@releasekit/publish 0.3.0-next.4 → 0.3.1

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.d.ts CHANGED
@@ -1 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+
4
+ declare function createPublishCommand(): Command;
5
+
6
+ export { createPublishCommand };
package/dist/cli.js CHANGED
@@ -1,63 +1,81 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  BasePublishError,
4
+ EXIT_CODES,
4
5
  PipelineError,
5
6
  loadConfig,
6
7
  parseInput,
7
- runPipeline
8
- } from "./chunk-GOBII36Q.js";
8
+ readPackageVersion,
9
+ runPipeline,
10
+ setJsonMode,
11
+ setLogLevel
12
+ } from "./chunk-GIMIZS5B.js";
9
13
 
10
14
  // src/cli.ts
11
- import { EXIT_CODES, setJsonMode, setLogLevel } from "@releasekit/core";
15
+ import { realpathSync } from "fs";
16
+ import { fileURLToPath } from "url";
12
17
  import { Command } from "commander";
13
- var program = new Command();
14
- program.name("releasekit-publish").description("Publish packages to registries with git tagging and GitHub releases").version("0.1.0").option("--input <path>", "Path to version output JSON (default: stdin)").option("--config <path>", "Path to releasekit config").option("--registry <type>", "Registry to publish to (npm, cargo, all)", "all").option("--npm-auth <method>", "NPM auth method (oidc, token, auto)", "auto").option("--dry-run", "Simulate all operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-publish", "Skip registry publishing", false).option("--skip-github-release", "Skip GitHub Release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("--json", "Output results as JSON", false).option("--verbose", "Verbose logging", false).action(async (options) => {
15
- if (options.verbose) setLogLevel("debug");
16
- if (options.json) setJsonMode(true);
17
- try {
18
- const config = loadConfig({ configPath: options.config });
19
- const input = await parseInput(options.input);
20
- if (options.npmAuth !== "auto") {
21
- config.npm.auth = options.npmAuth;
22
- }
23
- const cliOptions = {
24
- input: options.input,
25
- config: options.config,
26
- registry: options.registry,
27
- npmAuth: options.npmAuth,
28
- dryRun: options.dryRun,
29
- skipGit: options.skipGit,
30
- skipPublish: options.skipPublish,
31
- skipGithubRelease: options.skipGithubRelease,
32
- skipVerification: options.skipVerification,
33
- json: options.json,
34
- verbose: options.verbose
35
- };
36
- const output = await runPipeline(input, config, cliOptions);
37
- if (options.json) {
38
- console.log(JSON.stringify(output, null, 2));
39
- }
40
- } catch (err) {
41
- if (err instanceof PipelineError && options.json) {
42
- console.log(
43
- JSON.stringify(
44
- {
45
- error: err.message,
46
- failedStage: err.failedStage,
47
- partialOutput: err.partialOutput
48
- },
49
- null,
50
- 2
51
- )
52
- );
53
- process.exit(EXIT_CODES.PUBLISH_ERROR);
18
+ function createPublishCommand() {
19
+ return new Command("publish").description("Publish packages to registries with git tagging and GitHub releases").option("--input <path>", "Path to version output JSON (default: stdin)").option("--config <path>", "Path to releasekit config").option("--registry <type>", "Registry to publish to (npm, cargo, all)", "all").option("--npm-auth <method>", "NPM auth method (oidc, token, auto)", "auto").option("--dry-run", "Simulate all operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-publish", "Skip registry publishing", false).option("--skip-github-release", "Skip GitHub Release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("--json", "Output results as JSON", false).option("--verbose", "Verbose logging", false).action(async (options) => {
20
+ if (options.verbose) setLogLevel("debug");
21
+ if (options.json) setJsonMode(true);
22
+ try {
23
+ const config = loadConfig({ configPath: options.config });
24
+ const input = await parseInput(options.input);
25
+ if (options.npmAuth !== "auto") {
26
+ config.npm.auth = options.npmAuth;
27
+ }
28
+ const cliOptions = {
29
+ input: options.input,
30
+ config: options.config,
31
+ registry: options.registry,
32
+ npmAuth: options.npmAuth,
33
+ dryRun: options.dryRun,
34
+ skipGit: options.skipGit,
35
+ skipPublish: options.skipPublish,
36
+ skipGithubRelease: options.skipGithubRelease,
37
+ skipVerification: options.skipVerification,
38
+ json: options.json,
39
+ verbose: options.verbose
40
+ };
41
+ const output = await runPipeline(input, config, cliOptions);
42
+ if (options.json) {
43
+ console.log(JSON.stringify(output, null, 2));
44
+ }
45
+ } catch (err) {
46
+ if (err instanceof PipelineError && options.json) {
47
+ console.log(
48
+ JSON.stringify(
49
+ {
50
+ error: err.message,
51
+ failedStage: err.failedStage,
52
+ partialOutput: err.partialOutput
53
+ },
54
+ null,
55
+ 2
56
+ )
57
+ );
58
+ process.exit(EXIT_CODES.PUBLISH_ERROR);
59
+ }
60
+ if (BasePublishError.isPublishError(err)) {
61
+ err.logError();
62
+ process.exit(EXIT_CODES.PUBLISH_ERROR);
63
+ }
64
+ console.error(err instanceof Error ? err.message : String(err));
65
+ process.exit(EXIT_CODES.GENERAL_ERROR);
54
66
  }
55
- if (BasePublishError.isPublishError(err)) {
56
- err.logError();
57
- process.exit(EXIT_CODES.PUBLISH_ERROR);
58
- }
59
- console.error(err instanceof Error ? err.message : String(err));
60
- process.exit(EXIT_CODES.GENERAL_ERROR);
67
+ });
68
+ }
69
+ var isMain = (() => {
70
+ try {
71
+ return process.argv[1] ? realpathSync(process.argv[1]) === fileURLToPath(import.meta.url) : false;
72
+ } catch {
73
+ return false;
61
74
  }
62
- });
63
- program.parse();
75
+ })();
76
+ if (isMain) {
77
+ createPublishCommand().name("releasekit-publish").version(readPackageVersion(import.meta.url)).parse();
78
+ }
79
+ export {
80
+ createPublishCommand
81
+ };
package/dist/index.d.ts CHANGED
@@ -1,173 +1,9 @@
1
- import { LoadOptions, CargoManifest } from '@releasekit/config';
2
- export { CargoManifest, parseCargoToml } from '@releasekit/config';
3
- import { VersionOutput, ReleaseKitError } from '@releasekit/core';
4
-
5
- type PackageManager = 'pnpm' | 'npm' | 'yarn';
6
- declare function detectPackageManager(cwd: string): PackageManager;
7
-
8
- interface NpmConfig {
9
- enabled: boolean;
10
- auth: 'auto' | 'oidc' | 'token';
11
- provenance: boolean;
12
- access: 'public' | 'restricted';
13
- registry: string;
14
- copyFiles: string[];
15
- tag: string;
16
- }
17
- interface CargoConfig {
18
- enabled: boolean;
19
- noVerify: boolean;
20
- publishOrder: string[];
21
- clean: boolean;
22
- }
23
- interface GitConfig {
24
- push: boolean;
25
- pushMethod: 'auto' | 'ssh' | 'https';
26
- remote: string;
27
- branch: string;
28
- httpsTokenEnv?: string;
29
- skipHooks?: boolean;
30
- }
31
- interface GitHubReleaseConfig {
32
- enabled: boolean;
33
- draft: boolean;
34
- perPackage: boolean;
35
- prerelease: 'auto' | boolean;
36
- /** 'auto' | 'github' | 'none' | file path */
37
- releaseNotes: string;
38
- }
39
- interface VerifyRegistryConfig {
40
- enabled: boolean;
41
- maxAttempts: number;
42
- initialDelay: number;
43
- backoffMultiplier: number;
44
- }
45
- interface VerifyConfig {
46
- npm: VerifyRegistryConfig;
47
- cargo: VerifyRegistryConfig;
48
- }
49
- interface PublishConfig {
50
- npm: NpmConfig;
51
- cargo: CargoConfig;
52
- git: GitConfig;
53
- githubRelease: GitHubReleaseConfig;
54
- verify: VerifyConfig;
55
- }
56
- interface PublishCliOptions {
57
- input?: string;
58
- config?: string;
59
- registry: 'npm' | 'cargo' | 'all';
60
- npmAuth: 'auto' | 'oidc' | 'token';
61
- dryRun: boolean;
62
- skipGit: boolean;
63
- skipGitCommit?: boolean;
64
- skipPublish: boolean;
65
- skipGithubRelease: boolean;
66
- skipVerification: boolean;
67
- json: boolean;
68
- verbose: boolean;
69
- /** Per-package release notes keyed by package name, from the notes pipeline. */
70
- releaseNotes?: Record<string, string>;
71
- /** Additional files to stage in the git commit (e.g., changelog files from the notes step). */
72
- additionalFiles?: string[];
73
- }
74
- interface PublishResult {
75
- packageName: string;
76
- version: string;
77
- registry: 'npm' | 'cargo';
78
- success: boolean;
79
- skipped: boolean;
80
- reason?: string;
81
- alreadyPublished?: boolean;
82
- }
83
- interface VerificationResult {
84
- packageName: string;
85
- version: string;
86
- registry: 'npm' | 'cargo';
87
- verified: boolean;
88
- attempts: number;
89
- }
90
- interface GitHubReleaseResult {
91
- tag: string;
92
- url?: string;
93
- draft: boolean;
94
- prerelease: boolean;
95
- success: boolean;
96
- reason?: string;
97
- }
98
- interface GitResult {
99
- committed: boolean;
100
- tags: string[];
101
- pushed: boolean;
102
- }
103
- interface PublishOutput {
104
- dryRun: boolean;
105
- git: GitResult;
106
- npm: PublishResult[];
107
- cargo: PublishResult[];
108
- verification: VerificationResult[];
109
- githubReleases: GitHubReleaseResult[];
110
- }
111
- interface PipelineContext {
112
- input: VersionOutput;
113
- config: PublishConfig;
114
- cliOptions: PublishCliOptions;
115
- packageManager: PackageManager;
116
- output: PublishOutput;
117
- cwd: string;
118
- /** Per-package release notes keyed by package name, passed from the notes pipeline. */
119
- releaseNotes?: Record<string, string>;
120
- /** Additional files to stage in the git commit (e.g., changelog files from the notes step). */
121
- additionalFiles?: string[];
122
- }
123
-
124
- declare function loadConfig(options?: LoadOptions): PublishConfig;
125
- declare function getDefaultConfig(): PublishConfig;
126
-
127
- declare class BasePublishError extends ReleaseKitError {
128
- readonly code: string;
129
- readonly suggestions: string[];
130
- constructor(message: string, code: string, suggestions?: string[]);
131
- static isPublishError(error: unknown): error is BasePublishError;
132
- }
133
- declare class PublishError extends BasePublishError {
134
- }
135
- declare class PipelineError extends BasePublishError {
136
- readonly partialOutput: PublishOutput;
137
- readonly failedStage: string;
138
- readonly cause?: Error;
139
- constructor(message: string, failedStage: string, partialOutput: PublishOutput, cause?: Error);
140
- }
141
- declare enum PublishErrorCode {
142
- INPUT_PARSE_ERROR = "INPUT_PARSE_ERROR",
143
- INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR",
144
- CONFIG_ERROR = "CONFIG_ERROR",
145
- GIT_COMMIT_ERROR = "GIT_COMMIT_ERROR",
146
- GIT_TAG_ERROR = "GIT_TAG_ERROR",
147
- GIT_PUSH_ERROR = "GIT_PUSH_ERROR",
148
- NPM_PUBLISH_ERROR = "NPM_PUBLISH_ERROR",
149
- NPM_AUTH_ERROR = "NPM_AUTH_ERROR",
150
- CARGO_PUBLISH_ERROR = "CARGO_PUBLISH_ERROR",
151
- CARGO_AUTH_ERROR = "CARGO_AUTH_ERROR",
152
- VERIFICATION_FAILED = "VERIFICATION_FAILED",
153
- GITHUB_RELEASE_ERROR = "GITHUB_RELEASE_ERROR",
154
- FILE_COPY_ERROR = "FILE_COPY_ERROR",
155
- CARGO_TOML_ERROR = "CARGO_TOML_ERROR",
156
- PIPELINE_STAGE_ERROR = "PIPELINE_STAGE_ERROR"
157
- }
158
- declare function createPublishError(code: PublishErrorCode, details?: string): PublishError;
159
-
160
- declare function runPipeline(input: VersionOutput, config: PublishConfig, options: PublishCliOptions): Promise<PublishOutput>;
161
-
162
- declare function parseInput(inputPath?: string): Promise<VersionOutput>;
163
-
164
- declare function detectNpmAuth(): 'oidc' | 'token' | null;
165
- declare function hasCargoAuth(): boolean;
166
-
167
- declare function updateCargoVersion(cargoPath: string, newVersion: string): void;
168
- declare function extractPathDeps(manifest: CargoManifest): string[];
169
-
170
- declare function isPrerelease(version: string): boolean;
171
- declare function getDistTag(version: string, defaultTag?: string): string;
172
-
173
- export { BasePublishError, type CargoConfig, type GitConfig, type GitHubReleaseConfig, type GitHubReleaseResult, type GitResult, type NpmConfig, type PackageManager, type PipelineContext, PipelineError, type PublishCliOptions, type PublishConfig, PublishError, PublishErrorCode, type PublishOutput, type PublishResult, type VerificationResult, type VerifyConfig, createPublishError, detectNpmAuth, detectPackageManager, extractPathDeps, getDefaultConfig, getDistTag, hasCargoAuth, isPrerelease, loadConfig, parseInput, runPipeline, updateCargoVersion };
1
+ export { getDefaultConfig, loadConfig } from './config.ts';
2
+ export { BasePublishError, PipelineError, PublishError, PublishErrorCode, createPublishError } from './errors/index.ts';
3
+ export { runPipeline } from './pipeline/index.ts';
4
+ export { parseInput } from './stages/input.ts';
5
+ export { CargoConfig, GitConfig, GitHubReleaseConfig, GitHubReleaseResult, GitResult, NpmConfig, PipelineContext, PublishCliOptions, PublishConfig, PublishOutput, PublishResult, VerificationResult, VerifyConfig } from './types.ts';
6
+ export { detectNpmAuth, hasCargoAuth } from './utils/auth.ts';
7
+ export { CargoManifest, extractPathDeps, parseCargoToml, updateCargoVersion } from './utils/cargo.ts';
8
+ export { PackageManager, detectPackageManager } from './utils/package-manager.ts';
9
+ export { getDistTag, isPrerelease } from './utils/semver.ts';
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  parseInput,
17
17
  runPipeline,
