auklet 0.0.19 → 0.0.20
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/LICENSE +21 -0
- package/README.md +177 -389
- package/bin/entry.mjs +5 -0
- package/dist/build/bundleConfig.js +1 -1
- package/dist/build/cliOverrides.d.ts +22 -0
- package/dist/build/cliOverrides.js +22 -0
- package/dist/build/moduleConfig.js +1 -1
- package/dist/build/runTsdown.d.ts +2 -0
- package/dist/build/runTsdown.js +4 -3
- package/dist/build/tsdown/common.d.ts +2 -2
- package/dist/build/tsdown/context.d.ts +2 -1
- package/dist/build/tsdown/context.js +2 -1
- package/dist/build/tsdown/define.js +3 -2
- package/dist/build/tsdown/dependencies.js +3 -1
- package/dist/build/tsdown/entries.d.ts +2 -2
- package/dist/build/tsdown/entries.js +10 -10
- package/dist/build/tsdown/types.d.ts +1 -0
- package/dist/cli/build.d.ts +5 -0
- package/dist/cli/build.js +30 -0
- package/dist/cli/buildArgs.d.ts +8 -0
- package/dist/cli/buildArgs.js +114 -0
- package/dist/cli/buildCss.d.ts +12 -0
- package/dist/cli/buildCss.js +53 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/dev.js +39 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +95 -0
- package/dist/cli/publish.d.ts +2 -0
- package/dist/cli/publish.js +9 -0
- package/dist/css/production/buildReporter.d.ts +3 -0
- package/dist/css/production/buildReporter.js +19 -0
- package/dist/css/production/builder.d.ts +8 -3
- package/dist/css/production/builder.js +9 -13
- package/dist/css/vite/hmr.js +7 -6
- package/dist/css/vite/moduleGraph/graph.js +0 -1
- package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +5 -1
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +40 -31
- package/dist/css/vite/moduleGraph/types.d.ts +0 -1
- package/dist/css/watch/watcher.d.ts +0 -1
- package/dist/css/watch/watcher.js +3 -10
- package/dist/index.d.ts +5 -7
- package/dist/index.js +4 -5
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +14 -0
- package/dist/publish/api/gitApi.d.ts +7 -0
- package/dist/publish/api/gitApi.js +55 -0
- package/dist/publish/api/packageJsonApi.d.ts +7 -0
- package/dist/publish/api/packageJsonApi.js +34 -0
- package/dist/publish/api/pnpmApi.d.ts +9 -0
- package/dist/publish/api/pnpmApi.js +85 -0
- package/dist/publish/api/pnpmPublishApi.d.ts +4 -0
- package/dist/publish/api/pnpmPublishApi.js +7 -0
- package/dist/publish/api/publishArgs.d.ts +2 -0
- package/dist/publish/api/publishArgs.js +25 -0
- package/dist/publish/api/publishHookApi.d.ts +10 -0
- package/dist/publish/api/publishHookApi.js +52 -0
- package/dist/publish/cli.d.ts +2 -0
- package/dist/publish/cli.js +94 -0
- package/dist/publish/ownerRunner.d.ts +6 -0
- package/dist/publish/ownerRunner.js +22 -0
- package/dist/publish/publishRunner.d.ts +16 -0
- package/dist/publish/publishRunner.js +108 -0
- package/dist/publish/runner/packageBuilder.d.ts +4 -0
- package/dist/publish/runner/packageBuilder.js +15 -0
- package/dist/publish/runner/packagePublisher.d.ts +7 -0
- package/dist/publish/runner/packagePublisher.js +21 -0
- package/dist/publish/runner/publishFailureReporter.d.ts +3 -0
- package/dist/publish/runner/publishFailureReporter.js +14 -0
- package/dist/publish/runner/publishOutputFormatter.d.ts +2 -0
- package/dist/publish/runner/publishOutputFormatter.js +83 -0
- package/dist/publish/runner/publishPreflight.d.ts +8 -0
- package/dist/publish/runner/publishPreflight.js +26 -0
- package/dist/publish/runner/publishSummaryReporter.d.ts +10 -0
- package/dist/publish/runner/publishSummaryReporter.js +81 -0
- package/dist/publish/runner/publishTargetError.d.ts +9 -0
- package/dist/publish/runner/publishTargetError.js +14 -0
- package/dist/publish/runner/releaseGitController.d.ts +10 -0
- package/dist/publish/runner/releaseGitController.js +41 -0
- package/dist/publish/runner/versionWriter.d.ts +13 -0
- package/dist/publish/runner/versionWriter.js +78 -0
- package/dist/publish/targetResolver.d.ts +7 -0
- package/dist/publish/targetResolver.js +195 -0
- package/dist/publish/types.d.ts +70 -0
- package/dist/publish/types.js +0 -0
- package/dist/publish/version.d.ts +5 -0
- package/dist/publish/version.js +55 -0
- package/dist/types.d.ts +8 -7
- package/dist/workspace/packages.d.ts +9 -0
- package/dist/workspace/packages.js +62 -0
- package/dist/workspace/root.d.ts +1 -0
- package/dist/workspace/root.js +14 -0
- package/package.json +15 -6
- package/bin/entry.cjs +0 -163
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
export function logModuleStyleBuildResult(logger, result, elapsed) {
|
|
3
|
+
logger.step(`Build ${path.basename(result.packageRoot)}`);
|
|
4
|
+
logger.item(logger.colors.bold(logger.colors.yellow(String(result.styleFiles.length))), logger.colors.bold(logger.colors.white(' source style file(s), ')), logger.colors.bold(logger.colors.yellow(String(result.outputs.length))), logger.colors.bold(logger.colors.white(' output entry file(s)')));
|
|
5
|
+
if (result.outputs.length) {
|
|
6
|
+
const rows = result.outputs.map((output) => [
|
|
7
|
+
logger.path(path.relative(result.packageRoot, output.file)),
|
|
8
|
+
`${(output.size / 1000).toFixed(2)} kB`,
|
|
9
|
+
]);
|
|
10
|
+
const sizeWidth = Math.max(...rows.map(([, size]) => String(size).length));
|
|
11
|
+
logger.rows({
|
|
12
|
+
rows: rows.map(([file, size]) => [
|
|
13
|
+
file,
|
|
14
|
+
logger.colors.gray(String(size).padStart(sizeWidth)),
|
|
15
|
+
]),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
logger.success('Build complete in ', logger.duration(elapsed));
|
|
19
|
+
}
|
|
@@ -2,10 +2,15 @@ import type { ModuleStyleBuildConfig, ModuleStyleBuildContext, ModuleStyleBuildO
|
|
|
2
2
|
export declare class ModuleStyleBuilder {
|
|
3
3
|
private readonly config;
|
|
4
4
|
private readonly context;
|
|
5
|
-
private readonly logger?;
|
|
6
5
|
constructor(context?: ModuleStyleBuildContext, config?: ModuleStyleBuildConfig);
|
|
7
|
-
build(options?: ModuleStyleBuildOptions): Promise<
|
|
8
|
-
|
|
6
|
+
build(options?: ModuleStyleBuildOptions): Promise<{
|
|
7
|
+
packageRoot: string;
|
|
8
|
+
styleFiles: string[];
|
|
9
|
+
outputs: {
|
|
10
|
+
file: string;
|
|
11
|
+
size: number;
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
|
9
14
|
private createBuildContext;
|
|
10
15
|
private createPackageContext;
|
|
11
16
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
import { normalizeAukletConfig } from '#auklet/config';
|
|
3
3
|
import { moduleStyleBuildConfig } from '#auklet/css/config';
|
|
4
4
|
import { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
5
5
|
import { ModuleStyleOutputWriter } from '#auklet/css/production/moduleOutputWriter';
|
|
6
6
|
import { PackageStyleEntryWriter } from '#auklet/css/production/packageEntryWriter';
|
|
7
|
-
import { toPosixPath } from '#auklet/utils';
|
|
8
7
|
export class ModuleStyleBuilder {
|
|
9
8
|
config;
|
|
10
9
|
context;
|
|
11
|
-
logger;
|
|
12
10
|
constructor(context = {}, config = moduleStyleBuildConfig) {
|
|
13
11
|
this.config = config;
|
|
14
12
|
this.context = {
|
|
@@ -17,12 +15,10 @@ export class ModuleStyleBuilder {
|
|
|
17
15
|
output: context.output,
|
|
18
16
|
...context,
|
|
19
17
|
};
|
|
20
|
-
this.logger = context.logger;
|
|
21
18
|
}
|
|
22
19
|
async build(options = {}) {
|
|
23
20
|
const rawConfig = options.aukletConfig ?? this.context.aukletConfig ?? {};
|
|
24
21
|
const normalizedConfig = normalizeAukletConfig(rawConfig);
|
|
25
|
-
const logger = options.logger ?? this.logger;
|
|
26
22
|
const context = this.createBuildContext(normalizedConfig);
|
|
27
23
|
const packageContext = this.createPackageContext(context, normalizedConfig);
|
|
28
24
|
const writerOptions = {
|
|
@@ -33,17 +29,17 @@ export class ModuleStyleBuilder {
|
|
|
33
29
|
const packageWriter = new PackageStyleEntryWriter(writerOptions);
|
|
34
30
|
const packageOutput = packageWriter.write();
|
|
35
31
|
const outputs = packageOutput ? [packageOutput] : [];
|
|
36
|
-
logger?.log?.(`[auklet:css] build ${path.basename(context.packageRoot)}`);
|
|
37
32
|
if (normalizedConfig.modules) {
|
|
38
33
|
outputs.push(...new ModuleStyleOutputWriter(writerOptions).write());
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
return {
|
|
36
|
+
packageRoot: context.packageRoot,
|
|
37
|
+
styleFiles: packageContext.styleFiles,
|
|
38
|
+
outputs: outputs.map((file) => ({
|
|
39
|
+
file,
|
|
40
|
+
size: fs.statSync(file).size,
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
47
43
|
}
|
|
48
44
|
createBuildContext(config) {
|
|
49
45
|
return {
|
package/dist/css/vite/hmr.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { normalizeFileKey } from '#auklet/utils';
|
|
3
|
+
import { createScopedAukletLogger } from '#auklet/logger';
|
|
3
4
|
// package CSS 的 HMR 不能直接走 Vite 原生 CSS 文件链路:
|
|
4
|
-
//
|
|
5
|
+
// 1. 浏览器 import 的是 auklet-css:* 虚拟 CSS 模块,不是真实的
|
|
5
6
|
// packages/*/src/**/*.css 文件,所以真实 CSS 变化时 Vite 的 modules 可能为空。
|
|
6
|
-
//
|
|
7
|
+
// 2. Vite dev 会把 CSS 转成自接受的 JS 模块,重新执行模块里的 updateStyle()
|
|
7
8
|
// 才能更新样式,因此这里手动发送 js-update,而不是 css-update。
|
|
8
|
-
//
|
|
9
|
+
// 3. @tailwindcss/vite 会在相关 CSS 变化时主动发 full-reload。package CSS 已由
|
|
9
10
|
// 这个插件接管 HMR 时,需要在一个很短的窗口内吞掉这次 reload。
|
|
10
|
-
const HMR_LOG_PREFIX = '[auklet:css:vite]';
|
|
11
11
|
const FULL_RELOAD_SUPPRESS_MS = 100;
|
|
12
12
|
const DUPLICATE_UPDATE_IGNORE_MS = 500;
|
|
13
|
+
const logger = createScopedAukletLogger('css:vite');
|
|
13
14
|
const toBrowserVirtualPath = (id) => {
|
|
14
15
|
return `/@id/${id.replace('\0', '__x00__')}`;
|
|
15
16
|
};
|
|
@@ -61,7 +62,7 @@ export class AukletStyleHmr {
|
|
|
61
62
|
if (typeof payload !== 'string' &&
|
|
62
63
|
payload.type === 'full-reload' &&
|
|
63
64
|
this.shouldSuppressFullReload()) {
|
|
64
|
-
|
|
65
|
+
logger.info('suppressed package css full-reload');
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
if (typeof payload === 'string') {
|
|
@@ -98,7 +99,7 @@ export class AukletStyleHmr {
|
|
|
98
99
|
isWithinCircularImport: false,
|
|
99
100
|
};
|
|
100
101
|
});
|
|
101
|
-
|
|
102
|
+
logger.info(`package css hmr ${getRelativeFile(context.file)} tracked=${virtualIds.length} updates=${updates.length}`);
|
|
102
103
|
if (updates.length) {
|
|
103
104
|
context.server.ws.send({
|
|
104
105
|
type: 'update',
|
|
@@ -22,7 +22,6 @@ export class ModuleStyleGraph {
|
|
|
22
22
|
(options.mode ?? 'package') === 'monorepo'
|
|
23
23
|
? new MonorepoPackageSource({
|
|
24
24
|
root: normalizeFileKey(options.root),
|
|
25
|
-
packagesDir: options.packagesDir ?? 'packages',
|
|
26
25
|
styleExtensions: this.config.styleExtensions,
|
|
27
26
|
})
|
|
28
27
|
: new SinglePackageSource({
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import type { WorkspacePackageInfo } from '#auklet/workspace/packages';
|
|
1
2
|
import type { StylePackageInfo, StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
|
|
2
3
|
export type MonorepoPackageSourceOptions = {
|
|
3
4
|
root: string;
|
|
4
|
-
packagesDir: string;
|
|
5
5
|
styleExtensions: Array<string>;
|
|
6
|
+
readWorkspacePackages?: (root: string) => Array<WorkspacePackageInfo>;
|
|
6
7
|
};
|
|
7
8
|
export declare class MonorepoPackageSource implements StylePackageSource {
|
|
8
9
|
private readonly options;
|
|
9
10
|
private packages?;
|
|
10
11
|
private packageNames?;
|
|
11
12
|
private readonly root;
|
|
13
|
+
private readonly rawRoot;
|
|
12
14
|
constructor(options: MonorepoPackageSourceOptions);
|
|
13
15
|
getPackages(): StylePackageInfo[];
|
|
14
16
|
getPackageNames(): string[];
|
|
15
17
|
isKnownPackageName(packageName: string): boolean;
|
|
16
18
|
isSourceGraphFile(file: string): boolean;
|
|
17
19
|
getWatchRoots(): Promise<string[]>;
|
|
20
|
+
private getWorkspacePackages;
|
|
21
|
+
private isWorkspaceRootPackage;
|
|
18
22
|
}
|
|
@@ -2,42 +2,23 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { aukletConfigFile } from '#auklet/config';
|
|
4
4
|
import { SOURCE_MODULE_RE } from '#auklet/css/constants';
|
|
5
|
-
import { normalizeFileKey, toWatchPath } from '#auklet/utils';
|
|
5
|
+
import { normalizeFileKey, toPosixPath, toWatchPath } from '#auklet/utils';
|
|
6
|
+
import { readPnpmWorkspacePackageInfoSync } from '#auklet/workspace/packages';
|
|
6
7
|
export class MonorepoPackageSource {
|
|
7
8
|
options;
|
|
8
9
|
packages;
|
|
9
10
|
packageNames;
|
|
10
11
|
root;
|
|
12
|
+
rawRoot;
|
|
11
13
|
constructor(options) {
|
|
12
14
|
this.options = options;
|
|
13
15
|
this.root = normalizeFileKey(options.root);
|
|
16
|
+
this.rawRoot = toPosixPath(path.resolve(options.root));
|
|
14
17
|
}
|
|
15
18
|
getPackages() {
|
|
16
19
|
if (this.packages)
|
|
17
20
|
return this.packages;
|
|
18
|
-
|
|
19
|
-
if (!fs.existsSync(packagesRoot)) {
|
|
20
|
-
this.packages = [];
|
|
21
|
-
return this.packages;
|
|
22
|
-
}
|
|
23
|
-
this.packages = fs
|
|
24
|
-
.readdirSync(packagesRoot, { withFileTypes: true })
|
|
25
|
-
.filter((entry) => entry.isDirectory())
|
|
26
|
-
.flatMap((entry) => {
|
|
27
|
-
const packageRoot = path.join(packagesRoot, entry.name);
|
|
28
|
-
const packageJsonPath = path.join(packageRoot, 'package.json');
|
|
29
|
-
if (!fs.existsSync(packageJsonPath))
|
|
30
|
-
return [];
|
|
31
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
32
|
-
if (!pkg.name)
|
|
33
|
-
return [];
|
|
34
|
-
return [
|
|
35
|
-
{
|
|
36
|
-
packageName: pkg.name,
|
|
37
|
-
packageRoot,
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
});
|
|
21
|
+
this.packages = this.getWorkspacePackages() ?? [];
|
|
41
22
|
return this.packages;
|
|
42
23
|
}
|
|
43
24
|
getPackageNames() {
|
|
@@ -49,8 +30,8 @@ export class MonorepoPackageSource {
|
|
|
49
30
|
}
|
|
50
31
|
isSourceGraphFile(file) {
|
|
51
32
|
const normalizedFile = normalizeFileKey(file);
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
33
|
+
const packages = this.getPackages();
|
|
34
|
+
if (!packages.some((item) => isPackageFile(item, normalizedFile))) {
|
|
54
35
|
return false;
|
|
55
36
|
}
|
|
56
37
|
if (normalizedFile.endsWith(aukletConfigFile))
|
|
@@ -60,10 +41,38 @@ export class MonorepoPackageSource {
|
|
|
60
41
|
return this.options.styleExtensions.some((extension) => normalizedFile.endsWith(extension));
|
|
61
42
|
}
|
|
62
43
|
async getWatchRoots() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
toWatchPath(
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
return this.getPackages().flatMap((item) => [
|
|
45
|
+
toWatchPath(item.packageRoot, 'src'),
|
|
46
|
+
toWatchPath(item.packageRoot, aukletConfigFile),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
getWorkspacePackages() {
|
|
50
|
+
const readWorkspacePackages = this.options.readWorkspacePackages;
|
|
51
|
+
if (!readWorkspacePackages &&
|
|
52
|
+
!fs.existsSync(path.join(this.options.root, 'pnpm-workspace.yaml'))) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const readPackages = readWorkspacePackages ?? readPnpmWorkspacePackageInfoSync;
|
|
57
|
+
return readPackages(this.options.root)
|
|
58
|
+
.filter((item) => !this.isWorkspaceRootPackage(item))
|
|
59
|
+
.map((item) => ({
|
|
60
|
+
packageName: item.name,
|
|
61
|
+
packageRoot: normalizeFileKey(item.path),
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new Error('[auklet:css] failed to read pnpm workspace packages for Vite monorepo mode.', { cause: error });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
isWorkspaceRootPackage(item) {
|
|
69
|
+
const normalizedPackageRoot = normalizeFileKey(item.path);
|
|
70
|
+
const rawPackageRoot = toPosixPath(path.resolve(item.path));
|
|
71
|
+
return (normalizedPackageRoot === this.root || rawPackageRoot === this.rawRoot);
|
|
68
72
|
}
|
|
69
73
|
}
|
|
74
|
+
const isPackageFile = (item, normalizedFile) => {
|
|
75
|
+
const packageRoot = normalizeFileKey(item.packageRoot);
|
|
76
|
+
return (normalizedFile === packageRoot ||
|
|
77
|
+
normalizedFile.startsWith(`${packageRoot}/`));
|
|
78
|
+
};
|
|
@@ -2,7 +2,6 @@ import type { ModuleStyleBuildConfig, ModuleStyleBuildContext } from '#auklet/ty
|
|
|
2
2
|
export declare class ModuleStyleWatcher {
|
|
3
3
|
private readonly config;
|
|
4
4
|
private readonly context;
|
|
5
|
-
private readonly logger?;
|
|
6
5
|
private timer;
|
|
7
6
|
private isBuilding;
|
|
8
7
|
private shouldRebuild;
|
|
@@ -8,7 +8,6 @@ import { ModuleStyleBuilder } from '#auklet/css/production/builder';
|
|
|
8
8
|
export class ModuleStyleWatcher {
|
|
9
9
|
config;
|
|
10
10
|
context;
|
|
11
|
-
logger;
|
|
12
11
|
timer = null;
|
|
13
12
|
isBuilding = false;
|
|
14
13
|
shouldRebuild = false;
|
|
@@ -19,11 +18,9 @@ export class ModuleStyleWatcher {
|
|
|
19
18
|
packageRoot: process.cwd(),
|
|
20
19
|
...context,
|
|
21
20
|
};
|
|
22
|
-
this.logger = context.logger;
|
|
23
21
|
}
|
|
24
22
|
async watch() {
|
|
25
23
|
await this.rebuild();
|
|
26
|
-
this.logger?.log?.('[auklet:css] watch mode ready');
|
|
27
24
|
}
|
|
28
25
|
async rebuild() {
|
|
29
26
|
if (this.isBuilding) {
|
|
@@ -37,7 +34,7 @@ export class ModuleStyleWatcher {
|
|
|
37
34
|
await this.refreshWatcher();
|
|
38
35
|
}
|
|
39
36
|
catch (error) {
|
|
40
|
-
|
|
37
|
+
// Watch mode keeps running after transient build or watcher errors.
|
|
41
38
|
}
|
|
42
39
|
finally {
|
|
43
40
|
this.isBuilding = false;
|
|
@@ -65,18 +62,14 @@ export class ModuleStyleWatcher {
|
|
|
65
62
|
}
|
|
66
63
|
this.scheduleBuild();
|
|
67
64
|
});
|
|
68
|
-
this.watcher.on('error', (
|
|
69
|
-
this.logger?.error?.(error);
|
|
70
|
-
});
|
|
65
|
+
this.watcher.on('error', () => undefined);
|
|
71
66
|
}
|
|
72
67
|
scheduleBuild() {
|
|
73
68
|
if (this.timer)
|
|
74
69
|
clearTimeout(this.timer);
|
|
75
70
|
this.timer = setTimeout(() => {
|
|
76
71
|
this.timer = null;
|
|
77
|
-
this.rebuild()
|
|
78
|
-
this.logger?.error?.(error);
|
|
79
|
-
});
|
|
72
|
+
void this.rebuild();
|
|
80
73
|
}, 80);
|
|
81
74
|
}
|
|
82
75
|
shouldRebuildForFile(file) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export type { AukletConfig, ConfigureTsdown, ConfigureTsdownContext,
|
|
2
|
-
export type { RunTsdownOptions } from '#auklet/build/runTsdown';
|
|
1
|
+
export type { AukletConfig, ConfigureTsdown, ConfigureTsdownContext, PackageBuildFormat, PackageBuildPlatform, PackageBuildOptions, PackageBuildTarget, StyleDependencyGroup, StyleOptions, } from '#auklet/types';
|
|
3
2
|
export type { AukletStylePluginOptions } from '#auklet/css/vite/vitePlugin';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
3
|
+
export { runAukletCli } from '#auklet/cli/main';
|
|
4
|
+
export { runTsdown } from '#auklet/build/runTsdown';
|
|
5
|
+
export { loadAukletConfig } from '#auklet/configLoader';
|
|
6
6
|
export { aukletStylePlugin } from '#auklet/css/vite/vitePlugin';
|
|
7
|
-
export {
|
|
8
|
-
export { ModuleStyleWatcher } from '#auklet/css/watch/watcher';
|
|
9
|
-
export { ModuleStyleBuilder } from '#auklet/css/production/builder';
|
|
7
|
+
export { defineKernelPackageConfigFromFile, defineKernelPackageConfigFromOptions, } from '#auklet/build/tsdownConfig';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { runAukletCli } from '#auklet/cli/main';
|
|
2
|
+
export { runTsdown } from '#auklet/build/runTsdown';
|
|
3
|
+
export { loadAukletConfig } from '#auklet/configLoader';
|
|
3
4
|
export { aukletStylePlugin } from '#auklet/css/vite/vitePlugin';
|
|
4
|
-
export {
|
|
5
|
-
export { ModuleStyleWatcher } from '#auklet/css/watch/watcher';
|
|
6
|
-
export { ModuleStyleBuilder } from '#auklet/css/production/builder';
|
|
5
|
+
export { defineKernelPackageConfigFromFile, defineKernelPackageConfigFromOptions, } from '#auklet/build/tsdownConfig';
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Logger, type LoggerOptions } from 'briefing';
|
|
2
|
+
export type AukletLogger = Logger;
|
|
3
|
+
export type CreateAukletLoggerOptions = Pick<LoggerOptions, 'scope' | 'prefix' | 'colors' | 'silent' | 'verbose' | 'sink'>;
|
|
4
|
+
export declare function createAukletLogger(options?: CreateAukletLoggerOptions): Logger;
|
|
5
|
+
export declare function createScopedAukletLogger(scope: string): Logger;
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Logger } from 'briefing';
|
|
2
|
+
export function createAukletLogger(options = {}) {
|
|
3
|
+
return new Logger({
|
|
4
|
+
prefix: options.prefix,
|
|
5
|
+
scope: options.scope,
|
|
6
|
+
colors: options.colors,
|
|
7
|
+
silent: options.silent,
|
|
8
|
+
verbose: options.verbose,
|
|
9
|
+
sink: options.sink,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function createScopedAukletLogger(scope) {
|
|
13
|
+
return createAukletLogger({ scope });
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AukletLogger } from '#auklet/logger';
|
|
2
|
+
export declare function isGitRepository(cwd: string): Promise<boolean>;
|
|
3
|
+
export declare function getGitShortHash(cwd: string): Promise<string | null>;
|
|
4
|
+
export declare function ensureGitClean(cwd: string): Promise<void>;
|
|
5
|
+
export declare function hasGitChanges(cwd: string): Promise<boolean>;
|
|
6
|
+
export declare function commitRelease(cwd: string, version: string): Promise<void>;
|
|
7
|
+
export declare function createVersionTag(cwd: string, version: string, logger: AukletLogger): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
const runGit = async (args, cwd) => {
|
|
3
|
+
return execa('git', args, {
|
|
4
|
+
cwd,
|
|
5
|
+
reject: false,
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
export async function isGitRepository(cwd) {
|
|
9
|
+
const result = await runGit(['rev-parse', '--is-inside-work-tree'], cwd);
|
|
10
|
+
return !result.exitCode && result.stdout.trim() === 'true';
|
|
11
|
+
}
|
|
12
|
+
export async function getGitShortHash(cwd) {
|
|
13
|
+
const result = await runGit(['rev-parse', '--short=6', 'HEAD'], cwd);
|
|
14
|
+
if (result.exitCode)
|
|
15
|
+
return null;
|
|
16
|
+
return result.stdout.trim() || null;
|
|
17
|
+
}
|
|
18
|
+
export async function ensureGitClean(cwd) {
|
|
19
|
+
const result = await runGit(['status', '--porcelain'], cwd);
|
|
20
|
+
if (result.exitCode) {
|
|
21
|
+
throw new Error('[auklet:publish] failed to check git status.');
|
|
22
|
+
}
|
|
23
|
+
if (result.stdout.trim()) {
|
|
24
|
+
throw new Error('[auklet:publish] git working tree must be clean before publishing.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function hasGitChanges(cwd) {
|
|
28
|
+
const result = await runGit(['status', '--porcelain'], cwd);
|
|
29
|
+
if (result.exitCode) {
|
|
30
|
+
throw new Error('[auklet:publish] failed to check git status.');
|
|
31
|
+
}
|
|
32
|
+
return Boolean(result.stdout.trim());
|
|
33
|
+
}
|
|
34
|
+
export async function commitRelease(cwd, version) {
|
|
35
|
+
const addResult = await runGit(['add', '-A'], cwd);
|
|
36
|
+
if (addResult.exitCode) {
|
|
37
|
+
throw new Error('[auklet:publish] failed to stage release changes.');
|
|
38
|
+
}
|
|
39
|
+
const commitResult = await runGit(['commit', '-m', `release: ${version}`], cwd);
|
|
40
|
+
if (commitResult.exitCode) {
|
|
41
|
+
throw new Error('[auklet:publish] failed to commit release changes.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export async function createVersionTag(cwd, version, logger) {
|
|
45
|
+
const tagName = `v${version}`;
|
|
46
|
+
const exists = await runGit(['rev-parse', '--verify', tagName], cwd);
|
|
47
|
+
if (!exists.exitCode) {
|
|
48
|
+
logger.warnOnce('git tag ', logger.version(tagName), ' already exists, skipping tag creation.');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const result = await runGit(['tag', tagName], cwd);
|
|
52
|
+
if (result.exitCode) {
|
|
53
|
+
throw new Error(`[auklet:publish] failed to create git tag ${tagName}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PackageJson } from '#auklet/publish/types';
|
|
2
|
+
export declare function getPackageJsonPath(packageRoot: string): string;
|
|
3
|
+
export declare function readPackageJson(packageRoot: string): PackageJson;
|
|
4
|
+
export declare function writePackageJson(packageRoot: string, packageJson: PackageJson): void;
|
|
5
|
+
export declare function requirePackageName(packageRoot: string, packageJson: PackageJson): string;
|
|
6
|
+
export declare function requirePackageVersion(packageRoot: string, packageJson: PackageJson): string;
|
|
7
|
+
export declare function getPublishConfig(packageJson: PackageJson): import("#auklet/publish/types").PublishPackageConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const packageJsonFile = 'package.json';
|
|
4
|
+
export function getPackageJsonPath(packageRoot) {
|
|
5
|
+
return path.join(packageRoot, packageJsonFile);
|
|
6
|
+
}
|
|
7
|
+
export function readPackageJson(packageRoot) {
|
|
8
|
+
const filePath = getPackageJsonPath(packageRoot);
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
throw new Error(`[auklet:publish] failed to read package.json at ${filePath}.`, { cause: error });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function writePackageJson(packageRoot, packageJson) {
|
|
17
|
+
const filePath = getPackageJsonPath(packageRoot);
|
|
18
|
+
fs.writeFileSync(filePath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
19
|
+
}
|
|
20
|
+
export function requirePackageName(packageRoot, packageJson) {
|
|
21
|
+
if (typeof packageJson.name === 'string' && packageJson.name) {
|
|
22
|
+
return packageJson.name;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`[auklet:publish] package.json#name is required at ${packageRoot}.`);
|
|
25
|
+
}
|
|
26
|
+
export function requirePackageVersion(packageRoot, packageJson) {
|
|
27
|
+
if (typeof packageJson.version === 'string' && packageJson.version) {
|
|
28
|
+
return packageJson.version;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`[auklet:publish] package.json#version is required at ${packageRoot}.`);
|
|
31
|
+
}
|
|
32
|
+
export function getPublishConfig(packageJson) {
|
|
33
|
+
return packageJson.auklet?.publish ?? {};
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkspacePackage } from '#auklet/publish/types';
|
|
2
|
+
export declare function ensurePnpm(): Promise<string>;
|
|
3
|
+
export declare function readPnpmWorkspacePackages(root: string): Promise<WorkspacePackage[]>;
|
|
4
|
+
export declare function runPnpmBuild(packageRoot: string): Promise<void>;
|
|
5
|
+
export declare function runPnpmPublish(packageRoot: string, args: Array<string>): Promise<void>;
|
|
6
|
+
export declare function runPnpmOwnerAdd(packageName: string, user: string, options: {
|
|
7
|
+
cwd: string;
|
|
8
|
+
otp?: string;
|
|
9
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import { readPnpmWorkspacePackageInfo } from '#auklet/workspace/packages';
|
|
4
|
+
const supportedPnpmRange = '>=10.0.0';
|
|
5
|
+
const runPnpm = async (args, options = {}) => {
|
|
6
|
+
return execa('pnpm', args, {
|
|
7
|
+
reject: false,
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export async function ensurePnpm() {
|
|
12
|
+
const result = await runPnpm(['--version']);
|
|
13
|
+
const stdout = String(result.stdout ?? '');
|
|
14
|
+
if (result.failed || !stdout) {
|
|
15
|
+
throw new Error('[auklet:publish] pnpm is required for publishing.\n' +
|
|
16
|
+
'[auklet:publish] Install pnpm first:\n' +
|
|
17
|
+
' corepack enable\n' +
|
|
18
|
+
' corepack prepare pnpm@10 --activate');
|
|
19
|
+
}
|
|
20
|
+
const version = stdout.trim();
|
|
21
|
+
if (!semver.satisfies(version, supportedPnpmRange)) {
|
|
22
|
+
throw new Error(`[auklet:publish] unsupported pnpm version: ${version}\n` +
|
|
23
|
+
`[auklet:publish] expected pnpm ${supportedPnpmRange}`);
|
|
24
|
+
}
|
|
25
|
+
return version;
|
|
26
|
+
}
|
|
27
|
+
export async function readPnpmWorkspacePackages(root) {
|
|
28
|
+
try {
|
|
29
|
+
return (await readPnpmWorkspacePackageInfo(root)).map((item) => {
|
|
30
|
+
if (!isWorkspacePackage(item))
|
|
31
|
+
throwInvalidWorkspacePackages();
|
|
32
|
+
return item;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new Error('[auklet:publish] failed to read pnpm workspace packages.', { cause: error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export async function runPnpmBuild(packageRoot) {
|
|
40
|
+
const result = await runPnpm(['run', 'build'], {
|
|
41
|
+
cwd: packageRoot,
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
});
|
|
44
|
+
if (result.exitCode) {
|
|
45
|
+
throw new Error(`[auklet:publish] build failed at ${packageRoot}.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function runPnpmPublish(packageRoot, args) {
|
|
49
|
+
const result = await runPnpm(['publish', ...args], {
|
|
50
|
+
cwd: packageRoot,
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
});
|
|
53
|
+
if (result.exitCode) {
|
|
54
|
+
throw new Error(`[auklet:publish] pnpm publish failed at ${packageRoot}.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function runPnpmOwnerAdd(packageName, user, options) {
|
|
58
|
+
const args = ['owner', 'add', user, packageName];
|
|
59
|
+
if (options.otp)
|
|
60
|
+
args.push('--otp', options.otp);
|
|
61
|
+
const result = await runPnpm(args, {
|
|
62
|
+
cwd: options.cwd,
|
|
63
|
+
stdio: 'inherit',
|
|
64
|
+
});
|
|
65
|
+
if (result.exitCode) {
|
|
66
|
+
throw new Error(`[auklet:publish] pnpm owner add failed for ${user} -> ${packageName}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const isWorkspacePackage = (value) => {
|
|
70
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const item = value;
|
|
74
|
+
return (typeof item.name === 'string' &&
|
|
75
|
+
item.name.length > 0 &&
|
|
76
|
+
typeof item.path === 'string' &&
|
|
77
|
+
item.path.length > 0 &&
|
|
78
|
+
typeof item.version === 'string' &&
|
|
79
|
+
item.version.length > 0 &&
|
|
80
|
+
(item.private === undefined || typeof item.private === 'boolean'));
|
|
81
|
+
};
|
|
82
|
+
function throwInvalidWorkspacePackages() {
|
|
83
|
+
throw new Error('[auklet:publish] failed to read pnpm workspace packages.\n' +
|
|
84
|
+
'[auklet:publish] Expected `pnpm list -r --depth -1 --json` to return package objects with name/path/version.');
|
|
85
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { runPnpmPublish } from '#auklet/publish/api/pnpmApi';
|
|
2
|
+
import { createPublishArgs } from '#auklet/publish/api/publishArgs';
|
|
3
|
+
export class PnpmPublishApi {
|
|
4
|
+
async publish(target, options) {
|
|
5
|
+
await runPnpmPublish(target.packageRoot, createPublishArgs(target, options));
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function createPublishArgs(target, options) {
|
|
2
|
+
const args = ['--no-git-checks'];
|
|
3
|
+
if (options.dryRun)
|
|
4
|
+
args.push('--dry-run');
|
|
5
|
+
if (options.otp)
|
|
6
|
+
args.push('--otp', options.otp);
|
|
7
|
+
if (options.ignoreScripts)
|
|
8
|
+
args.push('--ignore-scripts');
|
|
9
|
+
if (shouldAddPublicAccess(target))
|
|
10
|
+
args.push('--access', 'public');
|
|
11
|
+
const tag = getPublishTag(options.version);
|
|
12
|
+
if (tag)
|
|
13
|
+
args.push('--tag', tag);
|
|
14
|
+
return args;
|
|
15
|
+
}
|
|
16
|
+
const shouldAddPublicAccess = (target) => {
|
|
17
|
+
return (target.packageName.startsWith('@') &&
|
|
18
|
+
!target.private &&
|
|
19
|
+
!target.packageJson.publishConfig?.access);
|
|
20
|
+
};
|
|
21
|
+
const getPublishTag = (versionSpec) => {
|
|
22
|
+
if (versionSpec === 'alpha' || versionSpec === 'beta')
|
|
23
|
+
return versionSpec;
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HookStatus, HookResult, PublishPlan, PublishTarget } from '#auklet/publish/types';
|
|
2
|
+
type RunPublishHookOptions = {
|
|
3
|
+
status: HookStatus;
|
|
4
|
+
plan: PublishPlan;
|
|
5
|
+
result?: HookResult;
|
|
6
|
+
failedTarget?: PublishTarget;
|
|
7
|
+
error?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare function runPublishHook(options: RunPublishHookOptions): Promise<void>;
|
|
10
|
+
export {};
|