@doki-land/nifty 0.1.0 → 0.1.2
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 +1 -1
- package/package.json +6 -6
- package/src/cli/authArgs.ts +3 -3
- package/src/cli/bump-cmd.ts +2 -2
- package/src/cli/bump.ts +10 -10
- package/src/cli/change-logs-cmd.ts +5 -5
- package/src/cli/cli.ts +1 -1
- package/src/cli/commit-cmd.ts +14 -16
- package/src/cli/commit-lint-report.ts +7 -9
- package/src/cli/context.ts +2 -2
- package/src/cli/format-cmd.ts +2 -2
- package/src/cli/format.ts +1 -1
- package/src/cli/install-native-cmd.ts +2 -2
- package/src/cli/install-native.ts +1 -1
- package/src/cli/lint-cmd.ts +2 -2
- package/src/cli/lint.ts +3 -7
- package/src/cli/options.ts +2 -2
- package/src/cli/publish-cmd.ts +3 -9
- package/src/cli/publish.ts +2 -2
- package/src/cli/retime-cmd.ts +4 -4
- package/src/cli/trust-cmd.ts +3 -3
- package/src/cli/trust.ts +1 -1
- package/src/cli/update-cmd.ts +2 -2
- package/src/cli/update.ts +2 -2
- package/src/cli/upload-cmd.ts +2 -2
- package/src/cli/upload.ts +40 -40
- package/src/cli/workspace.ts +13 -13
- package/src/config/authorMap.ts +2 -6
- package/src/config/defineConfig.ts +4 -4
- package/src/config/detectProject.ts +2 -2
- package/src/config/formatPresets.ts +3 -3
- package/src/config/loadConfig.ts +7 -7
- package/src/config/trustPayload.ts +4 -4
- package/src/config/types.ts +3 -3
- package/src/git.ts +2 -2
- package/src/github.ts +20 -20
- package/src/gitmoji.ts +2 -2
- package/src/native.ts +93 -97
- package/src/nifty.ts +8 -10
package/cli/nifty.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doki-land/nifty",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Gitmoji-first commit conventions and release helpers (Node-API + TypeScript)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"jiti": "^2.4.2"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"@doki-land/nifty-win32-x64": "0.1.
|
|
28
|
-
"@doki-land/nifty-linux-x64": "0.1.
|
|
29
|
-
"@doki-land/nifty-linux-arm64": "0.1.
|
|
30
|
-
"@doki-land/nifty-darwin-arm64": "0.1.
|
|
31
|
-
"@doki-land/nifty-darwin-x64": "0.1.
|
|
27
|
+
"@doki-land/nifty-win32-x64": "0.1.2",
|
|
28
|
+
"@doki-land/nifty-linux-x64": "0.1.2",
|
|
29
|
+
"@doki-land/nifty-linux-arm64": "0.1.2",
|
|
30
|
+
"@doki-land/nifty-darwin-arm64": "0.1.2",
|
|
31
|
+
"@doki-land/nifty-darwin-x64": "0.1.2"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
package/src/cli/authArgs.ts
CHANGED
|
@@ -44,9 +44,9 @@ export function authPayload(options: AuthCliOptions): {
|
|
|
44
44
|
npm: string;
|
|
45
45
|
} {
|
|
46
46
|
return {
|
|
47
|
-
...(options.otp !== undefined ? { otp: options.otp } : {}),
|
|
48
|
-
...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
|
|
49
|
-
...(options.token !== undefined ? { token: options.token } : {}),
|
|
47
|
+
...(options.otp !== undefined ? { otp: options.otp } : { }),
|
|
48
|
+
...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : { }),
|
|
49
|
+
...(options.token !== undefined ? { token: options.token } : { }),
|
|
50
50
|
npm: options.npm,
|
|
51
51
|
};
|
|
52
52
|
}
|
package/src/cli/bump-cmd.ts
CHANGED
|
@@ -11,10 +11,10 @@ export function registerBumpCommand(cli: Cli): void {
|
|
|
11
11
|
.option("--patch", "cli.opt.patch")
|
|
12
12
|
.option("--minor", "cli.opt.minor")
|
|
13
13
|
.option("--major", "cli.opt.major")
|
|
14
|
-
.action(async
|
|
14
|
+
.action(async(options) => cmdBump(options));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export async function cmdBump(options: ParsedOptions): Promise<number> {
|
|
17
|
+
export async function cmdBump(options: ParsedOptions): Promise < number> {
|
|
18
18
|
await bootstrapFromOptions(options);
|
|
19
19
|
const bumpOptions = bumpOptionsFromParsed(options);
|
|
20
20
|
const report = bumpWorkspace(bumpOptions);
|
package/src/cli/bump.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type BumpReport = {
|
|
|
24
24
|
|
|
25
25
|
const DEFAULT_KIND: BumpKind = "patch";
|
|
26
26
|
|
|
27
|
-
export async function runBump(argv: string[]): Promise<void> {
|
|
27
|
+
export async function runBump(argv: string[]): Promise < void> {
|
|
28
28
|
const options = parseBumpArgs(argv);
|
|
29
29
|
const report = bumpWorkspace(options);
|
|
30
30
|
printBumpReport(report, options.dryRun);
|
|
@@ -103,7 +103,7 @@ export function bumpWorkspace(options: BumpOptions): BumpReport {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function readWorkspaceVersion(cargoPaths: string[], npmPaths: string[]): string {
|
|
106
|
-
const versions = new Set<string>();
|
|
106
|
+
const versions = new Set < string> ();
|
|
107
107
|
for (const path of cargoPaths) {
|
|
108
108
|
versions.add(readCargoVersion(path));
|
|
109
109
|
}
|
|
@@ -116,7 +116,7 @@ function readWorkspaceVersion(cargoPaths: string[], npmPaths: string[]): string
|
|
|
116
116
|
if (versions.size > 1) {
|
|
117
117
|
throw new Error(`workspace versions are out of sync: ${[...versions].sort().join(", ")}`);
|
|
118
118
|
}
|
|
119
|
-
return
|
|
119
|
+
return[...versions][0];
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function readCargoVersion(path: string): string {
|
|
@@ -129,7 +129,7 @@ function readCargoVersion(path: string): string {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function readPackageVersion(path: string): string {
|
|
132
|
-
const parsed = JSON.parse(readFileSync(path, "utf8"))
|
|
132
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"))as { version?: string };
|
|
133
133
|
if (!parsed.version) {
|
|
134
134
|
throw new Error(`no version field in ${path}`);
|
|
135
135
|
}
|
|
@@ -165,7 +165,7 @@ export function bumpSemver(version: string, kind: BumpKind): string {
|
|
|
165
165
|
|
|
166
166
|
function collectCargoManifests(cratesDir: string): string[] {
|
|
167
167
|
if (!existsSync(cratesDir)) {
|
|
168
|
-
return
|
|
168
|
+
return[];
|
|
169
169
|
}
|
|
170
170
|
return readdirSync(cratesDir, { withFileTypes: true })
|
|
171
171
|
.filter((entry) => entry.isDirectory())
|
|
@@ -175,7 +175,7 @@ function collectCargoManifests(cratesDir: string): string[] {
|
|
|
175
175
|
|
|
176
176
|
function collectPackageManifests(packagesDir: string): string[] {
|
|
177
177
|
if (!existsSync(packagesDir)) {
|
|
178
|
-
return
|
|
178
|
+
return[];
|
|
179
179
|
}
|
|
180
180
|
return readdirSync(packagesDir, { withFileTypes: true })
|
|
181
181
|
.filter((entry) => entry.isDirectory() && entry.name !== "node_modules")
|
|
@@ -183,7 +183,7 @@ function collectPackageManifests(packagesDir: string): string[] {
|
|
|
183
183
|
.filter((path) => existsSync(path));
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
function bumpCargoManifest(path: string, version: string, dryRun?: boolean): string {
|
|
186
|
+
function bumpCargoManifest(path: string, version: string, dryRun?: boolean) : string {
|
|
187
187
|
const original = readFileSync(path, "utf8");
|
|
188
188
|
const next = original.replace(/^version\s*=\s*"[^"]*"/m, `version = "${version}"`);
|
|
189
189
|
if (next === original) {
|
|
@@ -195,9 +195,9 @@ function bumpCargoManifest(path: string, version: string, dryRun?: boolean): str
|
|
|
195
195
|
return path;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
function bumpPackageManifest(path: string, version: string, dryRun?: boolean): string {
|
|
198
|
+
function bumpPackageManifest(path: string, version: string, dryRun?: boolean) : string {
|
|
199
199
|
const original = readFileSync(path, "utf8");
|
|
200
|
-
const parsed = JSON.parse(original)
|
|
200
|
+
const parsed = JSON.parse(original)as { version?: string };
|
|
201
201
|
if (!parsed.version) {
|
|
202
202
|
throw new Error(`no version field in ${path}`);
|
|
203
203
|
}
|
|
@@ -209,7 +209,7 @@ function bumpPackageManifest(path: string, version: string, dryRun?: boolean): s
|
|
|
209
209
|
return path;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
export function printBumpReport(report: BumpReport, dryRun?: boolean): void {
|
|
212
|
+
export function printBumpReport(report: BumpReport, dryRun?: boolean) : void {
|
|
213
213
|
const prefix = dryRun ? "would bump" : "bumped";
|
|
214
214
|
const kind = report.kind ? ` (${report.kind})` : "";
|
|
215
215
|
console.log(`${prefix} workspace ${report.root} ${report.from} -> ${report.to}${kind}`);
|
|
@@ -27,12 +27,12 @@ export function registerChangeLogsCommand(cli: Cli): void {
|
|
|
27
27
|
.option("--map <path>", "cli.opt.author-map")
|
|
28
28
|
.option("--github-token <token>", "cli.opt.github-token")
|
|
29
29
|
.option("--fetch", "cli.opt.fetch")
|
|
30
|
-
.action(async
|
|
30
|
+
.action(async(options) => cmdChangeLogsLookup(options));
|
|
31
31
|
|
|
32
|
-
changeLogs.action(async
|
|
32
|
+
changeLogs.action(async(options) => cmdChangeLogsRender(options));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export async function cmdChangeLogsRender(options: ParsedOptions): Promise<number> {
|
|
35
|
+
export async function cmdChangeLogsRender(options: ParsedOptions): Promise < number> {
|
|
36
36
|
await bootstrapFromOptions(options);
|
|
37
37
|
const cwd = cwdFrom(options) ?? process.cwd();
|
|
38
38
|
const { config } = await loadConfig({ cwd, createIfMissing: false });
|
|
@@ -66,7 +66,7 @@ export async function cmdChangeLogsRender(options: ParsedOptions): Promise<numbe
|
|
|
66
66
|
return 0;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export async function cmdChangeLogsLookup(options: ParsedOptions): Promise<number> {
|
|
69
|
+
export async function cmdChangeLogsLookup(options: ParsedOptions): Promise < number> {
|
|
70
70
|
await bootstrapFromOptions(options);
|
|
71
71
|
const cwd = cwdFrom(options) ?? process.cwd();
|
|
72
72
|
const { config } = await loadConfig({ cwd, createIfMissing: false });
|
|
@@ -86,7 +86,7 @@ export async function cmdChangeLogsLookup(options: ParsedOptions): Promise<numbe
|
|
|
86
86
|
githubToken: str(options, "github-token") ?? config.githubToken ?? process.env.GITHUB_TOKEN,
|
|
87
87
|
fetch: flag(options, "fetch"),
|
|
88
88
|
});
|
|
89
|
-
const json: Record<string, unknown> = {};
|
|
89
|
+
const json: Record < string, unknown > = { };
|
|
90
90
|
if (author.id !== undefined) {
|
|
91
91
|
json.id = author.id;
|
|
92
92
|
}
|
package/src/cli/cli.ts
CHANGED
|
@@ -37,7 +37,7 @@ function buildNiftyCli() {
|
|
|
37
37
|
return cli;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export async function runCli(argv: string[]): Promise<number> {
|
|
40
|
+
export async function runCli(argv: string[]): Promise < number> {
|
|
41
41
|
try {
|
|
42
42
|
return await buildNiftyCli().parse(argv);
|
|
43
43
|
} catch (error) {
|
package/src/cli/commit-cmd.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function registerCommitCommand(cli: Cli): void {
|
|
|
17
17
|
.option("--path <file>", "cli.opt.path")
|
|
18
18
|
.option("--with-lint", "cli.opt.with-lint")
|
|
19
19
|
.option("--errors-only", "cli.opt.errors-only")
|
|
20
|
-
.action(async
|
|
20
|
+
.action(async(options) => cmdCommitExport(options));
|
|
21
21
|
|
|
22
22
|
commit
|
|
23
23
|
.command("apply", "cli.cmd.commit.apply")
|
|
@@ -25,7 +25,7 @@ export function registerCommitCommand(cli: Cli): void {
|
|
|
25
25
|
.option("--ref <ref>", "cli.opt.ref")
|
|
26
26
|
.option("--path <file>", "cli.opt.path")
|
|
27
27
|
.option("--dry-run", "cli.opt.dry-run")
|
|
28
|
-
.action(async
|
|
28
|
+
.action(async(options) => cmdCommitApply(options));
|
|
29
29
|
|
|
30
30
|
commit
|
|
31
31
|
.command("scan", "cli.cmd.commit.scan")
|
|
@@ -34,7 +34,7 @@ export function registerCommitCommand(cli: Cli): void {
|
|
|
34
34
|
.option("-s, --subject <text>...", "cli.opt.subject")
|
|
35
35
|
.option("--json", "cli.opt.json")
|
|
36
36
|
.option("--errors-only", "cli.opt.errors-only")
|
|
37
|
-
.action(async
|
|
37
|
+
.action(async(options) => cmdCommitScan(options));
|
|
38
38
|
|
|
39
39
|
commit
|
|
40
40
|
.command("audit", "cli.cmd.commit.audit")
|
|
@@ -43,10 +43,10 @@ export function registerCommitCommand(cli: Cli): void {
|
|
|
43
43
|
.option("-s, --subject <text>...", "cli.opt.subject")
|
|
44
44
|
.option("--json", "cli.opt.json")
|
|
45
45
|
.option("--errors-only", "cli.opt.errors-only")
|
|
46
|
-
.action(async
|
|
46
|
+
.action(async(options) => cmdCommitAudit(options));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function cmdCommitExport(options: ParsedOptions): Promise<number> {
|
|
49
|
+
export async function cmdCommitExport(options: ParsedOptions): Promise < number> {
|
|
50
50
|
await bootstrapFromOptions(options);
|
|
51
51
|
const base = requireStr(options, "base");
|
|
52
52
|
const path = str(options, "path") ?? "commit.pending.json";
|
|
@@ -77,7 +77,7 @@ export async function cmdCommitExport(options: ParsedOptions): Promise<number> {
|
|
|
77
77
|
return 0;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export async function cmdCommitApply(options: ParsedOptions): Promise<number> {
|
|
80
|
+
export async function cmdCommitApply(options: ParsedOptions): Promise < number> {
|
|
81
81
|
await bootstrapFromOptions(options);
|
|
82
82
|
const base = requireStr(options, "base");
|
|
83
83
|
const path = requireStr(options, "path");
|
|
@@ -117,13 +117,13 @@ export async function cmdCommitApply(options: ParsedOptions): Promise<number> {
|
|
|
117
117
|
return 0;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export async function cmdCommitScan(options: ParsedOptions): Promise<number> {
|
|
120
|
+
export async function cmdCommitScan(options: ParsedOptions): Promise < number> {
|
|
121
121
|
await bootstrapFromOptions(options);
|
|
122
122
|
await lintCommits({ ...commitLintOptions(options), reportTitle: "commit scan" }, false, true);
|
|
123
123
|
return 0;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export async function cmdCommitAudit(options: ParsedOptions): Promise<number> {
|
|
126
|
+
export async function cmdCommitAudit(options: ParsedOptions): Promise < number> {
|
|
127
127
|
await bootstrapFromOptions(options);
|
|
128
128
|
const errorCount = await lintCommits(commitLintOptions(options), false, true);
|
|
129
129
|
return errorCount > 0 ? 1 : 0;
|
|
@@ -145,10 +145,10 @@ function commitLintOptions(options: ParsedOptions): LintOptions {
|
|
|
145
145
|
|
|
146
146
|
type ExportDocument = {
|
|
147
147
|
version: number;
|
|
148
|
-
entries: Array<{
|
|
148
|
+
entries: Array < {
|
|
149
149
|
hash: string;
|
|
150
150
|
message: string;
|
|
151
|
-
violations?: Array<{
|
|
151
|
+
violations?: Array < {
|
|
152
152
|
rule: string;
|
|
153
153
|
severity: "error" | "warning" | "info";
|
|
154
154
|
message: string;
|
|
@@ -164,7 +164,7 @@ async function lintAndAnnotateExport(options: {
|
|
|
164
164
|
json: boolean;
|
|
165
165
|
errorsOnly: boolean;
|
|
166
166
|
reportTitle: string;
|
|
167
|
-
}): Promise<number> {
|
|
167
|
+
}): Promise < number> {
|
|
168
168
|
const native = loadNiftyNative();
|
|
169
169
|
const report = native.lint.run({
|
|
170
170
|
cwd: options.cwd,
|
|
@@ -173,9 +173,7 @@ async function lintAndAnnotateExport(options: {
|
|
|
173
173
|
commitOnly: true,
|
|
174
174
|
scanCargo: false,
|
|
175
175
|
});
|
|
176
|
-
const diagnostics = options.errorsOnly
|
|
177
|
-
? report.diagnostics.filter((item) => item.severity === "error")
|
|
178
|
-
: report.diagnostics;
|
|
176
|
+
const diagnostics = options.errorsOnly ? report.diagnostics.filter((item) => item.severity === "error") : report.diagnostics;
|
|
179
177
|
|
|
180
178
|
if (options.json) {
|
|
181
179
|
const { printCommitLintReport } = await import("./commit-lint-report.js");
|
|
@@ -192,7 +190,7 @@ async function lintAndAnnotateExport(options: {
|
|
|
192
190
|
});
|
|
193
191
|
}
|
|
194
192
|
|
|
195
|
-
const byHash = new Map<string, Array<{ rule: string; severity: "error" | "warning" | "info"; message: string }>>();
|
|
193
|
+
const byHash = new Map < string, Array < { rule: string; severity: "error" | "warning" | "info"; message: string }>>();
|
|
196
194
|
for (const item of diagnostics) {
|
|
197
195
|
if (!item.hash) {
|
|
198
196
|
continue;
|
|
@@ -203,7 +201,7 @@ async function lintAndAnnotateExport(options: {
|
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
const text = await readFile(options.path, "utf8");
|
|
206
|
-
const document = JSON.parse(text)
|
|
204
|
+
const document = JSON.parse(text)as ExportDocument;
|
|
207
205
|
document.entries = document.entries.map((entry) => {
|
|
208
206
|
const violations = byHash.get(entry.hash);
|
|
209
207
|
if (!violations || violations.length === 0) {
|
|
@@ -24,11 +24,9 @@ export function printCommitLintReport(
|
|
|
24
24
|
diagnostics: CommitLintDiagnostic[],
|
|
25
25
|
errorCount: number,
|
|
26
26
|
warningCount: number,
|
|
27
|
-
options: CommitLintReportOptions = {},
|
|
27
|
+
options: CommitLintReportOptions = { },
|
|
28
28
|
): void {
|
|
29
|
-
const filtered = options.errorsOnly
|
|
30
|
-
? diagnostics.filter((item) => item.severity === "error")
|
|
31
|
-
: diagnostics;
|
|
29
|
+
const filtered = options.errorsOnly ? diagnostics.filter((item) => item.severity === "error") : diagnostics;
|
|
32
30
|
|
|
33
31
|
if (options.json) {
|
|
34
32
|
const payload = {
|
|
@@ -59,7 +57,7 @@ export function printCommitLintReport(
|
|
|
59
57
|
const summary = summarizeByRule(filtered.filter((item) => item.severity === "error"));
|
|
60
58
|
if (summary.length > 0) {
|
|
61
59
|
console.log("summary by rule:");
|
|
62
|
-
for (const
|
|
60
|
+
for (const[rule, count]of summary) {
|
|
63
61
|
console.log(` ${rule} ${count}`);
|
|
64
62
|
}
|
|
65
63
|
console.log();
|
|
@@ -67,7 +65,7 @@ export function printCommitLintReport(
|
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
function groupCommitDiagnostics(diagnostics: CommitLintDiagnostic[]): CommitLintGroup[] {
|
|
70
|
-
const groups = new Map<string, CommitLintGroup>();
|
|
68
|
+
const groups = new Map < string, CommitLintGroup > ();
|
|
71
69
|
const order: string[] = [];
|
|
72
70
|
|
|
73
71
|
for (const item of diagnostics) {
|
|
@@ -86,12 +84,12 @@ function groupCommitDiagnostics(diagnostics: CommitLintDiagnostic[]): CommitLint
|
|
|
86
84
|
return order.map((key) => groups.get(key)!);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
function summarizeByRule(diagnostics: CommitLintDiagnostic[]): Array<[string, number]> {
|
|
90
|
-
const counts = new Map<string, number>();
|
|
87
|
+
function summarizeByRule(diagnostics: CommitLintDiagnostic[]): Array < [string, number] > {
|
|
88
|
+
const counts = new Map < string, number > ();
|
|
91
89
|
for (const item of diagnostics) {
|
|
92
90
|
counts.set(item.rule, (counts.get(item.rule) ?? 0) + 1);
|
|
93
91
|
}
|
|
94
|
-
return
|
|
92
|
+
return[...counts.entries()].sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]));
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
function printCommitGroup(group: CommitLintGroup): void {
|
package/src/cli/context.ts
CHANGED
|
@@ -23,13 +23,13 @@ export function parseCliContext(argv: string[]): { cwd: string; dryRun: boolean
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Ensure `nifty.config.*` exists before running a command (skip create on `--dry-run`). */
|
|
26
|
-
export async function bootstrapNiftyConfig(argv: string[]): Promise<void> {
|
|
26
|
+
export async function bootstrapNiftyConfig(argv: string[]): Promise < void> {
|
|
27
27
|
const { cwd, dryRun } = parseCliContext(argv);
|
|
28
28
|
await loadConfig({ cwd, createIfMissing: !dryRun });
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** Commander action hook: load config from parsed global/command flags. */
|
|
32
|
-
export async function bootstrapFromOptions(options: ParsedOptions): Promise<void> {
|
|
32
|
+
export async function bootstrapFromOptions(options: ParsedOptions): Promise < void> {
|
|
33
33
|
const cwd = cwdFrom(options) ?? process.cwd();
|
|
34
34
|
const dryRun = options["dry-run"] === true;
|
|
35
35
|
await loadConfig({ cwd, createIfMissing: !dryRun });
|
package/src/cli/format-cmd.ts
CHANGED
|
@@ -7,10 +7,10 @@ import { cwdFrom, flag } from "./options.js";
|
|
|
7
7
|
export function registerFormatCommand(cli: Cli): void {
|
|
8
8
|
cli.command("format", "cli.cmd.format")
|
|
9
9
|
.option("--check", "cli.opt.check")
|
|
10
|
-
.action(async
|
|
10
|
+
.action(async(options) => cmdFormat(options));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export async function cmdFormat(options: ParsedOptions): Promise<number> {
|
|
13
|
+
export async function cmdFormat(options: ParsedOptions): Promise < number> {
|
|
14
14
|
await bootstrapFromOptions(options);
|
|
15
15
|
const exitCode = await formatWorkspace({
|
|
16
16
|
check: flag(options, "check"),
|
package/src/cli/format.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type FormatOptions = {
|
|
|
6
6
|
cwd?: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export async function formatWorkspace(options: FormatOptions): Promise<number> {
|
|
9
|
+
export async function formatWorkspace(options: FormatOptions): Promise < number> {
|
|
10
10
|
const cwd = options.cwd ?? process.cwd();
|
|
11
11
|
const { config } = await loadConfig({ cwd, createIfMissing: false, env: { command: "format" } });
|
|
12
12
|
const resolved = resolveFormatConfig(config.format);
|
|
@@ -6,10 +6,10 @@ import { cwdFrom, str } from "./options.js";
|
|
|
6
6
|
export function registerInstallNativeCommand(cli: Cli): void {
|
|
7
7
|
cli.command("install-native", "cli.cmd.install-native")
|
|
8
8
|
.option("--from <dir>", "cli.opt.from-artifacts")
|
|
9
|
-
.action(async
|
|
9
|
+
.action(async(options) => cmdInstallNative(options));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export async function cmdInstallNative(options: ParsedOptions): Promise<number> {
|
|
12
|
+
export async function cmdInstallNative(options: ParsedOptions): Promise < number> {
|
|
13
13
|
const from =
|
|
14
14
|
str(options, "from") ??
|
|
15
15
|
process.env.NATIVE_ARTIFACT_ROOT ??
|
|
@@ -4,7 +4,7 @@ import { basename, dirname, join, relative, resolve } from "node:path";
|
|
|
4
4
|
import { detectProjectLayout } from "../config/detectProject.js";
|
|
5
5
|
|
|
6
6
|
/** Basename of a built .node file → platform package directory under projects/packages/. */
|
|
7
|
-
const PACKAGE_BY_ASSET: Record<string, string> = {
|
|
7
|
+
const PACKAGE_BY_ASSET: Record < string, string > = {
|
|
8
8
|
"nifty-win32-x64-msvc.node": "nifty-win32-x64",
|
|
9
9
|
"nifty-linux-x64-gnu.node": "nifty-linux-x64",
|
|
10
10
|
"nifty-linux-arm64-gnu.node": "nifty-linux-arm64",
|
package/src/cli/lint-cmd.ts
CHANGED
|
@@ -15,10 +15,10 @@ function registerLintLike(cli: Cli, name: string, helpId: string, check: boolean
|
|
|
15
15
|
.option("--to <ref>", "cli.opt.to")
|
|
16
16
|
.option("-s, --subject <text>...", "cli.opt.subject")
|
|
17
17
|
.option("--no-cargo", "cli.opt.no-cargo")
|
|
18
|
-
.action(async
|
|
18
|
+
.action(async(options) => cmdLint(options, check));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export async function cmdLint(options: ParsedOptions, check: boolean): Promise<number> {
|
|
21
|
+
export async function cmdLint(options: ParsedOptions, check: boolean): Promise < number> {
|
|
22
22
|
await bootstrapFromOptions(options);
|
|
23
23
|
const lintOptions: LintOptions = {
|
|
24
24
|
subjects: strList(options, "subject"),
|
package/src/cli/lint.ts
CHANGED
|
@@ -22,7 +22,7 @@ type LintRuleConfig = {
|
|
|
22
22
|
severity?: "error" | "warning" | "info";
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export async function runLint(argv: string[], check: boolean): Promise<void> {
|
|
25
|
+
export async function runLint(argv: string[], check: boolean): Promise < void> {
|
|
26
26
|
const options = parseLintArgs(argv);
|
|
27
27
|
const errorCount = await lintCommits(options, check);
|
|
28
28
|
if (check && errorCount > 0) {
|
|
@@ -34,7 +34,7 @@ export async function lintCommits(
|
|
|
34
34
|
options: LintOptions,
|
|
35
35
|
check: boolean,
|
|
36
36
|
commitOnly = options.commitOnly ?? false,
|
|
37
|
-
): Promise<number> {
|
|
37
|
+
): Promise < number> {
|
|
38
38
|
const native = loadNiftyNative();
|
|
39
39
|
const cwd = options.cwd ?? process.cwd();
|
|
40
40
|
const { config } = await loadConfig({ cwd, createIfMissing: false });
|
|
@@ -84,11 +84,7 @@ function printWorkspaceDiagnostic(item: LintDiagnostic): void {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const location =
|
|
87
|
-
item.path !== undefined
|
|
88
|
-
? item.line !== undefined
|
|
89
|
-
? `${item.path}:${item.line}`
|
|
90
|
-
: item.path
|
|
91
|
-
: undefined;
|
|
87
|
+
item.path !== undefined ? item.line !== undefined ? `${item.path}:${item.line}` : item.path : undefined;
|
|
92
88
|
const suffix = location ? ` @ ${location}` : "";
|
|
93
89
|
console.log(`${prefix} [${item.rule}] ${item.message}${suffix}`);
|
|
94
90
|
}
|
package/src/cli/options.ts
CHANGED
|
@@ -25,9 +25,9 @@ export function strList(options: ParsedOptions, key: string): string[] {
|
|
|
25
25
|
return value.filter((entry): entry is string => typeof entry === "string" && entry.length > 0);
|
|
26
26
|
}
|
|
27
27
|
if (typeof value === "string" && value.length > 0) {
|
|
28
|
-
return
|
|
28
|
+
return[value];
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return[];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export function authFromOptions(options: ParsedOptions): AuthCliOptions {
|
package/src/cli/publish-cmd.ts
CHANGED
|
@@ -19,10 +19,10 @@ export function registerPublishCommand(cli: Cli): void {
|
|
|
19
19
|
.option("--otp <code>", "cli.opt.otp")
|
|
20
20
|
.option("--totp-secret <secret>", "cli.opt.totp-secret")
|
|
21
21
|
.option("--npm-token <token>", "cli.opt.npm-token")
|
|
22
|
-
.action(async
|
|
22
|
+
.action(async(options) => cmdPublish(options));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function cmdPublish(options: ParsedOptions): Promise<number> {
|
|
25
|
+
export async function cmdPublish(options: ParsedOptions): Promise < number> {
|
|
26
26
|
await bootstrapFromOptions(options);
|
|
27
27
|
const { config } = await loadConfig({ cwd: cwdFrom(options), createIfMissing: false });
|
|
28
28
|
const packages = strList(options, "package");
|
|
@@ -35,13 +35,7 @@ export async function cmdPublish(options: ParsedOptions): Promise<number> {
|
|
|
35
35
|
placeholder: flag(options, "placeholder"),
|
|
36
36
|
tag: str(options, "tag"),
|
|
37
37
|
access: str(options, "access") ?? "public",
|
|
38
|
-
...(packages.length === 1
|
|
39
|
-
? { only: packages[0] }
|
|
40
|
-
: packages.length > 1
|
|
41
|
-
? { packages }
|
|
42
|
-
: fromConfig.length > 0
|
|
43
|
-
? { packages: fromConfig }
|
|
44
|
-
: {}),
|
|
38
|
+
...(packages.length === 1 ? { only: packages[0] } : packages.length > 1 ? { packages } : fromConfig.length > 0 ? { packages: fromConfig } : { }),
|
|
45
39
|
...trustPayloadFromConfig(config),
|
|
46
40
|
...authPayload(authFromOptions(options)),
|
|
47
41
|
});
|
package/src/cli/publish.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type PublishReport = {
|
|
|
18
18
|
skippedVersions: string[];
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export async function runPublish(argv: string[]): Promise<void> {
|
|
21
|
+
export async function runPublish(argv: string[]): Promise < void> {
|
|
22
22
|
const options = parsePublishArgs(argv);
|
|
23
23
|
const native = loadNiftyNative();
|
|
24
24
|
const report = native.publisher["publish-workspace"]({
|
|
@@ -67,7 +67,7 @@ function parsePublishArgs(argv: string[]) {
|
|
|
67
67
|
return { cwd, dryRun, refresh, placeholder, tag, access, auth };
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function printPublishReport(report: PublishReport, dryRun?: boolean): void {
|
|
70
|
+
export function printPublishReport(report: PublishReport, dryRun?: boolean) : void {
|
|
71
71
|
const prefix = dryRun ? "would publish" : "published";
|
|
72
72
|
console.log(`${prefix} workspace ${report.root}`);
|
|
73
73
|
if (report.skipped.length > 0) {
|
package/src/cli/retime-cmd.ts
CHANGED
|
@@ -18,12 +18,12 @@ export function registerRetimeCommand(cli: Cli): void {
|
|
|
18
18
|
.option("-b, --branch <branch>", "cli.opt.branch")
|
|
19
19
|
.option("--tip <ref>", "cli.opt.tip")
|
|
20
20
|
.option("-m, --message <text>", "cli.opt.message")
|
|
21
|
-
.action(async
|
|
21
|
+
.action(async(options) => cmdRetimeRoot(options));
|
|
22
22
|
|
|
23
|
-
retime.action(async
|
|
23
|
+
retime.action(async(options) => cmdRetimeRange(options));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export async function cmdRetimeRange(options: ParsedOptions): Promise<number> {
|
|
26
|
+
export async function cmdRetimeRange(options: ParsedOptions): Promise < number> {
|
|
27
27
|
await bootstrapFromOptions(options);
|
|
28
28
|
const commit = options._[0];
|
|
29
29
|
if (!commit) {
|
|
@@ -42,7 +42,7 @@ export async function cmdRetimeRange(options: ParsedOptions): Promise<number> {
|
|
|
42
42
|
return 0;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export async function cmdRetimeRoot(options: ParsedOptions): Promise<number> {
|
|
45
|
+
export async function cmdRetimeRoot(options: ParsedOptions): Promise < number> {
|
|
46
46
|
await bootstrapFromOptions(options);
|
|
47
47
|
const native = loadNiftyNative();
|
|
48
48
|
const report = native.history["retime-root"]({
|
package/src/cli/trust-cmd.ts
CHANGED
|
@@ -16,10 +16,10 @@ export function registerTrustCommand(cli: Cli): void {
|
|
|
16
16
|
.option("--otp <code>", "cli.opt.otp")
|
|
17
17
|
.option("--totp-secret <secret>", "cli.opt.totp-secret")
|
|
18
18
|
.option("--npm-token <token>", "cli.opt.npm-token")
|
|
19
|
-
.action(async
|
|
19
|
+
.action(async(options) => cmdTrust(options));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function cmdTrust(options: ParsedOptions): Promise<number> {
|
|
22
|
+
export async function cmdTrust(options: ParsedOptions): Promise < number> {
|
|
23
23
|
await bootstrapFromOptions(options);
|
|
24
24
|
const { config } = await loadConfig({ cwd: cwdFrom(options), createIfMissing: false });
|
|
25
25
|
const native = loadNiftyNative();
|
|
@@ -29,7 +29,7 @@ export async function cmdTrust(options: ParsedOptions): Promise<number> {
|
|
|
29
29
|
dryRun: flag(options, "dry-run"),
|
|
30
30
|
refresh: flag(options, "refresh"),
|
|
31
31
|
only: str(options, "only"),
|
|
32
|
-
...(fromConfig.length > 0 ? { packages: fromConfig } : {}),
|
|
32
|
+
...(fromConfig.length > 0 ? { packages: fromConfig } : { }),
|
|
33
33
|
...trustPayloadFromConfig(config),
|
|
34
34
|
...authPayload(authFromOptions(options)),
|
|
35
35
|
});
|
package/src/cli/trust.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type TrustReport = {
|
|
|
8
8
|
failed: string[];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export async function runTrust(argv: string[]): Promise<void> {
|
|
11
|
+
export async function runTrust(argv: string[]): Promise < void> {
|
|
12
12
|
const options = parseTrustArgs(argv);
|
|
13
13
|
const native = loadNiftyNative();
|
|
14
14
|
const report = native.publisher["trust-workspace"]({
|
package/src/cli/update-cmd.ts
CHANGED
|
@@ -7,10 +7,10 @@ import { cwdFrom, flag } from "./options.js";
|
|
|
7
7
|
export function registerUpdateCommand(cli: Cli): void {
|
|
8
8
|
cli.command("update", "cli.cmd.update")
|
|
9
9
|
.option("-i, --interactive", "cli.opt.interactive")
|
|
10
|
-
.action(async
|
|
10
|
+
.action(async(options) => cmdUpdate(options));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export async function cmdUpdate(options: ParsedOptions): Promise<number> {
|
|
13
|
+
export async function cmdUpdate(options: ParsedOptions): Promise < number> {
|
|
14
14
|
await bootstrapFromOptions(options);
|
|
15
15
|
await updateWorkspace({
|
|
16
16
|
interactive: flag(options, "interactive"),
|
package/src/cli/update.ts
CHANGED
|
@@ -5,11 +5,11 @@ export type UpdateOptions = {
|
|
|
5
5
|
cwd?: string;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export async function runUpdate(argv: string[]): Promise<void> {
|
|
8
|
+
export async function runUpdate(argv: string[]): Promise < void> {
|
|
9
9
|
await updateWorkspace(parseUpdateArgs(argv));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export async function updateWorkspace(options: UpdateOptions): Promise<void> {
|
|
12
|
+
export async function updateWorkspace(options: UpdateOptions): Promise < void> {
|
|
13
13
|
const native = loadNiftyNative();
|
|
14
14
|
native.updater.run({
|
|
15
15
|
cwd: options.cwd,
|
package/src/cli/upload-cmd.ts
CHANGED
|
@@ -19,10 +19,10 @@ export function registerUploadCommand(cli: Cli): void {
|
|
|
19
19
|
.option("--draft", "cli.opt.draft")
|
|
20
20
|
.option("--no-generate-notes", "cli.opt.no-generate-notes")
|
|
21
21
|
.option("--github-action", "cli.opt.github-action")
|
|
22
|
-
.action(async
|
|
22
|
+
.action(async(options) => cmdUpload(options));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function cmdUpload(options: ParsedOptions): Promise<number> {
|
|
25
|
+
export async function cmdUpload(options: ParsedOptions): Promise < number> {
|
|
26
26
|
await bootstrapFromOptions(options);
|
|
27
27
|
await uploadFromOptions({
|
|
28
28
|
release: flag(options, "release"),
|