auklet 0.1.5 → 0.1.7
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 +3 -0
- package/dist/cli/build.js +6 -2
- package/dist/cli/dev.js +6 -2
- package/dist/cli/help.d.ts +29 -0
- package/dist/cli/help.js +109 -0
- package/dist/cli/main.js +48 -20
- package/dist/cli/parse/build.d.ts +1 -0
- package/dist/cli/parse/dev.d.ts +1 -0
- package/dist/cli/parse/workspace.d.ts +2 -0
- package/dist/cli/parse/workspace.js +22 -7
- package/dist/cli/{buildWorkspace.d.ts → workspaceScripts.d.ts} +9 -6
- package/dist/cli/{buildWorkspace.js → workspaceScripts.js} +12 -12
- package/dist/publish/targetResolver.js +3 -1
- package/package.json +1 -1
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
|
@@ -6,7 +6,7 @@ import { loadAukletConfig } from '#auklet/configLoader';
|
|
|
6
6
|
import { createBuildEnv } from '#auklet/cli/parse/build';
|
|
7
7
|
import { runBuildCss } from '#auklet/cli/buildCss';
|
|
8
8
|
import { createAukletLogger } from '#auklet/logger';
|
|
9
|
-
import { getWorkspacePackageScript,
|
|
9
|
+
import { getWorkspacePackageScript, resolveWorkspaceScriptTargets, } from '#auklet/cli/workspaceScripts';
|
|
10
10
|
const workspaceBuildEnv = 'AUKLET_WORKSPACE_BUILD';
|
|
11
11
|
export async function runBuildJs(options) {
|
|
12
12
|
return options.envContext.run(async () => {
|
|
@@ -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) {
|
|
@@ -47,8 +48,11 @@ export async function runBuild(options) {
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
const runWorkspaceBuild = async (args, options) => {
|
|
50
|
-
const targets = await
|
|
51
|
+
const targets = await resolveWorkspaceScriptTargets(options.cwd, options.filters, options.envContext, {
|
|
52
|
+
scope: 'build',
|
|
53
|
+
emptyTargetMessage: '[build] no buildable workspace package found.',
|
|
51
54
|
includeDependencies: options.includeDependencies,
|
|
55
|
+
includePrivate: options.includePrivate,
|
|
52
56
|
});
|
|
53
57
|
const logger = createAukletLogger();
|
|
54
58
|
for (const target of targets) {
|
package/dist/cli/dev.js
CHANGED
|
@@ -2,7 +2,7 @@ import { execa } from 'execa';
|
|
|
2
2
|
import { createTsdownArgs } from '#auklet/build/runTsdown';
|
|
3
3
|
import { createBuildEnv } from '#auklet/cli/parse/build';
|
|
4
4
|
import { resolveBuildCssConfig, startBuildCssWatch, } from '#auklet/cli/buildCss';
|
|
5
|
-
import { getWorkspacePackageScript,
|
|
5
|
+
import { getWorkspacePackageScript, resolveWorkspaceScriptTargets, } from '#auklet/cli/workspaceScripts';
|
|
6
6
|
const workspaceDevEnv = 'AUKLET_WORKSPACE_DEV';
|
|
7
7
|
export async function runDev(options) {
|
|
8
8
|
return options.envContext.run(async () => {
|
|
@@ -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) {
|
|
@@ -57,8 +58,11 @@ const runDevWithEnv = async (options) => {
|
|
|
57
58
|
const runWorkspaceDev = async (options) => {
|
|
58
59
|
let closed = false;
|
|
59
60
|
const handles = [];
|
|
60
|
-
const targets = await
|
|
61
|
+
const targets = await resolveWorkspaceScriptTargets(options.cwd, options.filters, options.envContext, {
|
|
62
|
+
scope: 'dev',
|
|
63
|
+
emptyTargetMessage: '[dev] no dev workspace package found.',
|
|
61
64
|
includeDependencies: options.includeDependencies,
|
|
65
|
+
includePrivate: options.includePrivate,
|
|
62
66
|
});
|
|
63
67
|
const close = async () => {
|
|
64
68
|
if (closed)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CAC, Command } from 'cac';
|
|
2
|
+
type HelpOption = readonly [flags: string, description: string];
|
|
3
|
+
export declare const buildOverrideOptions: [string, string][];
|
|
4
|
+
export declare const workspaceOptions: [string, string][];
|
|
5
|
+
export declare const publishOptions: [string, string][];
|
|
6
|
+
export declare const ownerOptions: [string, string][];
|
|
7
|
+
export declare const inspectPublishOptions: [string, string][];
|
|
8
|
+
export declare const inspectPackOptions: [string, string][];
|
|
9
|
+
export declare const inspectCssOptions: [string, string][];
|
|
10
|
+
export declare const inspectOptions: [string, string][];
|
|
11
|
+
export declare const commandHelpOptions: {
|
|
12
|
+
buildOverrides: [string, string][];
|
|
13
|
+
inspect: [string, string][];
|
|
14
|
+
inspectCss: [string, string][];
|
|
15
|
+
inspectPack: [string, string][];
|
|
16
|
+
inspectPublish: [string, string][];
|
|
17
|
+
owner: [string, string][];
|
|
18
|
+
publish: [string, string][];
|
|
19
|
+
workspace: [string, string][];
|
|
20
|
+
};
|
|
21
|
+
export declare function addCommandOptions(command: Command, options: ReadonlyArray<HelpOption>): Command;
|
|
22
|
+
export declare function createHelpFormatter(cli: CAC): (sections: Array<{
|
|
23
|
+
title?: string;
|
|
24
|
+
body: string;
|
|
25
|
+
}>) => {
|
|
26
|
+
title?: string;
|
|
27
|
+
body: string;
|
|
28
|
+
}[];
|
|
29
|
+
export {};
|
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export const buildOverrideOptions = [
|
|
2
|
+
['--source <dir>', 'Source directory'],
|
|
3
|
+
['--output <dir>', 'Output directory'],
|
|
4
|
+
['--modules [value]', 'Enable unbundled module output'],
|
|
5
|
+
['--no-modules', 'Disable unbundled module output'],
|
|
6
|
+
[
|
|
7
|
+
'--build.formats <formats>',
|
|
8
|
+
'Comma-separated cjs, esm, and/or iife formats',
|
|
9
|
+
],
|
|
10
|
+
['--build.target <target>', 'JavaScript target passed to tsdown'],
|
|
11
|
+
['--build.platform <platform>', 'node, neutral, or browser'],
|
|
12
|
+
['--build.tsconfig <file>', 'TypeScript config file'],
|
|
13
|
+
];
|
|
14
|
+
export const workspaceOptions = [
|
|
15
|
+
['--filter <pattern>', 'Select workspace packages by package name'],
|
|
16
|
+
['--workspace', "Alias for --filter '*'"],
|
|
17
|
+
['--private [value]', 'Include private workspace packages'],
|
|
18
|
+
['--deps [value]', "Include selected packages' workspace dependencies"],
|
|
19
|
+
];
|
|
20
|
+
export const publishOptions = [
|
|
21
|
+
['--filter <pattern>', 'Select workspace packages by package name'],
|
|
22
|
+
['--workspace', "Alias for --filter '*'"],
|
|
23
|
+
['--version <value>', 'Publish version or version bump'],
|
|
24
|
+
['--dry-run [value]', 'Validate without writing git or registry state'],
|
|
25
|
+
['--format [value]', 'Enable publish output formatter'],
|
|
26
|
+
['--no-format', 'Disable publish output formatter'],
|
|
27
|
+
['--git [value]', 'Create release commit and tag'],
|
|
28
|
+
['--no-git', 'Skip release commit and tag'],
|
|
29
|
+
['--allow-dirty [value]', 'Allow publishing from a dirty worktree'],
|
|
30
|
+
['--ignore-scripts [value]', 'Skip publish lifecycle hooks'],
|
|
31
|
+
['--otp <code>', 'Forward an npm 2FA one-time password'],
|
|
32
|
+
['--token <value>', 'Set NODE_AUTH_TOKEN and NPM_TOKEN for subprocesses'],
|
|
33
|
+
];
|
|
34
|
+
export const ownerOptions = [
|
|
35
|
+
['--filter <pattern>', 'Add owners to matching workspace packages'],
|
|
36
|
+
['--package <name>', 'Add owners to explicit npm packages'],
|
|
37
|
+
['--otp <code>', 'Forward an npm owner-management 2FA code'],
|
|
38
|
+
];
|
|
39
|
+
export const inspectPublishOptions = [
|
|
40
|
+
['--filter <pattern>', 'Select workspace packages by package name'],
|
|
41
|
+
['--workspace', "Alias for --filter '*'"],
|
|
42
|
+
['--version <value>', 'Publish version or version bump'],
|
|
43
|
+
['--dry-run [value]', 'Preview dry-run publish behavior'],
|
|
44
|
+
['--otp <code>', 'Forward an npm 2FA one-time password'],
|
|
45
|
+
['--token <value>', 'Set NODE_AUTH_TOKEN and NPM_TOKEN for subprocesses'],
|
|
46
|
+
];
|
|
47
|
+
export const inspectPackOptions = [
|
|
48
|
+
['--filter <pattern>', 'Select workspace packages by package name'],
|
|
49
|
+
];
|
|
50
|
+
export const inspectCssOptions = [
|
|
51
|
+
['--source <dir>', 'CSS inspect source directory'],
|
|
52
|
+
['--output <dir>', 'CSS inspect output directory'],
|
|
53
|
+
['--modules [value]', 'Enable CSS inspect module output'],
|
|
54
|
+
['--no-modules', 'Disable CSS inspect module output'],
|
|
55
|
+
];
|
|
56
|
+
export const inspectOptions = [
|
|
57
|
+
...inspectPublishOptions,
|
|
58
|
+
...inspectPackOptions,
|
|
59
|
+
...inspectCssOptions,
|
|
60
|
+
].filter((option, index, options) => {
|
|
61
|
+
// First matching flag wins; keep shared inspect flag descriptions aligned.
|
|
62
|
+
return options.findIndex(([flags]) => flags === option[0]) === index;
|
|
63
|
+
});
|
|
64
|
+
export const commandHelpOptions = {
|
|
65
|
+
buildOverrides: buildOverrideOptions,
|
|
66
|
+
inspect: inspectOptions,
|
|
67
|
+
inspectCss: inspectCssOptions,
|
|
68
|
+
inspectPack: inspectPackOptions,
|
|
69
|
+
inspectPublish: inspectPublishOptions,
|
|
70
|
+
owner: ownerOptions,
|
|
71
|
+
publish: publishOptions,
|
|
72
|
+
workspace: workspaceOptions,
|
|
73
|
+
};
|
|
74
|
+
export function addCommandOptions(command, options) {
|
|
75
|
+
return options.reduce((currentCommand, [flags, description]) => currentCommand.option(flags, description), command);
|
|
76
|
+
}
|
|
77
|
+
export function createHelpFormatter(cli) {
|
|
78
|
+
return (sections) => {
|
|
79
|
+
const command = cli.matchedCommand?.name;
|
|
80
|
+
return sections.map((section) => {
|
|
81
|
+
if (section.title !== 'Options')
|
|
82
|
+
return section;
|
|
83
|
+
// CAC hides duplicate --version entries, so command-level version flags
|
|
84
|
+
// are patched back into help output here.
|
|
85
|
+
let body = section.body.replace(/\s+\(default: true\)/g, '');
|
|
86
|
+
if (!command) {
|
|
87
|
+
body = addHelpOptionLine(body, '--version', ' -v, --version Print auklet version');
|
|
88
|
+
}
|
|
89
|
+
if (command === 'publish') {
|
|
90
|
+
body = addHelpOptionLine(body, '--version', ' --version <value> Publish version or version bump');
|
|
91
|
+
}
|
|
92
|
+
if (command === 'inspect') {
|
|
93
|
+
body = addHelpOptionLine(body, '--version', ' --version <value> Publish version or version bump');
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
...section,
|
|
97
|
+
body,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const addHelpOptionLine = (body, key, line) => {
|
|
103
|
+
if (body.includes(key))
|
|
104
|
+
return body;
|
|
105
|
+
const helpLinePattern = /^ -h, --help/m;
|
|
106
|
+
if (!helpLinePattern.test(body))
|
|
107
|
+
return `${body}\n${line}`;
|
|
108
|
+
return body.replace(helpLinePattern, `${line}\n -h, --help`);
|
|
109
|
+
};
|
package/dist/cli/main.js
CHANGED
|
@@ -2,15 +2,16 @@ 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 {
|
|
10
|
-
import { runOwnerCli, runPublishCli } from '#auklet/publish/cli';
|
|
11
|
-
import { AukletEnvContext } from '#auklet/env';
|
|
13
|
+
import { addCommandOptions, commandHelpOptions, createHelpFormatter, } from '#auklet/cli/help';
|
|
12
14
|
import { parseBuildCommand, parseBuildCssCommand, parseBuildJsCommand, } from '#auklet/cli/parse/build';
|
|
13
|
-
import { parseDevCommand } from '#auklet/cli/parse/dev';
|
|
14
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
16
|
const getPackageVersion = () => {
|
|
16
17
|
const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf8'));
|
|
@@ -41,61 +42,88 @@ const createCommandContext = () => {
|
|
|
41
42
|
};
|
|
42
43
|
async function runCli(argv) {
|
|
43
44
|
const cli = cac('auk');
|
|
44
|
-
cli
|
|
45
|
-
.
|
|
45
|
+
addCommandOptions(addCommandOptions(cli.command('build [...args]', 'Build package JavaScript and CSS output'), commandHelpOptions.buildOverrides), commandHelpOptions.workspace)
|
|
46
|
+
.ignoreOptionDefaultValue()
|
|
46
47
|
.allowUnknownOptions()
|
|
47
48
|
.action(() => runCliCommand(() => {
|
|
48
49
|
const context = createCommandContext();
|
|
49
50
|
return runBuild(parseBuildCommand(getRawCommandArgs(argv, 'build'), context));
|
|
50
51
|
}));
|
|
51
|
-
cli
|
|
52
|
-
.
|
|
52
|
+
addCommandOptions(cli.command('build-js [...args]', 'Build package JavaScript output with tsdown'), commandHelpOptions.buildOverrides)
|
|
53
|
+
.ignoreOptionDefaultValue()
|
|
53
54
|
.allowUnknownOptions()
|
|
54
55
|
.action(() => runCliCommand(() => {
|
|
55
56
|
const context = createCommandContext();
|
|
56
57
|
return runBuildJs(parseBuildJsCommand(getRawCommandArgs(argv, 'build-js'), context));
|
|
57
58
|
}));
|
|
58
|
-
cli
|
|
59
|
+
addCommandOptions(cli
|
|
59
60
|
.command('build-css [...args]', 'Build package module CSS output')
|
|
60
|
-
.option('-w, --watch', 'Watch module CSS output')
|
|
61
|
+
.option('-w, --watch', 'Watch module CSS output'), commandHelpOptions.buildOverrides)
|
|
62
|
+
.ignoreOptionDefaultValue()
|
|
61
63
|
.allowUnknownOptions()
|
|
62
64
|
.action(() => runCliCommand(() => {
|
|
63
65
|
const context = createCommandContext();
|
|
64
66
|
return runBuildCss(parseBuildCssCommand(getRawCommandArgs(argv, 'build-css'), context));
|
|
65
67
|
}));
|
|
66
|
-
cli
|
|
67
|
-
.
|
|
68
|
+
addCommandOptions(addCommandOptions(cli.command('dev [...args]', 'Watch package JavaScript and CSS output'), commandHelpOptions.buildOverrides), commandHelpOptions.workspace)
|
|
69
|
+
.ignoreOptionDefaultValue()
|
|
68
70
|
.allowUnknownOptions()
|
|
69
71
|
.action(() => runCliCommand(() => {
|
|
70
72
|
const context = createCommandContext();
|
|
71
73
|
return runDev(parseDevCommand(getRawCommandArgs(argv, 'dev'), context));
|
|
72
74
|
}));
|
|
73
|
-
cli
|
|
74
|
-
.
|
|
75
|
+
addCommandOptions(cli.command('publish [...args]', 'Build and publish package output with pnpm'), commandHelpOptions.publish)
|
|
76
|
+
.ignoreOptionDefaultValue()
|
|
75
77
|
.allowUnknownOptions()
|
|
76
78
|
.action(() => runCliCommand(() => runPublishCli(getRawCommandArgs(argv, 'publish'))));
|
|
77
|
-
cli
|
|
79
|
+
addCommandOptions(cli.command('owner add <user...>', 'Add npm owners to the current package or selected packages'), commandHelpOptions.owner)
|
|
80
|
+
.ignoreOptionDefaultValue()
|
|
81
|
+
.allowUnknownOptions()
|
|
82
|
+
.action(() => runCliCommand(() => runOwnerCli(getRawCommandArgs(argv, 'owner'))));
|
|
83
|
+
addCommandOptions(cli
|
|
78
84
|
.command('owner [...args]', 'Manage npm package owners with pnpm')
|
|
85
|
+
.usage('add <user...> [options]'), commandHelpOptions.owner)
|
|
86
|
+
.ignoreOptionDefaultValue()
|
|
79
87
|
.allowUnknownOptions()
|
|
80
88
|
.action(() => runCliCommand(() => runOwnerCli(getRawCommandArgs(argv, 'owner'))));
|
|
81
|
-
cli
|
|
89
|
+
addCommandOptions(cli.command('inspect publish [...args]', 'Check publish readiness'), commandHelpOptions.inspectPublish)
|
|
90
|
+
.ignoreOptionDefaultValue()
|
|
91
|
+
.allowUnknownOptions()
|
|
92
|
+
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
93
|
+
addCommandOptions(cli.command('inspect pack [...args]', 'Check package entry and export files'), commandHelpOptions.inspectPack)
|
|
94
|
+
.ignoreOptionDefaultValue()
|
|
95
|
+
.allowUnknownOptions()
|
|
96
|
+
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
97
|
+
addCommandOptions(cli.command('inspect css [...args]', 'Explain CSS output plans'), commandHelpOptions.inspectCss)
|
|
98
|
+
.ignoreOptionDefaultValue()
|
|
99
|
+
.allowUnknownOptions()
|
|
100
|
+
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
101
|
+
addCommandOptions(cli
|
|
82
102
|
.command('inspect [...args]', 'Inspect auklet plans without side effects')
|
|
103
|
+
.usage('<publish|pack|css> [...args]'), commandHelpOptions.inspect)
|
|
104
|
+
.ignoreOptionDefaultValue()
|
|
83
105
|
.allowUnknownOptions()
|
|
84
106
|
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
85
107
|
cli
|
|
86
108
|
.command('version', 'Print auklet version')
|
|
87
109
|
.action(() => runCliCommand(runVersion));
|
|
88
|
-
cli.
|
|
89
|
-
|
|
110
|
+
cli.command('help', 'Print auklet help').action(() => runCliCommand(async () => {
|
|
111
|
+
cli.unsetMatchedCommand();
|
|
112
|
+
cli.outputHelp();
|
|
113
|
+
return 0;
|
|
114
|
+
}));
|
|
115
|
+
cli.help(createHelpFormatter(cli));
|
|
90
116
|
if (argv.length <= 2) {
|
|
91
117
|
cli.outputHelp();
|
|
92
118
|
process.exit(1);
|
|
93
119
|
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
120
|
+
const rawArgs = argv.slice(2);
|
|
121
|
+
if (rawArgs.length === 1 &&
|
|
122
|
+
(rawArgs[0] === '-v' || rawArgs[0] === '--version')) {
|
|
96
123
|
console.log(getPackageVersion());
|
|
97
124
|
process.exit(0);
|
|
98
125
|
}
|
|
126
|
+
cli.parse(argv, { run: false });
|
|
99
127
|
if (cli.options.help) {
|
|
100
128
|
process.exit(0);
|
|
101
129
|
}
|
package/dist/cli/parse/dev.d.ts
CHANGED
|
@@ -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
|
|
28
|
-
includeDependencies =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AukletEnvContext } from '#auklet/env';
|
|
2
|
-
type
|
|
2
|
+
type WorkspaceScriptPackageJson = {
|
|
3
3
|
name?: string;
|
|
4
4
|
private?: boolean;
|
|
5
5
|
scripts?: unknown;
|
|
@@ -7,17 +7,20 @@ type WorkspaceBuildPackageJson = {
|
|
|
7
7
|
optionalDependencies?: unknown;
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
10
|
+
export type WorkspaceScriptTarget = {
|
|
11
11
|
packageRoot: string;
|
|
12
12
|
packageName: string;
|
|
13
|
-
packageJson:
|
|
13
|
+
packageJson: WorkspaceScriptPackageJson;
|
|
14
14
|
};
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function resolveWorkspaceScriptTargets(cwd: string, filters: Array<string>, envContext: AukletEnvContext, options?: {
|
|
16
|
+
scope?: string;
|
|
17
|
+
emptyTargetMessage?: string;
|
|
18
|
+
includePrivate?: boolean;
|
|
16
19
|
includeDependencies?: boolean;
|
|
17
20
|
}): Promise<{
|
|
18
21
|
packageRoot: string;
|
|
19
22
|
packageName: string;
|
|
20
|
-
packageJson:
|
|
23
|
+
packageJson: WorkspaceScriptPackageJson;
|
|
21
24
|
}[]>;
|
|
22
|
-
export declare function getWorkspacePackageScript(packageJson:
|
|
25
|
+
export declare function getWorkspacePackageScript(packageJson: WorkspaceScriptPackageJson, name: string): string | null;
|
|
23
26
|
export {};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { isPlainObject, isString } from 'aidly';
|
|
4
|
-
import {
|
|
5
|
-
export async function
|
|
4
|
+
import { resolveWorkspaceTargets, getWorkspaceDependencyNames, } from '#auklet/workspace/targets';
|
|
5
|
+
export async function resolveWorkspaceScriptTargets(cwd, filters, envContext, options = {}) {
|
|
6
6
|
return resolveWorkspaceTargets({
|
|
7
7
|
cwd,
|
|
8
8
|
filters,
|
|
9
|
-
env: envContext.normalizedValues,
|
|
10
|
-
scope: 'build',
|
|
11
|
-
emptyTargetMessage: '[build] no buildable workspace package found.',
|
|
12
9
|
excludeRoot: true,
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
env: envContext.normalizedValues,
|
|
11
|
+
scope: options.scope ?? 'workspace',
|
|
12
|
+
emptyTargetMessage: options.emptyTargetMessage ?? '[workspace] no workspace package found.',
|
|
13
|
+
includePrivate: options.includePrivate,
|
|
14
|
+
readPackageJson: readWorkspaceScriptPackageJson,
|
|
15
|
+
getDependencies: getWorkspaceScriptDependencies,
|
|
16
|
+
includeDependencies: options.includeDependencies,
|
|
15
17
|
createTarget: (item, packageJson) => ({
|
|
16
18
|
packageRoot: item.path,
|
|
17
19
|
packageName: item.name,
|
|
18
20
|
packageJson,
|
|
19
21
|
}),
|
|
20
|
-
getDependencies: getBuildWorkspaceDependencies,
|
|
21
|
-
includeDependencies: options.includeDependencies,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const readWorkspaceScriptPackageJson = (packageRoot) => {
|
|
25
25
|
const file = path.join(packageRoot, 'package.json');
|
|
26
26
|
const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
27
27
|
if (!isPlainObject(packageJson)) {
|
|
28
|
-
throw new Error(`[
|
|
28
|
+
throw new Error(`[workspace] package.json must be an object at ${file}.`);
|
|
29
29
|
}
|
|
30
30
|
return packageJson;
|
|
31
31
|
};
|
|
32
|
-
const
|
|
32
|
+
const getWorkspaceScriptDependencies = (target) => {
|
|
33
33
|
return [
|
|
34
34
|
...getWorkspaceDependencyNames(target.packageJson.dependencies),
|
|
35
35
|
...getWorkspaceDependencyNames(target.packageJson.optionalDependencies),
|
|
@@ -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.');
|
|
@@ -73,6 +74,7 @@ const resolveMonorepoPublishPlan = async (options, runtime, logger) => {
|
|
|
73
74
|
filters: options.filters,
|
|
74
75
|
getDependencies: getWorkspaceDependencies,
|
|
75
76
|
emptyTargetMessage: '[publish] no publishable package found.',
|
|
77
|
+
includePrivate: false,
|
|
76
78
|
createTarget: (item, packageJson) => createPublishTarget({
|
|
77
79
|
packageRoot: item.path,
|
|
78
80
|
packageJson,
|