18
18
  updateCargoVersion
19
- } from "./chunk-GOBII36Q.js";
19
+ } from "./chunk-GIMIZS5B.js";
20
20
  export {
21
21
  BasePublishError,
22
22
  PipelineError,
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@releasekit/publish",
3
- "version": "0.3.0-next.4",
3
+ "version": "0.3.1",
4
4
  "description": "Publish packages to npm and crates.io with git tagging and GitHub releases",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
7
6
  "module": "./dist/index.js",
8
7
  "types": "./dist/index.d.ts",
9
8
  "exports": {
@@ -11,10 +10,12 @@
11
10
  "import": {
12
11
  "types": "./dist/index.d.ts",
13
12
  "default": "./dist/index.js"
14
- },
15
- "require": {
16
- "types": "./dist/index.d.cts",
17
- "default": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "./cli": {
16
+ "import": {
17
+ "types": "./dist/cli.d.ts",
18
+ "default": "./dist/cli.js"
18
19
  }
19
20
  }
20
21
  },
@@ -50,10 +51,8 @@
50
51
  "chalk": "^5.6.2",
51
52
  "commander": "^14.0.3",
52
53
  "semver": "^7.7.4",
53
- "smol-toml": "^1.6.0",
54
- "zod": "^4.3.6",
55
- "@releasekit/config": "0.1.0",
56
- "@releasekit/core": "0.1.0"
54
+ "smol-toml": "^1.6.1",
55
+ "zod": "^4.3.6"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@biomejs/biome": "^2.4.6",
@@ -62,14 +61,16 @@
62
61
  "@vitest/coverage-v8": "^4.1.0",
63
62
  "tsup": "^8.5.1",
64
63
  "typescript": "^5.9.3",
65
- "vitest": "^4.1.0"
64
+ "vitest": "^4.1.0",
65
+ "@releasekit/config": "0.0.0",
66
+ "@releasekit/core": "0.0.0"
66
67
  },
67
68
  "engines": {
68
69
  "node": ">=20"
69
70
  },
70
71
  "scripts": {
71
- "build": "tsup src/index.ts src/cli.ts --format esm,cjs --dts",
72
- "dev": "tsup src/index.ts src/cli.ts --format esm,cjs --watch --dts",
72
+ "build": "tsup",
73
+ "dev": "tsup --watch",
73
74
  "clean": "rm -rf dist coverage .turbo",
74
75
  "test": "vitest run",
75
76
  "test:unit": "vitest run --coverage",