@doki-land/nifty 0.0.3 → 0.0.5
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/cli/nifty.mjs +11 -11
- package/locales/en-US/cli.json +68 -68
- package/locales/locales.json +4 -4
- package/package.json +16 -20
- package/src/cli/authArgs.ts +52 -52
- package/src/cli/bump-cmd.ts +55 -55
- package/src/cli/bump.ts +237 -237
- package/src/cli/change-logs-cmd.ts +97 -97
- package/src/cli/cli.ts +47 -47
- package/src/cli/context.ts +36 -36
- package/src/cli/format-cmd.ts +23 -23
- package/src/cli/format.ts +28 -28
- package/src/cli/index.ts +9 -9
- package/src/cli/install-native-cmd.ts +22 -22
- package/src/cli/install-native.ts +80 -80
- package/src/cli/lint-cmd.ts +35 -35
- package/src/cli/lint.ts +102 -102
- package/src/cli/main.ts +1 -1
- package/src/cli/options.ts +40 -40
- package/src/cli/publish-cmd.ts +38 -38
- package/src/cli/publish.ts +95 -95
- package/src/cli/resolveNpm.ts +16 -16
- package/src/cli/retime-cmd.ts +62 -62
- package/src/cli/reword-cmd.ts +87 -87
- package/src/cli/trust-cmd.ts +38 -38
- package/src/cli/trust.ts +83 -83
- package/src/cli/update-cmd.ts +20 -20
- package/src/cli/update.ts +32 -32
- package/src/cli/upload-cmd.ts +44 -44
- package/src/cli/upload.ts +313 -313
- package/src/cli/workspace.ts +124 -124
- package/src/config/defineConfig.ts +12 -12
- package/src/config/detectProject.ts +189 -189
- package/src/config/index.ts +25 -25
- package/src/config/loadConfig.ts +129 -129
- package/src/config/types.ts +57 -57
- package/src/git.ts +61 -61
- package/src/github.ts +184 -184
- package/src/gitmoji.ts +77 -77
- package/src/index.ts +36 -36
- package/src/native.ts +665 -665
- package/src/nifty.ts +95 -95
- package/src/types.ts +40 -40
- package/README.md +0 -29
package/cli/nifty.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { createJiti } from "jiti";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
9
|
-
const { runCli } = await jiti.import(join(here, "../src/cli/main.ts"));
|
|
10
|
-
|
|
11
|
-
process.exit(await runCli(process.argv.slice(2)));
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createJiti } from "jiti";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
9
|
+
const { runCli } = await jiti.import(join(here, "../src/cli/main.ts"));
|
|
10
|
+
|
|
11
|
+
process.exit(await runCli(process.argv.slice(2)));
|
package/locales/en-US/cli.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cli.intro": "nifty — gitmoji-first release tooling for hybrid cargo + npm workspaces",
|
|
3
|
-
"cli.cmd.update": "Update Cargo and npm/pnpm dependencies",
|
|
4
|
-
"cli.cmd.format": "Format Rust with cargo fmt and JS/TS/JSON with oxc_formatter",
|
|
5
|
-
"cli.cmd.lint": "Lint commit subjects and cargo workspace hygiene",
|
|
6
|
-
"cli.cmd.check": "Lint commit subjects, cargo workspace hygiene, and fail on errors",
|
|
7
|
-
"cli.cmd.upload": "Upload generic assets to GitHub Release or GitHub Pages",
|
|
8
|
-
"cli.cmd.install-native": "Stage matrix .node artifacts into platform npm packages",
|
|
9
|
-
"cli.cmd.bump": "Align workspace crate and package versions",
|
|
10
|
-
"cli.cmd.publish": "Publish workspace npm packages (OIDC or token + TOTP)",
|
|
11
|
-
"cli.cmd.trust": "Configure npm Trusted Publisher for workspace packages",
|
|
12
|
-
"cli.cmd.reword": "Rewrite commit messages at the git object layer",
|
|
13
|
-
"cli.cmd.reword.export": "Export a JSON reword map template",
|
|
14
|
-
"cli.cmd.reword.rewrite": "Rewrite commits from a JSON map and update the branch ref",
|
|
15
|
-
"cli.cmd.retime": "Spread commit timestamps across a date range on a new branch",
|
|
16
|
-
"cli.cmd.retime.root": "Retime all commits from repository root through tip",
|
|
17
|
-
"cli.cmd.change-logs": "Draft release reference changelogs from git tags",
|
|
18
|
-
"cli.cmd.change-logs.lookup": "Look up GitHub user id/login from email or login",
|
|
19
|
-
"cli.opt.cwd": "Working directory",
|
|
20
|
-
"cli.opt.interactive": "Prompt before applying dependency updates",
|
|
21
|
-
"cli.opt.from": "Start git ref for commit range",
|
|
22
|
-
"cli.opt.to": "End git ref for commit range",
|
|
23
|
-
"cli.opt.subject": "Lint a single subject string (repeatable)",
|
|
24
|
-
"cli.opt.no-cargo": "Skip cargo workspace hygiene rules from cargo cry",
|
|
25
|
-
"cli.opt.release": "Upload files from --dir to the GitHub Release for --tag",
|
|
26
|
-
"cli.opt.pages": "Push --dir to gh-pages",
|
|
27
|
-
"cli.opt.both": "GitHub Release upload and GitHub Pages deploy",
|
|
28
|
-
"cli.opt.dir": "Directory tree for --release/--pages",
|
|
29
|
-
"cli.opt.from-artifacts": "Downloaded CI artifact root (default: native-artifacts or NATIVE_ARTIFACT_ROOT)",
|
|
30
|
-
"cli.opt.tag": "Git tag name (e.g. v0.0.1)",
|
|
31
|
-
"cli.opt.repo": "GitHub repo owner/name",
|
|
32
|
-
"cli.opt.token": "GitHub or npm token",
|
|
33
|
-
"cli.opt.name": "GitHub Release title",
|
|
34
|
-
"cli.opt.notes": "Release notes body",
|
|
35
|
-
"cli.opt.notes-file": "Read release notes from file",
|
|
36
|
-
"cli.opt.draft": "Create a draft GitHub Release",
|
|
37
|
-
"cli.opt.no-generate-notes": "Skip auto-generated release notes",
|
|
38
|
-
"cli.opt.github-action": "Read GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_REF_NAME",
|
|
39
|
-
"cli.opt.check": "Check formatting without writing files",
|
|
40
|
-
"cli.opt.dry-run": "Print actions without writing or publishing",
|
|
41
|
-
"cli.opt.refresh": "Ignore publish/trust cache and re-check registry",
|
|
42
|
-
"cli.opt.version": "Explicit semver target version",
|
|
43
|
-
"cli.opt.patch": "Bump patch segment",
|
|
44
|
-
"cli.opt.minor": "Bump minor segment",
|
|
45
|
-
"cli.opt.major": "Bump major segment",
|
|
46
|
-
"cli.opt.access": "npm publish --access",
|
|
47
|
-
"cli.opt.only": "Limit trust to one package name",
|
|
48
|
-
"cli.opt.package": "Publish only this workspace package (repeatable)",
|
|
49
|
-
"cli.opt.otp": "One-time npm password (6 digits)",
|
|
50
|
-
"cli.opt.totp-secret": "Base32 TOTP secret (overrides env)",
|
|
51
|
-
"cli.opt.npm-token": "npm auth token (overrides NPM_TOKEN)",
|
|
52
|
-
"cli.opt.base": "Exclusive range start commit (e.g. 34e1e665^)",
|
|
53
|
-
"cli.opt.ref": "Branch ref to rewrite (default: HEAD)",
|
|
54
|
-
"cli.opt.path": "Path to reword JSON map (default: reword.pending.json)",
|
|
55
|
-
"cli.opt.start-date": "Random window start (YYYY-MM-DD or ISO datetime)",
|
|
56
|
-
"cli.opt.end-date": "Random window end",
|
|
57
|
-
"cli.opt.branch": "Output branch name (default: time-travel)",
|
|
58
|
-
"cli.opt.tip": "Range end revision (default: HEAD)",
|
|
59
|
-
"cli.opt.message": "Optional new message for the root commit (retime root)",
|
|
60
|
-
"cli.opt.write": "Write documentation/maintenance/releases/vX.Y.Z.reference.md",
|
|
61
|
-
"cli.opt.tags": "List version tags with short hashes",
|
|
62
|
-
"cli.opt.author-map": "Path to author-github.json",
|
|
63
|
-
"cli.opt.releases-dir": "Releases directory for --write",
|
|
64
|
-
"cli.opt.email": "Author email to resolve",
|
|
65
|
-
"cli.opt.login": "GitHub login to resolve",
|
|
66
|
-
"cli.opt.github-token": "GitHub token for search-by-email",
|
|
67
|
-
"cli.opt.fetch": "Fetch missing numeric id from GitHub API"
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"cli.intro": "nifty — gitmoji-first release tooling for hybrid cargo + npm workspaces",
|
|
3
|
+
"cli.cmd.update": "Update Cargo and npm/pnpm dependencies",
|
|
4
|
+
"cli.cmd.format": "Format Rust with cargo fmt and JS/TS/JSON with oxc_formatter",
|
|
5
|
+
"cli.cmd.lint": "Lint commit subjects and cargo workspace hygiene",
|
|
6
|
+
"cli.cmd.check": "Lint commit subjects, cargo workspace hygiene, and fail on errors",
|
|
7
|
+
"cli.cmd.upload": "Upload generic assets to GitHub Release or GitHub Pages",
|
|
8
|
+
"cli.cmd.install-native": "Stage matrix .node artifacts into platform npm packages",
|
|
9
|
+
"cli.cmd.bump": "Align workspace crate and package versions",
|
|
10
|
+
"cli.cmd.publish": "Publish workspace npm packages (OIDC or token + TOTP)",
|
|
11
|
+
"cli.cmd.trust": "Configure npm Trusted Publisher for workspace packages",
|
|
12
|
+
"cli.cmd.reword": "Rewrite commit messages at the git object layer",
|
|
13
|
+
"cli.cmd.reword.export": "Export a JSON reword map template",
|
|
14
|
+
"cli.cmd.reword.rewrite": "Rewrite commits from a JSON map and update the branch ref",
|
|
15
|
+
"cli.cmd.retime": "Spread commit timestamps across a date range on a new branch",
|
|
16
|
+
"cli.cmd.retime.root": "Retime all commits from repository root through tip",
|
|
17
|
+
"cli.cmd.change-logs": "Draft release reference changelogs from git tags",
|
|
18
|
+
"cli.cmd.change-logs.lookup": "Look up GitHub user id/login from email or login",
|
|
19
|
+
"cli.opt.cwd": "Working directory",
|
|
20
|
+
"cli.opt.interactive": "Prompt before applying dependency updates",
|
|
21
|
+
"cli.opt.from": "Start git ref for commit range",
|
|
22
|
+
"cli.opt.to": "End git ref for commit range",
|
|
23
|
+
"cli.opt.subject": "Lint a single subject string (repeatable)",
|
|
24
|
+
"cli.opt.no-cargo": "Skip cargo workspace hygiene rules from cargo cry",
|
|
25
|
+
"cli.opt.release": "Upload files from --dir to the GitHub Release for --tag",
|
|
26
|
+
"cli.opt.pages": "Push --dir to gh-pages",
|
|
27
|
+
"cli.opt.both": "GitHub Release upload and GitHub Pages deploy",
|
|
28
|
+
"cli.opt.dir": "Directory tree for --release/--pages",
|
|
29
|
+
"cli.opt.from-artifacts": "Downloaded CI artifact root (default: native-artifacts or NATIVE_ARTIFACT_ROOT)",
|
|
30
|
+
"cli.opt.tag": "Git tag name (e.g. v0.0.1)",
|
|
31
|
+
"cli.opt.repo": "GitHub repo owner/name",
|
|
32
|
+
"cli.opt.token": "GitHub or npm token",
|
|
33
|
+
"cli.opt.name": "GitHub Release title",
|
|
34
|
+
"cli.opt.notes": "Release notes body",
|
|
35
|
+
"cli.opt.notes-file": "Read release notes from file",
|
|
36
|
+
"cli.opt.draft": "Create a draft GitHub Release",
|
|
37
|
+
"cli.opt.no-generate-notes": "Skip auto-generated release notes",
|
|
38
|
+
"cli.opt.github-action": "Read GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_REF_NAME",
|
|
39
|
+
"cli.opt.check": "Check formatting without writing files",
|
|
40
|
+
"cli.opt.dry-run": "Print actions without writing or publishing",
|
|
41
|
+
"cli.opt.refresh": "Ignore publish/trust cache and re-check registry",
|
|
42
|
+
"cli.opt.version": "Explicit semver target version",
|
|
43
|
+
"cli.opt.patch": "Bump patch segment",
|
|
44
|
+
"cli.opt.minor": "Bump minor segment",
|
|
45
|
+
"cli.opt.major": "Bump major segment",
|
|
46
|
+
"cli.opt.access": "npm publish --access",
|
|
47
|
+
"cli.opt.only": "Limit trust to one package name",
|
|
48
|
+
"cli.opt.package": "Publish only this workspace package (repeatable)",
|
|
49
|
+
"cli.opt.otp": "One-time npm password (6 digits)",
|
|
50
|
+
"cli.opt.totp-secret": "Base32 TOTP secret (overrides env)",
|
|
51
|
+
"cli.opt.npm-token": "npm auth token (overrides NPM_TOKEN)",
|
|
52
|
+
"cli.opt.base": "Exclusive range start commit (e.g. 34e1e665^)",
|
|
53
|
+
"cli.opt.ref": "Branch ref to rewrite (default: HEAD)",
|
|
54
|
+
"cli.opt.path": "Path to reword JSON map (default: reword.pending.json)",
|
|
55
|
+
"cli.opt.start-date": "Random window start (YYYY-MM-DD or ISO datetime)",
|
|
56
|
+
"cli.opt.end-date": "Random window end",
|
|
57
|
+
"cli.opt.branch": "Output branch name (default: time-travel)",
|
|
58
|
+
"cli.opt.tip": "Range end revision (default: HEAD)",
|
|
59
|
+
"cli.opt.message": "Optional new message for the root commit (retime root)",
|
|
60
|
+
"cli.opt.write": "Write documentation/maintenance/releases/vX.Y.Z.reference.md",
|
|
61
|
+
"cli.opt.tags": "List version tags with short hashes",
|
|
62
|
+
"cli.opt.author-map": "Path to author-github.json",
|
|
63
|
+
"cli.opt.releases-dir": "Releases directory for --write",
|
|
64
|
+
"cli.opt.email": "Author email to resolve",
|
|
65
|
+
"cli.opt.login": "GitHub login to resolve",
|
|
66
|
+
"cli.opt.github-token": "GitHub token for search-by-email",
|
|
67
|
+
"cli.opt.fetch": "Fetch missing numeric id from GitHub API"
|
|
68
|
+
}
|
package/locales/locales.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"defaultLocale": "en-US",
|
|
3
|
-
"locales": [{ "id": "en-US", "label": "English", "direction": "ltr" }]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"defaultLocale": "en-US",
|
|
3
|
+
"locales": [{ "id": "en-US", "label": "English", "direction": "ltr" }]
|
|
4
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"name": "@doki-land/nifty",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "Gitmoji-first commit conventions and release helpers (Node-API + TypeScript)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MPL-2.0",
|
|
2
7
|
"bin": {
|
|
3
8
|
"nifty": "cli/nifty.mjs"
|
|
4
9
|
},
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@vmz/commander": "^0.2.0",
|
|
7
|
-
"jiti": "^2.4.2"
|
|
8
|
-
},
|
|
9
|
-
"description": "Gitmoji-first commit conventions and release helpers (Node-API + TypeScript)",
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"@types/node": "^22.13.10",
|
|
12
|
-
"typescript": "^5.8.3"
|
|
13
|
-
},
|
|
14
10
|
"exports": {
|
|
15
11
|
".": "./src/index.ts",
|
|
16
12
|
"./cli": "./src/cli/index.ts"
|
|
@@ -20,12 +16,17 @@
|
|
|
20
16
|
"locales",
|
|
21
17
|
"src"
|
|
22
18
|
],
|
|
23
|
-
"
|
|
24
|
-
|
|
19
|
+
"scripts": {
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@vmz/commander": "^0.2.0",
|
|
24
|
+
"jiti": "^2.4.2"
|
|
25
|
+
},
|
|
25
26
|
"optionalDependencies": {
|
|
26
|
-
"@doki-land/nifty-
|
|
27
|
-
"@doki-land/nifty-linux-x64": "0.0.
|
|
28
|
-
"@doki-land/nifty-
|
|
27
|
+
"@doki-land/nifty-win32-x64": "0.0.5",
|
|
28
|
+
"@doki-land/nifty-linux-x64": "0.0.5",
|
|
29
|
+
"@doki-land/nifty-darwin-arm64": "0.0.5"
|
|
29
30
|
},
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|
|
@@ -33,10 +34,5 @@
|
|
|
33
34
|
"repository": {
|
|
34
35
|
"type": "git",
|
|
35
36
|
"url": "git+https://github.com/oovm/npm-tools.git"
|
|
36
|
-
}
|
|
37
|
-
"scripts": {
|
|
38
|
-
"typecheck": "tsc --noEmit"
|
|
39
|
-
},
|
|
40
|
-
"type": "module",
|
|
41
|
-
"version": "0.0.3"
|
|
37
|
+
}
|
|
42
38
|
}
|
package/src/cli/authArgs.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { resolveNpmExecutable } from "./resolveNpm.js";
|
|
2
|
-
|
|
3
|
-
export type AuthCliOptions = {
|
|
4
|
-
otp?: string;
|
|
5
|
-
totpSecret?: string;
|
|
6
|
-
token?: string;
|
|
7
|
-
npm: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function parseAuthArgs(argv: string[]): AuthCliOptions {
|
|
11
|
-
let otp: string | undefined;
|
|
12
|
-
let totpSecret: string | undefined;
|
|
13
|
-
let token: string | undefined;
|
|
14
|
-
|
|
15
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
16
|
-
const arg = argv[i];
|
|
17
|
-
if (arg === "--otp") {
|
|
18
|
-
otp = argv[++i];
|
|
19
|
-
} else if (arg === "--totp-secret") {
|
|
20
|
-
totpSecret = argv[++i];
|
|
21
|
-
} else if (arg === "--token") {
|
|
22
|
-
token = argv[++i];
|
|
23
|
-
} else if (arg.startsWith("--otp=")) {
|
|
24
|
-
otp = arg.slice("--otp=".length);
|
|
25
|
-
} else if (arg.startsWith("--totp-secret=")) {
|
|
26
|
-
totpSecret = arg.slice("--totp-secret=".length);
|
|
27
|
-
} else if (arg.startsWith("--token=")) {
|
|
28
|
-
token = arg.slice("--token=".length);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
otp,
|
|
34
|
-
totpSecret,
|
|
35
|
-
token,
|
|
36
|
-
npm: resolveNpmExecutable(),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function authPayload(options: AuthCliOptions): {
|
|
41
|
-
otp?: string;
|
|
42
|
-
totpSecret?: string;
|
|
43
|
-
token?: string;
|
|
44
|
-
npm: string;
|
|
45
|
-
} {
|
|
46
|
-
return {
|
|
47
|
-
...(options.otp !== undefined ? { otp: options.otp } : {}),
|
|
48
|
-
...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
|
|
49
|
-
...(options.token !== undefined ? { token: options.token } : {}),
|
|
50
|
-
npm: options.npm,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
1
|
+
import { resolveNpmExecutable } from "./resolveNpm.js";
|
|
2
|
+
|
|
3
|
+
export type AuthCliOptions = {
|
|
4
|
+
otp?: string;
|
|
5
|
+
totpSecret?: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
npm: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function parseAuthArgs(argv: string[]): AuthCliOptions {
|
|
11
|
+
let otp: string | undefined;
|
|
12
|
+
let totpSecret: string | undefined;
|
|
13
|
+
let token: string | undefined;
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
16
|
+
const arg = argv[i];
|
|
17
|
+
if (arg === "--otp") {
|
|
18
|
+
otp = argv[++i];
|
|
19
|
+
} else if (arg === "--totp-secret") {
|
|
20
|
+
totpSecret = argv[++i];
|
|
21
|
+
} else if (arg === "--token") {
|
|
22
|
+
token = argv[++i];
|
|
23
|
+
} else if (arg.startsWith("--otp=")) {
|
|
24
|
+
otp = arg.slice("--otp=".length);
|
|
25
|
+
} else if (arg.startsWith("--totp-secret=")) {
|
|
26
|
+
totpSecret = arg.slice("--totp-secret=".length);
|
|
27
|
+
} else if (arg.startsWith("--token=")) {
|
|
28
|
+
token = arg.slice("--token=".length);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
otp,
|
|
34
|
+
totpSecret,
|
|
35
|
+
token,
|
|
36
|
+
npm: resolveNpmExecutable(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function authPayload(options: AuthCliOptions): {
|
|
41
|
+
otp?: string;
|
|
42
|
+
totpSecret?: string;
|
|
43
|
+
token?: string;
|
|
44
|
+
npm: string;
|
|
45
|
+
} {
|
|
46
|
+
return {
|
|
47
|
+
...(options.otp !== undefined ? { otp: options.otp } : {}),
|
|
48
|
+
...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
|
|
49
|
+
...(options.token !== undefined ? { token: options.token } : {}),
|
|
50
|
+
npm: options.npm,
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/cli/bump-cmd.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
-
|
|
3
|
-
import { bumpWorkspace, printBumpReport, type BumpKind, type BumpOptions } from "./bump.js";
|
|
4
|
-
import { bootstrapFromOptions } from "./context.js";
|
|
5
|
-
import { cwdFrom, flag, str } from "./options.js";
|
|
6
|
-
|
|
7
|
-
export function registerBumpCommand(cli: Cli): void {
|
|
8
|
-
cli.command("bump", "cli.cmd.bump")
|
|
9
|
-
.option("--dry-run", "cli.opt.dry-run")
|
|
10
|
-
.option("--version, -v <version>", "cli.opt.version")
|
|
11
|
-
.option("--patch", "cli.opt.patch")
|
|
12
|
-
.option("--minor", "cli.opt.minor")
|
|
13
|
-
.option("--major", "cli.opt.major")
|
|
14
|
-
.action(async (options) => cmdBump(options));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function cmdBump(options: ParsedOptions): Promise<number> {
|
|
18
|
-
await bootstrapFromOptions(options);
|
|
19
|
-
const bumpOptions = bumpOptionsFromParsed(options);
|
|
20
|
-
const report = bumpWorkspace(bumpOptions);
|
|
21
|
-
printBumpReport(report, bumpOptions.dryRun);
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function bumpOptionsFromParsed(options: ParsedOptions): BumpOptions {
|
|
26
|
-
let version = str(options, "version");
|
|
27
|
-
let kind: BumpKind = "patch";
|
|
28
|
-
if (flag(options, "major")) {
|
|
29
|
-
kind = "major";
|
|
30
|
-
} else if (flag(options, "minor")) {
|
|
31
|
-
kind = "minor";
|
|
32
|
-
} else if (flag(options, "patch")) {
|
|
33
|
-
kind = "patch";
|
|
34
|
-
}
|
|
35
|
-
for (const positional of options._) {
|
|
36
|
-
if (isBumpKind(positional)) {
|
|
37
|
-
kind = positional;
|
|
38
|
-
} else if (positional) {
|
|
39
|
-
version = positional;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (version && !/^\d+\.\d+\.\d+(-[\w.-]+)?$/.test(version)) {
|
|
43
|
-
throw new Error(`invalid version ${version}, expected semver like 0.0.0`);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
version,
|
|
47
|
-
kind,
|
|
48
|
-
cwd: cwdFrom(options),
|
|
49
|
-
dryRun: flag(options, "dry-run"),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function isBumpKind(value: string): value is BumpKind {
|
|
54
|
-
return value === "patch" || value === "minor" || value === "major";
|
|
55
|
-
}
|
|
1
|
+
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
+
|
|
3
|
+
import { bumpWorkspace, printBumpReport, type BumpKind, type BumpOptions } from "./bump.js";
|
|
4
|
+
import { bootstrapFromOptions } from "./context.js";
|
|
5
|
+
import { cwdFrom, flag, str } from "./options.js";
|
|
6
|
+
|
|
7
|
+
export function registerBumpCommand(cli: Cli): void {
|
|
8
|
+
cli.command("bump", "cli.cmd.bump")
|
|
9
|
+
.option("--dry-run", "cli.opt.dry-run")
|
|
10
|
+
.option("--version, -v <version>", "cli.opt.version")
|
|
11
|
+
.option("--patch", "cli.opt.patch")
|
|
12
|
+
.option("--minor", "cli.opt.minor")
|
|
13
|
+
.option("--major", "cli.opt.major")
|
|
14
|
+
.action(async (options) => cmdBump(options));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function cmdBump(options: ParsedOptions): Promise<number> {
|
|
18
|
+
await bootstrapFromOptions(options);
|
|
19
|
+
const bumpOptions = bumpOptionsFromParsed(options);
|
|
20
|
+
const report = bumpWorkspace(bumpOptions);
|
|
21
|
+
printBumpReport(report, bumpOptions.dryRun);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function bumpOptionsFromParsed(options: ParsedOptions): BumpOptions {
|
|
26
|
+
let version = str(options, "version");
|
|
27
|
+
let kind: BumpKind = "patch";
|
|
28
|
+
if (flag(options, "major")) {
|
|
29
|
+
kind = "major";
|
|
30
|
+
} else if (flag(options, "minor")) {
|
|
31
|
+
kind = "minor";
|
|
32
|
+
} else if (flag(options, "patch")) {
|
|
33
|
+
kind = "patch";
|
|
34
|
+
}
|
|
35
|
+
for (const positional of options._) {
|
|
36
|
+
if (isBumpKind(positional)) {
|
|
37
|
+
kind = positional;
|
|
38
|
+
} else if (positional) {
|
|
39
|
+
version = positional;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (version && !/^\d+\.\d+\.\d+(-[\w.-]+)?$/.test(version)) {
|
|
43
|
+
throw new Error(`invalid version ${version}, expected semver like 0.0.0`);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
version,
|
|
47
|
+
kind,
|
|
48
|
+
cwd: cwdFrom(options),
|
|
49
|
+
dryRun: flag(options, "dry-run"),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isBumpKind(value: string): value is BumpKind {
|
|
54
|
+
return value === "patch" || value === "minor" || value === "major";
|
|
55
|
+
}
|