@dbx-tools/projen 0.9.21 → 0.9.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -207
- package/index.ts +10 -14
- package/package.json +4 -4
- package/src/barrels.ts +1 -74
- package/src/module-exports.ts +175 -1
- package/src/openapi.ts +5 -72
- package/src/packages.ts +45 -0
- package/src/project-js.ts +3 -6
- package/src/project-predicate.ts +1 -2
- package/src/project-py.ts +82 -103
- package/src/project.ts +2 -2
- package/src/python-node-bindings.ts +138 -0
- package/src/python-node-bundle.ts +92 -0
- package/src/release-catalog.ts +3 -5
- package/src/{release-dispatch.ts → release-context.ts} +0 -11
- package/src/release.ts +70 -152
- package/tasks/bump.ts +12 -21
- package/tasks/databricks-cli-assets.ts +129 -0
- package/tasks/local-publish.ts +23 -107
- package/tasks/publish-npm.ts +10 -1
- package/tasks/publish-python.ts +26 -11
- package/tasks/publish.ts +12 -48
- package/tasks/python-node-bindings-watch.ts +47 -0
- package/tasks/python-node-bindings.ts +1017 -0
- package/tasks/python-release.ts +74 -0
- package/tasks/release.ts +99 -0
- package/tasks/sync.ts +13 -18
- package/tasks/version-check.ts +1 -28
- package/._LICENSE +0 -0
- package/._README.md +0 -0
- package/._index.ts +0 -0
- package/._package.json +0 -0
- package/src/.__lazy-require.ts +0 -0
- package/src/.__release-platform.ts +0 -0
- package/src/.__rust-project.ts +0 -0
- package/src/.__rust-release-workflow.ts +0 -0
- package/src/.__task-command.ts +0 -0
- package/src/._barrels.ts +0 -0
- package/src/._bun-app.ts +0 -0
- package/src/._bun-workflow.ts +0 -0
- package/src/._clean.ts +0 -0
- package/src/._codegen.ts +0 -0
- package/src/._dbx-tools-config.ts +0 -0
- package/src/._engine-root.ts +0 -0
- package/src/._generated.ts +0 -0
- package/src/._mixin.ts +0 -0
- package/src/._module-exports.ts +0 -0
- package/src/._openapi.ts +0 -0
- package/src/._packages.ts +0 -0
- package/src/._pnpm-workspace.ts +0 -0
- package/src/._project-js.ts +0 -0
- package/src/._project-predicate.ts +0 -0
- package/src/._project-py.ts +0 -0
- package/src/._project-rs.ts +0 -0
- package/src/._project.ts +0 -0
- package/src/._projen-version.ts +0 -0
- package/src/._publish.ts +0 -0
- package/src/._release-catalog.ts +0 -0
- package/src/._release-dispatch.ts +0 -0
- package/src/._release-github.ts +0 -0
- package/src/._release.ts +0 -0
- package/src/._scaffold.ts +0 -0
- package/src/._tags.ts +0 -0
- package/src/._tsconfig.ts +0 -0
- package/src/._uniffi.ts +0 -0
- package/src/._vscode.ts +0 -0
- package/src/._watch.ts +0 -0
- package/src/._workspace-lock.ts +0 -0
- package/src/._workspace-version.ts +0 -0
- package/src/_release-platform.ts +0 -78
- package/src/_rust-project.ts +0 -429
- package/src/_rust-release-workflow.ts +0 -311
- package/src/project-rs.ts +0 -1054
- package/src/release-github.ts +0 -109
- package/src/uniffi.ts +0 -65
- package/tasks/._barrels.ts +0 -0
- package/tasks/._bump.ts +0 -0
- package/tasks/._clean.ts +0 -0
- package/tasks/._compile-workspace.ts +0 -0
- package/tasks/._local-publish.ts +0 -0
- package/tasks/._openapi.ts +0 -0
- package/tasks/._projenrc.ts +0 -0
- package/tasks/._publish-npm.ts +0 -0
- package/tasks/._publish-python.ts +0 -0
- package/tasks/._publish-uniffi-local.ts +0 -0
- package/tasks/._publish.ts +0 -0
- package/tasks/._python-registry.ts +0 -0
- package/tasks/._release-assets.ts +0 -0
- package/tasks/._release-candidate.ts +0 -0
- package/tasks/._release-manifest.ts +0 -0
- package/tasks/._release-pr.ts +0 -0
- package/tasks/._release-summary.ts +0 -0
- package/tasks/._release-version.ts +0 -0
- package/tasks/._rust.ts +0 -0
- package/tasks/._sync.ts +0 -0
- package/tasks/._uniffi-python.d.ts +0 -0
- package/tasks/._uniffi-python.js +0 -0
- package/tasks/._uniffi-release.mjs +0 -0
- package/tasks/._uniffi.ts +0 -0
- package/tasks/._version-check.ts +0 -0
- package/tasks/publish-uniffi-local.ts +0 -359
- package/tasks/release-assets.ts +0 -467
- package/tasks/release-candidate.ts +0 -416
- package/tasks/release-manifest.ts +0 -273
- package/tasks/release-pr.ts +0 -589
- package/tasks/release-summary.ts +0 -379
- package/tasks/rust.ts +0 -173
- package/tasks/uniffi-python.d.ts +0 -60
- package/tasks/uniffi-python.js +0 -178
- package/tasks/uniffi-release.mjs +0 -579
- package/tasks/uniffi.ts +0 -262
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Shared Python release manifest parsing and dependency projection. */
|
|
2
|
+
|
|
3
|
+
const projectTable = (document: unknown): Record<string, unknown> => {
|
|
4
|
+
const project = (document as { project?: unknown })?.project;
|
|
5
|
+
if (!project || typeof project !== "object" || Array.isArray(project)) {
|
|
6
|
+
throw new Error("Missing Python project metadata");
|
|
7
|
+
}
|
|
8
|
+
return project as Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const directSibling = (
|
|
12
|
+
dependency: string,
|
|
13
|
+
sibling: { readonly directory: string; readonly name: string },
|
|
14
|
+
): boolean => {
|
|
15
|
+
const prefix = `${sibling.name} @ git+`;
|
|
16
|
+
if (!dependency.startsWith(prefix)) return false;
|
|
17
|
+
const marker = "#subdirectory=";
|
|
18
|
+
const markerIndex = dependency.indexOf(marker, prefix.length);
|
|
19
|
+
if (markerIndex < 0) return false;
|
|
20
|
+
const directory = dependency.slice(markerIndex + marker.length);
|
|
21
|
+
return directory === sibling.directory || directory.endsWith(`/${sibling.directory}`);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function pythonProjectInfo(
|
|
25
|
+
source: string,
|
|
26
|
+
toml: { parse(source: string): unknown },
|
|
27
|
+
): { name: string; version: string; private: boolean } {
|
|
28
|
+
const document = toml.parse(source) as { tool?: { "dbx-tools"?: { private?: boolean } } };
|
|
29
|
+
const project = projectTable(document);
|
|
30
|
+
if (typeof project.name !== "string" || !project.name) {
|
|
31
|
+
throw new Error("Missing Python project name");
|
|
32
|
+
}
|
|
33
|
+
if (typeof project.version !== "string" || !project.version) {
|
|
34
|
+
throw new Error("Missing Python project version");
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: project.name,
|
|
38
|
+
version: project.version,
|
|
39
|
+
private: document.tool?.["dbx-tools"]?.private === true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function preparePythonProjectForPublication(
|
|
44
|
+
source: string,
|
|
45
|
+
options: {
|
|
46
|
+
readonly packages: readonly { readonly directory: string; readonly name: string }[];
|
|
47
|
+
readonly toml: { parse(source: string): unknown; stringify(document: unknown): string };
|
|
48
|
+
readonly version: string;
|
|
49
|
+
},
|
|
50
|
+
): string {
|
|
51
|
+
const marker = source.startsWith("# ") ? source.slice(0, source.indexOf("\n")) : undefined;
|
|
52
|
+
const document = options.toml.parse(source);
|
|
53
|
+
const project = projectTable(document);
|
|
54
|
+
if (project.version !== options.version) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Python project version ${String(project.version)} does not match release ${options.version}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const dependencies = project.dependencies;
|
|
60
|
+
if (dependencies !== undefined && !Array.isArray(dependencies)) {
|
|
61
|
+
throw new Error("Python project dependencies must be an array");
|
|
62
|
+
}
|
|
63
|
+
if (dependencies) {
|
|
64
|
+
project.dependencies = dependencies.map((dependency) => {
|
|
65
|
+
if (typeof dependency !== "string") {
|
|
66
|
+
throw new Error("Python project dependencies must be strings");
|
|
67
|
+
}
|
|
68
|
+
const sibling = options.packages.find((candidate) => directSibling(dependency, candidate));
|
|
69
|
+
return sibling ? `${sibling.name}==${options.version}` : dependency;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const body = options.toml.stringify(document).trimEnd();
|
|
73
|
+
return `${marker ? `${marker}\n\n` : ""}${body}\n`;
|
|
74
|
+
}
|
package/tasks/release.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env -S bun
|
|
2
|
+
/** Run the configured release transaction. */
|
|
3
|
+
import * as projectUtils from "@dbx-tools/core/project-utils";
|
|
4
|
+
import { log } from "@dbx-tools/shared-core";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import {
|
|
7
|
+
captureGitTaskCommand,
|
|
8
|
+
gitTaskCommandSucceeds,
|
|
9
|
+
runGitTaskCommand,
|
|
10
|
+
runTaskCommand,
|
|
11
|
+
} from "../src/_task-command.ts";
|
|
12
|
+
import { assertReleaseVersion } from "./release-version.ts";
|
|
13
|
+
import { readWorkspaceVersion } from "../src/workspace-version.ts";
|
|
14
|
+
|
|
15
|
+
const logger = log.logger("projen:release");
|
|
16
|
+
|
|
17
|
+
export function runRelease(options: {
|
|
18
|
+
readonly root: string;
|
|
19
|
+
readonly branch: string;
|
|
20
|
+
readonly bump?: boolean;
|
|
21
|
+
readonly prefix: string;
|
|
22
|
+
readonly remote: string;
|
|
23
|
+
}): string {
|
|
24
|
+
const { branch, prefix, remote, root } = options;
|
|
25
|
+
const currentBranch = captureGitTaskCommand(root, ["branch", "--show-current"], { check: true });
|
|
26
|
+
if (currentBranch !== branch) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`release must run on ${branch}, current branch is ${currentBranch || "detached"}`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (options.bump ?? true) {
|
|
33
|
+
const status = captureGitTaskCommand(
|
|
34
|
+
root,
|
|
35
|
+
["status", "--porcelain=v1", "--untracked-files=all"],
|
|
36
|
+
{ check: true },
|
|
37
|
+
);
|
|
38
|
+
if (status) {
|
|
39
|
+
throw new Error("release with automatic bump requires a clean working tree");
|
|
40
|
+
}
|
|
41
|
+
runTaskCommand(root, "bun", ["run", "bump"]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const version = readWorkspaceVersion(root);
|
|
45
|
+
const tag = `${prefix}${version}`;
|
|
46
|
+
runGitTaskCommand(root, ["fetch", remote, branch, "--tags"]);
|
|
47
|
+
assertReleaseVersion(version, { root, prefixes: [prefix], assertNext: true });
|
|
48
|
+
|
|
49
|
+
if (gitTaskCommandSucceeds(root, ["rev-parse", "--verify", `refs/tags/${tag}`])) {
|
|
50
|
+
throw new Error(`release tag ${tag} already exists`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
runTaskCommand(root, "bun", ["run", "version:check"]);
|
|
54
|
+
const status = captureGitTaskCommand(
|
|
55
|
+
root,
|
|
56
|
+
["status", "--porcelain=v1", "--untracked-files=all"],
|
|
57
|
+
{ check: true },
|
|
58
|
+
);
|
|
59
|
+
if (status) {
|
|
60
|
+
if (gitTaskCommandSucceeds(root, ["diff", "--quiet", "HEAD", "--", "VERSION"])) {
|
|
61
|
+
throw new Error("release changes must include the local VERSION bump");
|
|
62
|
+
}
|
|
63
|
+
runGitTaskCommand(root, ["add", "--all"]);
|
|
64
|
+
runGitTaskCommand(root, ["commit", "-m", `chore(release): ${version}`]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const remoteHead = captureGitTaskCommand(root, ["rev-parse", `${remote}/${branch}`], {
|
|
68
|
+
check: true,
|
|
69
|
+
});
|
|
70
|
+
const head = captureGitTaskCommand(root, ["rev-parse", "HEAD"], { check: true });
|
|
71
|
+
if (!gitTaskCommandSucceeds(root, ["merge-base", "--is-ancestor", remoteHead, head])) {
|
|
72
|
+
throw new Error(`${branch} must contain ${remote}/${branch} before release`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
runGitTaskCommand(root, ["push", remote, `HEAD:${branch}`]);
|
|
76
|
+
runGitTaskCommand(root, ["tag", "--annotate", tag, "--message", tag]);
|
|
77
|
+
runGitTaskCommand(root, ["push", remote, `refs/tags/${tag}`]);
|
|
78
|
+
logger.success(`released ${tag}`, { sha: head });
|
|
79
|
+
return tag;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (import.meta.main) {
|
|
83
|
+
new Command()
|
|
84
|
+
.option("--root <path>", "repository root")
|
|
85
|
+
.option("--branch <name>", "release branch", "main")
|
|
86
|
+
.option("--prefix <prefix>", "release tag prefix", "v")
|
|
87
|
+
.option("--remote <name>", "git remote", "origin")
|
|
88
|
+
.option("--no-bump", "use an existing synchronized local version bump")
|
|
89
|
+
.action((options: { root?: string; branch: string; bump: boolean; prefix: string; remote: string }) => {
|
|
90
|
+
runRelease({
|
|
91
|
+
root: options.root ?? projectUtils.root() ?? process.cwd(),
|
|
92
|
+
branch: options.branch,
|
|
93
|
+
bump: options.bump,
|
|
94
|
+
prefix: options.prefix,
|
|
95
|
+
remote: options.remote,
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
.parse();
|
|
99
|
+
}
|
package/tasks/sync.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { log } from "@dbx-tools/shared-core";
|
|
4
4
|
import concurrently from "concurrently";
|
|
5
|
-
import {
|
|
5
|
+
import { pythonNodeBindingProjects, repoRoot } from "../src/packages.ts";
|
|
6
6
|
import { runSynth } from "../src/scaffold.ts";
|
|
7
7
|
import { withWorkspaceMutationLock } from "../src/workspace-lock.ts";
|
|
8
8
|
|
|
@@ -26,14 +26,13 @@ function taskPath(script: string): string {
|
|
|
26
26
|
return fileURLToPath(new URL(`./${script}`, import.meta.url));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
29
|
+
/** One restartable focused watcher managed by the sync supervisor. */
|
|
30
|
+
function watcher(script: string, name: string, prefixColor: string, ...args: string[]) {
|
|
31
|
+
return {
|
|
32
|
+
command: ["bun", JSON.stringify(taskPath(script)), ...args].join(" "),
|
|
33
|
+
name,
|
|
34
|
+
prefixColor,
|
|
35
|
+
};
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
if (!process.argv.includes("--watch")) {
|
|
@@ -65,16 +64,12 @@ if (!process.argv.includes("--watch")) {
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
const watchers = [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
watcher("projenrc.ts", "projenrc", "magenta"),
|
|
68
|
+
watcher("barrels.ts", "barrels", "cyan", "--watch"),
|
|
69
|
+
watcher("openapi.ts", "openapi", "green", "--watch"),
|
|
71
70
|
];
|
|
72
|
-
if (
|
|
73
|
-
watchers.push(
|
|
74
|
-
command: `bun "${taskPath("rust.ts")}" --watch`,
|
|
75
|
-
name: "rust",
|
|
76
|
-
prefixColor: "yellow",
|
|
77
|
-
});
|
|
71
|
+
if (pythonNodeBindingProjects(repoRoot).length > 0) {
|
|
72
|
+
watchers.push(watcher("python-node-bindings-watch.ts", "node-bindings", "blue"));
|
|
78
73
|
}
|
|
79
74
|
const { result } = concurrently(watchers, {
|
|
80
75
|
prefix: "name",
|
package/tasks/version-check.ts
CHANGED
|
@@ -4,9 +4,8 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import * as projectUtils from "@dbx-tools/core/project-utils";
|
|
6
6
|
import { find } from "@dbx-tools/path";
|
|
7
|
-
import { json, log
|
|
7
|
+
import { json, log } from "@dbx-tools/shared-core";
|
|
8
8
|
import { parse } from "smol-toml";
|
|
9
|
-
import { captureTaskCommand } from "../src/_task-command.ts";
|
|
10
9
|
import { recordedPackages } from "../src/packages.ts";
|
|
11
10
|
import { readWorkspaceVersion } from "../src/workspace-version.ts";
|
|
12
11
|
|
|
@@ -24,30 +23,6 @@ function pythonVersion(path: string): string | undefined {
|
|
|
24
23
|
return typeof manifest.project?.version === "string" ? manifest.project.version : undefined;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
function cargoVersions(root: string): Array<{ name: string; version: string }> {
|
|
28
|
-
if (!existsSync(join(root, "Cargo.toml"))) return [];
|
|
29
|
-
const locked = existsSync(join(root, "Cargo.lock"));
|
|
30
|
-
const metadata = json.parseRecord(
|
|
31
|
-
captureTaskCommand(
|
|
32
|
-
root,
|
|
33
|
-
"cargo",
|
|
34
|
-
["metadata", ...(locked ? ["--locked"] : []), "--format-version", "1", "--no-deps"],
|
|
35
|
-
{ check: true, stderr: "inherit" },
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
if (!Array.isArray(metadata?.packages)) return [];
|
|
39
|
-
return metadata.packages.flatMap((candidate) => {
|
|
40
|
-
if (
|
|
41
|
-
!object.isRecord(candidate) ||
|
|
42
|
-
typeof candidate.name !== "string" ||
|
|
43
|
-
typeof candidate.version !== "string"
|
|
44
|
-
) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
return [{ name: candidate.name, version: candidate.version }];
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
26
|
function main(): void {
|
|
52
27
|
const root = projectUtils.root() ?? process.cwd();
|
|
53
28
|
const version = readWorkspaceVersion(root);
|
|
@@ -71,8 +46,6 @@ function main(): void {
|
|
|
71
46
|
for (const path of find.findFiles("**/pyproject.toml", { cwd: root })) {
|
|
72
47
|
check(path, pythonVersion(join(root, path)));
|
|
73
48
|
}
|
|
74
|
-
for (const pkg of cargoVersions(root)) check(`Cargo package ${pkg.name}`, pkg.version);
|
|
75
|
-
|
|
76
49
|
if (mismatches.length > 0) {
|
|
77
50
|
throw new Error(`Workspace version mismatch:\n${mismatches.join("\n")}`);
|
|
78
51
|
}
|
package/._LICENSE
DELETED
|
Binary file
|
package/._README.md
DELETED
|
Binary file
|
package/._index.ts
DELETED
|
Binary file
|
package/._package.json
DELETED
|
Binary file
|
package/src/.__lazy-require.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/.__rust-project.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/.__task-command.ts
DELETED
|
Binary file
|
package/src/._barrels.ts
DELETED
|
Binary file
|
package/src/._bun-app.ts
DELETED
|
Binary file
|
package/src/._bun-workflow.ts
DELETED
|
Binary file
|
package/src/._clean.ts
DELETED
|
Binary file
|
package/src/._codegen.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/._engine-root.ts
DELETED
|
Binary file
|
package/src/._generated.ts
DELETED
|
Binary file
|
package/src/._mixin.ts
DELETED
|
Binary file
|
package/src/._module-exports.ts
DELETED
|
Binary file
|
package/src/._openapi.ts
DELETED
|
Binary file
|
package/src/._packages.ts
DELETED
|
Binary file
|
package/src/._pnpm-workspace.ts
DELETED
|
Binary file
|
package/src/._project-js.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/._project-py.ts
DELETED
|
Binary file
|
package/src/._project-rs.ts
DELETED
|
Binary file
|
package/src/._project.ts
DELETED
|
Binary file
|
package/src/._projen-version.ts
DELETED
|
Binary file
|
package/src/._publish.ts
DELETED
|
Binary file
|
package/src/._release-catalog.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/._release-github.ts
DELETED
|
Binary file
|
package/src/._release.ts
DELETED
|
Binary file
|
package/src/._scaffold.ts
DELETED
|
Binary file
|
package/src/._tags.ts
DELETED
|
Binary file
|
package/src/._tsconfig.ts
DELETED
|
Binary file
|
package/src/._uniffi.ts
DELETED
|
Binary file
|
package/src/._vscode.ts
DELETED
|
Binary file
|
package/src/._watch.ts
DELETED
|
Binary file
|
package/src/._workspace-lock.ts
DELETED
|
Binary file
|
|
Binary file
|
package/src/_release-platform.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Option } from "commander";
|
|
2
|
-
import type { VersionLevel } from "./workspace-version.ts";
|
|
3
|
-
|
|
4
|
-
/** Supported semantic version increments for release commands. */
|
|
5
|
-
export const RELEASE_LEVELS = [
|
|
6
|
-
"patch",
|
|
7
|
-
"minor",
|
|
8
|
-
"major",
|
|
9
|
-
] as const satisfies readonly VersionLevel[];
|
|
10
|
-
|
|
11
|
-
/** Supported release operating systems. */
|
|
12
|
-
export const RELEASE_OSES = ["darwin", "linux", "win32"] as const;
|
|
13
|
-
|
|
14
|
-
/** Supported release CPU architectures. */
|
|
15
|
-
export const RELEASE_ARCHES = ["arm64", "x64"] as const;
|
|
16
|
-
|
|
17
|
-
/** Release operating system selector. */
|
|
18
|
-
export type ReleaseOs = (typeof RELEASE_OSES)[number];
|
|
19
|
-
|
|
20
|
-
/** Release CPU architecture selector. */
|
|
21
|
-
export type ReleaseArch = (typeof RELEASE_ARCHES)[number];
|
|
22
|
-
|
|
23
|
-
export type { VersionLevel } from "./workspace-version.ts";
|
|
24
|
-
|
|
25
|
-
/** Stable archive name for one native release binary. */
|
|
26
|
-
export function releaseBinaryAssetName(
|
|
27
|
-
binaryName: string,
|
|
28
|
-
nodeTarget: string,
|
|
29
|
-
operatingSystem: ReleaseOs,
|
|
30
|
-
): string {
|
|
31
|
-
const extension = operatingSystem === "win32" ? "zip" : "tar.gz";
|
|
32
|
-
return `${binaryName}-${nodeTarget}.${extension}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function collectValue<T extends string>(value: T, previous: T[]): T[] {
|
|
36
|
-
return [...previous, value];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Commander option for selecting the semantic release increment. */
|
|
40
|
-
export function releaseLevelOption(): Option {
|
|
41
|
-
return new Option("-l, --level <level>", "semver increment")
|
|
42
|
-
.choices([...RELEASE_LEVELS])
|
|
43
|
-
.default("patch");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Repeatable Commander option for release operating systems. */
|
|
47
|
-
export function releaseOperatingSystemOption(): Option {
|
|
48
|
-
return new Option("--os <os>", "release operating system, repeatable; crossed with every --arch")
|
|
49
|
-
.choices([...RELEASE_OSES])
|
|
50
|
-
.argParser((value, previous: ReleaseOs[]) => collectValue(value as ReleaseOs, previous))
|
|
51
|
-
.default([] as ReleaseOs[]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Repeatable Commander option for release CPU architectures. */
|
|
55
|
-
export function releaseArchitectureOption(): Option {
|
|
56
|
-
return new Option(
|
|
57
|
-
"--arch <arch>",
|
|
58
|
-
"release CPU architecture, repeatable; crossed with every --os",
|
|
59
|
-
)
|
|
60
|
-
.choices([...RELEASE_ARCHES])
|
|
61
|
-
.argParser((value, previous: ReleaseArch[]) => collectValue(value as ReleaseArch, previous))
|
|
62
|
-
.default([] as ReleaseArch[]);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Cartesian-product release target filter shared by release commands. */
|
|
66
|
-
export function releasePlatformFilter(
|
|
67
|
-
operatingSystems: readonly string[],
|
|
68
|
-
architectures: readonly string[],
|
|
69
|
-
): string {
|
|
70
|
-
if ((operatingSystems.length === 0) !== (architectures.length === 0)) {
|
|
71
|
-
throw new Error("--os and --arch must be used together");
|
|
72
|
-
}
|
|
73
|
-
return operatingSystems
|
|
74
|
-
.flatMap((operatingSystem) =>
|
|
75
|
-
architectures.map((architecture) => `${operatingSystem}:${architecture}`),
|
|
76
|
-
)
|
|
77
|
-
.join(",");
|
|
78
|
-
}
|