@procedures/lib 0.60.1 → 0.62.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/CHANGELOG.md +38 -0
- package/README.md +2 -0
- package/dist/procedures/lib/new.d.ts +11 -0
- package/dist/procedures/lib/new.d.ts.map +1 -1
- package/dist/procedures/lib/new.js +59 -0
- package/dist/procedures/lib/new.js.map +1 -1
- package/dist/workspace.d.ts +4 -2
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +6 -22
- package/dist/workspace.js.map +1 -1
- package/package.json +8 -7
- package/src/procedures/lib/new.ts +82 -0
- package/src/workspace.ts +6 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @procedures/lib
|
|
2
2
|
|
|
3
|
+
## 0.62.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fdb89bc: The path, glob and walk functions of three packages move to their home, `@mark1russell7/files` (roadmap CLI-125).
|
|
8
|
+
|
|
9
|
+
- `@procedures/fs`: `isInside` is a re-export of `@mark1russell7/files`. With `dot: true`, `fs.glob` uses `findEntriesAsync` of `@mark1russell7/files`, and its walk does not block the event loop.
|
|
10
|
+
- `@procedures/fs`: with `dot: true`, an absolute pattern under `cwd` matches. Before, it matched nothing. The other matches do not change.
|
|
11
|
+
- `@procedures/lib`: `expandHome` is a re-export of `@mark1russell7/files`. `findWorkspaceRoot` uses `findUp`.
|
|
12
|
+
- `@procedures/archive`: the walk of `archive.create` uses `walk` of `@mark1russell7/files`. `portableLinkTarget` uses `toPosix`. The limits and the error codes do not change.
|
|
13
|
+
- `@procedures/peer`: the range of `@mark1russell7/files` is `^0.0.4`, as in the other packages. The code does not change.
|
|
14
|
+
- 2b6a9bd: `lib.new` adds the new package to the fixed group of `@procedures/client` in `.changeset/config.json`. It also gives the package the version of that group. Before, the package kept the version of cue (0.1.0), and the package check failed on two versions until a person set the version.
|
|
15
|
+
|
|
16
|
+
PATCH: before 1.0.0, a backward-compatible fix raises PATCH. A workspace with no fixed group of `@procedures/client` keeps the old behavior.
|
|
17
|
+
- Updated dependencies [14f61a7]
|
|
18
|
+
- Updated dependencies [fdb89bc]
|
|
19
|
+
- @procedures/client@0.62.0
|
|
20
|
+
- @procedures/fs@0.62.0
|
|
21
|
+
- @procedures/dag@0.62.0
|
|
22
|
+
- @procedures/git@0.62.0
|
|
23
|
+
- @procedures/pnpm@0.62.0
|
|
24
|
+
- @procedures/shell@0.62.0
|
|
25
|
+
|
|
26
|
+
## 0.61.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [8506442]
|
|
31
|
+
- Updated dependencies [84d9551]
|
|
32
|
+
- Updated dependencies [f9a78f9]
|
|
33
|
+
- Updated dependencies [3eb4b59]
|
|
34
|
+
- @procedures/client@0.61.0
|
|
35
|
+
- @procedures/fs@0.61.0
|
|
36
|
+
- @procedures/dag@0.61.0
|
|
37
|
+
- @procedures/git@0.61.0
|
|
38
|
+
- @procedures/pnpm@0.61.0
|
|
39
|
+
- @procedures/shell@0.61.0
|
|
40
|
+
|
|
3
41
|
## 0.60.1
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -63,6 +63,8 @@ Input: `name` (without the scope), `preset` (default `lib`), `rootPath` and `dry
|
|
|
63
63
|
|
|
64
64
|
The procedure makes `packages/<name>`. It starts `cue-config init` and `cue-config generate`, and it writes `src/index.ts`, `src/register.ts` and `src/types.ts`. It also sets the `client.procedures` field and adds a `workspace:*` dependency on `client`. Then start `pnpm install` and `pnpm build`. `cue-config` needs the CUE binary.
|
|
65
65
|
|
|
66
|
+
The new package joins the fixed group of `@procedures/client` in `.changeset/config.json`, and it gets the version of that group. The packages of a fixed group share one version, and the package check fails on two versions. A release can change the version of the group before the merge of the new package. So before the merge, merge `main` and set the version again.
|
|
67
|
+
|
|
66
68
|
The output gives `success`, `packageName`, `packagePath`, `created`, `operations` and `errors`.
|
|
67
69
|
|
|
68
70
|
## `lib.audit`
|
|
@@ -13,6 +13,17 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { ProcedureContext } from "@procedures/client";
|
|
15
15
|
import type { LibNewInput, LibNewOutput } from "../../types.js";
|
|
16
|
+
/** The fixed groups of a changeset config, with the new package in the group of `GROUP_PACKAGE`. */
|
|
17
|
+
export interface JoinedGroups {
|
|
18
|
+
readonly fixed: string[][];
|
|
19
|
+
/** This value is true when the group of `GROUP_PACKAGE` did not hold the new package before. */
|
|
20
|
+
readonly changed: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This function adds a package to the fixed group that holds `GROUP_PACKAGE`. It gives undefined
|
|
24
|
+
* when the value is not a list of groups of names, or when no group holds `GROUP_PACKAGE`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function joinGroup(fixed: unknown, packageName: string): JoinedGroups | undefined;
|
|
16
27
|
/**
|
|
17
28
|
* Create a new client package in the workspace
|
|
18
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/procedures/lib/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/procedures/lib/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAWhE,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAYvF;AA8ID;;GAEG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CA2J7F"}
|
|
@@ -13,6 +13,53 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { packagesDir, resolveWorkspaceRoot } from "../../workspace.js";
|
|
16
|
+
/** A new package joins the fixed group of changesets that holds this package. */
|
|
17
|
+
const GROUP_PACKAGE = "@procedures/client";
|
|
18
|
+
/**
|
|
19
|
+
* This function adds a package to the fixed group that holds `GROUP_PACKAGE`. It gives undefined
|
|
20
|
+
* when the value is not a list of groups of names, or when no group holds `GROUP_PACKAGE`.
|
|
21
|
+
*/
|
|
22
|
+
export function joinGroup(fixed, packageName) {
|
|
23
|
+
if (!Array.isArray(fixed))
|
|
24
|
+
return undefined;
|
|
25
|
+
const groups = [];
|
|
26
|
+
for (const group of fixed) {
|
|
27
|
+
if (!Array.isArray(group) || !group.every((name) => typeof name === "string"))
|
|
28
|
+
return undefined;
|
|
29
|
+
groups.push([...group]);
|
|
30
|
+
}
|
|
31
|
+
const group = groups.find((names) => names.includes(GROUP_PACKAGE));
|
|
32
|
+
if (group === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
const changed = !group.includes(packageName);
|
|
35
|
+
if (changed)
|
|
36
|
+
group.push(packageName);
|
|
37
|
+
return { fixed: groups, changed };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* This function reads the fixed group of the client. The packages of a fixed group share one
|
|
41
|
+
* version, so the version of `GROUP_PACKAGE` is the version of the group. A release can change
|
|
42
|
+
* the version after the start of a package, so the merge of the package checks it again.
|
|
43
|
+
*/
|
|
44
|
+
async function groupOf(rootPath, packageName, ctx) {
|
|
45
|
+
const configPath = join(rootPath, ".changeset", "config.json");
|
|
46
|
+
const { exists } = await ctx.client.call(["fs", "exists"], { path: configPath });
|
|
47
|
+
if (!exists)
|
|
48
|
+
return undefined;
|
|
49
|
+
const { data } = await ctx.client.call(["fs", "read", "json"], { path: configPath });
|
|
50
|
+
const config = (data ?? {});
|
|
51
|
+
const joined = joinGroup(config["fixed"], packageName);
|
|
52
|
+
if (joined === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
const { matches } = await ctx.client.call(["fs", "glob"], { pattern: "packages/*/package.json", cwd: rootPath, absolute: true });
|
|
55
|
+
for (const path of matches) {
|
|
56
|
+
const { data: manifest } = await ctx.client.call(["fs", "read", "json"], { path });
|
|
57
|
+
const { name, version } = (manifest ?? {});
|
|
58
|
+
if (name === GROUP_PACKAGE && typeof version === "string")
|
|
59
|
+
return { configPath, config, joined, version };
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
16
63
|
// The root registers nothing: `import "<package>/register"` or `createRegistry()` registers the procedures
|
|
17
64
|
const INDEX_TS = `// The root registers nothing: import "<package>/register", or give the module to createRegistry()
|
|
18
65
|
export * from "./module.js";
|
|
@@ -155,6 +202,7 @@ export async function libNew(input, ctx) {
|
|
|
155
202
|
`Would run cue-config init --preset ${input.preset}`,
|
|
156
203
|
"Would run cue-config generate",
|
|
157
204
|
`Would set the package name to ${packageName}, the exports, the files without the build info of tsc, client.procedures and the client dependency`,
|
|
205
|
+
`Would add ${packageName} to the fixed group of ${GROUP_PACKAGE} in .changeset/config.json, at the version of the group`,
|
|
158
206
|
"Then run pnpm install and pnpm build in the workspace root",
|
|
159
207
|
],
|
|
160
208
|
errors: [],
|
|
@@ -202,7 +250,18 @@ export async function libNew(input, ctx) {
|
|
|
202
250
|
"@procedures/client": "workspace:*",
|
|
203
251
|
zod: "^4.6.5",
|
|
204
252
|
};
|
|
253
|
+
// Step 4: the new package joins the fixed group of the client, at the version of the group.
|
|
254
|
+
// Before, it kept the version of cue (0.1.0), and the package check failed on two versions.
|
|
255
|
+
const group = await groupOf(rootPath, packageName, ctx);
|
|
256
|
+
if (group !== undefined) {
|
|
257
|
+
pkgJson["version"] = group.version;
|
|
258
|
+
operations.push(`Setting the version to ${group.version}, the version of the fixed group of ${GROUP_PACKAGE}`);
|
|
259
|
+
}
|
|
205
260
|
await ctx.client.call(["fs", "write"], { path: pkgJsonPath, content: JSON.stringify(pkgJson, null, 2) + "\n" });
|
|
261
|
+
if (group?.joined.changed === true) {
|
|
262
|
+
operations.push(`Adding ${packageName} to the fixed group of ${GROUP_PACKAGE} in .changeset/config.json`);
|
|
263
|
+
await ctx.client.call(["fs", "write"], { path: group.configPath, content: JSON.stringify({ ...group.config, fixed: group.joined.fixed }, null, 2) + "\n" });
|
|
264
|
+
}
|
|
206
265
|
operations.push(`Created ${packageName}. Next: run pnpm install and pnpm build in ${rootPath}`);
|
|
207
266
|
}
|
|
208
267
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/procedures/lib/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/procedures/lib/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAOvE,iFAAiF;AACjF,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAS3C;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,WAAm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AAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CACxE,CAAC;QACF,IAAI,KAAK,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACnC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAW,0BAA0B,aAAa,4BAA4B,CAAC,CAAC;YAC1G,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CACnB,CAAC,IAAI,EAAE,OAAO,CAAC,EACf,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CACpH,CAAC;QACJ,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,WAAW,WAAW,8CAA8C,QAAQ,EAAE,CAAC,CAAC;IAClG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,WAAW;QACX,WAAW;QACX,OAAO;QACP,UAAU;QACV,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* find the workspace root and decide which dependencies link two ecosystem packages,
|
|
6
6
|
* so the lib.* procedures work on the monorepo instead of one git repository per package.
|
|
7
7
|
*/
|
|
8
|
+
import { expandHome } from "@mark1russell7/files";
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* This function replaces a leading `~` with the home folder: `~`, `~/a` and `~\a`. Its home is
|
|
11
|
+
* `@mark1russell7/files`.
|
|
10
12
|
*/
|
|
11
|
-
export
|
|
13
|
+
export { expandHome };
|
|
12
14
|
/**
|
|
13
15
|
* Find the nearest folder at or above `start` that holds pnpm-workspace.yaml
|
|
14
16
|
*/
|
package/dist/workspace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,UAAU,EAAU,MAAM,sBAAsB,CAAC;AAG1D;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAe9D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAwC,CAAC;AAEvF,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAClD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACvD,GAAG,MAAM,EAAE,CAUX"}
|
package/dist/workspace.js
CHANGED
|
@@ -6,37 +6,21 @@
|
|
|
6
6
|
* so the lib.* procedures work on the monorepo instead of one git repository per package.
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
|
-
import { homedir } from "node:os";
|
|
10
9
|
import { dirname, join, resolve } from "node:path";
|
|
11
10
|
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { expandHome, findUp } from "@mark1russell7/files";
|
|
12
12
|
import { isMark1Russell7Ref } from "./git/index.js";
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* This function replaces a leading `~` with the home folder: `~`, `~/a` and `~\a`. Its home is
|
|
15
|
+
* `@mark1russell7/files`.
|
|
15
16
|
*/
|
|
16
|
-
export
|
|
17
|
-
if (p === "~") {
|
|
18
|
-
return homedir();
|
|
19
|
-
}
|
|
20
|
-
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
21
|
-
return join(homedir(), p.slice(2));
|
|
22
|
-
}
|
|
23
|
-
return p;
|
|
24
|
-
}
|
|
17
|
+
export { expandHome };
|
|
25
18
|
/**
|
|
26
19
|
* Find the nearest folder at or above `start` that holds pnpm-workspace.yaml
|
|
27
20
|
*/
|
|
28
21
|
export function findWorkspaceRoot(start) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (existsSync(join(dir, "pnpm-workspace.yaml"))) {
|
|
32
|
-
return dir;
|
|
33
|
-
}
|
|
34
|
-
const parent = dirname(dir);
|
|
35
|
-
if (parent === dir) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
dir = parent;
|
|
39
|
-
}
|
|
22
|
+
const file = findUp("pnpm-workspace.yaml", start);
|
|
23
|
+
return file === null ? null : dirname(file);
|
|
40
24
|
}
|
|
41
25
|
/**
|
|
42
26
|
* Resolve the workspace root for a procedure call: the explicit `rootPath` if given,
|
package/dist/workspace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAiB;IACpD,IAAI,QAAQ,EAAE,CAAC;QACb,6FAA6F;QAC7F,sFAAsF;QACtF,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;I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CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/lib",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.62.0",
|
|
5
5
|
"description": "Workspace procedures for pnpm monorepos: scan the packages, graph their dependencies, scaffold a new package, audit packages against a template, and rename across the workspace.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"monorepo",
|
|
@@ -74,12 +74,13 @@
|
|
|
74
74
|
"vitest": "^5.0.3"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@
|
|
78
|
-
"@procedures/
|
|
79
|
-
"@procedures/
|
|
80
|
-
"@procedures/
|
|
81
|
-
"@procedures/
|
|
82
|
-
"@procedures/
|
|
77
|
+
"@mark1russell7/files": "^0.0.4",
|
|
78
|
+
"@procedures/client": "0.62.0",
|
|
79
|
+
"@procedures/dag": "0.62.0",
|
|
80
|
+
"@procedures/fs": "0.62.0",
|
|
81
|
+
"@procedures/git": "0.62.0",
|
|
82
|
+
"@procedures/pnpm": "0.62.0",
|
|
83
|
+
"@procedures/shell": "0.62.0",
|
|
83
84
|
"ts-morph": "^24.0.0",
|
|
84
85
|
"zod": "^4.6.5"
|
|
85
86
|
},
|
|
@@ -17,6 +17,72 @@ import type { ProcedureContext } from "@procedures/client";
|
|
|
17
17
|
import type { LibNewInput, LibNewOutput } from "../../types.js";
|
|
18
18
|
import { packagesDir, resolveWorkspaceRoot } from "../../workspace.js";
|
|
19
19
|
|
|
20
|
+
interface FsGlobOutput {
|
|
21
|
+
pattern: string;
|
|
22
|
+
matches: string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A new package joins the fixed group of changesets that holds this package. */
|
|
26
|
+
const GROUP_PACKAGE = "@procedures/client";
|
|
27
|
+
|
|
28
|
+
/** The fixed groups of a changeset config, with the new package in the group of `GROUP_PACKAGE`. */
|
|
29
|
+
export interface JoinedGroups {
|
|
30
|
+
readonly fixed: string[][];
|
|
31
|
+
/** This value is true when the group of `GROUP_PACKAGE` did not hold the new package before. */
|
|
32
|
+
readonly changed: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This function adds a package to the fixed group that holds `GROUP_PACKAGE`. It gives undefined
|
|
37
|
+
* when the value is not a list of groups of names, or when no group holds `GROUP_PACKAGE`.
|
|
38
|
+
*/
|
|
39
|
+
export function joinGroup(fixed: unknown, packageName: string): JoinedGroups | undefined {
|
|
40
|
+
if (!Array.isArray(fixed)) return undefined;
|
|
41
|
+
const groups: string[][] = [];
|
|
42
|
+
for (const group of fixed) {
|
|
43
|
+
if (!Array.isArray(group) || !group.every((name) => typeof name === "string")) return undefined;
|
|
44
|
+
groups.push([...(group as string[])]);
|
|
45
|
+
}
|
|
46
|
+
const group = groups.find((names) => names.includes(GROUP_PACKAGE));
|
|
47
|
+
if (group === undefined) return undefined;
|
|
48
|
+
const changed = !group.includes(packageName);
|
|
49
|
+
if (changed) group.push(packageName);
|
|
50
|
+
return { fixed: groups, changed };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The changeset config with the new package in the group of the client, and the version of the group. */
|
|
54
|
+
interface Group {
|
|
55
|
+
readonly configPath: string;
|
|
56
|
+
readonly config: Record<string, unknown>;
|
|
57
|
+
readonly joined: JoinedGroups;
|
|
58
|
+
readonly version: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* This function reads the fixed group of the client. The packages of a fixed group share one
|
|
63
|
+
* version, so the version of `GROUP_PACKAGE` is the version of the group. A release can change
|
|
64
|
+
* the version after the start of a package, so the merge of the package checks it again.
|
|
65
|
+
*/
|
|
66
|
+
async function groupOf(rootPath: string, packageName: string, ctx: ProcedureContext): Promise<Group | undefined> {
|
|
67
|
+
const configPath = join(rootPath, ".changeset", "config.json");
|
|
68
|
+
const { exists } = await ctx.client.call<{ path: string }, { exists: boolean }>(["fs", "exists"], { path: configPath });
|
|
69
|
+
if (!exists) return undefined;
|
|
70
|
+
const { data } = await ctx.client.call<{ path: string }, { data: unknown }>(["fs", "read", "json"], { path: configPath });
|
|
71
|
+
const config = (data ?? {}) as Record<string, unknown>;
|
|
72
|
+
const joined = joinGroup(config["fixed"], packageName);
|
|
73
|
+
if (joined === undefined) return undefined;
|
|
74
|
+
const { matches } = await ctx.client.call<{ pattern: string; cwd: string; absolute: boolean }, FsGlobOutput>(
|
|
75
|
+
["fs", "glob"],
|
|
76
|
+
{ pattern: "packages/*/package.json", cwd: rootPath, absolute: true }
|
|
77
|
+
);
|
|
78
|
+
for (const path of matches) {
|
|
79
|
+
const { data: manifest } = await ctx.client.call<{ path: string }, { data: unknown }>(["fs", "read", "json"], { path });
|
|
80
|
+
const { name, version } = (manifest ?? {}) as { name?: unknown; version?: unknown };
|
|
81
|
+
if (name === GROUP_PACKAGE && typeof version === "string") return { configPath, config, joined, version };
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
20
86
|
interface ShellRunOutput {
|
|
21
87
|
exitCode: number;
|
|
22
88
|
stdout: string;
|
|
@@ -188,6 +254,7 @@ export async function libNew(input: LibNewInput, ctx: ProcedureContext): Promise
|
|
|
188
254
|
`Would run cue-config init --preset ${input.preset}`,
|
|
189
255
|
"Would run cue-config generate",
|
|
190
256
|
`Would set the package name to ${packageName}, the exports, the files without the build info of tsc, client.procedures and the client dependency`,
|
|
257
|
+
`Would add ${packageName} to the fixed group of ${GROUP_PACKAGE} in .changeset/config.json, at the version of the group`,
|
|
191
258
|
"Then run pnpm install and pnpm build in the workspace root",
|
|
192
259
|
],
|
|
193
260
|
errors: [],
|
|
@@ -249,10 +316,25 @@ export async function libNew(input: LibNewInput, ctx: ProcedureContext): Promise
|
|
|
249
316
|
"@procedures/client": "workspace:*",
|
|
250
317
|
zod: "^4.6.5",
|
|
251
318
|
};
|
|
319
|
+
|
|
320
|
+
// Step 4: the new package joins the fixed group of the client, at the version of the group.
|
|
321
|
+
// Before, it kept the version of cue (0.1.0), and the package check failed on two versions.
|
|
322
|
+
const group = await groupOf(rootPath, packageName, ctx);
|
|
323
|
+
if (group !== undefined) {
|
|
324
|
+
pkgJson["version"] = group.version;
|
|
325
|
+
operations.push(`Setting the version to ${group.version}, the version of the fixed group of ${GROUP_PACKAGE}`);
|
|
326
|
+
}
|
|
252
327
|
await ctx.client.call<{ path: string; content: string }, { path: string; bytesWritten: number }>(
|
|
253
328
|
["fs", "write"],
|
|
254
329
|
{ path: pkgJsonPath, content: JSON.stringify(pkgJson, null, 2) + "\n" }
|
|
255
330
|
);
|
|
331
|
+
if (group?.joined.changed === true) {
|
|
332
|
+
operations.push(`Adding ${packageName} to the fixed group of ${GROUP_PACKAGE} in .changeset/config.json`);
|
|
333
|
+
await ctx.client.call<{ path: string; content: string }, { path: string; bytesWritten: number }>(
|
|
334
|
+
["fs", "write"],
|
|
335
|
+
{ path: group.configPath, content: JSON.stringify({ ...group.config, fixed: group.joined.fixed }, null, 2) + "\n" }
|
|
336
|
+
);
|
|
337
|
+
}
|
|
256
338
|
operations.push(`Created ${packageName}. Next: run pnpm install and pnpm build in ${rootPath}`);
|
|
257
339
|
} catch (error) {
|
|
258
340
|
errors.push(error instanceof Error ? error.message : String(error));
|
package/src/workspace.ts
CHANGED
|
@@ -7,39 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { existsSync } from "node:fs";
|
|
10
|
-
import { homedir } from "node:os";
|
|
11
10
|
import { dirname, join, resolve } from "node:path";
|
|
12
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { expandHome, findUp } from "@mark1russell7/files";
|
|
13
13
|
import { isMark1Russell7Ref } from "./git/index.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* This function replaces a leading `~` with the home folder: `~`, `~/a` and `~\a`. Its home is
|
|
17
|
+
* `@mark1russell7/files`.
|
|
17
18
|
*/
|
|
18
|
-
export
|
|
19
|
-
if (p === "~") {
|
|
20
|
-
return homedir();
|
|
21
|
-
}
|
|
22
|
-
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
23
|
-
return join(homedir(), p.slice(2));
|
|
24
|
-
}
|
|
25
|
-
return p;
|
|
26
|
-
}
|
|
19
|
+
export { expandHome };
|
|
27
20
|
|
|
28
21
|
/**
|
|
29
22
|
* Find the nearest folder at or above `start` that holds pnpm-workspace.yaml
|
|
30
23
|
*/
|
|
31
24
|
export function findWorkspaceRoot(start: string): string | null {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (existsSync(join(dir, "pnpm-workspace.yaml"))) {
|
|
35
|
-
return dir;
|
|
36
|
-
}
|
|
37
|
-
const parent = dirname(dir);
|
|
38
|
-
if (parent === dir) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
dir = parent;
|
|
42
|
-
}
|
|
25
|
+
const file = findUp("pnpm-workspace.yaml", start);
|
|
26
|
+
return file === null ? null : dirname(file);
|
|
43
27
|
}
|
|
44
28
|
|
|
45
29
|
/**
|