@doki-land/nifty 0.1.1 → 0.1.3

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 (41) hide show
  1. package/cli/nifty.mjs +2 -2
  2. package/package.json +8 -7
  3. package/src/cli/authArgs.ts +29 -29
  4. package/src/cli/bump-cmd.ts +15 -15
  5. package/src/cli/bump.ts +183 -94
  6. package/src/cli/change-logs-cmd.ts +26 -26
  7. package/src/cli/cli.ts +3 -3
  8. package/src/cli/commit-cmd.ts +77 -77
  9. package/src/cli/commit-lint-report.ts +44 -44
  10. package/src/cli/context.ts +9 -9
  11. package/src/cli/format-cmd.ts +6 -6
  12. package/src/cli/format.ts +15 -15
  13. package/src/cli/install-native-cmd.ts +4 -4
  14. package/src/cli/install-native.ts +24 -24
  15. package/src/cli/lint-cmd.ts +11 -11
  16. package/src/cli/lint.ts +49 -49
  17. package/src/cli/options.ts +16 -16
  18. package/src/cli/publish-cmd.ts +16 -16
  19. package/src/cli/publish.ts +38 -38
  20. package/src/cli/resolveNpm.ts +3 -3
  21. package/src/cli/retime-cmd.ts +18 -18
  22. package/src/cli/trust-cmd.ts +11 -11
  23. package/src/cli/trust.ts +26 -26
  24. package/src/cli/update-cmd.ts +5 -5
  25. package/src/cli/update.ts +12 -12
  26. package/src/cli/upload-cmd.ts +17 -17
  27. package/src/cli/upload.ts +132 -132
  28. package/src/cli/workspace.ts +49 -49
  29. package/src/config/authorMap.ts +4 -4
  30. package/src/config/defineConfig.ts +10 -8
  31. package/src/config/detectProject.ts +46 -46
  32. package/src/config/formatPresets.ts +26 -26
  33. package/src/config/loadConfig.ts +35 -35
  34. package/src/config/trustPayload.ts +7 -7
  35. package/src/config/types.ts +38 -38
  36. package/src/git.ts +14 -14
  37. package/src/github.ts +54 -54
  38. package/src/gitmoji.ts +18 -18
  39. package/src/native.ts +600 -600
  40. package/src/nifty.ts +30 -30
  41. package/src/types.ts +17 -17
@@ -4,7 +4,7 @@ import { loadNiftyNative } from "../native.js";
4
4
  import { bootstrapFromOptions } from "./context.js";
5
5
  import { cwdFrom, str } from "./options.js";
6
6
 
7
- export function registerRetimeCommand(cli : Cli) : void {
7
+ export function registerRetimeCommand(cli: Cli): void {
8
8
  const retime = cli.command("retime", "cli.cmd.retime")
9
9
  .option("-s, --start-date <start>", "cli.opt.start-date")
10
10
  .option("--end-date <end>", "cli.opt.end-date")
@@ -18,45 +18,45 @@ 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(options) =>cmdRetimeRoot(options));
21
+ .action(async (options) => cmdRetimeRoot(options));
22
22
 
23
- retime.action(async(options) =>cmdRetimeRange(options));
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
- if(!commit){
29
+ if (!commit) {
30
30
  throw new Error("missing commit hash for range retime");
31
31
  }
32
32
  const native = loadNiftyNative();
33
33
  const report = native.history["retime-range"]({
34
- cwd : cwdFrom(options),
34
+ cwd: cwdFrom(options),
35
35
  commit,
36
- startDate : str(options, "start-date"),
37
- endDate : str(options, "end-date"),
38
- branch : str(options, "branch"),
39
- tip : str(options, "tip"),
36
+ startDate: str(options, "start-date"),
37
+ endDate: str(options, "end-date"),
38
+ branch: str(options, "branch"),
39
+ tip: str(options, "tip"),
40
40
  });
41
41
  printRetimeSummary(report);
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"]({
49
- cwd : cwdFrom(options),
50
- startDate : str(options, "start-date"),
51
- endDate : str(options, "end-date"),
52
- branch : str(options, "branch"),
53
- tip : str(options, "tip"),
54
- message : str(options, "message"),
49
+ cwd: cwdFrom(options),
50
+ startDate: str(options, "start-date"),
51
+ endDate: str(options, "end-date"),
52
+ branch: str(options, "branch"),
53
+ tip: str(options, "tip"),
54
+ message: str(options, "message"),
55
55
  });
56
56
  printRetimeSummary(report);
57
57
  return 0;
58
58
  }
59
59
 
60
- function printRetimeSummary(report : { rewritten : number; branch : string; newTip : string }) : void {
60
+ function printRetimeSummary(report: { rewritten: number; branch: string; newTip: string }): void {
61
61
  console.log(`retimed ${report.rewritten} commit(s) on branch ${report.branch}; tip ${report.newTip}`);
62
62
  }
@@ -8,7 +8,7 @@ import { bootstrapFromOptions } from "./context.js";
8
8
  import { printTrustReport } from "./trust.js";
9
9
  import { authFromOptions, cwdFrom, flag, str } from "./options.js";
10
10
 
11
- export function registerTrustCommand(cli : Cli) : void {
11
+ export function registerTrustCommand(cli: Cli): void {
12
12
  cli.command("trust", "cli.cmd.trust")
13
13
  .option("--dry-run", "cli.opt.dry-run")
14
14
  .option("--refresh", "cli.opt.refresh")
@@ -16,25 +16,25 @@ 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(options) =>cmdTrust(options));
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
- const { config } = await loadConfig({ cwd : cwdFrom(options), createIfMissing : false });
24
+ const { config } = await loadConfig({ cwd: cwdFrom(options), createIfMissing: false });
25
25
  const native = loadNiftyNative();
26
- const fromConfig = config.publish ?.packages ?? [];
26
+ const fromConfig = config.publish?.packages ?? [];
27
27
  const report = native.publisher["trust-workspace"]({
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 } : { }),
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
33
  ...trustPayloadFromConfig(config),
34
34
  ...authPayload(authFromOptions(options)),
35
35
  });
36
36
  printTrustReport(report);
37
- if(report.failed.length>0){
37
+ if (report.failed.length > 0) {
38
38
  throw new Error(`trust failed for ${report.failed.length} package(s)`);
39
39
  }
40
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,25 +47,25 @@ 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
71
  Reads trust.npm from nifty.config.ts (repo / file / environment).
@@ -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
  }