auklet 0.1.6 → 0.1.8
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/dist/cli/build.js +4 -2
- package/dist/cli/dev.js +4 -2
- package/dist/cli/help.d.ts +29 -0
- package/dist/cli/help.js +109 -0
- package/dist/cli/main.js +15 -104
- package/dist/cli/{buildWorkspace.d.ts → workspaceScripts.d.ts} +8 -6
- package/dist/cli/{buildWorkspace.js → workspaceScripts.js} +11 -11
- package/dist/css/core/styleModuleEntryPlanner.d.ts +4 -1
- package/dist/css/core/styleModuleEntryPlanner.js +35 -0
- package/dist/css/core/styleProcessor.d.ts +5 -0
- package/dist/css/core/styleProcessor.js +9 -3
- package/dist/publish/targetResolver.js +1 -0
- package/package.json +1 -1
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 () => {
|
|
@@ -48,7 +48,9 @@ export async function runBuild(options) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
const runWorkspaceBuild = async (args, options) => {
|
|
51
|
-
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.',
|
|
52
54
|
includeDependencies: options.includeDependencies,
|
|
53
55
|
includePrivate: options.includePrivate,
|
|
54
56
|
});
|
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 () => {
|
|
@@ -58,7 +58,9 @@ const runDevWithEnv = async (options) => {
|
|
|
58
58
|
const runWorkspaceDev = async (options) => {
|
|
59
59
|
let closed = false;
|
|
60
60
|
const handles = [];
|
|
61
|
-
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.',
|
|
62
64
|
includeDependencies: options.includeDependencies,
|
|
63
65
|
includePrivate: options.includePrivate,
|
|
64
66
|
});
|
|
@@ -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
|
@@ -10,6 +10,7 @@ import { runInspect } from '#auklet/cli/inspect';
|
|
|
10
10
|
import { runBuildCss } from '#auklet/cli/buildCss';
|
|
11
11
|
import { parseDevCommand } from '#auklet/cli/parse/dev';
|
|
12
12
|
import { runBuild, runBuildJs } from '#auklet/cli/build';
|
|
13
|
+
import { addCommandOptions, commandHelpOptions, createHelpFormatter, } from '#auklet/cli/help';
|
|
13
14
|
import { parseBuildCommand, parseBuildCssCommand, parseBuildJsCommand, } from '#auklet/cli/parse/build';
|
|
14
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
16
|
const getPackageVersion = () => {
|
|
@@ -39,157 +40,67 @@ const createCommandContext = () => {
|
|
|
39
40
|
envContext: new AukletEnvContext(cwd),
|
|
40
41
|
};
|
|
41
42
|
};
|
|
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
|
-
};
|
|
106
43
|
async function runCli(argv) {
|
|
107
44
|
const cli = cac('auk');
|
|
108
|
-
|
|
45
|
+
addCommandOptions(addCommandOptions(cli.command('build [...args]', 'Build package JavaScript and CSS output'), commandHelpOptions.buildOverrides), commandHelpOptions.workspace)
|
|
109
46
|
.ignoreOptionDefaultValue()
|
|
110
47
|
.allowUnknownOptions()
|
|
111
48
|
.action(() => runCliCommand(() => {
|
|
112
49
|
const context = createCommandContext();
|
|
113
50
|
return runBuild(parseBuildCommand(getRawCommandArgs(argv, 'build'), context));
|
|
114
51
|
}));
|
|
115
|
-
|
|
52
|
+
addCommandOptions(cli.command('build-js [...args]', 'Build package JavaScript output with tsdown'), commandHelpOptions.buildOverrides)
|
|
116
53
|
.ignoreOptionDefaultValue()
|
|
117
54
|
.allowUnknownOptions()
|
|
118
55
|
.action(() => runCliCommand(() => {
|
|
119
56
|
const context = createCommandContext();
|
|
120
57
|
return runBuildJs(parseBuildJsCommand(getRawCommandArgs(argv, 'build-js'), context));
|
|
121
58
|
}));
|
|
122
|
-
|
|
59
|
+
addCommandOptions(cli
|
|
123
60
|
.command('build-css [...args]', 'Build package module CSS output')
|
|
124
|
-
.option('-w, --watch', 'Watch module CSS output'))
|
|
61
|
+
.option('-w, --watch', 'Watch module CSS output'), commandHelpOptions.buildOverrides)
|
|
125
62
|
.ignoreOptionDefaultValue()
|
|
126
63
|
.allowUnknownOptions()
|
|
127
64
|
.action(() => runCliCommand(() => {
|
|
128
65
|
const context = createCommandContext();
|
|
129
66
|
return runBuildCss(parseBuildCssCommand(getRawCommandArgs(argv, 'build-css'), context));
|
|
130
67
|
}));
|
|
131
|
-
|
|
68
|
+
addCommandOptions(addCommandOptions(cli.command('dev [...args]', 'Watch package JavaScript and CSS output'), commandHelpOptions.buildOverrides), commandHelpOptions.workspace)
|
|
132
69
|
.ignoreOptionDefaultValue()
|
|
133
70
|
.allowUnknownOptions()
|
|
134
71
|
.action(() => runCliCommand(() => {
|
|
135
72
|
const context = createCommandContext();
|
|
136
73
|
return runDev(parseDevCommand(getRawCommandArgs(argv, 'dev'), context));
|
|
137
74
|
}));
|
|
138
|
-
|
|
75
|
+
addCommandOptions(cli.command('publish [...args]', 'Build and publish package output with pnpm'), commandHelpOptions.publish)
|
|
139
76
|
.ignoreOptionDefaultValue()
|
|
140
77
|
.allowUnknownOptions()
|
|
141
78
|
.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')
|
|
79
|
+
addCommandOptions(cli.command('owner add <user...>', 'Add npm owners to the current package or selected packages'), commandHelpOptions.owner)
|
|
147
80
|
.ignoreOptionDefaultValue()
|
|
148
81
|
.allowUnknownOptions()
|
|
149
82
|
.action(() => runCliCommand(() => runOwnerCli(getRawCommandArgs(argv, 'owner'))));
|
|
150
|
-
cli
|
|
83
|
+
addCommandOptions(cli
|
|
151
84
|
.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')
|
|
85
|
+
.usage('add <user...> [options]'), commandHelpOptions.owner)
|
|
156
86
|
.ignoreOptionDefaultValue()
|
|
157
87
|
.allowUnknownOptions()
|
|
158
88
|
.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')
|
|
89
|
+
addCommandOptions(cli.command('inspect publish [...args]', 'Check publish readiness'), commandHelpOptions.inspectPublish)
|
|
167
90
|
.ignoreOptionDefaultValue()
|
|
168
91
|
.allowUnknownOptions()
|
|
169
92
|
.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')
|
|
93
|
+
addCommandOptions(cli.command('inspect pack [...args]', 'Check package entry and export files'), commandHelpOptions.inspectPack)
|
|
173
94
|
.ignoreOptionDefaultValue()
|
|
174
95
|
.allowUnknownOptions()
|
|
175
96
|
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
176
|
-
|
|
97
|
+
addCommandOptions(cli.command('inspect css [...args]', 'Explain CSS output plans'), commandHelpOptions.inspectCss)
|
|
177
98
|
.ignoreOptionDefaultValue()
|
|
178
99
|
.allowUnknownOptions()
|
|
179
100
|
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
180
|
-
cli
|
|
101
|
+
addCommandOptions(cli
|
|
181
102
|
.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')
|
|
103
|
+
.usage('<publish|pack|css> [...args]'), commandHelpOptions.inspect)
|
|
193
104
|
.ignoreOptionDefaultValue()
|
|
194
105
|
.allowUnknownOptions()
|
|
195
106
|
.action(() => runCliCommand(() => runInspect(getRawCommandArgs(argv, 'inspect'))));
|
|
@@ -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,18 +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;
|
|
16
18
|
includePrivate?: boolean;
|
|
17
19
|
includeDependencies?: boolean;
|
|
18
20
|
}): Promise<{
|
|
19
21
|
packageRoot: string;
|
|
20
22
|
packageName: string;
|
|
21
|
-
packageJson:
|
|
23
|
+
packageJson: WorkspaceScriptPackageJson;
|
|
22
24
|
}[]>;
|
|
23
|
-
export declare function getWorkspacePackageScript(packageJson:
|
|
25
|
+
export declare function getWorkspacePackageScript(packageJson: WorkspaceScriptPackageJson, name: string): string | null;
|
|
24
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,
|
|
10
|
+
env: envContext.normalizedValues,
|
|
11
|
+
scope: options.scope ?? 'workspace',
|
|
13
12
|
includePrivate: options.includePrivate,
|
|
14
|
-
readPackageJson:
|
|
13
|
+
readPackageJson: readWorkspaceScriptPackageJson,
|
|
14
|
+
getDependencies: getWorkspaceScriptDependencies,
|
|
15
|
+
includeDependencies: options.includeDependencies,
|
|
16
|
+
emptyTargetMessage: options.emptyTargetMessage ?? '[workspace] no workspace package found.',
|
|
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),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
2
2
|
export type ModuleStyleEntryPlan = {
|
|
3
3
|
sourceDir: string;
|
|
4
|
-
moduleStyleImports: Array<string>;
|
|
5
4
|
ownStyleFiles: Array<string>;
|
|
5
|
+
moduleStyleImports: Array<string>;
|
|
6
6
|
};
|
|
7
7
|
export declare class StyleModuleEntryPlanner {
|
|
8
8
|
private readonly packageContext;
|
|
@@ -23,4 +23,7 @@ export declare class StyleModuleEntryPlanner {
|
|
|
23
23
|
private getSourceModuleDirs;
|
|
24
24
|
private getOwnStyleDirs;
|
|
25
25
|
private getOwnStyleFiles;
|
|
26
|
+
private rejectCrossModuleStyleImports;
|
|
27
|
+
private getStyleFileModuleDir;
|
|
28
|
+
private toRelativeSourceFile;
|
|
26
29
|
}
|
|
@@ -11,6 +11,7 @@ export class StyleModuleEntryPlanner {
|
|
|
11
11
|
this.styleFilesByDir = groupStyleFilesByDir(this.packageContext.sourceRoot, this.packageContext.styleFiles);
|
|
12
12
|
this.importedStyleFiles =
|
|
13
13
|
this.packageContext.styleProcessor.collectImportedStyleFiles(this.packageContext.styleFiles);
|
|
14
|
+
this.rejectCrossModuleStyleImports();
|
|
14
15
|
}
|
|
15
16
|
createEntries(moduleStyleImports) {
|
|
16
17
|
return this.getSourceDirs(moduleStyleImports).map((sourceDir) => this.createEntry(sourceDir, moduleStyleImports));
|
|
@@ -47,4 +48,38 @@ export class StyleModuleEntryPlanner {
|
|
|
47
48
|
getOwnStyleFiles(sourceDir) {
|
|
48
49
|
return (this.styleFilesByDir.get(sourceDir) ?? []).filter((styleFile) => !this.importedStyleFiles.has(path.resolve(styleFile)));
|
|
49
50
|
}
|
|
51
|
+
rejectCrossModuleStyleImports() {
|
|
52
|
+
if (!this.packageContext.normalizedConfig.modules)
|
|
53
|
+
return;
|
|
54
|
+
const styleFileKeys = new Set(this.packageContext.styleFiles.map((file) => path.resolve(file)));
|
|
55
|
+
const imports = this.packageContext.styleProcessor.collectImportedStyleFileReferences(this.packageContext.styleFiles);
|
|
56
|
+
for (const item of imports) {
|
|
57
|
+
if (!styleFileKeys.has(item.imported))
|
|
58
|
+
continue;
|
|
59
|
+
const importerModuleDir = this.getStyleFileModuleDir(item.importer);
|
|
60
|
+
const importedModuleDir = this.getStyleFileModuleDir(item.imported);
|
|
61
|
+
if (!importerModuleDir ||
|
|
62
|
+
!importedModuleDir ||
|
|
63
|
+
importerModuleDir === importedModuleDir) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const importer = this.toRelativeSourceFile(item.importer);
|
|
67
|
+
const imported = this.toRelativeSourceFile(item.imported);
|
|
68
|
+
throw new Error(`[css] cross-component CSS import detected: ${importer} imports ${imported}. ` +
|
|
69
|
+
'Use TSX imports to express component dependencies so auklet can ' +
|
|
70
|
+
'generate module CSS entries correctly.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
getStyleFileModuleDir(file) {
|
|
74
|
+
const sourceRelative = toPosixPath(path.relative(this.packageContext.sourceRoot, file));
|
|
75
|
+
const parts = sourceRelative.split('/');
|
|
76
|
+
if (parts.length < 2)
|
|
77
|
+
return null;
|
|
78
|
+
if (parts.length === 2)
|
|
79
|
+
return getSourceModuleDir(sourceRelative);
|
|
80
|
+
return parts.slice(0, 2).join('/');
|
|
81
|
+
}
|
|
82
|
+
toRelativeSourceFile(file) {
|
|
83
|
+
return toPosixPath(path.relative(this.packageContext.sourceRoot, file));
|
|
84
|
+
}
|
|
50
85
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import postcss, { type Root } from 'postcss';
|
|
2
2
|
import type { ModuleStyleBuildConfig } from '#auklet/types';
|
|
3
3
|
import type { WorkspaceStyleResolver } from '#auklet/css/core/workspaceStyleResolver';
|
|
4
|
+
export type StyleFileImportReference = {
|
|
5
|
+
importer: string;
|
|
6
|
+
imported: string;
|
|
7
|
+
};
|
|
4
8
|
export declare class StyleProcessor {
|
|
5
9
|
private readonly config;
|
|
6
10
|
private readonly resolver;
|
|
@@ -11,6 +15,7 @@ export declare class StyleProcessor {
|
|
|
11
15
|
appendStyleContent(target: Root, content: string, from: string): void;
|
|
12
16
|
readStyleFile(stylePath: string, seen?: Set<string>): string;
|
|
13
17
|
collectImportedStyleFiles(styleFiles: Array<string>): Set<string>;
|
|
18
|
+
collectImportedStyleFileReferences(styleFiles: Array<string>): StyleFileImportReference[];
|
|
14
19
|
collectStyleImportSpecifiers(styleFiles: Array<string>): Set<string>;
|
|
15
20
|
private parse;
|
|
16
21
|
private parseImportSpecifier;
|
|
@@ -62,7 +62,10 @@ export class StyleProcessor {
|
|
|
62
62
|
return root.toString();
|
|
63
63
|
}
|
|
64
64
|
collectImportedStyleFiles(styleFiles) {
|
|
65
|
-
|
|
65
|
+
return new Set(this.collectImportedStyleFileReferences(styleFiles).map((item) => item.imported));
|
|
66
|
+
}
|
|
67
|
+
collectImportedStyleFileReferences(styleFiles) {
|
|
68
|
+
const imports = [];
|
|
66
69
|
for (const styleFile of styleFiles) {
|
|
67
70
|
const css = fs.readFileSync(styleFile, 'utf8');
|
|
68
71
|
const root = this.parse(css, styleFile);
|
|
@@ -72,10 +75,13 @@ export class StyleProcessor {
|
|
|
72
75
|
!this.config.styleExtensions.includes(path.extname(specifier))) {
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
|
-
|
|
78
|
+
imports.push({
|
|
79
|
+
importer: path.resolve(styleFile),
|
|
80
|
+
imported: path.resolve(path.dirname(styleFile), specifier),
|
|
81
|
+
});
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
|
-
return
|
|
84
|
+
return imports;
|
|
79
85
|
}
|
|
80
86
|
collectStyleImportSpecifiers(styleFiles) {
|
|
81
87
|
const specifiers = new Set();
|
|
@@ -74,6 +74,7 @@ const resolveMonorepoPublishPlan = async (options, runtime, logger) => {
|
|
|
74
74
|
filters: options.filters,
|
|
75
75
|
getDependencies: getWorkspaceDependencies,
|
|
76
76
|
emptyTargetMessage: '[publish] no publishable package found.',
|
|
77
|
+
includePrivate: false,
|
|
77
78
|
createTarget: (item, packageJson) => createPublishTarget({
|
|
78
79
|
packageRoot: item.path,
|
|
79
80
|
packageJson,
|