create-gtkx 2.0.0-beta.12 → 2.0.0-beta.14
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/README.md +3 -3
- package/dependency-ranges.json +7 -0
- package/dist/build-allowance.d.ts +43 -2
- package/dist/build-allowance.d.ts.map +1 -1
- package/dist/build-allowance.js +360 -10
- package/dist/build-allowance.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/package-managers.d.ts +6 -0
- package/dist/package-managers.d.ts.map +1 -1
- package/dist/package-managers.js +6 -0
- package/dist/package-managers.js.map +1 -1
- package/dist/project-name.d.ts +4 -2
- package/dist/project-name.d.ts.map +1 -1
- package/dist/project-name.js +12 -2
- package/dist/project-name.js.map +1 -1
- package/dist/scaffolder.d.ts.map +1 -1
- package/dist/scaffolder.js +171 -64
- package/dist/scaffolder.js.map +1 -1
- package/dist/templates/.claude/settings.json.ejs +4 -3
- package/dist/templates/.gitignore.ejs +4 -0
- package/dist/templates/.mcp.json.ejs +1 -1
- package/dist/templates/src/app.tsx.ejs +1 -1
- package/dist/templates/src/gtkx-env.d.ts.ejs +0 -1
- package/dist/templates/tsconfig.json.ejs +4 -2
- package/dist/templates.d.ts +3 -0
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +10 -6
- package/dist/templates.js.map +1 -1
- package/dist/workspace-mcp.d.ts +33 -0
- package/dist/workspace-mcp.d.ts.map +1 -0
- package/dist/workspace-mcp.js +75 -0
- package/dist/workspace-mcp.js.map +1 -0
- package/package.json +11 -7
- package/src/build-allowance.ts +488 -10
- package/src/index.ts +1 -0
- package/src/package-managers.ts +6 -0
- package/src/project-name.ts +19 -2
- package/src/scaffolder.ts +250 -70
- package/src/templates/.claude/settings.json.ejs +4 -3
- package/src/templates/.gitignore.ejs +4 -0
- package/src/templates/.mcp.json.ejs +1 -1
- package/src/templates/src/app.tsx.ejs +1 -1
- package/src/templates/src/gtkx-env.d.ts.ejs +0 -1
- package/src/templates/tsconfig.json.ejs +4 -2
- package/src/templates.ts +17 -8
- package/src/workspace-mcp.ts +111 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# create-gtkx
|
|
2
2
|
|
|
3
|
-
Create native
|
|
3
|
+
Create native GTK and Adwaita apps with React and GTKX.
|
|
4
4
|
|
|
5
5
|
Scaffold an app with TypeScript or JavaScript, an Adwaita window, and optional Vitest support.
|
|
6
6
|
|
|
7
|
-
Start on Linux with Node.js and the [native prerequisites](https://gtkx.dev/v2/guide/getting-started) installed:
|
|
7
|
+
Start on Linux with Node.js and the [native prerequisites](https://gtkx.dev/v2/guide/getting-started#what-you-need) installed:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
npm create gtkx@beta my-app
|
|
@@ -12,7 +12,7 @@ cd my-app
|
|
|
12
12
|
npm run dev
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
For language,
|
|
15
|
+
For the application ID, language, tests, package manager and other options, see [Scaffold Options](https://gtkx.dev/v2/guide/scaffold-options).
|
|
16
16
|
|
|
17
17
|
[Guide](https://gtkx.dev/v2/guide/getting-started) · [GTKX](https://gtkx.dev)
|
|
18
18
|
|
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
import type { PackageManager } from "./package-managers.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type MissingSetting = {
|
|
3
|
+
file: string;
|
|
4
|
+
section: string | null;
|
|
5
|
+
entries: string;
|
|
6
|
+
};
|
|
7
|
+
type Workspace = {
|
|
8
|
+
packageManager: PackageManager;
|
|
9
|
+
root: string;
|
|
10
|
+
member: string;
|
|
11
|
+
missingSettings: MissingSetting[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Configures the package manager to run the build scripts of the scaffold's native dependencies and to exempt
|
|
15
|
+
* GTKX's own packages from its release-age gate, so a project created on the day of a GTKX release installs it.
|
|
16
|
+
* Adds to an existing `pnpm-workspace.yaml`, `.yarnrc.yml` or `.npmrc` instead of replacing it.
|
|
17
|
+
*/
|
|
18
|
+
declare const writePackageManagerSettings: (root: string, packageManager: PackageManager) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Exempts GTKX's own packages from the release-age gate of the package manager that installs the project or
|
|
21
|
+
* workspace at `root`, adding only the entries its `pnpm-workspace.yaml`, `.yarnrc.yml` (Yarn 4.10 or newer)
|
|
22
|
+
* or `.npmrc` lacks and keeping everything else in it, and returns the files it changed.
|
|
23
|
+
*/
|
|
24
|
+
declare const writeReleaseAgeExemptions: (root: string, packageManager: PackageManager) => string[];
|
|
25
|
+
declare const PACKAGE_MANAGER_CONFIG_FILES: Record<PackageManager, string[]>;
|
|
26
|
+
/**
|
|
27
|
+
* The `packageManager` field for the new `package.json`: the existing project's pin when it names
|
|
28
|
+
* `packageManager`, otherwise, outside an enclosing workspace whose root owns the pin, the Yarn 2 or newer
|
|
29
|
+
* release that installs the project.
|
|
30
|
+
*/
|
|
31
|
+
declare const packageManagerPin: (root: string, packageManager: PackageManager, isInWorkspace: boolean) => string | null;
|
|
32
|
+
/**
|
|
33
|
+
* The pnpm, npm or Yarn workspace above `root` that includes it, with the settings its root configuration
|
|
34
|
+
* still lacks for the app, or null when `root` is not part of an enclosing workspace. pnpm reads
|
|
35
|
+
* `allowBuilds` and `minimumReleaseAgeExclude`, npm `allowScripts` and `min-release-age-exclude`, and Yarn
|
|
36
|
+
* `nodeLinker`, `npmPreapprovedPackages` and `dependenciesMeta` only for the whole workspace, from its root.
|
|
37
|
+
*/
|
|
38
|
+
declare const enclosingWorkspace: (root: string, packageManager: PackageManager) => Workspace | null;
|
|
39
|
+
/**
|
|
40
|
+
* Whether `yarn` in the workspace at `root` is Yarn 1, judged by the release it runs there, and Yarn 1 when no
|
|
41
|
+
* release can be determined.
|
|
42
|
+
*/
|
|
43
|
+
declare const isClassicYarn: (root: string) => boolean;
|
|
44
|
+
export { PACKAGE_MANAGER_CONFIG_FILES, enclosingWorkspace, isClassicYarn, packageManagerPin, type Workspace, writePackageManagerSettings, writeReleaseAgeExemptions, };
|
|
4
45
|
//# sourceMappingURL=build-allowance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-allowance.d.ts","sourceRoot":"","sources":["../src/build-allowance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-allowance.d.ts","sourceRoot":"","sources":["../src/build-allowance.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,cAAc,EAAE,CAAC;CACrC,CAAC;AA6MF;;;;GAIG;AACH,QAAA,MAAM,2BAA2B,SAAU,MAAM,kBAAkB,cAAc,KAAG,IAcnF,CAAC;AAWF;;;;GAIG;AACH,QAAA,MAAM,yBAAyB,SAAU,MAAM,kBAAkB,cAAc,KAAG,MAAM,EACjC,CAAC;AAExD,QAAA,MAAM,4BAA4B,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,CAIlE,CAAC;AAsCF;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,SAAU,MAAM,kBAAkB,cAAc,iBAAiB,OAAO,KAAG,MAAM,GAAG,IAEzB,CAAC;AAuKnF;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,SAAU,MAAM,kBAAkB,cAAc,KAAG,SAAS,GAAG,IAkBtF,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,aAAa,SAAU,MAAM,KAAG,OAIrC,CAAC;AAEF,OAAO,EACH,4BAA4B,EAC5B,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,KAAK,SAAS,EACd,2BAA2B,EAC3B,yBAAyB,GAC5B,CAAC"}
|
package/dist/build-allowance.js
CHANGED
|
@@ -1,27 +1,173 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { tryResolveExecutable } from "@gtkx/utils";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { existsSync, lstatSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, matchesGlob, posix, relative, sep } from "node:path";
|
|
5
|
+
import { isMap, isSeq, parse, parseDocument, stringify } from "yaml";
|
|
4
6
|
import { updateManifest } from "./manifest.js";
|
|
5
7
|
const BUILT_DEPENDENCIES = ["@swc/core", "esbuild"];
|
|
8
|
+
const RELEASE_AGE_EXEMPT_PACKAGES = ["@gtkx/*", "create-gtkx"];
|
|
9
|
+
const YARN_NODE_LINKER = "node-modules";
|
|
6
10
|
const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
11
|
+
const YARN_CONFIG_FILE = ".yarnrc.yml";
|
|
12
|
+
const NPM_CONFIG_FILE = ".npmrc";
|
|
13
|
+
const PACKAGE_JSON_FILE = "package.json";
|
|
14
|
+
const PNPM_RELEASE_AGE_EXCLUDE = "minimumReleaseAgeExclude";
|
|
15
|
+
const YARN_PREAPPROVED_PACKAGES = "npmPreapprovedPackages";
|
|
16
|
+
const NPM_RELEASE_AGE_EXCLUDE = "min-release-age-exclude[]";
|
|
17
|
+
const NPM_RELEASE_AGE_EXCLUDE_PATTERN = /^\s*min-release-age-exclude(?:\[\])?\s*=\s*(["']?)(.*?)\1\s*$/;
|
|
18
|
+
const NEGATION_PREFIX = "!";
|
|
19
|
+
const YARN_USER_AGENT_PATTERN = /^yarn\/(\d+\.\d+\.\d+\S*)/;
|
|
20
|
+
const FIRST_PINNED_YARN_MAJOR = 2;
|
|
21
|
+
const YARN_PIN_PREFIX = "yarn@";
|
|
22
|
+
const YARN_RELEASE_PATTERN = /^(\d+)\.(\d+)\./;
|
|
23
|
+
const FIRST_PREAPPROVING_YARN = { major: 4, minor: 10 };
|
|
24
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
+
const readSettings = (path, read) => {
|
|
26
|
+
try {
|
|
27
|
+
return read(readFileSync(path, "utf8"));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Writes `contents` to a new file at `path` in place of a file or symlink there, keeping the permissions of a
|
|
35
|
+
* replaced file, such as a private `.npmrc` that holds registry credentials.
|
|
36
|
+
*/
|
|
37
|
+
const replaceFile = (path, contents) => {
|
|
38
|
+
const replaced = lstatSync(path, { throwIfNoEntry: false });
|
|
39
|
+
rmSync(path, { force: true });
|
|
40
|
+
writeFileSync(path, contents, { mode: replaced?.isFile() ? replaced.mode & 0o777 : undefined });
|
|
41
|
+
};
|
|
42
|
+
const updateYamlFile = (path, update) => {
|
|
43
|
+
const document = parseDocument(existsSync(path) ? readFileSync(path, "utf8") : "");
|
|
44
|
+
update(document);
|
|
45
|
+
replaceFile(path, document.toString());
|
|
46
|
+
};
|
|
47
|
+
const missingExemptions = (exempted) => RELEASE_AGE_EXEMPT_PACKAGES.filter((name) => !Array.isArray(exempted) || !exempted.includes(name));
|
|
48
|
+
const addReleaseAgeExemptions = (document, key) => {
|
|
49
|
+
const current = document.get(key);
|
|
50
|
+
const missing = missingExemptions(isSeq(current) ? current.toJSON() : []);
|
|
51
|
+
if (!isSeq(current)) {
|
|
52
|
+
document.set(key, document.createNode([]));
|
|
53
|
+
}
|
|
54
|
+
for (const name of missing) {
|
|
55
|
+
document.addIn([key], name);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const npmExemptions = (source) => source.split(/\r?\n/).flatMap((line) => {
|
|
59
|
+
const value = NPM_RELEASE_AGE_EXCLUDE_PATTERN.exec(line)?.[2];
|
|
60
|
+
return value === undefined ? [] : [value];
|
|
61
|
+
});
|
|
62
|
+
const npmExemptionLines = (names) => names.map((name) => `${NPM_RELEASE_AGE_EXCLUDE}=${name}`).join("\n");
|
|
63
|
+
const writeNpmExemptions = (root) => {
|
|
64
|
+
const path = join(root, NPM_CONFIG_FILE);
|
|
65
|
+
const source = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
66
|
+
const missing = missingExemptions(npmExemptions(source));
|
|
67
|
+
if (missing.length === 0) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const separator = source === "" || source.endsWith("\n") ? "" : "\n";
|
|
71
|
+
replaceFile(path, `${source}${separator}${npmExemptionLines(missing)}\n`);
|
|
72
|
+
return [path];
|
|
73
|
+
};
|
|
74
|
+
const writeYamlExemptions = (path, key) => {
|
|
75
|
+
const settings = readSettings(path, parse);
|
|
76
|
+
if (missingExemptions(isRecord(settings) ? settings[key] : undefined).length === 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
updateYamlFile(path, (document) => addReleaseAgeExemptions(document, key));
|
|
80
|
+
return [path];
|
|
81
|
+
};
|
|
82
|
+
const reportedYarnRelease = (root) => {
|
|
83
|
+
const corepack = tryResolveExecutable("corepack");
|
|
84
|
+
const command = corepack ?? tryResolveExecutable("yarn");
|
|
85
|
+
if (command === undefined) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return execFileSync(command, corepack === undefined ? ["--version"] : ["yarn", "--version"], {
|
|
90
|
+
cwd: root,
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
93
|
+
}).trim();
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The Yarn release that installs a project without a pin at `root`: the Yarn running the scaffold, otherwise the
|
|
101
|
+
* one `yarn --version` reports there through Corepack.
|
|
102
|
+
*/
|
|
103
|
+
const installingYarnRelease = (root) => YARN_USER_AGENT_PATTERN.exec(process.env.npm_config_user_agent ?? "")?.[1] ?? reportedYarnRelease(root);
|
|
104
|
+
/**
|
|
105
|
+
* The Yarn release that `yarn` runs in the project or workspace at `root`: the one `yarn --version` reports
|
|
106
|
+
* there when its `.yarnrc.yml` sets `yarnPath`, which overrides a pin, otherwise the release its
|
|
107
|
+
* `packageManager` field pins, otherwise the Yarn running the scaffold, otherwise the one `yarn --version`
|
|
108
|
+
* reports there through Corepack.
|
|
109
|
+
*/
|
|
110
|
+
const yarnRelease = (root) => {
|
|
111
|
+
const settings = readSettings(join(root, YARN_CONFIG_FILE), parse);
|
|
112
|
+
if (isRecord(settings) && typeof settings.yarnPath === "string") {
|
|
113
|
+
return reportedYarnRelease(root);
|
|
114
|
+
}
|
|
115
|
+
const manifest = readSettings(join(root, PACKAGE_JSON_FILE), JSON.parse);
|
|
116
|
+
const pin = isRecord(manifest) && typeof manifest.packageManager === "string" ? manifest.packageManager : "";
|
|
117
|
+
if (pin.startsWith(YARN_PIN_PREFIX)) {
|
|
118
|
+
return pin.slice(YARN_PIN_PREFIX.length);
|
|
119
|
+
}
|
|
120
|
+
return installingYarnRelease(root);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Whether the Yarn installing the project at `root` reads `npmPreapprovedPackages`. Yarn 4.10 added it next to
|
|
124
|
+
* its release-age gate, and older releases refuse to run with a setting they do not know.
|
|
125
|
+
*/
|
|
126
|
+
const readsPreapprovedPackages = (root) => {
|
|
127
|
+
const matched = YARN_RELEASE_PATTERN.exec(yarnRelease(root) ?? "");
|
|
128
|
+
const major = Number(matched?.[1]);
|
|
129
|
+
const minor = Number(matched?.[2]);
|
|
130
|
+
return (major > FIRST_PREAPPROVING_YARN.major ||
|
|
131
|
+
(major === FIRST_PREAPPROVING_YARN.major && minor >= FIRST_PREAPPROVING_YARN.minor));
|
|
132
|
+
};
|
|
7
133
|
const writePnpmAllowance = (root) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
134
|
+
updateYamlFile(join(root, PNPM_WORKSPACE_FILE), (document) => {
|
|
135
|
+
if (!document.has("packages")) {
|
|
136
|
+
document.set("packages", document.createNode(["."]));
|
|
137
|
+
}
|
|
138
|
+
if (!isMap(document.get("allowBuilds"))) {
|
|
139
|
+
document.set("allowBuilds", document.createNode({}));
|
|
140
|
+
}
|
|
141
|
+
for (const name of BUILT_DEPENDENCIES) {
|
|
142
|
+
document.setIn(["allowBuilds", name], true);
|
|
143
|
+
}
|
|
144
|
+
addReleaseAgeExemptions(document, PNPM_RELEASE_AGE_EXCLUDE);
|
|
145
|
+
});
|
|
13
146
|
};
|
|
14
147
|
const writeNpmAllowance = (root) => {
|
|
15
148
|
updateManifest(root, (manifest) => {
|
|
16
149
|
manifest.allowScripts = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, true]));
|
|
17
150
|
});
|
|
151
|
+
writeNpmExemptions(root);
|
|
18
152
|
};
|
|
19
153
|
const writeYarnAllowance = (root) => {
|
|
154
|
+
const isPreapproving = readsPreapprovedPackages(root);
|
|
155
|
+
updateYamlFile(join(root, YARN_CONFIG_FILE), (document) => {
|
|
156
|
+
document.set("nodeLinker", YARN_NODE_LINKER);
|
|
157
|
+
if (isPreapproving) {
|
|
158
|
+
addReleaseAgeExemptions(document, YARN_PREAPPROVED_PACKAGES);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
20
161
|
updateManifest(root, (manifest) => {
|
|
21
162
|
manifest.dependenciesMeta = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, { built: true }]));
|
|
22
163
|
});
|
|
23
164
|
};
|
|
24
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Configures the package manager to run the build scripts of the scaffold's native dependencies and to exempt
|
|
167
|
+
* GTKX's own packages from its release-age gate, so a project created on the day of a GTKX release installs it.
|
|
168
|
+
* Adds to an existing `pnpm-workspace.yaml`, `.yarnrc.yml` or `.npmrc` instead of replacing it.
|
|
169
|
+
*/
|
|
170
|
+
const writePackageManagerSettings = (root, packageManager) => {
|
|
25
171
|
if (packageManager === "pnpm") {
|
|
26
172
|
writePnpmAllowance(root);
|
|
27
173
|
return;
|
|
@@ -32,5 +178,209 @@ const writeBuildAllowance = (root, packageManager) => {
|
|
|
32
178
|
}
|
|
33
179
|
writeNpmAllowance(root);
|
|
34
180
|
};
|
|
35
|
-
|
|
181
|
+
const RELEASE_AGE_EXEMPTION_WRITERS = {
|
|
182
|
+
pnpm: (root) => writeYamlExemptions(join(root, PNPM_WORKSPACE_FILE), PNPM_RELEASE_AGE_EXCLUDE),
|
|
183
|
+
yarn: (root) => readsPreapprovedPackages(root)
|
|
184
|
+
? writeYamlExemptions(join(root, YARN_CONFIG_FILE), YARN_PREAPPROVED_PACKAGES)
|
|
185
|
+
: [],
|
|
186
|
+
npm: writeNpmExemptions,
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Exempts GTKX's own packages from the release-age gate of the package manager that installs the project or
|
|
190
|
+
* workspace at `root`, adding only the entries its `pnpm-workspace.yaml`, `.yarnrc.yml` (Yarn 4.10 or newer)
|
|
191
|
+
* or `.npmrc` lacks and keeping everything else in it, and returns the files it changed.
|
|
192
|
+
*/
|
|
193
|
+
const writeReleaseAgeExemptions = (root, packageManager) => RELEASE_AGE_EXEMPTION_WRITERS[packageManager](root);
|
|
194
|
+
const PACKAGE_MANAGER_CONFIG_FILES = {
|
|
195
|
+
pnpm: [PNPM_WORKSPACE_FILE],
|
|
196
|
+
yarn: [YARN_CONFIG_FILE],
|
|
197
|
+
npm: [NPM_CONFIG_FILE],
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* The `packageManager` field of the project's existing `package.json` when it names `packageManager`, so
|
|
201
|
+
* replacing the manifest keeps the version the project pins.
|
|
202
|
+
*/
|
|
203
|
+
const pinnedPackageManager = (root, packageManager) => {
|
|
204
|
+
const path = join(root, PACKAGE_JSON_FILE);
|
|
205
|
+
if (!existsSync(path)) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
210
|
+
const pin = isRecord(manifest) ? manifest.packageManager : undefined;
|
|
211
|
+
return typeof pin === "string" && pin.startsWith(`${packageManager}@`) ? pin : null;
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const nearestDirectory = (path) => existsSync(path) || dirname(path) === path ? path : nearestDirectory(dirname(path));
|
|
218
|
+
/**
|
|
219
|
+
* The `packageManager` pin for the Yarn 2 or newer release that installs a new project at `root`, as
|
|
220
|
+
* `yarn init -2` writes it, or null when that is Yarn 1. The project may not exist yet, so Corepack is asked in
|
|
221
|
+
* its nearest existing directory, which resolves the same release for a project without a pin.
|
|
222
|
+
*/
|
|
223
|
+
const installingYarnPin = (root) => {
|
|
224
|
+
const release = installingYarnRelease(nearestDirectory(root));
|
|
225
|
+
const major = Number(YARN_RELEASE_PATTERN.exec(release ?? "")?.[1]);
|
|
226
|
+
return release !== null && major >= FIRST_PINNED_YARN_MAJOR ? `${YARN_PIN_PREFIX}${release}` : null;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* The `packageManager` field for the new `package.json`: the existing project's pin when it names
|
|
230
|
+
* `packageManager`, otherwise, outside an enclosing workspace whose root owns the pin, the Yarn 2 or newer
|
|
231
|
+
* release that installs the project.
|
|
232
|
+
*/
|
|
233
|
+
const packageManagerPin = (root, packageManager, isInWorkspace) => pinnedPackageManager(root, packageManager) ??
|
|
234
|
+
(packageManager === "yarn" && !isInWorkspace ? installingYarnPin(root) : null);
|
|
235
|
+
/**
|
|
236
|
+
* The workspace globs of `field`, given as a list or, as npm and Yarn also accept, as an object with a
|
|
237
|
+
* `packages` list.
|
|
238
|
+
*/
|
|
239
|
+
const workspacePatterns = (settings, field) => {
|
|
240
|
+
const value = isRecord(settings) ? settings[field] : undefined;
|
|
241
|
+
const patterns = isRecord(value) ? value.packages : value;
|
|
242
|
+
return Array.isArray(patterns) ? patterns.filter((pattern) => typeof pattern === "string") : [];
|
|
243
|
+
};
|
|
244
|
+
const matchesWorkspacePattern = (project, pattern) => matchesGlob(project, posix.normalize(pattern).replace(/\/+$/, ""));
|
|
245
|
+
const includesProject = (patterns, project) => patterns.some((pattern) => !pattern.startsWith(NEGATION_PREFIX) && matchesWorkspacePattern(project, pattern)) &&
|
|
246
|
+
!patterns.some((pattern) => pattern.startsWith(NEGATION_PREFIX) &&
|
|
247
|
+
matchesWorkspacePattern(project, pattern.slice(NEGATION_PREFIX.length)));
|
|
248
|
+
const ancestorFiles = (root, name) => {
|
|
249
|
+
const files = [];
|
|
250
|
+
for (let directory = dirname(root);; directory = dirname(directory)) {
|
|
251
|
+
const file = join(directory, name);
|
|
252
|
+
if (existsSync(file)) {
|
|
253
|
+
files.push(file);
|
|
254
|
+
}
|
|
255
|
+
if (dirname(directory) === directory) {
|
|
256
|
+
return files;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const projectPath = (file, root) => relative(dirname(file), root).split(sep).join(posix.sep);
|
|
261
|
+
const recordField = (settings, field) => isRecord(settings) && isRecord(settings[field]) ? settings[field] : {};
|
|
262
|
+
const missingBuilds = (allowances) => BUILT_DEPENDENCIES.filter((name) => !Object.hasOwn(allowances, name));
|
|
263
|
+
const settingsToAdd = (settings) => settings.filter((setting) => setting !== null);
|
|
264
|
+
const missingYamlExemptions = (file, settings, key) => {
|
|
265
|
+
const listed = isRecord(settings) ? settings[key] : undefined;
|
|
266
|
+
const missing = missingExemptions(listed);
|
|
267
|
+
if (missing.length === 0) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
return Array.isArray(listed)
|
|
271
|
+
? { file, section: key, entries: stringify(missing).trimEnd().replace(/^/gm, " ") }
|
|
272
|
+
: { file, section: null, entries: stringify({ [key]: missing }).trimEnd() };
|
|
273
|
+
};
|
|
274
|
+
const pnpmWorkspaceAt = (file, project) => {
|
|
275
|
+
const settings = parse(readFileSync(file, "utf8"));
|
|
276
|
+
if (!includesProject(workspacePatterns(settings, "packages"), project)) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
const allowances = recordField(settings, "allowBuilds");
|
|
280
|
+
const missing = BUILT_DEPENDENCIES.filter((name) => typeof allowances[name] !== "boolean");
|
|
281
|
+
const required = Object.fromEntries(missing.map((name) => [name, true]));
|
|
282
|
+
const setting = isRecord(settings) && isRecord(settings.allowBuilds)
|
|
283
|
+
? { file, section: "allowBuilds", entries: stringify(required).trimEnd().replace(/^/gm, " ") }
|
|
284
|
+
: { file, section: null, entries: stringify({ allowBuilds: required }).trimEnd() };
|
|
285
|
+
return {
|
|
286
|
+
packageManager: "pnpm",
|
|
287
|
+
root: dirname(file),
|
|
288
|
+
member: project,
|
|
289
|
+
missingSettings: settingsToAdd([
|
|
290
|
+
missing.length > 0 ? setting : null,
|
|
291
|
+
missingYamlExemptions(file, settings, PNPM_RELEASE_AGE_EXCLUDE),
|
|
292
|
+
]),
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
const npmWorkspaceAt = (file, project) => {
|
|
296
|
+
const manifest = JSON.parse(readFileSync(file, "utf8"));
|
|
297
|
+
if (!includesProject(workspacePatterns(manifest, "workspaces"), project)) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const missing = missingBuilds(recordField(manifest, "allowScripts"));
|
|
301
|
+
const entries = `"allowScripts": ${JSON.stringify(Object.fromEntries(missing.map((name) => [name, true])), null, 4)}`;
|
|
302
|
+
const configFile = join(dirname(file), NPM_CONFIG_FILE);
|
|
303
|
+
const exemptions = missingExemptions(npmExemptions(existsSync(configFile) ? readFileSync(configFile, "utf8") : ""));
|
|
304
|
+
return {
|
|
305
|
+
packageManager: "npm",
|
|
306
|
+
root: dirname(file),
|
|
307
|
+
member: project,
|
|
308
|
+
missingSettings: settingsToAdd([
|
|
309
|
+
missing.length > 0 ? { file, section: null, entries } : null,
|
|
310
|
+
exemptions.length > 0 ? { file: configFile, section: null, entries: npmExemptionLines(exemptions) } : null,
|
|
311
|
+
]),
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* The `nodeLinker` Yarn applies in `directory`: Yarn merges the `.yarnrc.yml` files of a project and its
|
|
316
|
+
* ancestors, and the closest one that sets a value wins.
|
|
317
|
+
*/
|
|
318
|
+
const yarnNodeLinker = (directory) => {
|
|
319
|
+
for (const file of [join(directory, YARN_CONFIG_FILE), ...ancestorFiles(directory, YARN_CONFIG_FILE)]) {
|
|
320
|
+
const settings = existsSync(file) ? parse(readFileSync(file, "utf8")) : undefined;
|
|
321
|
+
if (isRecord(settings) && Object.hasOwn(settings, "nodeLinker")) {
|
|
322
|
+
return settings.nodeLinker;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return undefined;
|
|
326
|
+
};
|
|
327
|
+
const yarnWorkspaceAt = (file, project) => {
|
|
328
|
+
const manifest = JSON.parse(readFileSync(file, "utf8"));
|
|
329
|
+
if (!includesProject(workspacePatterns(manifest, "workspaces"), project)) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
const missing = missingBuilds(recordField(manifest, "dependenciesMeta"));
|
|
333
|
+
const dependenciesMeta = Object.fromEntries(missing.map((name) => [name, { built: true }]));
|
|
334
|
+
const configFile = join(dirname(file), YARN_CONFIG_FILE);
|
|
335
|
+
const exemptions = readsPreapprovedPackages(dirname(file))
|
|
336
|
+
? missingYamlExemptions(configFile, readSettings(configFile, parse), YARN_PREAPPROVED_PACKAGES)
|
|
337
|
+
: null;
|
|
338
|
+
return {
|
|
339
|
+
packageManager: "yarn",
|
|
340
|
+
root: dirname(file),
|
|
341
|
+
member: project,
|
|
342
|
+
missingSettings: settingsToAdd([
|
|
343
|
+
yarnNodeLinker(dirname(file)) === YARN_NODE_LINKER
|
|
344
|
+
? null
|
|
345
|
+
: { file: configFile, section: null, entries: stringify({ nodeLinker: YARN_NODE_LINKER }).trimEnd() },
|
|
346
|
+
missing.length > 0
|
|
347
|
+
? { file, section: null, entries: `"dependenciesMeta": ${JSON.stringify(dependenciesMeta, null, 4)}` }
|
|
348
|
+
: null,
|
|
349
|
+
exemptions,
|
|
350
|
+
]),
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
const MANIFEST_WORKSPACES = {
|
|
354
|
+
npm: npmWorkspaceAt,
|
|
355
|
+
yarn: yarnWorkspaceAt,
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* The pnpm, npm or Yarn workspace above `root` that includes it, with the settings its root configuration
|
|
359
|
+
* still lacks for the app, or null when `root` is not part of an enclosing workspace. pnpm reads
|
|
360
|
+
* `allowBuilds` and `minimumReleaseAgeExclude`, npm `allowScripts` and `min-release-age-exclude`, and Yarn
|
|
361
|
+
* `nodeLinker`, `npmPreapprovedPackages` and `dependenciesMeta` only for the whole workspace, from its root.
|
|
362
|
+
*/
|
|
363
|
+
const enclosingWorkspace = (root, packageManager) => {
|
|
364
|
+
if (packageManager === "pnpm") {
|
|
365
|
+
const [nearest] = ancestorFiles(root, PNPM_WORKSPACE_FILE);
|
|
366
|
+
return nearest === undefined ? null : pnpmWorkspaceAt(nearest, projectPath(nearest, root));
|
|
367
|
+
}
|
|
368
|
+
const workspaceAt = MANIFEST_WORKSPACES[packageManager];
|
|
369
|
+
for (const file of ancestorFiles(root, PACKAGE_JSON_FILE)) {
|
|
370
|
+
const workspace = workspaceAt(file, projectPath(file, root));
|
|
371
|
+
if (workspace !== null) {
|
|
372
|
+
return workspace;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* Whether `yarn` in the workspace at `root` is Yarn 1, judged by the release it runs there, and Yarn 1 when no
|
|
379
|
+
* release can be determined.
|
|
380
|
+
*/
|
|
381
|
+
const isClassicYarn = (root) => {
|
|
382
|
+
const major = Number(YARN_RELEASE_PATTERN.exec(yarnRelease(root) ?? "")?.[1]);
|
|
383
|
+
return Number.isNaN(major) || major < FIRST_PINNED_YARN_MAJOR;
|
|
384
|
+
};
|
|
385
|
+
export { PACKAGE_MANAGER_CONFIG_FILES, enclosingWorkspace, isClassicYarn, packageManagerPin, writePackageManagerSettings, writeReleaseAgeExemptions, };
|
|
36
386
|
//# sourceMappingURL=build-allowance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-allowance.js","sourceRoot":"","sources":["../src/build-allowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACpD,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAClD,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC9C,MAAM,SAAS,GAAG;QACd,QAAQ,EAAE,CAAC,GAAG,CAAC;QACf,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;KAClF,CAAC;IACF,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC7C,cAAc,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC9B,QAAQ,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC9C,cAAc,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC9B,QAAQ,CAAC,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,cAA8B,EAAQ,EAAE;IAC/E,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;QAC5B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAEzB,OAAO;IACX,CAAC;IAED,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;QAC5B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAEzB,OAAO;IACX,CAAC;IAED,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { stringify } from \"yaml\";\nimport type { PackageManager } from \"./package-managers.js\";\nimport { updateManifest } from \"./manifest.js\";\n\nconst BUILT_DEPENDENCIES = [\"@swc/core\", \"esbuild\"];\nconst PNPM_WORKSPACE_FILE = \"pnpm-workspace.yaml\";\nconst writePnpmAllowance = (root: string): void => {\n const workspace = {\n packages: [\".\"],\n allowBuilds: Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, true])),\n };\n writeFileSync(join(root, PNPM_WORKSPACE_FILE), stringify(workspace));\n};\n\nconst writeNpmAllowance = (root: string): void => {\n updateManifest(root, (manifest) => {\n manifest.allowScripts = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, true]));\n });\n};\n\nconst writeYarnAllowance = (root: string): void => {\n updateManifest(root, (manifest) => {\n manifest.dependenciesMeta = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, { built: true }]));\n });\n};\n\nconst writeBuildAllowance = (root: string, packageManager: PackageManager): void => {\n if (packageManager === \"pnpm\") {\n writePnpmAllowance(root);\n\n return;\n }\n\n if (packageManager === \"yarn\") {\n writeYarnAllowance(root);\n\n return;\n }\n\n writeNpmAllowance(root);\n};\n\nexport { writeBuildAllowance };\n"]}
|
|
1
|
+
{"version":3,"file":"build-allowance.js","sourceRoot":"","sources":["../src/build-allowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAiB,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAe/C,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACpD,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAC/D,MAAM,gBAAgB,GAAG,cAAc,CAAC;AACxC,MAAM,mBAAmB,GAAG,qB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,CAAC,CAAC,CAAC;IAE9E,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,uBAAuB,CAAC;AAClE,CAAC,CAAC;AAEF,OAAO,EACH,4BAA4B,EAC5B,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAEjB,2BAA2B,EAC3B,yBAAyB,GAC5B,CAAC","sourcesContent":["import { tryResolveExecutable } from \"@gtkx/utils\";\nimport { execFileSync } from \"node:child_process\";\nimport { existsSync, lstatSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, matchesGlob, posix, relative, sep } from \"node:path\";\nimport { type Document, isMap, isSeq, parse, parseDocument, stringify } from \"yaml\";\nimport type { PackageManager } from \"./package-managers.js\";\nimport { updateManifest } from \"./manifest.js\";\n\ntype MissingSetting = {\n file: string;\n section: string | null;\n entries: string;\n};\n\ntype Workspace = {\n packageManager: PackageManager;\n root: string;\n member: string;\n missingSettings: MissingSetting[];\n};\n\nconst BUILT_DEPENDENCIES = [\"@swc/core\", \"esbuild\"];\nconst RELEASE_AGE_EXEMPT_PACKAGES = [\"@gtkx/*\", \"create-gtkx\"];\nconst YARN_NODE_LINKER = \"node-modules\";\nconst PNPM_WORKSPACE_FILE = \"pnpm-workspace.yaml\";\nconst YARN_CONFIG_FILE = \".yarnrc.yml\";\nconst NPM_CONFIG_FILE = \".npmrc\";\nconst PACKAGE_JSON_FILE = \"package.json\";\nconst PNPM_RELEASE_AGE_EXCLUDE = \"minimumReleaseAgeExclude\";\nconst YARN_PREAPPROVED_PACKAGES = \"npmPreapprovedPackages\";\nconst NPM_RELEASE_AGE_EXCLUDE = \"min-release-age-exclude[]\";\nconst NPM_RELEASE_AGE_EXCLUDE_PATTERN = /^\\s*min-release-age-exclude(?:\\[\\])?\\s*=\\s*([\"']?)(.*?)\\1\\s*$/;\nconst NEGATION_PREFIX = \"!\";\nconst YARN_USER_AGENT_PATTERN = /^yarn\\/(\\d+\\.\\d+\\.\\d+\\S*)/;\nconst FIRST_PINNED_YARN_MAJOR = 2;\nconst YARN_PIN_PREFIX = \"yarn@\";\nconst YARN_RELEASE_PATTERN = /^(\\d+)\\.(\\d+)\\./;\nconst FIRST_PREAPPROVING_YARN = { major: 4, minor: 10 };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst readSettings = (path: string, read: (source: string) => unknown): unknown => {\n try {\n return read(readFileSync(path, \"utf8\"));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Writes `contents` to a new file at `path` in place of a file or symlink there, keeping the permissions of a\n * replaced file, such as a private `.npmrc` that holds registry credentials.\n */\nconst replaceFile = (path: string, contents: string): void => {\n const replaced = lstatSync(path, { throwIfNoEntry: false });\n\n rmSync(path, { force: true });\n writeFileSync(path, contents, { mode: replaced?.isFile() ? replaced.mode & 0o777 : undefined });\n};\n\nconst updateYamlFile = (path: string, update: (document: Document) => void): void => {\n const document = parseDocument(existsSync(path) ? readFileSync(path, \"utf8\") : \"\");\n update(document);\n replaceFile(path, document.toString());\n};\n\nconst missingExemptions = (exempted: unknown): string[] =>\n RELEASE_AGE_EXEMPT_PACKAGES.filter((name) => !Array.isArray(exempted) || !exempted.includes(name));\n\nconst addReleaseAgeExemptions = (document: Document, key: string): void => {\n const current = document.get(key);\n const missing = missingExemptions(isSeq(current) ? current.toJSON() : []);\n\n if (!isSeq(current)) {\n document.set(key, document.createNode([]));\n }\n\n for (const name of missing) {\n document.addIn([key], name);\n }\n};\n\nconst npmExemptions = (source: string): string[] =>\n source.split(/\\r?\\n/).flatMap((line) => {\n const value = NPM_RELEASE_AGE_EXCLUDE_PATTERN.exec(line)?.[2];\n\n return value === undefined ? [] : [value];\n });\n\nconst npmExemptionLines = (names: string[]): string =>\n names.map((name) => `${NPM_RELEASE_AGE_EXCLUDE}=${name}`).join(\"\\n\");\n\nconst writeNpmExemptions = (root: string): string[] => {\n const path = join(root, NPM_CONFIG_FILE);\n const source = existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n const missing = missingExemptions(npmExemptions(source));\n\n if (missing.length === 0) {\n return [];\n }\n\n const separator = source === \"\" || source.endsWith(\"\\n\") ? \"\" : \"\\n\";\n replaceFile(path, `${source}${separator}${npmExemptionLines(missing)}\\n`);\n\n return [path];\n};\n\nconst writeYamlExemptions = (path: string, key: string): string[] => {\n const settings = readSettings(path, parse);\n\n if (missingExemptions(isRecord(settings) ? settings[key] : undefined).length === 0) {\n return [];\n }\n\n updateYamlFile(path, (document) => addReleaseAgeExemptions(document, key));\n\n return [path];\n};\n\nconst reportedYarnRelease = (root: string): string | null => {\n const corepack = tryResolveExecutable(\"corepack\");\n const command = corepack ?? tryResolveExecutable(\"yarn\");\n\n if (command === undefined) {\n return null;\n }\n\n try {\n return execFileSync(command, corepack === undefined ? [\"--version\"] : [\"yarn\", \"--version\"], {\n cwd: root,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n } catch {\n return null;\n }\n};\n\n/**\n * The Yarn release that installs a project without a pin at `root`: the Yarn running the scaffold, otherwise the\n * one `yarn --version` reports there through Corepack.\n */\nconst installingYarnRelease = (root: string): string | null =>\n YARN_USER_AGENT_PATTERN.exec(process.env.npm_config_user_agent ?? \"\")?.[1] ?? reportedYarnRelease(root);\n\n/**\n * The Yarn release that `yarn` runs in the project or workspace at `root`: the one `yarn --version` reports\n * there when its `.yarnrc.yml` sets `yarnPath`, which overrides a pin, otherwise the release its\n * `packageManager` field pins, otherwise the Yarn running the scaffold, otherwise the one `yarn --version`\n * reports there through Corepack.\n */\nconst yarnRelease = (root: string): string | null => {\n const settings = readSettings(join(root, YARN_CONFIG_FILE), parse);\n\n if (isRecord(settings) && typeof settings.yarnPath === \"string\") {\n return reportedYarnRelease(root);\n }\n\n const manifest = readSettings(join(root, PACKAGE_JSON_FILE), JSON.parse);\n const pin = isRecord(manifest) && typeof manifest.packageManager === \"string\" ? manifest.packageManager : \"\";\n\n if (pin.startsWith(YARN_PIN_PREFIX)) {\n return pin.slice(YARN_PIN_PREFIX.length);\n }\n\n return installingYarnRelease(root);\n};\n\n/**\n * Whether the Yarn installing the project at `root` reads `npmPreapprovedPackages`. Yarn 4.10 added it next to\n * its release-age gate, and older releases refuse to run with a setting they do not know.\n */\nconst readsPreapprovedPackages = (root: string): boolean => {\n const matched = YARN_RELEASE_PATTERN.exec(yarnRelease(root) ?? \"\");\n const major = Number(matched?.[1]);\n const minor = Number(matched?.[2]);\n\n return (\n major > FIRST_PREAPPROVING_YARN.major ||\n (major === FIRST_PREAPPROVING_YARN.major && minor >= FIRST_PREAPPROVING_YARN.minor)\n );\n};\n\nconst writePnpmAllowance = (root: string): void => {\n updateYamlFile(join(root, PNPM_WORKSPACE_FILE), (document) => {\n if (!document.has(\"packages\")) {\n document.set(\"packages\", document.createNode([\".\"]));\n }\n\n if (!isMap(document.get(\"allowBuilds\"))) {\n document.set(\"allowBuilds\", document.createNode({}));\n }\n\n for (const name of BUILT_DEPENDENCIES) {\n document.setIn([\"allowBuilds\", name], true);\n }\n\n addReleaseAgeExemptions(document, PNPM_RELEASE_AGE_EXCLUDE);\n });\n};\n\nconst writeNpmAllowance = (root: string): void => {\n updateManifest(root, (manifest) => {\n manifest.allowScripts = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, true]));\n });\n writeNpmExemptions(root);\n};\n\nconst writeYarnAllowance = (root: string): void => {\n const isPreapproving = readsPreapprovedPackages(root);\n\n updateYamlFile(join(root, YARN_CONFIG_FILE), (document) => {\n document.set(\"nodeLinker\", YARN_NODE_LINKER);\n\n if (isPreapproving) {\n addReleaseAgeExemptions(document, YARN_PREAPPROVED_PACKAGES);\n }\n });\n updateManifest(root, (manifest) => {\n manifest.dependenciesMeta = Object.fromEntries(BUILT_DEPENDENCIES.map((name) => [name, { built: true }]));\n });\n};\n\n/**\n * Configures the package manager to run the build scripts of the scaffold's native dependencies and to exempt\n * GTKX's own packages from its release-age gate, so a project created on the day of a GTKX release installs it.\n * Adds to an existing `pnpm-workspace.yaml`, `.yarnrc.yml` or `.npmrc` instead of replacing it.\n */\nconst writePackageManagerSettings = (root: string, packageManager: PackageManager): void => {\n if (packageManager === \"pnpm\") {\n writePnpmAllowance(root);\n\n return;\n }\n\n if (packageManager === \"yarn\") {\n writeYarnAllowance(root);\n\n return;\n }\n\n writeNpmAllowance(root);\n};\n\nconst RELEASE_AGE_EXEMPTION_WRITERS: Record<PackageManager, (root: string) => string[]> = {\n pnpm: (root) => writeYamlExemptions(join(root, PNPM_WORKSPACE_FILE), PNPM_RELEASE_AGE_EXCLUDE),\n yarn: (root) =>\n readsPreapprovedPackages(root)\n ? writeYamlExemptions(join(root, YARN_CONFIG_FILE), YARN_PREAPPROVED_PACKAGES)\n : [],\n npm: writeNpmExemptions,\n};\n\n/**\n * Exempts GTKX's own packages from the release-age gate of the package manager that installs the project or\n * workspace at `root`, adding only the entries its `pnpm-workspace.yaml`, `.yarnrc.yml` (Yarn 4.10 or newer)\n * or `.npmrc` lacks and keeping everything else in it, and returns the files it changed.\n */\nconst writeReleaseAgeExemptions = (root: string, packageManager: PackageManager): string[] =>\n RELEASE_AGE_EXEMPTION_WRITERS[packageManager](root);\n\nconst PACKAGE_MANAGER_CONFIG_FILES: Record<PackageManager, string[]> = {\n pnpm: [PNPM_WORKSPACE_FILE],\n yarn: [YARN_CONFIG_FILE],\n npm: [NPM_CONFIG_FILE],\n};\n\n/**\n * The `packageManager` field of the project's existing `package.json` when it names `packageManager`, so\n * replacing the manifest keeps the version the project pins.\n */\nconst pinnedPackageManager = (root: string, packageManager: PackageManager): string | null => {\n const path = join(root, PACKAGE_JSON_FILE);\n\n if (!existsSync(path)) {\n return null;\n }\n\n try {\n const manifest: unknown = JSON.parse(readFileSync(path, \"utf8\"));\n const pin = isRecord(manifest) ? manifest.packageManager : undefined;\n\n return typeof pin === \"string\" && pin.startsWith(`${packageManager}@`) ? pin : null;\n } catch {\n return null;\n }\n};\n\nconst nearestDirectory = (path: string): string =>\n existsSync(path) || dirname(path) === path ? path : nearestDirectory(dirname(path));\n\n/**\n * The `packageManager` pin for the Yarn 2 or newer release that installs a new project at `root`, as\n * `yarn init -2` writes it, or null when that is Yarn 1. The project may not exist yet, so Corepack is asked in\n * its nearest existing directory, which resolves the same release for a project without a pin.\n */\nconst installingYarnPin = (root: string): string | null => {\n const release = installingYarnRelease(nearestDirectory(root));\n const major = Number(YARN_RELEASE_PATTERN.exec(release ?? \"\")?.[1]);\n\n return release !== null && major >= FIRST_PINNED_YARN_MAJOR ? `${YARN_PIN_PREFIX}${release}` : null;\n};\n\n/**\n * The `packageManager` field for the new `package.json`: the existing project's pin when it names\n * `packageManager`, otherwise, outside an enclosing workspace whose root owns the pin, the Yarn 2 or newer\n * release that installs the project.\n */\nconst packageManagerPin = (root: string, packageManager: PackageManager, isInWorkspace: boolean): string | null =>\n pinnedPackageManager(root, packageManager) ??\n (packageManager === \"yarn\" && !isInWorkspace ? installingYarnPin(root) : null);\n\n/**\n * The workspace globs of `field`, given as a list or, as npm and Yarn also accept, as an object with a\n * `packages` list.\n */\nconst workspacePatterns = (settings: unknown, field: string): string[] => {\n const value = isRecord(settings) ? settings[field] : undefined;\n const patterns = isRecord(value) ? value.packages : value;\n\n return Array.isArray(patterns) ? patterns.filter((pattern) => typeof pattern === \"string\") : [];\n};\n\nconst matchesWorkspacePattern = (project: string, pattern: string): boolean =>\n matchesGlob(project, posix.normalize(pattern).replace(/\\/+$/, \"\"));\n\nconst includesProject = (patterns: string[], project: string): boolean =>\n patterns.some((pattern) => !pattern.startsWith(NEGATION_PREFIX) && matchesWorkspacePattern(project, pattern)) &&\n !patterns.some(\n (pattern) =>\n pattern.startsWith(NEGATION_PREFIX) &&\n matchesWorkspacePattern(project, pattern.slice(NEGATION_PREFIX.length)),\n );\n\nconst ancestorFiles = (root: string, name: string): string[] => {\n const files: string[] = [];\n\n for (let directory = dirname(root); ; directory = dirname(directory)) {\n const file = join(directory, name);\n\n if (existsSync(file)) {\n files.push(file);\n }\n\n if (dirname(directory) === directory) {\n return files;\n }\n }\n};\n\nconst projectPath = (file: string, root: string): string => relative(dirname(file), root).split(sep).join(posix.sep);\n\nconst recordField = (settings: unknown, field: string): Record<string, unknown> =>\n isRecord(settings) && isRecord(settings[field]) ? settings[field] : {};\n\nconst missingBuilds = (allowances: Record<string, unknown>): string[] =>\n BUILT_DEPENDENCIES.filter((name) => !Object.hasOwn(allowances, name));\n\nconst settingsToAdd = (settings: (MissingSetting | null)[]): MissingSetting[] =>\n settings.filter((setting) => setting !== null);\n\nconst missingYamlExemptions = (file: string, settings: unknown, key: string): MissingSetting | null => {\n const listed = isRecord(settings) ? settings[key] : undefined;\n const missing = missingExemptions(listed);\n\n if (missing.length === 0) {\n return null;\n }\n\n return Array.isArray(listed)\n ? { file, section: key, entries: stringify(missing).trimEnd().replace(/^/gm, \" \") }\n : { file, section: null, entries: stringify({ [key]: missing }).trimEnd() };\n};\n\nconst pnpmWorkspaceAt = (file: string, project: string): Workspace | null => {\n const settings: unknown = parse(readFileSync(file, \"utf8\"));\n\n if (!includesProject(workspacePatterns(settings, \"packages\"), project)) {\n return null;\n }\n\n const allowances = recordField(settings, \"allowBuilds\");\n const missing = BUILT_DEPENDENCIES.filter((name) => typeof allowances[name] !== \"boolean\");\n const required = Object.fromEntries(missing.map((name) => [name, true]));\n const setting: MissingSetting =\n isRecord(settings) && isRecord(settings.allowBuilds)\n ? { file, section: \"allowBuilds\", entries: stringify(required).trimEnd().replace(/^/gm, \" \") }\n : { file, section: null, entries: stringify({ allowBuilds: required }).trimEnd() };\n\n return {\n packageManager: \"pnpm\",\n root: dirname(file),\n member: project,\n missingSettings: settingsToAdd([\n missing.length > 0 ? setting : null,\n missingYamlExemptions(file, settings, PNPM_RELEASE_AGE_EXCLUDE),\n ]),\n };\n};\n\nconst npmWorkspaceAt = (file: string, project: string): Workspace | null => {\n const manifest: unknown = JSON.parse(readFileSync(file, \"utf8\"));\n\n if (!includesProject(workspacePatterns(manifest, \"workspaces\"), project)) {\n return null;\n }\n\n const missing = missingBuilds(recordField(manifest, \"allowScripts\"));\n const entries = `\"allowScripts\": ${JSON.stringify(Object.fromEntries(missing.map((name) => [name, true])), null, 4)}`;\n const configFile = join(dirname(file), NPM_CONFIG_FILE);\n const exemptions = missingExemptions(npmExemptions(existsSync(configFile) ? readFileSync(configFile, \"utf8\") : \"\"));\n\n return {\n packageManager: \"npm\",\n root: dirname(file),\n member: project,\n missingSettings: settingsToAdd([\n missing.length > 0 ? { file, section: null, entries } : null,\n exemptions.length > 0 ? { file: configFile, section: null, entries: npmExemptionLines(exemptions) } : null,\n ]),\n };\n};\n\n/**\n * The `nodeLinker` Yarn applies in `directory`: Yarn merges the `.yarnrc.yml` files of a project and its\n * ancestors, and the closest one that sets a value wins.\n */\nconst yarnNodeLinker = (directory: string): unknown => {\n for (const file of [join(directory, YARN_CONFIG_FILE), ...ancestorFiles(directory, YARN_CONFIG_FILE)]) {\n const settings: unknown = existsSync(file) ? parse(readFileSync(file, \"utf8\")) : undefined;\n\n if (isRecord(settings) && Object.hasOwn(settings, \"nodeLinker\")) {\n return settings.nodeLinker;\n }\n }\n\n return undefined;\n};\n\nconst yarnWorkspaceAt = (file: string, project: string): Workspace | null => {\n const manifest: unknown = JSON.parse(readFileSync(file, \"utf8\"));\n\n if (!includesProject(workspacePatterns(manifest, \"workspaces\"), project)) {\n return null;\n }\n\n const missing = missingBuilds(recordField(manifest, \"dependenciesMeta\"));\n const dependenciesMeta = Object.fromEntries(missing.map((name) => [name, { built: true }]));\n const configFile = join(dirname(file), YARN_CONFIG_FILE);\n const exemptions = readsPreapprovedPackages(dirname(file))\n ? missingYamlExemptions(configFile, readSettings(configFile, parse), YARN_PREAPPROVED_PACKAGES)\n : null;\n\n return {\n packageManager: \"yarn\",\n root: dirname(file),\n member: project,\n missingSettings: settingsToAdd([\n yarnNodeLinker(dirname(file)) === YARN_NODE_LINKER\n ? null\n : { file: configFile, section: null, entries: stringify({ nodeLinker: YARN_NODE_LINKER }).trimEnd() },\n missing.length > 0\n ? { file, section: null, entries: `\"dependenciesMeta\": ${JSON.stringify(dependenciesMeta, null, 4)}` }\n : null,\n exemptions,\n ]),\n };\n};\n\nconst MANIFEST_WORKSPACES: Record<\n Exclude<PackageManager, \"pnpm\">,\n (file: string, project: string) => Workspace | null\n> = {\n npm: npmWorkspaceAt,\n yarn: yarnWorkspaceAt,\n};\n\n/**\n * The pnpm, npm or Yarn workspace above `root` that includes it, with the settings its root configuration\n * still lacks for the app, or null when `root` is not part of an enclosing workspace. pnpm reads\n * `allowBuilds` and `minimumReleaseAgeExclude`, npm `allowScripts` and `min-release-age-exclude`, and Yarn\n * `nodeLinker`, `npmPreapprovedPackages` and `dependenciesMeta` only for the whole workspace, from its root.\n */\nconst enclosingWorkspace = (root: string, packageManager: PackageManager): Workspace | null => {\n if (packageManager === \"pnpm\") {\n const [nearest] = ancestorFiles(root, PNPM_WORKSPACE_FILE);\n\n return nearest === undefined ? null : pnpmWorkspaceAt(nearest, projectPath(nearest, root));\n }\n\n const workspaceAt = MANIFEST_WORKSPACES[packageManager];\n\n for (const file of ancestorFiles(root, PACKAGE_JSON_FILE)) {\n const workspace = workspaceAt(file, projectPath(file, root));\n\n if (workspace !== null) {\n return workspace;\n }\n }\n\n return null;\n};\n\n/**\n * Whether `yarn` in the workspace at `root` is Yarn 1, judged by the release it runs there, and Yarn 1 when no\n * release can be determined.\n */\nconst isClassicYarn = (root: string): boolean => {\n const major = Number(YARN_RELEASE_PATTERN.exec(yarnRelease(root) ?? \"\")?.[1]);\n\n return Number.isNaN(major) || major < FIRST_PINNED_YARN_MAJOR;\n};\n\nexport {\n PACKAGE_MANAGER_CONFIG_FILES,\n enclosingWorkspace,\n isClassicYarn,\n packageManagerPin,\n type Workspace,\n writePackageManagerSettings,\n writeReleaseAgeExemptions,\n};\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { scaffoldCommand } from \"./command.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { writeReleaseAgeExemptions } from \"./build-allowance.js\";\nexport { scaffoldCommand } from \"./command.js\";\n"]}
|
|
@@ -4,18 +4,24 @@ declare const PACKAGE_MANAGERS: readonly [{
|
|
|
4
4
|
readonly label: "pnpm";
|
|
5
5
|
readonly devCommand: "pnpm dev";
|
|
6
6
|
readonly installCommand: "pnpm install";
|
|
7
|
+
readonly runCommand: "pnpm";
|
|
8
|
+
readonly testCommand: "pnpm test";
|
|
7
9
|
readonly isRecommended: true;
|
|
8
10
|
}, {
|
|
9
11
|
readonly value: "npm";
|
|
10
12
|
readonly label: "npm";
|
|
11
13
|
readonly devCommand: "npm run dev";
|
|
12
14
|
readonly installCommand: "npm install";
|
|
15
|
+
readonly runCommand: "npm run";
|
|
16
|
+
readonly testCommand: "npm test";
|
|
13
17
|
readonly isRecommended: false;
|
|
14
18
|
}, {
|
|
15
19
|
readonly value: "yarn";
|
|
16
20
|
readonly label: "yarn";
|
|
17
21
|
readonly devCommand: "yarn dev";
|
|
18
22
|
readonly installCommand: "yarn install";
|
|
23
|
+
readonly runCommand: "yarn";
|
|
24
|
+
readonly testCommand: "yarn test";
|
|
19
25
|
readonly isRecommended: false;
|
|
20
26
|
}];
|
|
21
27
|
declare const PACKAGE_MANAGER_VALUES: PackageManager[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-managers.d.ts","sourceRoot":"","sources":["../src/package-managers.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAEjE,QAAA,MAAM,gBAAgB;aAEd,KAAK,EAAE,MAAM;aACb,KAAK,EAAE,MAAM;aACb,UAAU,EAAE,UAAU;aACtB,cAAc,EAAE,cAAc;aAC9B,aAAa;;aAGb,KAAK,EAAE,KAAK;aACZ,KAAK,EAAE,KAAK;aACZ,UAAU,EAAE,aAAa;aACzB,cAAc,EAAE,aAAa;aAC7B,aAAa;;aAGb,KAAK,EAAE,MAAM;aACb,KAAK,EAAE,MAAM;aACb,UAAU,EAAE,UAAU;aACtB,cAAc,EAAE,cAAc;aAC9B,aAAa;EAEX,CAAC;AAEX,QAAA,MAAM,sBAAsB,EAAE,cAAc,EAAqD,CAAC;AAClG,QAAA,MAAM,gCAAgC,QAA2D,CAAC;AAElG,QAAA,MAAM,qBAAqB,SAAU,MAAM,KAAG,IAAI,IAAI,cACC,CAAC;AAExD,OAAO,EACH,gBAAgB,EAChB,gCAAgC,EAChC,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,cAAc,GACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"package-managers.d.ts","sourceRoot":"","sources":["../src/package-managers.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAEjE,QAAA,MAA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