auklet 0.1.3 → 0.1.5

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 (72) hide show
  1. package/README.md +113 -412
  2. package/dist/build/tsdown/dependencies.js +2 -2
  3. package/dist/cli/build.d.ts +3 -5
  4. package/dist/cli/build.js +88 -17
  5. package/dist/cli/buildCss.d.ts +10 -3
  6. package/dist/cli/buildCss.js +40 -29
  7. package/dist/cli/buildWorkspace.d.ts +23 -0
  8. package/dist/cli/buildWorkspace.js +43 -0
  9. package/dist/cli/dev.d.ts +2 -1
  10. package/dist/cli/dev.js +131 -16
  11. package/dist/cli/main.js +36 -12
  12. package/dist/cli/parse/build.d.ts +62 -0
  13. package/dist/cli/parse/build.js +161 -0
  14. package/dist/cli/parse/core.d.ts +14 -0
  15. package/dist/cli/parse/core.js +68 -0
  16. package/dist/cli/parse/dev.d.ts +17 -0
  17. package/dist/cli/parse/dev.js +4 -0
  18. package/dist/cli/parse/owner.d.ts +11 -0
  19. package/dist/cli/parse/owner.js +25 -0
  20. package/dist/cli/parse/publish.d.ts +19 -0
  21. package/dist/cli/parse/publish.js +60 -0
  22. package/dist/cli/parse/values.d.ts +17 -0
  23. package/dist/cli/parse/values.js +14 -0
  24. package/dist/cli/parse/workspace.d.ts +12 -0
  25. package/dist/cli/parse/workspace.js +45 -0
  26. package/dist/css/core/style/dependencies.d.ts +0 -1
  27. package/dist/css/core/style/dependencies.js +0 -3
  28. package/dist/css/core/style/entries.js +2 -2
  29. package/dist/css/core/style/files.d.ts +0 -1
  30. package/dist/css/core/style/files.js +0 -3
  31. package/dist/css/core/stylePackageContext.js +3 -3
  32. package/dist/css/inspect.js +4 -3
  33. package/dist/css/vite/hmr.js +2 -2
  34. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +1 -1
  35. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +2 -2
  36. package/dist/env.d.ts +22 -0
  37. package/dist/env.js +105 -0
  38. package/dist/logger.d.ts +0 -1
  39. package/dist/logger.js +0 -3
  40. package/dist/publish/api/npmrc.d.ts +1 -1
  41. package/dist/publish/api/npmrc.js +1 -4
  42. package/dist/publish/api/pnpmApi.d.ts +5 -13
  43. package/dist/publish/api/pnpmApi.js +5 -47
  44. package/dist/publish/api/pnpmPublishApi.d.ts +2 -2
  45. package/dist/publish/api/pnpmPublishApi.js +5 -3
  46. package/dist/publish/cli.d.ts +0 -12
  47. package/dist/publish/cli.js +27 -106
  48. package/dist/publish/inspect.js +19 -9
  49. package/dist/publish/inspectPack.js +6 -2
  50. package/dist/publish/inspectRegistry.d.ts +3 -2
  51. package/dist/publish/inspectRegistry.js +11 -4
  52. package/dist/publish/publishEnv.d.ts +13 -0
  53. package/dist/publish/publishEnv.js +21 -0
  54. package/dist/publish/publishRunner.d.ts +3 -2
  55. package/dist/publish/publishRunner.js +9 -7
  56. package/dist/publish/runner/packageBuilder.d.ts +2 -3
  57. package/dist/publish/runner/packageBuilder.js +5 -3
  58. package/dist/publish/runner/packagePublisher.d.ts +3 -2
  59. package/dist/publish/runner/packagePublisher.js +4 -2
  60. package/dist/publish/runner/publishPreflight.d.ts +3 -2
  61. package/dist/publish/runner/publishPreflight.js +13 -6
  62. package/dist/publish/runner/versionWriter.d.ts +1 -1
  63. package/dist/publish/targetResolver.d.ts +2 -2
  64. package/dist/publish/targetResolver.js +34 -75
  65. package/dist/publish/types.d.ts +6 -7
  66. package/dist/workspace/targets.d.ts +31 -0
  67. package/dist/workspace/targets.js +144 -0
  68. package/package.json +1 -1
  69. package/dist/cli/buildArgs.d.ts +0 -8
  70. package/dist/cli/buildArgs.js +0 -114
  71. package/dist/cli/publish.d.ts +0 -2
  72. package/dist/cli/publish.js +0 -9
