@doki-land/nifty 0.0.2 → 0.0.4

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/README.md +29 -0
  2. package/cli/nifty.mjs +11 -11
  3. package/locales/en-US/cli.json +68 -64
  4. package/locales/locales.json +4 -4
  5. package/package.json +20 -16
  6. package/src/cli/authArgs.ts +52 -52
  7. package/src/cli/bump-cmd.ts +55 -55
  8. package/src/cli/bump.ts +237 -237
  9. package/src/cli/change-logs-cmd.ts +97 -97
  10. package/src/cli/cli.ts +47 -45
  11. package/src/cli/context.ts +36 -36
  12. package/src/cli/format-cmd.ts +23 -0
  13. package/src/cli/format.ts +28 -0
  14. package/src/cli/index.ts +9 -9
  15. package/src/cli/install-native-cmd.ts +22 -22
  16. package/src/cli/install-native.ts +80 -80
  17. package/src/cli/lint-cmd.ts +35 -33
  18. package/src/cli/lint.ts +102 -113
  19. package/src/cli/main.ts +1 -1
  20. package/src/cli/options.ts +40 -40
  21. package/src/cli/publish-cmd.ts +38 -34
  22. package/src/cli/publish.ts +95 -95
  23. package/src/cli/resolveNpm.ts +16 -16
  24. package/src/cli/retime-cmd.ts +62 -62
  25. package/src/cli/reword-cmd.ts +87 -87
  26. package/src/cli/trust-cmd.ts +38 -38
  27. package/src/cli/trust.ts +83 -83
  28. package/src/cli/update-cmd.ts +20 -20
  29. package/src/cli/update.ts +32 -185
  30. package/src/cli/upload-cmd.ts +44 -44
  31. package/src/cli/upload.ts +313 -313
  32. package/src/cli/workspace.ts +124 -124
  33. package/src/config/defineConfig.ts +12 -12
  34. package/src/config/detectProject.ts +189 -189
  35. package/src/config/index.ts +25 -25
  36. package/src/config/loadConfig.ts +129 -129
  37. package/src/config/types.ts +57 -57
  38. package/src/git.ts +61 -61
  39. package/src/github.ts +184 -184
  40. package/src/gitmoji.ts +77 -77
  41. package/src/index.ts +36 -36
  42. package/src/native.ts +665 -507
  43. package/src/nifty.ts +95 -95
  44. package/src/types.ts +40 -40
