@fuman/build 0.0.10 → 0.0.11
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/cli/commands/bump-version.js +5 -1
- package/cli/commands/release.js +14 -6
- package/index.js +2 -1
- package/misc/exec.d.ts +6 -1
- package/misc/exec.js +14 -6
- package/package.json +5 -5
|
@@ -17,7 +17,11 @@ function formatBumpVersionResult(result, withReleaseType) {
|
|
|
17
17
|
lines.push("");
|
|
18
18
|
lines.push("list of changed packages:");
|
|
19
19
|
for (const { package: pkg, because, prevVersion } of result.changedPackages) {
|
|
20
|
-
|
|
20
|
+
let versionStr = prevVersion;
|
|
21
|
+
if (!pkg.json.fuman?.ownVersioning) {
|
|
22
|
+
versionStr += ` → ${pkg.json.version}`;
|
|
23
|
+
}
|
|
24
|
+
lines.push(` ${pkg.json.name}${because ? ` (because of ${because.join(", ")})` : ""}: ${versionStr}`);
|
|
21
25
|
}
|
|
22
26
|
return lines.join("\n");
|
|
23
27
|
}
|
package/cli/commands/release.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createGithubRelease } from "../../git/github.js";
|
|
|
7
7
|
import { getLatestTag, getFirstCommit, gitTagExists } from "../../git/utils.js";
|
|
8
8
|
import { jsrCreatePackages } from "../../jsr/create-packages.js";
|
|
9
9
|
import { generateDenoWorkspace } from "../../jsr/generate-workspace.js";
|
|
10
|
-
import { exec } from "../../misc/exec.js";
|
|
10
|
+
import { exec, ExecError } from "../../misc/exec.js";
|
|
11
11
|
import { collectPackageJsons } from "../../package-json/collect-package-jsons.js";
|
|
12
12
|
import { bumpVersion } from "../../versioning/bump-version.js";
|
|
13
13
|
import { generateChangelog } from "../../versioning/generate-changelog.js";
|
|
@@ -218,11 +218,19 @@ ${changelog}`;
|
|
|
218
218
|
stdio: "inherit",
|
|
219
219
|
throwOnError: true
|
|
220
220
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
try {
|
|
222
|
+
await exec(["git", "push", origin, "--force", "--tags"], {
|
|
223
|
+
cwd: root,
|
|
224
|
+
throwOnError: true
|
|
225
|
+
});
|
|
226
|
+
} catch (e) {
|
|
227
|
+
if (!(e instanceof ExecError)) throw e;
|
|
228
|
+
if (e.result.stderr.includes(`cannot lock ref 'refs/tags/${tagName}': reference already exists`)) {
|
|
229
|
+
console.log(`❗ tag ${tagName} already exists on ${origin}, skipping`);
|
|
230
|
+
} else {
|
|
231
|
+
throw e;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
226
234
|
}
|
|
227
235
|
}
|
|
228
236
|
}
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { generateDocs } from "./cli/commands/docs.js";
|
|
|
4
4
|
import { generateDepsGraph } from "./cli/commands/gen-deps-graph.js";
|
|
5
5
|
import { validateWorkspaceDeps } from "./cli/commands/validate-workspace-deps.js";
|
|
6
6
|
import { findChangedFiles, getCommitsBetween, getCurrentBranch, getCurrentCommit, getFirstCommit, getLatestTag, gitTagExists, parseConventionalCommit } from "./git/utils.js";
|
|
7
|
-
import { exec } from "./misc/exec.js";
|
|
7
|
+
import { ExecError, exec } from "./misc/exec.js";
|
|
8
8
|
import { normalizeFilePath } from "./misc/path.js";
|
|
9
9
|
import { determinePublishOrder, sortWorkspaceByPublishOrder } from "./misc/publish-order.js";
|
|
10
10
|
import { getTsconfigFiles, getTsconfigFor } from "./misc/tsconfig.js";
|
|
@@ -18,6 +18,7 @@ import { bumpVersion } from "./versioning/bump-version.js";
|
|
|
18
18
|
import { findProjectChangedFiles, findProjectChangedPackages } from "./versioning/collect-files.js";
|
|
19
19
|
import { generateChangelog } from "./versioning/generate-changelog.js";
|
|
20
20
|
export {
|
|
21
|
+
ExecError,
|
|
21
22
|
NPM_PACKAGE_NAME_REGEX,
|
|
22
23
|
PackageJsonSchema,
|
|
23
24
|
buildPackage,
|
package/misc/exec.d.ts
CHANGED
|
@@ -8,12 +8,17 @@ export interface ExecResult {
|
|
|
8
8
|
/** exit code of the command */
|
|
9
9
|
exitCode: number;
|
|
10
10
|
}
|
|
11
|
+
export declare class ExecError extends Error {
|
|
12
|
+
readonly cmd: string[];
|
|
13
|
+
readonly result: ExecResult;
|
|
14
|
+
constructor(cmd: string[], result: ExecResult);
|
|
15
|
+
}
|
|
11
16
|
/**
|
|
12
17
|
* execute a command and return its result
|
|
13
18
|
*
|
|
14
19
|
* **differences from node's `child_process.exec()`**:
|
|
15
20
|
* - if `options.stdio` is set to `'inherit'`, the command will be printed to the console (unless `options.quiet` is set to `true`)
|
|
16
|
-
* - on non-zero exit code, the promise will be rejected with an
|
|
21
|
+
* - on non-zero exit code, the promise will be rejected with an {@link ExecError} if `options.throwOnError` is set to `true`
|
|
17
22
|
*
|
|
18
23
|
* @param cmd command to execute (first element is the command itself, the rest are arguments to it)
|
|
19
24
|
*/
|
package/misc/exec.js
CHANGED
|
@@ -2,6 +2,15 @@ import path__default from "node:path";
|
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { spawn } from "cross-spawn";
|
|
4
4
|
import { normalizeFilePath } from "./path.js";
|
|
5
|
+
class ExecError extends Error {
|
|
6
|
+
constructor(cmd, result) {
|
|
7
|
+
super(`Command exited with code ${result.exitCode}`, {
|
|
8
|
+
cause: result
|
|
9
|
+
});
|
|
10
|
+
this.cmd = cmd;
|
|
11
|
+
this.result = result;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
function exec(cmd, options) {
|
|
6
15
|
return new Promise((resolve, reject) => {
|
|
7
16
|
if (options?.stdio === "inherit" && !options.quiet) {
|
|
@@ -29,12 +38,10 @@ function exec(cmd, options) {
|
|
|
29
38
|
proc.on("error", reject);
|
|
30
39
|
proc.on("close", (code) => {
|
|
31
40
|
if (code !== 0 && options?.throwOnError) {
|
|
32
|
-
reject(new
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
cmd
|
|
37
|
-
}
|
|
41
|
+
reject(new ExecError(cmd, {
|
|
42
|
+
stdout: Buffer.concat(stdout).toString(),
|
|
43
|
+
stderr: Buffer.concat(stderr).toString(),
|
|
44
|
+
exitCode: code ?? -1
|
|
38
45
|
}));
|
|
39
46
|
}
|
|
40
47
|
resolve({
|
|
@@ -46,5 +53,6 @@ function exec(cmd, options) {
|
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
55
|
export {
|
|
56
|
+
ExecError,
|
|
49
57
|
exec
|
|
50
58
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/build",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"description": "utils for building packages and managing monorepos",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@drizzle-team/brocli": "^0.10.2",
|
|
10
|
-
"@fuman/fetch": "^0.0.
|
|
11
|
-
"@fuman/io": "^0.0.
|
|
12
|
-
"@fuman/node": "^0.0.
|
|
13
|
-
"@fuman/utils": "^0.0.
|
|
10
|
+
"@fuman/fetch": "^0.0.11",
|
|
11
|
+
"@fuman/io": "^0.0.11",
|
|
12
|
+
"@fuman/node": "^0.0.11",
|
|
13
|
+
"@fuman/utils": "^0.0.11",
|
|
14
14
|
"cross-spawn": "^7.0.5",
|
|
15
15
|
"detect-indent": "^7.0.1",
|
|
16
16
|
"js-yaml": "^4.1.0",
|