@mnci/cli 4.33.0 → 4.34.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/dist/cli.js +800 -490
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -37,9 +37,10 @@ __export(main_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(main_exports);
|
|
38
38
|
var import_commander = require("commander");
|
|
39
39
|
|
|
40
|
-
// src/ci-pipeline/
|
|
41
|
-
var
|
|
42
|
-
var
|
|
40
|
+
// src/ci-pipeline/audit.use-case.ts
|
|
41
|
+
var import_node_fs2 = require("fs");
|
|
42
|
+
var import_node_path = require("path");
|
|
43
|
+
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
43
44
|
|
|
44
45
|
// src/nx-workspace/nx.client.ts
|
|
45
46
|
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
@@ -206,15 +207,151 @@ function runFormatter(cwd, target = ".") {
|
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
|
|
210
|
+
// src/ci-pipeline/ci-environment.client.ts
|
|
211
|
+
var import_node_fs = require("fs");
|
|
212
|
+
function detectCiHost(environment) {
|
|
213
|
+
if (environment.GITHUB_ACTIONS === "true") {
|
|
214
|
+
return "github";
|
|
215
|
+
}
|
|
216
|
+
if (environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "") {
|
|
217
|
+
return "azure";
|
|
218
|
+
}
|
|
219
|
+
return "local";
|
|
220
|
+
}
|
|
221
|
+
function pullRequestTarget(environment) {
|
|
222
|
+
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
223
|
+
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
224
|
+
}
|
|
225
|
+
function isMainPush(environment) {
|
|
226
|
+
if (environment.GITHUB_ACTIONS === "true") {
|
|
227
|
+
return environment.GITHUB_EVENT_NAME === "push" && environment.GITHUB_REF_NAME === "main";
|
|
228
|
+
}
|
|
229
|
+
return environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "" && ["IndividualCI", "BatchedCI"].includes(environment.BUILD_REASON ?? "") && environment.BUILD_SOURCEBRANCHNAME === "main";
|
|
230
|
+
}
|
|
231
|
+
function addToPath(host, environment, directory, log) {
|
|
232
|
+
if (host === "azure") {
|
|
233
|
+
log(`##vso[task.prependpath]${directory}`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (host === "github" && environment.GITHUB_PATH) {
|
|
237
|
+
(0, import_node_fs.appendFileSync)(environment.GITHUB_PATH, `${directory}
|
|
238
|
+
`);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
log("Not running in a CI that reads a PATH file - skipping.");
|
|
242
|
+
}
|
|
243
|
+
function groupStart(host, title) {
|
|
244
|
+
switch (host) {
|
|
245
|
+
case "github": {
|
|
246
|
+
return `::group::${title}`;
|
|
247
|
+
}
|
|
248
|
+
case "azure": {
|
|
249
|
+
return `##[group]${title}`;
|
|
250
|
+
}
|
|
251
|
+
case "local": {
|
|
252
|
+
return `
|
|
253
|
+
\u25B8 ${title}`;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function groupEnd(host) {
|
|
258
|
+
switch (host) {
|
|
259
|
+
case "github": {
|
|
260
|
+
return "::endgroup::";
|
|
261
|
+
}
|
|
262
|
+
case "azure": {
|
|
263
|
+
return "##[endgroup]";
|
|
264
|
+
}
|
|
265
|
+
case "local": {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/ci-pipeline/audit.use-case.ts
|
|
272
|
+
var BLOCKING_SEVERITIES = /* @__PURE__ */ new Set(["critical", "high", "moderate"]);
|
|
273
|
+
var AUDIT_MAX_BUFFER = 32 * 1024 * 1024;
|
|
274
|
+
function onlyMajorFix(advisory) {
|
|
275
|
+
return typeof advisory.fixAvailable === "object" && advisory.fixAvailable.isSemVerMajor === true;
|
|
276
|
+
}
|
|
277
|
+
function classifyNpmAudit(report) {
|
|
278
|
+
const all = Object.values(report.vulnerabilities ?? {});
|
|
279
|
+
const blocking = all.filter((advisory) => Boolean(advisory.fixAvailable) && BLOCKING_SEVERITIES.has(advisory.severity) && !onlyMajorFix(advisory));
|
|
280
|
+
const notes = all.filter((advisory) => !blocking.includes(advisory)).map((advisory) => {
|
|
281
|
+
const why = advisory.fixAvailable ? onlyMajorFix(advisory) ? " - only a semver-major change would remove it (often a parent downgrade), not applied automatically" : " - fix available, below the blocking threshold" : " - NO fix available upstream, nothing to do here";
|
|
282
|
+
return ` note [${advisory.severity}] ${advisory.name}${why}`;
|
|
283
|
+
});
|
|
284
|
+
return { blocking, total: all.length, notes };
|
|
285
|
+
}
|
|
286
|
+
function auditNpm(result, log) {
|
|
287
|
+
let report;
|
|
288
|
+
try {
|
|
289
|
+
report = JSON.parse(result.stdout);
|
|
290
|
+
} catch {
|
|
291
|
+
log(`npm audit produced no JSON (exit ${result.status}) - not blocking on a broken audit.`);
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
const { blocking, total, notes } = classifyNpmAudit(report);
|
|
295
|
+
for (const note of notes) {
|
|
296
|
+
log(note);
|
|
297
|
+
}
|
|
298
|
+
if (blocking.length === 0) {
|
|
299
|
+
log(`npm audit - ${total} advisory(ies), none actionable at moderate or above.`);
|
|
300
|
+
return 0;
|
|
301
|
+
}
|
|
302
|
+
for (const advisory of blocking) {
|
|
303
|
+
log(` BLOCKING [${advisory.severity}] ${advisory.name} - fix available`);
|
|
304
|
+
}
|
|
305
|
+
log("Each has a published fix. Add a targeted overrides entry in package.json rather than npm audit fix --force.");
|
|
306
|
+
return 1;
|
|
307
|
+
}
|
|
308
|
+
function runAudit(workspaceRoot, dependencies = {}) {
|
|
309
|
+
const environment = dependencies.environment ?? process.env;
|
|
310
|
+
const processes = dependencies.processes ?? {
|
|
311
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
312
|
+
capture: (command, arguments_) => {
|
|
313
|
+
const result = import_cross_spawn2.default.sync(command, arguments_, { cwd: workspaceRoot, encoding: "utf8", maxBuffer: AUDIT_MAX_BUFFER });
|
|
314
|
+
return { status: result.status ?? 1, stdout: result.stdout ?? "" };
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const log = dependencies.log ?? ((message) => {
|
|
318
|
+
console.log(message);
|
|
319
|
+
});
|
|
320
|
+
const host = detectCiHost(environment);
|
|
321
|
+
const closeGroup = () => {
|
|
322
|
+
const closing = groupEnd(host);
|
|
323
|
+
if (closing !== void 0) {
|
|
324
|
+
log(closing);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
log(groupStart(host, "npm audit"));
|
|
328
|
+
const npm = auditNpm(processes.capture("npm", ["audit", "--json"]), log);
|
|
329
|
+
closeGroup();
|
|
330
|
+
if (npm !== 0) {
|
|
331
|
+
return npm;
|
|
332
|
+
}
|
|
333
|
+
if (!(0, import_node_fs2.existsSync)((0, import_node_path.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
334
|
+
return 0;
|
|
335
|
+
}
|
|
336
|
+
log(groupStart(host, "pip-audit (non-blocking)"));
|
|
337
|
+
processes.run(process.platform === "win32" ? "python" : "python3", ["-m", "pip_audit"]);
|
|
338
|
+
closeGroup();
|
|
339
|
+
return 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/ci-pipeline/native.use-case.ts
|
|
343
|
+
var import_node_fs5 = require("fs");
|
|
344
|
+
var import_node_path4 = require("path");
|
|
345
|
+
|
|
209
346
|
// src/workspace-overlay/overlay.use-case.ts
|
|
210
|
-
var
|
|
211
|
-
var
|
|
347
|
+
var import_node_fs4 = require("fs");
|
|
348
|
+
var import_node_path3 = require("path");
|
|
212
349
|
|
|
213
350
|
// src/file-system/file-system.client.ts
|
|
214
|
-
var
|
|
215
|
-
var
|
|
351
|
+
var import_node_fs3 = require("fs");
|
|
352
|
+
var import_node_path2 = require("path");
|
|
216
353
|
function readJson(path) {
|
|
217
|
-
return JSON.parse((0,
|
|
354
|
+
return JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
218
355
|
}
|
|
219
356
|
function stripJsonComments(text) {
|
|
220
357
|
let result = "";
|
|
@@ -271,7 +408,7 @@ function stripJsonComments(text) {
|
|
|
271
408
|
}
|
|
272
409
|
function readCodeWorkspace(path) {
|
|
273
410
|
try {
|
|
274
|
-
const withoutComments = stripJsonComments((0,
|
|
411
|
+
const withoutComments = stripJsonComments((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
275
412
|
return JSON.parse(withoutComments.replaceAll(/,(\s*[}\]])/g, "$1"));
|
|
276
413
|
} catch {
|
|
277
414
|
return void 0;
|
|
@@ -282,14 +419,14 @@ function toJson(value) {
|
|
|
282
419
|
`;
|
|
283
420
|
}
|
|
284
421
|
function writeFileEnsured(path, content) {
|
|
285
|
-
(0,
|
|
286
|
-
(0,
|
|
422
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path2.dirname)(path), { recursive: true });
|
|
423
|
+
(0, import_node_fs3.writeFileSync)(path, content);
|
|
287
424
|
}
|
|
288
425
|
function markExecutable(path) {
|
|
289
|
-
(0,
|
|
426
|
+
(0, import_node_fs3.chmodSync)(path, 493);
|
|
290
427
|
}
|
|
291
428
|
function fileExists(path) {
|
|
292
|
-
return (0,
|
|
429
|
+
return (0, import_node_fs3.existsSync)(path);
|
|
293
430
|
}
|
|
294
431
|
|
|
295
432
|
// src/workspace-overlay/overlay.use-case.ts
|
|
@@ -432,9 +569,9 @@ var VSCODE_EXTENSION_TAG = "type:vscode-extension";
|
|
|
432
569
|
var GO_RELEASE_TAG = "release:go";
|
|
433
570
|
var GO_CGO_TAG = "build:cgo";
|
|
434
571
|
function hasNativeGoApp(workspaceRoot) {
|
|
435
|
-
return (0,
|
|
572
|
+
return (0, import_node_fs4.globSync)("apps/*/project.json", { cwd: workspaceRoot }).some((projectJson) => {
|
|
436
573
|
try {
|
|
437
|
-
const { tags } = JSON.parse((0,
|
|
574
|
+
const { tags } = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path3.join)(workspaceRoot, projectJson), "utf8"));
|
|
438
575
|
return (tags ?? []).includes(GO_CGO_TAG);
|
|
439
576
|
} catch {
|
|
440
577
|
return false;
|
|
@@ -775,8 +912,8 @@ function isUnmodifiedMnciEslintConfig(content) {
|
|
|
775
912
|
return code.length === 2 && code[0] === "import mnci from '@mnci/eslint-config'" && code[1] === "export default mnci({ workspaceRoot: import.meta.dirname })";
|
|
776
913
|
}
|
|
777
914
|
function writeEslintEntryPoint(workspaceRoot, onProgress) {
|
|
778
|
-
const path = (0,
|
|
779
|
-
if ((0,
|
|
915
|
+
const path = (0, import_node_path3.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
916
|
+
if ((0, import_node_fs4.existsSync)(path) && !isUnmodifiedMnciEslintConfig((0, import_node_fs4.readFileSync)(path, "utf8"))) {
|
|
780
917
|
onProgress(`${ESLINT_USER_FILENAME} \u2014 kept as it is, it is yours`);
|
|
781
918
|
return;
|
|
782
919
|
}
|
|
@@ -944,7 +1081,7 @@ function mnciConfig(options) {
|
|
|
944
1081
|
};
|
|
945
1082
|
}
|
|
946
1083
|
function readMnciConfig(workspaceRoot) {
|
|
947
|
-
const nxJson = readJson((0,
|
|
1084
|
+
const nxJson = readJson((0, import_node_path3.join)(workspaceRoot, "nx.json"));
|
|
948
1085
|
return nxJson.mnci ?? {};
|
|
949
1086
|
}
|
|
950
1087
|
function pythonPublishUrl(registry) {
|
|
@@ -1872,12 +2009,12 @@ var ECOSYSTEM_MANIFESTS = {
|
|
|
1872
2009
|
};
|
|
1873
2010
|
function hasEcosystemProject(workspaceRoot, roots, manifests) {
|
|
1874
2011
|
return roots.some((root) => {
|
|
1875
|
-
const base = (0,
|
|
1876
|
-
if (!(0,
|
|
2012
|
+
const base = (0, import_node_path3.join)(workspaceRoot, root);
|
|
2013
|
+
if (!(0, import_node_fs4.existsSync)(base)) {
|
|
1877
2014
|
return false;
|
|
1878
2015
|
}
|
|
1879
|
-
return (0,
|
|
1880
|
-
(entry) => entry.isDirectory() && manifests.some((manifest) => (0,
|
|
2016
|
+
return (0, import_node_fs4.readdirSync)(base, { withFileTypes: true }).some(
|
|
2017
|
+
(entry) => entry.isDirectory() && manifests.some((manifest) => (0, import_node_fs4.existsSync)((0, import_node_path3.join)(base, entry.name, manifest)))
|
|
1881
2018
|
);
|
|
1882
2019
|
});
|
|
1883
2020
|
}
|
|
@@ -1955,11 +2092,11 @@ var LOCAL_REGISTRY_SCAFFOLDING = {
|
|
|
1955
2092
|
rootTarget: "local-registry"
|
|
1956
2093
|
};
|
|
1957
2094
|
function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
1958
|
-
(0,
|
|
2095
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, LOCAL_REGISTRY_SCAFFOLDING.directory), {
|
|
1959
2096
|
recursive: true,
|
|
1960
2097
|
force: true
|
|
1961
2098
|
});
|
|
1962
|
-
const manifestPath = (0,
|
|
2099
|
+
const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
|
|
1963
2100
|
if (!fileExists(manifestPath)) return;
|
|
1964
2101
|
const manifest = readJson(manifestPath);
|
|
1965
2102
|
if (manifest.devDependencies?.[LOCAL_REGISTRY_SCAFFOLDING.devDependency] !== void 0) {
|
|
@@ -1975,23 +2112,23 @@ function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
|
1975
2112
|
}
|
|
1976
2113
|
function removeNxScaffolding(workspaceRoot) {
|
|
1977
2114
|
for (const entry of NX_SCAFFOLDING_TO_REMOVE) {
|
|
1978
|
-
(0,
|
|
2115
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, entry), { recursive: true, force: true });
|
|
1979
2116
|
}
|
|
1980
2117
|
removeNxAuthoredAgentFiles(workspaceRoot);
|
|
1981
2118
|
removeProjectEslintConfigs(workspaceRoot);
|
|
1982
2119
|
}
|
|
1983
2120
|
function removeNxAuthoredAgentFiles(workspaceRoot) {
|
|
1984
|
-
(0,
|
|
1985
|
-
const claudeDirectory = (0,
|
|
1986
|
-
if ((0,
|
|
1987
|
-
(0,
|
|
2121
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, NX_CLAUDE_SETTINGS), { force: true });
|
|
2122
|
+
const claudeDirectory = (0, import_node_path3.join)(workspaceRoot, (0, import_node_path3.dirname)(NX_CLAUDE_SETTINGS));
|
|
2123
|
+
if ((0, import_node_fs4.existsSync)(claudeDirectory) && (0, import_node_fs4.readdirSync)(claudeDirectory).length === 0) {
|
|
2124
|
+
(0, import_node_fs4.rmSync)(claudeDirectory, { recursive: true, force: true });
|
|
1988
2125
|
}
|
|
1989
2126
|
for (const name of NX_AUTHORED_AGENT_FILES) {
|
|
1990
|
-
const path = (0,
|
|
1991
|
-
if (!(0,
|
|
1992
|
-
const kept = withoutNxAgentRules((0,
|
|
2127
|
+
const path = (0, import_node_path3.join)(workspaceRoot, name);
|
|
2128
|
+
if (!(0, import_node_fs4.existsSync)(path)) continue;
|
|
2129
|
+
const kept = withoutNxAgentRules((0, import_node_fs4.readFileSync)(path, "utf8"));
|
|
1993
2130
|
if (kept === void 0) continue;
|
|
1994
|
-
if (kept.trim() === "") (0,
|
|
2131
|
+
if (kept.trim() === "") (0, import_node_fs4.rmSync)(path, { force: true });
|
|
1995
2132
|
else writeFileEnsured(path, kept);
|
|
1996
2133
|
}
|
|
1997
2134
|
}
|
|
@@ -2006,14 +2143,14 @@ function withoutNxAgentRules(content) {
|
|
|
2006
2143
|
return `${content.slice(0, start)}${rest}`.replace(/^[\r\n]+/, "");
|
|
2007
2144
|
}
|
|
2008
2145
|
function removeIfPresent(path) {
|
|
2009
|
-
(0,
|
|
2146
|
+
(0, import_node_fs4.rmSync)(path, { recursive: true, force: true });
|
|
2010
2147
|
}
|
|
2011
2148
|
function ensureEslintCacheIgnored(workspaceRoot) {
|
|
2012
|
-
const gitignorePath = (0,
|
|
2149
|
+
const gitignorePath = (0, import_node_path3.join)(workspaceRoot, ".gitignore");
|
|
2013
2150
|
if (!fileExists(gitignorePath)) {
|
|
2014
2151
|
return;
|
|
2015
2152
|
}
|
|
2016
|
-
const current = (0,
|
|
2153
|
+
const current = (0, import_node_fs4.readFileSync)(gitignorePath, "utf8");
|
|
2017
2154
|
if (current.split("\n").some((line) => line.trim() === ".eslintcache")) {
|
|
2018
2155
|
return;
|
|
2019
2156
|
}
|
|
@@ -2028,18 +2165,18 @@ function ensureEslintCacheIgnored(workspaceRoot) {
|
|
|
2028
2165
|
}
|
|
2029
2166
|
var PYTHON_ARTEFACT_IGNORES = ["__pycache__/", "*.py[cod]"];
|
|
2030
2167
|
function ensurePythonArtefactsIgnored(workspaceRoot) {
|
|
2031
|
-
const gitignorePath = (0,
|
|
2168
|
+
const gitignorePath = (0, import_node_path3.join)(workspaceRoot, ".gitignore");
|
|
2032
2169
|
if (!fileExists(gitignorePath)) {
|
|
2033
2170
|
return;
|
|
2034
2171
|
}
|
|
2035
|
-
const hasPython = (0,
|
|
2172
|
+
const hasPython = (0, import_node_fs4.globSync)(
|
|
2036
2173
|
["python-packages/*/pyproject.toml", "apps/*/pyproject.toml", "libs/*/pyproject.toml"],
|
|
2037
2174
|
{ cwd: workspaceRoot }
|
|
2038
2175
|
).length > 0;
|
|
2039
2176
|
if (!hasPython) {
|
|
2040
2177
|
return;
|
|
2041
2178
|
}
|
|
2042
|
-
const current = (0,
|
|
2179
|
+
const current = (0, import_node_fs4.readFileSync)(gitignorePath, "utf8");
|
|
2043
2180
|
const present = new Set(current.split("\n").map((line) => line.trim()));
|
|
2044
2181
|
const missing = PYTHON_ARTEFACT_IGNORES.filter((line) => !present.has(line));
|
|
2045
2182
|
if (missing.length === 0) {
|
|
@@ -2059,16 +2196,16 @@ ${missing.join("\n")}
|
|
|
2059
2196
|
);
|
|
2060
2197
|
}
|
|
2061
2198
|
function removeProjectEslintConfigs(workspaceRoot) {
|
|
2062
|
-
const matches = (0,
|
|
2199
|
+
const matches = (0, import_node_fs4.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
2063
2200
|
cwd: workspaceRoot
|
|
2064
2201
|
});
|
|
2065
2202
|
for (const match of matches) {
|
|
2066
|
-
(0,
|
|
2203
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, match), { force: true });
|
|
2067
2204
|
}
|
|
2068
2205
|
}
|
|
2069
2206
|
function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
2070
2207
|
}) {
|
|
2071
|
-
const nxJsonPath = (0,
|
|
2208
|
+
const nxJsonPath = (0, import_node_path3.join)(workspaceRoot, "nx.json");
|
|
2072
2209
|
const nxJson = readJson(nxJsonPath);
|
|
2073
2210
|
const generators = {
|
|
2074
2211
|
...nxJson.generators,
|
|
@@ -2076,7 +2213,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2076
2213
|
};
|
|
2077
2214
|
const sync = { ...nxJson.sync, ...SYNC_CONFIG };
|
|
2078
2215
|
const mnci = { ...nxJson.mnci, ...mnciConfig(options) };
|
|
2079
|
-
const rootManifest = readJson((0,
|
|
2216
|
+
const rootManifest = readJson((0, import_node_path3.join)(workspaceRoot, "package.json"));
|
|
2080
2217
|
const hasPythonPlugin = (rootManifest.devDependencies ?? {})["@mnci/nx-python-pip"] !== void 0 || (rootManifest.dependencies ?? {})["@mnci/nx-python-pip"] !== void 0;
|
|
2081
2218
|
const withRelease = withReleaseConfig(nxJson, options.ci);
|
|
2082
2219
|
const patched = withPythonGraphPlugin(
|
|
@@ -2086,7 +2223,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2086
2223
|
onProgress("nx.json \u2014 release, sync, generators, shared inputs, mnci block");
|
|
2087
2224
|
writeFileEnsured(nxJsonPath, toJson({ ...patched, generators, sync, mnci }));
|
|
2088
2225
|
onProgress("package.json \u2014 root scripts, TS compilers, ESLint toolchain, overrides");
|
|
2089
|
-
const manifestPath = (0,
|
|
2226
|
+
const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
|
|
2090
2227
|
const manifest = readJson(manifestPath);
|
|
2091
2228
|
const scripts = {
|
|
2092
2229
|
...manifest.scripts,
|
|
@@ -2138,32 +2275,32 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2138
2275
|
`.npmrc \u2014 ${options.registry.kind === "azure-artifacts" ? "Azure Artifacts feed routing and credentials" : "public npm registry auth"}`
|
|
2139
2276
|
);
|
|
2140
2277
|
writeFileEnsured(
|
|
2141
|
-
(0,
|
|
2278
|
+
(0, import_node_path3.join)(workspaceRoot, ".npmrc"),
|
|
2142
2279
|
npmrcContent(options.registry, options.scope, options.npmAuth)
|
|
2143
2280
|
);
|
|
2144
2281
|
onProgress("commitlint.config.mjs and .husky/commit-msg \u2014 conventional commit enforcement");
|
|
2145
|
-
writeFileEnsured((0,
|
|
2146
|
-
const hookPath = (0,
|
|
2282
|
+
writeFileEnsured((0, import_node_path3.join)(workspaceRoot, "commitlint.config.mjs"), COMMITLINT_CONFIG);
|
|
2283
|
+
const hookPath = (0, import_node_path3.join)(workspaceRoot, ".husky/commit-msg");
|
|
2147
2284
|
writeFileEnsured(hookPath, COMMIT_MSG_HOOK);
|
|
2148
2285
|
markExecutable(hookPath);
|
|
2149
2286
|
onProgress(`${ESLINT_MNCI_FILENAME} \u2014 the shared lint AND formatting opinion`);
|
|
2150
|
-
writeFileEnsured((0,
|
|
2287
|
+
writeFileEnsured((0, import_node_path3.join)(workspaceRoot, ESLINT_MNCI_FILENAME), ESLINT_MNCI_CONFIG);
|
|
2151
2288
|
writeEslintEntryPoint(workspaceRoot, onProgress);
|
|
2152
2289
|
ensureEslintCacheIgnored(workspaceRoot);
|
|
2153
2290
|
ensurePythonArtefactsIgnored(workspaceRoot);
|
|
2154
2291
|
for (const retired of RETIRED_FORMATTER_FILES) {
|
|
2155
|
-
removeIfPresent((0,
|
|
2292
|
+
removeIfPresent((0, import_node_path3.join)(workspaceRoot, retired));
|
|
2156
2293
|
}
|
|
2157
2294
|
onProgress(".devcontainer/devcontainer.json \u2014 a local toolchain matching CI");
|
|
2158
2295
|
writeFileEnsured(
|
|
2159
|
-
(0,
|
|
2296
|
+
(0, import_node_path3.join)(workspaceRoot, ".devcontainer/devcontainer.json"),
|
|
2160
2297
|
devcontainerJson(options.workspaceName)
|
|
2161
2298
|
);
|
|
2162
2299
|
removeNxScaffolding(workspaceRoot);
|
|
2163
2300
|
onProgress(
|
|
2164
2301
|
`${options.workspaceName}.code-workspace \u2014 settings, extensions, launch configs`
|
|
2165
2302
|
);
|
|
2166
|
-
const codeWorkspacePath = (0,
|
|
2303
|
+
const codeWorkspacePath = (0, import_node_path3.join)(workspaceRoot, `${options.workspaceName}.code-workspace`);
|
|
2167
2304
|
const existing = readCodeWorkspace(codeWorkspacePath);
|
|
2168
2305
|
writeFileEnsured(
|
|
2169
2306
|
codeWorkspacePath,
|
|
@@ -2175,7 +2312,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2175
2312
|
)
|
|
2176
2313
|
);
|
|
2177
2314
|
if (options.workspaceName !== "undefined") {
|
|
2178
|
-
(0,
|
|
2315
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
|
|
2179
2316
|
}
|
|
2180
2317
|
const publishUrl = pythonPublishUrl(options.registry);
|
|
2181
2318
|
const nugetUrl = nugetFeedUrl(options.registry);
|
|
@@ -2183,7 +2320,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2183
2320
|
if (options.ci === "azure" || options.ci === "both") {
|
|
2184
2321
|
onProgress("azure-pipelines.yml \u2014 build, verify, pack and release");
|
|
2185
2322
|
writeFileEnsured(
|
|
2186
|
-
(0,
|
|
2323
|
+
(0, import_node_path3.join)(workspaceRoot, "azure-pipelines.yml"),
|
|
2187
2324
|
azurePipelinesYaml(
|
|
2188
2325
|
options.agent,
|
|
2189
2326
|
options.variableGroup,
|
|
@@ -2198,58 +2335,10 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2198
2335
|
if (options.ci === "github" || options.ci === "both") {
|
|
2199
2336
|
onProgress(".github/workflows/ci.yml and dependabot.yml");
|
|
2200
2337
|
writeFileEnsured(
|
|
2201
|
-
(0,
|
|
2338
|
+
(0, import_node_path3.join)(workspaceRoot, ".github/workflows/ci.yml"),
|
|
2202
2339
|
githubActionsYaml(options.agent, publishUrl, options.registry.kind, options.ci, nugetUrl, nativeApps)
|
|
2203
2340
|
);
|
|
2204
|
-
writeFileEnsured((0,
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
// src/ci-pipeline/ci-environment.client.ts
|
|
2209
|
-
function detectCiHost(environment) {
|
|
2210
|
-
if (environment.GITHUB_ACTIONS === "true") {
|
|
2211
|
-
return "github";
|
|
2212
|
-
}
|
|
2213
|
-
if (environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "") {
|
|
2214
|
-
return "azure";
|
|
2215
|
-
}
|
|
2216
|
-
return "local";
|
|
2217
|
-
}
|
|
2218
|
-
function pullRequestTarget(environment) {
|
|
2219
|
-
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
2220
|
-
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
2221
|
-
}
|
|
2222
|
-
function isMainPush(environment) {
|
|
2223
|
-
if (environment.GITHUB_ACTIONS === "true") {
|
|
2224
|
-
return environment.GITHUB_EVENT_NAME === "push" && environment.GITHUB_REF_NAME === "main";
|
|
2225
|
-
}
|
|
2226
|
-
return environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "" && ["IndividualCI", "BatchedCI"].includes(environment.BUILD_REASON ?? "") && environment.BUILD_SOURCEBRANCHNAME === "main";
|
|
2227
|
-
}
|
|
2228
|
-
function groupStart(host, title) {
|
|
2229
|
-
switch (host) {
|
|
2230
|
-
case "github": {
|
|
2231
|
-
return `::group::${title}`;
|
|
2232
|
-
}
|
|
2233
|
-
case "azure": {
|
|
2234
|
-
return `##[group]${title}`;
|
|
2235
|
-
}
|
|
2236
|
-
case "local": {
|
|
2237
|
-
return `
|
|
2238
|
-
\u25B8 ${title}`;
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
function groupEnd(host) {
|
|
2243
|
-
switch (host) {
|
|
2244
|
-
case "github": {
|
|
2245
|
-
return "::endgroup::";
|
|
2246
|
-
}
|
|
2247
|
-
case "azure": {
|
|
2248
|
-
return "##[endgroup]";
|
|
2249
|
-
}
|
|
2250
|
-
case "local": {
|
|
2251
|
-
return void 0;
|
|
2252
|
-
}
|
|
2341
|
+
writeFileEnsured((0, import_node_path3.join)(workspaceRoot, ".github/dependabot.yml"), dependabotConfig(workspaceRoot));
|
|
2253
2342
|
}
|
|
2254
2343
|
}
|
|
2255
2344
|
|
|
@@ -2277,26 +2366,26 @@ function runNative(workspaceRoot, dependencies = {}) {
|
|
|
2277
2366
|
if (built !== 0) {
|
|
2278
2367
|
return built;
|
|
2279
2368
|
}
|
|
2280
|
-
if (!isMainPush(environment) || !(0,
|
|
2369
|
+
if (!isMainPush(environment) || !(0, import_node_fs5.existsSync)((0, import_node_path4.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2281
2370
|
return 0;
|
|
2282
2371
|
}
|
|
2283
2372
|
return inGroup("Attach this OS's zip to the GitHub Release", "node", ["tools/go-app-release.cjs", "assets", "--native"]);
|
|
2284
2373
|
}
|
|
2285
2374
|
|
|
2286
2375
|
// src/ci-pipeline/pack.use-case.ts
|
|
2287
|
-
var
|
|
2288
|
-
var
|
|
2376
|
+
var import_node_fs6 = require("fs");
|
|
2377
|
+
var import_node_path5 = require("path");
|
|
2289
2378
|
function hasAppToPack(workspaceRoot) {
|
|
2290
|
-
const hasProjectJson = (0,
|
|
2291
|
-
const hasInlineNx = (0,
|
|
2379
|
+
const hasProjectJson = (0, import_node_fs6.globSync)("apps/*/project.json", { cwd: workspaceRoot }).length > 0;
|
|
2380
|
+
const hasInlineNx = (0, import_node_fs6.globSync)("apps/*/package.json", { cwd: workspaceRoot }).some((manifest) => {
|
|
2292
2381
|
try {
|
|
2293
|
-
const parsed = JSON.parse((0,
|
|
2382
|
+
const parsed = JSON.parse((0, import_node_fs6.readFileSync)((0, import_node_path5.join)(workspaceRoot, manifest), "utf8"));
|
|
2294
2383
|
return Boolean(parsed.nx);
|
|
2295
2384
|
} catch {
|
|
2296
2385
|
return false;
|
|
2297
2386
|
}
|
|
2298
2387
|
});
|
|
2299
|
-
const hasCsproj = (0,
|
|
2388
|
+
const hasCsproj = (0, import_node_fs6.globSync)("apps/*/*.csproj", { cwd: workspaceRoot }).length > 0;
|
|
2300
2389
|
return hasProjectJson || hasInlineNx || hasCsproj;
|
|
2301
2390
|
}
|
|
2302
2391
|
function runPack(workspaceRoot, dependencies = {}) {
|
|
@@ -2309,7 +2398,7 @@ function runPack(workspaceRoot, dependencies = {}) {
|
|
|
2309
2398
|
console.log(message);
|
|
2310
2399
|
});
|
|
2311
2400
|
const host = detectCiHost(environment);
|
|
2312
|
-
(0,
|
|
2401
|
+
(0, import_node_fs6.mkdirSync)((0, import_node_path5.join)(workspaceRoot, "dist", "drop"), { recursive: true });
|
|
2313
2402
|
if (!hasAppToPack(workspaceRoot)) {
|
|
2314
2403
|
log("No apps to pack - skipping.");
|
|
2315
2404
|
return 0;
|
|
@@ -2324,12 +2413,12 @@ function runPack(workspaceRoot, dependencies = {}) {
|
|
|
2324
2413
|
}
|
|
2325
2414
|
|
|
2326
2415
|
// src/ci-pipeline/release.use-case.ts
|
|
2327
|
-
var
|
|
2328
|
-
var
|
|
2416
|
+
var import_node_fs7 = require("fs");
|
|
2417
|
+
var import_node_path6 = require("path");
|
|
2329
2418
|
var SPECIFIER = /^(?:major|minor|patch|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2330
2419
|
function hasTag(workspaceRoot, relativePath, tag) {
|
|
2331
2420
|
try {
|
|
2332
|
-
const parsed = JSON.parse((0,
|
|
2421
|
+
const parsed = JSON.parse((0, import_node_fs7.readFileSync)((0, import_node_path6.join)(workspaceRoot, relativePath), "utf8"));
|
|
2333
2422
|
const tags = relativePath.endsWith("project.json") ? parsed.tags : parsed.nx?.tags;
|
|
2334
2423
|
return Array.isArray(tags) && tags.includes(tag);
|
|
2335
2424
|
} catch {
|
|
@@ -2338,12 +2427,12 @@ function hasTag(workspaceRoot, relativePath, tag) {
|
|
|
2338
2427
|
}
|
|
2339
2428
|
function releasableCounts(workspaceRoot) {
|
|
2340
2429
|
return {
|
|
2341
|
-
npm: (0,
|
|
2342
|
-
csharp: (0,
|
|
2343
|
-
python: (0,
|
|
2344
|
-
dart: (0,
|
|
2345
|
-
vscode: (0,
|
|
2346
|
-
go: (0,
|
|
2430
|
+
npm: (0, import_node_fs7.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length,
|
|
2431
|
+
csharp: (0, import_node_fs7.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }).length,
|
|
2432
|
+
python: (0, import_node_fs7.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot }).length,
|
|
2433
|
+
dart: (0, import_node_fs7.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }).length,
|
|
2434
|
+
vscode: (0, import_node_fs7.globSync)("apps/*/package.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, VSCODE_EXTENSION_TAG)).length,
|
|
2435
|
+
go: (0, import_node_fs7.globSync)("apps/*/project.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, GO_RELEASE_TAG)).length
|
|
2347
2436
|
};
|
|
2348
2437
|
}
|
|
2349
2438
|
function shallowCloneGuard(processes, log) {
|
|
@@ -2359,7 +2448,7 @@ function shallowCloneGuard(processes, log) {
|
|
|
2359
2448
|
return 0;
|
|
2360
2449
|
}
|
|
2361
2450
|
function npmPreflight(workspaceRoot, registryKind, environment, processes, log) {
|
|
2362
|
-
if (registryKind !== "npm" || (0,
|
|
2451
|
+
if (registryKind !== "npm" || (0, import_node_fs7.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length === 0) {
|
|
2363
2452
|
return 0;
|
|
2364
2453
|
}
|
|
2365
2454
|
if (!environment.NODE_AUTH_TOKEN) {
|
|
@@ -2375,7 +2464,7 @@ function npmPreflight(workspaceRoot, registryKind, environment, processes, log)
|
|
|
2375
2464
|
return 0;
|
|
2376
2465
|
}
|
|
2377
2466
|
async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetchStatus) {
|
|
2378
|
-
const files = (0,
|
|
2467
|
+
const files = (0, import_node_fs7.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot });
|
|
2379
2468
|
if (registryKind !== "npm" || files.length === 0) {
|
|
2380
2469
|
return 0;
|
|
2381
2470
|
}
|
|
@@ -2388,7 +2477,7 @@ async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetc
|
|
|
2388
2477
|
return 1;
|
|
2389
2478
|
}
|
|
2390
2479
|
const names = files.map((file) => {
|
|
2391
|
-
const text = (0,
|
|
2480
|
+
const text = (0, import_node_fs7.readFileSync)((0, import_node_path6.join)(workspaceRoot, file), "utf8");
|
|
2392
2481
|
const block = text.slice(text.indexOf("[project]"));
|
|
2393
2482
|
const line = block.split("\n").find((entry) => entry.trimStart().startsWith("name"));
|
|
2394
2483
|
return line ? line.split("=", 2)[1].replaceAll(/[^\w.-]/gi, "") : "";
|
|
@@ -2462,7 +2551,7 @@ function runReleaseCommand(workspaceRoot, registry, counts, environment, process
|
|
|
2462
2551
|
return processes.run("npx", ["nx", "release", ...extra, "--yes"]);
|
|
2463
2552
|
}
|
|
2464
2553
|
function afterRelease(workspaceRoot, processes) {
|
|
2465
|
-
if ((0,
|
|
2554
|
+
if ((0, import_node_fs7.existsSync)((0, import_node_path6.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2466
2555
|
const assets = processes.run("node", ["tools/go-app-release.cjs", "assets"]);
|
|
2467
2556
|
if (assets !== 0) {
|
|
2468
2557
|
return assets;
|
|
@@ -2512,6 +2601,221 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2512
2601
|
return close(afterRelease(workspaceRoot, processes));
|
|
2513
2602
|
}
|
|
2514
2603
|
|
|
2604
|
+
// src/ci-pipeline/setup.use-case.ts
|
|
2605
|
+
var import_node_fs10 = require("fs");
|
|
2606
|
+
var import_node_path9 = require("path");
|
|
2607
|
+
|
|
2608
|
+
// src/ci-pipeline/flutter-sdk.use-case.ts
|
|
2609
|
+
var import_node_fs8 = require("fs");
|
|
2610
|
+
var import_node_path7 = require("path");
|
|
2611
|
+
function flutterSdkDirectory(machine) {
|
|
2612
|
+
return (0, import_node_path7.join)(machine.home, `.mnci-flutter-${FLUTTER_SDK_VERSION}`);
|
|
2613
|
+
}
|
|
2614
|
+
function installFlutterSdk(workspaceRoot, processes, log, machine) {
|
|
2615
|
+
if (!(0, import_node_fs8.existsSync)((0, import_node_path7.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2616
|
+
log("No Flutter projects - skipping.");
|
|
2617
|
+
return 0;
|
|
2618
|
+
}
|
|
2619
|
+
if (processes.capture("flutter", ["--version"]).status === 0) {
|
|
2620
|
+
log("Flutter SDK already on PATH - skipping.");
|
|
2621
|
+
return 0;
|
|
2622
|
+
}
|
|
2623
|
+
const sdk = flutterSdkDirectory(machine);
|
|
2624
|
+
if ((0, import_node_fs8.existsSync)(sdk)) {
|
|
2625
|
+
log(`Flutter SDK already installed at ${sdk} - skipping.`);
|
|
2626
|
+
return 0;
|
|
2627
|
+
}
|
|
2628
|
+
return processes.run("git", ["clone", "--depth", "1", "--branch", FLUTTER_SDK_VERSION, "https://github.com/flutter/flutter.git", sdk]);
|
|
2629
|
+
}
|
|
2630
|
+
function publishFlutterSdk(workspaceRoot, host, environment, log, machine) {
|
|
2631
|
+
if (!(0, import_node_fs8.existsSync)((0, import_node_path7.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2632
|
+
log("No Flutter projects - skipping.");
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
const sdk = flutterSdkDirectory(machine);
|
|
2636
|
+
if (!(0, import_node_fs8.existsSync)(sdk)) {
|
|
2637
|
+
log("Flutter SDK was not installed by mnci (already on PATH) - skipping.");
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
addToPath(host, environment, (0, import_node_path7.join)(sdk, "bin"), log);
|
|
2641
|
+
}
|
|
2642
|
+
function resolveDartDependencies(workspaceRoot, processes, log) {
|
|
2643
|
+
if (!(0, import_node_fs8.existsSync)((0, import_node_path7.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2644
|
+
log("No Flutter projects - skipping.");
|
|
2645
|
+
return 0;
|
|
2646
|
+
}
|
|
2647
|
+
return processes.run("flutter", ["pub", "get"]);
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
// src/ci-pipeline/go-tools.use-case.ts
|
|
2651
|
+
var import_node_crypto = require("crypto");
|
|
2652
|
+
var import_node_fs9 = require("fs");
|
|
2653
|
+
var import_node_os = require("os");
|
|
2654
|
+
var import_node_path8 = require("path");
|
|
2655
|
+
function currentMachine() {
|
|
2656
|
+
return { platform: process.platform, architecture: process.arch, home: (0, import_node_os.homedir)() };
|
|
2657
|
+
}
|
|
2658
|
+
var GOLANGCI_LINT_MODULE = "github.com/golangci/golangci-lint/v2/cmd/golangci-lint";
|
|
2659
|
+
function downloadGoModules(workspaceRoot, processes, log) {
|
|
2660
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path8.join)(workspaceRoot, "go.mod"))) {
|
|
2661
|
+
log("No Go projects - skipping.");
|
|
2662
|
+
return 0;
|
|
2663
|
+
}
|
|
2664
|
+
return processes.run("go", ["mod", "download"]);
|
|
2665
|
+
}
|
|
2666
|
+
async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
2667
|
+
const { processes, log, fetchBytes } = dependencies;
|
|
2668
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path8.join)(workspaceRoot, "go.mod"))) {
|
|
2669
|
+
log("No Go projects - skipping.");
|
|
2670
|
+
return 0;
|
|
2671
|
+
}
|
|
2672
|
+
if (processes.capture("golangci-lint", ["--version"]).status === 0) {
|
|
2673
|
+
log("golangci-lint already installed - skipping.");
|
|
2674
|
+
return 0;
|
|
2675
|
+
}
|
|
2676
|
+
const version = GOLANGCI_LINT_VERSION;
|
|
2677
|
+
const fallback = (reason) => {
|
|
2678
|
+
log(`Prebuilt golangci-lint ${version} unavailable (${reason}) - building it with go install instead.`);
|
|
2679
|
+
return processes.run("go", ["install", `${GOLANGCI_LINT_MODULE}@v${version}`]);
|
|
2680
|
+
};
|
|
2681
|
+
const platform = { linux: "linux", darwin: "darwin", win32: "windows" }[machine.platform];
|
|
2682
|
+
const architecture = { x64: "amd64", arm64: "arm64" }[machine.architecture];
|
|
2683
|
+
if (platform === void 0 || architecture === void 0) {
|
|
2684
|
+
return fallback(`no prebuilt release for ${machine.platform}/${machine.architecture}`);
|
|
2685
|
+
}
|
|
2686
|
+
const gopath = processes.capture("go", ["env", "GOPATH"]);
|
|
2687
|
+
if (gopath.status !== 0) {
|
|
2688
|
+
return fallback("go env GOPATH failed");
|
|
2689
|
+
}
|
|
2690
|
+
const name = `golangci-lint-${version}-${platform}-${architecture}`;
|
|
2691
|
+
const file = `${name}${platform === "windows" ? ".zip" : ".tar.gz"}`;
|
|
2692
|
+
const base = `https://github.com/golangci/golangci-lint/releases/download/v${version}/`;
|
|
2693
|
+
let temporary;
|
|
2694
|
+
try {
|
|
2695
|
+
const checksumFile = await fetchBytes(`${base}golangci-lint-${version}-checksums.txt`);
|
|
2696
|
+
const checksums = checksumFile.toString("utf8");
|
|
2697
|
+
const entry = checksums.split("\n").map((line) => line.trim().split(" ").filter(Boolean)).find((parts) => parts[1] === file);
|
|
2698
|
+
if (entry === void 0) {
|
|
2699
|
+
throw new Error(`${file} is not in the release checksums`);
|
|
2700
|
+
}
|
|
2701
|
+
const archive = await fetchBytes(base + file);
|
|
2702
|
+
if ((0, import_node_crypto.createHash)("sha256").update(archive).digest("hex") !== entry[0]) {
|
|
2703
|
+
throw new Error(`checksum mismatch for ${file}`);
|
|
2704
|
+
}
|
|
2705
|
+
temporary = (0, import_node_fs9.mkdtempSync)((0, import_node_path8.join)((0, import_node_os.tmpdir)(), "golangci-lint-"));
|
|
2706
|
+
const archivePath = (0, import_node_path8.join)(temporary, file);
|
|
2707
|
+
(0, import_node_fs9.writeFileSync)(archivePath, archive);
|
|
2708
|
+
const tar = platform === "windows" ? (0, import_node_path8.join)(process.env.SystemRoot ?? "", "System32", "tar.exe") : "tar";
|
|
2709
|
+
if (processes.run(tar, ["-xf", archivePath, "-C", temporary]) !== 0) {
|
|
2710
|
+
throw new Error(`could not extract ${file}`);
|
|
2711
|
+
}
|
|
2712
|
+
const executable = `golangci-lint${platform === "windows" ? ".exe" : ""}`;
|
|
2713
|
+
const bin = (0, import_node_path8.join)(gopath.stdout.trim(), "bin");
|
|
2714
|
+
(0, import_node_fs9.mkdirSync)(bin, { recursive: true });
|
|
2715
|
+
(0, import_node_fs9.copyFileSync)((0, import_node_path8.join)(temporary, name, executable), (0, import_node_path8.join)(bin, executable));
|
|
2716
|
+
(0, import_node_fs9.chmodSync)((0, import_node_path8.join)(bin, executable), 493);
|
|
2717
|
+
log(`golangci-lint ${version} installed from its checksum-verified prebuilt release into ${bin}`);
|
|
2718
|
+
return 0;
|
|
2719
|
+
} catch (error) {
|
|
2720
|
+
return fallback(error instanceof Error ? error.message : String(error));
|
|
2721
|
+
} finally {
|
|
2722
|
+
if (temporary !== void 0) {
|
|
2723
|
+
(0, import_node_fs9.rmSync)(temporary, { recursive: true, force: true });
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
2728
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path8.join)(workspaceRoot, "go.mod"))) {
|
|
2729
|
+
log("No Go projects - skipping.");
|
|
2730
|
+
return;
|
|
2731
|
+
}
|
|
2732
|
+
const gopath = processes.capture("go", ["env", "GOPATH"]);
|
|
2733
|
+
if (gopath.status !== 0) {
|
|
2734
|
+
log("Could not resolve GOPATH - skipping.");
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
addToPath(host, environment, (0, import_node_path8.join)(gopath.stdout.trim(), "bin"), log);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
// src/ci-pipeline/setup.use-case.ts
|
|
2741
|
+
function pythonCommand(machine) {
|
|
2742
|
+
return machine.platform === "win32" ? "python" : "python3";
|
|
2743
|
+
}
|
|
2744
|
+
function installPythonToolchain(workspaceRoot, processes, log, machine) {
|
|
2745
|
+
if (!(0, import_node_fs10.existsSync)((0, import_node_path9.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
2746
|
+
log("No Python projects - skipping.");
|
|
2747
|
+
return 0;
|
|
2748
|
+
}
|
|
2749
|
+
return processes.run(pythonCommand(machine), ["-m", "pip", "install", "-r", "requirements-dev.txt"]);
|
|
2750
|
+
}
|
|
2751
|
+
function installPythonProjects(workspaceRoot, processes, log, machine) {
|
|
2752
|
+
const editable = ["apps/*/pyproject.toml", "python-packages/*/pyproject.toml", "libs/*/pyproject.toml"].flatMap((pattern) => (0, import_node_fs10.globSync)(pattern, { cwd: workspaceRoot })).map((path) => (0, import_node_path9.dirname)(path));
|
|
2753
|
+
const requirements = (0, import_node_fs10.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot });
|
|
2754
|
+
if (editable.length === 0 && requirements.length === 0) {
|
|
2755
|
+
log("No Python projects - skipping.");
|
|
2756
|
+
return 0;
|
|
2757
|
+
}
|
|
2758
|
+
return processes.run(pythonCommand(machine), [
|
|
2759
|
+
"-m",
|
|
2760
|
+
"pip",
|
|
2761
|
+
"install",
|
|
2762
|
+
"--quiet",
|
|
2763
|
+
...editable.flatMap((directory) => ["-e", directory]),
|
|
2764
|
+
...requirements.flatMap((file) => ["-r", file])
|
|
2765
|
+
]);
|
|
2766
|
+
}
|
|
2767
|
+
async function runSetup(workspaceRoot, dependencies = {}, machine = currentMachine()) {
|
|
2768
|
+
const environment = dependencies.environment ?? process.env;
|
|
2769
|
+
const processes = dependencies.processes ?? {
|
|
2770
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2771
|
+
capture: (command, arguments_) => runCapture(command, arguments_, workspaceRoot)
|
|
2772
|
+
};
|
|
2773
|
+
const log = dependencies.log ?? ((message) => {
|
|
2774
|
+
console.log(message);
|
|
2775
|
+
});
|
|
2776
|
+
const fetchBytes = dependencies.fetchBytes ?? (async (url) => {
|
|
2777
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(6e4) });
|
|
2778
|
+
if (!response.ok) {
|
|
2779
|
+
throw new Error(`HTTP ${response.status} for ${url}`);
|
|
2780
|
+
}
|
|
2781
|
+
return Buffer.from(await response.arrayBuffer());
|
|
2782
|
+
});
|
|
2783
|
+
const host = detectCiHost(environment);
|
|
2784
|
+
const step = async (title, work) => {
|
|
2785
|
+
log(groupStart(host, title));
|
|
2786
|
+
const status = await work();
|
|
2787
|
+
const closing = groupEnd(host);
|
|
2788
|
+
if (closing !== void 0) {
|
|
2789
|
+
log(closing);
|
|
2790
|
+
}
|
|
2791
|
+
return status;
|
|
2792
|
+
};
|
|
2793
|
+
const steps = [
|
|
2794
|
+
["Install Python dependencies (ruff, pytest, build, twine)", () => installPythonToolchain(workspaceRoot, processes, log, machine)],
|
|
2795
|
+
["Install Python project dependencies (editable, workspace-wide)", () => installPythonProjects(workspaceRoot, processes, log, machine)],
|
|
2796
|
+
["Download Go module dependencies", () => downloadGoModules(workspaceRoot, processes, log)],
|
|
2797
|
+
["Install golangci-lint", () => installGolangciLint(workspaceRoot, { processes, log, fetchBytes }, machine)],
|
|
2798
|
+
["Add Go tool bin to PATH", () => {
|
|
2799
|
+
publishGoTools(workspaceRoot, host, environment, processes, log);
|
|
2800
|
+
return 0;
|
|
2801
|
+
}],
|
|
2802
|
+
["Install the Flutter SDK", () => installFlutterSdk(workspaceRoot, processes, log, machine)],
|
|
2803
|
+
["Add the Flutter SDK to PATH", () => {
|
|
2804
|
+
publishFlutterSdk(workspaceRoot, host, environment, log, machine);
|
|
2805
|
+
return 0;
|
|
2806
|
+
}],
|
|
2807
|
+
["Resolve Dart dependencies (one pub get for the whole workspace)", () => resolveDartDependencies(workspaceRoot, processes, log)]
|
|
2808
|
+
];
|
|
2809
|
+
for (const [title, work] of steps) {
|
|
2810
|
+
const status = await step(title, work);
|
|
2811
|
+
if (status !== 0) {
|
|
2812
|
+
log(`Setup stopped at: ${title}`);
|
|
2813
|
+
return status;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return 0;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2515
2819
|
// src/ci-pipeline/verify.use-case.ts
|
|
2516
2820
|
function runVerify(workspaceRoot, dependencies = {}) {
|
|
2517
2821
|
const environment = dependencies.environment ?? process.env;
|
|
@@ -2563,7 +2867,7 @@ function runVerify(workspaceRoot, dependencies = {}) {
|
|
|
2563
2867
|
}
|
|
2564
2868
|
|
|
2565
2869
|
// src/ci-pipeline/index.ts
|
|
2566
|
-
var CI_PHASES = ["verify", "pack", "release", "native"];
|
|
2870
|
+
var CI_PHASES = ["setup", "audit", "verify", "pack", "release", "native"];
|
|
2567
2871
|
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
2568
2872
|
switch (phase) {
|
|
2569
2873
|
case "verify": {
|
|
@@ -2578,11 +2882,17 @@ function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
|
2578
2882
|
case "native": {
|
|
2579
2883
|
return runNative(workspaceRoot, dependencies);
|
|
2580
2884
|
}
|
|
2885
|
+
case "setup": {
|
|
2886
|
+
return runSetup(workspaceRoot, dependencies);
|
|
2887
|
+
}
|
|
2888
|
+
case "audit": {
|
|
2889
|
+
return runAudit(workspaceRoot, dependencies);
|
|
2890
|
+
}
|
|
2581
2891
|
}
|
|
2582
2892
|
}
|
|
2583
2893
|
|
|
2584
2894
|
// src/project-scaffolding/add-project.use-case.ts
|
|
2585
|
-
var
|
|
2895
|
+
var import_node_path30 = require("path");
|
|
2586
2896
|
var import_prompts3 = require("@inquirer/prompts");
|
|
2587
2897
|
|
|
2588
2898
|
// src/project-name/project-name.validator.ts
|
|
@@ -2595,8 +2905,8 @@ function assertValidProjectName(name, label) {
|
|
|
2595
2905
|
}
|
|
2596
2906
|
|
|
2597
2907
|
// src/project-scaffolding/csharp.use-case.ts
|
|
2598
|
-
var
|
|
2599
|
-
var
|
|
2908
|
+
var import_node_fs12 = require("fs");
|
|
2909
|
+
var import_node_path11 = require("path");
|
|
2600
2910
|
|
|
2601
2911
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
2602
2912
|
function csharpExampleFiles(identity) {
|
|
@@ -2637,10 +2947,10 @@ public class GreetUseCaseTests
|
|
|
2637
2947
|
}
|
|
2638
2948
|
|
|
2639
2949
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2640
|
-
var
|
|
2641
|
-
var
|
|
2950
|
+
var import_node_fs11 = require("fs");
|
|
2951
|
+
var import_node_path10 = require("path");
|
|
2642
2952
|
function hasPlugin(workspaceRoot, packageName) {
|
|
2643
|
-
const manifest = readJson((0,
|
|
2953
|
+
const manifest = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2644
2954
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
2645
2955
|
return Object.hasOwn(installed, packageName);
|
|
2646
2956
|
}
|
|
@@ -2679,7 +2989,7 @@ function markPublic(manifestPath) {
|
|
|
2679
2989
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
2680
2990
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
2681
2991
|
writeFileEnsured(
|
|
2682
|
-
(0,
|
|
2992
|
+
(0, import_node_path10.join)(projectRoot, "README.md"),
|
|
2683
2993
|
[
|
|
2684
2994
|
`# ${projectName}`,
|
|
2685
2995
|
"",
|
|
@@ -2698,13 +3008,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
2698
3008
|
}
|
|
2699
3009
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
2700
3010
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
2701
|
-
const directory = (0,
|
|
3011
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, scaffold);
|
|
2702
3012
|
try {
|
|
2703
|
-
const holdsAProject = (0,
|
|
3013
|
+
const holdsAProject = (0, import_node_fs11.readdirSync)(directory, { withFileTypes: true }).some(
|
|
2704
3014
|
(entry) => entry.isDirectory()
|
|
2705
3015
|
);
|
|
2706
3016
|
if (holdsAProject) {
|
|
2707
|
-
(0,
|
|
3017
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(directory, ".gitkeep"), { force: true });
|
|
2708
3018
|
}
|
|
2709
3019
|
} catch {
|
|
2710
3020
|
}
|
|
@@ -2724,7 +3034,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
2724
3034
|
}
|
|
2725
3035
|
}
|
|
2726
3036
|
function defaultScope(workspaceRoot) {
|
|
2727
|
-
const { name } = readJson((0,
|
|
3037
|
+
const { name } = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2728
3038
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
2729
3039
|
return `@${base}`;
|
|
2730
3040
|
}
|
|
@@ -2752,14 +3062,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
2752
3062
|
];
|
|
2753
3063
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
2754
3064
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
2755
|
-
(0,
|
|
3065
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
2756
3066
|
}
|
|
2757
|
-
(0,
|
|
3067
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
2758
3068
|
}
|
|
2759
3069
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
2760
3070
|
try {
|
|
2761
|
-
const entry = (0,
|
|
2762
|
-
return entry ? (0,
|
|
3071
|
+
const entry = (0, import_node_fs11.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
3072
|
+
return entry ? (0, import_node_path10.join)(workspaceRoot, entry) : void 0;
|
|
2763
3073
|
} catch {
|
|
2764
3074
|
return void 0;
|
|
2765
3075
|
}
|
|
@@ -2776,8 +3086,8 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
2776
3086
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component", empty);
|
|
2777
3087
|
}
|
|
2778
3088
|
function reshapeReactAppScaffold(projectRoot) {
|
|
2779
|
-
const appDir = (0,
|
|
2780
|
-
if (!(0,
|
|
3089
|
+
const appDir = (0, import_node_path10.join)(projectRoot, "src", "app");
|
|
3090
|
+
if (!(0, import_node_fs11.existsSync)((0, import_node_path10.join)(appDir, "app.tsx"))) {
|
|
2781
3091
|
return;
|
|
2782
3092
|
}
|
|
2783
3093
|
for (const [from, to] of [
|
|
@@ -2785,60 +3095,60 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
2785
3095
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
2786
3096
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
2787
3097
|
]) {
|
|
2788
|
-
if ((0,
|
|
2789
|
-
(0,
|
|
3098
|
+
if ((0, import_node_fs11.existsSync)((0, import_node_path10.join)(appDir, from))) {
|
|
3099
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(appDir, from), (0, import_node_path10.join)(appDir, to));
|
|
2790
3100
|
}
|
|
2791
3101
|
}
|
|
2792
3102
|
const rewrite = (file, from, to) => {
|
|
2793
|
-
if ((0,
|
|
2794
|
-
writeFileEnsured(file, repointSpecifier((0,
|
|
3103
|
+
if ((0, import_node_fs11.existsSync)(file)) {
|
|
3104
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs11.readFileSync)(file, "utf8"), from, to));
|
|
2795
3105
|
}
|
|
2796
3106
|
};
|
|
2797
|
-
rewrite((0,
|
|
2798
|
-
rewrite((0,
|
|
2799
|
-
rewrite((0,
|
|
3107
|
+
rewrite((0, import_node_path10.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
3108
|
+
rewrite((0, import_node_path10.join)(appDir, "app.component.spec.tsx"), "./app", "./app.component");
|
|
3109
|
+
rewrite((0, import_node_path10.join)(projectRoot, "src", "main.tsx"), "./app/app", "./app");
|
|
2800
3110
|
writeFileEnsured(
|
|
2801
|
-
(0,
|
|
3111
|
+
(0, import_node_path10.join)(appDir, "index.ts"),
|
|
2802
3112
|
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
2803
3113
|
);
|
|
2804
3114
|
}
|
|
2805
3115
|
function emptySlice(projectRoot, sliceDir) {
|
|
2806
|
-
for (const entry of (0,
|
|
2807
|
-
(0,
|
|
3116
|
+
for (const entry of (0, import_node_fs11.readdirSync)(sliceDir)) {
|
|
3117
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(sliceDir, entry), { recursive: true, force: true });
|
|
2808
3118
|
}
|
|
2809
|
-
writeFileEnsured((0,
|
|
2810
|
-
addNxTargets((0,
|
|
3119
|
+
writeFileEnsured((0, import_node_path10.join)(sliceDir, "index.ts"), "export {}\n");
|
|
3120
|
+
addNxTargets((0, import_node_path10.join)(projectRoot, "package.json"), { test: { options: { passWithNoTests: true } } });
|
|
2811
3121
|
}
|
|
2812
3122
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
2813
|
-
const sourceDir = (0,
|
|
2814
|
-
const libDir = (0,
|
|
2815
|
-
if (!(0,
|
|
3123
|
+
const sourceDir = (0, import_node_path10.join)(projectRoot, "src");
|
|
3124
|
+
const libDir = (0, import_node_path10.join)(sourceDir, "lib");
|
|
3125
|
+
if (!(0, import_node_fs11.existsSync)((0, import_node_path10.join)(libDir, `${name}.${extension}`))) {
|
|
2816
3126
|
return;
|
|
2817
3127
|
}
|
|
2818
|
-
const sliceDir = (0,
|
|
2819
|
-
(0,
|
|
2820
|
-
for (const entry of (0,
|
|
3128
|
+
const sliceDir = (0, import_node_path10.join)(sourceDir, name);
|
|
3129
|
+
(0, import_node_fs11.mkdirSync)(sliceDir, { recursive: true });
|
|
3130
|
+
for (const entry of (0, import_node_fs11.readdirSync)(libDir)) {
|
|
2821
3131
|
if (entry === `${name}.${extension}`) {
|
|
2822
|
-
(0,
|
|
3132
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(libDir, entry), (0, import_node_path10.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
2823
3133
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
2824
|
-
const renamed = (0,
|
|
2825
|
-
(0,
|
|
2826
|
-
writeFileEnsured(renamed, repointSpecifier((0,
|
|
3134
|
+
const renamed = (0, import_node_path10.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
3135
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(libDir, entry), renamed);
|
|
3136
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs11.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
2827
3137
|
} else {
|
|
2828
|
-
(0,
|
|
3138
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(libDir, entry), (0, import_node_path10.join)(sliceDir, entry));
|
|
2829
3139
|
}
|
|
2830
3140
|
}
|
|
2831
|
-
const barrel = (0,
|
|
2832
|
-
const esm = (0,
|
|
2833
|
-
writeFileEnsured((0,
|
|
3141
|
+
const barrel = (0, import_node_path10.join)(sourceDir, "index.ts");
|
|
3142
|
+
const esm = (0, import_node_fs11.existsSync)(barrel) && (0, import_node_fs11.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
3143
|
+
writeFileEnsured((0, import_node_path10.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
2834
3144
|
`);
|
|
2835
|
-
if ((0,
|
|
3145
|
+
if ((0, import_node_fs11.existsSync)(barrel)) {
|
|
2836
3146
|
writeFileEnsured(
|
|
2837
3147
|
barrel,
|
|
2838
|
-
(0,
|
|
3148
|
+
(0, import_node_fs11.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2839
3149
|
);
|
|
2840
3150
|
}
|
|
2841
|
-
(0,
|
|
3151
|
+
(0, import_node_fs11.rmSync)(libDir, { recursive: true, force: true });
|
|
2842
3152
|
if (empty) {
|
|
2843
3153
|
emptySlice(projectRoot, sliceDir);
|
|
2844
3154
|
} else if (role === "use-case") {
|
|
@@ -2848,7 +3158,7 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
2848
3158
|
function writeWorkedExample(sliceDir, name, esm) {
|
|
2849
3159
|
const suffix = esm ? ".js" : "";
|
|
2850
3160
|
writeFileEnsured(
|
|
2851
|
-
(0,
|
|
3161
|
+
(0, import_node_path10.join)(sliceDir, `${name}.contract.ts`),
|
|
2852
3162
|
`/** What greeting someone returns. */
|
|
2853
3163
|
export interface Greeting {
|
|
2854
3164
|
readonly message: string
|
|
@@ -2856,7 +3166,7 @@ export interface Greeting {
|
|
|
2856
3166
|
`
|
|
2857
3167
|
);
|
|
2858
3168
|
writeFileEnsured(
|
|
2859
|
-
(0,
|
|
3169
|
+
(0, import_node_path10.join)(sliceDir, `${name}.use-case.ts`),
|
|
2860
3170
|
`import type { Greeting } from './${name}.contract${suffix}'
|
|
2861
3171
|
|
|
2862
3172
|
/**
|
|
@@ -2875,7 +3185,7 @@ export function greet (name: string): Greeting {
|
|
|
2875
3185
|
`
|
|
2876
3186
|
);
|
|
2877
3187
|
writeFileEnsured(
|
|
2878
|
-
(0,
|
|
3188
|
+
(0, import_node_path10.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
2879
3189
|
`import { greet } from './${name}.use-case${suffix}'
|
|
2880
3190
|
|
|
2881
3191
|
describe('greet', () => {
|
|
@@ -2886,7 +3196,7 @@ describe('greet', () => {
|
|
|
2886
3196
|
`
|
|
2887
3197
|
);
|
|
2888
3198
|
writeFileEnsured(
|
|
2889
|
-
(0,
|
|
3199
|
+
(0, import_node_path10.join)(sliceDir, "index.ts"),
|
|
2890
3200
|
`export * from './${name}.contract${suffix}'
|
|
2891
3201
|
export * from './${name}.use-case${suffix}'
|
|
2892
3202
|
`
|
|
@@ -2900,8 +3210,8 @@ function repointSpecifier(source, from, to) {
|
|
|
2900
3210
|
return result;
|
|
2901
3211
|
}
|
|
2902
3212
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2903
|
-
const manifestPath = (0,
|
|
2904
|
-
if (!(0,
|
|
3213
|
+
const manifestPath = (0, import_node_path10.join)(workspaceRoot, "package.json");
|
|
3214
|
+
if (!(0, import_node_fs11.existsSync)(manifestPath)) {
|
|
2905
3215
|
return;
|
|
2906
3216
|
}
|
|
2907
3217
|
const manifest = readJson(manifestPath);
|
|
@@ -2924,11 +3234,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2924
3234
|
if (commands.start) {
|
|
2925
3235
|
scripts[`${name}:start`] = commands.start;
|
|
2926
3236
|
}
|
|
2927
|
-
const dependabotPath = (0,
|
|
2928
|
-
if ((0,
|
|
3237
|
+
const dependabotPath = (0, import_node_path10.join)(workspaceRoot, ".github/dependabot.yml");
|
|
3238
|
+
if ((0, import_node_fs11.existsSync)(dependabotPath)) {
|
|
2929
3239
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
2930
3240
|
}
|
|
2931
|
-
const manifestPath = (0,
|
|
3241
|
+
const manifestPath = (0, import_node_path10.join)(workspaceRoot, "package.json");
|
|
2932
3242
|
const manifest = readJson(manifestPath);
|
|
2933
3243
|
const existingScripts = manifest.scripts ?? {};
|
|
2934
3244
|
writeFileEnsured(
|
|
@@ -2966,7 +3276,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2966
3276
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
2967
3277
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
2968
3278
|
try {
|
|
2969
|
-
return readJson((0,
|
|
3279
|
+
return readJson((0, import_node_path10.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
2970
3280
|
} catch {
|
|
2971
3281
|
return {};
|
|
2972
3282
|
}
|
|
@@ -2978,7 +3288,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2978
3288
|
return;
|
|
2979
3289
|
}
|
|
2980
3290
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
2981
|
-
(root) => (0,
|
|
3291
|
+
(root) => (0, import_node_path10.join)(workspaceRoot, root, projectName, "package.json")
|
|
2982
3292
|
).find((candidate) => fileExists(candidate));
|
|
2983
3293
|
if (manifestPath === void 0) {
|
|
2984
3294
|
return;
|
|
@@ -2990,10 +3300,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2990
3300
|
const remaining = Object.fromEntries(
|
|
2991
3301
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
2992
3302
|
);
|
|
2993
|
-
const rootManifest = readJson((0,
|
|
3303
|
+
const rootManifest = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2994
3304
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
2995
3305
|
writeFileEnsured(
|
|
2996
|
-
(0,
|
|
3306
|
+
(0, import_node_path10.join)(workspaceRoot, "package.json"),
|
|
2997
3307
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
2998
3308
|
);
|
|
2999
3309
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -3032,28 +3342,28 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
3032
3342
|
}
|
|
3033
3343
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
3034
3344
|
if (kind === "classlib") {
|
|
3035
|
-
(0,
|
|
3345
|
+
(0, import_node_fs12.rmSync)((0, import_node_path11.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
3036
3346
|
}
|
|
3037
3347
|
const files = csharpExampleFiles(identity);
|
|
3038
3348
|
for (const [file, contents] of Object.entries(files)) {
|
|
3039
|
-
writeFileEnsured((0,
|
|
3349
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, file), contents);
|
|
3040
3350
|
}
|
|
3041
3351
|
if (kind === "console") {
|
|
3042
|
-
writeFileEnsured((0,
|
|
3352
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
3043
3353
|
}
|
|
3044
3354
|
}
|
|
3045
3355
|
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
3046
|
-
const name = (0,
|
|
3356
|
+
const name = (0, import_node_path11.basename)(projectRoot);
|
|
3047
3357
|
const testRoot = `tests/${name}`;
|
|
3048
3358
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
3049
|
-
(0,
|
|
3050
|
-
writeFileEnsured((0,
|
|
3359
|
+
(0, import_node_fs12.rmSync)((0, import_node_path11.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
3360
|
+
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
3051
3361
|
writeFileEnsured(
|
|
3052
|
-
(0,
|
|
3362
|
+
(0, import_node_path11.join)(workspaceRoot, testRoot, "project.json"),
|
|
3053
3363
|
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
3054
3364
|
);
|
|
3055
|
-
const reference = (0,
|
|
3056
|
-
if (runShell("dotnet", ["add", (0,
|
|
3365
|
+
const reference = (0, import_node_path11.join)(workspaceRoot, projectRoot, `${identity}.csproj`);
|
|
3366
|
+
if (runShell("dotnet", ["add", (0, import_node_path11.join)(workspaceRoot, testRoot), "reference", reference], workspaceRoot) !== 0) {
|
|
3057
3367
|
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
3058
3368
|
}
|
|
3059
3369
|
}
|
|
@@ -3080,9 +3390,9 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
3080
3390
|
ensureAdmZip(workspaceRoot);
|
|
3081
3391
|
const projectRoot = `apps/${name}`;
|
|
3082
3392
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
3083
|
-
writeCsharpExample((0,
|
|
3393
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3084
3394
|
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
3085
|
-
addProjectJsonTargets((0,
|
|
3395
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3086
3396
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
3087
3397
|
start: csharpAppStartTarget(projectRoot)
|
|
3088
3398
|
});
|
|
@@ -3175,7 +3485,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
3175
3485
|
module.exports = CsharpVersionActions
|
|
3176
3486
|
`;
|
|
3177
3487
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
3178
|
-
writeFileEnsured((0,
|
|
3488
|
+
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
3179
3489
|
}
|
|
3180
3490
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
3181
3491
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -3190,7 +3500,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3190
3500
|
);
|
|
3191
3501
|
}
|
|
3192
3502
|
function addInitialVersion(csprojPath) {
|
|
3193
|
-
const contents = (0,
|
|
3503
|
+
const contents = (0, import_node_fs12.readFileSync)(csprojPath, "utf8");
|
|
3194
3504
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3195
3505
|
}
|
|
3196
3506
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3205,16 +3515,16 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3205
3515
|
const projectRoot = `packages/${name}`;
|
|
3206
3516
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3207
3517
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3208
|
-
writeCsharpExample((0,
|
|
3518
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3209
3519
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3210
|
-
addInitialVersion((0,
|
|
3520
|
+
addInitialVersion((0, import_node_path11.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3211
3521
|
writeCsharpVersionActions(workspaceRoot);
|
|
3212
|
-
addProjectJsonReleaseVersionActions((0,
|
|
3213
|
-
addProjectJsonTargets((0,
|
|
3522
|
+
addProjectJsonReleaseVersionActions((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"));
|
|
3523
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3214
3524
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
3215
3525
|
});
|
|
3216
3526
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
3217
|
-
writeFileEnsured((0,
|
|
3527
|
+
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
3218
3528
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
3219
3529
|
}
|
|
3220
3530
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -3223,7 +3533,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3223
3533
|
const projectRoot = `libs/${name}`;
|
|
3224
3534
|
const identity = pascalCase(name);
|
|
3225
3535
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3226
|
-
writeCsharpExample((0,
|
|
3536
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3227
3537
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3228
3538
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3229
3539
|
logger.step(
|
|
@@ -3292,20 +3602,20 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3292
3602
|
const projectRoot = `apps/${name}`;
|
|
3293
3603
|
const identity = pascalCase(name);
|
|
3294
3604
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
3295
|
-
const absoluteRoot = (0,
|
|
3296
|
-
writeFileEnsured((0,
|
|
3297
|
-
writeFileEnsured((0,
|
|
3298
|
-
writeFileEnsured((0,
|
|
3605
|
+
const absoluteRoot = (0, import_node_path11.join)(workspaceRoot, projectRoot);
|
|
3606
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
3607
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
3608
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3299
3609
|
const example = csharpExampleFiles(identity);
|
|
3300
3610
|
for (const [file, contents] of Object.entries(example)) {
|
|
3301
|
-
writeFileEnsured((0,
|
|
3611
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, file), contents);
|
|
3302
3612
|
}
|
|
3303
|
-
writeFileEnsured((0,
|
|
3613
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3304
3614
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3305
3615
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3306
3616
|
}
|
|
3307
3617
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3308
|
-
addProjectJsonTargets((0,
|
|
3618
|
+
addProjectJsonTargets((0, import_node_path11.join)(absoluteRoot, "project.json"), {
|
|
3309
3619
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3310
3620
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
3311
3621
|
});
|
|
@@ -3313,7 +3623,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3313
3623
|
}
|
|
3314
3624
|
|
|
3315
3625
|
// src/project-scaffolding/flutter.use-case.ts
|
|
3316
|
-
var
|
|
3626
|
+
var import_node_path12 = require("path");
|
|
3317
3627
|
function flutterAppStartTarget(name) {
|
|
3318
3628
|
return {
|
|
3319
3629
|
executor: "nx:run-commands",
|
|
@@ -3349,7 +3659,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
3349
3659
|
prepareFlutter(workspaceRoot);
|
|
3350
3660
|
ensureAdmZip(workspaceRoot);
|
|
3351
3661
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
3352
|
-
addProjectJsonTargets((0,
|
|
3662
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3353
3663
|
start: flutterAppStartTarget(name)
|
|
3354
3664
|
});
|
|
3355
3665
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -3366,8 +3676,8 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3366
3676
|
}
|
|
3367
3677
|
|
|
3368
3678
|
// src/project-scaffolding/go.use-case.ts
|
|
3369
|
-
var
|
|
3370
|
-
var
|
|
3679
|
+
var import_node_fs16 = require("fs");
|
|
3680
|
+
var import_node_path16 = require("path");
|
|
3371
3681
|
|
|
3372
3682
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
3373
3683
|
function greetingContract(packageName) {
|
|
@@ -3436,14 +3746,14 @@ function goAppExampleFiles(modulePath) {
|
|
|
3436
3746
|
}
|
|
3437
3747
|
|
|
3438
3748
|
// src/go-workspace/go-plugin.use-case.ts
|
|
3439
|
-
var
|
|
3440
|
-
var
|
|
3749
|
+
var import_node_fs13 = require("fs");
|
|
3750
|
+
var import_node_path13 = require("path");
|
|
3441
3751
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
3442
3752
|
function hasGoProject(workspaceRoot) {
|
|
3443
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0,
|
|
3753
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs13.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
3444
3754
|
return projectFiles.some((projectFile) => {
|
|
3445
3755
|
try {
|
|
3446
|
-
const { tags } = JSON.parse((0,
|
|
3756
|
+
const { tags } = JSON.parse((0, import_node_fs13.readFileSync)((0, import_node_path13.join)(workspaceRoot, projectFile), "utf8"));
|
|
3447
3757
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
3448
3758
|
} catch {
|
|
3449
3759
|
return false;
|
|
@@ -3451,7 +3761,7 @@ function hasGoProject(workspaceRoot) {
|
|
|
3451
3761
|
});
|
|
3452
3762
|
}
|
|
3453
3763
|
function isNxGoPluginRegistered(workspaceRoot) {
|
|
3454
|
-
const nxJsonPath = (0,
|
|
3764
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3455
3765
|
if (!fileExists(nxJsonPath)) {
|
|
3456
3766
|
return false;
|
|
3457
3767
|
}
|
|
@@ -3478,7 +3788,7 @@ function goModulePrefix(workspaceRoot) {
|
|
|
3478
3788
|
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
3479
3789
|
}
|
|
3480
3790
|
function registerNxGoPlugin(workspaceRoot) {
|
|
3481
|
-
const nxJsonPath = (0,
|
|
3791
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3482
3792
|
if (!fileExists(nxJsonPath)) {
|
|
3483
3793
|
return false;
|
|
3484
3794
|
}
|
|
@@ -3502,8 +3812,8 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3502
3812
|
}
|
|
3503
3813
|
|
|
3504
3814
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3505
|
-
var
|
|
3506
|
-
var
|
|
3815
|
+
var import_node_fs14 = require("fs");
|
|
3816
|
+
var import_node_path14 = require("path");
|
|
3507
3817
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3508
3818
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3509
3819
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -3629,7 +3939,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
3629
3939
|
}
|
|
3630
3940
|
};
|
|
3631
3941
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
3632
|
-
const projectJsonPath = (0,
|
|
3942
|
+
const projectJsonPath = (0, import_node_path14.join)(workspaceRoot, "apps", name, "project.json");
|
|
3633
3943
|
if (!fileExists(projectJsonPath)) {
|
|
3634
3944
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
3635
3945
|
}
|
|
@@ -3650,22 +3960,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
3650
3960
|
}
|
|
3651
3961
|
})
|
|
3652
3962
|
);
|
|
3653
|
-
writeFileEnsured((0,
|
|
3963
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
3654
3964
|
}
|
|
3655
3965
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
3656
|
-
const apps = (0,
|
|
3966
|
+
const apps = (0, import_node_path14.join)(workspaceRoot, "apps");
|
|
3657
3967
|
let entries;
|
|
3658
3968
|
try {
|
|
3659
|
-
entries = (0,
|
|
3969
|
+
entries = (0, import_node_fs14.readdirSync)(apps);
|
|
3660
3970
|
} catch {
|
|
3661
3971
|
return false;
|
|
3662
3972
|
}
|
|
3663
3973
|
const hasReleasableApp = entries.some((entry) => {
|
|
3664
|
-
const projectJsonPath = (0,
|
|
3974
|
+
const projectJsonPath = (0, import_node_path14.join)(apps, entry, "project.json");
|
|
3665
3975
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3666
3976
|
});
|
|
3667
|
-
const path = (0,
|
|
3668
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
3977
|
+
const path = (0, import_node_path14.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3978
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs14.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
3669
3979
|
return false;
|
|
3670
3980
|
}
|
|
3671
3981
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3673,8 +3983,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3673
3983
|
}
|
|
3674
3984
|
|
|
3675
3985
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3676
|
-
var
|
|
3677
|
-
var
|
|
3986
|
+
var import_node_fs15 = require("fs");
|
|
3987
|
+
var import_node_path15 = require("path");
|
|
3678
3988
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3679
3989
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
3680
3990
|
var GO_WEB_SOURCE = `package main
|
|
@@ -3752,18 +4062,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
3752
4062
|
}
|
|
3753
4063
|
`;
|
|
3754
4064
|
function assertWebApp(workspaceRoot, web) {
|
|
3755
|
-
const directory = (0,
|
|
3756
|
-
const isReactApp = fileExists((0,
|
|
4065
|
+
const directory = (0, import_node_path15.join)(workspaceRoot, "apps", web);
|
|
4066
|
+
const isReactApp = fileExists((0, import_node_path15.join)(directory, "package.json")) && (0, import_node_fs15.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
3757
4067
|
if (!isReactApp) {
|
|
3758
4068
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
3759
4069
|
}
|
|
3760
4070
|
}
|
|
3761
4071
|
function webProjectName(workspaceRoot, web) {
|
|
3762
|
-
const manifest = readJson((0,
|
|
4072
|
+
const manifest = readJson((0, import_node_path15.join)(workspaceRoot, "apps", web, "package.json"));
|
|
3763
4073
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
3764
4074
|
}
|
|
3765
4075
|
function addApiProxy(viteConfigPath) {
|
|
3766
|
-
const source = (0,
|
|
4076
|
+
const source = (0, import_node_fs15.readFileSync)(viteConfigPath, "utf8");
|
|
3767
4077
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
3768
4078
|
return false;
|
|
3769
4079
|
}
|
|
@@ -3776,7 +4086,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
3776
4086
|
return true;
|
|
3777
4087
|
}
|
|
3778
4088
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
3779
|
-
const projectJsonPath = (0,
|
|
4089
|
+
const projectJsonPath = (0, import_node_path15.join)(workspaceRoot, "apps", name, "project.json");
|
|
3780
4090
|
const project = readJson(projectJsonPath);
|
|
3781
4091
|
const webName = webProjectName(workspaceRoot, web);
|
|
3782
4092
|
const targets = project.targets ?? {};
|
|
@@ -3802,13 +4112,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
3802
4112
|
projectJsonPath,
|
|
3803
4113
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
3804
4114
|
);
|
|
3805
|
-
const directory = (0,
|
|
3806
|
-
writeFileEnsured((0,
|
|
3807
|
-
writeFileEnsured((0,
|
|
3808
|
-
writeFileEnsured((0,
|
|
3809
|
-
writeFileEnsured((0,
|
|
3810
|
-
const viteConfig = (0,
|
|
3811
|
-
if (viteConfig === void 0 || !addApiProxy((0,
|
|
4115
|
+
const directory = (0, import_node_path15.join)(workspaceRoot, "apps", name);
|
|
4116
|
+
writeFileEnsured((0, import_node_path15.join)(directory, ".gitignore"), "/web/\n");
|
|
4117
|
+
writeFileEnsured((0, import_node_path15.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
4118
|
+
writeFileEnsured((0, import_node_path15.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
4119
|
+
writeFileEnsured((0, import_node_path15.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
4120
|
+
const viteConfig = (0, import_node_fs15.readdirSync)((0, import_node_path15.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
4121
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path15.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
3812
4122
|
logger.warn(
|
|
3813
4123
|
`Could not add the /api proxy to apps/${web}'s Vite config: add \`server: { proxy: { '/api': 'http://${DEFAULT_ADDRESS}' } }\` yourself, so \`nx run ${name}:dev\` reaches the Go server.`
|
|
3814
4124
|
);
|
|
@@ -3842,7 +4152,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
3842
4152
|
}
|
|
3843
4153
|
}
|
|
3844
4154
|
function ensureGoModule(workspaceRoot) {
|
|
3845
|
-
if (fileExists((0,
|
|
4155
|
+
if (fileExists((0, import_node_path16.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path16.join)(workspaceRoot, "go.mod"))) {
|
|
3846
4156
|
return;
|
|
3847
4157
|
}
|
|
3848
4158
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -3850,38 +4160,38 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3850
4160
|
}
|
|
3851
4161
|
function readGoModModule(goModPath) {
|
|
3852
4162
|
try {
|
|
3853
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
4163
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs16.readFileSync)(goModPath, "utf8"))?.[1];
|
|
3854
4164
|
} catch {
|
|
3855
4165
|
return void 0;
|
|
3856
4166
|
}
|
|
3857
4167
|
}
|
|
3858
4168
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
3859
|
-
const projectModule = readGoModModule((0,
|
|
4169
|
+
const projectModule = readGoModModule((0, import_node_path16.join)(workspaceRoot, projectDir, "go.mod"));
|
|
3860
4170
|
if (projectModule !== void 0) {
|
|
3861
4171
|
return projectModule;
|
|
3862
4172
|
}
|
|
3863
|
-
const rootModule = readGoModModule((0,
|
|
4173
|
+
const rootModule = readGoModModule((0, import_node_path16.join)(workspaceRoot, "go.mod"));
|
|
3864
4174
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
3865
4175
|
}
|
|
3866
4176
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
3867
4177
|
const prefix = goModulePrefix(workspaceRoot);
|
|
3868
|
-
const goModPath = (0,
|
|
4178
|
+
const goModPath = (0, import_node_path16.join)(workspaceRoot, projectDir, "go.mod");
|
|
3869
4179
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
3870
4180
|
return;
|
|
3871
4181
|
}
|
|
3872
|
-
const rewritten = (0,
|
|
4182
|
+
const rewritten = (0, import_node_fs16.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
3873
4183
|
writeFileEnsured(goModPath, rewritten);
|
|
3874
4184
|
}
|
|
3875
4185
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
3876
|
-
const goModPath = (0,
|
|
3877
|
-
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0,
|
|
4186
|
+
const goModPath = (0, import_node_path16.join)(workspaceRoot, projectDir, "go.mod");
|
|
4187
|
+
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs16.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
3878
4188
|
if (modulePath === void 0) {
|
|
3879
4189
|
return;
|
|
3880
4190
|
}
|
|
3881
|
-
(0,
|
|
4191
|
+
(0, import_node_fs16.rmSync)((0, import_node_path16.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
3882
4192
|
const example = goAppExampleFiles(modulePath);
|
|
3883
4193
|
for (const [relative, contents] of Object.entries(example)) {
|
|
3884
|
-
writeFileEnsured((0,
|
|
4194
|
+
writeFileEnsured((0, import_node_path16.join)(workspaceRoot, projectDir, relative), contents);
|
|
3885
4195
|
}
|
|
3886
4196
|
}
|
|
3887
4197
|
function goTestTarget() {
|
|
@@ -3959,16 +4269,16 @@ function goNativePackageTarget(name) {
|
|
|
3959
4269
|
}
|
|
3960
4270
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3961
4271
|
const changed = [];
|
|
3962
|
-
const apps = (0,
|
|
4272
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
3963
4273
|
if (!fileExists(apps)) {
|
|
3964
4274
|
return changed;
|
|
3965
4275
|
}
|
|
3966
|
-
for (const name of (0,
|
|
3967
|
-
const projectJsonPath = (0,
|
|
4276
|
+
for (const name of (0, import_node_fs16.readdirSync)(apps)) {
|
|
4277
|
+
const projectJsonPath = (0, import_node_path16.join)(apps, name, "project.json");
|
|
3968
4278
|
if (!fileExists(projectJsonPath)) {
|
|
3969
4279
|
continue;
|
|
3970
4280
|
}
|
|
3971
|
-
const project = JSON.parse((0,
|
|
4281
|
+
const project = JSON.parse((0, import_node_fs16.readFileSync)(projectJsonPath, "utf8"));
|
|
3972
4282
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3973
4283
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3974
4284
|
continue;
|
|
@@ -4004,8 +4314,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
4004
4314
|
}
|
|
4005
4315
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
4006
4316
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
4007
|
-
(0,
|
|
4008
|
-
(0,
|
|
4317
|
+
(0, import_node_fs16.rmSync)((0, import_node_path16.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
4318
|
+
(0, import_node_fs16.rmSync)((0, import_node_path16.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
4009
4319
|
const files = [
|
|
4010
4320
|
[
|
|
4011
4321
|
"doc.go",
|
|
@@ -4015,7 +4325,7 @@ package ${packageName}
|
|
|
4015
4325
|
`
|
|
4016
4326
|
],
|
|
4017
4327
|
[
|
|
4018
|
-
(0,
|
|
4328
|
+
(0, import_node_path16.join)(packageName, "doc.go"),
|
|
4019
4329
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
4020
4330
|
// the outcome it delivers, and add one package per further outcome.
|
|
4021
4331
|
package ${packageName}
|
|
@@ -4023,11 +4333,11 @@ package ${packageName}
|
|
|
4023
4333
|
],
|
|
4024
4334
|
// The starter slice: a contract, a use case and its test (see goLibraryExampleFiles).
|
|
4025
4335
|
...Object.entries(goLibraryExampleFiles(packageName, fileStem)).map(
|
|
4026
|
-
([name, content]) => [(0,
|
|
4336
|
+
([name, content]) => [(0, import_node_path16.join)(packageName, name), content]
|
|
4027
4337
|
)
|
|
4028
4338
|
];
|
|
4029
4339
|
for (const [relativePath, content] of files) {
|
|
4030
|
-
const path = (0,
|
|
4340
|
+
const path = (0, import_node_path16.join)(projectRoot, relativePath);
|
|
4031
4341
|
if (!fileExists(path)) {
|
|
4032
4342
|
writeFileEnsured(path, content);
|
|
4033
4343
|
}
|
|
@@ -4065,7 +4375,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4065
4375
|
if (options.web === void 0) {
|
|
4066
4376
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4067
4377
|
}
|
|
4068
|
-
addProjectJsonTargets((0,
|
|
4378
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4069
4379
|
build: goBuildTarget(name),
|
|
4070
4380
|
test: goTestTarget(),
|
|
4071
4381
|
lint: goLintTarget(),
|
|
@@ -4105,7 +4415,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4105
4415
|
);
|
|
4106
4416
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4107
4417
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4108
|
-
addProjectJsonTargets((0,
|
|
4418
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4109
4419
|
"build": goBuildTarget(name),
|
|
4110
4420
|
"test": goTestTarget(),
|
|
4111
4421
|
"lint": goLintTarget(),
|
|
@@ -4129,11 +4439,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4129
4439
|
workspaceRoot
|
|
4130
4440
|
);
|
|
4131
4441
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4132
|
-
addProjectJsonTargets((0,
|
|
4442
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4133
4443
|
test: goTestTarget(),
|
|
4134
4444
|
lint: goLintTarget()
|
|
4135
4445
|
});
|
|
4136
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4446
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path16.join)(workspaceRoot, "packages", name), name);
|
|
4137
4447
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4138
4448
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
4139
4449
|
if (module2) {
|
|
@@ -4154,11 +4464,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4154
4464
|
workspaceRoot
|
|
4155
4465
|
);
|
|
4156
4466
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4157
|
-
addProjectJsonTargets((0,
|
|
4467
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4158
4468
|
test: goTestTarget(),
|
|
4159
4469
|
lint: goLintTarget()
|
|
4160
4470
|
});
|
|
4161
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4471
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path16.join)(workspaceRoot, "libs", name), name);
|
|
4162
4472
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4163
4473
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
4164
4474
|
if (module2) {
|
|
@@ -4167,7 +4477,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4167
4477
|
}
|
|
4168
4478
|
|
|
4169
4479
|
// src/project-scaffolding/node.use-case.ts
|
|
4170
|
-
var
|
|
4480
|
+
var import_node_path17 = require("path");
|
|
4171
4481
|
|
|
4172
4482
|
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
4173
4483
|
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
@@ -4290,12 +4600,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
4290
4600
|
],
|
|
4291
4601
|
workspaceRoot
|
|
4292
4602
|
);
|
|
4293
|
-
const appRoot = (0,
|
|
4603
|
+
const appRoot = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4294
4604
|
separateDeclarationOutput(appRoot);
|
|
4295
4605
|
repairAssetMapping(appRoot, name);
|
|
4296
4606
|
}
|
|
4297
4607
|
function separateDeclarationOutput(appRoot) {
|
|
4298
|
-
const tsconfigPath = (0,
|
|
4608
|
+
const tsconfigPath = (0, import_node_path17.join)(appRoot, "tsconfig.app.json");
|
|
4299
4609
|
if (!fileExists(tsconfigPath)) {
|
|
4300
4610
|
return;
|
|
4301
4611
|
}
|
|
@@ -4317,7 +4627,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
4317
4627
|
);
|
|
4318
4628
|
}
|
|
4319
4629
|
function repairAssetMapping(appRoot, name) {
|
|
4320
|
-
const manifestPath = (0,
|
|
4630
|
+
const manifestPath = (0, import_node_path17.join)(appRoot, "package.json");
|
|
4321
4631
|
if (!fileExists(manifestPath)) {
|
|
4322
4632
|
return;
|
|
4323
4633
|
}
|
|
@@ -4346,11 +4656,11 @@ function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
|
4346
4656
|
const example = nodeAppExampleFiles(framework);
|
|
4347
4657
|
if (example !== null) {
|
|
4348
4658
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4349
|
-
writeFileEnsured((0,
|
|
4659
|
+
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
4350
4660
|
}
|
|
4351
4661
|
}
|
|
4352
4662
|
ensureAdmZip(workspaceRoot);
|
|
4353
|
-
addNxTargets((0,
|
|
4663
|
+
addNxTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
4354
4664
|
package: nodeAppPackageTarget(name)
|
|
4355
4665
|
});
|
|
4356
4666
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -4419,10 +4729,10 @@ describe('greet', () => {
|
|
|
4419
4729
|
})
|
|
4420
4730
|
`;
|
|
4421
4731
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
4422
|
-
const manifestPath = (0,
|
|
4732
|
+
const manifestPath = (0, import_node_path17.join)(nodeFunctionAppRoot, "package.json");
|
|
4423
4733
|
const manifest = readJson(manifestPath);
|
|
4424
4734
|
const azureFunctionsVersion = readJson(
|
|
4425
|
-
(0,
|
|
4735
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
4426
4736
|
).version;
|
|
4427
4737
|
const dependencies = manifest.dependencies ?? {};
|
|
4428
4738
|
writeFileEnsured(
|
|
@@ -4465,20 +4775,20 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
4465
4775
|
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
4466
4776
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4467
4777
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4468
|
-
const nodeFunctionAppRoot = (0,
|
|
4469
|
-
writeFileEnsured((0,
|
|
4778
|
+
const nodeFunctionAppRoot = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4779
|
+
writeFileEnsured((0, import_node_path17.join)(nodeFunctionAppRoot, "src/main.ts"), empty ? NODE_FUNCTION_APP_MAIN_EMPTY : NODE_FUNCTION_APP_MAIN);
|
|
4470
4780
|
if (!empty) {
|
|
4471
|
-
const slice = (0,
|
|
4472
|
-
writeFileEnsured((0,
|
|
4473
|
-
writeFileEnsured((0,
|
|
4474
|
-
writeFileEnsured((0,
|
|
4475
|
-
writeFileEnsured((0,
|
|
4476
|
-
writeFileEnsured((0,
|
|
4477
|
-
}
|
|
4478
|
-
writeFileEnsured((0,
|
|
4781
|
+
const slice = (0, import_node_path17.join)(nodeFunctionAppRoot, "src/hello");
|
|
4782
|
+
writeFileEnsured((0, import_node_path17.join)(slice, "hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
4783
|
+
writeFileEnsured((0, import_node_path17.join)(slice, "greet.use-case.ts"), NODE_FUNCTION_APP_GREET_USE_CASE);
|
|
4784
|
+
writeFileEnsured((0, import_node_path17.join)(slice, "greet.use-case.spec.ts"), NODE_FUNCTION_APP_GREET_SPEC);
|
|
4785
|
+
writeFileEnsured((0, import_node_path17.join)(slice, "greeting.contract.ts"), NODE_FUNCTION_APP_GREETING_CONTRACT);
|
|
4786
|
+
writeFileEnsured((0, import_node_path17.join)(slice, "index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
4787
|
+
}
|
|
4788
|
+
writeFileEnsured((0, import_node_path17.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
4479
4789
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4480
4790
|
ensureAdmZip(workspaceRoot);
|
|
4481
|
-
addNxTargets((0,
|
|
4791
|
+
addNxTargets((0, import_node_path17.join)(nodeFunctionAppRoot, "package.json"), {
|
|
4482
4792
|
package: nodeFunctionAppPackageTarget(name),
|
|
4483
4793
|
prune: nodeFunctionAppPruneTarget(name),
|
|
4484
4794
|
start: nodeFunctionAppStartTarget(name),
|
|
@@ -4490,11 +4800,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
|
4490
4800
|
}
|
|
4491
4801
|
|
|
4492
4802
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4493
|
-
var
|
|
4803
|
+
var import_node_path21 = require("path");
|
|
4494
4804
|
|
|
4495
4805
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
4496
|
-
var
|
|
4497
|
-
var
|
|
4806
|
+
var import_node_fs17 = require("fs");
|
|
4807
|
+
var import_node_path18 = require("path");
|
|
4498
4808
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
4499
4809
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
4500
4810
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -4517,14 +4827,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
4517
4827
|
}
|
|
4518
4828
|
function repairPublishableManifests(workspaceRoot) {
|
|
4519
4829
|
const changed = [];
|
|
4520
|
-
const manifests = (0,
|
|
4830
|
+
const manifests = (0, import_node_fs17.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
4521
4831
|
cwd: workspaceRoot
|
|
4522
4832
|
});
|
|
4523
4833
|
for (const relativePath of manifests) {
|
|
4524
|
-
const manifestPath = (0,
|
|
4525
|
-
const before = (0,
|
|
4834
|
+
const manifestPath = (0, import_node_path18.join)(workspaceRoot, relativePath);
|
|
4835
|
+
const before = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
4526
4836
|
repairPublishableManifest(manifestPath);
|
|
4527
|
-
const after = (0,
|
|
4837
|
+
const after = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
4528
4838
|
if (after !== before) {
|
|
4529
4839
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
4530
4840
|
}
|
|
@@ -4533,8 +4843,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
4533
4843
|
}
|
|
4534
4844
|
|
|
4535
4845
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4536
|
-
var
|
|
4537
|
-
var
|
|
4846
|
+
var import_node_fs18 = require("fs");
|
|
4847
|
+
var import_node_path19 = require("path");
|
|
4538
4848
|
|
|
4539
4849
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
4540
4850
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -4736,12 +5046,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
4736
5046
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4737
5047
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
4738
5048
|
const changed = [];
|
|
4739
|
-
const configs = (0,
|
|
5049
|
+
const configs = (0, import_node_fs18.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4740
5050
|
cwd: workspaceRoot
|
|
4741
5051
|
});
|
|
4742
5052
|
for (const relativePath of configs) {
|
|
4743
|
-
const configPath = (0,
|
|
4744
|
-
const before = (0,
|
|
5053
|
+
const configPath = (0, import_node_path19.join)(workspaceRoot, relativePath);
|
|
5054
|
+
const before = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4745
5055
|
const after = withRollupSourceMaps(before);
|
|
4746
5056
|
if (after !== before) {
|
|
4747
5057
|
writeFileEnsured(configPath, after);
|
|
@@ -4752,12 +5062,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
4752
5062
|
}
|
|
4753
5063
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
4754
5064
|
const changed = [];
|
|
4755
|
-
const configs = (0,
|
|
5065
|
+
const configs = (0, import_node_fs18.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4756
5066
|
cwd: workspaceRoot
|
|
4757
5067
|
});
|
|
4758
5068
|
for (const relativePath of configs) {
|
|
4759
|
-
const configPath = (0,
|
|
4760
|
-
const before = (0,
|
|
5069
|
+
const configPath = (0, import_node_path19.join)(workspaceRoot, relativePath);
|
|
5070
|
+
const before = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4761
5071
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
4762
5072
|
if (after !== before) {
|
|
4763
5073
|
writeFileEnsured(configPath, after);
|
|
@@ -4767,11 +5077,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
4767
5077
|
return changed;
|
|
4768
5078
|
}
|
|
4769
5079
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
4770
|
-
const configPath = (0,
|
|
5080
|
+
const configPath = (0, import_node_path19.join)(projectRoot, "rollup.config.cjs");
|
|
4771
5081
|
if (!fileExists(configPath)) {
|
|
4772
5082
|
return;
|
|
4773
5083
|
}
|
|
4774
|
-
const config = (0,
|
|
5084
|
+
const config = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4775
5085
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
4776
5086
|
return;
|
|
4777
5087
|
}
|
|
@@ -4780,10 +5090,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
4780
5090
|
}
|
|
4781
5091
|
|
|
4782
5092
|
// src/rollup-library/rollup-config.repository.ts
|
|
4783
|
-
var
|
|
4784
|
-
var
|
|
5093
|
+
var import_node_fs19 = require("fs");
|
|
5094
|
+
var import_node_path20 = require("path");
|
|
4785
5095
|
function resolveRequireTarget(fromDir, specifier) {
|
|
4786
|
-
const base = (0,
|
|
5096
|
+
const base = (0, import_node_path20.join)(fromDir, specifier);
|
|
4787
5097
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
4788
5098
|
}
|
|
4789
5099
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -4793,7 +5103,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4793
5103
|
visited.add(configPath);
|
|
4794
5104
|
let text;
|
|
4795
5105
|
try {
|
|
4796
|
-
text = (0,
|
|
5106
|
+
text = (0, import_node_fs19.readFileSync)(configPath, "utf8");
|
|
4797
5107
|
} catch {
|
|
4798
5108
|
return "";
|
|
4799
5109
|
}
|
|
@@ -4801,15 +5111,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4801
5111
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
4802
5112
|
(match) => match[2]
|
|
4803
5113
|
);
|
|
4804
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
5114
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path20.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
4805
5115
|
return [text, ...requiredText].join("\n");
|
|
4806
5116
|
}
|
|
4807
5117
|
|
|
4808
5118
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4809
5119
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4810
5120
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4811
|
-
const projectRoot = (0,
|
|
4812
|
-
const manifestPath = (0,
|
|
5121
|
+
const projectRoot = (0, import_node_path21.join)(workspaceRoot, "packages", name);
|
|
5122
|
+
const manifestPath = (0, import_node_path21.join)(projectRoot, "package.json");
|
|
4813
5123
|
runGeneratorAndRepair(
|
|
4814
5124
|
workspaceRoot,
|
|
4815
5125
|
[
|
|
@@ -4838,8 +5148,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4838
5148
|
}
|
|
4839
5149
|
|
|
4840
5150
|
// src/project-scaffolding/python.use-case.ts
|
|
4841
|
-
var
|
|
4842
|
-
var
|
|
5151
|
+
var import_node_fs20 = require("fs");
|
|
5152
|
+
var import_node_path22 = require("path");
|
|
4843
5153
|
function ensurePython(workspaceRoot) {
|
|
4844
5154
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
4845
5155
|
if (!hasPython) {
|
|
@@ -4862,7 +5172,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
4862
5172
|
registerPythonGraphPlugin(workspaceRoot);
|
|
4863
5173
|
}
|
|
4864
5174
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
4865
|
-
const nxJsonPath = (0,
|
|
5175
|
+
const nxJsonPath = (0, import_node_path22.join)(workspaceRoot, "nx.json");
|
|
4866
5176
|
if (!fileExists(nxJsonPath)) {
|
|
4867
5177
|
return;
|
|
4868
5178
|
}
|
|
@@ -4885,7 +5195,7 @@ pytest
|
|
|
4885
5195
|
pip-audit
|
|
4886
5196
|
`;
|
|
4887
5197
|
function ensureRequirementsDev(workspaceRoot) {
|
|
4888
|
-
const requirementsDevPath = (0,
|
|
5198
|
+
const requirementsDevPath = (0, import_node_path22.join)(workspaceRoot, "requirements-dev.txt");
|
|
4889
5199
|
if (!fileExists(requirementsDevPath)) {
|
|
4890
5200
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
4891
5201
|
}
|
|
@@ -4945,8 +5255,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
4945
5255
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
4946
5256
|
workspaceRoot
|
|
4947
5257
|
);
|
|
4948
|
-
writeFileEnsured((0,
|
|
4949
|
-
addProjectJsonTargets((0,
|
|
5258
|
+
writeFileEnsured((0, import_node_path22.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
5259
|
+
addProjectJsonTargets((0, import_node_path22.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4950
5260
|
package: pythonAppPackageTarget(name),
|
|
4951
5261
|
start: pythonAppStartTarget(name)
|
|
4952
5262
|
});
|
|
@@ -4968,7 +5278,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
4968
5278
|
workspaceRoot
|
|
4969
5279
|
);
|
|
4970
5280
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
4971
|
-
addProjectJsonTargets((0,
|
|
5281
|
+
addProjectJsonTargets((0, import_node_path22.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4972
5282
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
4973
5283
|
start: pythonFunctionAppStartTarget(name)
|
|
4974
5284
|
});
|
|
@@ -5009,7 +5319,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
5009
5319
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
5010
5320
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
5011
5321
|
return PYTHON_PROJECT_DIRS.find(
|
|
5012
|
-
(directory) => fileExists((0,
|
|
5322
|
+
(directory) => fileExists((0, import_node_path22.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
5013
5323
|
);
|
|
5014
5324
|
}
|
|
5015
5325
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -5048,7 +5358,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5048
5358
|
`No Python project named '${consumer}' with a pyproject.toml found (checked apps/, python-packages/, libs/). A Python function app has no pyproject.toml \u2014 there is nothing to vendor into.`
|
|
5049
5359
|
);
|
|
5050
5360
|
}
|
|
5051
|
-
if (!fileExists((0,
|
|
5361
|
+
if (!fileExists((0, import_node_path22.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
5052
5362
|
throw new Error(
|
|
5053
5363
|
`No internal Python library named '${lib}' found at libs/${lib}/pyproject.toml. Only an internal library (added via 'mnci add python-internal-lib') can be vendored.`
|
|
5054
5364
|
);
|
|
@@ -5056,8 +5366,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5056
5366
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
5057
5367
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5058
5368
|
}
|
|
5059
|
-
const pyprojectPath = (0,
|
|
5060
|
-
const pyprojectToml = (0,
|
|
5369
|
+
const pyprojectPath = (0, import_node_path22.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
5370
|
+
const pyprojectToml = (0, import_node_fs20.readFileSync)(pyprojectPath, "utf8");
|
|
5061
5371
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5062
5372
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5063
5373
|
return;
|
|
@@ -5069,8 +5379,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5069
5379
|
}
|
|
5070
5380
|
|
|
5071
5381
|
// src/project-scaffolding/react-app.use-case.ts
|
|
5072
|
-
var
|
|
5073
|
-
var
|
|
5382
|
+
var import_node_fs21 = require("fs");
|
|
5383
|
+
var import_node_path23 = require("path");
|
|
5074
5384
|
|
|
5075
5385
|
// src/project-scaffolding/react-app-example.algorithm.ts
|
|
5076
5386
|
function reactAppExampleFiles(name) {
|
|
@@ -5187,12 +5497,12 @@ function reactAppTargets(name) {
|
|
|
5187
5497
|
return targets;
|
|
5188
5498
|
}
|
|
5189
5499
|
function allowEnvFiles(workspaceRoot) {
|
|
5190
|
-
const gitignorePath = (0,
|
|
5500
|
+
const gitignorePath = (0, import_node_path23.join)(workspaceRoot, ".gitignore");
|
|
5191
5501
|
if (!fileExists(gitignorePath)) {
|
|
5192
5502
|
return;
|
|
5193
5503
|
}
|
|
5194
5504
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
5195
|
-
const current = (0,
|
|
5505
|
+
const current = (0, import_node_fs21.readFileSync)(gitignorePath, "utf8");
|
|
5196
5506
|
if (current.includes(marker)) {
|
|
5197
5507
|
return;
|
|
5198
5508
|
}
|
|
@@ -5219,30 +5529,30 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
5219
5529
|
workspaceRoot
|
|
5220
5530
|
);
|
|
5221
5531
|
ensureAdmZip(workspaceRoot);
|
|
5222
|
-
const reactAppRoot = (0,
|
|
5532
|
+
const reactAppRoot = (0, import_node_path23.join)(workspaceRoot, "apps", name);
|
|
5223
5533
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
5224
|
-
writeFileEnsured((0,
|
|
5534
|
+
writeFileEnsured((0, import_node_path23.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
5225
5535
|
}
|
|
5226
5536
|
allowEnvFiles(workspaceRoot);
|
|
5227
|
-
addNxTargets((0,
|
|
5537
|
+
addNxTargets((0, import_node_path23.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
5228
5538
|
reshapeReactAppScaffold(reactAppRoot);
|
|
5229
|
-
(0,
|
|
5539
|
+
(0, import_node_fs21.rmSync)((0, import_node_path23.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
5230
5540
|
const example = reactAppExampleFiles(name);
|
|
5231
5541
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5232
|
-
writeFileEnsured((0,
|
|
5542
|
+
writeFileEnsured((0, import_node_path23.join)(reactAppRoot, "src", relative), contents);
|
|
5233
5543
|
}
|
|
5234
5544
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
5235
5545
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
5236
5546
|
}
|
|
5237
5547
|
|
|
5238
5548
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
5239
|
-
var
|
|
5549
|
+
var import_node_path24 = require("path");
|
|
5240
5550
|
var REACT_LIB_BUNDLER = "rollup";
|
|
5241
5551
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
5242
5552
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5243
5553
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
5244
|
-
const projectRoot = (0,
|
|
5245
|
-
const publishableManifest = (0,
|
|
5554
|
+
const projectRoot = (0, import_node_path24.join)(workspaceRoot, "packages", name);
|
|
5555
|
+
const publishableManifest = (0, import_node_path24.join)(projectRoot, "package.json");
|
|
5246
5556
|
runGeneratorAndRepair(
|
|
5247
5557
|
workspaceRoot,
|
|
5248
5558
|
[
|
|
@@ -5272,8 +5582,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5272
5582
|
}
|
|
5273
5583
|
function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
5274
5584
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5275
|
-
const projectRoot = (0,
|
|
5276
|
-
const privateManifest = (0,
|
|
5585
|
+
const projectRoot = (0, import_node_path24.join)(workspaceRoot, "libs", name);
|
|
5586
|
+
const privateManifest = (0, import_node_path24.join)(projectRoot, "package.json");
|
|
5277
5587
|
runGeneratorAndRepair(
|
|
5278
5588
|
workspaceRoot,
|
|
5279
5589
|
[
|
|
@@ -5300,8 +5610,8 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
5300
5610
|
}
|
|
5301
5611
|
|
|
5302
5612
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
5303
|
-
var
|
|
5304
|
-
var
|
|
5613
|
+
var import_node_fs22 = require("fs");
|
|
5614
|
+
var import_node_path25 = require("path");
|
|
5305
5615
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
5306
5616
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
5307
5617
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -5486,8 +5796,8 @@ export const window = {
|
|
|
5486
5796
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
5487
5797
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
5488
5798
|
const [file, anchor, mapping] = testRunner === "jest" ? ["jest.config.cts", "testEnvironment: 'node',", `moduleNameMapper: { '^vscode$': '<rootDir>/${VSCODE_STUB_PATH}' },`] : ["vitest.config.mts", "environment: 'node',", `alias: { vscode: \`\${import.meta.dirname}/${VSCODE_STUB_PATH}\` },`];
|
|
5489
|
-
const path = (0,
|
|
5490
|
-
const content = fileExists(path) ? (0,
|
|
5799
|
+
const path = (0, import_node_path25.join)(projectRoot, file);
|
|
5800
|
+
const content = fileExists(path) ? (0, import_node_fs22.readFileSync)(path, "utf8") : "";
|
|
5491
5801
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
5492
5802
|
if (line === void 0) {
|
|
5493
5803
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -5507,11 +5817,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
5507
5817
|
}
|
|
5508
5818
|
}
|
|
5509
5819
|
function defaultPublisher(workspaceRoot) {
|
|
5510
|
-
const { name } = readJson((0,
|
|
5820
|
+
const { name } = readJson((0, import_node_path25.join)(workspaceRoot, "package.json"));
|
|
5511
5821
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
5512
5822
|
}
|
|
5513
5823
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
5514
|
-
const manifestPath = (0,
|
|
5824
|
+
const manifestPath = (0, import_node_path25.join)(projectRoot, "package.json");
|
|
5515
5825
|
const manifest = readJson(manifestPath);
|
|
5516
5826
|
const { nx = {}, ...rest } = manifest;
|
|
5517
5827
|
const targets = { ...nx.targets };
|
|
@@ -5575,11 +5885,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
5575
5885
|
};
|
|
5576
5886
|
}
|
|
5577
5887
|
function addDebugLaunch(workspaceRoot, name) {
|
|
5578
|
-
const file = (0,
|
|
5888
|
+
const file = (0, import_node_fs22.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
5579
5889
|
if (file === void 0) {
|
|
5580
5890
|
return;
|
|
5581
5891
|
}
|
|
5582
|
-
const path = (0,
|
|
5892
|
+
const path = (0, import_node_path25.join)(workspaceRoot, file);
|
|
5583
5893
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
5584
5894
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
5585
5895
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -5612,39 +5922,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
5612
5922
|
);
|
|
5613
5923
|
}
|
|
5614
5924
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
5615
|
-
const apps = (0,
|
|
5925
|
+
const apps = (0, import_node_path25.join)(workspaceRoot, "apps");
|
|
5616
5926
|
let entries;
|
|
5617
5927
|
try {
|
|
5618
|
-
entries = (0,
|
|
5928
|
+
entries = (0, import_node_fs22.readdirSync)(apps);
|
|
5619
5929
|
} catch {
|
|
5620
5930
|
return false;
|
|
5621
5931
|
}
|
|
5622
5932
|
const hasExtension = entries.some((entry) => {
|
|
5623
|
-
const manifestPath = (0,
|
|
5933
|
+
const manifestPath = (0, import_node_path25.join)(apps, entry, "package.json");
|
|
5624
5934
|
if (!fileExists(manifestPath)) {
|
|
5625
5935
|
return false;
|
|
5626
5936
|
}
|
|
5627
5937
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
5628
5938
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
5629
5939
|
});
|
|
5630
|
-
const path = (0,
|
|
5631
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
5940
|
+
const path = (0, import_node_path25.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
5941
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs22.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
5632
5942
|
return false;
|
|
5633
5943
|
}
|
|
5634
5944
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
5635
5945
|
return true;
|
|
5636
5946
|
}
|
|
5637
5947
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
5638
|
-
const apps = (0,
|
|
5948
|
+
const apps = (0, import_node_path25.join)(workspaceRoot, "apps");
|
|
5639
5949
|
let entries;
|
|
5640
5950
|
try {
|
|
5641
|
-
entries = (0,
|
|
5951
|
+
entries = (0, import_node_fs22.readdirSync)(apps);
|
|
5642
5952
|
} catch {
|
|
5643
5953
|
return [];
|
|
5644
5954
|
}
|
|
5645
5955
|
const updated = [];
|
|
5646
5956
|
for (const entry of entries) {
|
|
5647
|
-
const manifestPath = (0,
|
|
5957
|
+
const manifestPath = (0, import_node_path25.join)(apps, entry, "package.json");
|
|
5648
5958
|
if (!fileExists(manifestPath)) {
|
|
5649
5959
|
continue;
|
|
5650
5960
|
}
|
|
@@ -5664,22 +5974,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
5664
5974
|
}
|
|
5665
5975
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
5666
5976
|
const { sidecar } = options;
|
|
5667
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
5977
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path25.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
5668
5978
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
5669
5979
|
}
|
|
5670
5980
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
5671
5981
|
ensureVscodeToolchain(workspaceRoot);
|
|
5672
|
-
const projectRoot = (0,
|
|
5982
|
+
const projectRoot = (0, import_node_path25.join)(workspaceRoot, "apps", name);
|
|
5673
5983
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
5674
|
-
addVscodeTypes((0,
|
|
5675
|
-
addVscodeTypes((0,
|
|
5676
|
-
writeFileEnsured((0,
|
|
5677
|
-
writeFileEnsured((0,
|
|
5678
|
-
writeFileEnsured((0,
|
|
5984
|
+
addVscodeTypes((0, import_node_path25.join)(projectRoot, "tsconfig.app.json"));
|
|
5985
|
+
addVscodeTypes((0, import_node_path25.join)(projectRoot, "tsconfig.spec.json"));
|
|
5986
|
+
writeFileEnsured((0, import_node_path25.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
5987
|
+
writeFileEnsured((0, import_node_path25.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
5988
|
+
writeFileEnsured((0, import_node_path25.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
5679
5989
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
5680
|
-
writeFileEnsured((0,
|
|
5681
|
-
writeFileEnsured((0,
|
|
5682
|
-
addNxTargets((0,
|
|
5990
|
+
writeFileEnsured((0, import_node_path25.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
5991
|
+
writeFileEnsured((0, import_node_path25.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
5992
|
+
addNxTargets((0, import_node_path25.join)(projectRoot, "package.json"), {
|
|
5683
5993
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
5684
5994
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
5685
5995
|
});
|
|
@@ -5690,12 +6000,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5690
6000
|
}
|
|
5691
6001
|
|
|
5692
6002
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5693
|
-
var
|
|
5694
|
-
var
|
|
6003
|
+
var import_node_fs24 = require("fs");
|
|
6004
|
+
var import_node_path27 = require("path");
|
|
5695
6005
|
|
|
5696
6006
|
// src/dependency-management/manifest.repository.ts
|
|
5697
|
-
var
|
|
5698
|
-
var
|
|
6007
|
+
var import_node_fs23 = require("fs");
|
|
6008
|
+
var import_node_path26 = require("path");
|
|
5699
6009
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5700
6010
|
var ROOT_LABEL = "(root)";
|
|
5701
6011
|
var MANIFEST_GLOBS = {
|
|
@@ -5728,23 +6038,23 @@ function projectOf(manifestRelativePath) {
|
|
|
5728
6038
|
}
|
|
5729
6039
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
5730
6040
|
if (ecosystem === "go") {
|
|
5731
|
-
return fileExists((0,
|
|
6041
|
+
return fileExists((0, import_node_path26.join)(workspaceRoot, "go.mod"));
|
|
5732
6042
|
}
|
|
5733
6043
|
if (ecosystem === "nuget") {
|
|
5734
|
-
return (0,
|
|
6044
|
+
return (0, import_node_fs23.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
5735
6045
|
}
|
|
5736
6046
|
const rootMarker = {
|
|
5737
6047
|
npm: "package.json",
|
|
5738
6048
|
pip: "requirements-dev.txt",
|
|
5739
6049
|
pub: "pubspec.yaml"
|
|
5740
6050
|
};
|
|
5741
|
-
return fileExists((0,
|
|
6051
|
+
return fileExists((0, import_node_path26.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs23.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
5742
6052
|
}
|
|
5743
6053
|
function collectNpm(workspaceRoot) {
|
|
5744
6054
|
const sites = [];
|
|
5745
|
-
const relativePaths = ["package.json", ...(0,
|
|
6055
|
+
const relativePaths = ["package.json", ...(0, import_node_fs23.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
5746
6056
|
for (const relativePath of relativePaths) {
|
|
5747
|
-
const manifestPath = (0,
|
|
6057
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
5748
6058
|
try {
|
|
5749
6059
|
const manifest = readJson(manifestPath);
|
|
5750
6060
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -5805,17 +6115,17 @@ function collectPip(workspaceRoot) {
|
|
|
5805
6115
|
name: parsed.name,
|
|
5806
6116
|
ecosystem: "pip",
|
|
5807
6117
|
project: projectOf(relativePath),
|
|
5808
|
-
manifestPath: (0,
|
|
6118
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5809
6119
|
section,
|
|
5810
6120
|
spec: parsed.spec,
|
|
5811
6121
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
5812
6122
|
});
|
|
5813
6123
|
};
|
|
5814
|
-
const pyprojectPaths = (0,
|
|
6124
|
+
const pyprojectPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
5815
6125
|
for (const relativePath of pyprojectPaths) {
|
|
5816
6126
|
let content;
|
|
5817
6127
|
try {
|
|
5818
|
-
content = (0,
|
|
6128
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5819
6129
|
} catch {
|
|
5820
6130
|
continue;
|
|
5821
6131
|
}
|
|
@@ -5826,14 +6136,14 @@ function collectPip(workspaceRoot) {
|
|
|
5826
6136
|
}
|
|
5827
6137
|
const requirementsPaths = [
|
|
5828
6138
|
"requirements-dev.txt",
|
|
5829
|
-
...(0,
|
|
6139
|
+
...(0, import_node_fs23.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
5830
6140
|
];
|
|
5831
6141
|
for (const relativePath of requirementsPaths) {
|
|
5832
|
-
if (!fileExists((0,
|
|
6142
|
+
if (!fileExists((0, import_node_path26.join)(workspaceRoot, relativePath))) {
|
|
5833
6143
|
continue;
|
|
5834
6144
|
}
|
|
5835
6145
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
5836
|
-
const lines = (0,
|
|
6146
|
+
const lines = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
5837
6147
|
for (const line of lines) {
|
|
5838
6148
|
push(relativePath, section, line);
|
|
5839
6149
|
}
|
|
@@ -5871,11 +6181,11 @@ function pyprojectDependencies(content) {
|
|
|
5871
6181
|
}
|
|
5872
6182
|
function collectPub(workspaceRoot) {
|
|
5873
6183
|
const sites = [];
|
|
5874
|
-
const pubspecPaths = (0,
|
|
6184
|
+
const pubspecPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
5875
6185
|
for (const relativePath of pubspecPaths) {
|
|
5876
6186
|
let content;
|
|
5877
6187
|
try {
|
|
5878
|
-
content = (0,
|
|
6188
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5879
6189
|
} catch {
|
|
5880
6190
|
continue;
|
|
5881
6191
|
}
|
|
@@ -5885,7 +6195,7 @@ function collectPub(workspaceRoot) {
|
|
|
5885
6195
|
name: entry.name,
|
|
5886
6196
|
ecosystem: "pub",
|
|
5887
6197
|
project: projectOf(relativePath),
|
|
5888
|
-
manifestPath: (0,
|
|
6198
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5889
6199
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
5890
6200
|
spec: entry.spec,
|
|
5891
6201
|
rewritable: entry.spec !== ""
|
|
@@ -5935,11 +6245,11 @@ function stripQuotes(value) {
|
|
|
5935
6245
|
}
|
|
5936
6246
|
function collectNuget(workspaceRoot) {
|
|
5937
6247
|
const sites = [];
|
|
5938
|
-
const csprojPaths = (0,
|
|
6248
|
+
const csprojPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
5939
6249
|
for (const relativePath of csprojPaths) {
|
|
5940
6250
|
let content;
|
|
5941
6251
|
try {
|
|
5942
|
-
content = (0,
|
|
6252
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5943
6253
|
} catch {
|
|
5944
6254
|
continue;
|
|
5945
6255
|
}
|
|
@@ -5948,7 +6258,7 @@ function collectNuget(workspaceRoot) {
|
|
|
5948
6258
|
name: entry.name,
|
|
5949
6259
|
ecosystem: "nuget",
|
|
5950
6260
|
project: projectOf(relativePath),
|
|
5951
|
-
manifestPath: (0,
|
|
6261
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5952
6262
|
section: "dep",
|
|
5953
6263
|
spec: entry.spec,
|
|
5954
6264
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -5973,13 +6283,13 @@ function csprojPackageReferences(content) {
|
|
|
5973
6283
|
return entries;
|
|
5974
6284
|
}
|
|
5975
6285
|
function collectGo(workspaceRoot) {
|
|
5976
|
-
const manifestPath = (0,
|
|
6286
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "go.mod");
|
|
5977
6287
|
if (!fileExists(manifestPath)) {
|
|
5978
6288
|
return [];
|
|
5979
6289
|
}
|
|
5980
6290
|
let content;
|
|
5981
6291
|
try {
|
|
5982
|
-
content = (0,
|
|
6292
|
+
content = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5983
6293
|
} catch {
|
|
5984
6294
|
return [];
|
|
5985
6295
|
}
|
|
@@ -6028,7 +6338,7 @@ var PROJECT_GLOBS = {
|
|
|
6028
6338
|
function locateProjects(workspaceRoot) {
|
|
6029
6339
|
const locations = [];
|
|
6030
6340
|
for (const ecosystem of ECOSYSTEMS) {
|
|
6031
|
-
const relativePaths = (0,
|
|
6341
|
+
const relativePaths = (0, import_node_fs23.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
6032
6342
|
for (const relativePath of relativePaths) {
|
|
6033
6343
|
const posix = toPosix(relativePath);
|
|
6034
6344
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -6036,7 +6346,7 @@ function locateProjects(workspaceRoot) {
|
|
|
6036
6346
|
ecosystem,
|
|
6037
6347
|
dir,
|
|
6038
6348
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
6039
|
-
manifestPath: (0,
|
|
6349
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath)
|
|
6040
6350
|
});
|
|
6041
6351
|
}
|
|
6042
6352
|
}
|
|
@@ -6057,7 +6367,7 @@ function rewriteSpec(site, spec) {
|
|
|
6057
6367
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
6058
6368
|
return true;
|
|
6059
6369
|
}
|
|
6060
|
-
const before = (0,
|
|
6370
|
+
const before = (0, import_node_fs23.readFileSync)(site.manifestPath, "utf8");
|
|
6061
6371
|
const after = (() => {
|
|
6062
6372
|
switch (site.ecosystem) {
|
|
6063
6373
|
case "pip": {
|
|
@@ -6148,13 +6458,13 @@ function escapeForRegex(value) {
|
|
|
6148
6458
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
6149
6459
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
6150
6460
|
return ["apps", "libs", "packages"].some(
|
|
6151
|
-
(directory) => fileExists((0,
|
|
6461
|
+
(directory) => fileExists((0, import_node_path26.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
6152
6462
|
);
|
|
6153
6463
|
}
|
|
6154
6464
|
function isAliasedInstall(workspaceRoot, name) {
|
|
6155
6465
|
try {
|
|
6156
6466
|
const installed = readJson(
|
|
6157
|
-
(0,
|
|
6467
|
+
(0, import_node_path26.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6158
6468
|
);
|
|
6159
6469
|
return installed.name !== void 0 && installed.name !== name;
|
|
6160
6470
|
} catch {
|
|
@@ -6165,14 +6475,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6165
6475
|
if (ecosystem === "npm") {
|
|
6166
6476
|
try {
|
|
6167
6477
|
return readJson(
|
|
6168
|
-
(0,
|
|
6478
|
+
(0, import_node_path26.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6169
6479
|
).version;
|
|
6170
6480
|
} catch {
|
|
6171
6481
|
return void 0;
|
|
6172
6482
|
}
|
|
6173
6483
|
}
|
|
6174
6484
|
if (ecosystem === "pub") {
|
|
6175
|
-
const lockPath = (0,
|
|
6485
|
+
const lockPath = (0, import_node_path26.join)(workspaceRoot, "pubspec.lock");
|
|
6176
6486
|
if (!fileExists(lockPath)) {
|
|
6177
6487
|
return void 0;
|
|
6178
6488
|
}
|
|
@@ -6180,7 +6490,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6180
6490
|
const match = new RegExp(
|
|
6181
6491
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
6182
6492
|
"m"
|
|
6183
|
-
).exec((0,
|
|
6493
|
+
).exec((0, import_node_fs23.readFileSync)(lockPath, "utf8"));
|
|
6184
6494
|
return match?.[1];
|
|
6185
6495
|
} catch {
|
|
6186
6496
|
return void 0;
|
|
@@ -6246,7 +6556,7 @@ function resolveTarget(locations, target) {
|
|
|
6246
6556
|
return byName[0];
|
|
6247
6557
|
}
|
|
6248
6558
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
6249
|
-
const projectDir = (0,
|
|
6559
|
+
const projectDir = (0, import_node_path27.join)(workspaceRoot, location.dir);
|
|
6250
6560
|
switch (location.ecosystem) {
|
|
6251
6561
|
case "npm": {
|
|
6252
6562
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -6299,7 +6609,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
6299
6609
|
function addPythonDependency(manifestPath, specifier) {
|
|
6300
6610
|
let content;
|
|
6301
6611
|
try {
|
|
6302
|
-
content = (0,
|
|
6612
|
+
content = (0, import_node_fs24.readFileSync)(manifestPath, "utf8");
|
|
6303
6613
|
} catch {
|
|
6304
6614
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
6305
6615
|
return;
|
|
@@ -6328,7 +6638,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
6328
6638
|
}
|
|
6329
6639
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
6330
6640
|
if (ecosystem === "go") {
|
|
6331
|
-
return fileExists((0,
|
|
6641
|
+
return fileExists((0, import_node_path27.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path27.join)(workspaceRoot, "go.mod"));
|
|
6332
6642
|
}
|
|
6333
6643
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
6334
6644
|
}
|
|
@@ -6347,7 +6657,7 @@ function splitAtLast(value, separator) {
|
|
|
6347
6657
|
}
|
|
6348
6658
|
|
|
6349
6659
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
6350
|
-
var
|
|
6660
|
+
var import_node_path28 = require("path");
|
|
6351
6661
|
|
|
6352
6662
|
// src/dependency-management/semver.algorithm.ts
|
|
6353
6663
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -6524,7 +6834,7 @@ function describe(finding) {
|
|
|
6524
6834
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
6525
6835
|
}
|
|
6526
6836
|
function runSync(workspaceRoot, options) {
|
|
6527
|
-
if (!fileExists((0,
|
|
6837
|
+
if (!fileExists((0, import_node_path28.join)(workspaceRoot, "nx.json"))) {
|
|
6528
6838
|
throw new Error(
|
|
6529
6839
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
6530
6840
|
);
|
|
@@ -6574,7 +6884,7 @@ function runSync(workspaceRoot, options) {
|
|
|
6574
6884
|
}
|
|
6575
6885
|
|
|
6576
6886
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
6577
|
-
var
|
|
6887
|
+
var import_node_path29 = require("path");
|
|
6578
6888
|
var import_prompts2 = require("@inquirer/prompts");
|
|
6579
6889
|
|
|
6580
6890
|
// src/dependency-management/registry.client.ts
|
|
@@ -6857,7 +7167,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
6857
7167
|
function hasPythonInstallScript(workspaceRoot) {
|
|
6858
7168
|
try {
|
|
6859
7169
|
const manifest = readJson(
|
|
6860
|
-
(0,
|
|
7170
|
+
(0, import_node_path29.join)(workspaceRoot, "package.json")
|
|
6861
7171
|
);
|
|
6862
7172
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
6863
7173
|
} catch {
|
|
@@ -6873,7 +7183,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
6873
7183
|
}
|
|
6874
7184
|
}
|
|
6875
7185
|
async function runUp(workspaceRoot, options) {
|
|
6876
|
-
if (!fileExists((0,
|
|
7186
|
+
if (!fileExists((0, import_node_path29.join)(workspaceRoot, "nx.json"))) {
|
|
6877
7187
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
6878
7188
|
}
|
|
6879
7189
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -6950,7 +7260,7 @@ var PROJECT_KINDS = [
|
|
|
6950
7260
|
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
6951
7261
|
async function runAdd(kind, name, options) {
|
|
6952
7262
|
const workspaceRoot = process.cwd();
|
|
6953
|
-
if (!fileExists((0,
|
|
7263
|
+
if (!fileExists((0, import_node_path30.join)(workspaceRoot, "nx.json"))) {
|
|
6954
7264
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
6955
7265
|
}
|
|
6956
7266
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -7013,8 +7323,8 @@ async function runAdd(kind, name, options) {
|
|
|
7013
7323
|
],
|
|
7014
7324
|
workspaceRoot
|
|
7015
7325
|
);
|
|
7016
|
-
markPrivate((0,
|
|
7017
|
-
renameScaffoldPlaceholder((0,
|
|
7326
|
+
markPrivate((0, import_node_path30.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
7327
|
+
renameScaffoldPlaceholder((0, import_node_path30.join)(workspaceRoot, "libs", resolvedName), resolvedName, options.empty === true);
|
|
7018
7328
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
7019
7329
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
7020
7330
|
break;
|
|
@@ -7106,7 +7416,7 @@ async function runAdd(kind, name, options) {
|
|
|
7106
7416
|
}
|
|
7107
7417
|
function readWorkspaceStack(workspaceRoot) {
|
|
7108
7418
|
const nxJson = readJson(
|
|
7109
|
-
(0,
|
|
7419
|
+
(0, import_node_path30.join)(workspaceRoot, "nx.json")
|
|
7110
7420
|
);
|
|
7111
7421
|
const stack = nxJson.mnci?.stack;
|
|
7112
7422
|
return {
|
|
@@ -7155,15 +7465,15 @@ function runKinds(options) {
|
|
|
7155
7465
|
|
|
7156
7466
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
7157
7467
|
var import_node_child_process = require("child_process");
|
|
7158
|
-
var
|
|
7159
|
-
var
|
|
7468
|
+
var import_node_fs25 = require("fs");
|
|
7469
|
+
var import_node_path31 = require("path");
|
|
7160
7470
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
7161
7471
|
function toPosix2(path) {
|
|
7162
7472
|
return path.replaceAll("\\", "/");
|
|
7163
7473
|
}
|
|
7164
7474
|
function checkEslintConfigs(workspaceRoot) {
|
|
7165
|
-
const rootConfigs = (0,
|
|
7166
|
-
const projectConfigs = (0,
|
|
7475
|
+
const rootConfigs = (0, import_node_fs25.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
7476
|
+
const projectConfigs = (0, import_node_fs25.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
7167
7477
|
cwd: workspaceRoot
|
|
7168
7478
|
}).map((config) => toPosix2(config));
|
|
7169
7479
|
return [
|
|
@@ -7183,10 +7493,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
7183
7493
|
];
|
|
7184
7494
|
}
|
|
7185
7495
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
7186
|
-
const rules = (0,
|
|
7187
|
-
if (!(0,
|
|
7188
|
-
const entryPoint = (0,
|
|
7189
|
-
const source = (0,
|
|
7496
|
+
const rules = (0, import_node_path31.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
7497
|
+
if (!(0, import_node_fs25.existsSync)(rules)) return [];
|
|
7498
|
+
const entryPoint = (0, import_node_path31.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
7499
|
+
const source = (0, import_node_fs25.existsSync)(entryPoint) ? (0, import_node_fs25.readFileSync)(entryPoint, "utf8") : "";
|
|
7190
7500
|
return [
|
|
7191
7501
|
{
|
|
7192
7502
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -7199,7 +7509,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
7199
7509
|
function declaredDevDependencies(workspaceRoot) {
|
|
7200
7510
|
try {
|
|
7201
7511
|
const manifest = readJson(
|
|
7202
|
-
(0,
|
|
7512
|
+
(0, import_node_path31.join)(workspaceRoot, "package.json")
|
|
7203
7513
|
);
|
|
7204
7514
|
return manifest.devDependencies ?? {};
|
|
7205
7515
|
} catch {
|
|
@@ -7207,7 +7517,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
7207
7517
|
}
|
|
7208
7518
|
}
|
|
7209
7519
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
7210
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
7520
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path31.join)(workspaceRoot, file)));
|
|
7211
7521
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
7212
7522
|
const stale = [...files, ...declared];
|
|
7213
7523
|
if (stale.length === 0) {
|
|
@@ -7233,7 +7543,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
7233
7543
|
};
|
|
7234
7544
|
}
|
|
7235
7545
|
function checkResolvedEslint(workspaceRoot) {
|
|
7236
|
-
const manifestPath = (0,
|
|
7546
|
+
const manifestPath = (0, import_node_path31.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
7237
7547
|
if (!fileExists(manifestPath)) {
|
|
7238
7548
|
return void 0;
|
|
7239
7549
|
}
|
|
@@ -7251,11 +7561,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
7251
7561
|
}
|
|
7252
7562
|
}
|
|
7253
7563
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
7254
|
-
const npmrcPath = (0,
|
|
7564
|
+
const npmrcPath = (0, import_node_path31.join)(workspaceRoot, ".npmrc");
|
|
7255
7565
|
if (!registry || !fileExists(npmrcPath)) {
|
|
7256
7566
|
return void 0;
|
|
7257
7567
|
}
|
|
7258
|
-
const npmrc = (0,
|
|
7568
|
+
const npmrc = (0, import_node_fs25.readFileSync)(npmrcPath, "utf8");
|
|
7259
7569
|
if (registry.kind === "npm") {
|
|
7260
7570
|
return {
|
|
7261
7571
|
check: ".npmrc authenticates the public registry",
|
|
@@ -7272,11 +7582,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
7272
7582
|
};
|
|
7273
7583
|
}
|
|
7274
7584
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
7275
|
-
const npmrcPath = (0,
|
|
7585
|
+
const npmrcPath = (0, import_node_path31.join)(workspaceRoot, ".npmrc");
|
|
7276
7586
|
if (!fileExists(npmrcPath)) {
|
|
7277
7587
|
return void 0;
|
|
7278
7588
|
}
|
|
7279
|
-
const npmrc = (0,
|
|
7589
|
+
const npmrc = (0, import_node_fs25.readFileSync)(npmrcPath, "utf8");
|
|
7280
7590
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7281
7591
|
const referenced = [
|
|
7282
7592
|
...new Set(
|
|
@@ -7300,13 +7610,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
7300
7610
|
};
|
|
7301
7611
|
}
|
|
7302
7612
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
7303
|
-
const npmrcPath = (0,
|
|
7304
|
-
const pipelinePath = (0,
|
|
7613
|
+
const npmrcPath = (0, import_node_path31.join)(workspaceRoot, ".npmrc");
|
|
7614
|
+
const pipelinePath = (0, import_node_path31.join)(workspaceRoot, "azure-pipelines.yml");
|
|
7305
7615
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
7306
7616
|
return void 0;
|
|
7307
7617
|
}
|
|
7308
|
-
const holdsCredentials = (0,
|
|
7309
|
-
const runsTask = (0,
|
|
7618
|
+
const holdsCredentials = (0, import_node_fs25.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7619
|
+
const runsTask = (0, import_node_fs25.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
7310
7620
|
if (!holdsCredentials && !runsTask) {
|
|
7311
7621
|
return {
|
|
7312
7622
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -7351,13 +7661,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
7351
7661
|
}
|
|
7352
7662
|
function checkVersionActions(workspaceRoot) {
|
|
7353
7663
|
const candidates = [
|
|
7354
|
-
...(0,
|
|
7355
|
-
...(0,
|
|
7356
|
-
...(0,
|
|
7664
|
+
...(0, import_node_fs25.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
7665
|
+
...(0, import_node_fs25.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
7666
|
+
...(0, import_node_fs25.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
7357
7667
|
].map((manifest) => toPosix2(manifest));
|
|
7358
7668
|
return candidates.flatMap((manifest) => {
|
|
7359
7669
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
7360
|
-
const projectJsonPath = (0,
|
|
7670
|
+
const projectJsonPath = (0, import_node_path31.join)(workspaceRoot, projectRoot, "project.json");
|
|
7361
7671
|
let hasOverride = false;
|
|
7362
7672
|
try {
|
|
7363
7673
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -7386,7 +7696,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7386
7696
|
]) {
|
|
7387
7697
|
try {
|
|
7388
7698
|
const targets = extract(
|
|
7389
|
-
readJson((0,
|
|
7699
|
+
readJson((0, import_node_path31.join)(workspaceRoot, projectRoot, file))
|
|
7390
7700
|
);
|
|
7391
7701
|
if (targets && typeof targets === "object") {
|
|
7392
7702
|
sources.push({
|
|
@@ -7402,8 +7712,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7402
7712
|
function checkTargetFilesExist(workspaceRoot) {
|
|
7403
7713
|
const projectRoots = new Set(
|
|
7404
7714
|
[
|
|
7405
|
-
...(0,
|
|
7406
|
-
...(0,
|
|
7715
|
+
...(0, import_node_fs25.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
7716
|
+
...(0, import_node_fs25.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
7407
7717
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
7408
7718
|
);
|
|
7409
7719
|
return [...projectRoots].flatMap(
|
|
@@ -7418,7 +7728,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
7418
7728
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
7419
7729
|
const value = target?.options?.[option];
|
|
7420
7730
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
7421
|
-
if (!checkable || fileExists((0,
|
|
7731
|
+
if (!checkable || fileExists((0, import_node_path31.join)(workspaceRoot, value))) {
|
|
7422
7732
|
return [];
|
|
7423
7733
|
}
|
|
7424
7734
|
return [
|
|
@@ -7457,15 +7767,15 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
7457
7767
|
};
|
|
7458
7768
|
}
|
|
7459
7769
|
function checkGoWorkInSync(workspaceRoot) {
|
|
7460
|
-
const goWorkPath = (0,
|
|
7770
|
+
const goWorkPath = (0, import_node_path31.join)(workspaceRoot, "go.work");
|
|
7461
7771
|
if (!fileExists(goWorkPath)) {
|
|
7462
7772
|
return void 0;
|
|
7463
7773
|
}
|
|
7464
|
-
const contents = (0,
|
|
7774
|
+
const contents = (0, import_node_fs25.existsSync)(goWorkPath) ? (0, import_node_fs25.readFileSync)(goWorkPath, "utf8") : "";
|
|
7465
7775
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
7466
7776
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
7467
7777
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
7468
|
-
const stale = uses.filter((entry) => !(0,
|
|
7778
|
+
const stale = uses.filter((entry) => !(0, import_node_fs25.existsSync)((0, import_node_path31.join)(workspaceRoot, entry, "go.mod")));
|
|
7469
7779
|
return {
|
|
7470
7780
|
check: "every go.work `use` entry points to a module that still exists",
|
|
7471
7781
|
ok: stale.length === 0,
|
|
@@ -7481,9 +7791,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7481
7791
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
7482
7792
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
7483
7793
|
];
|
|
7484
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
7794
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path31.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
7485
7795
|
check: `${file} builds the native apps on every OS`,
|
|
7486
|
-
ok: (0,
|
|
7796
|
+
ok: (0, import_node_fs25.readFileSync)((0, import_node_path31.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
7487
7797
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
7488
7798
|
remedy: "run `mnci upgrade`"
|
|
7489
7799
|
}));
|
|
@@ -7496,7 +7806,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7496
7806
|
return findings;
|
|
7497
7807
|
}
|
|
7498
7808
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
7499
|
-
const manifestPath = (0,
|
|
7809
|
+
const manifestPath = (0, import_node_path31.join)(workspaceRoot, "package.json");
|
|
7500
7810
|
if (!fileExists(manifestPath)) {
|
|
7501
7811
|
return void 0;
|
|
7502
7812
|
}
|
|
@@ -7516,14 +7826,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
7516
7826
|
};
|
|
7517
7827
|
}
|
|
7518
7828
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
7519
|
-
const configs = (0,
|
|
7829
|
+
const configs = (0, import_node_fs25.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7520
7830
|
cwd: workspaceRoot
|
|
7521
7831
|
}).map((config) => toPosix2(config));
|
|
7522
7832
|
return configs.flatMap((relativePath) => {
|
|
7523
|
-
const configPath = (0,
|
|
7833
|
+
const configPath = (0, import_node_path31.join)(workspaceRoot, relativePath);
|
|
7524
7834
|
let config;
|
|
7525
7835
|
try {
|
|
7526
|
-
config = (0,
|
|
7836
|
+
config = (0, import_node_fs25.readFileSync)(configPath, "utf8");
|
|
7527
7837
|
} catch {
|
|
7528
7838
|
return [];
|
|
7529
7839
|
}
|
|
@@ -7538,11 +7848,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
7538
7848
|
});
|
|
7539
7849
|
}
|
|
7540
7850
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
7541
|
-
const configs = (0,
|
|
7851
|
+
const configs = (0, import_node_fs25.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7542
7852
|
cwd: workspaceRoot
|
|
7543
7853
|
}).map((config) => toPosix2(config));
|
|
7544
7854
|
return configs.flatMap((relativePath) => {
|
|
7545
|
-
const configPath = (0,
|
|
7855
|
+
const configPath = (0, import_node_path31.join)(workspaceRoot, relativePath);
|
|
7546
7856
|
if (!fileExists(configPath)) {
|
|
7547
7857
|
return [];
|
|
7548
7858
|
}
|
|
@@ -7576,7 +7886,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
7576
7886
|
});
|
|
7577
7887
|
}
|
|
7578
7888
|
function collectFindings(workspaceRoot) {
|
|
7579
|
-
const nxJsonPath = (0,
|
|
7889
|
+
const nxJsonPath = (0, import_node_path31.join)(workspaceRoot, "nx.json");
|
|
7580
7890
|
if (!fileExists(nxJsonPath)) {
|
|
7581
7891
|
throw new Error(
|
|
7582
7892
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -7700,11 +8010,11 @@ function runCommands(program, options) {
|
|
|
7700
8010
|
}
|
|
7701
8011
|
|
|
7702
8012
|
// src/workspace-info/list-projects.use-case.ts
|
|
7703
|
-
var
|
|
8013
|
+
var import_node_path32 = require("path");
|
|
7704
8014
|
var TYPE_TAG_PREFIX = "type:";
|
|
7705
8015
|
function listProjects(workspaceRoot) {
|
|
7706
8016
|
return locateProjects(workspaceRoot).map((location) => {
|
|
7707
|
-
const projectJsonPath = (0,
|
|
8017
|
+
const projectJsonPath = (0, import_node_path32.join)(workspaceRoot, location.dir, "project.json");
|
|
7708
8018
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
7709
8019
|
const typeTag = (project.tags ?? []).find((tag) => tag.startsWith(TYPE_TAG_PREFIX));
|
|
7710
8020
|
return {
|
|
@@ -7717,7 +8027,7 @@ function listProjects(workspaceRoot) {
|
|
|
7717
8027
|
}).toSorted((a, b) => a.dir.localeCompare(b.dir));
|
|
7718
8028
|
}
|
|
7719
8029
|
function runProjects(workspaceRoot, options) {
|
|
7720
|
-
if (!fileExists((0,
|
|
8030
|
+
if (!fileExists((0, import_node_path32.join)(workspaceRoot, "nx.json"))) {
|
|
7721
8031
|
throw new Error("No nx.json found here. Run `projects` from the workspace root.");
|
|
7722
8032
|
}
|
|
7723
8033
|
const projects = listProjects(workspaceRoot);
|
|
@@ -7731,12 +8041,12 @@ function runProjects(workspaceRoot, options) {
|
|
|
7731
8041
|
}
|
|
7732
8042
|
|
|
7733
8043
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7734
|
-
var
|
|
8044
|
+
var import_node_path34 = require("path");
|
|
7735
8045
|
|
|
7736
8046
|
// src/cli-version/check-for-update.use-case.ts
|
|
7737
|
-
var
|
|
7738
|
-
var
|
|
7739
|
-
var
|
|
8047
|
+
var import_node_fs26 = require("fs");
|
|
8048
|
+
var import_node_path33 = require("path");
|
|
8049
|
+
var import_cross_spawn3 = __toESM(require("cross-spawn"));
|
|
7740
8050
|
var PACKAGE_NAME = "@mnci/cli";
|
|
7741
8051
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
7742
8052
|
function checkForUpdate(currentVersion2) {
|
|
@@ -7754,7 +8064,7 @@ function checkForUpdate(currentVersion2) {
|
|
|
7754
8064
|
}
|
|
7755
8065
|
}
|
|
7756
8066
|
function fetchLatestVersion() {
|
|
7757
|
-
const result =
|
|
8067
|
+
const result = import_cross_spawn3.default.sync("npm", ["view", PACKAGE_NAME, "version"], {
|
|
7758
8068
|
encoding: "utf8",
|
|
7759
8069
|
timeout: REGISTRY_TIMEOUT_MS,
|
|
7760
8070
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -7794,8 +8104,8 @@ function releaseTriple(version) {
|
|
|
7794
8104
|
}
|
|
7795
8105
|
function readCliVersion(packageDirectory) {
|
|
7796
8106
|
try {
|
|
7797
|
-
const manifestPath = (0,
|
|
7798
|
-
const manifest = JSON.parse((0,
|
|
8107
|
+
const manifestPath = (0, import_node_path33.join)(packageDirectory, "..", "package.json");
|
|
8108
|
+
const manifest = JSON.parse((0, import_node_fs26.readFileSync)(manifestPath, "utf8"));
|
|
7799
8109
|
return manifest.version ?? "0.0.0";
|
|
7800
8110
|
} catch {
|
|
7801
8111
|
return "0.0.0";
|
|
@@ -7805,7 +8115,7 @@ function readCliVersion(packageDirectory) {
|
|
|
7805
8115
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7806
8116
|
function readWorkspaceInfo(workspaceRoot, cliVersion) {
|
|
7807
8117
|
const latest = fetchLatestVersion() ?? null;
|
|
7808
|
-
const isWorkspace = fileExists((0,
|
|
8118
|
+
const isWorkspace = fileExists((0, import_node_path34.join)(workspaceRoot, "nx.json"));
|
|
7809
8119
|
return {
|
|
7810
8120
|
cli: {
|
|
7811
8121
|
version: cliVersion,
|
|
@@ -7826,8 +8136,8 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
7826
8136
|
}
|
|
7827
8137
|
|
|
7828
8138
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
7829
|
-
var
|
|
7830
|
-
var
|
|
8139
|
+
var import_node_fs27 = require("fs");
|
|
8140
|
+
var import_node_path35 = require("path");
|
|
7831
8141
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
7832
8142
|
var AGENT_AND_CI_ENTRIES = [
|
|
7833
8143
|
"AGENTS.md",
|
|
@@ -7858,13 +8168,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
7858
8168
|
"packages"
|
|
7859
8169
|
];
|
|
7860
8170
|
function assertAdoptableDirectory(target) {
|
|
7861
|
-
if (!(0,
|
|
8171
|
+
if (!(0, import_node_fs27.existsSync)(target)) {
|
|
7862
8172
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
7863
8173
|
}
|
|
7864
|
-
if (!(0,
|
|
8174
|
+
if (!(0, import_node_fs27.statSync)(target).isDirectory()) {
|
|
7865
8175
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
7866
8176
|
}
|
|
7867
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
8177
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs27.existsSync)((0, import_node_path35.join)(target, entry)));
|
|
7868
8178
|
if (blockers.length > 0) {
|
|
7869
8179
|
throw new Error(
|
|
7870
8180
|
`--into '${target}' already holds ${blockers.join(", ")}, so it is a project already. Use \`mnci upgrade\` to re-apply the overlay to an existing workspace, or point --into at an empty checkout.`
|
|
@@ -7872,15 +8182,15 @@ function assertAdoptableDirectory(target) {
|
|
|
7872
8182
|
}
|
|
7873
8183
|
}
|
|
7874
8184
|
function mergeGitignore(generatedFile, targetFile) {
|
|
7875
|
-
const existing = (0,
|
|
8185
|
+
const existing = (0, import_node_fs27.readFileSync)(targetFile, "utf8");
|
|
7876
8186
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
7877
|
-
const additions = (0,
|
|
8187
|
+
const additions = (0, import_node_fs27.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
7878
8188
|
const trimmed = line.trim();
|
|
7879
8189
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
7880
8190
|
});
|
|
7881
8191
|
if (additions.length === 0) return false;
|
|
7882
8192
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
7883
|
-
(0,
|
|
8193
|
+
(0, import_node_fs27.writeFileSync)(
|
|
7884
8194
|
targetFile,
|
|
7885
8195
|
`${existing}${separator}
|
|
7886
8196
|
# Added by mnci (Nx workspace)
|
|
@@ -7890,9 +8200,9 @@ ${additions.join("\n")}
|
|
|
7890
8200
|
return true;
|
|
7891
8201
|
}
|
|
7892
8202
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
7893
|
-
const entries = (0,
|
|
8203
|
+
const entries = (0, import_node_fs27.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
7894
8204
|
const collisions = entries.filter(
|
|
7895
|
-
(entry) => (0,
|
|
8205
|
+
(entry) => (0, import_node_fs27.existsSync)((0, import_node_path35.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
7896
8206
|
);
|
|
7897
8207
|
if (collisions.length > 0) {
|
|
7898
8208
|
throw new Error(
|
|
@@ -7901,28 +8211,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
7901
8211
|
}
|
|
7902
8212
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
7903
8213
|
for (const entry of entries) {
|
|
7904
|
-
const from = (0,
|
|
7905
|
-
const to = (0,
|
|
7906
|
-
if (entry === ".gitignore" && (0,
|
|
8214
|
+
const from = (0, import_node_path35.join)(generatedRoot, entry);
|
|
8215
|
+
const to = (0, import_node_path35.join)(target, entry);
|
|
8216
|
+
if (entry === ".gitignore" && (0, import_node_fs27.existsSync)(to)) {
|
|
7907
8217
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
7908
8218
|
result.kept.push(entry);
|
|
7909
8219
|
continue;
|
|
7910
8220
|
}
|
|
7911
|
-
if ((0,
|
|
8221
|
+
if ((0, import_node_fs27.existsSync)(to)) {
|
|
7912
8222
|
result.kept.push(entry);
|
|
7913
8223
|
continue;
|
|
7914
8224
|
}
|
|
7915
|
-
(0,
|
|
8225
|
+
(0, import_node_fs27.cpSync)(from, to, { recursive: true });
|
|
7916
8226
|
result.copied.push(entry);
|
|
7917
8227
|
}
|
|
7918
|
-
(0,
|
|
8228
|
+
(0, import_node_fs27.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
7919
8229
|
return result;
|
|
7920
8230
|
}
|
|
7921
8231
|
|
|
7922
8232
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
7923
|
-
var
|
|
7924
|
-
var
|
|
7925
|
-
var
|
|
8233
|
+
var import_node_fs28 = require("fs");
|
|
8234
|
+
var import_node_os2 = require("os");
|
|
8235
|
+
var import_node_path36 = require("path");
|
|
7926
8236
|
function nxCloudProviderValue(ci) {
|
|
7927
8237
|
return ci === "azure" ? "azure" : "github";
|
|
7928
8238
|
}
|
|
@@ -7965,9 +8275,9 @@ async function resolveRegistry(options) {
|
|
|
7965
8275
|
return await promptRegistry();
|
|
7966
8276
|
}
|
|
7967
8277
|
async function runNew(name, options) {
|
|
7968
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
8278
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path36.resolve)(process.cwd(), options.into);
|
|
7969
8279
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
7970
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
8280
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path36.basename)(adoptTarget));
|
|
7971
8281
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
7972
8282
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
7973
8283
|
const registry = await resolveRegistry(options);
|
|
@@ -7980,8 +8290,8 @@ async function runNew(name, options) {
|
|
|
7980
8290
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
7981
8291
|
const stack = await resolveStack(options);
|
|
7982
8292
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
7983
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
7984
|
-
let workspaceRoot = (0,
|
|
8293
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs28.mkdtempSync)((0, import_node_path36.join)((0, import_node_os2.tmpdir)(), "mnci-new-"));
|
|
8294
|
+
let workspaceRoot = (0, import_node_path36.join)(stagingParent, workspaceName);
|
|
7985
8295
|
try {
|
|
7986
8296
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
7987
8297
|
runNpx(
|
|
@@ -8004,7 +8314,7 @@ async function runNew(name, options) {
|
|
|
8004
8314
|
workspaceRoot = adoptTarget;
|
|
8005
8315
|
}
|
|
8006
8316
|
} finally {
|
|
8007
|
-
if (adoptTarget !== void 0) (0,
|
|
8317
|
+
if (adoptTarget !== void 0) (0, import_node_fs28.rmSync)(stagingParent, { recursive: true, force: true });
|
|
8008
8318
|
}
|
|
8009
8319
|
logger.step(
|
|
8010
8320
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -8014,8 +8324,8 @@ async function runNew(name, options) {
|
|
|
8014
8324
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
8015
8325
|
logger.detail
|
|
8016
8326
|
);
|
|
8017
|
-
(0,
|
|
8018
|
-
(0,
|
|
8327
|
+
(0, import_node_fs28.rmSync)((0, import_node_path36.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
8328
|
+
(0, import_node_fs28.rmSync)((0, import_node_path36.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
8019
8329
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
8020
8330
|
const installStatus = runShell(
|
|
8021
8331
|
"npm",
|
|
@@ -8053,12 +8363,12 @@ function projectKindHintLines(kinds = PROJECT_KINDS) {
|
|
|
8053
8363
|
}
|
|
8054
8364
|
|
|
8055
8365
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8056
|
-
var
|
|
8366
|
+
var import_node_path38 = require("path");
|
|
8057
8367
|
var import_prompts4 = require("@inquirer/prompts");
|
|
8058
8368
|
|
|
8059
8369
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
8060
|
-
var
|
|
8061
|
-
var
|
|
8370
|
+
var import_node_fs29 = require("fs");
|
|
8371
|
+
var import_node_path37 = require("path");
|
|
8062
8372
|
function resolveRegistry2(options, persisted) {
|
|
8063
8373
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
8064
8374
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -8087,7 +8397,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8087
8397
|
return persisted.workspaceName;
|
|
8088
8398
|
}
|
|
8089
8399
|
try {
|
|
8090
|
-
const existing = (0,
|
|
8400
|
+
const existing = (0, import_node_fs29.readdirSync)(workspaceRoot).find(
|
|
8091
8401
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
8092
8402
|
);
|
|
8093
8403
|
if (existing) {
|
|
@@ -8095,11 +8405,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8095
8405
|
}
|
|
8096
8406
|
} catch {
|
|
8097
8407
|
}
|
|
8098
|
-
return (0,
|
|
8408
|
+
return (0, import_node_path37.basename)(workspaceRoot);
|
|
8099
8409
|
}
|
|
8100
8410
|
function detectNpmAuth(workspaceRoot) {
|
|
8101
8411
|
try {
|
|
8102
|
-
return (0,
|
|
8412
|
+
return (0, import_node_fs29.readFileSync)((0, import_node_path37.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
8103
8413
|
} catch {
|
|
8104
8414
|
return void 0;
|
|
8105
8415
|
}
|
|
@@ -8146,7 +8456,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
8146
8456
|
};
|
|
8147
8457
|
}
|
|
8148
8458
|
function runUpgrade(workspaceRoot, options) {
|
|
8149
|
-
if (!fileExists((0,
|
|
8459
|
+
if (!fileExists((0, import_node_path37.join)(workspaceRoot, "nx.json"))) {
|
|
8150
8460
|
throw new Error(
|
|
8151
8461
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
8152
8462
|
);
|
|
@@ -8211,7 +8521,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
8211
8521
|
|
|
8212
8522
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8213
8523
|
async function runInteractive() {
|
|
8214
|
-
const inWorkspace = fileExists((0,
|
|
8524
|
+
const inWorkspace = fileExists((0, import_node_path38.join)(process.cwd(), "nx.json"));
|
|
8215
8525
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
8216
8526
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
8217
8527
|
const choiceUpgrade = {
|
|
@@ -8264,7 +8574,7 @@ function buildProgram(cliVersion) {
|
|
|
8264
8574
|
runDoctor(process.cwd(), options);
|
|
8265
8575
|
});
|
|
8266
8576
|
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
8267
|
-
"Run a phase of the CI pipeline here, the same way CI runs it: `verify` is the sync check and then every project (or, in a pull request, the affected ones) through lint, typecheck, test and build. `pack` builds the per-app artifacts, `release` versions, tags and publishes, and `native` builds the apps that need a C toolchain on this OS. Exits non-zero when it fails"
|
|
8577
|
+
"Run a phase of the CI pipeline here, the same way CI runs it: `verify` is the sync check and then every project (or, in a pull request, the affected ones) through lint, typecheck, test and build. `setup` installs the Python, Go and Flutter toolchains the workspace needs, `audit` fails on a known advisory that has a fix, `pack` builds the per-app artifacts, `release` versions, tags and publishes, and `native` builds the apps that need a C toolchain on this OS. Exits non-zero when it fails"
|
|
8268
8578
|
).action(async (phase) => {
|
|
8269
8579
|
process.exitCode = await runCiPhase(phase, process.cwd());
|
|
8270
8580
|
});
|