@doki-land/nifty 0.0.12 → 0.1.1

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.
Files changed (44) hide show
  1. package/cli/nifty.mjs +2 -2
  2. package/locales/en-US/cli.json +1 -1
  3. package/package.json +6 -6
  4. package/src/cli/authArgs.ts +29 -29
  5. package/src/cli/bump-cmd.ts +15 -15
  6. package/src/cli/bump.ts +81 -81
  7. package/src/cli/change-logs-cmd.ts +26 -26
  8. package/src/cli/cli.ts +3 -3
  9. package/src/cli/commit-cmd.ts +77 -77
  10. package/src/cli/commit-lint-report.ts +44 -44
  11. package/src/cli/context.ts +9 -9
  12. package/src/cli/format-cmd.ts +6 -6
  13. package/src/cli/format.ts +15 -15
  14. package/src/cli/install-native-cmd.ts +4 -4
  15. package/src/cli/install-native.ts +24 -24
  16. package/src/cli/lint-cmd.ts +11 -11
  17. package/src/cli/lint.ts +49 -49
  18. package/src/cli/options.ts +16 -16
  19. package/src/cli/publish-cmd.ts +18 -16
  20. package/src/cli/publish.ts +38 -38
  21. package/src/cli/resolveNpm.ts +3 -3
  22. package/src/cli/retime-cmd.ts +18 -18
  23. package/src/cli/trust-cmd.ts +13 -10
  24. package/src/cli/trust.ts +30 -27
  25. package/src/cli/update-cmd.ts +5 -5
  26. package/src/cli/update.ts +12 -12
  27. package/src/cli/upload-cmd.ts +17 -17
  28. package/src/cli/upload.ts +132 -132
  29. package/src/cli/workspace.ts +49 -49
  30. package/src/config/authorMap.ts +4 -4
  31. package/src/config/defineConfig.ts +5 -5
  32. package/src/config/detectProject.ts +46 -46
  33. package/src/config/formatPresets.ts +26 -26
  34. package/src/config/index.ts +3 -0
  35. package/src/config/loadConfig.ts +35 -35
  36. package/src/config/trustPayload.ts +14 -0
  37. package/src/config/types.ts +60 -37
  38. package/src/git.ts +14 -14
  39. package/src/github.ts +54 -54
  40. package/src/gitmoji.ts +18 -18
  41. package/src/index.ts +3 -0
  42. package/src/native.ts +601 -591
  43. package/src/nifty.ts +30 -30
  44. package/src/types.ts +17 -17
@@ -3,11 +3,12 @@ import type { Cli, ParsedOptions } from "@vmz/commander";
3
3
  import { loadNiftyNative } from "../native.js";
4
4
  import { authPayload } from "./authArgs.js";
5
5
  import { loadConfig } from "../config/loadConfig.js";
6
+ import { trustPayloadFromConfig } from "../config/trustPayload.js";
6
7
  import { bootstrapFromOptions } from "./context.js";
7
8
  import { printTrustReport } from "./trust.js";
8
9
  import { authFromOptions, cwdFrom, flag, str } from "./options.js";
9
10
 
