@yorozu/build 0.1.0
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 +38 -0
- package/chunks/21EFCjEU.js +19160 -0
- package/chunks/CMapqBQB.js +2620 -0
- package/chunks/CYSd7-PF.js +623 -0
- package/chunks/Cr5v7tI0.js +1824 -0
- package/ci/github-actions.d.ts +3 -0
- package/ci/index.d.ts +1 -0
- package/cli/commands/_utils.d.ts +8 -0
- package/cli/commands/build.d.ts +40 -0
- package/cli/commands/bump-version.d.ts +27 -0
- package/cli/commands/cr.d.ts +27 -0
- package/cli/commands/docs.d.ts +9 -0
- package/cli/commands/find-changed-packages.d.ts +10 -0
- package/cli/commands/gen-changelog.d.ts +10 -0
- package/cli/commands/gen-deps-graph.d.ts +15 -0
- package/cli/commands/jsr.d.ts +6 -0
- package/cli/commands/lint/config.d.ts +1 -0
- package/cli/commands/lint/index.d.ts +11 -0
- package/cli/commands/lint/validate-workspace-deps.d.ts +23 -0
- package/cli/commands/publish.d.ts +62 -0
- package/cli/commands/release.d.ts +45 -0
- package/cli/index.d.ts +8 -0
- package/cli/log.d.ts +3 -0
- package/cli/main.d.ts +2 -0
- package/config.d.ts +57 -0
- package/git/github.d.ts +15 -0
- package/git/index.d.ts +2 -0
- package/git/utils.d.ts +38 -0
- package/index.d.ts +8 -0
- package/index.js +26 -0
- package/jsr/_deno-directives.d.ts +1 -0
- package/jsr/config.d.ts +1 -0
- package/jsr/create-packages.d.ts +8 -0
- package/jsr/deno-json.d.ts +19 -0
- package/jsr/generate-workspace.d.ts +9 -0
- package/jsr/index.d.ts +6 -0
- package/jsr/populate.d.ts +10 -0
- package/jsr/utils/external-libs.d.ts +8 -0
- package/jsr/utils/index.d.ts +4 -0
- package/jsr/utils/jsr-api.d.ts +23 -0
- package/jsr/utils/jsr-json.d.ts +10 -0
- package/jsr/utils/jsr.d.ts +10 -0
- package/jsr.d.ts +1 -0
- package/jsr.js +2 -0
- package/misc/_config.d.ts +2 -0
- package/misc/exec.d.ts +15 -0
- package/misc/fs.d.ts +4 -0
- package/misc/index.d.ts +6 -0
- package/misc/path.d.ts +1 -0
- package/misc/publish-order.d.ts +3 -0
- package/misc/tsconfig.d.ts +2 -0
- package/npm/index.d.ts +1 -0
- package/npm/npm-api.d.ts +6 -0
- package/package-json/collect-package-jsons.d.ts +9 -0
- package/package-json/find-package-json.d.ts +1 -0
- package/package-json/index.d.ts +6 -0
- package/package-json/parse.d.ts +11 -0
- package/package-json/process-package-json.d.ts +20 -0
- package/package-json/types.d.ts +39 -0
- package/package-json/utils.d.ts +4 -0
- package/package.json +59 -0
- package/versioning/bump-version.d.ts +31 -0
- package/versioning/collect-files.d.ts +21 -0
- package/versioning/generate-changelog.d.ts +8 -0
- package/versioning/index.d.ts +4 -0
- package/versioning/types.d.ts +21 -0
- package/vite/build-plugin.d.ts +73 -0
- package/vite/config.d.ts +47 -0
- package/vite/index.d.ts +2 -0
- package/vite.d.ts +1 -0
- package/vite.js +184 -0
- package/yorozu-build.d.ts +1 -0
- package/yorozu-build.js +527 -0
package/yorozu-build.js
ADDED
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { asNonNull, collectPackageJsons, error, filterPackageJsonsForPublish, findRootPackage, getWorkspaceRoot, info, parallelMap, warn } from "./chunks/21EFCjEU.js";
|
|
3
|
+
import { boolean, buildPackageCli, bumpVersion, command, createGithubRelease, findProjectChangedPackages, generateChangelog, generateDepsGraphCli, generateDocsCli, getCommitsBetween, getLatestTag, gitTagExists, isRunningInGithubActions, loadConfig, publishPackages, publishPackagesCli, resolveWorkspaceRoot, run, runContinuousReleaseCli, string, validateWorkspaceDeps, writeGithubActionsOutput } from "./chunks/CMapqBQB.js";
|
|
4
|
+
import { ExecError, exec, sortWorkspaceByPublishOrder } from "./chunks/Cr5v7tI0.js";
|
|
5
|
+
import { generateDenoWorkspace, jsrCreatePackages, populateFromUpstream } from "./chunks/CYSd7-PF.js";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { basename } from "node:path";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
//#region src/cli/commands/lint/index.ts
|
|
10
|
+
var INTERNAL_MESSAGES = {
|
|
11
|
+
not_workspace_proto: "internal dependencies must be linked with workspace: protocol",
|
|
12
|
+
not_workspace_dep: "workspace: protocol is used to link to a package not found in the workspace"
|
|
13
|
+
};
|
|
14
|
+
var lintCli = command({
|
|
15
|
+
name: "lint",
|
|
16
|
+
desc: "check the workspace for any issues",
|
|
17
|
+
options: {
|
|
18
|
+
workspace: string().desc("path to the workspace root (default: cwd)"),
|
|
19
|
+
noErrorCode: boolean("no-error-code").desc("whether to always exit with a zero code").default(false)
|
|
20
|
+
},
|
|
21
|
+
handler: async (args) => {
|
|
22
|
+
let workspaceRoot = resolveWorkspaceRoot(args.workspace);
|
|
23
|
+
let config = (await loadConfig({ workspaceRoot }))?.lint;
|
|
24
|
+
let errors = await validateWorkspaceDeps({
|
|
25
|
+
workspaceRoot,
|
|
26
|
+
config
|
|
27
|
+
});
|
|
28
|
+
if (errors.length === 0) {
|
|
29
|
+
info("workspace dependencies look good");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let externalErrors = errors.filter((item) => item.type === "external");
|
|
33
|
+
let internalErrors = errors.filter((item) => item.type === "internal");
|
|
34
|
+
if (externalErrors.length > 0) {
|
|
35
|
+
warn("Found external dependencies mismatch:");
|
|
36
|
+
for (let item of externalErrors) warn(` - at ${item.package}: ${item.at} has ${item.dependency}@${item.version}, but ${item.otherPackage} has @${item.otherVersion}`);
|
|
37
|
+
}
|
|
38
|
+
if (internalErrors.length > 0) {
|
|
39
|
+
warn("Found issues with internal dependencies:");
|
|
40
|
+
for (let item of internalErrors) warn(` - at ${item.package}, dependency ${item.dependency}: ${INTERNAL_MESSAGES[item.subtype]}`);
|
|
41
|
+
}
|
|
42
|
+
if (!args.noErrorCode) process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/cli/commands/bump-version.ts
|
|
47
|
+
function sharedWorkspaceBumpOptions(params) {
|
|
48
|
+
return {
|
|
49
|
+
type: params.type === "auto" ? void 0 : params.type,
|
|
50
|
+
withRoot: true,
|
|
51
|
+
all: true,
|
|
52
|
+
dryRun: params.dryRun
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function formatBumpVersionResult(result, withReleaseType) {
|
|
56
|
+
let lines = [];
|
|
57
|
+
if (withReleaseType) {
|
|
58
|
+
lines.push(`detected release type: ${result.releaseType}`);
|
|
59
|
+
lines.push(` has breaking changes: ${result.hasBreakingChanges}`);
|
|
60
|
+
lines.push(` has new features: ${result.hasFeatures}`);
|
|
61
|
+
lines.push("");
|
|
62
|
+
}
|
|
63
|
+
lines.push("list of changed packages:");
|
|
64
|
+
for (let { package: pkg, prevVersion } of result.changedPackages) {
|
|
65
|
+
let versionStr = prevVersion;
|
|
66
|
+
if (!pkg.json.yorozu?.ownVersioning) versionStr += ` → ${pkg.json.version}`;
|
|
67
|
+
lines.push(` ${pkg.json.name}: ${versionStr}`);
|
|
68
|
+
}
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
var bumpVersionCli = command({
|
|
72
|
+
name: "bump-version",
|
|
73
|
+
desc: "bump the shared workspace version",
|
|
74
|
+
options: {
|
|
75
|
+
root: string().desc("path to the root of the workspace (default: process.cwd())"),
|
|
76
|
+
type: string().desc("override type of release (major, minor, patch) (default: auto-detect)").enum("major", "minor", "patch", "auto").default("auto"),
|
|
77
|
+
since: string().desc("starting point for the changelog (default: latest tag)"),
|
|
78
|
+
dryRun: boolean("dry-run").desc("whether to only print the detected changes without actually modifying anything"),
|
|
79
|
+
quiet: boolean().desc("whether to only print the new version number").alias("q")
|
|
80
|
+
},
|
|
81
|
+
handler: async (args) => {
|
|
82
|
+
let root = resolveWorkspaceRoot(args.root);
|
|
83
|
+
let releaseType = args.type === "auto" ? void 0 : args.type;
|
|
84
|
+
let workspace = await collectPackageJsons(root, true);
|
|
85
|
+
let config = await loadConfig({
|
|
86
|
+
workspaceRoot: root,
|
|
87
|
+
require: false
|
|
88
|
+
});
|
|
89
|
+
let since = args.since ?? await getLatestTag(root);
|
|
90
|
+
if (since == null) throw new Error("no previous tag found, cannot determine changeset");
|
|
91
|
+
let result = await bumpVersion({
|
|
92
|
+
workspace,
|
|
93
|
+
cwd: root,
|
|
94
|
+
since,
|
|
95
|
+
params: config?.versioning,
|
|
96
|
+
...sharedWorkspaceBumpOptions({
|
|
97
|
+
type: args.type,
|
|
98
|
+
dryRun: args.dryRun
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
if (args.quiet) info(JSON.stringify(result.nextVersions));
|
|
102
|
+
else info(formatBumpVersionResult(result, releaseType == null));
|
|
103
|
+
if (isRunningInGithubActions()) {
|
|
104
|
+
writeGithubActionsOutput("versions", JSON.stringify(result.nextVersions));
|
|
105
|
+
writeGithubActionsOutput("hasBreakingChanges", String(result.hasBreakingChanges));
|
|
106
|
+
writeGithubActionsOutput("hasFeatures", String(result.hasFeatures));
|
|
107
|
+
writeGithubActionsOutput("changedPackages", result.changedPackages.map((item) => item.package.json.name).join(","));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/cli/commands/gen-changelog.ts
|
|
113
|
+
var generateChangelogCli = command({
|
|
114
|
+
name: "gen-changelog",
|
|
115
|
+
desc: "generate a changelog for the workspace",
|
|
116
|
+
options: {
|
|
117
|
+
only: string().desc("comma-separated list of packages to include"),
|
|
118
|
+
root: string().desc("path to the root of the workspace (default: process.cwd())"),
|
|
119
|
+
since: string().desc("starting point for the changelog (default: latest tag)")
|
|
120
|
+
},
|
|
121
|
+
handler: async (args) => {
|
|
122
|
+
let root = resolveWorkspaceRoot(args.root);
|
|
123
|
+
let config = await loadConfig({
|
|
124
|
+
workspaceRoot: root,
|
|
125
|
+
require: false
|
|
126
|
+
});
|
|
127
|
+
let workspacePackages = await collectPackageJsons(root, false);
|
|
128
|
+
if (args.only !== void 0) {
|
|
129
|
+
let only = new Set(args.only.split(",").map((item) => item.trim()));
|
|
130
|
+
workspacePackages = workspacePackages.filter((pkg) => pkg.json.name != null && only.has(pkg.json.name));
|
|
131
|
+
}
|
|
132
|
+
let since = args.since ?? await getLatestTag(root);
|
|
133
|
+
if (since == null) throw new Error("no previous tag found, cannot determine changeset");
|
|
134
|
+
let changelog = await generateChangelog({
|
|
135
|
+
workspace: workspacePackages,
|
|
136
|
+
cwd: root,
|
|
137
|
+
since,
|
|
138
|
+
params: config?.versioning
|
|
139
|
+
});
|
|
140
|
+
if (isRunningInGithubActions()) {
|
|
141
|
+
writeGithubActionsOutput("changelog", changelog);
|
|
142
|
+
info("Written changelog to `changelog` output");
|
|
143
|
+
} else info(changelog);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/cli/commands/find-changed-packages.ts
|
|
148
|
+
var findChangedPackagesCli = command({
|
|
149
|
+
name: "find-changed-packages",
|
|
150
|
+
desc: "find changed packages between two commits, and output a comma-separated list of package names",
|
|
151
|
+
options: {
|
|
152
|
+
root: string().desc("path to the root of the workspace (default: process.cwd())"),
|
|
153
|
+
since: string().desc("starting point for the changelog (default: latest tag)"),
|
|
154
|
+
until: string().desc("ending point for the changelog (default: HEAD)")
|
|
155
|
+
},
|
|
156
|
+
handler: async (args) => {
|
|
157
|
+
let root = resolveWorkspaceRoot(args.root);
|
|
158
|
+
let config = await loadConfig({
|
|
159
|
+
workspaceRoot: root,
|
|
160
|
+
require: false
|
|
161
|
+
});
|
|
162
|
+
let since = args.since ?? await getLatestTag(root);
|
|
163
|
+
if (since == null) throw new Error("no previous tag found, cannot determine changeset");
|
|
164
|
+
let result = (await findProjectChangedPackages({
|
|
165
|
+
params: config?.versioning,
|
|
166
|
+
root,
|
|
167
|
+
since,
|
|
168
|
+
until: args.until
|
|
169
|
+
})).map((pkg) => pkg.json.name).join(",");
|
|
170
|
+
if (isRunningInGithubActions()) {
|
|
171
|
+
writeGithubActionsOutput("packages", result);
|
|
172
|
+
info("Written packages to `packages` output");
|
|
173
|
+
} else info(result);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/cli/commands/release.ts
|
|
178
|
+
function npmPublishList(workspace) {
|
|
179
|
+
return filterPackageJsonsForPublish(sortWorkspaceByPublishOrder(workspace.filter((pkg) => !pkg.root)), "npm");
|
|
180
|
+
}
|
|
181
|
+
function printPublishList(packages) {
|
|
182
|
+
info("publish list:");
|
|
183
|
+
if (packages.length === 0) {
|
|
184
|
+
info(" (none)");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
for (let pkg of packages) info(` ${pkg.json.name}@${pkg.json.version}`);
|
|
188
|
+
}
|
|
189
|
+
function shouldSkipAutoRelease(params) {
|
|
190
|
+
return params.kind === "auto" && params.prevTag != null && params.commitsSincePrevTag.length === 0;
|
|
191
|
+
}
|
|
192
|
+
async function nextDateTag(root) {
|
|
193
|
+
let date = /* @__PURE__ */ new Date();
|
|
194
|
+
let tagNamePrefix = `v${date.getFullYear()}.${(date.getMonth() + 1).toString().padStart(2, "0")}.${date.getDate().toString().padStart(2, "0")}`;
|
|
195
|
+
let currentSuffix = "a";
|
|
196
|
+
let tagName = `${tagNamePrefix}${currentSuffix}`;
|
|
197
|
+
while (await gitTagExists(tagName, root)) {
|
|
198
|
+
if (currentSuffix === "z") throw new Error("Too many releases for today (max 26)");
|
|
199
|
+
currentSuffix = String.fromCharCode(currentSuffix.charCodeAt(0) + 1);
|
|
200
|
+
tagName = `${tagNamePrefix}${currentSuffix}`;
|
|
201
|
+
}
|
|
202
|
+
return tagName;
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/cli/main.ts
|
|
206
|
+
await run([
|
|
207
|
+
lintCli,
|
|
208
|
+
buildPackageCli,
|
|
209
|
+
publishPackagesCli,
|
|
210
|
+
bumpVersionCli,
|
|
211
|
+
generateChangelogCli,
|
|
212
|
+
findChangedPackagesCli,
|
|
213
|
+
command({
|
|
214
|
+
name: "release",
|
|
215
|
+
desc: "release packages",
|
|
216
|
+
options: {
|
|
217
|
+
kind: string("kind").desc("release kind").enum("major", "minor", "patch", "auto").default("auto"),
|
|
218
|
+
withGithubRelease: boolean("with-github-release").desc("whether to create a github release (requires GITHUB_TOKEN env var). if false, will only create a commit with the release notes").default(false),
|
|
219
|
+
gitExtraOrigins: string("git-extra-origins").desc("extra git origins to push to (e.g. for mirrors). note that these origins will be force-pushed to"),
|
|
220
|
+
githubToken: string("github-token").desc("github token to use for creating a release (defaults to GITHUB_TOKEN env var)"),
|
|
221
|
+
githubRepo: string("github-repo").desc("github repo to create a release for (defaults to GITHUB_REPOSITORY env var)"),
|
|
222
|
+
githubApiUrl: string("github-api-url").desc("github api url to use for creating a release (for github-compatible apis)"),
|
|
223
|
+
withJsr: boolean("with-jsr").desc("whether to publish to jsr").default(false),
|
|
224
|
+
jsrRegistry: string("jsr-registry").desc("URL of the jsr registry to publish to"),
|
|
225
|
+
jsrToken: string("jsr-token").desc("jsr token to use for publishing"),
|
|
226
|
+
jsrPublishArgs: string("jsr-publish-args").desc("additional arguments to pass to `deno publish`"),
|
|
227
|
+
jsrCreatePackages: boolean("jsr-create-packages").desc("whether to create missing packages in jsr"),
|
|
228
|
+
withNpm: boolean("with-npm").desc("whether to publish to npm"),
|
|
229
|
+
npmToken: string("npm-token").desc("npm token to use for publishing (passed via env and a temporary local .npmrc)"),
|
|
230
|
+
npmPublishArgs: string("npm-publish-args").desc("additional arguments to pass to `npm publish`"),
|
|
231
|
+
npmDistDir: string("npm-dist-dir").desc("directory to publish to npm from, relative to package root (default: dist)"),
|
|
232
|
+
npmRegistry: string("npm-registry").desc("URL of the npm registry to publish to"),
|
|
233
|
+
noProvenance: boolean("no-provenance").desc("version to NOT use provenance even when it should be possible"),
|
|
234
|
+
dryRun: boolean("dry-run").desc("whether to skip publishing and only print what is going to happen")
|
|
235
|
+
},
|
|
236
|
+
handler: async (args) => {
|
|
237
|
+
let root = getWorkspaceRoot();
|
|
238
|
+
let config = await loadConfig({
|
|
239
|
+
workspaceRoot: root,
|
|
240
|
+
require: false
|
|
241
|
+
});
|
|
242
|
+
let workspaceWithRoot = await collectPackageJsons(root, true);
|
|
243
|
+
let rootPackage = findRootPackage(workspaceWithRoot);
|
|
244
|
+
let prevTag = await getLatestTag(root);
|
|
245
|
+
if (prevTag == null) info("no previous tag found, assuming this is a first ever release");
|
|
246
|
+
else info(`previous tag: ${prevTag}`);
|
|
247
|
+
let bumpVersionResult;
|
|
248
|
+
let nextVersion;
|
|
249
|
+
let changelog;
|
|
250
|
+
if (prevTag == null) {
|
|
251
|
+
nextVersion = asNonNull(rootPackage.json.version);
|
|
252
|
+
changelog = "Initial release";
|
|
253
|
+
} else {
|
|
254
|
+
let commitsSincePrevTag = await getCommitsBetween({
|
|
255
|
+
since: prevTag,
|
|
256
|
+
cwd: root
|
|
257
|
+
});
|
|
258
|
+
if (shouldSkipAutoRelease({
|
|
259
|
+
kind: args.kind,
|
|
260
|
+
prevTag,
|
|
261
|
+
commitsSincePrevTag
|
|
262
|
+
})) {
|
|
263
|
+
info(`no commits since ${prevTag}, nothing to do`);
|
|
264
|
+
process.exit(0);
|
|
265
|
+
}
|
|
266
|
+
bumpVersionResult = await bumpVersion({
|
|
267
|
+
workspace: workspaceWithRoot,
|
|
268
|
+
since: prevTag,
|
|
269
|
+
type: args.kind === "auto" ? void 0 : args.kind,
|
|
270
|
+
all: true,
|
|
271
|
+
cwd: root,
|
|
272
|
+
params: config?.versioning,
|
|
273
|
+
dryRun: args.dryRun,
|
|
274
|
+
withRoot: true
|
|
275
|
+
});
|
|
276
|
+
info(formatBumpVersionResult(bumpVersionResult, args.kind === "auto"));
|
|
277
|
+
nextVersion = bumpVersionResult.nextVersion;
|
|
278
|
+
changelog = await generateChangelog({
|
|
279
|
+
workspace: bumpVersionResult.changedPackages.map((pkg) => pkg.package),
|
|
280
|
+
cwd: root,
|
|
281
|
+
since: prevTag,
|
|
282
|
+
params: config?.versioning
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
let taggingSchema = config?.versioning?.taggingSchema ?? "semver";
|
|
286
|
+
let tagName;
|
|
287
|
+
if (prevTag == null || taggingSchema === "semver") {
|
|
288
|
+
tagName = `v${nextVersion}`;
|
|
289
|
+
if (await gitTagExists(tagName, root)) throw new Error(`tag ${tagName} already exists. did the previous release complete successfully? if so, please verify versions in package.json and try again`);
|
|
290
|
+
} else if (taggingSchema === "date") tagName = await nextDateTag(root);
|
|
291
|
+
else throw new Error(`Unknown tagging schema: ${String(taggingSchema)}`);
|
|
292
|
+
info(`next version: ${nextVersion}`);
|
|
293
|
+
info(`next tag: ${tagName}`);
|
|
294
|
+
info("--begin changelog--");
|
|
295
|
+
info(changelog);
|
|
296
|
+
info("--end changelog--");
|
|
297
|
+
printPublishList(npmPublishList(workspaceWithRoot));
|
|
298
|
+
if (isRunningInGithubActions()) {
|
|
299
|
+
writeGithubActionsOutput("version", nextVersion);
|
|
300
|
+
writeGithubActionsOutput("tag", tagName);
|
|
301
|
+
writeGithubActionsOutput("changelog", changelog);
|
|
302
|
+
}
|
|
303
|
+
let tarballs = [];
|
|
304
|
+
if (args.withNpm) if (args.dryRun) info("dry run, skipping npm publish");
|
|
305
|
+
else {
|
|
306
|
+
info("publishing to npm...");
|
|
307
|
+
let publishResult = await publishPackages({
|
|
308
|
+
packages: [":all"],
|
|
309
|
+
workspace: workspaceWithRoot,
|
|
310
|
+
workspaceRoot: root,
|
|
311
|
+
registryUrl: args.npmRegistry,
|
|
312
|
+
token: args.npmToken ?? process.env.NPM_TOKEN,
|
|
313
|
+
distDir: args.npmDistDir,
|
|
314
|
+
publishArgs: args.npmPublishArgs?.split(" "),
|
|
315
|
+
dryRun: args.dryRun,
|
|
316
|
+
withBuild: true,
|
|
317
|
+
withTarballs: args.withGithubRelease,
|
|
318
|
+
noProvenance: args.noProvenance
|
|
319
|
+
});
|
|
320
|
+
if (publishResult.failed.length > 0) {
|
|
321
|
+
info("failed to publish:");
|
|
322
|
+
for (let pkg of publishResult.failed) info(` ${pkg}`);
|
|
323
|
+
process.exit(1);
|
|
324
|
+
}
|
|
325
|
+
info("published to npm");
|
|
326
|
+
tarballs = publishResult.tarballs;
|
|
327
|
+
}
|
|
328
|
+
else if (args.withGithubRelease) throw new Error("Cannot create a github release without publishing to npm (yet)");
|
|
329
|
+
if (args.withJsr) if (args.dryRun) info("dry run, skipping jsr publish");
|
|
330
|
+
else {
|
|
331
|
+
if (args.jsrCreatePackages) {
|
|
332
|
+
info("creating missing packages in jsr...");
|
|
333
|
+
if (await jsrCreatePackages({
|
|
334
|
+
workspaceRoot: root,
|
|
335
|
+
workspacePackages: workspaceWithRoot,
|
|
336
|
+
registry: args.jsrRegistry,
|
|
337
|
+
token: args.jsrToken,
|
|
338
|
+
githubRepo: args.githubRepo
|
|
339
|
+
})) info("some packages are missing, this might cause issues");
|
|
340
|
+
}
|
|
341
|
+
info("generating deno workspace...");
|
|
342
|
+
let workspaceDir = await generateDenoWorkspace({
|
|
343
|
+
workspaceRoot: root,
|
|
344
|
+
workspacePackages: workspaceWithRoot,
|
|
345
|
+
rootConfig: config?.jsr
|
|
346
|
+
});
|
|
347
|
+
info("publishing to jsr...");
|
|
348
|
+
await exec([
|
|
349
|
+
"deno",
|
|
350
|
+
"publish",
|
|
351
|
+
"--quiet",
|
|
352
|
+
"--allow-dirty",
|
|
353
|
+
...args.jsrToken != null ? ["--token", args.jsrToken] : [],
|
|
354
|
+
...args.jsrPublishArgs?.split(" ") ?? []
|
|
355
|
+
], {
|
|
356
|
+
env: {
|
|
357
|
+
...process.env,
|
|
358
|
+
JSR_URL: args.jsrRegistry
|
|
359
|
+
},
|
|
360
|
+
cwd: workspaceDir,
|
|
361
|
+
stdio: "inherit",
|
|
362
|
+
throwOnError: true
|
|
363
|
+
});
|
|
364
|
+
info("published to jsr");
|
|
365
|
+
}
|
|
366
|
+
if (args.dryRun) info("dry run, skipping release commit and tag");
|
|
367
|
+
else {
|
|
368
|
+
await config?.versioning?.beforeReleaseCommit?.(workspaceWithRoot);
|
|
369
|
+
let message = `chore(release): ${tagName}`;
|
|
370
|
+
if (!args.withGithubRelease) message += `\n\n${changelog}`;
|
|
371
|
+
await exec([
|
|
372
|
+
"git",
|
|
373
|
+
"commit",
|
|
374
|
+
"-am",
|
|
375
|
+
message,
|
|
376
|
+
"--allow-empty"
|
|
377
|
+
], {
|
|
378
|
+
cwd: root,
|
|
379
|
+
stdio: "inherit",
|
|
380
|
+
throwOnError: true
|
|
381
|
+
});
|
|
382
|
+
await exec([
|
|
383
|
+
"git",
|
|
384
|
+
"tag",
|
|
385
|
+
tagName,
|
|
386
|
+
"-m",
|
|
387
|
+
tagName
|
|
388
|
+
], {
|
|
389
|
+
cwd: root,
|
|
390
|
+
stdio: "inherit",
|
|
391
|
+
throwOnError: true
|
|
392
|
+
});
|
|
393
|
+
await exec([
|
|
394
|
+
"git",
|
|
395
|
+
"push",
|
|
396
|
+
"--follow-tags"
|
|
397
|
+
], {
|
|
398
|
+
cwd: root,
|
|
399
|
+
stdio: "inherit",
|
|
400
|
+
throwOnError: true
|
|
401
|
+
});
|
|
402
|
+
if (args.gitExtraOrigins != null) for (let origin of args.gitExtraOrigins.split(",")) {
|
|
403
|
+
await exec([
|
|
404
|
+
"git",
|
|
405
|
+
"push",
|
|
406
|
+
origin,
|
|
407
|
+
"--force"
|
|
408
|
+
], {
|
|
409
|
+
cwd: root,
|
|
410
|
+
stdio: "inherit",
|
|
411
|
+
throwOnError: true
|
|
412
|
+
});
|
|
413
|
+
try {
|
|
414
|
+
await exec([
|
|
415
|
+
"git",
|
|
416
|
+
"push",
|
|
417
|
+
origin,
|
|
418
|
+
"--force",
|
|
419
|
+
"--tags"
|
|
420
|
+
], {
|
|
421
|
+
cwd: root,
|
|
422
|
+
throwOnError: true
|
|
423
|
+
});
|
|
424
|
+
} catch (err) {
|
|
425
|
+
if (!(err instanceof ExecError)) throw err;
|
|
426
|
+
if (err.result.stderr.includes(`cannot lock ref 'refs/tags/${tagName}': reference already exists`)) info(`tag ${tagName} already exists on ${origin}, skipping`);
|
|
427
|
+
else throw err;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (args.withGithubRelease) if (args.dryRun) info("dry run, skipping github release");
|
|
432
|
+
else {
|
|
433
|
+
let token = args.githubToken ?? process.env.GITHUB_TOKEN;
|
|
434
|
+
if (token == null) throw new Error("github token is not set");
|
|
435
|
+
let repo = args.githubRepo ?? process.env.GITHUB_REPOSITORY;
|
|
436
|
+
if (repo == null) throw new Error("github repo is not set");
|
|
437
|
+
info("creating github release...");
|
|
438
|
+
await createGithubRelease({
|
|
439
|
+
token,
|
|
440
|
+
repo,
|
|
441
|
+
tag: tagName,
|
|
442
|
+
name: tagName,
|
|
443
|
+
body: changelog,
|
|
444
|
+
apiUrl: args.githubApiUrl,
|
|
445
|
+
artifacts: await parallelMap(tarballs, async (file) => ({
|
|
446
|
+
name: basename(file),
|
|
447
|
+
type: "application/gzip",
|
|
448
|
+
body: new Uint8Array(await readFile(file))
|
|
449
|
+
}))
|
|
450
|
+
});
|
|
451
|
+
info(`github release created: https://github.com/${repo}/releases/tag/${tagName}`);
|
|
452
|
+
}
|
|
453
|
+
info("done!");
|
|
454
|
+
}
|
|
455
|
+
}),
|
|
456
|
+
command({
|
|
457
|
+
name: "jsr",
|
|
458
|
+
desc: "jsr-related commands",
|
|
459
|
+
subcommands: [
|
|
460
|
+
command({
|
|
461
|
+
name: "populate",
|
|
462
|
+
desc: "populate a local JSR instance with packages from an upstream registry",
|
|
463
|
+
options: {
|
|
464
|
+
upstream: string().desc("URL of the upstream registry (default: process.env.JSR_URL)"),
|
|
465
|
+
createViaApi: boolean("create-via-api").desc("create packages via the API instead of manually via web UI"),
|
|
466
|
+
packages: string().desc("comma-separated list of packages to populate (with version, e.g. `@std/fs@0.105.0`)").required(),
|
|
467
|
+
downstream: string().desc("URL of the downstream local registry").required(),
|
|
468
|
+
token: string().desc("API token"),
|
|
469
|
+
quiet: boolean().alias("q").desc("suppress output"),
|
|
470
|
+
publishArgs: string("publish-args").desc("Additional arguments to pass to `deno publish`")
|
|
471
|
+
},
|
|
472
|
+
transform: (args) => {
|
|
473
|
+
return {
|
|
474
|
+
...args,
|
|
475
|
+
packages: args.packages.split(",").map((item) => item.trim()),
|
|
476
|
+
publishArgs: args.publishArgs?.split(" ")
|
|
477
|
+
};
|
|
478
|
+
},
|
|
479
|
+
handler: populateFromUpstream
|
|
480
|
+
}),
|
|
481
|
+
command({
|
|
482
|
+
name: "create-packages",
|
|
483
|
+
desc: "create missing packages from the workspace",
|
|
484
|
+
options: {
|
|
485
|
+
registry: string("registry").desc("URL of the registry to publish to").default("https://jsr.io"),
|
|
486
|
+
root: string().desc("path to the root of the workspace (default: cwd)"),
|
|
487
|
+
token: string("token").desc("token to use for managing the packages"),
|
|
488
|
+
githubRepo: string("github-repo").desc("github repo to set for the package (requires --token)")
|
|
489
|
+
},
|
|
490
|
+
handler: async (args) => {
|
|
491
|
+
if (!await jsrCreatePackages({
|
|
492
|
+
workspaceRoot: resolveWorkspaceRoot(args.root),
|
|
493
|
+
registry: args.registry,
|
|
494
|
+
token: args.token,
|
|
495
|
+
githubRepo: args.githubRepo
|
|
496
|
+
})) info("all packages were published");
|
|
497
|
+
}
|
|
498
|
+
}),
|
|
499
|
+
command({
|
|
500
|
+
name: "gen-deno-workspace",
|
|
501
|
+
desc: "generate a deno workspace for jsr publishing",
|
|
502
|
+
options: {
|
|
503
|
+
workspaceRoot: string("root").desc("path to the root of the workspace (default: cwd)"),
|
|
504
|
+
withDryRun: boolean("with-dry-run").desc("whether to run `deno publish --dry-run` after generating the workspace")
|
|
505
|
+
},
|
|
506
|
+
handler: async (args) => {
|
|
507
|
+
let workspaceRoot = resolveWorkspaceRoot(args.workspaceRoot);
|
|
508
|
+
info(`deno workspace generated at ${await generateDenoWorkspace({
|
|
509
|
+
workspaceRoot,
|
|
510
|
+
rootConfig: (await loadConfig({ workspaceRoot }))?.jsr,
|
|
511
|
+
withDryRun: args.withDryRun
|
|
512
|
+
})}`);
|
|
513
|
+
}
|
|
514
|
+
})
|
|
515
|
+
]
|
|
516
|
+
}),
|
|
517
|
+
generateDocsCli,
|
|
518
|
+
generateDepsGraphCli,
|
|
519
|
+
runContinuousReleaseCli
|
|
520
|
+
], { theme: (event) => {
|
|
521
|
+
if (event.type === "error" && event.violation === "unknown_error") {
|
|
522
|
+
error(event.error instanceof Error ? event.error : new Error(String(event.error)));
|
|
523
|
+
process.exit(1);
|
|
524
|
+
}
|
|
525
|
+
return false;
|
|
526
|
+
} });
|
|
527
|
+
//#endregion
|