@@ -0,0 +1,161 @@
1
+ import { hasTsdownConfigArg } from '#auklet/build/runTsdown';
2
+ import { aukletCliConfigOverridesEnv, encodeAukletCliConfigOverrides, } from '#auklet/build/cliOverrides';
3
+ import { resolveCliBoolean, resolveCliValue } from '#auklet/cli/parse/values';
4
+ import { readFlagValue, readOptionalFlagValue } from '#auklet/cli/parse/core';
5
+ import { parseWorkspaceSelectionArgs } from '#auklet/cli/parse/workspace';
6
+ const buildFormats = new Set(['cjs', 'esm', 'iife']);
7
+ const buildPlatforms = new Set(['node', 'neutral', 'browser']);
8
+ const hasAukletConfig = (config) => {
9
+ return Object.keys(config).length > 0;
10
+ };
11
+ export function parseBuildCommand(args, options) {
12
+ const workspaceArgs = parseWorkspaceSelectionArgs(args, options.envContext);
13
+ const buildArgs = parseBuildOverrideArgs(workspaceArgs.remainingArgs, options.envContext);
14
+ return {
15
+ cwd: options.cwd,
16
+ envContext: options.envContext,
17
+ workspace: workspaceArgs.workspace,
18
+ overrides: buildArgs.config,
19
+ passthroughArgs: buildArgs.args,
20
+ workspaceScriptArgs: workspaceArgs.remainingArgs,
21
+ };
22
+ }
23
+ export function parseBuildJsCommand(args, options) {
24
+ const buildArgs = parseBuildOverrideArgs(args, options.envContext);
25
+ return {
26
+ cwd: options.cwd,
27
+ envContext: options.envContext,
28
+ overrides: buildArgs.config,
29
+ passthroughArgs: buildArgs.args,
30
+ };
31
+ }
32
+ export function parseBuildCssCommand(args, options) {
33
+ const buildArgs = parseBuildOverrideArgs(args, options.envContext);
34
+ const remainingArgs = buildArgs.args.filter((arg) => arg !== '--watch' && arg !== '-w');
35
+ if (remainingArgs.length) {
36
+ throw new Error(`[build-css] unknown build-css argument: ${remainingArgs[0]}`);
37
+ }
38
+ return {
39
+ cwd: options.cwd,
40
+ envContext: options.envContext,
41
+ overrides: buildArgs.config,
42
+ watch: buildArgs.args.includes('--watch') || buildArgs.args.includes('-w'),
43
+ };
44
+ }
45
+ export function parseBuildOverrideArgs(args, envContext) {
46
+ const remainingArgs = [];
47
+ const config = {};
48
+ for (let index = 0; index < args.length; index += 1) {
49
+ const arg = args[index];
50
+ const [name, inlineValue] = arg.split('=', 2);
51
+ if (name === '--source') {
52
+ config.source = getResolvedFlagValue(args, index, inlineValue, name, envContext);
53
+ if (inlineValue === undefined)
54
+ index += 1;
55
+ continue;
56
+ }
57
+ if (name === '--output') {
58
+ config.output = getResolvedFlagValue(args, index, inlineValue, name, envContext);
59
+ if (inlineValue === undefined)
60
+ index += 1;
61
+ continue;
62
+ }
63
+ if (name === '--modules') {
64
+ const value = readOptionalFlagValue(args, index, inlineValue);
65
+ config.modules =
66
+ value === undefined
67
+ ? true
68
+ : resolveCliBoolean(value, { label: name, context: envContext });
69
+ if (inlineValue === undefined && value !== undefined)
70
+ index += 1;
71
+ continue;
72
+ }
73
+ if (name === '--no-modules') {
74
+ config.modules = false;
75
+ continue;
76
+ }
77
+ if (name === '--build.formats') {
78
+ config.build = {
79
+ ...config.build,
80
+ formats: parseBuildFormats(inlineValue === undefined
81
+ ? getResolvedFlagValue(args, index, inlineValue, name, envContext)
82
+ : (resolveCliValue(inlineValue, {
83
+ label: name,
84
+ context: envContext,
85
+ }) ?? inlineValue)),
86
+ };
87
+ if (inlineValue === undefined)
88
+ index += 1;
89
+ continue;
90
+ }
91
+ if (name === '--build.target') {
92
+ config.build = {
93
+ ...config.build,
94
+ target: getResolvedFlagValue(args, index, inlineValue, name, envContext),
95
+ };
96
+ if (inlineValue === undefined)
97
+ index += 1;
98
+ continue;
99
+ }
100
+ if (name === '--build.platform') {
101
+ config.build = {
102
+ ...config.build,
103
+ platform: parseBuildPlatform(getResolvedFlagValue(args, index, inlineValue, name, envContext)),
104
+ };
105
+ if (inlineValue === undefined)
106
+ index += 1;
107
+ continue;
108
+ }
109
+ if (name === '--build.tsconfig') {
110
+ config.build = {
111
+ ...config.build,
112
+ tsconfig: getResolvedFlagValue(args, index, inlineValue, name, envContext),
113
+ };
114
+ if (inlineValue === undefined)
115
+ index += 1;
116
+ continue;
117
+ }
118
+ remainingArgs.push(arg);
119
+ }
120
+ if (hasAukletConfig(config) && hasTsdownConfigArg(remainingArgs)) {
121
+ throw new Error('Auklet build config flags cannot be used with tsdown --config, -c, or --no-config.');
122
+ }
123
+ return {
124
+ args: remainingArgs,
125
+ config,
126
+ };
127
+ }
128
+ export function createBuildEnv(config) {
129
+ if (!hasAukletConfig(config))
130
+ return undefined;
131
+ return {
132
+ [aukletCliConfigOverridesEnv]: encodeAukletCliConfigOverrides(config),
133
+ };
134
+ }
135
+ const getResolvedFlagValue = (args, index, inlineValue, flag, envContext) => {
136
+ return resolveCliValue(readFlagValue(args, index, inlineValue, flag), {
137
+ label: flag,
138
+ context: envContext,
139
+ });
140
+ };
141
+ const parseBuildFormats = (value) => {
142
+ const formats = value
143
+ .split(',')
144
+ .map((item) => item.trim())
145
+ .filter(Boolean);
146
+ if (!formats.length) {
147
+ throw new Error('--build.formats requires at least one format.');
148
+ }
149
+ for (const format of formats) {
150
+ if (!buildFormats.has(format)) {
151
+ throw new Error(`Unknown build format: ${format}`);
152
+ }
153
+ }
154
+ return formats;
155
+ };
156
+ const parseBuildPlatform = (value) => {
157
+ if (!buildPlatforms.has(value)) {
158
+ throw new Error(`Unknown build platform: ${value}`);
159
+ }
160
+ return value;
161
+ };
@@ -0,0 +1,14 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ export declare function stripArgsSeparator(args: Array<string>): string[];
3
+ export declare function readFlagValue(args: Array<string>, index: number, inlineValue: string | undefined, flag: string): string;
4
+ export declare function readOptionalFlagValue(args: Array<string>, index: number, inlineValue: string | undefined): string | undefined;
5
+ export declare function dedupe<T>(items: Array<T>): T[];
6
+ export declare function stringOption(value: unknown, label: string, envContext: AukletEnvContext): string | undefined;
7
+ export declare function deferredStringOption(value: unknown, label: string): {
8
+ raw: string;
9
+ resolve(context: AukletEnvContext): string | undefined;
10
+ } | undefined;
11
+ export declare function booleanOption(value: unknown, label: string, envContext: AukletEnvContext, defaultValue?: boolean): boolean;
12
+ export declare function stringArrayOption(value: unknown, label: string, envContext: AukletEnvContext): string[];
13
+ export declare function validateUnknownFlags(argv: Record<string, unknown>, allowedFlags: Set<string>, scope: string): void;
14
+ export declare function validateNoPrefixedFlags(args: Array<string>, allowedFlags: Set<string>, scope: string): void;
@@ -0,0 +1,68 @@
1
+ import { isArray } from 'aidly';
2
+ import { createDeferredCliValue, resolveCliBoolean, resolveCliValue, } from '#auklet/cli/parse/values';
3
+ export function stripArgsSeparator(args) {
4
+ return args.filter((arg) => arg !== '--');
5
+ }
6
+ export function readFlagValue(args, index, inlineValue, flag) {
7
+ const value = inlineValue ?? args[index + 1];
8
+ if (!value || value.startsWith('--')) {
9
+ throw new Error(`${flag} requires a value.`);
10
+ }
11
+ return value;
12
+ }
13
+ export function readOptionalFlagValue(args, index, inlineValue) {
14
+ if (inlineValue !== undefined)
15
+ return inlineValue;
16
+ const value = args[index + 1];
17
+ if (!value || value.startsWith('--'))
18
+ return undefined;
19
+ return value;
20
+ }
21
+ export function dedupe(items) {
22
+ return [...new Set(items)];
23
+ }
24
+ export function stringOption(value, label, envContext) {
25
+ if (value === undefined)
26
+ return undefined;
27
+ if (isArray(value))
28
+ return stringOption(value.at(-1), label, envContext);
29
+ return resolveCliValue(String(value), { label, context: envContext });
30
+ }
31
+ export function deferredStringOption(value, label) {
32
+ if (value === undefined)
33
+ return undefined;
34
+ if (isArray(value))
35
+ return deferredStringOption(value.at(-1), label);
36
+ return createDeferredCliValue(String(value), { label });
37
+ }
38
+ export function booleanOption(value, label, envContext, defaultValue = false) {
39
+ if (value === undefined)
40
+ return defaultValue;
41
+ if (isArray(value)) {
42
+ return booleanOption(value.at(-1), label, envContext, defaultValue);
43
+ }
44
+ if (typeof value === 'boolean')
45
+ return value;
46
+ return resolveCliBoolean(String(value), { label, context: envContext });
47
+ }
48
+ export function stringArrayOption(value, label, envContext) {
49
+ if (value === undefined)
50
+ return [];
51
+ const values = isArray(value)
52
+ ? value.map((item) => stringOption(item, label, envContext)).filter(Boolean)
53
+ : [stringOption(value, label, envContext)].filter(Boolean);
54
+ return values.filter((item) => Boolean(item));
55
+ }
56
+ export function validateUnknownFlags(argv, allowedFlags, scope) {
57
+ for (const flag of Object.keys(argv)) {
58
+ if (!allowedFlags.has(flag)) {
59
+ throw new Error(`[${scope}] unknown option: --${flag}`);
60
+ }
61
+ }
62
+ }
63
+ export function validateNoPrefixedFlags(args, allowedFlags, scope) {
64
+ const flag = args.find((arg) => arg.startsWith('--no-') && !allowedFlags.has(arg));
65
+ if (flag) {
66
+ throw new Error(`[${scope}] unknown option: ${flag}`);
67
+ }
68
+ }
@@ -0,0 +1,17 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ import type { BuildCommandOptions } from '#auklet/cli/parse/build';
3
+ export type DevCommandOptions = BuildCommandOptions;
4
+ export declare function parseDevCommand(args: Array<string>, options: {
5
+ cwd: string;
6
+ envContext: AukletEnvContext;
7
+ }): {
8
+ cwd: string;
9
+ envContext: AukletEnvContext;
10
+ workspace: {
11
+ filters: string[];
12
+ includeDependencies: boolean;
13
+ };
14
+ overrides: import("../..").AukletConfig;
15
+ passthroughArgs: string[];
16
+ workspaceScriptArgs: string[];
17
+ };
@@ -0,0 +1,4 @@
1
+ import { parseBuildCommand } from '#auklet/cli/parse/build';
2
+ export function parseDevCommand(args, options) {
3
+ return parseBuildCommand(args, options);
4
+ }
@@ -0,0 +1,11 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ export declare function parseOwnerCommand(args: Array<string>, options: {
3
+ cwd: string;
4
+ envContext: AukletEnvContext;
5
+ }): {
6
+ cwd: string;
7
+ users: string[];
8
+ filters: string[];
9
+ packages: string[];
10
+ otp: string | undefined;
11
+ };
@@ -0,0 +1,25 @@
1
+ import minimist from 'minimist';
2
+ import { stringArrayOption, stringOption, stripArgsSeparator, validateNoPrefixedFlags, validateUnknownFlags, } from '#auklet/cli/parse/core';
3
+ const ownerFlags = new Set(['_', 'filter', 'package', 'otp']);
4
+ export function parseOwnerCommand(args, options) {
5
+ const cliArgs = stripArgsSeparator(args);
6
+ validateNoPrefixedFlags(cliArgs, new Set(), 'publish');
7
+ const argv = minimist(cliArgs, {
8
+ string: ['filter', 'package', 'otp'],
9
+ });
10
+ validateUnknownFlags(argv, ownerFlags, 'publish');
11
+ const [subcommand, ...users] = argv._;
12
+ if (subcommand !== 'add') {
13
+ throw new Error('[publish] expected owner command: auk owner add <user...>');
14
+ }
15
+ if (!users.length) {
16
+ throw new Error('[publish] owner add requires at least one user.');
17
+ }
18
+ return {
19
+ cwd: options.cwd,
20
+ users,
21
+ filters: stringArrayOption(argv.filter, '--filter', options.envContext),
22
+ packages: stringArrayOption(argv.package, '--package', options.envContext),
23
+ otp: stringOption(argv.otp, '--otp', options.envContext),
24
+ };
25
+ }
@@ -0,0 +1,19 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ export declare function parsePublishCommand(args: Array<string>, options: {
3
+ cwd: string;
4
+ envContext: AukletEnvContext;
5
+ }): {
6
+ cwd: string;
7
+ otp: string | undefined;
8
+ filters: string[];
9
+ version: string | undefined;
10
+ git: boolean;
11
+ format: boolean;
12
+ dryRun: boolean;
13
+ allowDirty: boolean;
14
+ ignoreScripts: boolean;
15
+ token: {
16
+ raw: string;
17
+ resolve(context: AukletEnvContext): string | undefined;
18
+ } | undefined;
19
+ };
@@ -0,0 +1,60 @@
1
+ import minimist from 'minimist';
2
+ import { booleanOption, deferredStringOption, dedupe, stringArrayOption, stringOption, stripArgsSeparator, validateNoPrefixedFlags, validateUnknownFlags, } from '#auklet/cli/parse/core';
3
+ const publishFlags = new Set([
4
+ '_',
5
+ 'filter',
6
+ 'workspace',
7
+ 'version',
8
+ 'dry-run',
9
+ 'format',
10
+ 'git',
11
+ 'otp',
12
+ 'token',
13
+ 'ignore-scripts',
14
+ 'allow-dirty',
15
+ ]);
16
+ export function parsePublishCommand(args, options) {
17
+ const argv = parsePublishArgs(args);
18
+ if (argv._.length) {
19
+ throw new Error(`[publish] unknown publish argument: ${argv._.join(' ')}`);
20
+ }
21
+ return {
22
+ cwd: options.cwd,
23
+ otp: stringOption(argv.otp, '--otp', options.envContext),
24
+ filters: resolvePublishFilters(argv, options.envContext),
25
+ version: stringOption(argv.version, '--version', options.envContext),
26
+ git: booleanOption(argv.git, '--git', options.envContext, true),
27
+ format: booleanOption(argv.format, '--format', options.envContext, true),
28
+ dryRun: booleanOption(argv['dry-run'], '--dry-run', options.envContext),
29
+ allowDirty: booleanOption(argv['allow-dirty'], '--allow-dirty', options.envContext),
30
+ ignoreScripts: booleanOption(argv['ignore-scripts'], '--ignore-scripts', options.envContext),
31
+ token: deferredStringOption(argv.token, '--token'),
32
+ };
33
+ }
34
+ const parsePublishArgs = (args) => {
35
+ const cliArgs = stripArgsSeparator(args);
36
+ validateNoPrefixedFlags(cliArgs, new Set(['--no-format', '--no-git']), 'publish');
37
+ const argv = minimist(cliArgs, {
38
+ string: [
39
+ 'filter',
40
+ 'version',
41
+ 'otp',
42
+ 'token',
43
+ 'dry-run',
44
+ 'format',
45
+ 'git',
46
+ 'ignore-scripts',
47
+ 'allow-dirty',
48
+ ],
49
+ boolean: ['workspace'],
50
+ });
51
+ validateUnknownFlags(argv, publishFlags, 'publish');
52
+ return argv;
53
+ };
54
+ const resolvePublishFilters = (argv, envContext) => {
55
+ const filters = stringArrayOption(argv.filter, '--filter', envContext);
56
+ if (booleanOption(argv.workspace, '--workspace', envContext)) {
57
+ filters.push('*');
58
+ }
59
+ return dedupe(filters);
60
+ };
@@ -0,0 +1,17 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ export type CliValueOptions = {
3
+ label: string;
4
+ context: AukletEnvContext;
5
+ };
6
+ export type DeferredCliValue = {
7
+ raw: string;
8
+ resolve(context: AukletEnvContext): string | undefined;
9
+ };
10
+ export declare function createDeferredCliValue(value: string, options: {
11
+ label: string;
12
+ }): {
13
+ raw: string;
14
+ resolve(context: AukletEnvContext): string | undefined;
15
+ };
16
+ export declare function resolveCliValue(value: string | undefined, options: CliValueOptions): string | undefined;
17
+ export declare function resolveCliBoolean(value: boolean | string | undefined, options: CliValueOptions): boolean;
@@ -0,0 +1,14 @@
1
+ export function createDeferredCliValue(value, options) {
2
+ return {
3
+ raw: value,
4
+ resolve(context) {
5
+ return resolveCliValue(value, { label: options.label, context });
6
+ },
7
+ };
8
+ }
9
+ export function resolveCliValue(value, options) {
10
+ return options.context.resolveValue(value, { label: options.label });
11
+ }
12
+ export function resolveCliBoolean(value, options) {
13
+ return options.context.resolveBoolean(value, { label: options.label });
14
+ }
@@ -0,0 +1,12 @@
1
+ import type { AukletEnvContext } from '#auklet/env';
2
+ export type WorkspaceSelection = {
3
+ filters: Array<string>;
4
+ includeDependencies: boolean;
5
+ };
6
+ export declare function parseWorkspaceSelectionArgs(args: Array<string>, envContext: AukletEnvContext): {
7
+ remainingArgs: string[];
8
+ workspace: {
9
+ filters: string[];
10
+ includeDependencies: boolean;
11
+ };
12
+ };
@@ -0,0 +1,45 @@
1
+ import { resolveCliBoolean, resolveCliValue } from '#auklet/cli/parse/values';
2
+ import { dedupe, readFlagValue, readOptionalFlagValue, } from '#auklet/cli/parse/core';
3
+ export function parseWorkspaceSelectionArgs(args, envContext) {
4
+ const remainingArgs = [];
5
+ const filters = [];
6
+ let includeDependencies = false;
7
+ for (let index = 0; index < args.length; index += 1) {
8
+ const arg = args[index];
9
+ const [name, inlineValue] = arg.split('=', 2);
10
+ if (name === '--workspace') {
11
+ if (inlineValue !== undefined) {
12
+ throw new Error('--workspace does not accept a value.');
13
+ }
14
+ filters.push('*');
15
+ continue;
16
+ }
17
+ if (name === '--filter') {
18
+ filters.push(resolveCliValue(readFlagValue(args, index, inlineValue, name), {
19
+ label: name,
20
+ context: envContext,
21
+ }));
22
+ if (inlineValue === undefined)
23
+ index += 1;
24
+ continue;
25
+ }
26
+ 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)
33
+ index += 1;
34
+ continue;
35
+ }
36
+ remainingArgs.push(arg);
37
+ }
38
+ return {
39
+ remainingArgs,
40
+ workspace: {
41
+ filters: dedupe(filters),
42
+ includeDependencies,
43
+ },
44
+ };
45
+ }
@@ -1,6 +1,5 @@
1
1
  import type { NormalizedAukletConfig } from '#auklet/types';
