@decohere/ci-tools 0.0.1-dev.114 → 0.0.1-dev.116

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/ci-tools",
3
- "version": "0.0.1-dev.114",
3
+ "version": "0.0.1-dev.116",
4
4
  "description": "CI utility scripts for badge generation, coverage reporting, pages artifact assembly, and GitHub API tooling",
5
5
  "keywords": [
6
6
  "typescript",
@@ -1,28 +1,25 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync, readdirSync, readFileSync } from "node:fs";
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 dir of readdirSync(projectsDir)) {
14
- const pkgPath = join(projectsDir, dir, "package.json");
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));
@@ -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/workspace (`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 the workspace package 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 { readdirSync, readFileSync } from "node:fs";
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 projects = readdirSync(projectsDir);
22
-
23
- for (const project of projects) {
24
- const pkgPath = join(projectsDir, project, "package.json");
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",
@@ -13,7 +13,7 @@ SF:projects/forge/src/build/index.ts
13
13
  LF:20
14
14
  LH:15
15
15
  end_of_record
16
- SF:projects/nexus/src/index.ts
16
+ SF:projects/core/src/index.ts
17
17
  LF:5
18
18
  LH:5
19
19
  end_of_record
@@ -46,9 +46,9 @@ describe("parseLcovByProject", () => {
46
46
  expect(result.get("forge")).toBeDefined();
47
47
  expect(result.get("forge").totalLines).toBe(30);
48
48
  expect(result.get("forge").coveredLines).toBe(24);
49
- expect(result.get("nexus")).toBeDefined();
50
- expect(result.get("nexus").totalLines).toBe(5);
51
- expect(result.get("nexus").coveredLines).toBe(5);
49
+ expect(result.get("core")).toBeDefined();
50
+ expect(result.get("core").totalLines).toBe(5);
51
+ expect(result.get("core").coveredLines).toBe(5);
52
52
  });
53
53
 
54
54
  it("ignores records with LF:0", () => {