auklet 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -125,10 +125,16 @@ Publish controls stay on CLI flags:
|
|
|
125
125
|
auk publish --filter @scope/ui
|
|
126
126
|
auk publish --version patch --dry-run
|
|
127
127
|
auk publish --no-format
|
|
128
|
+
auk publish --otp 123456
|
|
128
129
|
```
|
|
129
130
|
|
|
130
131
|
`--no-format` disables auklet's publish output formatter for that run. It is not
|
|
131
132
|
configured in `package.json`.
|
|
133
|
+
Before writing versions, auklet checks npm authentication from each target
|
|
134
|
+
package directory. Package-local `.npmrc` files and
|
|
135
|
+
`package.json#publishConfig.registry` are respected.
|
|
136
|
+
`--otp` is forwarded to `pnpm publish` for npm accounts or organizations that
|
|
137
|
+
require publish 2FA. In CI, prefer an npm automation token.
|
|
132
138
|
|
|
133
139
|
## Configuration
|
|
134
140
|
|
package/dist/build/runTsdown.js
CHANGED
|
@@ -3,8 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
const tsdownRunFile = require.resolve('tsdown/run');
|
|
6
|
-
const
|
|
7
|
-
const defaultConfigFile = fileURLToPath(new URL(`./tsdownConfig.${currentExtension}`, import.meta.url));
|
|
6
|
+
const defaultConfigFile = fileURLToPath(new URL('./tsdownConfig.js', import.meta.url));
|
|
8
7
|
export function hasTsdownConfigArg(args) {
|
|
9
8
|
return args.some((arg, index) => arg === '--no-config' ||
|
|
10
9
|
arg === '-c' ||
|
|
@@ -6,7 +6,10 @@ export declare function ensurePnpm(): Promise<string>;
|
|
|
6
6
|
export declare function readPnpmWorkspacePackages(root: string): Promise<WorkspacePackage[]>;
|
|
7
7
|
export declare function runPnpmBuild(packageRoot: string): Promise<void>;
|
|
8
8
|
export declare function runPnpmPublish(packageRoot: string, args: Array<string>): Promise<void>;
|
|
9
|
-
export declare function runPnpmWhoami(
|
|
9
|
+
export declare function runPnpmWhoami(packageRoot: string, options?: {
|
|
10
|
+
packageName?: string;
|
|
11
|
+
registry?: string;
|
|
12
|
+
}): Promise<string>;
|
|
10
13
|
export declare function runPnpmOwnerAdd(packageName: string, user: string, options: {
|
|
11
14
|
cwd: string;
|
|
12
15
|
otp?: string;
|
|
@@ -5,7 +5,8 @@ import { readPnpmWorkspacePackageInfo } from '#auklet/workspace/packages';
|
|
|
5
5
|
const supportedPnpmRange = '>=10.0.0';
|
|
6
6
|
export class NpmPublishAuthenticationError extends Error {
|
|
7
7
|
constructor(packageRoot) {
|
|
8
|
-
super(`[publish] pnpm publish failed at ${packageRoot}:
|
|
8
|
+
super(`[publish] pnpm publish failed at ${packageRoot}: ` +
|
|
9
|
+
`npm publish requires additional authentication.`);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
const runPnpm = async (args, options = {}) => {
|
|
@@ -66,12 +67,17 @@ export async function runPnpmPublish(packageRoot, args) {
|
|
|
66
67
|
throw new Error(`[publish] pnpm publish failed at ${packageRoot}.`);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
export async function runPnpmWhoami(
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
export async function runPnpmWhoami(packageRoot, options = {}) {
|
|
71
|
+
const args = ['whoami'];
|
|
72
|
+
if (options.registry)
|
|
73
|
+
args.push('--registry', options.registry);
|
|
74
|
+
const result = await runPnpm(args, {
|
|
75
|
+
cwd: packageRoot,
|
|
72
76
|
});
|
|
73
77
|
if (result.exitCode) {
|
|
74
|
-
|
|
78
|
+
const target = options.packageName ? ` for ${options.packageName}` : '';
|
|
79
|
+
const registry = options.registry ? ` at ${options.registry}` : '';
|
|
80
|
+
throw new Error(`[publish] npm authentication is required${target}${registry} before publishing.\n` +
|
|
75
81
|
'[publish] Run `pnpm login` or configure an npm token before retrying.');
|
|
76
82
|
}
|
|
77
83
|
return String(result.stdout ?? '').trim();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainObject, isString } from 'aidly';
|
|
1
2
|
import { PnpmPublishApi } from '#auklet/publish/api/pnpmPublishApi';
|
|
2
3
|
import { runPnpmWhoami } from '#auklet/publish/api/pnpmApi';
|
|
3
4
|
import { logAuthenticationError } from '#auklet/publish/runner/packagePublisher';
|
|
@@ -16,7 +17,18 @@ export class PublishPreflight {
|
|
|
16
17
|
async verifyAuthentication(plan) {
|
|
17
18
|
if (plan.dryRun)
|
|
18
19
|
return;
|
|
19
|
-
|
|
20
|
+
const checked = new Set();
|
|
21
|
+
for (const target of plan.targets) {
|
|
22
|
+
const registry = getPublishRegistry(target.packageJson.publishConfig);
|
|
23
|
+
const key = `${target.packageRoot}\n${registry ?? ''}`;
|
|
24
|
+
if (checked.has(key))
|
|
25
|
+
continue;
|
|
26
|
+
await runPnpmWhoami(target.packageRoot, {
|
|
27
|
+
packageName: target.packageName,
|
|
28
|
+
registry,
|
|
29
|
+
});
|
|
30
|
+
checked.add(key);
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
async verifyPnpmPublishDryRun(plan) {
|
|
22
34
|
const options = {
|
|
@@ -34,3 +46,9 @@ export class PublishPreflight {
|
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
}
|
|
49
|
+
const getPublishRegistry = (publishConfig) => {
|
|
50
|
+
if (!isPlainObject(publishConfig))
|
|
51
|
+
return undefined;
|
|
52
|
+
const registry = Reflect.get(publishConfig, 'registry');
|
|
53
|
+
return isString(registry) && registry.length > 0 ? registry : undefined;
|
|
54
|
+
};
|