auklet 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -48,6 +48,7 @@ Build and dev flags:
48
48
  | `--filter <pattern>` | `build`, `dev` | Select workspace packages by package name. |
49
49
  | `--workspace` | `build`, `dev` | Alias for `--filter '*'`. |
50
50
  | `--deps` | `build`, `dev` | Include selected packages' workspace dependencies. |
51
+ | `--private` | `build`, `dev` | Include private workspace packages. |
51
52
 
52
53
  Notes:
53
54
 
@@ -57,6 +58,8 @@ Notes:
57
58
  - Workspace `build` runs each target package's own `build` script.
58
59
  - Workspace `dev` runs each target package's own `dev` script. Packages without
59
60
  a `dev` script fail fast.
61
+ - Workspace `build` and `dev` skip private packages by default. Use `--private`
62
+ to include them.
60
63
 
61
64
  ### Publish
62
65
 
package/dist/cli/build.js CHANGED
@@ -33,6 +33,7 @@ export async function runBuild(options) {
33
33
  envContext: options.envContext,
34
34
  filters: options.workspace.filters,
35
35
  includeDependencies: options.workspace.includeDependencies,
36
+ includePrivate: options.workspace.includePrivate,
36
37
  });
37
38
  }
38
39
  if (options.workspace.includeDependencies) {
@@ -49,6 +50,7 @@ export async function runBuild(options) {
49
50
  const runWorkspaceBuild = async (args, options) => {
50
51
  const targets = await resolveWorkspaceBuildTargets(options.cwd, options.filters, options.envContext, {
51
52
  includeDependencies: options.includeDependencies,
53
+ includePrivate: options.includePrivate,
52
54
  });
53
55
  const logger = createAukletLogger();
54
56
  for (const target of targets) {
@@ -13,6 +13,7 @@ export type WorkspaceBuildTarget = {
13
13
  packageJson: WorkspaceBuildPackageJson;
14
14
  };
15
15
  export declare function resolveWorkspaceBuildTargets(cwd: string, filters: Array<string>, envContext: AukletEnvContext, options?: {
16
+ includePrivate?: boolean;
16
17
  includeDependencies?: boolean;
17
18
  }): Promise<{
18
19
  packageRoot: string;
@@ -10,7 +10,7 @@ export async function resolveWorkspaceBuildTargets(cwd, filters, envContext, opt
10
10
  scope: 'build',
11
11
  emptyTargetMessage: '[build] no buildable workspace package found.',
12
12
  excludeRoot: true,
13
- includePrivate: true,
13
+ includePrivate: options.includePrivate,
14
14
  readPackageJson: readBuildPackageJson,
15
15
  createTarget: (item, packageJson) => ({
16
16
  packageRoot: item.path,
package/dist/cli/dev.js CHANGED
@@ -16,6 +16,7 @@ export async function runDev(options) {
16
16
  workspaceScriptArgs: options.workspaceScriptArgs,
17
17
  filters: options.workspace.filters,
18
18
  includeDependencies: options.workspace.includeDependencies,
19
+ includePrivate: options.workspace.includePrivate,
19
20
  });
20
21
  }
21
22
  if (options.workspace.includeDependencies) {
@@ -59,6 +60,7 @@ const runWorkspaceDev = async (options) => {
59
60
  const handles = [];
60
61
  const targets = await resolveWorkspaceBuildTargets(options.cwd, options.filters, options.envContext, {
61
62
  includeDependencies: options.includeDependencies,
63
+ includePrivate: options.includePrivate,
62
64
  });
63
65
  const close = async () => {
64
66
  if (closed)
package/dist/cli/main.js CHANGED
@@ -2,15 +2,15 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { cac } from 'cac';
5
+ import { AukletEnvContext } from '#auklet/env';
5
6
  import { createAukletLogger } from '#auklet/logger';
7
+ import { runOwnerCli, runPublishCli } from '#auklet/publish/cli';
6
8
  import { runDev } from '#auklet/cli/dev';
9
+ import { runInspect } from '#auklet/cli/inspect';
7
10
  import { runBuildCss } from '#auklet/cli/buildCss';
11
+ import { parseDevCommand } from '#auklet/cli/parse/dev';
8
12
  import { runBuild, runBuildJs } from '#auklet/cli/build';
9
- import { runInspect } from '#auklet/cli/inspect';
10
- import { runOwnerCli, runPublishCli } from '#auklet/publish/cli';
11
- import { AukletEnvContext } from '#auklet/env';
12
13
  import { parseBuildCommand, parseBuildCssCommand, parseBuildJsCommand, } from '#auklet/cli/parse/build';
13
- import { parseDevCommand } from '#auklet/cli/parse/dev';
14
14
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
15
  const getPackageVersion = () => {
16
16
  const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf8'));
@@ -39,63 +39,180 @@ const createCommandContext = () => {
39
39
  envContext: new AukletEnvContext(cwd),
40
40
  };
41
41
  };
42
+ const addBuildOverrideOptions = (command) => {
43
+ return command
44
+ .option('--source <dir>', 'Source directory')
45
+ .option('--output <dir>', 'Output directory')
46
+ .option('--modules [value]', 'Enable unbundled module output')
47
+ .option('--no-modules', 'Disable unbundled module output')
48
+ .option('--build.formats <formats>', 'Comma-separated cjs, esm, and/or iife formats')
49
+ .option('--build.target <target>', 'JavaScript target passed to tsdown')
50
+ .option('--build.platform <platform>', 'node, neutral, or browser')
51
+ .option('--build.tsconfig <file>', 'TypeScript config file');
52
+ };
53
+ const addWorkspaceOptions = (command) => {
54
+ return command
55
+ .option('--filter <pattern>', 'Select workspace packages by package name')
56
+ .option('--workspace', "Alias for --filter '*'")
57
+ .option('--private [value]', 'Include private workspace packages')
58
+ .option('--deps [value]', "Include selected packages' workspace dependencies");
59
+ };
60
+ const addPublishOptions = (command) => {
61
+ return command
62
+ .option('--filter <pattern>', 'Select workspace packages by package name')
63
+ .option('--workspace', "Alias for --filter '*'")
64
+ .option('--version <value>', 'Publish version or version bump')
65
+ .option('--dry-run [value]', 'Validate without writing git or registry state')
66
+ .option('--format [value]', 'Enable publish output formatter')
67
+ .option('--no-format', 'Disable publish output formatter')
68
+ .option('--git [value]', 'Create release commit and tag')
69
+ .option('--no-git', 'Skip release commit and tag')
70
+ .option('--allow-dirty [value]', 'Allow publishing from a dirty worktree')
71
+ .option('--ignore-scripts [value]', 'Skip publish lifecycle hooks')
72
+ .option('--otp <code>', 'Forward an npm 2FA one-time password')
73
+ .option('--token <value>', 'Set NODE_AUTH_TOKEN and NPM_TOKEN for subprocesses');
74
+ };
75
+ const createHelpFormatter = (cli) => {
76
+ return (sections) => {
77
+ const command = cli.matchedCommand?.name;
78
+ return sections.map((section) => {
79
+ if (section.title !== 'Options')
80
+ return section;
81
+ let body = section.body.replace(/\s+\(default: true\)/g, '');
82
+ if (!command) {
83
+ body = addHelpOptionLine(body, ' -v, --version Print auklet version');
84
+ }
85
+ if (command === 'publish') {
86
+ body = addHelpOptionLine(body, ' --version <value> Publish version or version bump');
87
+ }
88
+ if (command === 'inspect') {
89
+ body = addHelpOptionLine(body, ' --version <value> Publish version or version bump');
90
+ }
91
+ return {
92
+ ...section,
93
+ body,
94
+ };
95
+ });
96
+ };
97
+ };
98
+ const addHelpOptionLine = (body, line) => {
99
+ if (body.includes(line.trimStart().split(/\s+/)[0]))
100
+ return body;
101
+ const helpLinePattern = /^ -h, --help/m;
102
+ if (!helpLinePattern.test(body))
103
+ return `${body}\n${line}`;
104
+ return body.replace(helpLinePattern, `${line}\n -h, --help`);
105
+ };
42
106
  async function runCli(argv) {
43
107
  const cli = cac('auk');
44
- cli
45
- .command('build [...args]', 'Build package JavaScript and CSS output')
108
+ addWorkspaceOptions(addBuildOverrideOptions(cli.command('build [...args]', 'Build package JavaScript and CSS output')))
109
+ .ignoreOptionDefaultValue()
46
110
  .allowUnknownOptions()
47
111
  .action(() => runCliCommand(() => {
48
112
  const context = createCommandContext();
49
113
  return runBuild(parseBuildCommand(getRawCommandArgs(argv, 'build'), context));
50
114
  }));
51
- cli
52
- .command('build-js [...args]', 'Build package JavaScript output with tsdown')
115
+ addBuildOverrideOptions(cli.command('build-js [...args]', 'Build package JavaScript output with tsdown'))
116
+ .ignoreOptionDefaultValue()
53
117
  .allowUnknownOptions()
54
118
  .action(() => runCliCommand(() => {
55
119
  const context = createCommandContext();
56
120
  return runBuildJs(parseBuildJsCommand(getRawCommandArgs(argv, 'build-js'), context));
57
121
  }));
58
- cli
122
+ addBuildOverrideOptions(cli
59
123
  .command('build-css [...args]', 'Build package module CSS output')
60
- .option('-w, --watch', 'Watch module CSS output')
124
+ .option('-w, --watch', 'Watch module CSS output'))
125
+ .ignoreOptionDefaultValue()
61
126
  .allowUnknownOptions()
62
127
  .action(() => runCliCommand(() => {
63
128
  const context = createCommandContext();
64
129
  return runBuildCss(parseBuildCssCommand(getRawCommandArgs(argv, 'build-css'), context));
65
130
  }));
66
- cli
67
- .command('dev [...args]', 'Watch package JavaScript and CSS output')
131
+ addWorkspaceOptions(addBuildOverrideOptions(cli.command('dev [...args]', 'Watch package JavaScript and CSS output')))
132
+ .ignoreOptionDefaultValue()
68
133
  .allowUnknownOptions()
69
134
  .action(() => runCliCommand(() => {
70
135
  const context = createCommandContext();
71
136
  return runDev(parseDevCommand(getRawCommandArgs(argv, 'dev'), context));
72
137
  }));
73
- cli
74
- .command('publish [...args]', 'Build and publish package output with pnpm')
138
+ addPublishOptions(cli.command('publish [...args]', 'Build and publish package output with pnpm'))
139
+ .ignoreOptionDefaultValue()
75
140
  .allowUnknownOptions()
76
141
  .action(() => runCliCommand(() => runPublishCli(getRawCommandArgs(argv, 'publish'))));
142
+ cli
143
+ .command('owner add <user...>', 'Add npm owners to the current package or selected packages')
144
+ .option('--filter <pattern>', 'Add owners to matching workspace packages')
145
+ .option('--package <name>', 'Add owners to explicit npm packages')
146
+ .option('--otp <code>', 'Forward an npm owner-management 2FA code')
147
+ .ignoreOptionDefaultValue()
148
+ .allowUnknownOptions()
149
+ .action(() => runCliCommand(() => runOwnerCli(getRawCommandArgs(argv, 'owner'))));
77
150
  cli
78
151
  .command('owner [...args]', 'Manage npm package owners with pnpm')
152
+ .usage('add <user...> [options]')
153
+ .option('--filter <pattern>', 'Add owners to matching workspace packages')
154
+ .option('--package <name>', 'Add owners to explicit npm packages')
155
+ .option('--otp <code>', 'Forward an npm owner-management 2FA code')
156
+ .ignoreOptionDefaultValue()
79
157
  .allowUnknownOptions()
80
158
  .action(() => runCliCommand(() => runOwnerCli(getRawCommandArgs(argv, 'owner'))));
159
+ cli
160
+ .command('inspect publish [...args]', 'Check publish readiness')
161
+ .option('--filter <pattern>', 'Select workspace packages by package name')
162
+ .option('--workspace', "Alias for --filter '*'")
163
+ .option('--version <value>', 'Publish version or version bump')
164
+ .option('--dry-run [value]', 'Preview dry-run publish behavior')
165
+ .option('--otp <code>', 'Forward an npm 2FA one-time password')
166
+ .option('--token <value>', 'Set NODE_AUTH_TOKEN and NPM_TOKEN for subprocesses')
167
+ .ignoreOptionDefaultValue()
168
+ .allowUnknownOptions()
169
+ .action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
170
+ cli
171
+ .command('inspect pack [...args]', 'Check package entry and export files')
172
+ .option('--filter <pattern>', 'Select workspace packages by package name')
173
+ .ignoreOptionDefaultValue()
174
+ .allowUnknownOptions()
175
+ .action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
176
+ addBuildOverrideOptions(cli.command('inspect css [...args]', 'Explain CSS output plans'))
177
+ .ignoreOptionDefaultValue()
178
+ .allowUnknownOptions()
179
+ .action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
81
180
  cli
82
181
  .command('inspect [...args]', 'Inspect auklet plans without side effects')
182
+ .usage('<publish|pack|css> [...args]')
183
+ .option('--filter <pattern>', 'Select workspace packages by package name')
184
+ .option('--workspace', "Alias for --filter '*'")
185
+ .option('--version <value>', 'Publish version or version bump')
186
+ .option('--dry-run [value]', 'Preview dry-run publish behavior')
187
+ .option('--otp <code>', 'Forward an npm 2FA one-time password')
188
+ .option('--token <value>', 'Set publish auth token')
189
+ .option('--source <dir>', 'CSS inspect source directory')
190
+ .option('--output <dir>', 'CSS inspect output directory')
191
+ .option('--modules [value]', 'Enable CSS inspect module output')
192
+ .option('--no-modules', 'Disable CSS inspect module output')
193
+ .ignoreOptionDefaultValue()
83
194
  .allowUnknownOptions()
84
195
  .action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
85
196
  cli
86
197
  .command('version', 'Print auklet version')
87
198
  .action(() => runCliCommand(runVersion));
88
- cli.option('-v, --version', 'Print auklet version');
89
- cli.help();
199
+ cli.command('help', 'Print auklet help').action(() => runCliCommand(async () => {
200
+ cli.unsetMatchedCommand();
201
+ cli.outputHelp();
202
+ return 0;
203
+ }));
204
+ cli.help(createHelpFormatter(cli));
90
205
  if (argv.length <= 2) {
91
206
  cli.outputHelp();
92
207
  process.exit(1);
93
208
  }
94
- cli.parse(argv, { run: false });
95
- if (!cli.matchedCommand && cli.options.version) {
209
+ const rawArgs = argv.slice(2);
210
+ if (rawArgs.length === 1 &&
211
+ (rawArgs[0] === '-v' || rawArgs[0] === '--version')) {
96
212
  console.log(getPackageVersion());
97
213
  process.exit(0);
98
214
  }
215
+ cli.parse(argv, { run: false });
99
216
  if (cli.options.help) {
100
217
  process.exit(0);
101
218
  }
@@ -30,6 +30,7 @@ export declare function parseBuildCommand(args: Array<string>, options: {
30
30
  workspace: {
31
31
  filters: string[];
32
32
  includeDependencies: boolean;
33
+ includePrivate: boolean;
33
34
  };
34
35
  overrides: AukletConfig;
35
36
  passthroughArgs: string[];
@@ -10,6 +10,7 @@ export declare function parseDevCommand(args: Array<string>, options: {
10
10
  workspace: {
11
11
  filters: string[];
12
12
  includeDependencies: boolean;
13
+ includePrivate: boolean;
13
14
  };
14
15
  overrides: import("../..").AukletConfig;
15
16
  passthroughArgs: string[];
@@ -1,6 +1,7 @@
1
1
  import type { AukletEnvContext } from '#auklet/env';
2
2
  export type WorkspaceSelection = {
3
3
  filters: Array<string>;
4
+ includePrivate: boolean;
4
5
  includeDependencies: boolean;
5
6
  };
6
7
  export declare function parseWorkspaceSelectionArgs(args: Array<string>, envContext: AukletEnvContext): {
@@ -8,5 +9,6 @@ export declare function parseWorkspaceSelectionArgs(args: Array<string>, envCont
8
9
  workspace: {
9
10
  filters: string[];
10
11
  includeDependencies: boolean;
12
+ includePrivate: boolean;
11
13
  };
12
14
  };
@@ -1,8 +1,9 @@
1
1
  import { resolveCliBoolean, resolveCliValue } from '#auklet/cli/parse/values';
2
2
  import { dedupe, readFlagValue, readOptionalFlagValue, } from '#auklet/cli/parse/core';
3
3
  export function parseWorkspaceSelectionArgs(args, envContext) {
4
- const remainingArgs = [];
5
4
  const filters = [];
5
+ const remainingArgs = [];
6
+ let includePrivate = false;
6
7
  let includeDependencies = false;
7
8
  for (let index = 0; index < args.length; index += 1) {
8
9
  const arg = args[index];
@@ -24,12 +25,16 @@ export function parseWorkspaceSelectionArgs(args, envContext) {
24
25
  continue;
25
26
  }
26
27
  if (name === '--deps') {
27
- const value = readOptionalFlagValue(args, index, inlineValue);
28
- includeDependencies =
29
- value === undefined
30
- ? true
31
- : resolveCliBoolean(value, { label: name, context: envContext });
32
- if (inlineValue === undefined && value !== undefined)
28
+ const result = readWorkspaceBooleanFlag(args, index, inlineValue, name, envContext);
29
+ includeDependencies = result.value;
30
+ if (result.consumedNext)
31
+ index += 1;
32
+ continue;
33
+ }
34
+ if (name === '--private') {
35
+ const result = readWorkspaceBooleanFlag(args, index, inlineValue, name, envContext);
36
+ includePrivate = result.value;
37
+ if (result.consumedNext)
33
38
  index += 1;
34
39
  continue;
35
40
  }
@@ -40,6 +45,16 @@ export function parseWorkspaceSelectionArgs(args, envContext) {
40
45
  workspace: {
41
46
  filters: dedupe(filters),
42
47
  includeDependencies,
48
+ includePrivate,
43
49
  },
44
50
  };
45
51
  }
52
+ const readWorkspaceBooleanFlag = (args, index, inlineValue, name, envContext) => {
53
+ const value = readOptionalFlagValue(args, index, inlineValue);
54
+ return {
55
+ consumedNext: inlineValue === undefined && value !== undefined,
56
+ value: value === undefined
57
+ ? true
58
+ : resolveCliBoolean(value, { label: name, context: envContext }),
59
+ };
60
+ };
@@ -24,8 +24,9 @@ export async function resolveOwnerPackageNames(options) {
24
24
  });
25
25
  return packages.filter((item) => !item.private).map((item) => item.name);
26
26
  }
27
- if (options.packages.length)
27
+ if (options.packages.length) {
28
28
  return [...new Set(options.packages)];
29
+ }
29
30
  const packageJson = readPackageJson(options.cwd);
30
31
  if (packageJson.private) {
31
32
  throw new Error('[publish] current package is private.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
6
  "description": "Build utilities for TypeScript packages and module CSS output.",