@antelopejs/tooling-configs 0.5.3 → 0.5.5
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 +24 -23
- package/assets/readme/OFL.txt +93 -0
- package/assets/readme/geist-extrabold.woff2 +0 -0
- package/assets/readme/geist-mono.woff2 +0 -0
- package/dist/bin/api-diff.mjs +3 -3
- package/dist/bin/body-check.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/comment-proof.mjs +2 -2
- package/dist/bin/ratchet.mjs +1 -1
- package/dist/bin/readme-strip.d.mts +1 -0
- package/dist/bin/readme-strip.mjs +134 -0
- package/dist/bin/sync.mjs +197 -51
- package/dist/{checks-BFGuy1KI.mjs → checks-DqTjyKCC.mjs} +994 -880
- package/dist/oxc/lint.mjs +1 -1
- package/dist/{package-DiaBP7bI.mjs → package-DnxZ2CXZ.mjs} +37 -30
- package/dist/{proof-stamp-BPIdT5ik.mjs → proof-stamp-Kg-tkM6G.mjs} +1 -1
- package/dist/{ratchet-BZvlFCWL.mjs → ratchet-1O8k4Dxu.mjs} +1 -1
- package/dist/{templates-C6cfOd2H.mjs → templates-Dg188oRC.mjs} +1 -1
- package/dist/{typescript-DJzdex32.mjs → typescript-DhavwHb7.mjs} +1 -1
- package/package.json +3 -1
package/dist/bin/sync.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as formatCeilings, l as readCeilings, s as isRetired, t as CEILINGS_FILE } from "../ceilings-B7KayYIG.mjs";
|
|
3
|
+
import { a as managedPackage, c as repositoryTools, f as toolingVersions, l as serializeManifest, m as usesNuxt, n as bootstrapDependencies, o as packageManager, p as usesCaptures, r as bootstrappedManifest, s as parseManifest, t as addedDevDependencies, u as templatePackage } from "../package-DnxZ2CXZ.mjs";
|
|
3
4
|
import { t as admits } from "../semver-BDxeEcP_.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-C6cfOd2H.mjs";
|
|
5
|
+
import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-Dg188oRC.mjs";
|
|
6
6
|
import { a as VERIFY_KINDS, c as isVerifyKind, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-igPpEDpS.mjs";
|
|
7
7
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
8
8
|
import { c as CI_CONTEXT, f as ciWorkflow, i as hasChecksWorkflow, n as ciNodeCallers, p as placeholderTestScript, r as ciRenovateSyncCallers, s as renovateArtifacts, t as MISSING_CHECKS_WORKFLOW, u as CI_PATH } from "../workflow-CPcNc8KL.mjs";
|
|
9
9
|
import { a as gitFiles, c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
|
|
10
|
-
import { i as
|
|
11
|
-
import {
|
|
10
|
+
import { a as stepsOf, c as workspacePatterns, i as matchingScripts, n as droppedChecksSteps, o as planDocs, s as workspaceDirectories } from "../checks-DqTjyKCC.mjs";
|
|
11
|
+
import { i as recordedRelease, t as measureBaseline } from "../ratchet-1O8k4Dxu.mjs";
|
|
12
12
|
import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-DgYdu6JK.mjs";
|
|
13
13
|
import { u as typescript } from "../suppressions-CQTcKCi1.mjs";
|
|
14
14
|
import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
|
|
@@ -16,7 +16,7 @@ import { createRequire } from "node:module";
|
|
|
16
16
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { basename, dirname, join, posix, resolve } from "node:path";
|
|
18
18
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
19
|
-
import { isMap, isScalar, parseDocument } from "yaml";
|
|
19
|
+
import { isAlias, isMap, isNode, isScalar, isSeq, parseDocument, stringify } from "yaml";
|
|
20
20
|
import ts from "typescript";
|
|
21
21
|
import { parseArgs } from "node:util";
|
|
22
22
|
//#region src/guardrails/docs-typescript.ts
|
|
@@ -264,37 +264,47 @@ function readsSettings(manifest) {
|
|
|
264
264
|
return pinned === void 0 || admits(">=10.5.0", pinned);
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
267
|
+
* The dependency builds sync declares and pnpm 11 must be told to skip.
|
|
268
|
+
* The synced `prepare` script runs `lefthook install` itself, and `MongoMemoryServer.create()` downloads the mongod that the capture peer's postinstall would fetch.
|
|
269
269
|
*/
|
|
270
|
-
function
|
|
270
|
+
function skippedBuilds(captures) {
|
|
271
|
+
return captures ? ["lefthook", "mongodb-memory-server"] : ["lefthook"];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* `current` with `allowBuilds.<name>` set to `false` for each of `names` the repository does not already decide.
|
|
275
|
+
* pnpm 11 fails an install on a dependency build it was not told about.
|
|
276
|
+
*/
|
|
277
|
+
function withBuildsDecided(names, current = "") {
|
|
271
278
|
const document = parseDocument(current);
|
|
272
279
|
if (document.errors.length) throw new Error(`${PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
|
|
273
280
|
if (document.toJS() == null) {
|
|
274
281
|
const kept = current.trimStart();
|
|
275
|
-
|
|
282
|
+
const lines = names.map((name) => ` ${name}: false\n`).join("");
|
|
283
|
+
return `${kept}${kept === "" || kept.endsWith("\n") ? "" : "\n"}allowBuilds:\n${lines}`;
|
|
276
284
|
}
|
|
277
285
|
if (!isMap(document.contents)) throw new Error(`${PATH} must contain a YAML mapping.`);
|
|
278
286
|
if (document.get("allowBuilds") == null) document.set("allowBuilds", document.createNode({}));
|
|
279
287
|
const builds = document.get("allowBuilds");
|
|
280
288
|
if (!isMap(builds)) throw new Error(`${PATH}: allowBuilds must be a mapping.`);
|
|
281
|
-
|
|
289
|
+
const undecided = names.filter((name) => builds.get(name) == null);
|
|
290
|
+
if (!undecided.length) return current;
|
|
282
291
|
document.contents.flow = false;
|
|
283
292
|
builds.flow = false;
|
|
284
|
-
builds.set(
|
|
293
|
+
for (const name of undecided) builds.set(name, false);
|
|
285
294
|
return document.toString({
|
|
286
295
|
lineWidth: 0,
|
|
287
296
|
flowCollectionPadding: false
|
|
288
297
|
});
|
|
289
298
|
}
|
|
290
|
-
/** The `pnpm-workspace.yaml` a full-profile pnpm repository needs so pnpm 11 and later install
|
|
299
|
+
/** The `pnpm-workspace.yaml` a full-profile pnpm repository needs so pnpm 11 and later install the builds sync declares without `ERR_PNPM_IGNORED_BUILDS`. */
|
|
291
300
|
function pnpmWorkspaceArtifacts(root, manifest, managed) {
|
|
292
301
|
if (!managed || packageManager(manifest) !== "pnpm") return [];
|
|
293
302
|
const file = join(root, PATH);
|
|
294
303
|
const current = existsSync(file) ? readFileSync(file, "utf8") : void 0;
|
|
295
304
|
if (current === void 0 && !readsSettings(manifest)) return [];
|
|
305
|
+
const names = skippedBuilds(usesCaptures(root));
|
|
296
306
|
try {
|
|
297
|
-
const content =
|
|
307
|
+
const content = withBuildsDecided(names, current);
|
|
298
308
|
return [content === current ? {
|
|
299
309
|
kind: "unchanged",
|
|
300
310
|
path: PATH
|
|
@@ -308,7 +318,7 @@ function pnpmWorkspaceArtifacts(root, manifest, managed) {
|
|
|
308
318
|
return [{
|
|
309
319
|
kind: "error",
|
|
310
320
|
path: PATH,
|
|
311
|
-
message: `${error instanceof Error ? error.message : String(error)} Add \`allowBuilds: {
|
|
321
|
+
message: `${error instanceof Error ? error.message : String(error)} Add \`allowBuilds: { ${names.map((name) => `${name}: false`).join(", ")} }\` to it, then rerun antelopejs-sync.`
|
|
312
322
|
}];
|
|
313
323
|
}
|
|
314
324
|
}
|
|
@@ -1478,7 +1488,7 @@ function repositoryContext(root, current, profile, verificationSkill) {
|
|
|
1478
1488
|
glossary: ["GLOSSARY.md", "docs/GLOSSARY.md"].find((file) => existsSync(join(root, file))),
|
|
1479
1489
|
docs: profile === "full" && current.has("package.json") ? planDocs(root, manager) : void 0,
|
|
1480
1490
|
placeholderTests: current.has("package.json") && placeholderTestScript(manifest.scripts?.test),
|
|
1481
|
-
captures:
|
|
1491
|
+
captures: usesCaptures(root)
|
|
1482
1492
|
};
|
|
1483
1493
|
}
|
|
1484
1494
|
function writeArtifacts(root, artifacts) {
|
|
@@ -1709,9 +1719,72 @@ const ALIGNED_TOOLS = [
|
|
|
1709
1719
|
"knip",
|
|
1710
1720
|
"lefthook"
|
|
1711
1721
|
];
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1722
|
+
const CATALOG = "catalog:";
|
|
1723
|
+
/** The scalar keys of the mapping `node` holds, each with its value node, following YAML aliases and `<<` merge keys; a key the mapping sets itself comes after the merged one it overrides. */
|
|
1724
|
+
function mapPairs(document, node, seen = /* @__PURE__ */ new Set()) {
|
|
1725
|
+
const map = isAlias(node) ? node.resolve(document) : node;
|
|
1726
|
+
if (!isMap(map) || seen.has(map)) return [];
|
|
1727
|
+
const within = /* @__PURE__ */ new Set([...seen, map]);
|
|
1728
|
+
const merged = [];
|
|
1729
|
+
const own = [];
|
|
1730
|
+
for (const { key, value } of map.items) {
|
|
1731
|
+
if (!isScalar(key)) continue;
|
|
1732
|
+
if (key.value !== "<<") {
|
|
1733
|
+
own.push([String(key.value), isAlias(value) ? value.resolve(document) : value]);
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
const merge = isAlias(value) ? value.resolve(document) : value;
|
|
1737
|
+
const sources = isSeq(merge) ? [...merge.items].reverse() : [merge];
|
|
1738
|
+
for (const source of sources) if (isNode(source)) merged.push(...mapPairs(document, source, within));
|
|
1739
|
+
}
|
|
1740
|
+
return [...merged, ...own];
|
|
1741
|
+
}
|
|
1742
|
+
/** The scalar keys of the mapping at `path`, each with its value node. */
|
|
1743
|
+
function mapEntries(document, path) {
|
|
1744
|
+
let pairs = mapPairs(document, document.contents);
|
|
1745
|
+
for (const key of path) {
|
|
1746
|
+
const value = new Map(pairs).get(key);
|
|
1747
|
+
pairs = isNode(value) ? mapPairs(document, value) : [];
|
|
1748
|
+
}
|
|
1749
|
+
return pairs;
|
|
1750
|
+
}
|
|
1751
|
+
/** The package names of the catalog at `path`, each with its range. */
|
|
1752
|
+
function catalogEntries(document, path) {
|
|
1753
|
+
return mapEntries(document, path).flatMap(([name, value]) => isScalar(value) ? [[name, String(value.value)]] : []);
|
|
1754
|
+
}
|
|
1755
|
+
function catalogSource(root) {
|
|
1756
|
+
const pnpm = join(root, "pnpm-workspace.yaml");
|
|
1757
|
+
if (existsSync(pnpm)) return {
|
|
1758
|
+
document: parseDocument(readFileSync(pnpm, "utf8")),
|
|
1759
|
+
prefixes: [[]]
|
|
1760
|
+
};
|
|
1761
|
+
return {
|
|
1762
|
+
document: parseDocument(readFileSync(join(root, "package.json"), "utf8")),
|
|
1763
|
+
prefixes: [["workspaces"], []]
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
function workspaceCatalogs(root) {
|
|
1767
|
+
const { document, prefixes } = catalogSource(root);
|
|
1768
|
+
const catalogs = /* @__PURE__ */ new Map();
|
|
1769
|
+
const add = (name, path) => catalogs.set(name, new Map([...catalogs.get(name) ?? [], ...catalogEntries(document, path)]));
|
|
1770
|
+
for (const prefix of prefixes) {
|
|
1771
|
+
add("default", [...prefix, "catalog"]);
|
|
1772
|
+
for (const [name] of mapEntries(document, [...prefix, "catalogs"])) add(name, [
|
|
1773
|
+
...prefix,
|
|
1774
|
+
"catalogs",
|
|
1775
|
+
name
|
|
1776
|
+
]);
|
|
1777
|
+
}
|
|
1778
|
+
return catalogs;
|
|
1779
|
+
}
|
|
1780
|
+
/** The range `spec` installs `name` at: `spec` itself, its catalog entry for a `catalog:` spec, or undefined for another protocol or a path. */
|
|
1781
|
+
function resolvedRange(catalogs, name, spec) {
|
|
1782
|
+
if (spec.startsWith(CATALOG)) return catalogs.get(spec.slice(8) || "default")?.get(name);
|
|
1783
|
+
return /[:/]/.test(spec) ? void 0 : spec;
|
|
1784
|
+
}
|
|
1785
|
+
/** The spec of each pack tool at the root: the one it declares, else the one `--init` and sync add. A `catalog:` spec resolves the same in every member; another protocol or a path stays root-only, since a member would resolve it elsewhere. */
|
|
1786
|
+
function rootSpecs(root, versions, catalogs) {
|
|
1787
|
+
const declared = /* @__PURE__ */ new Map([
|
|
1715
1788
|
["@antelopejs/tooling-configs", `^${versions.pack}`],
|
|
1716
1789
|
["oxlint", versions.oxlint],
|
|
1717
1790
|
["oxlint-tsgolint", versions.tsgolint],
|
|
@@ -1719,27 +1792,40 @@ function rootRanges(root, versions) {
|
|
|
1719
1792
|
["knip", versions.knip],
|
|
1720
1793
|
["lefthook", versions.lefthook]
|
|
1721
1794
|
]);
|
|
1722
|
-
for (const field of [root.dependencies, root.devDependencies]) for (const [name,
|
|
1723
|
-
|
|
1724
|
-
|
|
1795
|
+
for (const field of [root.dependencies, root.devDependencies]) for (const [name, spec] of Object.entries(field ?? {})) if (declared.has(name)) declared.set(name, spec);
|
|
1796
|
+
const specs = /* @__PURE__ */ new Map();
|
|
1797
|
+
for (const [name, spec] of declared) {
|
|
1798
|
+
const range = resolvedRange(catalogs, name, spec);
|
|
1799
|
+
if (range !== void 0) specs.set(name, {
|
|
1800
|
+
spec,
|
|
1801
|
+
range
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
return specs;
|
|
1725
1805
|
}
|
|
1726
|
-
/** Sets each pack tool the member declares to the root's
|
|
1727
|
-
function alignRanges(member,
|
|
1806
|
+
/** Sets each pack tool the member declares as a plain range to the root's spec, so the workspace installs one copy of the pack, and names each member `catalog:` spec that resolves to another range; returns whether it changed one. */
|
|
1807
|
+
function alignRanges(member, manifestPath, specs, catalogs, failures) {
|
|
1728
1808
|
let changed = false;
|
|
1729
1809
|
for (const field of [member.dependencies, member.devDependencies]) for (const name of ALIGNED_TOOLS) {
|
|
1730
1810
|
const declared = field && Object.hasOwn(field, name) ? field[name] : void 0;
|
|
1731
|
-
const wanted =
|
|
1732
|
-
if (!field || declared === void 0 || wanted === void 0 || declared === wanted
|
|
1733
|
-
|
|
1811
|
+
const wanted = specs.get(name);
|
|
1812
|
+
if (!field || declared === void 0 || wanted === void 0 || declared === wanted.spec) continue;
|
|
1813
|
+
if (declared.startsWith(CATALOG)) {
|
|
1814
|
+
const range = resolvedRange(catalogs, name, declared);
|
|
1815
|
+
if (range !== void 0 && range !== wanted.range) failures.push(`${manifestPath} declares ${name} as ${declared}, which resolves to ${range}, while the root resolves it to ${wanted.range}, so the workspace would install two copies. Give both the same catalog entry or range, then rerun antelopejs-sync --init.`);
|
|
1816
|
+
continue;
|
|
1817
|
+
}
|
|
1818
|
+
if (declared.includes(":")) continue;
|
|
1819
|
+
field[name] = wanted.spec;
|
|
1734
1820
|
changed = true;
|
|
1735
1821
|
}
|
|
1736
1822
|
return changed;
|
|
1737
1823
|
}
|
|
1738
|
-
function alignMember(root, directory,
|
|
1824
|
+
function alignMember(root, directory, workspace, result) {
|
|
1739
1825
|
const manifestPath = join(root, directory, "package.json");
|
|
1740
1826
|
const current = readFileSync(manifestPath, "utf8");
|
|
1741
1827
|
const member = parseManifest(current);
|
|
1742
|
-
let changed = alignRanges(member,
|
|
1828
|
+
let changed = alignRanges(member, `${directory}/package.json`, workspace.specs, workspace.catalogs, result.failures);
|
|
1743
1829
|
for (const name of LINT_CONFIGS) {
|
|
1744
1830
|
const relative = `${directory}/${name}`;
|
|
1745
1831
|
const path = join(root, relative);
|
|
@@ -1767,12 +1853,16 @@ function alignMember(root, directory, ranges, result) {
|
|
|
1767
1853
|
* on the member's `oxlint` scripts.
|
|
1768
1854
|
*/
|
|
1769
1855
|
function alignWorkspaceMembers(root, manifest, versions) {
|
|
1770
|
-
const
|
|
1856
|
+
const catalogs = workspaceCatalogs(root);
|
|
1857
|
+
const workspace = {
|
|
1858
|
+
specs: rootSpecs(manifest, versions, catalogs),
|
|
1859
|
+
catalogs
|
|
1860
|
+
};
|
|
1771
1861
|
const result = {
|
|
1772
1862
|
paths: [],
|
|
1773
1863
|
failures: []
|
|
1774
1864
|
};
|
|
1775
|
-
for (const directory of workspaceDirectories(root)) alignMember(root, directory,
|
|
1865
|
+
for (const directory of workspaceDirectories(root)) alignMember(root, directory, workspace, result);
|
|
1776
1866
|
return result;
|
|
1777
1867
|
}
|
|
1778
1868
|
//#endregion
|
|
@@ -1833,10 +1923,10 @@ function ensureBranchCleanup(root) {
|
|
|
1833
1923
|
reason: failureText(write)
|
|
1834
1924
|
} : { kind: "enabled" };
|
|
1835
1925
|
}
|
|
1836
|
-
/** Runs
|
|
1837
|
-
function run(root,
|
|
1838
|
-
const command = [
|
|
1839
|
-
const result = spawnSync(
|
|
1926
|
+
/** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
|
|
1927
|
+
function run(root, args) {
|
|
1928
|
+
const command = ["pnpm", ...args].join(" ");
|
|
1929
|
+
const result = spawnSync("pnpm", args, {
|
|
1840
1930
|
cwd: root,
|
|
1841
1931
|
encoding: "utf8"
|
|
1842
1932
|
});
|
|
@@ -1844,8 +1934,8 @@ function run(root, manager, args) {
|
|
|
1844
1934
|
if (result.status === 0) return void 0;
|
|
1845
1935
|
return `${command} failed (exit ${result.status}).\n${result.stdout}${result.stderr}`.trimEnd();
|
|
1846
1936
|
}
|
|
1847
|
-
function install(root
|
|
1848
|
-
return run(root,
|
|
1937
|
+
function install(root) {
|
|
1938
|
+
return run(root, ["install"]);
|
|
1849
1939
|
}
|
|
1850
1940
|
function resolveOxfmt(root) {
|
|
1851
1941
|
const require = createRequire(join(root, "package.json"));
|
|
@@ -1899,19 +1989,77 @@ const NODE_TSCONFIG = `{
|
|
|
1899
1989
|
}
|
|
1900
1990
|
}
|
|
1901
1991
|
`;
|
|
1902
|
-
|
|
1992
|
+
/**
|
|
1993
|
+
* The other package managers' install state `--init` deletes once pnpm's lockfile replaces it, and whether
|
|
1994
|
+
* `pnpm import` reads the versions it resolved. Yarn's Plug'n'Play loaders go too: left in place, Node resolves every
|
|
1995
|
+
* package through them and misses what pnpm installed.
|
|
1996
|
+
*/
|
|
1997
|
+
const FOREIGN_INSTALL_FILES = [
|
|
1998
|
+
{
|
|
1999
|
+
file: "package-lock.json",
|
|
2000
|
+
importable: true
|
|
2001
|
+
},
|
|
2002
|
+
{
|
|
2003
|
+
file: "npm-shrinkwrap.json",
|
|
2004
|
+
importable: true
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
file: "yarn.lock",
|
|
2008
|
+
importable: true
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
file: ".pnp.cjs",
|
|
2012
|
+
importable: false
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
file: ".pnp.loader.mjs",
|
|
2016
|
+
importable: false
|
|
2017
|
+
},
|
|
2018
|
+
{
|
|
2019
|
+
file: "bun.lock",
|
|
2020
|
+
importable: false
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
file: "bun.lockb",
|
|
2024
|
+
importable: false
|
|
2025
|
+
}
|
|
2026
|
+
];
|
|
2027
|
+
const LINK_WORKSPACE_PACKAGES = "link-workspace-packages=true";
|
|
2028
|
+
/**
|
|
2029
|
+
* Lists package.json `workspaces` in a new `pnpm-workspace.yaml`, since pnpm ignores the field, and, when `converting`
|
|
2030
|
+
* another manager's install state, links members declared by version as npm, yarn and bun do, so `pnpm import` locks
|
|
2031
|
+
* every member. `.npmrc` carries the link setting because the pinned pnpm reads no settings from `pnpm-workspace.yaml`
|
|
2032
|
+
* when importing, and an explicit setting there is kept. Returns the files it wrote.
|
|
2033
|
+
*/
|
|
2034
|
+
function ensurePnpmWorkspace(root, converting) {
|
|
2035
|
+
const packages = workspacePatterns(root);
|
|
2036
|
+
if (!packages.length) return [];
|
|
2037
|
+
const written = [];
|
|
2038
|
+
const workspace = join(root, "pnpm-workspace.yaml");
|
|
2039
|
+
if (!existsSync(workspace)) {
|
|
2040
|
+
writeFileSync(workspace, stringify({ packages }));
|
|
2041
|
+
written.push("pnpm-workspace.yaml");
|
|
2042
|
+
}
|
|
2043
|
+
const npmrc = join(root, ".npmrc");
|
|
2044
|
+
const current = existsSync(npmrc) ? readFileSync(npmrc, "utf8") : "";
|
|
2045
|
+
if (!converting || /^\s*link-workspace-packages\s*=/m.test(current)) return written;
|
|
2046
|
+
const separator = current === "" || current.endsWith("\n") ? "" : "\n";
|
|
2047
|
+
writeFileSync(npmrc, `${current}${separator}${LINK_WORKSPACE_PACKAGES}\n`);
|
|
2048
|
+
return [...written, ".npmrc"];
|
|
2049
|
+
}
|
|
1903
2050
|
/**
|
|
1904
2051
|
* The file steps before the first install: `node_modules` ignored, the pnpm version the pack's CI runs pinned when
|
|
1905
|
-
* `packageManager`
|
|
1906
|
-
* `typecheck`, the pack's oxfmt config when there is none, each workspace member on the root's tool ranges with
|
|
1907
|
-
* oxlint `options` moved to flags,
|
|
2052
|
+
* `packageManager` names no pnpm, the bootstrap devDependencies, a tsconfig for a Node repository without one or its
|
|
2053
|
+
* own `typecheck`, the pack's oxfmt config when there is none, each workspace member on the root's tool ranges with
|
|
2054
|
+
* its oxlint `options` moved to flags, package.json `workspaces` listed for pnpm, and the other managers' lockfiles
|
|
2055
|
+
* deleted once `pnpm import` carried the versions npm's or yarn's resolved into a pnpm lockfile.
|
|
1908
2056
|
*/
|
|
1909
2057
|
function bootstrap(root) {
|
|
1910
2058
|
const path = join(root, "package.json");
|
|
1911
2059
|
if (!existsSync(path)) throw new Error("package.json is missing. antelopejs-sync --init needs a repository that already has one.");
|
|
1912
2060
|
const current = readFileSync(path, "utf8");
|
|
1913
2061
|
const manifest = parseManifest(current);
|
|
1914
|
-
|
|
2062
|
+
packageManager(manifest);
|
|
1915
2063
|
const versions = toolingVersions();
|
|
1916
2064
|
const paths = [];
|
|
1917
2065
|
if (ensureGitignore(root)) paths.push(".gitignore");
|
|
@@ -1933,25 +2081,23 @@ function bootstrap(root) {
|
|
|
1933
2081
|
const members = alignWorkspaceMembers(root, manifest, versions);
|
|
1934
2082
|
paths.push(...members.paths);
|
|
1935
2083
|
if (members.failures.length) return {
|
|
1936
|
-
manager,
|
|
1937
2084
|
paths,
|
|
1938
2085
|
removed: [],
|
|
1939
2086
|
failure: members.failures.join("\n")
|
|
1940
2087
|
};
|
|
1941
|
-
const
|
|
1942
|
-
|
|
2088
|
+
const foreign = FOREIGN_INSTALL_FILES.filter(({ file }) => existsSync(join(root, file)));
|
|
2089
|
+
paths.push(...ensurePnpmWorkspace(root, foreign.length > 0));
|
|
2090
|
+
const imported = foreign.some(({ importable }) => importable) && !existsSync(join(root, "pnpm-lock.yaml")) ? run(root, ["import"]) : void 0;
|
|
1943
2091
|
if (imported !== void 0) return {
|
|
1944
|
-
manager,
|
|
1945
2092
|
paths,
|
|
1946
2093
|
removed: [],
|
|
1947
2094
|
failure: imported
|
|
1948
2095
|
};
|
|
1949
|
-
|
|
2096
|
+
for (const { file } of foreign) unlinkSync(join(root, file));
|
|
1950
2097
|
return {
|
|
1951
|
-
manager,
|
|
1952
2098
|
paths,
|
|
1953
|
-
removed:
|
|
1954
|
-
failure: install(root
|
|
2099
|
+
removed: foreign.map(({ file }) => file),
|
|
2100
|
+
failure: install(root)
|
|
1955
2101
|
};
|
|
1956
2102
|
}
|
|
1957
2103
|
/**
|
|
@@ -1961,7 +2107,7 @@ function bootstrap(root) {
|
|
|
1961
2107
|
* did. Every step is idempotent, so a second run changes nothing.
|
|
1962
2108
|
*/
|
|
1963
2109
|
function initRepository(root, options = {}) {
|
|
1964
|
-
const {
|
|
2110
|
+
const { paths, removed, failure: installed } = bootstrap(root);
|
|
1965
2111
|
const format = () => {
|
|
1966
2112
|
const formatted = formatRepository(root);
|
|
1967
2113
|
for (const file of formatted.rewritten) if (!paths.includes(file)) paths.push(file);
|
|
@@ -1982,7 +2128,7 @@ function initRepository(root, options = {}) {
|
|
|
1982
2128
|
});
|
|
1983
2129
|
let failure;
|
|
1984
2130
|
if (!sync.errors.length) {
|
|
1985
|
-
failure = sync.dependenciesAdded ? install(root
|
|
2131
|
+
failure = sync.dependenciesAdded ? install(root) : void 0;
|
|
1986
2132
|
failure ??= format();
|
|
1987
2133
|
}
|
|
1988
2134
|
return {
|