2
2
  export declare function getGlobalStyleDependencies(config: NormalizedAukletConfig): string[];
3
- export declare function getExternalStyleDependencies(config: NormalizedAukletConfig): string[];
4
3
  export declare function getThemeStyleDependencies(config: NormalizedAukletConfig, themeName: string): string[];
5
4
  export declare function getThemeNames(config: NormalizedAukletConfig): string[];
6
5
  export declare function getThemeStyleEntries(config: NormalizedAukletConfig): {
@@ -15,9 +15,6 @@ export function getGlobalStyleDependencies(config) {
15
15
  }
16
16
  return dependencies;
17
17
  }
18
- export function getExternalStyleDependencies(config) {
19
- return getGlobalStyleDependencies(config);
20
- }
21
18
  export function getThemeStyleDependencies(config, themeName) {
22
19
  const dependencies = [];
23
20
  for (const [packageName, dependency] of Object.entries(config.styles.dependencies)) {
@@ -1,4 +1,4 @@
1
- import { getExternalStyleDependencies, getGlobalStyleDependencies, getThemeNames, getThemeStyleDependencies, } from '#auklet/css/core/style/dependencies';
1
+ import { getGlobalStyleDependencies, getThemeNames, getThemeStyleDependencies, } from '#auklet/css/core/style/dependencies';
2
2
  import { StyleModuleEntryPlanner } from '#auklet/css/core/styleModuleEntryPlanner';
3
3
  const dependenciesPart = (specifiers) => ({ type: 'dependencies', specifiers });
4
4
  // 环境无关的 style entry graph。production writer 和 Vite/dev renderer 都从这里取入口语义。
@@ -21,7 +21,7 @@ export function createThemeEntryParts(config, themeName, options = {}) {
21
21
  }
22
22
  export function createExternalEntryParts(config) {
23
23
  return [
24
- dependenciesPart(getExternalStyleDependencies(config)),
24
+ dependenciesPart(getGlobalStyleDependencies(config)),
25
25
  ];
26
26
  }
27
27
  export function collectModuleStyleImports(packageContext) {
@@ -1,3 +1,2 @@
1
1
  export declare function groupStyleFilesByDir(sourceRoot: string, styleFiles: Array<string>): Map<string, string[]>;
2
2
  export declare function createStyleFileKeySet(styleFiles: Iterable<string>): Set<string>;
3
- export declare function createStyleFileKey(styleFile: string): string;
@@ -14,6 +14,3 @@ export function groupStyleFilesByDir(sourceRoot, styleFiles) {
14
14
  export function createStyleFileKeySet(styleFiles) {
15
15
  return new Set(Array.from(styleFiles, normalizeFileKey));
16
16
  }
17
- export function createStyleFileKey(styleFile) {
18
- return normalizeFileKey(styleFile);
19
- }
@@ -3,9 +3,9 @@ import path from 'node:path';
3
3
  import { ModuleStyleImportCollector } from '#auklet/css/core/styleImports/collector';
4
4
  import { StyleProcessor } from '#auklet/css/core/styleProcessor';
5
5
  import { WorkspaceStyleResolver } from '#auklet/css/core/workspaceStyleResolver';
6
- import { createStyleFileKey, createStyleFileKeySet, } from '#auklet/css/core/style/files';
6
+ import { createStyleFileKeySet } from '#auklet/css/core/style/files';
7
7
  import { getThemeNames, resolveThemeStyleFiles, } from '#auklet/css/core/style/dependencies';
8
- import { fileWalker } from '#auklet/utils';
8
+ import { fileWalker, normalizeFileKey } from '#auklet/utils';
9
9
  export class StylePackageContext {
10
10
  options;
11
11
  normalizedConfig;
@@ -36,6 +36,6 @@ export class StylePackageContext {
36
36
  const themeFileKeys = createStyleFileKeySet(this.themeFiles.values());
37
37
  return files
38
38
  .filter((file) => this.options.config.styleExtensions.includes(path.extname(file)))
39
- .filter((styleFile) => !themeFileKeys.has(createStyleFileKey(styleFile)));
39
+ .filter((styleFile) => !themeFileKeys.has(normalizeFileKey(styleFile)));
40
40
  }
41
41
  }
@@ -3,7 +3,8 @@ import { readFileSync } from 'node:fs';
3
3
  import { isPlainObject, isString } from 'aidly';
4
4
  import { normalizeAukletConfig } from '#auklet/config';
5
5
  import { loadAukletConfig } from '#auklet/configLoader';
6
- import { resolveBuildCliArgs } from '#auklet/cli/buildArgs';
6
+ import { parseBuildOverrideArgs } from '#auklet/cli/parse/build';
7
+ import { AukletEnvContext } from '#auklet/env';
7
8
  import { moduleStyleBuildConfig } from '#auklet/css/config';
8
9
  import { mergeAukletConfigOverrides } from '#auklet/build/cliOverrides';
9
10
  import { createExternalEntryParts, createModuleStyleEntryPlans, createStyleEntryParts, createThemeEntryParts, } from '#auklet/css/core/style/entries';
@@ -20,11 +21,11 @@ export async function runInspectCssCli(args) {
20
21
  return 0;
21
22
  }
22
23
  export async function resolveInspectCssOptions(args) {
23
- const buildArgs = resolveBuildCliArgs(args.filter((arg) => arg !== '--'));
24
+ const cwd = process.cwd();
25
+ const buildArgs = parseBuildOverrideArgs(args.filter((arg) => arg !== '--'), new AukletEnvContext(cwd));
24
26
  if (buildArgs.args.length) {
25
27
  throw new Error(`[inspect] unknown inspect css argument: ${buildArgs.args[0]}`);
26
28
  }
27
- const cwd = process.cwd();
28
29
  const workspaceRoot = findWorkspaceRoot(cwd);
29
30
  const packageRoots = workspaceRoot === cwd
30
31
  ? (await readPnpmWorkspacePackageInfo(cwd))
@@ -1,10 +1,10 @@
1
1
  import path from 'node:path';
2
2
  import { isString } from 'aidly';
3
3
  import { normalizeFileKey } from '#auklet/utils';
4
- import { createScopedAukletLogger } from '#auklet/logger';
4
+ import { createAukletLogger } from '#auklet/logger';
5
5
  const FULL_RELOAD_SUPPRESS_MS = 100;
6
6
  const DUPLICATE_UPDATE_IGNORE_MS = 500;
7
- const logger = createScopedAukletLogger('css:vite');
7
+ const logger = createAukletLogger({ scope: 'css:vite' });
8
8
  const toBrowserVirtualPath = (id) => {
9
9
  return `/@id/${id.replace('\0', '__x00__')}`;
10
10
  };
@@ -1,4 +1,4 @@
1
- import type { WorkspacePackageInfo } from '#auklet/workspace/packages';
1
+ import { type WorkspacePackageInfo } from '#auklet/workspace/packages';
2
2
  import type { StylePackageInfo, StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
3
3
  export type MonorepoPackageSourceOptions = {
4
4
  root: string;
@@ -1,9 +1,9 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { aukletConfigFiles, isAukletConfigFile } from '#auklet/config';
4
3
  import { SOURCE_MODULE_RE } from '#auklet/css/constants';
4
+ import { aukletConfigFiles, isAukletConfigFile } from '#auklet/config';
5
5
  import { normalizeFileKey, toPosixPath, toWatchPath } from '#auklet/utils';
6
- import { readPnpmWorkspacePackageInfoSync } from '#auklet/workspace/packages';
6
+ import { readPnpmWorkspacePackageInfoSync, } from '#auklet/workspace/packages';
7
7
  export class MonorepoPackageSource {
8
8
  options;
9
9
  packages;
package/dist/env.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export declare class AukletEnvContext {
2
+ private readonly packageRoot;
3
+ private readonly root?;
4
+ private readonly env;
5
+ private readonly processEnv;
6
+ constructor(packageRoot: string, root?: string | undefined, options?: {
7
+ processEnv?: Record<string, string | undefined>;
8
+ });
9
+ get values(): Record<string, string | undefined>;
10
+ get normalizedValues(): Record<string, string | undefined> | undefined;
11
+ createPackageContext(packageRoot: string): AukletEnvContext;
12
+ resolveValue(value: string | undefined, options: {
13
+ label: string;
14
+ }): string | undefined;
15
+ resolveBoolean(value: boolean | string | undefined, options: {
16
+ label: string;
17
+ }): boolean;
18
+ run<T>(fn: () => Promise<T>): Promise<T>;
19
+ private readEnv;
20
+ private findEnvFiles;
21
+ private createProcessEnvOverrides;
22
+ }