@gadicc/loom 1.17.0 → 1.18.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/README.md +60 -41
- package/deno.json +3 -0
- package/esm/src/cli/mod.d.ts +3 -1
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +958 -341
- package/esm/src/cli/projectTooling.d.ts +138 -0
- package/esm/src/cli/projectTooling.d.ts.map +1 -0
- package/esm/src/cli/projectTooling.js +614 -0
- package/package.json +3 -2
- package/script/src/cli/mod.d.ts +3 -1
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +958 -341
- package/script/src/cli/projectTooling.d.ts +138 -0
- package/script/src/cli/projectTooling.d.ts.map +1 -0
- package/script/src/cli/projectTooling.js +634 -0
- package/skills/loom/SKILL.md +34 -22
- package/skills/loom-db/SKILL.md +9 -7
- package/skills/loom-db/references/db-stack.md +2 -1
- package/skills/loom-jobs/SKILL.md +9 -6
- package/skills/loom-lingui/SKILL.md +38 -0
- package/skills/loom-lingui/agents/openai.yaml +4 -0
package/script/src/cli/mod.js
CHANGED
|
@@ -80,6 +80,7 @@ const retention_js_1 = require("../apiKeys/retention.js");
|
|
|
80
80
|
const projectSkills_js_1 = require("./projectSkills.js");
|
|
81
81
|
const migrationEnv_js_1 = require("./migrationEnv.js");
|
|
82
82
|
const vercelBuildEnv_js_1 = require("./vercelBuildEnv.js");
|
|
83
|
+
const projectTooling_js_1 = require("./projectTooling.js");
|
|
83
84
|
exports.DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
84
85
|
exports.LOOM_DEPENDENCY = "@gadicc/loom";
|
|
85
86
|
exports.LOOM_MANIFEST_SCHEMA = "https://loom.gadicc.local/project-manifest.schema.json";
|
|
@@ -173,6 +174,12 @@ const managedSkills = [
|
|
|
173
174
|
relativePackagePath: "skills/loom-mail",
|
|
174
175
|
skillName: "loom-mail",
|
|
175
176
|
},
|
|
177
|
+
{
|
|
178
|
+
featureKey: "lingui",
|
|
179
|
+
label: "loom Lingui skill",
|
|
180
|
+
relativePackagePath: "skills/loom-lingui",
|
|
181
|
+
skillName: "loom-lingui",
|
|
182
|
+
},
|
|
176
183
|
];
|
|
177
184
|
const featureDefinitions = [
|
|
178
185
|
{
|
|
@@ -195,6 +202,10 @@ const featureDefinitions = [
|
|
|
195
202
|
key: "jobs",
|
|
196
203
|
description: "Shared App Router admin jobs pages, route handlers, direct-run helpers, and job controller wiring.",
|
|
197
204
|
},
|
|
205
|
+
{
|
|
206
|
+
key: "lingui",
|
|
207
|
+
description: "Lingui catalog source policy, generated-catalog ignores, dependencies, tasks, and build wiring.",
|
|
208
|
+
},
|
|
198
209
|
{
|
|
199
210
|
key: "mail",
|
|
200
211
|
description: "Durable outgoing mail, Postal transport/webhooks, and admin-gated test-mail UI.",
|
|
@@ -272,6 +283,30 @@ const PWA_GITIGNORE_LINES = [
|
|
|
272
283
|
"/public/workbox-*.js",
|
|
273
284
|
"/public/workbox-*.js.map",
|
|
274
285
|
];
|
|
286
|
+
const LINGUI_DEFAULT_DEPENDENCIES = {
|
|
287
|
+
"@lingui/core": "^6.5.0",
|
|
288
|
+
"@lingui/react": "^6.5.0",
|
|
289
|
+
};
|
|
290
|
+
const LINGUI_DEFAULT_DEV_DEPENDENCIES = {
|
|
291
|
+
"@lingui/cli": "^6.5.0",
|
|
292
|
+
"@lingui/format-po": "^6.5.0",
|
|
293
|
+
"@lingui/swc-plugin": "^6.5.0",
|
|
294
|
+
};
|
|
295
|
+
const LINGUI_LOADER_DEV_DEPENDENCIES = {
|
|
296
|
+
"@lingui/loader": "^6.5.0",
|
|
297
|
+
};
|
|
298
|
+
const LINGUI_CONFIG_CANDIDATES = [
|
|
299
|
+
"lingui.config.ts",
|
|
300
|
+
"lingui.config.js",
|
|
301
|
+
"lingui.config.mts",
|
|
302
|
+
"lingui.config.mjs",
|
|
303
|
+
"lingui.config.cjs",
|
|
304
|
+
];
|
|
305
|
+
const LINGUI_DEFAULT_TASKS = {
|
|
306
|
+
build: "build",
|
|
307
|
+
compile: "i18n:compile",
|
|
308
|
+
extract: "i18n:extract",
|
|
309
|
+
};
|
|
275
310
|
const PWA_UPDATE_PROMPT = "A newer version of this web app is available. Reload to update?";
|
|
276
311
|
const DB_CONNECTION_ENV_NAMES = [
|
|
277
312
|
"DATABASE_URL",
|
|
@@ -399,11 +434,14 @@ async function readManifestFramework(cwd) {
|
|
|
399
434
|
if (manifest?.project?.framework) {
|
|
400
435
|
return manifest.project.framework;
|
|
401
436
|
}
|
|
402
|
-
|
|
403
|
-
|
|
437
|
+
let metadata;
|
|
438
|
+
try {
|
|
439
|
+
metadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
440
|
+
}
|
|
441
|
+
catch {
|
|
404
442
|
return null;
|
|
405
443
|
}
|
|
406
|
-
return await detectFramework(cwd,
|
|
444
|
+
return await detectFramework(cwd, metadata.packageJson);
|
|
407
445
|
}
|
|
408
446
|
async function loadProjectEnv(cwd) {
|
|
409
447
|
const framework = await readManifestFramework(cwd);
|
|
@@ -499,7 +537,8 @@ function dbScriptBypassesEnvRunner(scriptName, scriptCommand) {
|
|
|
499
537
|
return false;
|
|
500
538
|
}
|
|
501
539
|
return !scriptUsesLoomEnvRunner(scriptCommand) &&
|
|
502
|
-
!/\
|
|
540
|
+
!/\b(?:pnpm|yarn|npx)\s+drizzle-kit\b/.test(scriptCommand) &&
|
|
541
|
+
!/\bdeno\s+run\s+-A\s+npm:drizzle-kit\b/.test(scriptCommand);
|
|
503
542
|
}
|
|
504
543
|
function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
|
|
505
544
|
if (!scriptCommand) {
|
|
@@ -508,7 +547,7 @@ function jobsScriptBypassesEnvRunner(scriptName, scriptCommand) {
|
|
|
508
547
|
return (scriptName === "job" || scriptCommand.includes("jobDirect.ts")) &&
|
|
509
548
|
!scriptUsesLoomEnvRunner(scriptCommand);
|
|
510
549
|
}
|
|
511
|
-
async function checkEnvRunnerAdoption(cwd, manifest
|
|
550
|
+
async function checkEnvRunnerAdoption(cwd, manifest) {
|
|
512
551
|
const issues = [];
|
|
513
552
|
const suggestions = new Set();
|
|
514
553
|
const activeDb = manifest.features.db?.status === "active";
|
|
@@ -523,14 +562,25 @@ async function checkEnvRunnerAdoption(cwd, manifest, packageJson) {
|
|
|
523
562
|
if (directEnvLoaderFiles.length) {
|
|
524
563
|
suggestions.add("Move env loading into package scripts with `loom env -- <command>` and remove `dotenv`/`@next/env` imports from implementation files.");
|
|
525
564
|
}
|
|
526
|
-
|
|
565
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
566
|
+
const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
567
|
+
for (const [scriptName, definition] of Object.entries(taskStore.definitions)) {
|
|
568
|
+
const scriptCommand = (0, projectTooling_js_1.getTaskCommand)(definition);
|
|
527
569
|
if (activeDb && dbScriptBypassesEnvRunner(scriptName, scriptCommand)) {
|
|
528
|
-
issues.push(
|
|
529
|
-
|
|
570
|
+
issues.push(taskStore.config === "package.json"
|
|
571
|
+
? `DB package.json script bypasses the Loom env runner: ${scriptName}`
|
|
572
|
+
: `DB task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
|
|
573
|
+
suggestions.add(taskStore.config === "package.json"
|
|
574
|
+
? "Run `loom add db` to refresh DB package scripts."
|
|
575
|
+
: "Run `loom add db` to refresh DB tasks.");
|
|
530
576
|
}
|
|
531
577
|
if (activeJobs && jobsScriptBypassesEnvRunner(scriptName, scriptCommand)) {
|
|
532
|
-
issues.push(
|
|
533
|
-
|
|
578
|
+
issues.push(taskStore.config === "package.json"
|
|
579
|
+
? `Jobs package.json script bypasses the Loom env runner: ${scriptName}`
|
|
580
|
+
: `Jobs task in ${taskStore.config} bypasses the Loom env runner: ${scriptName}`);
|
|
581
|
+
suggestions.add(taskStore.config === "package.json"
|
|
582
|
+
? "Run `loom add jobs` to refresh jobs package scripts."
|
|
583
|
+
: "Run `loom add jobs` to refresh jobs tasks.");
|
|
534
584
|
}
|
|
535
585
|
}
|
|
536
586
|
return {
|
|
@@ -795,6 +845,29 @@ function ensurePwaGitignoreText(existingText) {
|
|
|
795
845
|
text: nextText,
|
|
796
846
|
};
|
|
797
847
|
}
|
|
848
|
+
function normalizeGitignorePattern(pattern) {
|
|
849
|
+
return pattern.trim().replaceAll("\\", "/").replace(/^\.\//, "");
|
|
850
|
+
}
|
|
851
|
+
function linguiGitignoreLineMatches(line, expectedLine) {
|
|
852
|
+
const normalized = normalizeGitignorePattern(line).replace(/^\//, "");
|
|
853
|
+
const expected = normalizeGitignorePattern(expectedLine).replace(/^\//, "");
|
|
854
|
+
return normalized === expected;
|
|
855
|
+
}
|
|
856
|
+
function ensureLinguiGitignoreText(existingText, generatedCatalogs) {
|
|
857
|
+
const normalized = existingText ? normalizeText(existingText) : "";
|
|
858
|
+
const lines = normalized
|
|
859
|
+
.split("\n")
|
|
860
|
+
.filter((line, index, array) => index < array.length - 1 || line !== "");
|
|
861
|
+
const missingLines = generatedCatalogs.filter((expectedLine) => !lines.some((line) => linguiGitignoreLineMatches(line, expectedLine)));
|
|
862
|
+
const nextText = missingLines.length
|
|
863
|
+
? `${[...lines, ...missingLines].join("\n")}\n`
|
|
864
|
+
: normalized;
|
|
865
|
+
return {
|
|
866
|
+
changed: nextText !== normalized,
|
|
867
|
+
missingLines,
|
|
868
|
+
text: nextText,
|
|
869
|
+
};
|
|
870
|
+
}
|
|
798
871
|
function loomDevStateGitignoreLineMatches(line) {
|
|
799
872
|
const normalized = line.trim().replace(/^\/?/, "");
|
|
800
873
|
return normalized === exports.LOOM_LOCAL_DEV_STATE_GITIGNORE_LINE ||
|
|
@@ -828,58 +901,30 @@ function ensurePackageJsonDependency(packageJson, versionRange = exports.DEFAULT
|
|
|
828
901
|
previous: current,
|
|
829
902
|
};
|
|
830
903
|
}
|
|
831
|
-
function
|
|
832
|
-
|
|
833
|
-
nextPackageJson[field] ??= {};
|
|
834
|
-
const changedKeys = [];
|
|
835
|
-
for (const [dependencyName, versionRange] of Object.entries(dependencies)) {
|
|
836
|
-
if (!nextPackageJson[field][dependencyName]) {
|
|
837
|
-
nextPackageJson[field][dependencyName] = versionRange;
|
|
838
|
-
changedKeys.push(dependencyName);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
return {
|
|
842
|
-
changed: changedKeys.length > 0,
|
|
843
|
-
changedKeys,
|
|
844
|
-
packageJson: nextPackageJson,
|
|
845
|
-
};
|
|
904
|
+
async function getProjectTooling(cwd, manifest) {
|
|
905
|
+
return await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest.project?.tooling);
|
|
846
906
|
}
|
|
847
|
-
function
|
|
848
|
-
const
|
|
849
|
-
const removedKeys = [];
|
|
850
|
-
for (const dependencyName of dependencyNames) {
|
|
851
|
-
if (nextPackageJson.dependencies?.[dependencyName]) {
|
|
852
|
-
delete nextPackageJson.dependencies[dependencyName];
|
|
853
|
-
removedKeys.push(dependencyName);
|
|
854
|
-
}
|
|
855
|
-
if (nextPackageJson.devDependencies?.[dependencyName]) {
|
|
856
|
-
delete nextPackageJson.devDependencies[dependencyName];
|
|
857
|
-
removedKeys.push(dependencyName);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
return {
|
|
861
|
-
changed: removedKeys.length > 0,
|
|
862
|
-
packageJson: nextPackageJson,
|
|
863
|
-
removedKeys,
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
function ensurePackageJsonScripts(packageJson, scripts) {
|
|
867
|
-
const nextPackageJson = structuredClone(packageJson);
|
|
868
|
-
nextPackageJson.scripts ??= {};
|
|
907
|
+
async function ensureProjectTasks(cwd, manifest, tasks) {
|
|
908
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
869
909
|
const changedKeys = [];
|
|
870
|
-
for (const [
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
changedKeys.push(
|
|
874
|
-
}
|
|
910
|
+
for (const [name, definition] of Object.entries(tasks)) {
|
|
911
|
+
const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, { definition, name });
|
|
912
|
+
if (result.changed)
|
|
913
|
+
changedKeys.push(name);
|
|
875
914
|
}
|
|
915
|
+
return { changedKeys, config: tooling.tasks.config, tooling };
|
|
916
|
+
}
|
|
917
|
+
async function checkProjectTasks(cwd, manifest, expected) {
|
|
918
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
919
|
+
const store = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
876
920
|
return {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
921
|
+
config: tooling.tasks.config,
|
|
922
|
+
mismatches: Object.entries(expected).flatMap(([name, command]) => (0, projectTooling_js_1.getTaskCommand)(store.definitions[name]) === command ? [] : [name]),
|
|
923
|
+
store,
|
|
924
|
+
tooling,
|
|
880
925
|
};
|
|
881
926
|
}
|
|
882
|
-
function buildManifest(cwd, packageJson, framework, existingManifest) {
|
|
927
|
+
function buildManifest(cwd, packageJson, framework, existingManifest, tooling) {
|
|
883
928
|
return {
|
|
884
929
|
$schema: existingManifest?.$schema ?? exports.LOOM_MANIFEST_SCHEMA,
|
|
885
930
|
version: 1,
|
|
@@ -891,6 +936,7 @@ function buildManifest(cwd, packageJson, framework, existingManifest) {
|
|
|
891
936
|
...existingManifest?.project?.framework,
|
|
892
937
|
...framework,
|
|
893
938
|
},
|
|
939
|
+
tooling: existingManifest?.project?.tooling ?? tooling,
|
|
894
940
|
},
|
|
895
941
|
features: existingManifest?.features ?? {},
|
|
896
942
|
};
|
|
@@ -910,33 +956,6 @@ function hasPackageDependency(packageJson, dependencyName) {
|
|
|
910
956
|
return Boolean(packageJson.dependencies?.[dependencyName] ||
|
|
911
957
|
packageJson.devDependencies?.[dependencyName]);
|
|
912
958
|
}
|
|
913
|
-
async function detectPackageManager(cwd, packageJson) {
|
|
914
|
-
if (packageJson.packageManager?.startsWith("pnpm@")) {
|
|
915
|
-
return "pnpm";
|
|
916
|
-
}
|
|
917
|
-
if (packageJson.packageManager?.startsWith("yarn@")) {
|
|
918
|
-
return "yarn";
|
|
919
|
-
}
|
|
920
|
-
if (packageJson.packageManager?.startsWith("npm@")) {
|
|
921
|
-
return "npm";
|
|
922
|
-
}
|
|
923
|
-
if (await exists((0, node_path_1.join)(cwd, "pnpm-lock.yaml"))) {
|
|
924
|
-
return "pnpm";
|
|
925
|
-
}
|
|
926
|
-
if (await exists((0, node_path_1.join)(cwd, "yarn.lock"))) {
|
|
927
|
-
return "yarn";
|
|
928
|
-
}
|
|
929
|
-
return "npm";
|
|
930
|
-
}
|
|
931
|
-
function getRunScriptCommand(packageManager, scriptName) {
|
|
932
|
-
if (packageManager === "pnpm") {
|
|
933
|
-
return `pnpm ${scriptName}`;
|
|
934
|
-
}
|
|
935
|
-
if (packageManager === "yarn") {
|
|
936
|
-
return `yarn ${scriptName}`;
|
|
937
|
-
}
|
|
938
|
-
return `npm run ${scriptName}`;
|
|
939
|
-
}
|
|
940
959
|
function scriptRunsSerwistBuild(script) {
|
|
941
960
|
return Boolean(script && (/\bserwist\s+build\b/.test(script) ||
|
|
942
961
|
script.includes("@serwist/cli") ||
|
|
@@ -951,35 +970,6 @@ function formatTsNumberLiteral(value) {
|
|
|
951
970
|
function numberLiteralRegExp(value) {
|
|
952
971
|
return String(value).split("").map((digit) => `${digit}_?`).join("");
|
|
953
972
|
}
|
|
954
|
-
function ensurePwaPackageJsonScripts(packageJson, packageManager) {
|
|
955
|
-
const nextPackageJson = structuredClone(packageJson);
|
|
956
|
-
nextPackageJson.scripts ??= {};
|
|
957
|
-
const changedKeys = [];
|
|
958
|
-
const notes = [];
|
|
959
|
-
if (nextPackageJson.scripts["pwa:build"] !== PWA_BUILD_SCRIPT) {
|
|
960
|
-
nextPackageJson.scripts["pwa:build"] = PWA_BUILD_SCRIPT;
|
|
961
|
-
changedKeys.push("pwa:build");
|
|
962
|
-
}
|
|
963
|
-
const buildScript = nextPackageJson.scripts.build;
|
|
964
|
-
if (!buildScript) {
|
|
965
|
-
nextPackageJson.scripts.build = `next build && ${getRunScriptCommand(packageManager, "pwa:build")}`;
|
|
966
|
-
changedKeys.push("build");
|
|
967
|
-
}
|
|
968
|
-
else if (buildScript.includes("next build") &&
|
|
969
|
-
!scriptRunsSerwistBuild(buildScript)) {
|
|
970
|
-
nextPackageJson.scripts.build = `${buildScript} && ${getRunScriptCommand(packageManager, "pwa:build")}`;
|
|
971
|
-
changedKeys.push("build");
|
|
972
|
-
}
|
|
973
|
-
else if (!scriptRunsSerwistBuild(buildScript)) {
|
|
974
|
-
notes.push("PWA build script was added, but the existing build script does not visibly run `next build`; wire `pwa:build` after the app's Next.js build step.");
|
|
975
|
-
}
|
|
976
|
-
return {
|
|
977
|
-
changed: changedKeys.length > 0,
|
|
978
|
-
changedKeys,
|
|
979
|
-
notes,
|
|
980
|
-
packageJson: nextPackageJson,
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
973
|
function getJobsConfig(framework) {
|
|
984
974
|
const appRoot = framework.srcDir ? "src/app" : "app";
|
|
985
975
|
const jobsRoot = framework.srcDir ? "src/jobs" : "jobs";
|
|
@@ -1222,12 +1212,37 @@ async function mergeAuthConfig(cwd, framework, featureConfig) {
|
|
|
1222
1212
|
},
|
|
1223
1213
|
};
|
|
1224
1214
|
}
|
|
1225
|
-
function
|
|
1215
|
+
function dependencyExecutable(tooling, executable) {
|
|
1216
|
+
switch (tooling.manager) {
|
|
1217
|
+
case "deno":
|
|
1218
|
+
return `deno run -A npm:${executable}`;
|
|
1219
|
+
case "npm":
|
|
1220
|
+
return `npx ${executable}`;
|
|
1221
|
+
case "pnpm":
|
|
1222
|
+
return `pnpm ${executable}`;
|
|
1223
|
+
case "yarn":
|
|
1224
|
+
return `yarn ${executable}`;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
function dependencyRefreshCommand(tooling, name, version) {
|
|
1228
|
+
switch (tooling.manager) {
|
|
1229
|
+
case "deno":
|
|
1230
|
+
return "deno install";
|
|
1231
|
+
case "npm":
|
|
1232
|
+
return `npm install --save-exact ${name}@${version}`;
|
|
1233
|
+
case "pnpm":
|
|
1234
|
+
return `pnpm update --no-save ${name}@${version} && pnpm install`;
|
|
1235
|
+
case "yarn":
|
|
1236
|
+
return `yarn add --exact ${name}@${version}`;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function getDbExpectedScripts(config, tooling) {
|
|
1240
|
+
const drizzleKit = dependencyExecutable(tooling.dependencies, "drizzle-kit");
|
|
1226
1241
|
return {
|
|
1227
1242
|
"db:fixtures": "loom db fixtures",
|
|
1228
|
-
"db:generate":
|
|
1229
|
-
"db:migrate":
|
|
1230
|
-
"db:push":
|
|
1243
|
+
"db:generate": `${drizzleKit} generate`,
|
|
1244
|
+
"db:migrate": `${drizzleKit} migrate`,
|
|
1245
|
+
"db:push": `${drizzleKit} push`,
|
|
1231
1246
|
"drizzle-kit": `NODE_OPTIONS='--import tsx' loom env -- drizzle-kit --config=./${config.modules.drizzleConfig}`,
|
|
1232
1247
|
"schema:gen": "loom db schema-gen",
|
|
1233
1248
|
};
|
|
@@ -1860,9 +1875,10 @@ For all work in this repo:
|
|
|
1860
1875
|
1. Use the \`loom\` skill first.
|
|
1861
1876
|
2. Read \`loom.json\` before making Loom-related changes.
|
|
1862
1877
|
3. Treat active Loom features and configured paths as the contract between the app and the shared package.
|
|
1863
|
-
4.
|
|
1864
|
-
5.
|
|
1865
|
-
6.
|
|
1878
|
+
4. Read \`project.tooling\` in \`loom.json\`; do not assume tasks live in \`package.json\` or that pnpm is the runner.
|
|
1879
|
+
5. If the task touches a specific active Loom feature, also use the matching feature skill such as \`loom-jobs\`.
|
|
1880
|
+
6. Next commands load \`.env*\` themselves; non-Next commands that need env should use the authoritative project task or \`loom env -- <command>\`, not inline env-loader imports.
|
|
1881
|
+
7. Keep project-specific rules outside this managed block; shared Loom policy lives in the \`loom\` skill.
|
|
1866
1882
|
${exports.LOOM_MANAGED_AGENTS_END}
|
|
1867
1883
|
`;
|
|
1868
1884
|
}
|
|
@@ -2125,6 +2141,37 @@ async function ensurePnpmProject(cwd, packageJson) {
|
|
|
2125
2141
|
}
|
|
2126
2142
|
throw new Error("loom dev local/published currently supports pnpm projects only.");
|
|
2127
2143
|
}
|
|
2144
|
+
function usesDenoTooling(tooling) {
|
|
2145
|
+
return tooling.tasks.runner === "deno" ||
|
|
2146
|
+
tooling.dependencies.manager === "deno";
|
|
2147
|
+
}
|
|
2148
|
+
async function getDenoConfigForLinks(cwd, tooling) {
|
|
2149
|
+
for (const config of [
|
|
2150
|
+
tooling.tasks.config,
|
|
2151
|
+
tooling.dependencies.config,
|
|
2152
|
+
"deno.json",
|
|
2153
|
+
"deno.jsonc",
|
|
2154
|
+
]) {
|
|
2155
|
+
if ((config === "deno.json" || config === "deno.jsonc") &&
|
|
2156
|
+
await exists((0, node_path_1.join)(cwd, config))) {
|
|
2157
|
+
return config;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
throw new Error("Deno local development requires a deno.json or deno.jsonc workspace root.");
|
|
2161
|
+
}
|
|
2162
|
+
async function findLocalLoomDenoLink(cwd, links) {
|
|
2163
|
+
for (const link of links) {
|
|
2164
|
+
const path = (0, node_path_1.resolve)(cwd, link);
|
|
2165
|
+
const packageText = await readTextIfExists((0, node_path_1.join)(path, "package.json"));
|
|
2166
|
+
if (!packageText)
|
|
2167
|
+
continue;
|
|
2168
|
+
if (parseJson(packageText, `${link}/package.json`).name ===
|
|
2169
|
+
exports.LOOM_DEPENDENCY) {
|
|
2170
|
+
return { link, path };
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
return null;
|
|
2174
|
+
}
|
|
2128
2175
|
async function resolveLocalLoomPackagePath(cwd, inputPath) {
|
|
2129
2176
|
const resolvedInput = (0, node_path_1.resolve)(cwd, inputPath);
|
|
2130
2177
|
const candidates = [resolvedInput, (0, node_path_1.join)(resolvedInput, "npm")];
|
|
@@ -2240,6 +2287,9 @@ async function readPackageVersion(packagePath) {
|
|
|
2240
2287
|
}
|
|
2241
2288
|
return parseJson(packageJsonText, (0, node_path_1.join)(packagePath, "package.json")).version;
|
|
2242
2289
|
}
|
|
2290
|
+
function versionFromDependencySpec(spec) {
|
|
2291
|
+
return spec?.match(/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/)?.[1];
|
|
2292
|
+
}
|
|
2243
2293
|
async function getGitStdout(commandRunner, cwd, args, env) {
|
|
2244
2294
|
const result = await commandRunner("git", args, { cwd, env });
|
|
2245
2295
|
if (result.code !== 0) {
|
|
@@ -2306,7 +2356,7 @@ async function writeLocalDevStateIfChanged(cwd, state) {
|
|
|
2306
2356
|
await (0, promises_1.writeFile)(gitignorePath, gitignoreUpdate.text, "utf8");
|
|
2307
2357
|
gitignoreChanged = true;
|
|
2308
2358
|
}
|
|
2309
|
-
return stateChanged
|
|
2359
|
+
return { gitignoreChanged, stateChanged };
|
|
2310
2360
|
}
|
|
2311
2361
|
async function getCurrentLocalDevState(cwd, workspaceText) {
|
|
2312
2362
|
return getManagedDevState(workspaceText) ?? await readLocalDevState(cwd);
|
|
@@ -2422,10 +2472,19 @@ async function resolveLoomCommitPublication(sourceRoot, sourceCommit, commandRun
|
|
|
2422
2472
|
return { status: "no-release-tag" };
|
|
2423
2473
|
}
|
|
2424
2474
|
async function syncLocalDevPackage(cwd, options = {}) {
|
|
2475
|
+
const manifest = await readManifestIfExists(cwd);
|
|
2476
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
2477
|
+
const denoMode = usesDenoTooling(tooling);
|
|
2425
2478
|
const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
|
|
2426
2479
|
const workspaceText = await readTextIfExists(workspacePath);
|
|
2427
2480
|
const overrideSpec = getManagedDevOverrideSpec(workspaceText);
|
|
2428
|
-
|
|
2481
|
+
const denoConfig = denoMode
|
|
2482
|
+
? await getDenoConfigForLinks(cwd, tooling)
|
|
2483
|
+
: null;
|
|
2484
|
+
const denoLink = denoConfig
|
|
2485
|
+
? await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig))
|
|
2486
|
+
: null;
|
|
2487
|
+
if (!overrideSpec && !denoLink) {
|
|
2429
2488
|
if (options.requireActive) {
|
|
2430
2489
|
throw new Error("No managed Loom local-dev override is active. Run `loom dev local /path/to/loom` first.");
|
|
2431
2490
|
}
|
|
@@ -2438,20 +2497,31 @@ async function syncLocalDevPackage(cwd, options = {}) {
|
|
|
2438
2497
|
};
|
|
2439
2498
|
}
|
|
2440
2499
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
2441
|
-
|
|
2500
|
+
if (!denoMode)
|
|
2501
|
+
await ensurePnpmProject(cwd, packageJson);
|
|
2442
2502
|
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
2443
2503
|
const env = options.env ?? node_process_1.default.env;
|
|
2444
|
-
const localPackagePath =
|
|
2504
|
+
const localPackagePath = denoLink?.path ??
|
|
2505
|
+
fileSpecToPath(cwd, overrideSpec);
|
|
2445
2506
|
const sourceRoot = await resolveLocalLoomSourceRoot(localPackagePath);
|
|
2507
|
+
const configuredSpec = packageJson.dependencies?.[exports.LOOM_DEPENDENCY] ??
|
|
2508
|
+
packageJson.devDependencies?.[exports.LOOM_DEPENDENCY];
|
|
2509
|
+
const desiredLocalVersion = await readPackageVersion((0, node_path_1.join)(cwd, "node_modules", exports.LOOM_DEPENDENCY)) ?? versionFromDependencySpec(configuredSpec) ??
|
|
2510
|
+
await readPackageVersion(localPackagePath);
|
|
2511
|
+
const currentLocalVersion = await readPackageVersion(localPackagePath);
|
|
2512
|
+
const buildEnv = desiredLocalVersion && !env.NPM_PACKAGE_VERSION
|
|
2513
|
+
? { ...env, NPM_PACKAGE_VERSION: desiredLocalVersion }
|
|
2514
|
+
: env;
|
|
2446
2515
|
const ranCommands = [];
|
|
2447
2516
|
let buildRan = false;
|
|
2448
|
-
if (options.force ||
|
|
2517
|
+
if (options.force || denoMode && currentLocalVersion !== desiredLocalVersion ||
|
|
2518
|
+
await isLocalLoomBuildStale(sourceRoot, localPackagePath)) {
|
|
2449
2519
|
if (!sourceRoot) {
|
|
2450
2520
|
throw new Error(`Could not find the Loom source checkout for ${localPackagePath}; cannot rebuild the local package.`);
|
|
2451
2521
|
}
|
|
2452
2522
|
await runCommandOrThrow(commandRunner, "deno", ["task", "build"], {
|
|
2453
2523
|
cwd: sourceRoot,
|
|
2454
|
-
env,
|
|
2524
|
+
env: buildEnv,
|
|
2455
2525
|
stdio: "inherit",
|
|
2456
2526
|
});
|
|
2457
2527
|
ranCommands.push("deno task build");
|
|
@@ -2461,25 +2531,39 @@ async function syncLocalDevPackage(cwd, options = {}) {
|
|
|
2461
2531
|
await isInstalledLocalLoomPackageStale(cwd, localPackagePath);
|
|
2462
2532
|
let packageRefreshRan = false;
|
|
2463
2533
|
if (options.force || packageRefreshNeeded) {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2534
|
+
if (denoMode) {
|
|
2535
|
+
await runCommandOrThrow(commandRunner, "deno", ["install"], {
|
|
2536
|
+
cwd,
|
|
2537
|
+
env,
|
|
2538
|
+
stdio: "inherit",
|
|
2539
|
+
});
|
|
2540
|
+
ranCommands.push("deno install");
|
|
2541
|
+
}
|
|
2542
|
+
else {
|
|
2543
|
+
const packageSpec = `${exports.LOOM_DEPENDENCY}@file:${localPackagePath}`;
|
|
2544
|
+
await runCommandOrThrow(commandRunner, "pnpm", ["update", "--no-save", packageSpec], { cwd, env, stdio: "inherit" });
|
|
2545
|
+
ranCommands.push(`pnpm update --no-save ${packageSpec}`);
|
|
2546
|
+
await runCommandOrThrow(commandRunner, "pnpm", ["install"], {
|
|
2547
|
+
cwd,
|
|
2548
|
+
env,
|
|
2549
|
+
stdio: "inherit",
|
|
2550
|
+
});
|
|
2551
|
+
ranCommands.push("pnpm install");
|
|
2552
|
+
}
|
|
2473
2553
|
packageRefreshRan = true;
|
|
2474
2554
|
}
|
|
2475
2555
|
const currentWorkspaceText = await readTextIfExists(workspacePath);
|
|
2476
|
-
const currentState =
|
|
2556
|
+
const currentState = denoMode
|
|
2557
|
+
? await readLocalDevState(cwd)
|
|
2558
|
+
: await getCurrentLocalDevState(cwd, currentWorkspaceText);
|
|
2477
2559
|
let state = null;
|
|
2478
2560
|
if (buildRan || packageRefreshRan || !currentState) {
|
|
2479
2561
|
state = await buildLocalDevState(localPackagePath, sourceRoot, commandRunner, env);
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2562
|
+
if (!denoMode) {
|
|
2563
|
+
const stateUpdate = setManagedDevStateText(await readTextIfExists(workspacePath), overrideSpec, state);
|
|
2564
|
+
if (stateUpdate.changed) {
|
|
2565
|
+
await writeTextOrDeleteIfEmpty(workspacePath, stateUpdate.text);
|
|
2566
|
+
}
|
|
2483
2567
|
}
|
|
2484
2568
|
}
|
|
2485
2569
|
if (state ?? currentState) {
|
|
@@ -2508,16 +2592,43 @@ async function syncLocalDevPackage(cwd, options = {}) {
|
|
|
2508
2592
|
};
|
|
2509
2593
|
}
|
|
2510
2594
|
async function useLocalDevPackage(cwd, inputPath) {
|
|
2511
|
-
const
|
|
2512
|
-
const
|
|
2513
|
-
|
|
2514
|
-
|
|
2595
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
2596
|
+
const manifest = await readManifestIfExists(cwd);
|
|
2597
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
2598
|
+
const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
|
|
2599
|
+
const publishedSpec = getPublishedLoomDependencySpec(packageJson);
|
|
2600
|
+
if (usesDenoTooling(tooling)) {
|
|
2601
|
+
if (!await exists((0, node_path_1.join)(localPackagePath, "deno.json"))) {
|
|
2602
|
+
throw new Error(`Local Deno development requires ${localPackagePath}/deno.json. Rebuild the Loom npm output before linking it.`);
|
|
2603
|
+
}
|
|
2604
|
+
const denoConfig = await getDenoConfigForLinks(cwd, tooling);
|
|
2605
|
+
const relativeLocalPackagePath = (0, node_path_1.relative)(cwd, localPackagePath)
|
|
2606
|
+
.replaceAll("\\", "/");
|
|
2607
|
+
const update = await (0, projectTooling_js_1.mutateDenoLinks)(cwd, denoConfig, {
|
|
2608
|
+
add: relativeLocalPackagePath,
|
|
2609
|
+
});
|
|
2610
|
+
const state = {
|
|
2611
|
+
dependency: exports.LOOM_DEPENDENCY,
|
|
2612
|
+
localPackagePath,
|
|
2613
|
+
packageVersion: await readPackageVersion(localPackagePath),
|
|
2614
|
+
syncedAt: new Date().toISOString(),
|
|
2615
|
+
version: 1,
|
|
2616
|
+
};
|
|
2617
|
+
const stateUpdate = await writeLocalDevStateIfChanged(cwd, state);
|
|
2618
|
+
const changedFiles = update.changed ? [denoConfig] : [];
|
|
2619
|
+
if (stateUpdate.gitignoreChanged)
|
|
2620
|
+
changedFiles.push(".gitignore");
|
|
2621
|
+
return {
|
|
2622
|
+
changedFiles,
|
|
2623
|
+
notes: [
|
|
2624
|
+
`Local Loom dev link is active in ${denoConfig}: ${localPackagePath}`,
|
|
2625
|
+
"Run `loom dev sync` to rebuild the local Loom package and refresh Deno's dependency installation when needed.",
|
|
2626
|
+
`Before committing or shipping a published build, run loom dev published, then deno install to restore ${exports.LOOM_DEPENDENCY}@${publishedSpec}.`,
|
|
2627
|
+
],
|
|
2628
|
+
};
|
|
2515
2629
|
}
|
|
2516
|
-
const packageJson = parseJson(packageJsonText, "package.json");
|
|
2517
2630
|
await ensurePnpmProject(cwd, packageJson);
|
|
2518
|
-
const localPackagePath = await resolveLocalLoomPackagePath(cwd, inputPath);
|
|
2519
2631
|
const overrideSpec = `file:${localPackagePath}`;
|
|
2520
|
-
const publishedSpec = getPublishedLoomDependencySpec(packageJson);
|
|
2521
2632
|
const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
|
|
2522
2633
|
const update = ensurePnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath), overrideSpec);
|
|
2523
2634
|
if (update.conflict) {
|
|
@@ -2538,20 +2649,30 @@ async function useLocalDevPackage(cwd, inputPath) {
|
|
|
2538
2649
|
};
|
|
2539
2650
|
}
|
|
2540
2651
|
async function usePublishedDevPackage(cwd, options = {}) {
|
|
2541
|
-
const
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
await ensurePnpmProject(cwd, packageJson);
|
|
2652
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
2653
|
+
const manifest = await readManifestIfExists(cwd);
|
|
2654
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
2655
|
+
const denoMode = usesDenoTooling(tooling);
|
|
2656
|
+
if (!denoMode)
|
|
2657
|
+
await ensurePnpmProject(cwd, packageJson);
|
|
2548
2658
|
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
2549
2659
|
const env = options.env ?? node_process_1.default.env;
|
|
2550
2660
|
const workspacePath = (0, node_path_1.join)(cwd, "pnpm-workspace.yaml");
|
|
2551
2661
|
const workspaceText = await readTextIfExists(workspacePath);
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2554
|
-
|
|
2662
|
+
const denoConfig = denoMode
|
|
2663
|
+
? await getDenoConfigForLinks(cwd, tooling)
|
|
2664
|
+
: null;
|
|
2665
|
+
const denoLink = denoConfig
|
|
2666
|
+
? await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig))
|
|
2667
|
+
: null;
|
|
2668
|
+
const activeOverrideSpec = denoLink?.link ??
|
|
2669
|
+
getManagedDevOverrideSpec(workspaceText);
|
|
2670
|
+
const localLockfileResolution = denoMode
|
|
2671
|
+
? null
|
|
2672
|
+
: await getProjectLocalLoomLockfileResolution(cwd);
|
|
2673
|
+
const state = denoMode
|
|
2674
|
+
? await readLocalDevState(cwd)
|
|
2675
|
+
: await getCurrentLocalDevState(cwd, workspaceText);
|
|
2555
2676
|
const notes = [];
|
|
2556
2677
|
let publishedSpec = getPublishedLoomDependencySpec(packageJson);
|
|
2557
2678
|
const needsPublicationProof = Boolean(activeOverrideSpec || localLockfileResolution);
|
|
@@ -2574,21 +2695,33 @@ async function usePublishedDevPackage(cwd, options = {}) {
|
|
|
2574
2695
|
else if (needsPublicationProof) {
|
|
2575
2696
|
notes.push("No recorded Loom sync commit was found; switching back to the existing published dependency without proving whether local Loom changes were required.");
|
|
2576
2697
|
}
|
|
2577
|
-
const dependencyUpdate =
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
}
|
|
2581
|
-
const
|
|
2698
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
2699
|
+
dependencies: { [exports.LOOM_DEPENDENCY]: publishedSpec },
|
|
2700
|
+
replace: true,
|
|
2701
|
+
});
|
|
2702
|
+
const denoUpdate = denoConfig && denoLink
|
|
2703
|
+
? await (0, projectTooling_js_1.mutateDenoLinks)(cwd, denoConfig, { remove: denoLink.link })
|
|
2704
|
+
: null;
|
|
2705
|
+
const update = denoMode
|
|
2706
|
+
? { changed: denoUpdate?.changed ?? false, text: "" }
|
|
2707
|
+
: clearPnpmWorkspaceLocalDevText(await readTextIfExists(workspacePath));
|
|
2582
2708
|
const changedFiles = [];
|
|
2583
2709
|
if (dependencyUpdate.changed) {
|
|
2584
|
-
changedFiles.push(
|
|
2710
|
+
changedFiles.push(dependencyUpdate.config);
|
|
2585
2711
|
}
|
|
2586
2712
|
if (update.changed) {
|
|
2587
|
-
|
|
2588
|
-
|
|
2713
|
+
if (denoMode) {
|
|
2714
|
+
changedFiles.push(denoConfig);
|
|
2715
|
+
}
|
|
2716
|
+
else {
|
|
2717
|
+
await writeTextOrDeleteIfEmpty(workspacePath, update.text);
|
|
2718
|
+
changedFiles.push("pnpm-workspace.yaml");
|
|
2719
|
+
}
|
|
2589
2720
|
}
|
|
2590
2721
|
if (update.changed || localLockfileResolution) {
|
|
2591
|
-
notes.push(
|
|
2722
|
+
notes.push(denoMode
|
|
2723
|
+
? `Run \`deno install\` in this project to return node_modules and deno.lock to published ${exports.LOOM_DEPENDENCY}@${publishedSpec}.`
|
|
2724
|
+
: `Run \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@${publishedSpec}\` and then \`pnpm install\` in this project to return node_modules and the lockfile to the published ${exports.LOOM_DEPENDENCY} dependency.`);
|
|
2592
2725
|
}
|
|
2593
2726
|
if (localLockfileResolution) {
|
|
2594
2727
|
notes.push(`pnpm-lock.yaml still resolves ${exports.LOOM_DEPENDENCY} to ${localLockfileResolution} until that update is run.`);
|
|
@@ -2722,26 +2855,43 @@ async function checkManagedAgentsFile(cwd) {
|
|
|
2722
2855
|
};
|
|
2723
2856
|
}
|
|
2724
2857
|
async function checkManagedLocalDevOverride(cwd, production = false) {
|
|
2858
|
+
const manifest = await readManifestIfExists(cwd);
|
|
2859
|
+
let denoLink = null;
|
|
2860
|
+
let denoConfig = null;
|
|
2861
|
+
try {
|
|
2862
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
2863
|
+
if (usesDenoTooling(tooling)) {
|
|
2864
|
+
denoConfig = await getDenoConfigForLinks(cwd, tooling);
|
|
2865
|
+
denoLink = await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, denoConfig));
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
catch {
|
|
2869
|
+
// The main project tooling check reports invalid configuration separately.
|
|
2870
|
+
}
|
|
2725
2871
|
const workspaceText = await readTextIfExists((0, node_path_1.join)(cwd, "pnpm-workspace.yaml"));
|
|
2726
2872
|
const overrideSpec = getManagedDevOverrideSpec(workspaceText);
|
|
2727
|
-
if (!overrideSpec) {
|
|
2873
|
+
if (!overrideSpec && !denoLink) {
|
|
2728
2874
|
return {
|
|
2729
2875
|
issues: [],
|
|
2730
2876
|
suggestions: [],
|
|
2731
2877
|
warnings: [],
|
|
2732
2878
|
};
|
|
2733
2879
|
}
|
|
2880
|
+
const location = denoLink
|
|
2881
|
+
? `${denoConfig} links: ${denoLink.link}`
|
|
2882
|
+
: `pnpm-workspace.yaml: ${overrideSpec}`;
|
|
2883
|
+
const restore = denoLink
|
|
2884
|
+
? "Run `loom dev published`, then run `deno install` before committing or shipping a published build."
|
|
2885
|
+
: `Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`;
|
|
2734
2886
|
return {
|
|
2735
2887
|
issues: production
|
|
2736
2888
|
? [
|
|
2737
|
-
`Local Loom dev override is active in
|
|
2889
|
+
`Local Loom dev override is active in ${location}`,
|
|
2738
2890
|
]
|
|
2739
2891
|
: [],
|
|
2740
|
-
suggestions: [
|
|
2741
|
-
`Run \`loom dev published\`, then follow its printed \`pnpm update --no-save ${exports.LOOM_DEPENDENCY}@<version>\` command and run \`pnpm install\` before committing or shipping a published build.`,
|
|
2742
|
-
],
|
|
2892
|
+
suggestions: [restore],
|
|
2743
2893
|
warnings: production ? [] : [
|
|
2744
|
-
`Local Loom dev override is active in
|
|
2894
|
+
`Local Loom dev override is active in ${location}`,
|
|
2745
2895
|
],
|
|
2746
2896
|
};
|
|
2747
2897
|
}
|
|
@@ -2782,6 +2932,18 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
|
|
|
2782
2932
|
const warnings = [];
|
|
2783
2933
|
const dependency = packageJson.dependencies?.[exports.LOOM_DEPENDENCY];
|
|
2784
2934
|
const production = options.production;
|
|
2935
|
+
const projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
2936
|
+
let dependencyTooling = {
|
|
2937
|
+
config: projectMetadata.config,
|
|
2938
|
+
manager: projectMetadata.config === "package.json" ? "pnpm" : "deno",
|
|
2939
|
+
};
|
|
2940
|
+
try {
|
|
2941
|
+
const manifest = await readManifestIfExists(cwd);
|
|
2942
|
+
dependencyTooling = (await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling)).dependencies;
|
|
2943
|
+
}
|
|
2944
|
+
catch {
|
|
2945
|
+
// The main tooling check owns the validation error; release hints can fall back.
|
|
2946
|
+
}
|
|
2785
2947
|
const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
|
|
2786
2948
|
const devState = await readLocalDevState(cwd);
|
|
2787
2949
|
if (localLockfileResolution) {
|
|
@@ -2815,8 +2977,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
|
|
|
2815
2977
|
"package-equivalent"
|
|
2816
2978
|
? `package-relevant files match ${exports.LOOM_DEPENDENCY}@${publication.version}`
|
|
2817
2979
|
: `it is published as ${exports.LOOM_DEPENDENCY}@${publication.version}`;
|
|
2818
|
-
addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but
|
|
2819
|
-
suggestions.add(`Run
|
|
2980
|
+
addReleaseCheckMessage(issues, warnings, production, `This app was last synced against Loom commit ${shortCommit}; ${publicationDescription}, but ${dependencyTooling.config} is pinned to ${dependency}.`);
|
|
2981
|
+
suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, publication.version)}.`);
|
|
2820
2982
|
}
|
|
2821
2983
|
else if (localLockfileResolution) {
|
|
2822
2984
|
const publicationDescription = publication.reason ===
|
|
@@ -2824,7 +2986,7 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
|
|
|
2824
2986
|
? `has no package-relevant changes after ${publication.tag}, so ${exports.LOOM_DEPENDENCY}@${publication.version} covers it`
|
|
2825
2987
|
: `is published as ${exports.LOOM_DEPENDENCY}@${publication.version}`;
|
|
2826
2988
|
warnings.push(`The synced Loom commit ${shortCommit} ${publicationDescription}; refresh the lockfile away from ${localLockfileResolution}.`);
|
|
2827
|
-
suggestions.add(`Run
|
|
2989
|
+
suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, publication.version)}.`);
|
|
2828
2990
|
}
|
|
2829
2991
|
break;
|
|
2830
2992
|
}
|
|
@@ -2849,8 +3011,8 @@ async function checkLoomReleaseState(cwd, packageJson, options) {
|
|
|
2849
3011
|
else {
|
|
2850
3012
|
const installedPackage = parseJson(installedPackageText, (0, node_path_1.join)("node_modules", exports.LOOM_DEPENDENCY, "package.json"));
|
|
2851
3013
|
if (installedPackage.version !== dependency) {
|
|
2852
|
-
issues.push(`Installed ${exports.LOOM_DEPENDENCY} version ${installedPackage.version} does not match
|
|
2853
|
-
suggestions.add(`Run
|
|
3014
|
+
issues.push(`Installed ${exports.LOOM_DEPENDENCY} version ${installedPackage.version} does not match ${dependencyTooling.config} ${dependency}.`);
|
|
3015
|
+
suggestions.add(`Run ${dependencyRefreshCommand(dependencyTooling, exports.LOOM_DEPENDENCY, dependency)}.`);
|
|
2854
3016
|
}
|
|
2855
3017
|
}
|
|
2856
3018
|
}
|
|
@@ -2924,7 +3086,7 @@ function getGithubWorkflowStepBlocks(text) {
|
|
|
2924
3086
|
}
|
|
2925
3087
|
function workflowInstallsNodeDependencies(stepBlocks) {
|
|
2926
3088
|
return stepBlocks.some((block) => /uses:\s*actions\/setup-node@/m.test(block) ||
|
|
2927
|
-
/\b(?:pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
|
|
3089
|
+
/\b(?:deno\s+install|pnpm\s+(?:install|i)|npm\s+(?:ci|install)|yarn\s+install|bun\s+install)\b/
|
|
2928
3090
|
.test(block));
|
|
2929
3091
|
}
|
|
2930
3092
|
function hasGithubPackagesSetupNodeConfig(stepBlocks) {
|
|
@@ -3047,14 +3209,14 @@ function githubWorkflowRunsOnMainPush(text) {
|
|
|
3047
3209
|
return !hasBranchFilter && !ignoresMain;
|
|
3048
3210
|
}
|
|
3049
3211
|
function workflowStepRunsDbMigrate(block) {
|
|
3050
|
-
return /\b(?:pnpm\s+(?:run\s+)?db:migrate|npm\s+run\s+db:migrate|yarn\s+(?:run\s+)?db:migrate|bun\s+run\s+db:migrate)\b/
|
|
3212
|
+
return /\b(?:deno\s+task\s+db:migrate|pnpm\s+(?:run\s+)?db:migrate|npm\s+run\s+db:migrate|yarn\s+(?:run\s+)?db:migrate|bun\s+run\s+db:migrate)\b/
|
|
3051
3213
|
.test(block) ||
|
|
3052
3214
|
/\bdrizzle-kit\s+migrate\b/.test(block) ||
|
|
3053
3215
|
/spawnSync\(\s*["']pnpm["'][\s\S]*["']db:migrate["']/.test(block);
|
|
3054
3216
|
}
|
|
3055
3217
|
function workflowStepUsesVercelCommand(block, subcommand) {
|
|
3056
3218
|
const launcher = String
|
|
3057
|
-
.raw `(?:vercel|pnpm\s+(?:dlx|exec)\s+vercel(?:@[^\s]+)?|npx\s+vercel(?:@[^\s]+)?|yarn\s+(?:dlx\s+)?vercel(?:@[^\s]+)?|bunx\s+vercel(?:@[^\s]+)?)`;
|
|
3219
|
+
.raw `(?:vercel|deno\s+run\s+-A\s+npm:vercel(?:@[^\s]+)?|pnpm\s+(?:dlx|exec)\s+vercel(?:@[^\s]+)?|npx\s+vercel(?:@[^\s]+)?|yarn\s+(?:dlx\s+)?vercel(?:@[^\s]+)?|bunx\s+vercel(?:@[^\s]+)?)`;
|
|
3058
3220
|
const globalFlags = String
|
|
3059
3221
|
.raw `(?:\s+(?:--[A-Za-z-]+(?:=(?:"[^"]+"|'[^']+'|[^\s]+)|\s+(?:"[^"]+"|'[^']+'|[^\s]+))?|-[A-Za-z](?:\s+(?:"[^"]+"|'[^']+'|[^\s]+))?))*`;
|
|
3060
3222
|
return new RegExp(String.raw `\b${launcher}${globalFlags}\s+${subcommand}\b`)
|
|
@@ -4016,10 +4178,13 @@ function dbScriptsTsconfigTemplate() {
|
|
|
4016
4178
|
}
|
|
4017
4179
|
`;
|
|
4018
4180
|
}
|
|
4019
|
-
function dbPgliteHarnessTemplate(config) {
|
|
4181
|
+
function dbPgliteHarnessTemplate(config, testRunner = "vitest") {
|
|
4020
4182
|
const schemaImportPath = toRelativeImportPath(config.modules.pgliteHarnessModule, (0, node_path_1.join)(config.dirs.schemaDir, "index.ts"));
|
|
4183
|
+
const afterAllImport = testRunner === "deno"
|
|
4184
|
+
? 'import { afterAll } from "jsr:@std/testing@^1.0.19/bdd";'
|
|
4185
|
+
: 'import { afterAll } from "vitest";';
|
|
4021
4186
|
return `import { createMemoryPgliteHarness } from "@gadicc/loom/db/testing";
|
|
4022
|
-
|
|
4187
|
+
${afterAllImport}
|
|
4023
4188
|
import * as schema from "${schemaImportPath}";
|
|
4024
4189
|
|
|
4025
4190
|
const harness = await createMemoryPgliteHarness({
|
|
@@ -4040,6 +4205,14 @@ afterAll(closeMemoryPglite);
|
|
|
4040
4205
|
export const { client, db, tableLoader } = harness;
|
|
4041
4206
|
`;
|
|
4042
4207
|
}
|
|
4208
|
+
async function getDbTestRunner(cwd, tooling) {
|
|
4209
|
+
if (tooling.tasks.runner !== "deno")
|
|
4210
|
+
return "vitest";
|
|
4211
|
+
const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
4212
|
+
return /\bvitest\b/.test((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.test) ?? "")
|
|
4213
|
+
? "vitest"
|
|
4214
|
+
: "deno";
|
|
4215
|
+
}
|
|
4043
4216
|
function dbFixturesScriptTemplate(config) {
|
|
4044
4217
|
const schemaImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, (0, node_path_1.join)(config.dirs.schemaDir, "index.ts"));
|
|
4045
4218
|
const neonImportPath = toRelativeImportPath(config.modules.fixtureDumpScript, config.modules.neonModule);
|
|
@@ -5078,14 +5251,11 @@ async function materializeManagedSchema(cwd, schema, dbConfig) {
|
|
|
5078
5251
|
};
|
|
5079
5252
|
}
|
|
5080
5253
|
async function readProjectPackageJson(cwd) {
|
|
5081
|
-
const
|
|
5082
|
-
const packageJsonText = await readTextIfExists(packageJsonPath);
|
|
5083
|
-
if (!packageJsonText) {
|
|
5084
|
-
throw new Error(`No package.json found in ${cwd}`);
|
|
5085
|
-
}
|
|
5254
|
+
const metadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
5086
5255
|
return {
|
|
5087
|
-
packageJson:
|
|
5088
|
-
packageJsonPath,
|
|
5256
|
+
packageJson: metadata.packageJson,
|
|
5257
|
+
packageJsonPath: metadata.path,
|
|
5258
|
+
projectConfig: metadata.config,
|
|
5089
5259
|
};
|
|
5090
5260
|
}
|
|
5091
5261
|
async function resolveDbProjectConfig(cwd) {
|
|
@@ -5174,7 +5344,8 @@ async function syncDbSchemas(cwd) {
|
|
|
5174
5344
|
changedFiles.push("loom.json");
|
|
5175
5345
|
}
|
|
5176
5346
|
if (changedFiles.length) {
|
|
5177
|
-
|
|
5347
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
5348
|
+
notes.push(`No migrations were generated. Review the schema diff, then run ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate")} if the schema changed.`);
|
|
5178
5349
|
}
|
|
5179
5350
|
return {
|
|
5180
5351
|
changedFiles: [...new Set(changedFiles)],
|
|
@@ -5515,7 +5686,7 @@ async function setupCloudflareR2(cwd, options = {}) {
|
|
|
5515
5686
|
if (options.localProvider === "r2" && !options.localBucket) {
|
|
5516
5687
|
throw new Error("--local-provider r2 requires an explicit --local-bucket.");
|
|
5517
5688
|
}
|
|
5518
|
-
const { packageJson
|
|
5689
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
5519
5690
|
const framework = await detectFramework(cwd, packageJson);
|
|
5520
5691
|
const manifestPath = (0, node_path_1.join)(cwd, "loom.json");
|
|
5521
5692
|
const manifestText = await readTextIfExists(manifestPath);
|
|
@@ -5523,6 +5694,7 @@ async function setupCloudflareR2(cwd, options = {}) {
|
|
|
5523
5694
|
throw new Error("Missing loom.json. Run `loom add files` first.");
|
|
5524
5695
|
}
|
|
5525
5696
|
const manifest = parseJson(manifestText, "loom.json");
|
|
5697
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
5526
5698
|
const feature = manifest.features.files;
|
|
5527
5699
|
if (!feature || feature.status !== "active") {
|
|
5528
5700
|
throw new Error("The files feature is not active. Run `loom add files` first.");
|
|
@@ -5680,11 +5852,10 @@ async function setupCloudflareR2(cwd, options = {}) {
|
|
|
5680
5852
|
throw new Error(`R2 bucket \`${bucket}\` exists, but Loom could not verify its private-access policy: ${privacy.detail}. Rerun after Wrangler can inspect public URL and custom-domain settings.`);
|
|
5681
5853
|
}
|
|
5682
5854
|
}
|
|
5683
|
-
const dependencyUpdate =
|
|
5855
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, { dependencies: FILES_S3_DEPENDENCIES });
|
|
5684
5856
|
if (dependencyUpdate.changed) {
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")}.`);
|
|
5857
|
+
changedFiles.push(dependencyUpdate.config);
|
|
5858
|
+
notes.push(`Added files storage dependency: ${dependencyUpdate.changedKeys.join(", ")} to ${dependencyUpdate.config}.`);
|
|
5688
5859
|
}
|
|
5689
5860
|
const storagePath = (0, node_path_1.join)(cwd, config.modules.storageModule);
|
|
5690
5861
|
const storageText = await readTextIfExists(storagePath);
|
|
@@ -7137,26 +7308,21 @@ async function applyJobsFeature(cwd, framework, manifest, activate) {
|
|
|
7137
7308
|
? structuredClone(currentFeature)
|
|
7138
7309
|
: { status: "planned" };
|
|
7139
7310
|
const config = mergeJobsConfig(framework, feature.config);
|
|
7140
|
-
const
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
if (
|
|
7149
|
-
scriptsUpdate.
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
}
|
|
7153
|
-
if (dependencyUpdate.changedKeys.length ||
|
|
7154
|
-
devDependencyUpdate.changedKeys.length) {
|
|
7155
|
-
notes.push(`Added jobs package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
|
|
7156
|
-
.join(", ")}`);
|
|
7311
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
7312
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
7313
|
+
dependencies: JOBS_DEFAULT_DEPENDENCIES,
|
|
7314
|
+
devDependencies: JOBS_DEFAULT_DEV_DEPENDENCIES,
|
|
7315
|
+
});
|
|
7316
|
+
const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getJobsExpectedScripts(config));
|
|
7317
|
+
if (dependencyUpdate.changed)
|
|
7318
|
+
changedFiles.push(dependencyUpdate.config);
|
|
7319
|
+
if (scriptsUpdate.changedKeys.length)
|
|
7320
|
+
changedFiles.push(scriptsUpdate.config);
|
|
7321
|
+
if (dependencyUpdate.changedKeys.length) {
|
|
7322
|
+
notes.push(`Added jobs dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
|
|
7157
7323
|
}
|
|
7158
7324
|
if (scriptsUpdate.changedKeys.length) {
|
|
7159
|
-
notes.push(`Updated jobs
|
|
7325
|
+
notes.push(`Updated jobs tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
|
|
7160
7326
|
}
|
|
7161
7327
|
if (activate && feature.status !== "active") {
|
|
7162
7328
|
feature.status = "active";
|
|
@@ -7251,41 +7417,35 @@ async function applyDbFeature(cwd, framework, manifest, activate) {
|
|
|
7251
7417
|
}
|
|
7252
7418
|
feature.config = config;
|
|
7253
7419
|
manifest.features.db = feature;
|
|
7254
|
-
const
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
const
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
packageJsonChanged ||= removedDependencyUpdate.changed;
|
|
7269
|
-
if (packageJsonChanged) {
|
|
7270
|
-
await (0, promises_1.writeFile)(packageJsonPath, stringifyJson(nextPackageJson), "utf8");
|
|
7271
|
-
changedFiles.push("package.json");
|
|
7272
|
-
}
|
|
7273
|
-
if (dependencyUpdate.changedKeys.length ||
|
|
7274
|
-
devDependencyUpdate.changedKeys.length) {
|
|
7275
|
-
notes.push(`Added DB package.json dependencies: ${[...dependencyUpdate.changedKeys, ...devDependencyUpdate.changedKeys]
|
|
7276
|
-
.join(", ")}`);
|
|
7420
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
7421
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
7422
|
+
dependencies: DB_DEFAULT_DEPENDENCIES,
|
|
7423
|
+
devDependencies: DB_DEFAULT_DEV_DEPENDENCIES,
|
|
7424
|
+
remove: DB_MOVED_DEPENDENCIES,
|
|
7425
|
+
});
|
|
7426
|
+
const scriptsUpdate = await ensureProjectTasks(cwd, manifest, getDbExpectedScripts(config, tooling));
|
|
7427
|
+
const testRunner = await getDbTestRunner(cwd, tooling);
|
|
7428
|
+
if (dependencyUpdate.changed)
|
|
7429
|
+
changedFiles.push(dependencyUpdate.config);
|
|
7430
|
+
if (scriptsUpdate.changedKeys.length)
|
|
7431
|
+
changedFiles.push(scriptsUpdate.config);
|
|
7432
|
+
if (dependencyUpdate.changedKeys.length) {
|
|
7433
|
+
notes.push(`Added DB dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
|
|
7277
7434
|
}
|
|
7278
7435
|
if (scriptsUpdate.changedKeys.length) {
|
|
7279
|
-
notes.push(`Updated DB
|
|
7436
|
+
notes.push(`Updated DB tasks in ${scriptsUpdate.config}: ${scriptsUpdate.changedKeys.join(", ")}`);
|
|
7280
7437
|
}
|
|
7281
|
-
if (
|
|
7282
|
-
notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${
|
|
7438
|
+
if (dependencyUpdate.removedKeys.length) {
|
|
7439
|
+
notes.push(`Removed consumer-managed DB generator dependencies now owned by Loom: ${dependencyUpdate.removedKeys.join(", ")}`);
|
|
7283
7440
|
}
|
|
7284
7441
|
const managedFiles = [
|
|
7285
7442
|
[config.modules.neonModule, dbNeonTemplate()],
|
|
7286
7443
|
[config.modules.neonFullModule, dbNeonFullTemplate()],
|
|
7287
7444
|
[config.modules.drizzleConfig, dbDrizzleConfigTemplate(config)],
|
|
7288
|
-
[
|
|
7445
|
+
[
|
|
7446
|
+
config.modules.pgliteHarnessModule,
|
|
7447
|
+
dbPgliteHarnessTemplate(config, testRunner),
|
|
7448
|
+
],
|
|
7289
7449
|
[config.modules.scriptsTsconfig, dbScriptsTsconfigTemplate()],
|
|
7290
7450
|
[
|
|
7291
7451
|
config.modules.refinementsCommonModule,
|
|
@@ -7355,7 +7515,8 @@ async function applyFilesFeature(cwd, framework, manifest, activate) {
|
|
|
7355
7515
|
changedFiles.push(...materialized.changedFiles);
|
|
7356
7516
|
notes.push(...materialized.notes);
|
|
7357
7517
|
config.schema = materialized.schema;
|
|
7358
|
-
|
|
7518
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
7519
|
+
notes.push(`No migration was generated. Review the schema diff, then run ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate")} when you are ready to create the app-local migration.`);
|
|
7359
7520
|
}
|
|
7360
7521
|
const scaffoldFiles = [
|
|
7361
7522
|
[
|
|
@@ -7611,12 +7772,246 @@ async function applyAuthFeature(cwd, framework, manifest, activate) {
|
|
|
7611
7772
|
}
|
|
7612
7773
|
return { changedFiles, notes };
|
|
7613
7774
|
}
|
|
7775
|
+
function linguiCliCommand(tooling) {
|
|
7776
|
+
switch (tooling.dependencies.manager) {
|
|
7777
|
+
case "deno":
|
|
7778
|
+
return "deno run -A npm:@lingui/cli";
|
|
7779
|
+
case "npm":
|
|
7780
|
+
return "npx lingui";
|
|
7781
|
+
case "pnpm":
|
|
7782
|
+
return "pnpm lingui";
|
|
7783
|
+
case "yarn":
|
|
7784
|
+
return "yarn lingui";
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7787
|
+
function linguiConfigTemplate(framework) {
|
|
7788
|
+
const sourceRoot = framework.srcDir ? "src/" : "";
|
|
7789
|
+
return `import { formatter } from "@lingui/format-po";
|
|
7790
|
+
|
|
7791
|
+
/** @type {import("@lingui/conf").LinguiConfig} */
|
|
7792
|
+
export default {
|
|
7793
|
+
locales: ["en"],
|
|
7794
|
+
sourceLocale: "en",
|
|
7795
|
+
catalogs: [
|
|
7796
|
+
{
|
|
7797
|
+
path: "<rootDir>/${sourceRoot}locales/{locale}/messages",
|
|
7798
|
+
include: ["<rootDir>/${sourceRoot}**/*.{ts,tsx}"],
|
|
7799
|
+
},
|
|
7800
|
+
],
|
|
7801
|
+
format: formatter({ lineNumbers: false }),
|
|
7802
|
+
};
|
|
7803
|
+
`;
|
|
7804
|
+
}
|
|
7805
|
+
function generatedLinguiCatalogsFromConfig(configText, framework) {
|
|
7806
|
+
const paths = [...configText.matchAll(/\bpath\s*:\s*["'`]([^"'`]+)["'`]/g)]
|
|
7807
|
+
.map((match) => match[1])
|
|
7808
|
+
.filter((path) => Boolean(path))
|
|
7809
|
+
.map((path) => path
|
|
7810
|
+
.replace(/^<rootDir>\//, "")
|
|
7811
|
+
.replaceAll("{locale}", "*")
|
|
7812
|
+
.replaceAll("{name}", "*")
|
|
7813
|
+
.replaceAll("\\", "/")
|
|
7814
|
+
.replace(/\.(?:js|po)$/, "") + ".js");
|
|
7815
|
+
return [
|
|
7816
|
+
...new Set(paths.length
|
|
7817
|
+
? paths
|
|
7818
|
+
: [`${framework.srcDir ? "src/" : ""}locales/*/messages.js`]),
|
|
7819
|
+
];
|
|
7820
|
+
}
|
|
7821
|
+
async function findLinguiConfigPath(cwd) {
|
|
7822
|
+
return await findFirstExistingRelativePath(cwd, [
|
|
7823
|
+
...LINGUI_CONFIG_CANDIDATES,
|
|
7824
|
+
]);
|
|
7825
|
+
}
|
|
7826
|
+
async function findSourceFilesMatching(cwd, pattern, relativeDir = "") {
|
|
7827
|
+
const results = [];
|
|
7828
|
+
let entries;
|
|
7829
|
+
try {
|
|
7830
|
+
entries = await (0, promises_1.readdir)((0, node_path_1.join)(cwd, relativeDir), { withFileTypes: true });
|
|
7831
|
+
}
|
|
7832
|
+
catch (error) {
|
|
7833
|
+
if (isNodeErrorCode(error, "ENOENT"))
|
|
7834
|
+
return results;
|
|
7835
|
+
throw error;
|
|
7836
|
+
}
|
|
7837
|
+
for (const entry of entries) {
|
|
7838
|
+
const relativePath = relativeDir
|
|
7839
|
+
? (0, node_path_1.join)(relativeDir, entry.name)
|
|
7840
|
+
: entry.name;
|
|
7841
|
+
if (entry.isDirectory()) {
|
|
7842
|
+
if (!ENV_LOADER_SCAN_IGNORED_DIRS.has(entry.name)) {
|
|
7843
|
+
results.push(...await findSourceFilesMatching(cwd, pattern, relativePath));
|
|
7844
|
+
}
|
|
7845
|
+
continue;
|
|
7846
|
+
}
|
|
7847
|
+
if (!entry.isFile() || !hasScannedSourceExtension(entry.name))
|
|
7848
|
+
continue;
|
|
7849
|
+
const text = await readTextIfExists((0, node_path_1.join)(cwd, relativePath));
|
|
7850
|
+
pattern.lastIndex = 0;
|
|
7851
|
+
if (text && pattern.test(text)) {
|
|
7852
|
+
results.push(relativePath.replaceAll("\\", "/"));
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7855
|
+
return results.sort();
|
|
7856
|
+
}
|
|
7857
|
+
async function detectLinguiCatalogMode(cwd) {
|
|
7858
|
+
const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
|
|
7859
|
+
if (poImports.length)
|
|
7860
|
+
return "loader";
|
|
7861
|
+
const nextConfigPath = await findNextConfigPath(cwd);
|
|
7862
|
+
const nextConfigText = nextConfigPath
|
|
7863
|
+
? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
|
|
7864
|
+
: null;
|
|
7865
|
+
return nextConfigText?.includes("@lingui/loader") ? "loader" : "precompile";
|
|
7866
|
+
}
|
|
7867
|
+
async function getLinguiConfig(cwd, framework, currentConfig) {
|
|
7868
|
+
const configFile = currentConfig?.configFile ??
|
|
7869
|
+
await findLinguiConfigPath(cwd) ?? "lingui.config.ts";
|
|
7870
|
+
const configText = await readTextIfExists((0, node_path_1.join)(cwd, configFile)) ??
|
|
7871
|
+
linguiConfigTemplate(framework);
|
|
7872
|
+
return {
|
|
7873
|
+
catalogMode: currentConfig?.catalogMode ??
|
|
7874
|
+
await detectLinguiCatalogMode(cwd),
|
|
7875
|
+
configFile,
|
|
7876
|
+
generatedCatalogs: currentConfig?.generatedCatalogs?.length
|
|
7877
|
+
? [...new Set(currentConfig.generatedCatalogs)]
|
|
7878
|
+
: generatedLinguiCatalogsFromConfig(configText, framework),
|
|
7879
|
+
tasks: {
|
|
7880
|
+
...LINGUI_DEFAULT_TASKS,
|
|
7881
|
+
...currentConfig?.tasks,
|
|
7882
|
+
},
|
|
7883
|
+
};
|
|
7884
|
+
}
|
|
7885
|
+
function linguiTaskRuns(command, action) {
|
|
7886
|
+
return Boolean(command?.includes("lingui") &&
|
|
7887
|
+
new RegExp(`(?:^|\\s)${action}(?:\\s|$)`).test(command));
|
|
7888
|
+
}
|
|
7889
|
+
function dependencyMajor(spec) {
|
|
7890
|
+
const match = spec?.match(/(?:^|[^0-9])(\d+)\./);
|
|
7891
|
+
return match ? Number(match[1]) : null;
|
|
7892
|
+
}
|
|
7893
|
+
function linguiPoDeclarationTemplate() {
|
|
7894
|
+
return `declare module "*.po" {
|
|
7895
|
+
import type { Messages } from "@lingui/core";
|
|
7896
|
+
|
|
7897
|
+
export const messages: Messages;
|
|
7898
|
+
}
|
|
7899
|
+
`;
|
|
7900
|
+
}
|
|
7901
|
+
async function applyLinguiFeature(cwd, framework, manifest, activate) {
|
|
7902
|
+
const changedFiles = [];
|
|
7903
|
+
const notes = [];
|
|
7904
|
+
const currentFeature = manifest.features.lingui;
|
|
7905
|
+
const config = await getLinguiConfig(cwd, framework, currentFeature?.config);
|
|
7906
|
+
const feature = currentFeature
|
|
7907
|
+
? structuredClone(currentFeature)
|
|
7908
|
+
: { status: "planned" };
|
|
7909
|
+
if (activate && feature.status !== "active") {
|
|
7910
|
+
feature.status = "active";
|
|
7911
|
+
feature.activatedOn ??= todayIso();
|
|
7912
|
+
}
|
|
7913
|
+
feature.config = config;
|
|
7914
|
+
manifest.features.lingui = feature;
|
|
7915
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
7916
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
7917
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
7918
|
+
dependencies: LINGUI_DEFAULT_DEPENDENCIES,
|
|
7919
|
+
devDependencies: {
|
|
7920
|
+
...LINGUI_DEFAULT_DEV_DEPENDENCIES,
|
|
7921
|
+
...(config.catalogMode === "loader"
|
|
7922
|
+
? LINGUI_LOADER_DEV_DEPENDENCIES
|
|
7923
|
+
: {}),
|
|
7924
|
+
},
|
|
7925
|
+
});
|
|
7926
|
+
if (dependencyUpdate.changed)
|
|
7927
|
+
changedFiles.push(dependencyUpdate.config);
|
|
7928
|
+
const configState = await scaffoldTextFile((0, node_path_1.join)(cwd, config.configFile), linguiConfigTemplate(framework));
|
|
7929
|
+
if (configState === "created") {
|
|
7930
|
+
changedFiles.push(config.configFile);
|
|
7931
|
+
notes.push(`Scaffolded ${config.configFile} with an English starter locale; update its locales and catalog include paths for the app.`);
|
|
7932
|
+
}
|
|
7933
|
+
else if (activate && configState === "preserved") {
|
|
7934
|
+
notes.push(`Preserved existing Lingui config: ${config.configFile}`);
|
|
7935
|
+
}
|
|
7936
|
+
const taskChanges = [];
|
|
7937
|
+
const executable = linguiCliCommand(tooling);
|
|
7938
|
+
for (const [name, command] of [
|
|
7939
|
+
[config.tasks.extract, `${executable} extract --clean`],
|
|
7940
|
+
[config.tasks.compile, `${executable} compile`],
|
|
7941
|
+
]) {
|
|
7942
|
+
const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
|
|
7943
|
+
definition: command,
|
|
7944
|
+
name,
|
|
7945
|
+
});
|
|
7946
|
+
if (result.changed)
|
|
7947
|
+
taskChanges.push(name);
|
|
7948
|
+
}
|
|
7949
|
+
let taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
7950
|
+
if (!(0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build])) {
|
|
7951
|
+
const result = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
|
|
7952
|
+
definition: framework.kind === "nextjs" ? "next build" : "build",
|
|
7953
|
+
name: config.tasks.build,
|
|
7954
|
+
});
|
|
7955
|
+
if (result.changed)
|
|
7956
|
+
taskChanges.push(config.tasks.build);
|
|
7957
|
+
taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
7958
|
+
}
|
|
7959
|
+
const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build]);
|
|
7960
|
+
if (config.catalogMode === "precompile" && buildCommand &&
|
|
7961
|
+
!(0, projectTooling_js_1.taskInvokes)(taskStore, config.tasks.build, config.tasks.compile)) {
|
|
7962
|
+
const result = await (0, projectTooling_js_1.ensureTaskPrerequisite)(cwd, tooling.tasks, config.tasks.build, config.tasks.compile);
|
|
7963
|
+
if (result.changed)
|
|
7964
|
+
taskChanges.push(config.tasks.build);
|
|
7965
|
+
}
|
|
7966
|
+
if (taskChanges.length)
|
|
7967
|
+
changedFiles.push(tooling.tasks.config);
|
|
7968
|
+
const gitignorePath = (0, node_path_1.join)(cwd, ".gitignore");
|
|
7969
|
+
const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists(gitignorePath), config.generatedCatalogs);
|
|
7970
|
+
if (gitignoreUpdate.changed) {
|
|
7971
|
+
await (0, promises_1.writeFile)(gitignorePath, gitignoreUpdate.text, "utf8");
|
|
7972
|
+
changedFiles.push(".gitignore");
|
|
7973
|
+
}
|
|
7974
|
+
if (config.catalogMode === "loader") {
|
|
7975
|
+
const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
|
|
7976
|
+
if (!poDeclarations.length) {
|
|
7977
|
+
const declarationPath = `${framework.srcDir ? "src/" : ""}lingui.d.ts`;
|
|
7978
|
+
if (await writeTextIfChanged((0, node_path_1.join)(cwd, declarationPath), linguiPoDeclarationTemplate())) {
|
|
7979
|
+
changedFiles.push(declarationPath);
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
7982
|
+
}
|
|
7983
|
+
if (framework.kind === "nextjs") {
|
|
7984
|
+
const nextConfigPath = await findNextConfigPath(cwd);
|
|
7985
|
+
const nextConfigText = nextConfigPath
|
|
7986
|
+
? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
|
|
7987
|
+
: null;
|
|
7988
|
+
if (!nextConfigText?.includes("@lingui/swc-plugin")) {
|
|
7989
|
+
notes.push("Add @lingui/swc-plugin to experimental.swcPlugins in the app-owned Next config.");
|
|
7990
|
+
}
|
|
7991
|
+
if (config.catalogMode === "loader" &&
|
|
7992
|
+
!nextConfigText?.includes("@lingui/loader")) {
|
|
7993
|
+
notes.push("Add @lingui/loader .po rules for Turbopack and webpack in the app-owned Next config.");
|
|
7994
|
+
}
|
|
7995
|
+
}
|
|
7996
|
+
if (dependencyUpdate.changedKeys.length) {
|
|
7997
|
+
notes.push(`Added Lingui dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
|
|
7998
|
+
}
|
|
7999
|
+
if (taskChanges.length) {
|
|
8000
|
+
notes.push(`Updated Lingui tasks in ${tooling.tasks.config}: ${[...new Set(taskChanges)].join(", ")}`);
|
|
8001
|
+
}
|
|
8002
|
+
if (packageJson.dependencies?.["@lingui/macro"] ||
|
|
8003
|
+
packageJson.devDependencies?.["@lingui/macro"]) {
|
|
8004
|
+
notes.push("The legacy @lingui/macro package remains app-owned; migrate imports to the v6 macro entrypoints before removing it.");
|
|
8005
|
+
}
|
|
8006
|
+
return { changedFiles, notes };
|
|
8007
|
+
}
|
|
7614
8008
|
async function applyPwaFeature(cwd, framework, manifest, activate) {
|
|
7615
8009
|
const changedFiles = [];
|
|
7616
8010
|
const notes = [];
|
|
7617
8011
|
const currentFeature = manifest.features.pwa;
|
|
7618
8012
|
const currentConfig = currentFeature?.config;
|
|
7619
|
-
const {
|
|
8013
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
8014
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
7620
8015
|
const config = await getPwaConfig(cwd, framework, packageJson, currentConfig, activate);
|
|
7621
8016
|
const feature = currentFeature
|
|
7622
8017
|
? structuredClone(currentFeature)
|
|
@@ -7627,31 +8022,48 @@ async function applyPwaFeature(cwd, framework, manifest, activate) {
|
|
|
7627
8022
|
}
|
|
7628
8023
|
feature.config = config;
|
|
7629
8024
|
manifest.features.pwa = feature;
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
8025
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
8026
|
+
dependencies: PWA_DEFAULT_DEPENDENCIES,
|
|
8027
|
+
devDependencies: PWA_DEFAULT_DEV_DEPENDENCIES,
|
|
8028
|
+
});
|
|
8029
|
+
if (dependencyUpdate.changed)
|
|
8030
|
+
changedFiles.push(dependencyUpdate.config);
|
|
8031
|
+
const scriptsChanged = [];
|
|
8032
|
+
const pwaTask = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
|
|
8033
|
+
definition: PWA_BUILD_SCRIPT,
|
|
8034
|
+
name: "pwa:build",
|
|
8035
|
+
});
|
|
8036
|
+
if (pwaTask.changed)
|
|
8037
|
+
scriptsChanged.push("pwa:build");
|
|
8038
|
+
const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
8039
|
+
const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.build);
|
|
8040
|
+
if (!buildCommand) {
|
|
8041
|
+
const build = await (0, projectTooling_js_1.ensureTask)(cwd, tooling.tasks, {
|
|
8042
|
+
definition: `next build && ${(0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "pwa:build")}`,
|
|
8043
|
+
name: "build",
|
|
8044
|
+
});
|
|
8045
|
+
if (build.changed)
|
|
8046
|
+
scriptsChanged.push("build");
|
|
7650
8047
|
}
|
|
7651
|
-
if (
|
|
7652
|
-
|
|
8048
|
+
else if (buildCommand.includes("next build") &&
|
|
8049
|
+
!(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build") &&
|
|
8050
|
+
!scriptRunsSerwistBuild(buildCommand)) {
|
|
8051
|
+
const build = await (0, projectTooling_js_1.ensureTaskFollowup)(cwd, tooling.tasks, "build", "pwa:build");
|
|
8052
|
+
if (build.changed)
|
|
8053
|
+
scriptsChanged.push("build");
|
|
8054
|
+
}
|
|
8055
|
+
else if (!(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build") &&
|
|
8056
|
+
!scriptRunsSerwistBuild(buildCommand)) {
|
|
8057
|
+
notes.push("PWA build task was added, but the existing build task does not visibly run `next build`; wire `pwa:build` after the app's Next.js build step.");
|
|
8058
|
+
}
|
|
8059
|
+
if (scriptsChanged.length)
|
|
8060
|
+
changedFiles.push(tooling.tasks.config);
|
|
8061
|
+
if (dependencyUpdate.changedKeys.length) {
|
|
8062
|
+
notes.push(`Added PWA dependencies to ${dependencyUpdate.config}: ${dependencyUpdate.changedKeys.join(", ")}`);
|
|
8063
|
+
}
|
|
8064
|
+
if (scriptsChanged.length) {
|
|
8065
|
+
notes.push(`Updated PWA tasks in ${tooling.tasks.config}: ${scriptsChanged.join(", ")}`);
|
|
7653
8066
|
}
|
|
7654
|
-
notes.push(...scriptsUpdate.notes);
|
|
7655
8067
|
const serwistConfigState = await scaffoldTextFile((0, node_path_1.join)(cwd, config.modules.serwistConfig), pwaSerwistConfigTemplate(config));
|
|
7656
8068
|
if (serwistConfigState === "created") {
|
|
7657
8069
|
changedFiles.push(config.modules.serwistConfig);
|
|
@@ -7705,13 +8117,13 @@ async function checkJobsFeature(cwd, framework, manifest) {
|
|
|
7705
8117
|
return { issues, suggestions: [], warnings: [] };
|
|
7706
8118
|
}
|
|
7707
8119
|
const config = mergeJobsConfig(framework, feature.config);
|
|
7708
|
-
const { packageJson } = await readProjectPackageJson(cwd);
|
|
7709
8120
|
const expectedScripts = getJobsExpectedScripts(config);
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
8121
|
+
const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
|
|
8122
|
+
for (const taskName of taskCheck.mismatches) {
|
|
8123
|
+
issues.push(taskCheck.config === "package.json"
|
|
8124
|
+
? `Jobs package.json script does not match Loom defaults: ${taskName}`
|
|
8125
|
+
: `Jobs task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
|
|
8126
|
+
suggestions.add("Run `loom add jobs`.");
|
|
7715
8127
|
}
|
|
7716
8128
|
const requiredFiles = [
|
|
7717
8129
|
JOBS_SCRIPTS_TSCONFIG_PATH,
|
|
@@ -7868,7 +8280,9 @@ async function checkDbFeature(cwd, framework, manifest, options) {
|
|
|
7868
8280
|
}
|
|
7869
8281
|
const config = mergeDbConfig(framework, feature.config);
|
|
7870
8282
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
7871
|
-
const
|
|
8283
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
8284
|
+
const testRunner = await getDbTestRunner(cwd, tooling);
|
|
8285
|
+
const expectedScripts = getDbExpectedScripts(config, tooling);
|
|
7872
8286
|
const migrationFlowCheck = await checkDbProductionMigrationFlow(cwd, options.production ?? false);
|
|
7873
8287
|
issues.push(...migrationFlowCheck.issues);
|
|
7874
8288
|
warnings.push(...migrationFlowCheck.warnings);
|
|
@@ -7876,29 +8290,36 @@ async function checkDbFeature(cwd, framework, manifest, options) {
|
|
|
7876
8290
|
suggestions.add(suggestion);
|
|
7877
8291
|
}
|
|
7878
8292
|
for (const dependencyName of Object.keys(DB_DEFAULT_DEPENDENCIES)) {
|
|
7879
|
-
if (!packageJson
|
|
7880
|
-
issues.push(
|
|
8293
|
+
if (!hasPackageDependency(packageJson, dependencyName)) {
|
|
8294
|
+
issues.push(tooling.dependencies.config === "package.json"
|
|
8295
|
+
? `DB dependency is missing from package.json dependencies: ${dependencyName}`
|
|
8296
|
+
: `DB dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
|
|
7881
8297
|
suggestions.add("Run `loom add db`.");
|
|
7882
8298
|
}
|
|
7883
8299
|
}
|
|
7884
8300
|
for (const dependencyName of Object.keys(DB_DEFAULT_DEV_DEPENDENCIES)) {
|
|
7885
|
-
if (!packageJson
|
|
7886
|
-
issues.push(
|
|
8301
|
+
if (!hasPackageDependency(packageJson, dependencyName)) {
|
|
8302
|
+
issues.push(tooling.dependencies.config === "package.json"
|
|
8303
|
+
? `DB dependency is missing from package.json devDependencies: ${dependencyName}`
|
|
8304
|
+
: `DB development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
|
|
7887
8305
|
suggestions.add("Run `loom add db`.");
|
|
7888
8306
|
}
|
|
7889
8307
|
}
|
|
7890
8308
|
for (const dependencyName of DB_MOVED_DEPENDENCIES) {
|
|
7891
8309
|
if (packageJson.dependencies?.[dependencyName] ||
|
|
7892
8310
|
packageJson.devDependencies?.[dependencyName]) {
|
|
7893
|
-
issues.push(
|
|
7894
|
-
|
|
8311
|
+
issues.push(tooling.dependencies.config === "package.json"
|
|
8312
|
+
? `Consumer package.json still declares a Loom-managed DB generator dependency: ${dependencyName}`
|
|
8313
|
+
: `Consumer ${tooling.dependencies.config} still declares a Loom-managed DB generator dependency: ${dependencyName}`);
|
|
8314
|
+
suggestions.add(`Run loom add db to rewrite ${tooling.dependencies.config}.`);
|
|
7895
8315
|
}
|
|
7896
8316
|
}
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
8317
|
+
const taskCheck = await checkProjectTasks(cwd, manifest, expectedScripts);
|
|
8318
|
+
for (const taskName of taskCheck.mismatches) {
|
|
8319
|
+
issues.push(taskCheck.config === "package.json"
|
|
8320
|
+
? `DB package.json script does not match Loom defaults: ${taskName}`
|
|
8321
|
+
: `DB task in ${taskCheck.config} does not match Loom defaults: ${taskName}`);
|
|
8322
|
+
suggestions.add("Run `loom add db`.");
|
|
7902
8323
|
}
|
|
7903
8324
|
const requiredFiles = [
|
|
7904
8325
|
config.modules.neonModule,
|
|
@@ -7934,7 +8355,7 @@ async function checkDbFeature(cwd, framework, manifest, options) {
|
|
|
7934
8355
|
],
|
|
7935
8356
|
[
|
|
7936
8357
|
config.modules.pgliteHarnessModule,
|
|
7937
|
-
dbPgliteHarnessTemplate(config),
|
|
8358
|
+
dbPgliteHarnessTemplate(config, testRunner),
|
|
7938
8359
|
"PGlite test harness does not match the Loom-managed wrapper",
|
|
7939
8360
|
],
|
|
7940
8361
|
[
|
|
@@ -8025,6 +8446,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8025
8446
|
const dbConfig = mergeDbConfig(framework, dbFeature.config);
|
|
8026
8447
|
const config = getFilesConfig(framework, dbConfig, feature.config);
|
|
8027
8448
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
8449
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
8450
|
+
const generateCommand = (0, projectTooling_js_1.formatTaskInvocation)(tooling.tasks, "db:generate");
|
|
8028
8451
|
const schema = config.schema;
|
|
8029
8452
|
const latestSchema = getLatestManagedSchemaConfig(schema);
|
|
8030
8453
|
if (schema.mode !== "managed-local" || schema.blueprint !== "files") {
|
|
@@ -8038,7 +8461,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8038
8461
|
}
|
|
8039
8462
|
else if (schema.version < supportedVersion) {
|
|
8040
8463
|
warnings.push(`Files schema blueprint is stale: ${schema.version} < ${supportedVersion}.`);
|
|
8041
|
-
suggestions.add(
|
|
8464
|
+
suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
|
|
8042
8465
|
}
|
|
8043
8466
|
const schemaRelativeToDir = (0, node_path_1.relative)(dbConfig.dirs.schemaDir, schema.module)
|
|
8044
8467
|
.replaceAll("\\", "/");
|
|
@@ -8053,7 +8476,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8053
8476
|
const schemaText = await readTextIfExists((0, node_path_1.join)(cwd, schema.module));
|
|
8054
8477
|
if (!schemaText) {
|
|
8055
8478
|
issues.push(`Files schema file is missing: ${schema.module}`);
|
|
8056
|
-
suggestions.add(
|
|
8479
|
+
suggestions.add(`Run loom db schemas sync, review the schema diff, then run ${generateCommand} if the schema changed.`);
|
|
8057
8480
|
}
|
|
8058
8481
|
else {
|
|
8059
8482
|
const currentHash = hashManagedSchemaText(schemaText);
|
|
@@ -8169,8 +8592,8 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8169
8592
|
suggestions.add("Replace the generated files storage stub with an S3 or app-specific storage adapter before production use.");
|
|
8170
8593
|
}
|
|
8171
8594
|
if (config.storage.adapter === "s3") {
|
|
8172
|
-
if (!packageJson
|
|
8173
|
-
issues.push(
|
|
8595
|
+
if (!hasPackageDependency(packageJson, "@aws-sdk/client-s3")) {
|
|
8596
|
+
issues.push(`Files S3/R2 storage requires @aws-sdk/client-s3 in ${tooling.dependencies.config}.`);
|
|
8174
8597
|
suggestions.add("Run `loom files r2 setup` to restore the dependency.");
|
|
8175
8598
|
}
|
|
8176
8599
|
for (const envName of FILES_S3_REQUIRED_ENV_NAMES) {
|
|
@@ -8654,6 +9077,125 @@ async function findNextConfigPath(cwd) {
|
|
|
8654
9077
|
];
|
|
8655
9078
|
return await findFirstExistingRelativePath(cwd, candidates);
|
|
8656
9079
|
}
|
|
9080
|
+
async function checkLinguiFeature(cwd, framework, manifest, options) {
|
|
9081
|
+
const issues = [];
|
|
9082
|
+
const suggestions = new Set();
|
|
9083
|
+
const warnings = [];
|
|
9084
|
+
const feature = manifest.features.lingui;
|
|
9085
|
+
if (!feature || feature.status !== "active") {
|
|
9086
|
+
return { issues, suggestions: [], warnings };
|
|
9087
|
+
}
|
|
9088
|
+
const { packageJson } = await readProjectPackageJson(cwd);
|
|
9089
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
9090
|
+
const config = await getLinguiConfig(cwd, framework, feature.config);
|
|
9091
|
+
const requiredDependencies = {
|
|
9092
|
+
...LINGUI_DEFAULT_DEPENDENCIES,
|
|
9093
|
+
...LINGUI_DEFAULT_DEV_DEPENDENCIES,
|
|
9094
|
+
...(config.catalogMode === "loader" ? LINGUI_LOADER_DEV_DEPENDENCIES : {}),
|
|
9095
|
+
};
|
|
9096
|
+
for (const dependencyName of Object.keys(requiredDependencies)) {
|
|
9097
|
+
if (!hasPackageDependency(packageJson, dependencyName)) {
|
|
9098
|
+
issues.push(`Lingui dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
|
|
9099
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9100
|
+
}
|
|
9101
|
+
}
|
|
9102
|
+
if (!await exists((0, node_path_1.join)(cwd, config.configFile))) {
|
|
9103
|
+
issues.push(`Lingui config is missing: ${config.configFile}`);
|
|
9104
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9105
|
+
}
|
|
9106
|
+
const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
9107
|
+
if (!linguiTaskRuns((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.extract]), "extract")) {
|
|
9108
|
+
issues.push(`Lingui extraction task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.extract}`);
|
|
9109
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9110
|
+
}
|
|
9111
|
+
if (!linguiTaskRuns((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.compile]), "compile")) {
|
|
9112
|
+
issues.push(`Lingui compile task is missing or invalid in ${tooling.tasks.config}: ${config.tasks.compile}`);
|
|
9113
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9114
|
+
}
|
|
9115
|
+
if (config.catalogMode === "precompile") {
|
|
9116
|
+
if (!(0, projectTooling_js_1.taskInvokes)(taskStore, config.tasks.build, config.tasks.compile)) {
|
|
9117
|
+
issues.push(`Build task does not compile Lingui catalogs in ${tooling.tasks.config}: ${config.tasks.build}`);
|
|
9118
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9119
|
+
}
|
|
9120
|
+
else {
|
|
9121
|
+
const buildCommand = (0, projectTooling_js_1.getTaskCommand)(taskStore.definitions[config.tasks.build]);
|
|
9122
|
+
if (buildCommand?.includes("next build") &&
|
|
9123
|
+
!(0, projectTooling_js_1.taskRunsBeforeCommand)(taskStore, config.tasks.build, config.tasks.compile, "next build")) {
|
|
9124
|
+
issues.push(`Lingui catalogs are compiled after Next.js starts building in ${tooling.tasks.config}: ${config.tasks.build}`);
|
|
9125
|
+
suggestions.add(`Run ${config.tasks.compile} before the framework build command.`);
|
|
9126
|
+
}
|
|
9127
|
+
}
|
|
9128
|
+
}
|
|
9129
|
+
const gitignoreUpdate = ensureLinguiGitignoreText(await readTextIfExists((0, node_path_1.join)(cwd, ".gitignore")), config.generatedCatalogs);
|
|
9130
|
+
if (gitignoreUpdate.missingLines.length) {
|
|
9131
|
+
issues.push(`Lingui generated catalogs are missing from .gitignore: ${gitignoreUpdate.missingLines.join(", ")}`);
|
|
9132
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9133
|
+
}
|
|
9134
|
+
const gitResult = await (options.commandRunner ?? defaultCommandRunner)("git", ["ls-files", "--", ...config.generatedCatalogs], { cwd, stdio: "pipe" });
|
|
9135
|
+
const trackedCatalogs = gitResult.code === 0
|
|
9136
|
+
? gitResult.stdout.trim().split(/\r?\n/).filter(Boolean)
|
|
9137
|
+
: [];
|
|
9138
|
+
if (trackedCatalogs.length) {
|
|
9139
|
+
issues.push(`Lingui generated catalogs are still tracked by git: ${trackedCatalogs.join(", ")}`);
|
|
9140
|
+
suggestions.add("Remove generated catalogs from the git index while keeping the source .po catalogs tracked.");
|
|
9141
|
+
}
|
|
9142
|
+
const nextConfigPath = await findNextConfigPath(cwd);
|
|
9143
|
+
const nextConfigText = nextConfigPath
|
|
9144
|
+
? await readTextIfExists((0, node_path_1.join)(cwd, nextConfigPath))
|
|
9145
|
+
: null;
|
|
9146
|
+
if (framework.kind === "nextjs") {
|
|
9147
|
+
if (!nextConfigText?.includes("@lingui/swc-plugin")) {
|
|
9148
|
+
issues.push(`Next config is missing @lingui/swc-plugin${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
|
|
9149
|
+
suggestions.add("Add @lingui/swc-plugin to experimental.swcPlugins in the Next config.");
|
|
9150
|
+
}
|
|
9151
|
+
if (config.catalogMode === "loader" &&
|
|
9152
|
+
!nextConfigText?.includes("@lingui/loader")) {
|
|
9153
|
+
issues.push(`Lingui loader mode is not wired in the Next config${nextConfigPath ? `: ${nextConfigPath}` : "."}`);
|
|
9154
|
+
suggestions.add("Add matching .po rules for Turbopack and webpack, or switch the manifest to precompile mode.");
|
|
9155
|
+
}
|
|
9156
|
+
if (nextConfigText && /\breactCompiler\s*:\s*true/.test(nextConfigText)) {
|
|
9157
|
+
warnings.push("Next.js React Compiler and the Lingui SWC plugin are both enabled; keep this combination covered by a production build test when upgrading either tool.");
|
|
9158
|
+
}
|
|
9159
|
+
}
|
|
9160
|
+
const poImports = await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']+\.po["']/);
|
|
9161
|
+
if (config.catalogMode === "precompile" && poImports.length) {
|
|
9162
|
+
issues.push(`Lingui is configured for precompile mode but source files import .po catalogs: ${poImports.join(", ")}`);
|
|
9163
|
+
suggestions.add("Switch loom.json to loader mode or import the generated .js catalogs.");
|
|
9164
|
+
}
|
|
9165
|
+
if (config.catalogMode === "loader" && !poImports.length) {
|
|
9166
|
+
warnings.push("Lingui is configured for loader mode, but no source .po imports were found.");
|
|
9167
|
+
}
|
|
9168
|
+
if (config.catalogMode === "loader") {
|
|
9169
|
+
const poDeclarations = await findSourceFilesMatching(cwd, /declare\s+module\s+["']\*\.po["']/);
|
|
9170
|
+
if (!poDeclarations.length) {
|
|
9171
|
+
issues.push("Lingui loader mode is missing a TypeScript *.po module declaration.");
|
|
9172
|
+
suggestions.add("Run `loom add lingui`.");
|
|
9173
|
+
}
|
|
9174
|
+
}
|
|
9175
|
+
const configImports = (await findSourceFilesMatching(cwd, /(?:from\s+|import\s*\()\s*["'][^"']*lingui\.config(?:\.[cm]?[jt]s)?["']/)).filter((relativePath) => relativePath !== config.configFile);
|
|
9176
|
+
if (configImports.length) {
|
|
9177
|
+
warnings.push(`Lingui config is imported by runtime source; keep config evaluation build-time only: ${configImports.join(", ")}`);
|
|
9178
|
+
}
|
|
9179
|
+
const linguiCoreMajor = dependencyMajor(packageJson.dependencies?.["@lingui/core"] ??
|
|
9180
|
+
packageJson.devDependencies?.["@lingui/core"]);
|
|
9181
|
+
const legacyMacroSpec = packageJson.dependencies?.["@lingui/macro"] ??
|
|
9182
|
+
packageJson.devDependencies?.["@lingui/macro"];
|
|
9183
|
+
if (legacyMacroSpec && linguiCoreMajor !== null &&
|
|
9184
|
+
dependencyMajor(legacyMacroSpec) !== linguiCoreMajor) {
|
|
9185
|
+
warnings.push(`Legacy @lingui/macro (${legacyMacroSpec}) does not match @lingui/core's major version; prefer @lingui/react/macro and @lingui/core/macro imports.`);
|
|
9186
|
+
}
|
|
9187
|
+
const linguiFamilyMajors = Object.keys(requiredDependencies).flatMap((dependencyName) => {
|
|
9188
|
+
const spec = packageJson.dependencies?.[dependencyName] ??
|
|
9189
|
+
packageJson.devDependencies?.[dependencyName];
|
|
9190
|
+
const major = dependencyMajor(spec);
|
|
9191
|
+
return major === null ? [] : [`${dependencyName}@${major}`];
|
|
9192
|
+
});
|
|
9193
|
+
if (new Set(linguiFamilyMajors.map((entry) => entry.split("@").at(-1))).size >
|
|
9194
|
+
1) {
|
|
9195
|
+
warnings.push(`Lingui packages span multiple major versions: ${linguiFamilyMajors.join(", ")}`);
|
|
9196
|
+
}
|
|
9197
|
+
return { issues, suggestions: [...suggestions], warnings };
|
|
9198
|
+
}
|
|
8657
9199
|
async function checkPwaFeature(cwd, framework, manifest) {
|
|
8658
9200
|
const issues = [];
|
|
8659
9201
|
const suggestions = new Set();
|
|
@@ -8663,6 +9205,7 @@ async function checkPwaFeature(cwd, framework, manifest) {
|
|
|
8663
9205
|
return { issues, suggestions: [], warnings };
|
|
8664
9206
|
}
|
|
8665
9207
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
9208
|
+
const tooling = await getProjectTooling(cwd, manifest);
|
|
8666
9209
|
const config = await getPwaConfig(cwd, framework, packageJson, feature.config, false);
|
|
8667
9210
|
const hasMui = hasPackageDependency(packageJson, "@mui/material");
|
|
8668
9211
|
if (framework.kind !== "nextjs" || framework.router !== "app") {
|
|
@@ -8670,23 +9213,25 @@ async function checkPwaFeature(cwd, framework, manifest) {
|
|
|
8670
9213
|
suggestions.add("Update loom.json if this project intentionally uses a custom PWA integration.");
|
|
8671
9214
|
}
|
|
8672
9215
|
for (const dependencyName of Object.keys(PWA_DEFAULT_DEPENDENCIES)) {
|
|
8673
|
-
if (!packageJson
|
|
8674
|
-
issues.push(`PWA dependency is missing from
|
|
9216
|
+
if (!hasPackageDependency(packageJson, dependencyName)) {
|
|
9217
|
+
issues.push(`PWA dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
|
|
8675
9218
|
suggestions.add("Run `loom add pwa`.");
|
|
8676
9219
|
}
|
|
8677
9220
|
}
|
|
8678
9221
|
for (const dependencyName of Object.keys(PWA_DEFAULT_DEV_DEPENDENCIES)) {
|
|
8679
|
-
if (!packageJson
|
|
8680
|
-
issues.push(`PWA dependency is missing from
|
|
9222
|
+
if (!hasPackageDependency(packageJson, dependencyName)) {
|
|
9223
|
+
issues.push(`PWA development dependency is missing from ${tooling.dependencies.config}: ${dependencyName}`);
|
|
8681
9224
|
suggestions.add("Run `loom add pwa`.");
|
|
8682
9225
|
}
|
|
8683
9226
|
}
|
|
8684
|
-
|
|
8685
|
-
|
|
9227
|
+
const taskStore = await (0, projectTooling_js_1.readTaskStore)(cwd, tooling.tasks);
|
|
9228
|
+
if (!scriptRunsSerwistBuild((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions["pwa:build"]))) {
|
|
9229
|
+
issues.push(`PWA task in ${tooling.tasks.config} does not build Serwist: pwa:build`);
|
|
8686
9230
|
suggestions.add("Run `loom add pwa`.");
|
|
8687
9231
|
}
|
|
8688
|
-
if (!scriptRunsSerwistBuild(
|
|
8689
|
-
|
|
9232
|
+
if (!scriptRunsSerwistBuild((0, projectTooling_js_1.getTaskCommand)(taskStore.definitions.build)) &&
|
|
9233
|
+
!(0, projectTooling_js_1.taskInvokes)(taskStore, "build", "pwa:build")) {
|
|
9234
|
+
issues.push(`PWA build task in ${tooling.tasks.config} does not run Serwist after the Next.js build.`);
|
|
8690
9235
|
suggestions.add("Run `loom add pwa`.");
|
|
8691
9236
|
}
|
|
8692
9237
|
const gitignoreUpdate = ensurePwaGitignoreText(await readTextIfExists((0, node_path_1.join)(cwd, ".gitignore")));
|
|
@@ -8867,6 +9412,10 @@ const featureHooks = {
|
|
|
8867
9412
|
apply: applyJobsFeature,
|
|
8868
9413
|
check: checkJobsFeature,
|
|
8869
9414
|
},
|
|
9415
|
+
lingui: {
|
|
9416
|
+
apply: applyLinguiFeature,
|
|
9417
|
+
check: checkLinguiFeature,
|
|
9418
|
+
},
|
|
8870
9419
|
mail: {
|
|
8871
9420
|
apply: applyMailFeature,
|
|
8872
9421
|
check: checkMailFeature,
|
|
@@ -8894,11 +9443,14 @@ async function ensureActiveFeatureScaffolds(cwd, framework, manifest) {
|
|
|
8894
9443
|
async function initProject(cwd, versionRange) {
|
|
8895
9444
|
const changedFiles = [];
|
|
8896
9445
|
const notes = [];
|
|
8897
|
-
const
|
|
8898
|
-
const
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
9446
|
+
const loomManifestPath = (0, node_path_1.join)(cwd, "loom.json");
|
|
9447
|
+
const existingManifestText = await readTextIfExists(loomManifestPath);
|
|
9448
|
+
const existingManifest = existingManifestText
|
|
9449
|
+
? parseJson(existingManifestText, "loom.json")
|
|
9450
|
+
: null;
|
|
9451
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, existingManifest?.project?.tooling);
|
|
9452
|
+
const initialMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
9453
|
+
const initialPackageJson = initialMetadata.packageJson;
|
|
8902
9454
|
const npmrcPath = (0, node_path_1.join)(cwd, ".npmrc");
|
|
8903
9455
|
const npmrcUpdate = removeLegacyLoomNpmrcText(await readTextIfExists(npmrcPath));
|
|
8904
9456
|
if (npmrcUpdate.changed) {
|
|
@@ -8906,19 +9458,23 @@ async function initProject(cwd, versionRange) {
|
|
|
8906
9458
|
changedFiles.push(".npmrc");
|
|
8907
9459
|
notes.push("Removed Loom's obsolete GitHub Packages registry configuration.");
|
|
8908
9460
|
}
|
|
8909
|
-
const
|
|
8910
|
-
|
|
9461
|
+
const dependencyUpdate = await (0, projectTooling_js_1.mutateProjectDependencies)(cwd, tooling.dependencies, {
|
|
9462
|
+
dependencies: {
|
|
9463
|
+
[exports.LOOM_DEPENDENCY]: versionRange ??
|
|
9464
|
+
getPublishedLoomDependencySpec(initialPackageJson),
|
|
9465
|
+
},
|
|
9466
|
+
replace: true,
|
|
9467
|
+
});
|
|
8911
9468
|
if (dependencyUpdate.changed) {
|
|
8912
|
-
|
|
8913
|
-
|
|
9469
|
+
changedFiles.push(tooling.dependencies.config);
|
|
9470
|
+
if (tooling.dependencies.config !== "package.json") {
|
|
9471
|
+
notes.push(`Recorded ${exports.LOOM_DEPENDENCY} in ${tooling.dependencies.config} imports and enabled Deno's local node_modules directory when needed.`);
|
|
9472
|
+
}
|
|
8914
9473
|
}
|
|
8915
|
-
const
|
|
8916
|
-
|
|
8917
|
-
const
|
|
8918
|
-
const
|
|
8919
|
-
? parseJson(existingManifestText, "loom.json")
|
|
8920
|
-
: null;
|
|
8921
|
-
const manifest = buildManifest(cwd, dependencyUpdate.packageJson, framework, existingManifest);
|
|
9474
|
+
const packageJson = (await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd))
|
|
9475
|
+
.packageJson;
|
|
9476
|
+
const framework = await detectFramework(cwd, packageJson);
|
|
9477
|
+
const manifest = buildManifest(cwd, packageJson, framework, existingManifest, tooling);
|
|
8922
9478
|
const featureInit = await ensureActiveFeatureScaffolds(cwd, framework, manifest);
|
|
8923
9479
|
changedFiles.push(...featureInit.changedFiles);
|
|
8924
9480
|
notes.push(...featureInit.notes);
|
|
@@ -8929,7 +9485,7 @@ async function initProject(cwd, versionRange) {
|
|
|
8929
9485
|
if (agentsInit.changed) {
|
|
8930
9486
|
changedFiles.push("AGENTS.md");
|
|
8931
9487
|
}
|
|
8932
|
-
const nextAgentsInit = await ensureNextAgentsFile(cwd,
|
|
9488
|
+
const nextAgentsInit = await ensureNextAgentsFile(cwd, packageJson);
|
|
8933
9489
|
if (nextAgentsInit.changed)
|
|
8934
9490
|
changedFiles.push("AGENTS.md");
|
|
8935
9491
|
if (nextAgentsInit.note)
|
|
@@ -8953,7 +9509,8 @@ async function initProject(cwd, versionRange) {
|
|
|
8953
9509
|
framework,
|
|
8954
9510
|
manifest,
|
|
8955
9511
|
notes,
|
|
8956
|
-
packageJson:
|
|
9512
|
+
packageJson: (await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd))
|
|
9513
|
+
.packageJson,
|
|
8957
9514
|
};
|
|
8958
9515
|
}
|
|
8959
9516
|
async function addFeature(cwd, featureKey, versionRange) {
|
|
@@ -9099,18 +9656,20 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
|
|
|
9099
9656
|
const issues = [];
|
|
9100
9657
|
const suggestions = new Set();
|
|
9101
9658
|
const warnings = [];
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9659
|
+
let projectMetadata;
|
|
9660
|
+
try {
|
|
9661
|
+
projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
9662
|
+
}
|
|
9663
|
+
catch (error) {
|
|
9105
9664
|
return {
|
|
9106
|
-
issues: [
|
|
9665
|
+
issues: [error.message],
|
|
9107
9666
|
suggestions: [
|
|
9108
|
-
"Run `loom init` from a project
|
|
9667
|
+
"Run `loom init` from a project with package.json, deno.json, or deno.jsonc.",
|
|
9109
9668
|
],
|
|
9110
9669
|
warnings: [],
|
|
9111
9670
|
};
|
|
9112
9671
|
}
|
|
9113
|
-
const packageJson =
|
|
9672
|
+
const packageJson = projectMetadata.packageJson;
|
|
9114
9673
|
const npmrcText = await readTextIfExists((0, node_path_1.join)(cwd, ".npmrc"));
|
|
9115
9674
|
if (removeLegacyLoomNpmrcText(npmrcText).changed) {
|
|
9116
9675
|
warnings.push(".npmrc retains Loom's obsolete GitHub Packages registry configuration.");
|
|
@@ -9119,7 +9678,7 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
|
|
|
9119
9678
|
const framework = await detectFramework(cwd, packageJson);
|
|
9120
9679
|
const dependency = packageJson.dependencies?.[exports.LOOM_DEPENDENCY];
|
|
9121
9680
|
if (!dependency) {
|
|
9122
|
-
issues.push(`Missing ${exports.LOOM_DEPENDENCY} in
|
|
9681
|
+
issues.push(`Missing ${exports.LOOM_DEPENDENCY} in ${projectMetadata.config} dependencies/imports.`);
|
|
9123
9682
|
suggestions.add("Run `loom init`.");
|
|
9124
9683
|
}
|
|
9125
9684
|
else if (isLocalPackageSpec(dependency)) {
|
|
@@ -9136,6 +9695,26 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
|
|
|
9136
9695
|
manifest = parseJson(manifestText, "loom.json");
|
|
9137
9696
|
}
|
|
9138
9697
|
if (manifest) {
|
|
9698
|
+
let tooling = null;
|
|
9699
|
+
if (!manifest.project?.tooling) {
|
|
9700
|
+
warnings.push("loom.json does not record authoritative project tooling.");
|
|
9701
|
+
suggestions.add("Run `loom init` to adopt the detected project tooling.");
|
|
9702
|
+
}
|
|
9703
|
+
try {
|
|
9704
|
+
tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest.project?.tooling);
|
|
9705
|
+
}
|
|
9706
|
+
catch (error) {
|
|
9707
|
+
issues.push(`Invalid project tooling configuration: ${error.message}`);
|
|
9708
|
+
suggestions.add("Fix the recorded project.tooling config in loom.json.");
|
|
9709
|
+
}
|
|
9710
|
+
if (tooling) {
|
|
9711
|
+
for (const conflict of await (0, projectTooling_js_1.findTaskConflicts)(cwd, tooling.tasks)) {
|
|
9712
|
+
const deploymentWarning = conflict.name === "build"
|
|
9713
|
+
? " Deployment may invoke the wrong build task."
|
|
9714
|
+
: "";
|
|
9715
|
+
warnings.push(`Conflicting '${conflict.name}' tasks in ${conflict.authoritativeConfig} (authoritative) and ${conflict.secondaryConfig}.${deploymentWarning}`);
|
|
9716
|
+
}
|
|
9717
|
+
}
|
|
9139
9718
|
for (const [featureKey, feature] of Object.entries(manifest.features)) {
|
|
9140
9719
|
if (feature.status !== "active")
|
|
9141
9720
|
continue;
|
|
@@ -9167,7 +9746,7 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
|
|
|
9167
9746
|
for (const suggestion of agentsCheck.suggestions) {
|
|
9168
9747
|
suggestions.add(suggestion);
|
|
9169
9748
|
}
|
|
9170
|
-
const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest
|
|
9749
|
+
const envRunnerCheck = await checkEnvRunnerAdoption(cwd, manifest);
|
|
9171
9750
|
for (const issue of envRunnerCheck.issues) {
|
|
9172
9751
|
issues.push(issue);
|
|
9173
9752
|
}
|
|
@@ -9221,13 +9800,16 @@ async function checkProjectNetwork(cwd, env = node_process_1.default.env, option
|
|
|
9221
9800
|
const suggestions = new Set();
|
|
9222
9801
|
const warnings = [];
|
|
9223
9802
|
const steps = [];
|
|
9224
|
-
|
|
9225
|
-
|
|
9803
|
+
let projectMetadata;
|
|
9804
|
+
try {
|
|
9805
|
+
projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
9806
|
+
}
|
|
9807
|
+
catch (error) {
|
|
9226
9808
|
return {
|
|
9227
|
-
issues: [
|
|
9809
|
+
issues: [error.message],
|
|
9228
9810
|
steps,
|
|
9229
9811
|
suggestions: [
|
|
9230
|
-
"Run `loom init` from a
|
|
9812
|
+
"Run `loom init` from a package.json or Deno project.",
|
|
9231
9813
|
],
|
|
9232
9814
|
warnings,
|
|
9233
9815
|
};
|
|
@@ -9241,7 +9823,7 @@ async function checkProjectNetwork(cwd, env = node_process_1.default.env, option
|
|
|
9241
9823
|
warnings,
|
|
9242
9824
|
};
|
|
9243
9825
|
}
|
|
9244
|
-
const packageJson =
|
|
9826
|
+
const packageJson = projectMetadata.packageJson;
|
|
9245
9827
|
const framework = await detectFramework(cwd, packageJson);
|
|
9246
9828
|
const manifest = parseJson(manifestText, "loom.json");
|
|
9247
9829
|
const context = {
|
|
@@ -9570,13 +10152,15 @@ function formatSkillLinkState(state) {
|
|
|
9570
10152
|
}
|
|
9571
10153
|
}
|
|
9572
10154
|
async function runStatus(cwd, io) {
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
10155
|
+
let projectMetadata;
|
|
10156
|
+
try {
|
|
10157
|
+
projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
10158
|
+
}
|
|
10159
|
+
catch (error) {
|
|
10160
|
+
io.err(error.message);
|
|
9577
10161
|
return 1;
|
|
9578
10162
|
}
|
|
9579
|
-
const packageJson =
|
|
10163
|
+
const packageJson = projectMetadata.packageJson;
|
|
9580
10164
|
const manifestText = await readTextIfExists((0, node_path_1.join)(cwd, "loom.json"));
|
|
9581
10165
|
const manifest = manifestText
|
|
9582
10166
|
? parseJson(manifestText, "loom.json")
|
|
@@ -9591,6 +10175,19 @@ async function runStatus(cwd, io) {
|
|
|
9591
10175
|
: null;
|
|
9592
10176
|
const workspaceText = await readTextIfExists((0, node_path_1.join)(cwd, "pnpm-workspace.yaml"));
|
|
9593
10177
|
const overrideSpec = getManagedDevOverrideSpec(workspaceText);
|
|
10178
|
+
let denoOverride = null;
|
|
10179
|
+
try {
|
|
10180
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
10181
|
+
if (usesDenoTooling(tooling)) {
|
|
10182
|
+
const config = await getDenoConfigForLinks(cwd, tooling);
|
|
10183
|
+
const link = await findLocalLoomDenoLink(cwd, await (0, projectTooling_js_1.readDenoLinks)(cwd, config));
|
|
10184
|
+
if (link)
|
|
10185
|
+
denoOverride = { config, link: link.link };
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
catch {
|
|
10189
|
+
// Status reports stored project data even when live detection fails.
|
|
10190
|
+
}
|
|
9594
10191
|
const localLockfileResolution = await getProjectLocalLoomLockfileResolution(cwd);
|
|
9595
10192
|
const devState = getManagedDevState(workspaceText) ??
|
|
9596
10193
|
await readLocalDevState(cwd);
|
|
@@ -9599,14 +10196,22 @@ async function runStatus(cwd, io) {
|
|
|
9599
10196
|
io.out(`Loom status for ${projectName}`);
|
|
9600
10197
|
io.out("");
|
|
9601
10198
|
io.out("Package:");
|
|
9602
|
-
io.out(`
|
|
10199
|
+
io.out(` ${projectMetadata.config}: ${dependencySpec ? `${exports.LOOM_DEPENDENCY} ${dependencySpec}` : "not declared"}`);
|
|
9603
10200
|
io.out(` installed: ${installedPackage?.version ?? "not installed"}`);
|
|
9604
|
-
io.out(` local dev override: ${
|
|
10201
|
+
io.out(` local dev override: ${denoOverride
|
|
10202
|
+
? `active (${denoOverride.config} links ${denoOverride.link})`
|
|
10203
|
+
: overrideSpec
|
|
10204
|
+
? `active (${overrideSpec})`
|
|
10205
|
+
: "none"}`);
|
|
9605
10206
|
io.out(` lockfile local resolution: ${localLockfileResolution ?? "none"}`);
|
|
9606
10207
|
io.out("");
|
|
9607
10208
|
io.out("Project:");
|
|
9608
10209
|
io.out(` loom.json: ${manifest ? `version ${manifest.version}` : "missing"}`);
|
|
9609
10210
|
io.out(` framework: ${formatFrameworkInfo(framework)}`);
|
|
10211
|
+
if (manifest?.project?.tooling) {
|
|
10212
|
+
io.out(` tasks: ${manifest.project.tooling.tasks.config} via ${manifest.project.tooling.tasks.runner}`);
|
|
10213
|
+
io.out(` dependencies: ${manifest.project.tooling.dependencies.config} via ${manifest.project.tooling.dependencies.manager}`);
|
|
10214
|
+
}
|
|
9610
10215
|
io.out("");
|
|
9611
10216
|
io.out("Features:");
|
|
9612
10217
|
if (!manifest) {
|
|
@@ -9695,7 +10300,7 @@ function printHelp({ out }) {
|
|
|
9695
10300
|
out("loom <command>");
|
|
9696
10301
|
out("");
|
|
9697
10302
|
out("Commands:");
|
|
9698
|
-
out(" init Set up package
|
|
10303
|
+
out(" init Set up package/Deno config, loom.json, managed AGENTS.md guidance, first-party links, and package skills.");
|
|
9699
10304
|
out(" add <feature> Activate a shared feature. Run `loom add` to list available features.");
|
|
9700
10305
|
out(" files id-generation uuid-v4|uuid-v7 Select the managed Files schema ID default.");
|
|
9701
10306
|
out(" files r2 setup Create/reuse private Cloudflare R2 buckets, configure Vercel Production/Preview, and configure local MinIO by default.");
|
|
@@ -9717,8 +10322,8 @@ function printHelp({ out }) {
|
|
|
9717
10322
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
9718
10323
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
9719
10324
|
out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
|
|
9720
|
-
out(" dev local Enable local Loom development using a managed
|
|
9721
|
-
out(" dev sync Rebuild
|
|
10325
|
+
out(" dev local Enable local Loom development using a managed pnpm override or Deno link.");
|
|
10326
|
+
out(" dev sync Rebuild local Loom and refresh this project's pnpm or Deno install when linked.");
|
|
9722
10327
|
out(" dev published Remove the managed local-dev override and return to the published dependency.");
|
|
9723
10328
|
out("");
|
|
9724
10329
|
out("Options:");
|
|
@@ -9957,12 +10562,15 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
9957
10562
|
printSkillsHelp(io);
|
|
9958
10563
|
return 0;
|
|
9959
10564
|
}
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
10565
|
+
let projectMetadata;
|
|
10566
|
+
try {
|
|
10567
|
+
projectMetadata = await (0, projectTooling_js_1.readProjectPackageMetadata)(cwd);
|
|
10568
|
+
}
|
|
10569
|
+
catch (error) {
|
|
10570
|
+
io.err(error.message);
|
|
9963
10571
|
return 1;
|
|
9964
10572
|
}
|
|
9965
|
-
const packageJson =
|
|
10573
|
+
const packageJson = projectMetadata.packageJson;
|
|
9966
10574
|
const manifestText = await readTextIfExists((0, node_path_1.join)(cwd, "loom.json"));
|
|
9967
10575
|
const manifest = manifestText
|
|
9968
10576
|
? parseJson(manifestText, "loom.json")
|
|
@@ -10130,7 +10738,16 @@ async function runDbSchemaGen(cwd, forwardedArgs, io) {
|
|
|
10130
10738
|
if (!isNodeErrorCode(error, "MODULE_NOT_FOUND")) {
|
|
10131
10739
|
throw error;
|
|
10132
10740
|
}
|
|
10133
|
-
|
|
10741
|
+
const manifest = await readManifestIfExists(cwd);
|
|
10742
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
10743
|
+
if (usesDenoTooling(tooling)) {
|
|
10744
|
+
const formatExitCode = await runInheritedChild("deno", ["fmt", config.dirs.valibotGeneratedDir], cwd);
|
|
10745
|
+
if (formatExitCode !== 0)
|
|
10746
|
+
return formatExitCode;
|
|
10747
|
+
}
|
|
10748
|
+
else {
|
|
10749
|
+
io.out("Biome is not installed; generated Valibot files were left unformatted.");
|
|
10750
|
+
}
|
|
10134
10751
|
}
|
|
10135
10752
|
if (await syncValibotBarrel(cwd, config)) {
|
|
10136
10753
|
io.out(`Updated ${config.modules.valibotBarrelModule}.`);
|
|
@@ -10433,7 +11050,7 @@ async function runDev(cwd, mode, pathInput, io, options = {}) {
|
|
|
10433
11050
|
io.out(`Updated ${result.changedFiles.join(", ")}.`);
|
|
10434
11051
|
}
|
|
10435
11052
|
else if (result.notes.length) {
|
|
10436
|
-
io.out("Project
|
|
11053
|
+
io.out("Project config uses a published @gadicc/loom dependency, but follow-up is still needed.");
|
|
10437
11054
|
}
|
|
10438
11055
|
else {
|
|
10439
11056
|
io.out("Project already uses the published @gadicc/loom dependency.");
|