package/src/nifty.ts CHANGED
@@ -1,95 +1,95 @@
1
- import {
2
- authorMapToJson,
3
- detectProjectLayout,
4
- loadConfig,
5
- type LoadConfigOptions,
6
- type NiftyConfig,
7
- type ProjectLayout,
8
- } from "./config/index.js";
9
-
10
- import { Git } from "./git.js";
11
- import { Github } from "./github.js";
12
- import { Gitmoji } from "./gitmoji.js";
13
- import { loadNiftyNative } from "./native.js";
14
-
15
- export type NiftyOpenOptions = NiftyConfig &
16
- LoadConfigOptions & {
17
- /** When `false`, skip loading `nifty.config.ts/js`. Inline options still apply. */
18
- config?: false;
19
- };
20
-
21
- function resolveRoots(config: NiftyConfig, layout: ProjectLayout): NiftyConfig {
22
- return {
23
- ...config,
24
- repoRoot: config.repoRoot ?? layout.root,
25
- cargoRoot:
26
- config.cargoRoot ??
27
- layout.cargoWorkspaceRoot ??
28
- (layout.cargoManifest ? layout.cargoManifest.replace(/[/\\]Cargo\.toml$/, "") : undefined),
29
- npmRoot:
30
- config.npmRoot ??
31
- layout.npmWorkspaceRoot ??
32
- (layout.packageManifest ? layout.packageManifest.replace(/[/\\]package\.json$/, "") : undefined),
33
- };
34
- }
35
-
36
- /** Combined Nifty engine: gitmoji conventions + gix repository reads + GitHub API. */
37
- export class Nifty {
38
- readonly gitmoji: Gitmoji;
39
- readonly git: Git;
40
- readonly github: Github;
41
- readonly config: NiftyConfig;
42
- readonly layout: ProjectLayout;
43
- readonly configFile?: string;
44
-
45
- private constructor(
46
- gitmoji: Gitmoji,
47
- git: Git,
48
- github: Github,
49
- config: NiftyConfig,
50
- layout: ProjectLayout,
51
- configFile?: string,
52
- ) {
53
- this.gitmoji = gitmoji;
54
- this.git = git;
55
- this.github = github;
56
- this.config = config;
57
- this.layout = layout;
58
- this.configFile = configFile;
59
- }
60
-
61
- static async open(options: NiftyOpenOptions = {}): Promise<Nifty> {
62
- const cwd = options.cwd ?? process.cwd();
63
- const layout = detectProjectLayout(cwd);
64
- const { config: skipConfig, configFile, env, githubToken, authorMap, repoRoot, cargoRoot, npmRoot } = options;
65
- const loaded =
66
- skipConfig === false
67
- ? { config: {} as NiftyConfig }
68
- : await loadConfig({ cwd, configFile, env: { layout, ...env } });
69
- const merged = resolveRoots(
70
- {
71
- ...loaded.config,
72
- ...(githubToken !== undefined ? { githubToken } : {}),
73
- ...(authorMap !== undefined ? { authorMap } : {}),
74
- ...(repoRoot !== undefined ? { repoRoot } : {}),
75
- ...(cargoRoot !== undefined ? { cargoRoot } : {}),
76
- ...(npmRoot !== undefined ? { npmRoot } : {}),
77
- },
78
- layout,
79
- );
80
-
81
- const native = loadNiftyNative();
82
- return new Nifty(
83
- new Gitmoji(native.gitmoji, authorMapToJson(merged.authorMap)),
84
- new Git(native.git),
85
- Github.open(merged.githubToken),
86
- merged,
87
- layout,
88
- loaded.configFile,
89
- );
90
- }
91
- }
92
-
93
- export async function createNifty(options: NiftyOpenOptions = {}): Promise<Nifty> {
94
- return Nifty.open(options);
95
- }
1
+ import {
2
+ authorMapToJson,
3
+ detectProjectLayout,
4
+ loadConfig,
5
+ type LoadConfigOptions,
6
+ type NiftyConfig,
7
+ type ProjectLayout,
8
+ } from "./config/index.js";
9
+
10
+ import { Git } from "./git.js";
11
+ import { Github } from "./github.js";
12
+ import { Gitmoji } from "./gitmoji.js";
13
+ import { loadNiftyNative } from "./native.js";
14
+
15
+ export type NiftyOpenOptions = NiftyConfig &
16
+ LoadConfigOptions & {
17
+ /** When `false`, skip loading `nifty.config.ts/js`. Inline options still apply. */
18
+ config?: false;
19
+ };
20
+
21
+ function resolveRoots(config: NiftyConfig, layout: ProjectLayout): NiftyConfig {
22
+ return {
23
+ ...config,
24
+ repoRoot: config.repoRoot ?? layout.root,
25
+ cargoRoot:
26
+ config.cargoRoot ??
27
+ layout.cargoWorkspaceRoot ??
28
+ (layout.cargoManifest ? layout.cargoManifest.replace(/[/\\]Cargo\.toml$/, "") : undefined),
29
+ npmRoot:
30
+ config.npmRoot ??
31
+ layout.npmWorkspaceRoot ??
32
+ (layout.packageManifest ? layout.packageManifest.replace(/[/\\]package\.json$/, "") : undefined),
33
+ };
34
+ }
35
+
36
+ /** Combined Nifty engine: gitmoji conventions + gix repository reads + GitHub API. */
37
+ export class Nifty {
38
+ readonly gitmoji: Gitmoji;
39
+ readonly git: Git;
40
+ readonly github: Github;
41
+ readonly config: NiftyConfig;
42
+ readonly layout: ProjectLayout;
43
+ readonly configFile?: string;
44
+
45
+ private constructor(
46
+ gitmoji: Gitmoji,
47
+ git: Git,
48
+ github: Github,
49
+ config: NiftyConfig,
50
+ layout: ProjectLayout,
51
+ configFile?: string,
52
+ ) {
53
+ this.gitmoji = gitmoji;
54
+ this.git = git;
55
+ this.github = github;
56
+ this.config = config;
57
+ this.layout = layout;
58
+ this.configFile = configFile;
59
+ }
60
+
61
+ static async open(options: NiftyOpenOptions = {}): Promise<Nifty> {
62
+ const cwd = options.cwd ?? process.cwd();
63
+ const layout = detectProjectLayout(cwd);
64
+ const { config: skipConfig, configFile, env, githubToken, authorMap, repoRoot, cargoRoot, npmRoot } = options;
65
+ const loaded =
66
+ skipConfig === false
67
+ ? { config: {} as NiftyConfig }
68
+ : await loadConfig({ cwd, configFile, env: { layout, ...env } });
69
+ const merged = resolveRoots(
70
+ {
71
+ ...loaded.config,
72
+ ...(githubToken !== undefined ? { githubToken } : {}),
73
+ ...(authorMap !== undefined ? { authorMap } : {}),
74
+ ...(repoRoot !== undefined ? { repoRoot } : {}),
75
+ ...(cargoRoot !== undefined ? { cargoRoot } : {}),
76
+ ...(npmRoot !== undefined ? { npmRoot } : {}),
77
+ },
78
+ layout,
79
+ );
80
+
81
+ const native = loadNiftyNative();
82
+ return new Nifty(
83
+ new Gitmoji(native.gitmoji, authorMapToJson(merged.authorMap)),
84
+ new Git(native.git),
85
+ Github.open(merged.githubToken),
86
+ merged,
87
+ layout,
88
+ loaded.configFile,
89
+ );
90
+ }
91
+ }
92
+
93
+ export async function createNifty(options: NiftyOpenOptions = {}): Promise<Nifty> {
94
+ return Nifty.open(options);
95
+ }
package/src/types.ts CHANGED
@@ -1,40 +1,40 @@
1
- /** GitHub author resolved from noreply email or `author-github.json`. */
2
- export type GithubAuthor = {
3
- id?: bigint;
4
- login?: string;
5
- };
6
-
7
- /** Nifty gitmoji-parsed commit subject. */
8
- export type ParsedSubject = {
9
- gitmoji?: string;
10
- body: string;
11
- /** `features` | `fixes` | `breaking` | `other` */
12
- section: string;
13
- };
14
-
15
- /** Release note section keys (Nifty gitmoji grouping). */
16
- export type ReleaseSection = "features" | "fixes" | "breaking" | "other";
17
-
18
- /** Semver tag with short hash. */
19
- export type TagInfo = {
20
- name: string;
21
- shortHash: string;
22
- };
23
-
24
- /** Resolved release tag range. */
25
- export type RangeInfo = {
26
- version: string;
27
- fromRef?: string;
28
- toRef: string;
29
- };
30
-
31
- /** Commit from repository history with Nifty gitmoji fields. */
32
- export type CommitRecord = {
33
- hash: string;
34
- email: string;
35
- author: string;
36
- subject: string;
37
- body: string;
38
- gitmoji?: string;
39
- section: ReleaseSection;
40
- };
1
+ /** GitHub author resolved from noreply email or `author-github.json`. */
2
+ export type GithubAuthor = {
3
+ id?: bigint;
4
+ login?: string;
5
+ };
6
+
7
+ /** Nifty gitmoji-parsed commit subject. */
8
+ export type ParsedSubject = {
9
+ gitmoji?: string;
10
+ body: string;
11
+ /** `features` | `fixes` | `breaking` | `other` */
12
+ section: string;
13
+ };
14
+
15
+ /** Release note section keys (Nifty gitmoji grouping). */
16
+ export type ReleaseSection = "features" | "fixes" | "breaking" | "other";
17
+
18
+ /** Semver tag with short hash. */
19
+ export type TagInfo = {
20
+ name: string;
21
+ shortHash: string;
22
+ };
23
+
24
+ /** Resolved release tag range. */
25
+ export type RangeInfo = {
26
+ version: string;
27
+ fromRef?: string;
28
+ toRef: string;
29
+ };
30
+
31
+ /** Commit from repository history with Nifty gitmoji fields. */
32
+ export type CommitRecord = {
33
+ hash: string;
34
+ email: string;
35
+ author: string;
36
+ subject: string;
37
+ body: string;
38
+ gitmoji?: string;
39
+ section: ReleaseSection;
40
+ };