Skip to content

Commit

Permalink
feat(ports): npmi (#31)
Browse files Browse the repository at this point in the history
* feat(ports): `npmi`

* feat(ports, cpy_bs): add param to change relaseTag for indygreg releases
  • Loading branch information
Yohe-Am authored Jan 9, 2024
1 parent 9c02081 commit 2f6169c
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 143 deletions.
38 changes: 28 additions & 10 deletions .ghjk/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@
"version": "v25.1",
"depConfigs": {},
"portRef": "[email protected]"
},
"c58811a17645c26b5a55a2de02f930945e04adf37e408846bf6b5c72bf707146": {
"version": "3.12.0",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"depConfigs": {},
"portRef": "[email protected]"
},
"zstd_aa": {
"version": "v1.5.5,",
"depConfigs": {},
"portRef": "[email protected]"
}
},
"portRef": "[email protected]",
"releaseTag": "20231002"
}
}
},
Expand Down Expand Up @@ -110,7 +127,7 @@
]
],
"version": "0.1.0",
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/act.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/act.ts"
}
},
{
Expand Down Expand Up @@ -189,7 +206,7 @@
"name": "cpy_bs_ghrel"
}
],
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/pipi.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/pipi.ts"
},
"packageName": "pre-commit"
},
Expand Down Expand Up @@ -232,8 +249,9 @@
"name": "zstd_aa"
}
],
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/cpy_bs.ts"
}
"moduleSpecifier": "file:///data/home/ghjk/ports/cpy_bs.ts"
},
"releaseTag": "20231002"
}
],
"allowedDeps": {
Expand Down Expand Up @@ -524,7 +542,7 @@
]
],
"version": "0.1.0",
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/cargo-binstall.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/cargo-binstall.ts"
},
"defaultInst": {
"portRef": "[email protected]"
Expand Down Expand Up @@ -561,7 +579,7 @@
]
],
"version": "0.1.0",
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/pnpm.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/pnpm.ts"
},
"defaultInst": {
"portRef": "[email protected]"
Expand Down Expand Up @@ -608,7 +626,7 @@
"name": "git_aa"
}
],
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/asdf_plugin_git.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/asdf_plugin_git.ts"
},
"defaultInst": {
"portRef": "[email protected]"
Expand Down Expand Up @@ -650,7 +668,7 @@
"name": "tar_aa"
}
],
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/node.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/node.ts"
},
"defaultInst": {
"portRef": "[email protected]"
Expand Down Expand Up @@ -695,7 +713,7 @@
"name": "zstd_aa"
}
],
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/cpy_bs.ts"
"moduleSpecifier": "file:///data/home/ghjk/ports/cpy_bs.ts"
},
"defaultInst": {
"portRef": "[email protected]"
Expand Down Expand Up @@ -727,7 +745,7 @@
"ty": "denoWorker@v1",
"name": "protoc_ghrel",
"version": "0.1.0",
"moduleSpecifier": "file:///home/asdf/repos/ecma/ghjk/ports/protoc.ts",
"moduleSpecifier": "file:///data/home/ghjk/ports/protoc.ts",
"platforms": [
[
"linux",
Expand Down
11 changes: 11 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions ghjk.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export { ghjk } from "./mod.ts";
import * as ghjk from "./mod.ts";
import act from "./ports/act.ts";
import protoc from "./ports/protoc.ts";

import pipi from "./ports/pipi.ts";
import { act, cpy_bs, pipi, protoc } from "./ports/mod.ts";

ghjk
.task("greet", {
Expand Down Expand Up @@ -63,7 +60,8 @@ ghjk.install();
// these are used for developing ghjk
ghjk.install(
act(),
...pipi({ packageName: "pre-commit" }),
pipi({ packageName: "pre-commit" })[0],
cpy_bs({ releaseTag: "20231002" }),
);

export const secureConfig = ghjk.secureConfig({
Expand Down
64 changes: 37 additions & 27 deletions ports/cpy_bs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
osXarch,
PortBase,
std_fs,
zod,
} from "../port.ts";
import type {
DownloadArgs,
Expand All @@ -39,8 +40,17 @@ export const manifest = {
platforms: osXarch(["linux", "darwin", "windows"], ["x86_64", "aarch64"]),
};

const confValidator = zod.object({
releaseTag: zod.string().nullish(),
}).passthrough();

export type CpythonBsInstallConf =
& InstallConfigSimple
& GithubReleasesInstConf
& zod.input<typeof confValidator>;

export default function conf(
config: InstallConfigSimple & GithubReleasesInstConf = {},
config: CpythonBsInstallConf = {},
) {
return {
...readGhVars(),
Expand All @@ -66,9 +76,8 @@ export class Port extends PortBase {
return defaultLatestStable(this, args);
}

async listAll(args: ListAllArgs) {
const headers = ghHeaders(args.config);
const latestMeta = await $.withRetries({
async latestMeta(headers: Record<string, string>) {
const meta = await $.withRetries({
count: 10,
delay: exponentialBackoff(1000),
action: async () =>
Expand All @@ -83,14 +92,31 @@ export class Port extends PortBase {
"asset_url_prefix": string;
},
});
if (meta.version != 1) {
throw new Error(
`${this.repoOwner}/${this.repoName} have changed their latest release tag json version`,
{ cause: meta },
);
}
return meta;
}

async listAll(args: ListAllArgs) {
const headers = ghHeaders(args.config);
const conf = confValidator.parse(args.config);
let tag = conf.releaseTag;
if (!tag) {
const latestMeta = await this.latestMeta(headers);
tag = latestMeta.tag;
}
// python-build-standalone builds all supported versions of python
// on every release
const metadata = await $.withRetries({
count: 10,
delay: exponentialBackoff(1000),
action: async () =>
await $.request(
`https://api.github.com/repos/${this.repoOwner}/${this.repoName}/releases/tags/${latestMeta.tag}`,
`https://api.github.com/repos/${this.repoOwner}/${this.repoName}/releases/tags/${tag}`,
)
.header(headers)
.json() as {
Expand All @@ -113,27 +139,11 @@ export class Port extends PortBase {

async download(args: DownloadArgs) {
const headers = ghHeaders(args.config);
const latestMeta = await $.withRetries({
count: 10,
delay: exponentialBackoff(1000),
action: async () =>
await $.request(
`https://raw.githubusercontent.com/${this.repoOwner}/${this.repoName}/latest-release/latest-release.json`,
)
.header(headers)
.json() as {
"version": number;
"tag": string;
"release_url": string;
"asset_url_prefix": string;
},
});
if (latestMeta.version != 1) {
throw new Error(
`${this.repoOwner}/${this.repoName} have changed their latest release tag json version ${
$.inspect(latestMeta)
}`,
);
const conf = confValidator.parse(args.config);
let tag = conf.releaseTag;
if (!tag) {
const latestMeta = await this.latestMeta(headers);
tag = latestMeta.tag;
}
const { installVersion, platform } = args;
const arch = platform.arch;
Expand All @@ -155,7 +165,7 @@ export class Port extends PortBase {
throw new Error(`unsupported: ${platform}`);
}
const urls = [
`${latestMeta.asset_url_prefix}/cpython-${installVersion}+${latestMeta.tag}-${arch}-${os}-pgo+lto-full.tar.zst`,
`https://github.com/${this.repoOwner}/${this.repoName}/releases/download/${tag}/cpython-${installVersion}+${tag}-${arch}-${os}-pgo+lto-full.tar.zst`,
];
await Promise.all(
urls.map(dwnUrlOut)
Expand Down
91 changes: 0 additions & 91 deletions ports/jco.ts

This file was deleted.

2 changes: 1 addition & 1 deletion ports/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export { default as curl } from "../ports/curl.ts";
export { default as earthly } from "../ports/earthly.ts";
export { default as git } from "../ports/git.ts";
export { default as infisical } from "../ports/infisical.ts";
export { default as jco } from "../ports/jco.ts";
export { default as mold } from "../ports/mold.ts";
export { default as node } from "../ports/node.ts";
export { default as npmi } from "../ports/npmi.ts";
export { default as pipi } from "../ports/pipi.ts";
export { default as pnpm } from "../ports/pnpm.ts";
export { default as protoc } from "../ports/protoc.ts";
Expand Down
Loading

0 comments on commit 2f6169c

Please sign in to comment.