@ucdjs/release-scripts 0.1.0-beta.6 → 0.1.0-beta.61
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 +100 -1
- package/dist/{eta-Boh7yPZi.mjs → eta-g9ausaEx.mjs} +12 -10
- package/dist/index.d.mts +66 -92
- package/dist/index.mjs +2675 -677
- package/package.json +23 -11
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
1
|
# @ucdjs/release-scripts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
|
|
6
|
+
Monorepo release automation for pnpm workspaces. Handles version calculation, dependency graph resolution, changelog generation, and GitHub integration.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @ucdjs/release-scripts
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { createReleaseScripts } from "@ucdjs/release-scripts";
|
|
18
|
+
|
|
19
|
+
const release = await createReleaseScripts({
|
|
20
|
+
repo: "owner/repo",
|
|
21
|
+
githubToken: process.env.GITHUB_TOKEN,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Prepare a release (calculate versions, update package.json files, create PR)
|
|
25
|
+
const result = await release.prepare();
|
|
26
|
+
|
|
27
|
+
// Verify a release branch matches expected state
|
|
28
|
+
await release.verify();
|
|
29
|
+
|
|
30
|
+
// Publish packages to npm
|
|
31
|
+
await release.publish();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Configuration
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const release = await createReleaseScripts({
|
|
38
|
+
repo: "owner/repo",
|
|
39
|
+
githubToken: "...",
|
|
40
|
+
workspaceRoot: process.cwd(),
|
|
41
|
+
dryRun: false,
|
|
42
|
+
safeguards: true,
|
|
43
|
+
globalCommitMode: "dependencies",
|
|
44
|
+
packages: {
|
|
45
|
+
include: ["@scope/pkg-a", "@scope/pkg-b"],
|
|
46
|
+
exclude: ["@scope/internal"],
|
|
47
|
+
excludePrivate: true,
|
|
48
|
+
},
|
|
49
|
+
branch: {
|
|
50
|
+
release: "release/next",
|
|
51
|
+
default: "main",
|
|
52
|
+
},
|
|
53
|
+
npm: {
|
|
54
|
+
provenance: true,
|
|
55
|
+
access: "public",
|
|
56
|
+
},
|
|
57
|
+
changelog: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
emojis: true,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Package Discovery
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// List all workspace packages
|
|
68
|
+
const packages = await release.packages.list();
|
|
69
|
+
|
|
70
|
+
// Get a specific package
|
|
71
|
+
const pkg = await release.packages.get("@scope/pkg-a");
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Workflows
|
|
75
|
+
|
|
76
|
+
#### `prepare()`
|
|
77
|
+
|
|
78
|
+
Calculates version bumps from conventional commits, updates `package.json` files, generates changelogs, and creates/updates a release pull request.
|
|
79
|
+
|
|
80
|
+
#### `verify()`
|
|
81
|
+
|
|
82
|
+
Validates that a release branch matches expected release artifacts. Compares expected vs actual versions and dependency ranges, then sets a GitHub commit status.
|
|
83
|
+
|
|
84
|
+
#### `publish()`
|
|
85
|
+
|
|
86
|
+
Publishes packages to npm in topological order with provenance support, creates git tags, and pushes them to the remote.
|
|
87
|
+
|
|
88
|
+
## CLI Flags
|
|
89
|
+
|
|
90
|
+
When used in a script, the following flags are supported:
|
|
91
|
+
|
|
92
|
+
- `--dry` / `-d` - Dry-run mode, no changes are made
|
|
93
|
+
- `--verbose` / `-v` - Enable verbose logging
|
|
94
|
+
|
|
95
|
+
## 📄 License
|
|
96
|
+
|
|
97
|
+
Published under [MIT License](./LICENSE).
|
|
98
|
+
|
|
99
|
+
[npm-version-src]: https://img.shields.io/npm/v/@ucdjs/release-scripts?style=flat&colorA=18181B&colorB=4169E1
|
|
100
|
+
[npm-version-href]: https://npmjs.com/package/@ucdjs/release-scripts
|
|
101
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@ucdjs/release-scripts?style=flat&colorA=18181B&colorB=4169E1
|
|
102
|
+
[npm-downloads-href]: https://npmjs.com/package/@ucdjs/release-scripts
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
1
|
import * as path from "node:path";
|
|
3
|
-
|
|
4
|
-
//#region node_modules/.pnpm/eta@4.
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
//#region node_modules/.pnpm/eta@4.5.1/node_modules/eta/dist/index.mjs
|
|
5
4
|
var EtaError = class extends Error {
|
|
6
5
|
constructor(message) {
|
|
7
6
|
super(message);
|
|
@@ -53,6 +52,7 @@ function RuntimeErr(originalError, str, lineNo, path$1) {
|
|
|
53
52
|
}).join("\n");
|
|
54
53
|
const err = new EtaRuntimeError((filename ? filename + ":" + lineNo + "\n" : "line " + lineNo + "\n") + context + "\n\n" + originalError.message);
|
|
55
54
|
err.name = originalError.name;
|
|
55
|
+
err.cause = originalError;
|
|
56
56
|
throw err;
|
|
57
57
|
}
|
|
58
58
|
function readFile(path$1) {
|
|
@@ -121,8 +121,8 @@ function compileToString(str, options) {
|
|
|
121
121
|
const compileBody$1 = this.compileBody;
|
|
122
122
|
const buffer = this.parse.call(this, str);
|
|
123
123
|
let res = `${config.functionHeader}
|
|
124
|
-
let include = (
|
|
125
|
-
let includeAsync = (
|
|
124
|
+
let include = (__eta_t, __eta_d) => this.render(__eta_t, {...${config.varName}, ...(__eta_d ?? {})}, options);
|
|
125
|
+
let includeAsync = (__eta_t, __eta_d) => this.renderAsync(__eta_t, {...${config.varName}, ...(__eta_d ?? {})}, options);
|
|
126
126
|
|
|
127
127
|
let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction${config.debug ? ", line: 1, templateStr: \"" + str.replace(/\\|"/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n") + "\"" : ""}};
|
|
128
128
|
|
|
@@ -131,6 +131,8 @@ function layout(path, data) {
|
|
|
131
131
|
__eta.layoutData = data;
|
|
132
132
|
}${config.debug ? "try {" : ""}${config.useWith ? "with(" + config.varName + "||{}){" : ""}
|
|
133
133
|
|
|
134
|
+
function ${config.outputFunctionName}(s){__eta.res+=s;}
|
|
135
|
+
|
|
134
136
|
${compileBody$1.call(this, buffer)}
|
|
135
137
|
if (__eta.layout) {
|
|
136
138
|
__eta.res = ${isAsync ? "await includeAsync" : "include"} (__eta.layout, {...${config.varName}, body: __eta.res, ...__eta.layoutData});
|
|
@@ -162,18 +164,18 @@ function compileBody(buff) {
|
|
|
162
164
|
let returnStr = "";
|
|
163
165
|
for (; i < buffLength; i++) {
|
|
164
166
|
const currentBlock = buff[i];
|
|
165
|
-
if (typeof currentBlock === "string") returnStr += "__eta.res+='" + currentBlock + "'
|
|
167
|
+
if (typeof currentBlock === "string") returnStr += "__eta.res+='" + currentBlock + "';\n";
|
|
166
168
|
else {
|
|
167
169
|
const type = currentBlock.t;
|
|
168
170
|
let content = currentBlock.val || "";
|
|
169
171
|
if (config.debug) returnStr += "__eta.line=" + currentBlock.lineNo + "\n";
|
|
170
172
|
if (type === "r") {
|
|
171
173
|
if (config.autoFilter) content = "__eta.f(" + content + ")";
|
|
172
|
-
returnStr += "__eta.res+=" + content + "
|
|
174
|
+
returnStr += "__eta.res+=" + content + ";\n";
|
|
173
175
|
} else if (type === "i") {
|
|
174
176
|
if (config.autoFilter) content = "__eta.f(" + content + ")";
|
|
175
177
|
if (config.autoEscape) content = "__eta.e(" + content + ")";
|
|
176
|
-
returnStr += "__eta.res+=" + content + "
|
|
178
|
+
returnStr += "__eta.res+=" + content + ";\n";
|
|
177
179
|
} else if (type === "e") returnStr += content + "\n";
|
|
178
180
|
}
|
|
179
181
|
}
|
|
@@ -233,6 +235,7 @@ const defaultConfig = {
|
|
|
233
235
|
debug: false,
|
|
234
236
|
escapeFunction: XMLEscape,
|
|
235
237
|
filterFunction: (val) => String(val),
|
|
238
|
+
outputFunctionName: "output",
|
|
236
239
|
functionHeader: "",
|
|
237
240
|
parse: {
|
|
238
241
|
exec: "",
|
|
@@ -472,6 +475,5 @@ var Eta = class extends Eta$1 {
|
|
|
472
475
|
readFile = readFile;
|
|
473
476
|
resolvePath = resolvePath;
|
|
474
477
|
};
|
|
475
|
-
|
|
476
478
|
//#endregion
|
|
477
|
-
export { Eta as t };
|
|
479
|
+
export { Eta as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/options.d.ts
|
|
2
|
+
interface FindWorkspacePackagesOptions {
|
|
3
|
+
exclude?: string[];
|
|
4
|
+
include?: string[];
|
|
5
|
+
excludePrivate?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ReleaseScriptsOptionsInput {
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
repo: `${string}/${string}`;
|
|
10
|
+
workspaceRoot?: string;
|
|
11
|
+
packages?: true | FindWorkspacePackagesOptions | string[];
|
|
12
|
+
githubToken: string;
|
|
13
|
+
safeguards?: boolean;
|
|
14
|
+
branch?: {
|
|
15
|
+
release?: string;
|
|
16
|
+
default?: string;
|
|
17
|
+
};
|
|
18
|
+
globalCommitMode?: "dependencies" | "all" | "none";
|
|
19
|
+
pullRequest?: {
|
|
20
|
+
title?: string;
|
|
21
|
+
body?: string;
|
|
22
|
+
};
|
|
23
|
+
types?: Record<string, CommitTypeRule>;
|
|
24
|
+
changelog?: {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
template?: string;
|
|
27
|
+
emojis?: boolean;
|
|
28
|
+
combinePrereleaseIntoFirstStable?: boolean;
|
|
29
|
+
};
|
|
30
|
+
npm?: {
|
|
31
|
+
otp?: string;
|
|
32
|
+
provenance?: boolean;
|
|
33
|
+
access?: "public" | "restricted";
|
|
34
|
+
};
|
|
35
|
+
prompts?: {
|
|
36
|
+
versions?: boolean;
|
|
37
|
+
packages?: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/workspace.d.ts
|
|
2
42
|
interface WorkspacePackage {
|
|
3
43
|
name: string;
|
|
4
44
|
version: string;
|
|
@@ -8,46 +48,17 @@ interface WorkspacePackage {
|
|
|
8
48
|
workspaceDevDependencies: string[];
|
|
9
49
|
}
|
|
10
50
|
//#endregion
|
|
11
|
-
//#region src/types.d.ts
|
|
51
|
+
//#region src/shared/types.d.ts
|
|
12
52
|
type BumpKind = "none" | "patch" | "minor" | "major";
|
|
13
|
-
interface
|
|
14
|
-
/**
|
|
15
|
-
* Repository identifier (e.g., "owner/repo")
|
|
16
|
-
*/
|
|
17
|
-
repo: string;
|
|
53
|
+
interface CommitTypeRule {
|
|
18
54
|
/**
|
|
19
|
-
*
|
|
55
|
+
* Display title (e.g., "Features", "Bug Fixes")
|
|
20
56
|
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Specific packages to prepare for release.
|
|
24
|
-
* - true: discover all packages
|
|
25
|
-
* - FindWorkspacePackagesOptions: discover with filters
|
|
26
|
-
* - string[]: specific package names
|
|
27
|
-
*/
|
|
28
|
-
packages?: true | FindWorkspacePackagesOptions | string[];
|
|
29
|
-
/**
|
|
30
|
-
* Whether to enable verbose logging
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
verbose?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* GitHub token for authentication
|
|
36
|
-
*/
|
|
37
|
-
githubToken: string;
|
|
57
|
+
title: string;
|
|
38
58
|
/**
|
|
39
|
-
*
|
|
59
|
+
* Commit types to include in this group (defaults to the map key)
|
|
40
60
|
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Enable package selection prompt (defaults to true when not in CI)
|
|
44
|
-
*/
|
|
45
|
-
packages?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Enable version override prompt (defaults to true when not in CI)
|
|
48
|
-
*/
|
|
49
|
-
versions?: boolean;
|
|
50
|
-
};
|
|
61
|
+
types?: string[];
|
|
51
62
|
}
|
|
52
63
|
interface PackageJson {
|
|
53
64
|
name: string;
|
|
@@ -58,21 +69,7 @@ interface PackageJson {
|
|
|
58
69
|
private?: boolean;
|
|
59
70
|
[key: string]: unknown;
|
|
60
71
|
}
|
|
61
|
-
interface
|
|
62
|
-
/**
|
|
63
|
-
* Package names to exclude
|
|
64
|
-
*/
|
|
65
|
-
exclude?: string[];
|
|
66
|
-
/**
|
|
67
|
-
* Only include these packages (if specified, all others are excluded)
|
|
68
|
-
*/
|
|
69
|
-
include?: string[];
|
|
70
|
-
/**
|
|
71
|
-
* Whether to exclude private packages (default: false)
|
|
72
|
-
*/
|
|
73
|
-
excludePrivate?: boolean;
|
|
74
|
-
}
|
|
75
|
-
interface VersionUpdate {
|
|
72
|
+
interface PackageRelease {
|
|
76
73
|
/**
|
|
77
74
|
* The package being updated
|
|
78
75
|
*/
|
|
@@ -93,52 +90,18 @@ interface VersionUpdate {
|
|
|
93
90
|
* Whether this package has direct changes (vs being updated due to dependency changes)
|
|
94
91
|
*/
|
|
95
92
|
hasDirectChanges: boolean;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/publish.d.ts
|
|
99
|
-
interface PublishOptions extends SharedOptions {}
|
|
100
|
-
declare function publish(_options: PublishOptions): void;
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/release.d.ts
|
|
103
|
-
interface ReleaseOptions extends SharedOptions {
|
|
104
93
|
/**
|
|
105
|
-
*
|
|
94
|
+
* Why/how this release entry exists.
|
|
106
95
|
*/
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Whether to perform a dry run (no changes pushed or PR created)
|
|
110
|
-
* @default false
|
|
111
|
-
*/
|
|
112
|
-
dryRun?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Whether to enable safety safeguards (e.g., checking for clean working directory)
|
|
115
|
-
* @default true
|
|
116
|
-
*/
|
|
117
|
-
safeguards?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Pull request configuration
|
|
120
|
-
*/
|
|
121
|
-
pullRequest?: {
|
|
122
|
-
/**
|
|
123
|
-
* Title for the release pull request
|
|
124
|
-
*/
|
|
125
|
-
title?: string;
|
|
126
|
-
/**
|
|
127
|
-
* Body for the release pull request
|
|
128
|
-
*
|
|
129
|
-
* If not provided, a default body will be generated.
|
|
130
|
-
*
|
|
131
|
-
* NOTE:
|
|
132
|
-
* You can use custom template expressions, see [h3js/rendu](https://github.com/h3js/rendu)
|
|
133
|
-
*/
|
|
134
|
-
body?: string;
|
|
135
|
-
};
|
|
96
|
+
changeKind: "auto" | "manual" | "as-is" | "dependent";
|
|
136
97
|
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/types.d.ts
|
|
137
100
|
interface ReleaseResult {
|
|
138
101
|
/**
|
|
139
102
|
* Packages that will be updated
|
|
140
103
|
*/
|
|
141
|
-
updates:
|
|
104
|
+
updates: PackageRelease[];
|
|
142
105
|
/**
|
|
143
106
|
* URL of the created or updated PR
|
|
144
107
|
*/
|
|
@@ -148,6 +111,17 @@ interface ReleaseResult {
|
|
|
148
111
|
*/
|
|
149
112
|
created: boolean;
|
|
150
113
|
}
|
|
151
|
-
declare function release(options: ReleaseOptions): Promise<ReleaseResult | null>;
|
|
152
114
|
//#endregion
|
|
153
|
-
|
|
115
|
+
//#region src/index.d.ts
|
|
116
|
+
interface ReleaseScripts {
|
|
117
|
+
verify: () => Promise<void>;
|
|
118
|
+
prepare: () => Promise<ReleaseResult | null>;
|
|
119
|
+
publish: () => Promise<void>;
|
|
120
|
+
packages: {
|
|
121
|
+
list: () => Promise<WorkspacePackage[]>;
|
|
122
|
+
get: (packageName: string) => Promise<WorkspacePackage | undefined>;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
declare function createReleaseScripts(options: ReleaseScriptsOptionsInput): Promise<ReleaseScripts>;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { ReleaseScripts, createReleaseScripts };
|