@fuman/build 0.0.3 → 0.0.4
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/cr.d.ts
CHANGED
|
@@ -5,13 +5,19 @@ export declare function runContinuousRelease(params: {
|
|
|
5
5
|
workspace?: WorkspacePackage[];
|
|
6
6
|
distDir?: string;
|
|
7
7
|
extraArgs?: string[];
|
|
8
|
+
onlyChanged?: boolean;
|
|
9
|
+
onlyChangedSince?: string;
|
|
8
10
|
}): Promise<void>;
|
|
9
11
|
export declare const runContinuousReleaseCli: bc.Command<{
|
|
10
12
|
root: string | undefined;
|
|
11
13
|
distDir: string | undefined;
|
|
12
14
|
extraArgs: string | undefined;
|
|
15
|
+
onlyChanged: boolean;
|
|
16
|
+
onlyChangedSince: string | undefined;
|
|
13
17
|
}, {
|
|
14
18
|
extraArgs: string[] | undefined;
|
|
15
19
|
root: string | undefined;
|
|
16
20
|
distDir: string | undefined;
|
|
21
|
+
onlyChanged: boolean;
|
|
22
|
+
onlyChangedSince: string | undefined;
|
|
17
23
|
}>;
|
package/cli/commands/cr.js
CHANGED
|
@@ -2,24 +2,77 @@ import { join } from "node:path";
|
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { asNonNull } from "@fuman/utils";
|
|
4
4
|
import { isRunningInGithubActions } from "../../ci/github-actions.js";
|
|
5
|
+
import { getLatestTag } from "../../git/utils.js";
|
|
5
6
|
import { exec } from "../../misc/exec.js";
|
|
6
7
|
import { collectPackageJsons, filterPackageJsonsForPublish } from "../../package-json/collect-package-jsons.js";
|
|
7
|
-
import
|
|
8
|
+
import { findProjectChangedPackages } from "../../versioning/collect-files.js";
|
|
9
|
+
import { loadConfig } from "./_utils.js";
|
|
8
10
|
import { buildPackage } from "./build.js";
|
|
11
|
+
import * as bc from "@drizzle-team/brocli";
|
|
9
12
|
async function runContinuousRelease(params) {
|
|
10
13
|
const {
|
|
11
14
|
workspaceRoot = process.cwd(),
|
|
12
15
|
workspace = await collectPackageJsons(workspaceRoot, true),
|
|
13
16
|
distDir = "dist",
|
|
14
|
-
extraArgs = []
|
|
17
|
+
extraArgs = [],
|
|
18
|
+
onlyChanged = false,
|
|
19
|
+
onlyChangedSince
|
|
15
20
|
} = params;
|
|
16
21
|
const workspaceWithoutRoot = workspace.filter((pkg) => !pkg.root);
|
|
17
|
-
|
|
22
|
+
let packages = filterPackageJsonsForPublish(workspaceWithoutRoot, "npm");
|
|
23
|
+
if (onlyChanged) {
|
|
24
|
+
const config = await loadConfig({
|
|
25
|
+
workspaceRoot,
|
|
26
|
+
require: false
|
|
27
|
+
});
|
|
28
|
+
const since = onlyChangedSince ?? await getLatestTag(workspaceRoot);
|
|
29
|
+
if (since == null) {
|
|
30
|
+
throw new Error("no previous tag found, cannot determine changeset");
|
|
31
|
+
}
|
|
32
|
+
const changedPackages = await findProjectChangedPackages({
|
|
33
|
+
params: config?.versioning,
|
|
34
|
+
workspace: workspaceWithoutRoot,
|
|
35
|
+
root: workspaceRoot,
|
|
36
|
+
since
|
|
37
|
+
});
|
|
38
|
+
if (!changedPackages.length) {
|
|
39
|
+
console.log(`🤔 no packages changed since ${since}, nothing to do`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const changedPackagesNames = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const pkg of changedPackages) {
|
|
44
|
+
changedPackagesNames.add(asNonNull(pkg.json.name));
|
|
45
|
+
}
|
|
46
|
+
let hadChanges = true;
|
|
47
|
+
while (hadChanges) {
|
|
48
|
+
hadChanges = false;
|
|
49
|
+
for (const pkg of packages) {
|
|
50
|
+
const pkgName = asNonNull(pkg.json.name);
|
|
51
|
+
for (const field of ["dependencies", "peerDependencies"]) {
|
|
52
|
+
const deps = pkg.json[field];
|
|
53
|
+
if (deps == null) continue;
|
|
54
|
+
for (const name of Object.keys(deps)) {
|
|
55
|
+
if (changedPackagesNames.has(name) && !changedPackagesNames.has(pkgName)) {
|
|
56
|
+
hadChanges = true;
|
|
57
|
+
changedPackages.push(pkg);
|
|
58
|
+
changedPackagesNames.add(pkgName);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
packages = changedPackages;
|
|
66
|
+
console.log(`📝 only publishing changed packages since ${since}:`);
|
|
67
|
+
for (const pkg of packages) {
|
|
68
|
+
console.log(` - ${pkg.json.name}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
18
71
|
if (!isRunningInGithubActions()) {
|
|
19
72
|
throw new Error("cr command is only supported in github actions");
|
|
20
73
|
}
|
|
21
74
|
const distPaths = [];
|
|
22
|
-
for (const pkg of
|
|
75
|
+
for (const pkg of packages) {
|
|
23
76
|
if (pkg.json.scripts?.build !== void 0) {
|
|
24
77
|
await exec([
|
|
25
78
|
"npm",
|
|
@@ -60,7 +113,9 @@ const runContinuousReleaseCli = bc.command({
|
|
|
60
113
|
options: {
|
|
61
114
|
root: bc.string().desc("path to the root of the workspace (default: cwd)"),
|
|
62
115
|
distDir: bc.string("dist-dir").desc("directory to publish from, relative to package root (default: dist)"),
|
|
63
|
-
extraArgs: bc.string("extra-args").desc("extra arguments to pass to pkg-pr-new")
|
|
116
|
+
extraArgs: bc.string("extra-args").desc("extra arguments to pass to pkg-pr-new"),
|
|
117
|
+
onlyChanged: bc.boolean("only-changed").desc("whether to only publish packages changed since the last release.").default(false),
|
|
118
|
+
onlyChangedSince: bc.string("only-changed-since").desc("starting point for the changelog (defaults to latest tag)")
|
|
64
119
|
},
|
|
65
120
|
transform: (args) => {
|
|
66
121
|
return {
|
package/cli/commands/release.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
-
import {
|
|
5
|
-
import { asNonNull, notImplemented } from "@fuman/utils";
|
|
4
|
+
import { asNonNull, notImplemented, parallelMap } from "@fuman/utils";
|
|
6
5
|
import { sort } from "semver";
|
|
7
6
|
import { createGithubRelease } from "../../git/github.js";
|
|
8
7
|
import { getLatestTag, getFirstCommit, gitTagExists } from "../../git/utils.js";
|
|
@@ -213,10 +212,10 @@ ${changelog}`;
|
|
|
213
212
|
tag: tagName,
|
|
214
213
|
name: tagName,
|
|
215
214
|
body: changelog,
|
|
216
|
-
artifacts: tarballs
|
|
215
|
+
artifacts: await parallelMap(tarballs, async (file) => ({
|
|
217
216
|
name: basename(file),
|
|
218
217
|
type: "application/gzip",
|
|
219
|
-
body:
|
|
218
|
+
body: await readFile(file)
|
|
220
219
|
}))
|
|
221
220
|
});
|
|
222
221
|
console.log(`\x1B[;32m✅github release created: https://github.com/${repo}/releases/tag/${tagName}\x1B[;0m`);
|
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.4",
|
|
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.4",
|
|
11
|
+
"@fuman/io": "^0.0.4",
|
|
12
|
+
"@fuman/node": "^0.0.4",
|
|
13
|
+
"@fuman/utils": "^0.0.4",
|
|
14
14
|
"cross-spawn": "^7.0.5",
|
|
15
15
|
"detect-indent": "^7.0.1",
|
|
16
16
|
"js-yaml": "^4.1.0",
|
|
@@ -10,12 +10,14 @@ export interface ProjectChangedFile {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function findProjectChangedFiles(params: {
|
|
12
12
|
params?: VersioningOptions;
|
|
13
|
+
workspace?: WorkspacePackage[];
|
|
13
14
|
root?: string | URL;
|
|
14
15
|
since: string;
|
|
15
16
|
until?: string;
|
|
16
17
|
}): Promise<ProjectChangedFile[]>;
|
|
17
18
|
export declare function findProjectChangedPackages(params: {
|
|
18
19
|
params?: VersioningOptions;
|
|
20
|
+
workspace?: WorkspacePackage[];
|
|
19
21
|
root?: string | URL;
|
|
20
22
|
since: string;
|
|
21
23
|
until?: string;
|
|
@@ -29,10 +29,7 @@ async function findProjectChangedFiles(params) {
|
|
|
29
29
|
cwd: root
|
|
30
30
|
});
|
|
31
31
|
if (!changed.length) return [];
|
|
32
|
-
const packages = await collectPackageJsons(root);
|
|
33
|
-
for (const pkg of packages) {
|
|
34
|
-
pkg.path = relative(root, pkg.path);
|
|
35
|
-
}
|
|
32
|
+
const packages = (params.workspace ?? await collectPackageJsons(root)).map((pkg) => ({ ...pkg, path: relative(root, pkg.path) }));
|
|
36
33
|
const files = [];
|
|
37
34
|
const includeGlobs = include == null ? null : picomatch(include);
|
|
38
35
|
const excludeGlobs = exclude == null ? null : picomatch(exclude);
|