@decohere/ci-tools 0.0.1-dev.113 → 0.0.1-dev.115
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/package.json
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { listProjectDirs } from "../lib/workspace-packages.mjs";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* Workspace packages that `forge publish` will upload (not `"private": true`)
|
|
8
|
+
* Workspace packages that `forge publish` will upload (not `"private": true`), including
|
|
9
|
+
* grouped ones such as `projects/data/data-typeorm`.
|
|
8
10
|
* @param {string} root
|
|
9
11
|
*/
|
|
10
12
|
export function listPublishablePackages(root) {
|
|
11
|
-
const projectsDir = join(root, "projects");
|
|
12
13
|
const packages = [];
|
|
13
|
-
for (const
|
|
14
|
-
const
|
|
15
|
-
if (!existsSync(pkgPath)) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
14
|
+
for (const projectDir of listProjectDirs(root)) {
|
|
15
|
+
const pkg = JSON.parse(readFileSync(join(projectDir, "package.json"), "utf8"));
|
|
19
16
|
if (typeof pkg.name !== "string" || pkg.private === true) {
|
|
20
17
|
continue;
|
|
21
18
|
}
|
|
22
19
|
packages.push({
|
|
23
20
|
name: pkg.name,
|
|
24
21
|
version: pkg.version,
|
|
25
|
-
dir,
|
|
22
|
+
dir: relative(join(root, "projects"), projectDir),
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
return packages.sort((a, b) => a.name.localeCompare(b.name));
|
package/src/lib/github-issue.mjs
CHANGED
|
@@ -47,7 +47,9 @@ export function upsertIssue(options, run = gh) {
|
|
|
47
47
|
"--limit",
|
|
48
48
|
"200",
|
|
49
49
|
"--search",
|
|
50
|
-
|
|
50
|
+
// Quoted: GitHub's search can't match a title like `security(ci): …` unquoted (#681).
|
|
51
|
+
// The exact-title match in pickIssue still decides.
|
|
52
|
+
`"${title.replaceAll('"', "")}" in:title`,
|
|
51
53
|
"--json",
|
|
52
54
|
"number,title,state,url",
|
|
53
55
|
]),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
// The same rule as WorkspaceDefaults in @decohere/mesh (`projects/**/package.json`, minus these
|
|
5
|
+
// folders, and a package.json inside another project is not a project). CI scripts run on plain
|
|
6
|
+
// Node before any install, so they can't import mesh itself.
|
|
7
|
+
const SKIP = new Set(["node_modules", "__fixtures__", "dist"]);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Every project directory under `<root>/projects`, at any depth (`projects/cli`,
|
|
11
|
+
* `projects/data/data-typeorm`).
|
|
12
|
+
* @param {string} root
|
|
13
|
+
* @returns {string[]} absolute paths
|
|
14
|
+
*/
|
|
15
|
+
export function listProjectDirs(root) {
|
|
16
|
+
const found = [];
|
|
17
|
+
const walk = (dir) => {
|
|
18
|
+
if (existsSync(join(dir, "package.json"))) {
|
|
19
|
+
found.push(dir);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
23
|
+
if (entry.isDirectory() && !SKIP.has(entry.name) && !entry.name.startsWith(".")) {
|
|
24
|
+
walk(join(dir, entry.name));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
walk(join(root, "projects"));
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Outputs markdown formatted links for GitHub release notes
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
+
import { listProjectDirs } from "../lib/workspace-packages.mjs";
|
|
9
10
|
|
|
10
11
|
const VERSION = process.argv[2] || process.env.VERSION;
|
|
11
12
|
|
|
@@ -15,20 +16,12 @@ if (!VERSION) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
let links = "## Published Packages\n\n";
|
|
18
|
-
const projectsDir = join(process.cwd(), "projects");
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
27
|
-
if (pkg.name?.startsWith("@decohere/")) {
|
|
28
|
-
links += `- [\`${pkg.name}@${VERSION}\`](https://www.npmjs.com/package/${pkg.name}/v/${VERSION})\n`;
|
|
29
|
-
}
|
|
30
|
-
} catch {
|
|
31
|
-
// Skip projects without package.json
|
|
21
|
+
for (const projectDir of listProjectDirs(process.cwd())) {
|
|
22
|
+
const pkg = JSON.parse(readFileSync(join(projectDir, "package.json"), "utf8"));
|
|
23
|
+
if (pkg.name?.startsWith("@decohere/")) {
|
|
24
|
+
links += `- [\`${pkg.name}@${VERSION}\`](https://www.npmjs.com/package/${pkg.name}/v/${VERSION})\n`;
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
27
|
|
|
@@ -47,6 +47,26 @@ describe("publish-verify", () => {
|
|
|
47
47
|
]);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
it("lists grouped packages (projects/<group>/<name>) and skips nested and build folders", () => {
|
|
51
|
+
const root = seedWorkspace();
|
|
52
|
+
vol.fromJSON({
|
|
53
|
+
[`${root}/projects/data/data/package.json`]: JSON.stringify({ name: "@decohere/data" }),
|
|
54
|
+
[`${root}/projects/data/data-typeorm/package.json`]: JSON.stringify({
|
|
55
|
+
name: "@decohere/data-typeorm",
|
|
56
|
+
}),
|
|
57
|
+
[`${root}/projects/cli/examples/demo/package.json`]: JSON.stringify({ name: "nested" }),
|
|
58
|
+
[`${root}/projects/__fixtures__/app/package.json`]: JSON.stringify({ name: "fixture" }),
|
|
59
|
+
[`${root}/projects/node_modules/dep/package.json`]: JSON.stringify({ name: "dep" }),
|
|
60
|
+
[`${root}/projects/dist/out/package.json`]: JSON.stringify({ name: "built" }),
|
|
61
|
+
});
|
|
62
|
+
expect(listPublishablePackages(root).map((pkg) => pkg.name)).toEqual([
|
|
63
|
+
"@decohere/cli",
|
|
64
|
+
"@decohere/create",
|
|
65
|
+
"@decohere/data",
|
|
66
|
+
"@decohere/data-typeorm",
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
50
70
|
it("parses GHCR repository coordinates", () => {
|
|
51
71
|
expect(parseGhcrRepository("ghcr.io/typesmiths/decohere/create")).toEqual({
|
|
52
72
|
org: "typesmiths",
|
|
@@ -28,6 +28,17 @@ describe("github-issue", () => {
|
|
|
28
28
|
expect(pickIssue([], TITLE)).toBeNull();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
// #681: GitHub's search can't match `security(ci): …` unquoted, so the lookup found nothing
|
|
32
|
+
// and a new issue was opened on every run.
|
|
33
|
+
it("searches for the title as a quoted phrase", () => {
|
|
34
|
+
const { run, calls } = fakeGh([]);
|
|
35
|
+
upsertIssue({ title: "security(ci): npm audit vulnerabilities detected", body: "b" }, run);
|
|
36
|
+
const args = calls[0].args;
|
|
37
|
+
expect(args[args.indexOf("--search") + 1]).toBe(
|
|
38
|
+
'"security(ci): npm audit vulnerabilities detected" in:title',
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
31
42
|
it("opens an issue with assignees when none has the title", () => {
|
|
32
43
|
const { run, calls } = fakeGh([]);
|
|
33
44
|
const result = upsertIssue({ title: TITLE, body: "body", assignees: ["das974"] }, run);
|