10
- export function registerTrustCommand(cli: Cli): void {
11
+ export function registerTrustCommand(cli : Cli) : void {
11
12
  cli.command("trust", "cli.cmd.trust")
12
13
  .option("--dry-run", "cli.opt.dry-run")
13
14
  .option("--refresh", "cli.opt.refresh")
@@ -15,23 +16,25 @@ export function registerTrustCommand(cli: Cli): void {
15
16
  .option("--otp <code>", "cli.opt.otp")
16
17
  .option("--totp-secret <secret>", "cli.opt.totp-secret")
17
18
  .option("--npm-token <token>", "cli.opt.npm-token")
18
- .action(async (options) => cmdTrust(options));
19
+ .action(async(options) =>cmdTrust(options));
19
20
  }
20
21
 
21
- export async function cmdTrust(options: ParsedOptions): Promise<number> {
22
+ export async function cmdTrust(options : ParsedOptions) : Promise<number>{
22
23
  await bootstrapFromOptions(options);
23
- const { config } = await loadConfig({ cwd: cwdFrom(options), createIfMissing: false });
24
+ const { config } = await loadConfig({ cwd : cwdFrom(options), createIfMissing : false });
24
25
  const native = loadNiftyNative();
26
+ const fromConfig = config.publish ?.packages ?? [];
25
27
  const report = native.publisher["trust-workspace"]({
26
- cwd: cwdFrom(options),
27
- dryRun: flag(options, "dry-run"),
28
- refresh: flag(options, "refresh"),
29
- only: str(options, "only"),
30
- packages: config.publish?.packages,
28
+ cwd : cwdFrom(options),
29
+ dryRun : flag(options, "dry-run"),
30
+ refresh : flag(options, "refresh"),
31
+ only : str(options, "only"),
32
+ ...(fromConfig.length>0 ? { packages : fromConfig } : { }),
33
+ ...trustPayloadFromConfig(config),
31
34
  ...authPayload(authFromOptions(options)),
32
35
  });
33
36
  printTrustReport(report);
34
- if (report.failed.length > 0) {
37
+ if(report.failed.length>0){
35
38
  throw new Error(`trust failed for ${report.failed.length} package(s)`);
36
39
  }
37
40
  return 0;
package/src/cli/trust.ts CHANGED
@@ -2,43 +2,43 @@ import { loadNiftyNative } from "../native.js";
2
2
  import { authPayload, parseAuthArgs } from "./authArgs.js";
3
3
 
4
4
  export type TrustReport = {
5
- root: string;
6
- configured: string[];
7
- skipped: string[];
8
- failed: string[];
5
+ root : string;
6
+ configured : string[];
7
+ skipped : string[];
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"]({
15
- cwd: options.cwd,
16
- dryRun: options.dryRun,
17
- refresh: options.refresh,
18
- only: options.only,
15
+ cwd : options.cwd,
16
+ dryRun : options.dryRun,
17
+ refresh : options.refresh,
18
+ only : options.only,
19
19
  ...authPayload(options.auth),
20
20
  });
21
21
  printTrustReport(report);
22
22
  }
23
23
 
24
- function parseTrustArgs(argv: string[]) {
25
- let cwd: string | undefined;
24
+ function parseTrustArgs(argv : string[]){
25
+ let cwd : string | undefined;
26
26
  let dryRun = false;
27
27
  let refresh = false;
28
- let only: string | undefined;
28
+ let only : string | undefined;
29
29
  const auth = parseAuthArgs(argv);
30
30
 
31
- for (let i = 0; i < argv.length; i += 1) {
31
+ for(let i = 0; i<argv.length; i += 1){
32
32
  const arg = argv[i];
33
- if (arg === "--dry-run") {
33
+ if(arg === "--dry-run"){
34
34
  dryRun = true;
35
- } else if (arg === "--refresh") {
35
+ } else if(arg === "--refresh"){
36
36
  refresh = true;
37
- } else if (arg === "-C" || arg === "--cwd") {
38
- cwd = argv[++i];
39
- } else if (arg === "--only") {
40
- only = argv[++i];
41
- } else if (arg === "-h" || arg === "--help") {
37
+ } else if(arg === "-C" || arg === "--cwd"){
38
+ cwd = argv[ ++ i];
39
+ } else if(arg === "--only"){
40
+ only = argv[ ++ i];
41
+ } else if(arg === "-h" || arg === "--help"){
42
42
  printTrustHelp();
43
43
  process.exit(0);
44
44
  }
@@ -47,29 +47,32 @@ function parseTrustArgs(argv: string[]) {
47
47
  return { cwd, dryRun, refresh, only, auth };
48
48
  }
49
49
 
50
- export function printTrustReport(report: TrustReport): void {
50
+ export function printTrustReport(report : TrustReport) : void {
51
51
  console.log(`trust workspace ${report.root}`);
52
52
  console.log(` configured: ${report.configured.length}`);
53
- for (const name of report.configured) {
53
+ for(const name of report.configured){
54
54
  console.log(` + ${name}`);
55
55
  }
56
56
  console.log(` skipped: ${report.skipped.length}`);
57
- for (const name of report.skipped) {
57
+ for(const name of report.skipped){
58
58
  console.log(` = ${name}`);
59
59
  }
60
- if (report.failed.length > 0) {
60
+ if(report.failed.length>0){
61
61
  console.log(` failed: ${report.failed.length}`);
62
- for (const name of report.failed) {
62
+ for(const name of report.failed){
63
63
  console.log(` ! ${name}`);
64
64
  }
65
65
  }
66
66
  }
67
67
 
68
- function printTrustHelp(): void {
68
+ function printTrustHelp() : void {
69
69
  console.log(`nifty trust — configure npm Trusted Publisher for workspace packages
70
70
 
71
- Reads NPM_TOTP_SECRET / NPM_OTP / NPM_TOKEN from env or .env.placeholder.local.
71
+ Reads trust.npm from nifty.config.ts (repo / file / environment).
72
+ Auth: NPM_TOKEN from env or .env.placeholder.local, or npm login token in project .npmrc / ~/.npmrc.
73
+ Optional NPM_TOTP_SECRET / NPM_OTP for 2FA accounts (npm-otp header).
72
74
  Trust list cache lives in .cache/npm-placeholder.json.
75
+ Uses the npm registry API (/-/package/*/trust), not npm trust CLI.
73
76
 
74
77
  Usage:
75
78
  nifty trust
@@ -4,17 +4,17 @@ import { bootstrapFromOptions } from "./context.js";
4
4
  import { updateWorkspace } from "./update.js";
5
5
  import { cwdFrom, flag } from "./options.js";
6
6
 
7
- export function registerUpdateCommand(cli: Cli): void {
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 (options) => cmdUpdate(options));
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
- interactive: flag(options, "interactive"),
17
- cwd: cwdFrom(options),
16
+ interactive : flag(options, "interactive"),
17
+ cwd : cwdFrom(options),
18
18
  });
19
19
  return 0;
20
20
  }
package/src/cli/update.ts CHANGED
@@ -1,31 +1,31 @@
1
1
  import { loadNiftyNative } from "../native.js";
2
2
 
3
3
  export type UpdateOptions = {
4
- interactive: boolean;
5
- cwd?: string;
4
+ interactive : boolean;
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
- cwd: options.cwd,
16
- interactive: options.interactive,
15
+ cwd : options.cwd,
16
+ interactive : options.interactive,
17
17
  });
18
18
  }
19
19
 
20
- function parseUpdateArgs(argv: string[]): UpdateOptions {
20
+ function parseUpdateArgs(argv : string[]) : UpdateOptions {
21
21
  let interactive = false;
22
- let cwd: string | undefined;
23
- for (let i = 0; i < argv.length; i += 1) {
22
+ let cwd : string | undefined;
23
+ for(let i = 0; i<argv.length; i += 1){
24
24
  const arg = argv[i];
25
- if (arg === "-i" || arg === "--interactive") {
25
+ if(arg === "-i" || arg === "--interactive"){
26
26
  interactive = true;
27
- } else if (arg === "-C" || arg === "--cwd") {
28
- cwd = argv[++i];
27
+ } else if(arg === "-C" || arg === "--cwd"){
28
+ cwd = argv[ ++ i];
29
29
  }
30
30
  }
31
31
  return { interactive, cwd };
@@ -4,7 +4,7 @@ import { bootstrapFromOptions } from "./context.js";
4
4
  import { uploadFromOptions } from "./upload.js";
5
5
  import { cwdFrom, flag, str } from "./options.js";
6
6
 
7
- export function registerUploadCommand(cli: Cli): void {
7
+ export function registerUploadCommand(cli : Cli) : void {
8
8
  cli.command("upload", "cli.cmd.upload")
9
9
  .option("--release", "cli.opt.release")
10
10
  .option("--pages", "cli.opt.pages")
@@ -19,26 +19,26 @@ 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 (options) => cmdUpload(options));
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
- release: flag(options, "release"),
29
- pages: flag(options, "pages"),
30
- both: flag(options, "both"),
31
- dir: str(options, "dir") ?? "dist",
32
- tag: str(options, "tag"),
33
- repo: str(options, "repo"),
34
- token: str(options, "token"),
35
- name: str(options, "name"),
36
- notes: str(options, "notes"),
37
- notesFile: str(options, "notes-file"),
38
- draft: flag(options, "draft"),
39
- generateNotes: !flag(options, "no-generate-notes"),
40
- githubAction: flag(options, "github-action"),
41
- cwd: cwdFrom(options),
28
+ release : flag(options, "release"),
29
+ pages : flag(options, "pages"),
30
+ both : flag(options, "both"),
31
+ dir : str(options, "dir") ?? "dist",
32
+ tag : str(options, "tag"),
33
+ repo : str(options, "repo"),
34
+ token : str(options, "token"),
35
+ name : str(options, "name"),
36
+ notes : str(options, "notes"),
37
+ notesFile : str(options, "notes-file"),
38
+ draft : flag(options, "draft"),
39
+ generateNotes : !flag(options, "no-generate-notes"),
40
+ githubAction : flag(options, "github-action"),
41
+ cwd : cwdFrom(options),
42
42
  });
43
43
  return 0;
44
44
  }