auklet 0.0.21 → 0.0.22

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.
@@ -13,10 +13,19 @@ export function hasTsdownConfigArg(args) {
13
13
  args[index - 1] === '-c' ||
14
14
  args[index - 1] === '--config');
15
15
  }
16
+ const hasTsdownConfigLoaderArg = (args) => {
17
+ return args.some((arg, index) => arg === '--config-loader' ||
18
+ arg.startsWith('--config-loader=') ||
19
+ args[index - 1] === '--config-loader');
20
+ };
16
21
  export function createTsdownArgs(args) {
17
- const tsdownArgs = hasTsdownConfigArg(args)
18
- ? args
19
- : ['--config', defaultConfigFile, ...args];
22
+ if (hasTsdownConfigArg(args)) {
23
+ return [tsdownRunFile, ...args];
24
+ }
25
+ const loaderArgs = hasTsdownConfigLoaderArg(args)
26
+ ? []
27
+ : ['--config-loader', 'native'];
28
+ const tsdownArgs = ['--config', defaultConfigFile, ...loaderArgs, ...args];
20
29
  return [tsdownRunFile, ...tsdownArgs];
21
30
  }
22
31
  export async function runTsdown(args, options = {}) {
@@ -3,6 +3,7 @@ export declare function ensurePnpm(): Promise<string>;
3
3
  export declare function readPnpmWorkspacePackages(root: string): Promise<WorkspacePackage[]>;
4
4
  export declare function runPnpmBuild(packageRoot: string): Promise<void>;
5
5
  export declare function runPnpmPublish(packageRoot: string, args: Array<string>): Promise<void>;
6
+ export declare function runPnpmWhoami(root: string): Promise<string>;
6
7
  export declare function runPnpmOwnerAdd(packageName: string, user: string, options: {
7
8
  cwd: string;
8
9
  otp?: string;
@@ -55,6 +55,16 @@ export async function runPnpmPublish(packageRoot, args) {
55
55
  throw new Error(`[auklet:publish] pnpm publish failed at ${packageRoot}.`);
56
56
  }
57
57
  }
58
+ export async function runPnpmWhoami(root) {
59
+ const result = await runPnpm(['whoami'], {
60
+ cwd: root,
61
+ });
62
+ if (result.exitCode) {
63
+ throw new Error('[auklet:publish] npm authentication is required before publishing.\n' +
64
+ '[auklet:publish] Run `pnpm login` or configure an npm token before retrying.');
65
+ }
66
+ return String(result.stdout ?? '').trim();
67
+ }
58
68
  export async function runPnpmOwnerAdd(packageName, user, options) {
59
69
  const args = ['owner', 'add', user, packageName];
60
70
  if (options.otp)
@@ -57,6 +57,7 @@ export class PublishRunner {
57
57
  const plan = await resolvePublishPlan(this.options, this.logger);
58
58
  validateBuildScript(plan.targets);
59
59
  await this.git.checkBeforePublish(plan);
60
+ await this.preflight.verifyAuthentication(plan);
60
61
  this.versions.logDryRunPlan(plan);
61
62
  return plan;
62
63
  }
@@ -4,5 +4,6 @@ export declare class PublishPreflight {
4
4
  private readonly pnpm;
5
5
  constructor(options: PublishOptions);
6
6
  run(plan: PublishPlan): Promise<void>;
7
+ verifyAuthentication(plan: PublishPlan): Promise<void>;
7
8
  private verifyPnpmPublishDryRun;
8
9
  }
@@ -1,4 +1,5 @@
1
1
  import { PnpmPublishApi } from '#auklet/publish/api/pnpmPublishApi';
2
+ import { runPnpmWhoami } from '#auklet/publish/api/pnpmApi';
2
3
  import { PublishTargetError } from '#auklet/publish/runner/publishTargetError';
3
4
  export class PublishPreflight {
4
5
  options;
@@ -9,6 +10,11 @@ export class PublishPreflight {
9
10
  async run(plan) {
10
11
  await this.verifyPnpmPublishDryRun(plan);
11
12
  }
13
+ async verifyAuthentication(plan) {
14
+ if (plan.dryRun)
15
+ return;
16
+ await runPnpmWhoami(plan.root);
17
+ }
12
18
  async verifyPnpmPublishDryRun(plan) {
13
19
  const options = {
14
20
  ...this.options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
6
  "description": "Build utilities for TypeScript packages and module CSS output.",