@mnci/cli 4.32.3 → 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 +798 -435
- 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
|
|
40
|
+
// src/ci-pipeline/audit.use-case.ts
|
|
41
|
+
var import_node_fs2 = require("fs");
|
|
42
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"));
|
|
@@ -207,6 +208,7 @@ function runFormatter(cwd, target = ".") {
|
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
// src/ci-pipeline/ci-environment.client.ts
|
|
211
|
+
var import_node_fs = require("fs");
|
|
210
212
|
function detectCiHost(environment) {
|
|
211
213
|
if (environment.GITHUB_ACTIONS === "true") {
|
|
212
214
|
return "github";
|
|
@@ -220,6 +222,24 @@ function pullRequestTarget(environment) {
|
|
|
220
222
|
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
221
223
|
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
222
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
|
+
}
|
|
223
243
|
function groupStart(host, title) {
|
|
224
244
|
switch (host) {
|
|
225
245
|
case "github": {
|
|
@@ -248,57 +268,90 @@ function groupEnd(host) {
|
|
|
248
268
|
}
|
|
249
269
|
}
|
|
250
270
|
|
|
251
|
-
// src/ci-pipeline/
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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}`;
|
|
261
283
|
});
|
|
262
|
-
|
|
263
|
-
return hasProjectJson || hasInlineNx || hasCsproj;
|
|
284
|
+
return { blocking, total: all.length, notes };
|
|
264
285
|
}
|
|
265
|
-
function
|
|
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 = {}) {
|
|
266
309
|
const environment = dependencies.environment ?? process.env;
|
|
267
310
|
const processes = dependencies.processes ?? {
|
|
268
311
|
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
269
|
-
capture: () =>
|
|
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
|
+
}
|
|
270
316
|
};
|
|
271
317
|
const log = dependencies.log ?? ((message) => {
|
|
272
318
|
console.log(message);
|
|
273
319
|
});
|
|
274
320
|
const host = detectCiHost(environment);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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;
|
|
279
332
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const closing = groupEnd(host);
|
|
283
|
-
if (closing !== void 0) {
|
|
284
|
-
log(closing);
|
|
333
|
+
if (!(0, import_node_fs2.existsSync)((0, import_node_path.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
334
|
+
return 0;
|
|
285
335
|
}
|
|
286
|
-
|
|
336
|
+
log(groupStart(host, "pip-audit (non-blocking)"));
|
|
337
|
+
processes.run(process.platform === "win32" ? "python" : "python3", ["-m", "pip_audit"]);
|
|
338
|
+
closeGroup();
|
|
339
|
+
return 0;
|
|
287
340
|
}
|
|
288
341
|
|
|
289
|
-
// src/ci-pipeline/
|
|
290
|
-
var
|
|
342
|
+
// src/ci-pipeline/native.use-case.ts
|
|
343
|
+
var import_node_fs5 = require("fs");
|
|
291
344
|
var import_node_path4 = require("path");
|
|
292
345
|
|
|
293
346
|
// src/workspace-overlay/overlay.use-case.ts
|
|
294
|
-
var
|
|
347
|
+
var import_node_fs4 = require("fs");
|
|
295
348
|
var import_node_path3 = require("path");
|
|
296
349
|
|
|
297
350
|
// src/file-system/file-system.client.ts
|
|
298
|
-
var
|
|
351
|
+
var import_node_fs3 = require("fs");
|
|
299
352
|
var import_node_path2 = require("path");
|
|
300
353
|
function readJson(path) {
|
|
301
|
-
return JSON.parse((0,
|
|
354
|
+
return JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
302
355
|
}
|
|
303
356
|
function stripJsonComments(text) {
|
|
304
357
|
let result = "";
|
|
@@ -355,7 +408,7 @@ function stripJsonComments(text) {
|
|
|
355
408
|
}
|
|
356
409
|
function readCodeWorkspace(path) {
|
|
357
410
|
try {
|
|
358
|
-
const withoutComments = stripJsonComments((0,
|
|
411
|
+
const withoutComments = stripJsonComments((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
359
412
|
return JSON.parse(withoutComments.replaceAll(/,(\s*[}\]])/g, "$1"));
|
|
360
413
|
} catch {
|
|
361
414
|
return void 0;
|
|
@@ -366,14 +419,14 @@ function toJson(value) {
|
|
|
366
419
|
`;
|
|
367
420
|
}
|
|
368
421
|
function writeFileEnsured(path, content) {
|
|
369
|
-
(0,
|
|
370
|
-
(0,
|
|
422
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path2.dirname)(path), { recursive: true });
|
|
423
|
+
(0, import_node_fs3.writeFileSync)(path, content);
|
|
371
424
|
}
|
|
372
425
|
function markExecutable(path) {
|
|
373
|
-
(0,
|
|
426
|
+
(0, import_node_fs3.chmodSync)(path, 493);
|
|
374
427
|
}
|
|
375
428
|
function fileExists(path) {
|
|
376
|
-
return (0,
|
|
429
|
+
return (0, import_node_fs3.existsSync)(path);
|
|
377
430
|
}
|
|
378
431
|
|
|
379
432
|
// src/workspace-overlay/overlay.use-case.ts
|
|
@@ -516,9 +569,9 @@ var VSCODE_EXTENSION_TAG = "type:vscode-extension";
|
|
|
516
569
|
var GO_RELEASE_TAG = "release:go";
|
|
517
570
|
var GO_CGO_TAG = "build:cgo";
|
|
518
571
|
function hasNativeGoApp(workspaceRoot) {
|
|
519
|
-
return (0,
|
|
572
|
+
return (0, import_node_fs4.globSync)("apps/*/project.json", { cwd: workspaceRoot }).some((projectJson) => {
|
|
520
573
|
try {
|
|
521
|
-
const { tags } = JSON.parse((0,
|
|
574
|
+
const { tags } = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path3.join)(workspaceRoot, projectJson), "utf8"));
|
|
522
575
|
return (tags ?? []).includes(GO_CGO_TAG);
|
|
523
576
|
} catch {
|
|
524
577
|
return false;
|
|
@@ -860,7 +913,7 @@ function isUnmodifiedMnciEslintConfig(content) {
|
|
|
860
913
|
}
|
|
861
914
|
function writeEslintEntryPoint(workspaceRoot, onProgress) {
|
|
862
915
|
const path = (0, import_node_path3.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
863
|
-
if ((0,
|
|
916
|
+
if ((0, import_node_fs4.existsSync)(path) && !isUnmodifiedMnciEslintConfig((0, import_node_fs4.readFileSync)(path, "utf8"))) {
|
|
864
917
|
onProgress(`${ESLINT_USER_FILENAME} \u2014 kept as it is, it is yours`);
|
|
865
918
|
return;
|
|
866
919
|
}
|
|
@@ -1131,7 +1184,8 @@ function affectedOrAllGuard(exclude = "") {
|
|
|
1131
1184
|
}
|
|
1132
1185
|
var AFFECTED_OR_ALL_GUARD = affectedOrAllGuard();
|
|
1133
1186
|
var AFFECTED_OR_ALL_GUARD_WITHOUT_NATIVE = affectedOrAllGuard(`--exclude=tag:${GO_CGO_TAG}`);
|
|
1134
|
-
var
|
|
1187
|
+
var NATIVE_TARGETS = "lint,test,build-native,package-native";
|
|
1188
|
+
var NATIVE_BUILD_COMMAND = `npx nx run-many -t ${NATIVE_TARGETS} --projects=tag:${GO_CGO_TAG}`;
|
|
1135
1189
|
var NATIVE_LINUX_PREREQUISITES = "sudo apt-get update && sudo apt-get install -y gcc pkg-config";
|
|
1136
1190
|
function githubNativeJob(npmAuthName, npmAuthValue, onMain) {
|
|
1137
1191
|
return `
|
|
@@ -1956,11 +2010,11 @@ var ECOSYSTEM_MANIFESTS = {
|
|
|
1956
2010
|
function hasEcosystemProject(workspaceRoot, roots, manifests) {
|
|
1957
2011
|
return roots.some((root) => {
|
|
1958
2012
|
const base = (0, import_node_path3.join)(workspaceRoot, root);
|
|
1959
|
-
if (!(0,
|
|
2013
|
+
if (!(0, import_node_fs4.existsSync)(base)) {
|
|
1960
2014
|
return false;
|
|
1961
2015
|
}
|
|
1962
|
-
return (0,
|
|
1963
|
-
(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)))
|
|
1964
2018
|
);
|
|
1965
2019
|
});
|
|
1966
2020
|
}
|
|
@@ -2038,7 +2092,7 @@ var LOCAL_REGISTRY_SCAFFOLDING = {
|
|
|
2038
2092
|
rootTarget: "local-registry"
|
|
2039
2093
|
};
|
|
2040
2094
|
function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
2041
|
-
(0,
|
|
2095
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, LOCAL_REGISTRY_SCAFFOLDING.directory), {
|
|
2042
2096
|
recursive: true,
|
|
2043
2097
|
force: true
|
|
2044
2098
|
});
|
|
@@ -2058,23 +2112,23 @@ function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
|
2058
2112
|
}
|
|
2059
2113
|
function removeNxScaffolding(workspaceRoot) {
|
|
2060
2114
|
for (const entry of NX_SCAFFOLDING_TO_REMOVE) {
|
|
2061
|
-
(0,
|
|
2115
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, entry), { recursive: true, force: true });
|
|
2062
2116
|
}
|
|
2063
2117
|
removeNxAuthoredAgentFiles(workspaceRoot);
|
|
2064
2118
|
removeProjectEslintConfigs(workspaceRoot);
|
|
2065
2119
|
}
|
|
2066
2120
|
function removeNxAuthoredAgentFiles(workspaceRoot) {
|
|
2067
|
-
(0,
|
|
2121
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, NX_CLAUDE_SETTINGS), { force: true });
|
|
2068
2122
|
const claudeDirectory = (0, import_node_path3.join)(workspaceRoot, (0, import_node_path3.dirname)(NX_CLAUDE_SETTINGS));
|
|
2069
|
-
if ((0,
|
|
2070
|
-
(0,
|
|
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 });
|
|
2071
2125
|
}
|
|
2072
2126
|
for (const name of NX_AUTHORED_AGENT_FILES) {
|
|
2073
2127
|
const path = (0, import_node_path3.join)(workspaceRoot, name);
|
|
2074
|
-
if (!(0,
|
|
2075
|
-
const kept = withoutNxAgentRules((0,
|
|
2128
|
+
if (!(0, import_node_fs4.existsSync)(path)) continue;
|
|
2129
|
+
const kept = withoutNxAgentRules((0, import_node_fs4.readFileSync)(path, "utf8"));
|
|
2076
2130
|
if (kept === void 0) continue;
|
|
2077
|
-
if (kept.trim() === "") (0,
|
|
2131
|
+
if (kept.trim() === "") (0, import_node_fs4.rmSync)(path, { force: true });
|
|
2078
2132
|
else writeFileEnsured(path, kept);
|
|
2079
2133
|
}
|
|
2080
2134
|
}
|
|
@@ -2089,14 +2143,14 @@ function withoutNxAgentRules(content) {
|
|
|
2089
2143
|
return `${content.slice(0, start)}${rest}`.replace(/^[\r\n]+/, "");
|
|
2090
2144
|
}
|
|
2091
2145
|
function removeIfPresent(path) {
|
|
2092
|
-
(0,
|
|
2146
|
+
(0, import_node_fs4.rmSync)(path, { recursive: true, force: true });
|
|
2093
2147
|
}
|
|
2094
2148
|
function ensureEslintCacheIgnored(workspaceRoot) {
|
|
2095
2149
|
const gitignorePath = (0, import_node_path3.join)(workspaceRoot, ".gitignore");
|
|
2096
2150
|
if (!fileExists(gitignorePath)) {
|
|
2097
2151
|
return;
|
|
2098
2152
|
}
|
|
2099
|
-
const current = (0,
|
|
2153
|
+
const current = (0, import_node_fs4.readFileSync)(gitignorePath, "utf8");
|
|
2100
2154
|
if (current.split("\n").some((line) => line.trim() === ".eslintcache")) {
|
|
2101
2155
|
return;
|
|
2102
2156
|
}
|
|
@@ -2115,14 +2169,14 @@ function ensurePythonArtefactsIgnored(workspaceRoot) {
|
|
|
2115
2169
|
if (!fileExists(gitignorePath)) {
|
|
2116
2170
|
return;
|
|
2117
2171
|
}
|
|
2118
|
-
const hasPython = (0,
|
|
2172
|
+
const hasPython = (0, import_node_fs4.globSync)(
|
|
2119
2173
|
["python-packages/*/pyproject.toml", "apps/*/pyproject.toml", "libs/*/pyproject.toml"],
|
|
2120
2174
|
{ cwd: workspaceRoot }
|
|
2121
2175
|
).length > 0;
|
|
2122
2176
|
if (!hasPython) {
|
|
2123
2177
|
return;
|
|
2124
2178
|
}
|
|
2125
|
-
const current = (0,
|
|
2179
|
+
const current = (0, import_node_fs4.readFileSync)(gitignorePath, "utf8");
|
|
2126
2180
|
const present = new Set(current.split("\n").map((line) => line.trim()));
|
|
2127
2181
|
const missing = PYTHON_ARTEFACT_IGNORES.filter((line) => !present.has(line));
|
|
2128
2182
|
if (missing.length === 0) {
|
|
@@ -2142,11 +2196,11 @@ ${missing.join("\n")}
|
|
|
2142
2196
|
);
|
|
2143
2197
|
}
|
|
2144
2198
|
function removeProjectEslintConfigs(workspaceRoot) {
|
|
2145
|
-
const matches = (0,
|
|
2199
|
+
const matches = (0, import_node_fs4.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
2146
2200
|
cwd: workspaceRoot
|
|
2147
2201
|
});
|
|
2148
2202
|
for (const match of matches) {
|
|
2149
|
-
(0,
|
|
2203
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, match), { force: true });
|
|
2150
2204
|
}
|
|
2151
2205
|
}
|
|
2152
2206
|
function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
@@ -2258,7 +2312,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2258
2312
|
)
|
|
2259
2313
|
);
|
|
2260
2314
|
if (options.workspaceName !== "undefined") {
|
|
2261
|
-
(0,
|
|
2315
|
+
(0, import_node_fs4.rmSync)((0, import_node_path3.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
|
|
2262
2316
|
}
|
|
2263
2317
|
const publishUrl = pythonPublishUrl(options.registry);
|
|
2264
2318
|
const nugetUrl = nugetFeedUrl(options.registry);
|
|
@@ -2288,11 +2342,83 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2288
2342
|
}
|
|
2289
2343
|
}
|
|
2290
2344
|
|
|
2345
|
+
// src/ci-pipeline/native.use-case.ts
|
|
2346
|
+
function runNative(workspaceRoot, dependencies = {}) {
|
|
2347
|
+
const environment = dependencies.environment ?? process.env;
|
|
2348
|
+
const processes = dependencies.processes ?? {
|
|
2349
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2350
|
+
capture: (command, arguments_) => runCapture(command, arguments_, workspaceRoot)
|
|
2351
|
+
};
|
|
2352
|
+
const log = dependencies.log ?? ((message) => {
|
|
2353
|
+
console.log(message);
|
|
2354
|
+
});
|
|
2355
|
+
const host = detectCiHost(environment);
|
|
2356
|
+
const inGroup = (title, command, arguments_) => {
|
|
2357
|
+
log(groupStart(host, title));
|
|
2358
|
+
const status = processes.run(command, arguments_);
|
|
2359
|
+
const closing = groupEnd(host);
|
|
2360
|
+
if (closing !== void 0) {
|
|
2361
|
+
log(closing);
|
|
2362
|
+
}
|
|
2363
|
+
return status;
|
|
2364
|
+
};
|
|
2365
|
+
const built = inGroup("Lint, test, build and package the native apps", "npx", ["nx", "run-many", "-t", NATIVE_TARGETS, `--projects=tag:${GO_CGO_TAG}`]);
|
|
2366
|
+
if (built !== 0) {
|
|
2367
|
+
return built;
|
|
2368
|
+
}
|
|
2369
|
+
if (!isMainPush(environment) || !(0, import_node_fs5.existsSync)((0, import_node_path4.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2370
|
+
return 0;
|
|
2371
|
+
}
|
|
2372
|
+
return inGroup("Attach this OS's zip to the GitHub Release", "node", ["tools/go-app-release.cjs", "assets", "--native"]);
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
// src/ci-pipeline/pack.use-case.ts
|
|
2376
|
+
var import_node_fs6 = require("fs");
|
|
2377
|
+
var import_node_path5 = require("path");
|
|
2378
|
+
function hasAppToPack(workspaceRoot) {
|
|
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) => {
|
|
2381
|
+
try {
|
|
2382
|
+
const parsed = JSON.parse((0, import_node_fs6.readFileSync)((0, import_node_path5.join)(workspaceRoot, manifest), "utf8"));
|
|
2383
|
+
return Boolean(parsed.nx);
|
|
2384
|
+
} catch {
|
|
2385
|
+
return false;
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
const hasCsproj = (0, import_node_fs6.globSync)("apps/*/*.csproj", { cwd: workspaceRoot }).length > 0;
|
|
2389
|
+
return hasProjectJson || hasInlineNx || hasCsproj;
|
|
2390
|
+
}
|
|
2391
|
+
function runPack(workspaceRoot, dependencies = {}) {
|
|
2392
|
+
const environment = dependencies.environment ?? process.env;
|
|
2393
|
+
const processes = dependencies.processes ?? {
|
|
2394
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2395
|
+
capture: () => ({ status: 1, stdout: "" })
|
|
2396
|
+
};
|
|
2397
|
+
const log = dependencies.log ?? ((message) => {
|
|
2398
|
+
console.log(message);
|
|
2399
|
+
});
|
|
2400
|
+
const host = detectCiHost(environment);
|
|
2401
|
+
(0, import_node_fs6.mkdirSync)((0, import_node_path5.join)(workspaceRoot, "dist", "drop"), { recursive: true });
|
|
2402
|
+
if (!hasAppToPack(workspaceRoot)) {
|
|
2403
|
+
log("No apps to pack - skipping.");
|
|
2404
|
+
return 0;
|
|
2405
|
+
}
|
|
2406
|
+
log(groupStart(host, "Pack all apps"));
|
|
2407
|
+
const status = processes.run("npx", ["nx", "run-many", "-t", "package"]);
|
|
2408
|
+
const closing = groupEnd(host);
|
|
2409
|
+
if (closing !== void 0) {
|
|
2410
|
+
log(closing);
|
|
2411
|
+
}
|
|
2412
|
+
return status;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2291
2415
|
// src/ci-pipeline/release.use-case.ts
|
|
2416
|
+
var import_node_fs7 = require("fs");
|
|
2417
|
+
var import_node_path6 = require("path");
|
|
2292
2418
|
var SPECIFIER = /^(?:major|minor|patch|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2293
2419
|
function hasTag(workspaceRoot, relativePath, tag) {
|
|
2294
2420
|
try {
|
|
2295
|
-
const parsed = JSON.parse((0,
|
|
2421
|
+
const parsed = JSON.parse((0, import_node_fs7.readFileSync)((0, import_node_path6.join)(workspaceRoot, relativePath), "utf8"));
|
|
2296
2422
|
const tags = relativePath.endsWith("project.json") ? parsed.tags : parsed.nx?.tags;
|
|
2297
2423
|
return Array.isArray(tags) && tags.includes(tag);
|
|
2298
2424
|
} catch {
|
|
@@ -2301,12 +2427,12 @@ function hasTag(workspaceRoot, relativePath, tag) {
|
|
|
2301
2427
|
}
|
|
2302
2428
|
function releasableCounts(workspaceRoot) {
|
|
2303
2429
|
return {
|
|
2304
|
-
npm: (0,
|
|
2305
|
-
csharp: (0,
|
|
2306
|
-
python: (0,
|
|
2307
|
-
dart: (0,
|
|
2308
|
-
vscode: (0,
|
|
2309
|
-
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
|
|
2310
2436
|
};
|
|
2311
2437
|
}
|
|
2312
2438
|
function shallowCloneGuard(processes, log) {
|
|
@@ -2322,7 +2448,7 @@ function shallowCloneGuard(processes, log) {
|
|
|
2322
2448
|
return 0;
|
|
2323
2449
|
}
|
|
2324
2450
|
function npmPreflight(workspaceRoot, registryKind, environment, processes, log) {
|
|
2325
|
-
if (registryKind !== "npm" || (0,
|
|
2451
|
+
if (registryKind !== "npm" || (0, import_node_fs7.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length === 0) {
|
|
2326
2452
|
return 0;
|
|
2327
2453
|
}
|
|
2328
2454
|
if (!environment.NODE_AUTH_TOKEN) {
|
|
@@ -2338,7 +2464,7 @@ function npmPreflight(workspaceRoot, registryKind, environment, processes, log)
|
|
|
2338
2464
|
return 0;
|
|
2339
2465
|
}
|
|
2340
2466
|
async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetchStatus) {
|
|
2341
|
-
const files = (0,
|
|
2467
|
+
const files = (0, import_node_fs7.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot });
|
|
2342
2468
|
if (registryKind !== "npm" || files.length === 0) {
|
|
2343
2469
|
return 0;
|
|
2344
2470
|
}
|
|
@@ -2351,7 +2477,7 @@ async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetc
|
|
|
2351
2477
|
return 1;
|
|
2352
2478
|
}
|
|
2353
2479
|
const names = files.map((file) => {
|
|
2354
|
-
const text = (0,
|
|
2480
|
+
const text = (0, import_node_fs7.readFileSync)((0, import_node_path6.join)(workspaceRoot, file), "utf8");
|
|
2355
2481
|
const block = text.slice(text.indexOf("[project]"));
|
|
2356
2482
|
const line = block.split("\n").find((entry) => entry.trimStart().startsWith("name"));
|
|
2357
2483
|
return line ? line.split("=", 2)[1].replaceAll(/[^\w.-]/gi, "") : "";
|
|
@@ -2424,6 +2550,15 @@ function runReleaseCommand(workspaceRoot, registry, counts, environment, process
|
|
|
2424
2550
|
}
|
|
2425
2551
|
return processes.run("npx", ["nx", "release", ...extra, "--yes"]);
|
|
2426
2552
|
}
|
|
2553
|
+
function afterRelease(workspaceRoot, processes) {
|
|
2554
|
+
if ((0, import_node_fs7.existsSync)((0, import_node_path6.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2555
|
+
const assets = processes.run("node", ["tools/go-app-release.cjs", "assets"]);
|
|
2556
|
+
if (assets !== 0) {
|
|
2557
|
+
return assets;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
return processes.run("git", ["push", "origin", "--tags"]);
|
|
2561
|
+
}
|
|
2427
2562
|
async function runRelease(workspaceRoot, dependencies = {}) {
|
|
2428
2563
|
const environment = dependencies.environment ?? process.env;
|
|
2429
2564
|
const processes = dependencies.processes ?? {
|
|
@@ -2459,7 +2594,226 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2459
2594
|
if (pypi !== 0) {
|
|
2460
2595
|
return close(pypi);
|
|
2461
2596
|
}
|
|
2462
|
-
|
|
2597
|
+
const released = runReleaseCommand(workspaceRoot, registry, releasableCounts(workspaceRoot), environment, processes, log);
|
|
2598
|
+
if (released !== 0) {
|
|
2599
|
+
return close(released);
|
|
2600
|
+
}
|
|
2601
|
+
return close(afterRelease(workspaceRoot, processes));
|
|
2602
|
+
}
|
|
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;
|
|
2463
2817
|
}
|
|
2464
2818
|
|
|
2465
2819
|
// src/ci-pipeline/verify.use-case.ts
|
|
@@ -2513,7 +2867,7 @@ function runVerify(workspaceRoot, dependencies = {}) {
|
|
|
2513
2867
|
}
|
|
2514
2868
|
|
|
2515
2869
|
// src/ci-pipeline/index.ts
|
|
2516
|
-
var CI_PHASES = ["verify", "pack", "release"];
|
|
2870
|
+
var CI_PHASES = ["setup", "audit", "verify", "pack", "release", "native"];
|
|
2517
2871
|
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
2518
2872
|
switch (phase) {
|
|
2519
2873
|
case "verify": {
|
|
@@ -2525,11 +2879,20 @@ function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
|
2525
2879
|
case "release": {
|
|
2526
2880
|
return runRelease(workspaceRoot, dependencies);
|
|
2527
2881
|
}
|
|
2882
|
+
case "native": {
|
|
2883
|
+
return runNative(workspaceRoot, dependencies);
|
|
2884
|
+
}
|
|
2885
|
+
case "setup": {
|
|
2886
|
+
return runSetup(workspaceRoot, dependencies);
|
|
2887
|
+
}
|
|
2888
|
+
case "audit": {
|
|
2889
|
+
return runAudit(workspaceRoot, dependencies);
|
|
2890
|
+
}
|
|
2528
2891
|
}
|
|
2529
2892
|
}
|
|
2530
2893
|
|
|
2531
2894
|
// src/project-scaffolding/add-project.use-case.ts
|
|
2532
|
-
var
|
|
2895
|
+
var import_node_path30 = require("path");
|
|
2533
2896
|
var import_prompts3 = require("@inquirer/prompts");
|
|
2534
2897
|
|
|
2535
2898
|
// src/project-name/project-name.validator.ts
|
|
@@ -2542,8 +2905,8 @@ function assertValidProjectName(name, label) {
|
|
|
2542
2905
|
}
|
|
2543
2906
|
|
|
2544
2907
|
// src/project-scaffolding/csharp.use-case.ts
|
|
2545
|
-
var
|
|
2546
|
-
var
|
|
2908
|
+
var import_node_fs12 = require("fs");
|
|
2909
|
+
var import_node_path11 = require("path");
|
|
2547
2910
|
|
|
2548
2911
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
2549
2912
|
function csharpExampleFiles(identity) {
|
|
@@ -2584,10 +2947,10 @@ public class GreetUseCaseTests
|
|
|
2584
2947
|
}
|
|
2585
2948
|
|
|
2586
2949
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2587
|
-
var
|
|
2588
|
-
var
|
|
2950
|
+
var import_node_fs11 = require("fs");
|
|
2951
|
+
var import_node_path10 = require("path");
|
|
2589
2952
|
function hasPlugin(workspaceRoot, packageName) {
|
|
2590
|
-
const manifest = readJson((0,
|
|
2953
|
+
const manifest = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2591
2954
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
2592
2955
|
return Object.hasOwn(installed, packageName);
|
|
2593
2956
|
}
|
|
@@ -2626,7 +2989,7 @@ function markPublic(manifestPath) {
|
|
|
2626
2989
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
2627
2990
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
2628
2991
|
writeFileEnsured(
|
|
2629
|
-
(0,
|
|
2992
|
+
(0, import_node_path10.join)(projectRoot, "README.md"),
|
|
2630
2993
|
[
|
|
2631
2994
|
`# ${projectName}`,
|
|
2632
2995
|
"",
|
|
@@ -2645,13 +3008,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
2645
3008
|
}
|
|
2646
3009
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
2647
3010
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
2648
|
-
const directory = (0,
|
|
3011
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, scaffold);
|
|
2649
3012
|
try {
|
|
2650
|
-
const holdsAProject = (0,
|
|
3013
|
+
const holdsAProject = (0, import_node_fs11.readdirSync)(directory, { withFileTypes: true }).some(
|
|
2651
3014
|
(entry) => entry.isDirectory()
|
|
2652
3015
|
);
|
|
2653
3016
|
if (holdsAProject) {
|
|
2654
|
-
(0,
|
|
3017
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(directory, ".gitkeep"), { force: true });
|
|
2655
3018
|
}
|
|
2656
3019
|
} catch {
|
|
2657
3020
|
}
|
|
@@ -2671,7 +3034,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
2671
3034
|
}
|
|
2672
3035
|
}
|
|
2673
3036
|
function defaultScope(workspaceRoot) {
|
|
2674
|
-
const { name } = readJson((0,
|
|
3037
|
+
const { name } = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2675
3038
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
2676
3039
|
return `@${base}`;
|
|
2677
3040
|
}
|
|
@@ -2699,14 +3062,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
2699
3062
|
];
|
|
2700
3063
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
2701
3064
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
2702
|
-
(0,
|
|
3065
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
2703
3066
|
}
|
|
2704
|
-
(0,
|
|
3067
|
+
(0, import_node_fs11.rmSync)((0, import_node_path10.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
2705
3068
|
}
|
|
2706
3069
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
2707
3070
|
try {
|
|
2708
|
-
const entry = (0,
|
|
2709
|
-
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;
|
|
2710
3073
|
} catch {
|
|
2711
3074
|
return void 0;
|
|
2712
3075
|
}
|
|
@@ -2723,8 +3086,8 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
2723
3086
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component", empty);
|
|
2724
3087
|
}
|
|
2725
3088
|
function reshapeReactAppScaffold(projectRoot) {
|
|
2726
|
-
const appDir = (0,
|
|
2727
|
-
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"))) {
|
|
2728
3091
|
return;
|
|
2729
3092
|
}
|
|
2730
3093
|
for (const [from, to] of [
|
|
@@ -2732,60 +3095,60 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
2732
3095
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
2733
3096
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
2734
3097
|
]) {
|
|
2735
|
-
if ((0,
|
|
2736
|
-
(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));
|
|
2737
3100
|
}
|
|
2738
3101
|
}
|
|
2739
3102
|
const rewrite = (file, from, to) => {
|
|
2740
|
-
if ((0,
|
|
2741
|
-
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));
|
|
2742
3105
|
}
|
|
2743
3106
|
};
|
|
2744
|
-
rewrite((0,
|
|
2745
|
-
rewrite((0,
|
|
2746
|
-
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");
|
|
2747
3110
|
writeFileEnsured(
|
|
2748
|
-
(0,
|
|
3111
|
+
(0, import_node_path10.join)(appDir, "index.ts"),
|
|
2749
3112
|
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
2750
3113
|
);
|
|
2751
3114
|
}
|
|
2752
3115
|
function emptySlice(projectRoot, sliceDir) {
|
|
2753
|
-
for (const entry of (0,
|
|
2754
|
-
(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 });
|
|
2755
3118
|
}
|
|
2756
|
-
writeFileEnsured((0,
|
|
2757
|
-
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 } } });
|
|
2758
3121
|
}
|
|
2759
3122
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
2760
|
-
const sourceDir = (0,
|
|
2761
|
-
const libDir = (0,
|
|
2762
|
-
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}`))) {
|
|
2763
3126
|
return;
|
|
2764
3127
|
}
|
|
2765
|
-
const sliceDir = (0,
|
|
2766
|
-
(0,
|
|
2767
|
-
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)) {
|
|
2768
3131
|
if (entry === `${name}.${extension}`) {
|
|
2769
|
-
(0,
|
|
3132
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(libDir, entry), (0, import_node_path10.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
2770
3133
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
2771
|
-
const renamed = (0,
|
|
2772
|
-
(0,
|
|
2773
|
-
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}`));
|
|
2774
3137
|
} else {
|
|
2775
|
-
(0,
|
|
3138
|
+
(0, import_node_fs11.renameSync)((0, import_node_path10.join)(libDir, entry), (0, import_node_path10.join)(sliceDir, entry));
|
|
2776
3139
|
}
|
|
2777
3140
|
}
|
|
2778
|
-
const barrel = (0,
|
|
2779
|
-
const esm = (0,
|
|
2780
|
-
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" : ""}'
|
|
2781
3144
|
`);
|
|
2782
|
-
if ((0,
|
|
3145
|
+
if ((0, import_node_fs11.existsSync)(barrel)) {
|
|
2783
3146
|
writeFileEnsured(
|
|
2784
3147
|
barrel,
|
|
2785
|
-
(0,
|
|
3148
|
+
(0, import_node_fs11.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2786
3149
|
);
|
|
2787
3150
|
}
|
|
2788
|
-
(0,
|
|
3151
|
+
(0, import_node_fs11.rmSync)(libDir, { recursive: true, force: true });
|
|
2789
3152
|
if (empty) {
|
|
2790
3153
|
emptySlice(projectRoot, sliceDir);
|
|
2791
3154
|
} else if (role === "use-case") {
|
|
@@ -2795,7 +3158,7 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
2795
3158
|
function writeWorkedExample(sliceDir, name, esm) {
|
|
2796
3159
|
const suffix = esm ? ".js" : "";
|
|
2797
3160
|
writeFileEnsured(
|
|
2798
|
-
(0,
|
|
3161
|
+
(0, import_node_path10.join)(sliceDir, `${name}.contract.ts`),
|
|
2799
3162
|
`/** What greeting someone returns. */
|
|
2800
3163
|
export interface Greeting {
|
|
2801
3164
|
readonly message: string
|
|
@@ -2803,7 +3166,7 @@ export interface Greeting {
|
|
|
2803
3166
|
`
|
|
2804
3167
|
);
|
|
2805
3168
|
writeFileEnsured(
|
|
2806
|
-
(0,
|
|
3169
|
+
(0, import_node_path10.join)(sliceDir, `${name}.use-case.ts`),
|
|
2807
3170
|
`import type { Greeting } from './${name}.contract${suffix}'
|
|
2808
3171
|
|
|
2809
3172
|
/**
|
|
@@ -2822,7 +3185,7 @@ export function greet (name: string): Greeting {
|
|
|
2822
3185
|
`
|
|
2823
3186
|
);
|
|
2824
3187
|
writeFileEnsured(
|
|
2825
|
-
(0,
|
|
3188
|
+
(0, import_node_path10.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
2826
3189
|
`import { greet } from './${name}.use-case${suffix}'
|
|
2827
3190
|
|
|
2828
3191
|
describe('greet', () => {
|
|
@@ -2833,7 +3196,7 @@ describe('greet', () => {
|
|
|
2833
3196
|
`
|
|
2834
3197
|
);
|
|
2835
3198
|
writeFileEnsured(
|
|
2836
|
-
(0,
|
|
3199
|
+
(0, import_node_path10.join)(sliceDir, "index.ts"),
|
|
2837
3200
|
`export * from './${name}.contract${suffix}'
|
|
2838
3201
|
export * from './${name}.use-case${suffix}'
|
|
2839
3202
|
`
|
|
@@ -2847,8 +3210,8 @@ function repointSpecifier(source, from, to) {
|
|
|
2847
3210
|
return result;
|
|
2848
3211
|
}
|
|
2849
3212
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2850
|
-
const manifestPath = (0,
|
|
2851
|
-
if (!(0,
|
|
3213
|
+
const manifestPath = (0, import_node_path10.join)(workspaceRoot, "package.json");
|
|
3214
|
+
if (!(0, import_node_fs11.existsSync)(manifestPath)) {
|
|
2852
3215
|
return;
|
|
2853
3216
|
}
|
|
2854
3217
|
const manifest = readJson(manifestPath);
|
|
@@ -2871,11 +3234,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2871
3234
|
if (commands.start) {
|
|
2872
3235
|
scripts[`${name}:start`] = commands.start;
|
|
2873
3236
|
}
|
|
2874
|
-
const dependabotPath = (0,
|
|
2875
|
-
if ((0,
|
|
3237
|
+
const dependabotPath = (0, import_node_path10.join)(workspaceRoot, ".github/dependabot.yml");
|
|
3238
|
+
if ((0, import_node_fs11.existsSync)(dependabotPath)) {
|
|
2876
3239
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
2877
3240
|
}
|
|
2878
|
-
const manifestPath = (0,
|
|
3241
|
+
const manifestPath = (0, import_node_path10.join)(workspaceRoot, "package.json");
|
|
2879
3242
|
const manifest = readJson(manifestPath);
|
|
2880
3243
|
const existingScripts = manifest.scripts ?? {};
|
|
2881
3244
|
writeFileEnsured(
|
|
@@ -2913,7 +3276,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2913
3276
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
2914
3277
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
2915
3278
|
try {
|
|
2916
|
-
return readJson((0,
|
|
3279
|
+
return readJson((0, import_node_path10.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
2917
3280
|
} catch {
|
|
2918
3281
|
return {};
|
|
2919
3282
|
}
|
|
@@ -2925,7 +3288,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2925
3288
|
return;
|
|
2926
3289
|
}
|
|
2927
3290
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
2928
|
-
(root) => (0,
|
|
3291
|
+
(root) => (0, import_node_path10.join)(workspaceRoot, root, projectName, "package.json")
|
|
2929
3292
|
).find((candidate) => fileExists(candidate));
|
|
2930
3293
|
if (manifestPath === void 0) {
|
|
2931
3294
|
return;
|
|
@@ -2937,10 +3300,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2937
3300
|
const remaining = Object.fromEntries(
|
|
2938
3301
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
2939
3302
|
);
|
|
2940
|
-
const rootManifest = readJson((0,
|
|
3303
|
+
const rootManifest = readJson((0, import_node_path10.join)(workspaceRoot, "package.json"));
|
|
2941
3304
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
2942
3305
|
writeFileEnsured(
|
|
2943
|
-
(0,
|
|
3306
|
+
(0, import_node_path10.join)(workspaceRoot, "package.json"),
|
|
2944
3307
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
2945
3308
|
);
|
|
2946
3309
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -2979,28 +3342,28 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
2979
3342
|
}
|
|
2980
3343
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
2981
3344
|
if (kind === "classlib") {
|
|
2982
|
-
(0,
|
|
3345
|
+
(0, import_node_fs12.rmSync)((0, import_node_path11.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
2983
3346
|
}
|
|
2984
3347
|
const files = csharpExampleFiles(identity);
|
|
2985
3348
|
for (const [file, contents] of Object.entries(files)) {
|
|
2986
|
-
writeFileEnsured((0,
|
|
3349
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, file), contents);
|
|
2987
3350
|
}
|
|
2988
3351
|
if (kind === "console") {
|
|
2989
|
-
writeFileEnsured((0,
|
|
3352
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
2990
3353
|
}
|
|
2991
3354
|
}
|
|
2992
3355
|
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
2993
|
-
const name = (0,
|
|
3356
|
+
const name = (0, import_node_path11.basename)(projectRoot);
|
|
2994
3357
|
const testRoot = `tests/${name}`;
|
|
2995
3358
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
2996
|
-
(0,
|
|
2997
|
-
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));
|
|
2998
3361
|
writeFileEnsured(
|
|
2999
|
-
(0,
|
|
3362
|
+
(0, import_node_path11.join)(workspaceRoot, testRoot, "project.json"),
|
|
3000
3363
|
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
3001
3364
|
);
|
|
3002
|
-
const reference = (0,
|
|
3003
|
-
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) {
|
|
3004
3367
|
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
3005
3368
|
}
|
|
3006
3369
|
}
|
|
@@ -3027,9 +3390,9 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
3027
3390
|
ensureAdmZip(workspaceRoot);
|
|
3028
3391
|
const projectRoot = `apps/${name}`;
|
|
3029
3392
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
3030
|
-
writeCsharpExample((0,
|
|
3393
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3031
3394
|
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
3032
|
-
addProjectJsonTargets((0,
|
|
3395
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3033
3396
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
3034
3397
|
start: csharpAppStartTarget(projectRoot)
|
|
3035
3398
|
});
|
|
@@ -3122,7 +3485,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
3122
3485
|
module.exports = CsharpVersionActions
|
|
3123
3486
|
`;
|
|
3124
3487
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
3125
|
-
writeFileEnsured((0,
|
|
3488
|
+
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
3126
3489
|
}
|
|
3127
3490
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
3128
3491
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -3137,7 +3500,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3137
3500
|
);
|
|
3138
3501
|
}
|
|
3139
3502
|
function addInitialVersion(csprojPath) {
|
|
3140
|
-
const contents = (0,
|
|
3503
|
+
const contents = (0, import_node_fs12.readFileSync)(csprojPath, "utf8");
|
|
3141
3504
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3142
3505
|
}
|
|
3143
3506
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3152,16 +3515,16 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3152
3515
|
const projectRoot = `packages/${name}`;
|
|
3153
3516
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3154
3517
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3155
|
-
writeCsharpExample((0,
|
|
3518
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3156
3519
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3157
|
-
addInitialVersion((0,
|
|
3520
|
+
addInitialVersion((0, import_node_path11.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3158
3521
|
writeCsharpVersionActions(workspaceRoot);
|
|
3159
|
-
addProjectJsonReleaseVersionActions((0,
|
|
3160
|
-
addProjectJsonTargets((0,
|
|
3522
|
+
addProjectJsonReleaseVersionActions((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"));
|
|
3523
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3161
3524
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
3162
3525
|
});
|
|
3163
3526
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
3164
|
-
writeFileEnsured((0,
|
|
3527
|
+
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
3165
3528
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
3166
3529
|
}
|
|
3167
3530
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -3170,7 +3533,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3170
3533
|
const projectRoot = `libs/${name}`;
|
|
3171
3534
|
const identity = pascalCase(name);
|
|
3172
3535
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3173
|
-
writeCsharpExample((0,
|
|
3536
|
+
writeCsharpExample((0, import_node_path11.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3174
3537
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3175
3538
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3176
3539
|
logger.step(
|
|
@@ -3239,20 +3602,20 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3239
3602
|
const projectRoot = `apps/${name}`;
|
|
3240
3603
|
const identity = pascalCase(name);
|
|
3241
3604
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
3242
|
-
const absoluteRoot = (0,
|
|
3243
|
-
writeFileEnsured((0,
|
|
3244
|
-
writeFileEnsured((0,
|
|
3245
|
-
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));
|
|
3246
3609
|
const example = csharpExampleFiles(identity);
|
|
3247
3610
|
for (const [file, contents] of Object.entries(example)) {
|
|
3248
|
-
writeFileEnsured((0,
|
|
3611
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, file), contents);
|
|
3249
3612
|
}
|
|
3250
|
-
writeFileEnsured((0,
|
|
3613
|
+
writeFileEnsured((0, import_node_path11.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3251
3614
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3252
3615
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3253
3616
|
}
|
|
3254
3617
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3255
|
-
addProjectJsonTargets((0,
|
|
3618
|
+
addProjectJsonTargets((0, import_node_path11.join)(absoluteRoot, "project.json"), {
|
|
3256
3619
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3257
3620
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
3258
3621
|
});
|
|
@@ -3260,7 +3623,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3260
3623
|
}
|
|
3261
3624
|
|
|
3262
3625
|
// src/project-scaffolding/flutter.use-case.ts
|
|
3263
|
-
var
|
|
3626
|
+
var import_node_path12 = require("path");
|
|
3264
3627
|
function flutterAppStartTarget(name) {
|
|
3265
3628
|
return {
|
|
3266
3629
|
executor: "nx:run-commands",
|
|
@@ -3296,7 +3659,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
3296
3659
|
prepareFlutter(workspaceRoot);
|
|
3297
3660
|
ensureAdmZip(workspaceRoot);
|
|
3298
3661
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
3299
|
-
addProjectJsonTargets((0,
|
|
3662
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3300
3663
|
start: flutterAppStartTarget(name)
|
|
3301
3664
|
});
|
|
3302
3665
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -3313,8 +3676,8 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3313
3676
|
}
|
|
3314
3677
|
|
|
3315
3678
|
// src/project-scaffolding/go.use-case.ts
|
|
3316
|
-
var
|
|
3317
|
-
var
|
|
3679
|
+
var import_node_fs16 = require("fs");
|
|
3680
|
+
var import_node_path16 = require("path");
|
|
3318
3681
|
|
|
3319
3682
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
3320
3683
|
function greetingContract(packageName) {
|
|
@@ -3383,14 +3746,14 @@ function goAppExampleFiles(modulePath) {
|
|
|
3383
3746
|
}
|
|
3384
3747
|
|
|
3385
3748
|
// src/go-workspace/go-plugin.use-case.ts
|
|
3386
|
-
var
|
|
3387
|
-
var
|
|
3749
|
+
var import_node_fs13 = require("fs");
|
|
3750
|
+
var import_node_path13 = require("path");
|
|
3388
3751
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
3389
3752
|
function hasGoProject(workspaceRoot) {
|
|
3390
|
-
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 }));
|
|
3391
3754
|
return projectFiles.some((projectFile) => {
|
|
3392
3755
|
try {
|
|
3393
|
-
const { tags } = JSON.parse((0,
|
|
3756
|
+
const { tags } = JSON.parse((0, import_node_fs13.readFileSync)((0, import_node_path13.join)(workspaceRoot, projectFile), "utf8"));
|
|
3394
3757
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
3395
3758
|
} catch {
|
|
3396
3759
|
return false;
|
|
@@ -3398,7 +3761,7 @@ function hasGoProject(workspaceRoot) {
|
|
|
3398
3761
|
});
|
|
3399
3762
|
}
|
|
3400
3763
|
function isNxGoPluginRegistered(workspaceRoot) {
|
|
3401
|
-
const nxJsonPath = (0,
|
|
3764
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3402
3765
|
if (!fileExists(nxJsonPath)) {
|
|
3403
3766
|
return false;
|
|
3404
3767
|
}
|
|
@@ -3425,7 +3788,7 @@ function goModulePrefix(workspaceRoot) {
|
|
|
3425
3788
|
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
3426
3789
|
}
|
|
3427
3790
|
function registerNxGoPlugin(workspaceRoot) {
|
|
3428
|
-
const nxJsonPath = (0,
|
|
3791
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3429
3792
|
if (!fileExists(nxJsonPath)) {
|
|
3430
3793
|
return false;
|
|
3431
3794
|
}
|
|
@@ -3449,8 +3812,8 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3449
3812
|
}
|
|
3450
3813
|
|
|
3451
3814
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3452
|
-
var
|
|
3453
|
-
var
|
|
3815
|
+
var import_node_fs14 = require("fs");
|
|
3816
|
+
var import_node_path14 = require("path");
|
|
3454
3817
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3455
3818
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3456
3819
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -3576,7 +3939,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
3576
3939
|
}
|
|
3577
3940
|
};
|
|
3578
3941
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
3579
|
-
const projectJsonPath = (0,
|
|
3942
|
+
const projectJsonPath = (0, import_node_path14.join)(workspaceRoot, "apps", name, "project.json");
|
|
3580
3943
|
if (!fileExists(projectJsonPath)) {
|
|
3581
3944
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
3582
3945
|
}
|
|
@@ -3597,22 +3960,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
3597
3960
|
}
|
|
3598
3961
|
})
|
|
3599
3962
|
);
|
|
3600
|
-
writeFileEnsured((0,
|
|
3963
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
3601
3964
|
}
|
|
3602
3965
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
3603
|
-
const apps = (0,
|
|
3966
|
+
const apps = (0, import_node_path14.join)(workspaceRoot, "apps");
|
|
3604
3967
|
let entries;
|
|
3605
3968
|
try {
|
|
3606
|
-
entries = (0,
|
|
3969
|
+
entries = (0, import_node_fs14.readdirSync)(apps);
|
|
3607
3970
|
} catch {
|
|
3608
3971
|
return false;
|
|
3609
3972
|
}
|
|
3610
3973
|
const hasReleasableApp = entries.some((entry) => {
|
|
3611
|
-
const projectJsonPath = (0,
|
|
3974
|
+
const projectJsonPath = (0, import_node_path14.join)(apps, entry, "project.json");
|
|
3612
3975
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3613
3976
|
});
|
|
3614
|
-
const path = (0,
|
|
3615
|
-
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) {
|
|
3616
3979
|
return false;
|
|
3617
3980
|
}
|
|
3618
3981
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3620,8 +3983,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3620
3983
|
}
|
|
3621
3984
|
|
|
3622
3985
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3623
|
-
var
|
|
3624
|
-
var
|
|
3986
|
+
var import_node_fs15 = require("fs");
|
|
3987
|
+
var import_node_path15 = require("path");
|
|
3625
3988
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3626
3989
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
3627
3990
|
var GO_WEB_SOURCE = `package main
|
|
@@ -3699,18 +4062,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
3699
4062
|
}
|
|
3700
4063
|
`;
|
|
3701
4064
|
function assertWebApp(workspaceRoot, web) {
|
|
3702
|
-
const directory = (0,
|
|
3703
|
-
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."));
|
|
3704
4067
|
if (!isReactApp) {
|
|
3705
4068
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
3706
4069
|
}
|
|
3707
4070
|
}
|
|
3708
4071
|
function webProjectName(workspaceRoot, web) {
|
|
3709
|
-
const manifest = readJson((0,
|
|
4072
|
+
const manifest = readJson((0, import_node_path15.join)(workspaceRoot, "apps", web, "package.json"));
|
|
3710
4073
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
3711
4074
|
}
|
|
3712
4075
|
function addApiProxy(viteConfigPath) {
|
|
3713
|
-
const source = (0,
|
|
4076
|
+
const source = (0, import_node_fs15.readFileSync)(viteConfigPath, "utf8");
|
|
3714
4077
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
3715
4078
|
return false;
|
|
3716
4079
|
}
|
|
@@ -3723,7 +4086,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
3723
4086
|
return true;
|
|
3724
4087
|
}
|
|
3725
4088
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
3726
|
-
const projectJsonPath = (0,
|
|
4089
|
+
const projectJsonPath = (0, import_node_path15.join)(workspaceRoot, "apps", name, "project.json");
|
|
3727
4090
|
const project = readJson(projectJsonPath);
|
|
3728
4091
|
const webName = webProjectName(workspaceRoot, web);
|
|
3729
4092
|
const targets = project.targets ?? {};
|
|
@@ -3749,13 +4112,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
3749
4112
|
projectJsonPath,
|
|
3750
4113
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
3751
4114
|
);
|
|
3752
|
-
const directory = (0,
|
|
3753
|
-
writeFileEnsured((0,
|
|
3754
|
-
writeFileEnsured((0,
|
|
3755
|
-
writeFileEnsured((0,
|
|
3756
|
-
writeFileEnsured((0,
|
|
3757
|
-
const viteConfig = (0,
|
|
3758
|
-
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))) {
|
|
3759
4122
|
logger.warn(
|
|
3760
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.`
|
|
3761
4124
|
);
|
|
@@ -3789,7 +4152,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
3789
4152
|
}
|
|
3790
4153
|
}
|
|
3791
4154
|
function ensureGoModule(workspaceRoot) {
|
|
3792
|
-
if (fileExists((0,
|
|
4155
|
+
if (fileExists((0, import_node_path16.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path16.join)(workspaceRoot, "go.mod"))) {
|
|
3793
4156
|
return;
|
|
3794
4157
|
}
|
|
3795
4158
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -3797,38 +4160,38 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3797
4160
|
}
|
|
3798
4161
|
function readGoModModule(goModPath) {
|
|
3799
4162
|
try {
|
|
3800
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
4163
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs16.readFileSync)(goModPath, "utf8"))?.[1];
|
|
3801
4164
|
} catch {
|
|
3802
4165
|
return void 0;
|
|
3803
4166
|
}
|
|
3804
4167
|
}
|
|
3805
4168
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
3806
|
-
const projectModule = readGoModModule((0,
|
|
4169
|
+
const projectModule = readGoModModule((0, import_node_path16.join)(workspaceRoot, projectDir, "go.mod"));
|
|
3807
4170
|
if (projectModule !== void 0) {
|
|
3808
4171
|
return projectModule;
|
|
3809
4172
|
}
|
|
3810
|
-
const rootModule = readGoModModule((0,
|
|
4173
|
+
const rootModule = readGoModModule((0, import_node_path16.join)(workspaceRoot, "go.mod"));
|
|
3811
4174
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
3812
4175
|
}
|
|
3813
4176
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
3814
4177
|
const prefix = goModulePrefix(workspaceRoot);
|
|
3815
|
-
const goModPath = (0,
|
|
4178
|
+
const goModPath = (0, import_node_path16.join)(workspaceRoot, projectDir, "go.mod");
|
|
3816
4179
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
3817
4180
|
return;
|
|
3818
4181
|
}
|
|
3819
|
-
const rewritten = (0,
|
|
4182
|
+
const rewritten = (0, import_node_fs16.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
3820
4183
|
writeFileEnsured(goModPath, rewritten);
|
|
3821
4184
|
}
|
|
3822
4185
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
3823
|
-
const goModPath = (0,
|
|
3824
|
-
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;
|
|
3825
4188
|
if (modulePath === void 0) {
|
|
3826
4189
|
return;
|
|
3827
4190
|
}
|
|
3828
|
-
(0,
|
|
4191
|
+
(0, import_node_fs16.rmSync)((0, import_node_path16.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
3829
4192
|
const example = goAppExampleFiles(modulePath);
|
|
3830
4193
|
for (const [relative, contents] of Object.entries(example)) {
|
|
3831
|
-
writeFileEnsured((0,
|
|
4194
|
+
writeFileEnsured((0, import_node_path16.join)(workspaceRoot, projectDir, relative), contents);
|
|
3832
4195
|
}
|
|
3833
4196
|
}
|
|
3834
4197
|
function goTestTarget() {
|
|
@@ -3906,16 +4269,16 @@ function goNativePackageTarget(name) {
|
|
|
3906
4269
|
}
|
|
3907
4270
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3908
4271
|
const changed = [];
|
|
3909
|
-
const apps = (0,
|
|
4272
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
3910
4273
|
if (!fileExists(apps)) {
|
|
3911
4274
|
return changed;
|
|
3912
4275
|
}
|
|
3913
|
-
for (const name of (0,
|
|
3914
|
-
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");
|
|
3915
4278
|
if (!fileExists(projectJsonPath)) {
|
|
3916
4279
|
continue;
|
|
3917
4280
|
}
|
|
3918
|
-
const project = JSON.parse((0,
|
|
4281
|
+
const project = JSON.parse((0, import_node_fs16.readFileSync)(projectJsonPath, "utf8"));
|
|
3919
4282
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3920
4283
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3921
4284
|
continue;
|
|
@@ -3951,8 +4314,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
3951
4314
|
}
|
|
3952
4315
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
3953
4316
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
3954
|
-
(0,
|
|
3955
|
-
(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 });
|
|
3956
4319
|
const files = [
|
|
3957
4320
|
[
|
|
3958
4321
|
"doc.go",
|
|
@@ -3962,7 +4325,7 @@ package ${packageName}
|
|
|
3962
4325
|
`
|
|
3963
4326
|
],
|
|
3964
4327
|
[
|
|
3965
|
-
(0,
|
|
4328
|
+
(0, import_node_path16.join)(packageName, "doc.go"),
|
|
3966
4329
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
3967
4330
|
// the outcome it delivers, and add one package per further outcome.
|
|
3968
4331
|
package ${packageName}
|
|
@@ -3970,11 +4333,11 @@ package ${packageName}
|
|
|
3970
4333
|
],
|
|
3971
4334
|
// The starter slice: a contract, a use case and its test (see goLibraryExampleFiles).
|
|
3972
4335
|
...Object.entries(goLibraryExampleFiles(packageName, fileStem)).map(
|
|
3973
|
-
([name, content]) => [(0,
|
|
4336
|
+
([name, content]) => [(0, import_node_path16.join)(packageName, name), content]
|
|
3974
4337
|
)
|
|
3975
4338
|
];
|
|
3976
4339
|
for (const [relativePath, content] of files) {
|
|
3977
|
-
const path = (0,
|
|
4340
|
+
const path = (0, import_node_path16.join)(projectRoot, relativePath);
|
|
3978
4341
|
if (!fileExists(path)) {
|
|
3979
4342
|
writeFileEnsured(path, content);
|
|
3980
4343
|
}
|
|
@@ -4012,7 +4375,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4012
4375
|
if (options.web === void 0) {
|
|
4013
4376
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4014
4377
|
}
|
|
4015
|
-
addProjectJsonTargets((0,
|
|
4378
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4016
4379
|
build: goBuildTarget(name),
|
|
4017
4380
|
test: goTestTarget(),
|
|
4018
4381
|
lint: goLintTarget(),
|
|
@@ -4052,7 +4415,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4052
4415
|
);
|
|
4053
4416
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4054
4417
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4055
|
-
addProjectJsonTargets((0,
|
|
4418
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4056
4419
|
"build": goBuildTarget(name),
|
|
4057
4420
|
"test": goTestTarget(),
|
|
4058
4421
|
"lint": goLintTarget(),
|
|
@@ -4076,11 +4439,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4076
4439
|
workspaceRoot
|
|
4077
4440
|
);
|
|
4078
4441
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4079
|
-
addProjectJsonTargets((0,
|
|
4442
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4080
4443
|
test: goTestTarget(),
|
|
4081
4444
|
lint: goLintTarget()
|
|
4082
4445
|
});
|
|
4083
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4446
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path16.join)(workspaceRoot, "packages", name), name);
|
|
4084
4447
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4085
4448
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
4086
4449
|
if (module2) {
|
|
@@ -4101,11 +4464,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4101
4464
|
workspaceRoot
|
|
4102
4465
|
);
|
|
4103
4466
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4104
|
-
addProjectJsonTargets((0,
|
|
4467
|
+
addProjectJsonTargets((0, import_node_path16.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4105
4468
|
test: goTestTarget(),
|
|
4106
4469
|
lint: goLintTarget()
|
|
4107
4470
|
});
|
|
4108
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4471
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path16.join)(workspaceRoot, "libs", name), name);
|
|
4109
4472
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4110
4473
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
4111
4474
|
if (module2) {
|
|
@@ -4114,7 +4477,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4114
4477
|
}
|
|
4115
4478
|
|
|
4116
4479
|
// src/project-scaffolding/node.use-case.ts
|
|
4117
|
-
var
|
|
4480
|
+
var import_node_path17 = require("path");
|
|
4118
4481
|
|
|
4119
4482
|
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
4120
4483
|
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
@@ -4237,12 +4600,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
4237
4600
|
],
|
|
4238
4601
|
workspaceRoot
|
|
4239
4602
|
);
|
|
4240
|
-
const appRoot = (0,
|
|
4603
|
+
const appRoot = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4241
4604
|
separateDeclarationOutput(appRoot);
|
|
4242
4605
|
repairAssetMapping(appRoot, name);
|
|
4243
4606
|
}
|
|
4244
4607
|
function separateDeclarationOutput(appRoot) {
|
|
4245
|
-
const tsconfigPath = (0,
|
|
4608
|
+
const tsconfigPath = (0, import_node_path17.join)(appRoot, "tsconfig.app.json");
|
|
4246
4609
|
if (!fileExists(tsconfigPath)) {
|
|
4247
4610
|
return;
|
|
4248
4611
|
}
|
|
@@ -4264,7 +4627,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
4264
4627
|
);
|
|
4265
4628
|
}
|
|
4266
4629
|
function repairAssetMapping(appRoot, name) {
|
|
4267
|
-
const manifestPath = (0,
|
|
4630
|
+
const manifestPath = (0, import_node_path17.join)(appRoot, "package.json");
|
|
4268
4631
|
if (!fileExists(manifestPath)) {
|
|
4269
4632
|
return;
|
|
4270
4633
|
}
|
|
@@ -4293,11 +4656,11 @@ function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
|
4293
4656
|
const example = nodeAppExampleFiles(framework);
|
|
4294
4657
|
if (example !== null) {
|
|
4295
4658
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4296
|
-
writeFileEnsured((0,
|
|
4659
|
+
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
4297
4660
|
}
|
|
4298
4661
|
}
|
|
4299
4662
|
ensureAdmZip(workspaceRoot);
|
|
4300
|
-
addNxTargets((0,
|
|
4663
|
+
addNxTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
4301
4664
|
package: nodeAppPackageTarget(name)
|
|
4302
4665
|
});
|
|
4303
4666
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -4366,10 +4729,10 @@ describe('greet', () => {
|
|
|
4366
4729
|
})
|
|
4367
4730
|
`;
|
|
4368
4731
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
4369
|
-
const manifestPath = (0,
|
|
4732
|
+
const manifestPath = (0, import_node_path17.join)(nodeFunctionAppRoot, "package.json");
|
|
4370
4733
|
const manifest = readJson(manifestPath);
|
|
4371
4734
|
const azureFunctionsVersion = readJson(
|
|
4372
|
-
(0,
|
|
4735
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
4373
4736
|
).version;
|
|
4374
4737
|
const dependencies = manifest.dependencies ?? {};
|
|
4375
4738
|
writeFileEnsured(
|
|
@@ -4412,20 +4775,20 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
4412
4775
|
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
4413
4776
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4414
4777
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4415
|
-
const nodeFunctionAppRoot = (0,
|
|
4416
|
-
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);
|
|
4417
4780
|
if (!empty) {
|
|
4418
|
-
const slice = (0,
|
|
4419
|
-
writeFileEnsured((0,
|
|
4420
|
-
writeFileEnsured((0,
|
|
4421
|
-
writeFileEnsured((0,
|
|
4422
|
-
writeFileEnsured((0,
|
|
4423
|
-
writeFileEnsured((0,
|
|
4424
|
-
}
|
|
4425
|
-
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);
|
|
4426
4789
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4427
4790
|
ensureAdmZip(workspaceRoot);
|
|
4428
|
-
addNxTargets((0,
|
|
4791
|
+
addNxTargets((0, import_node_path17.join)(nodeFunctionAppRoot, "package.json"), {
|
|
4429
4792
|
package: nodeFunctionAppPackageTarget(name),
|
|
4430
4793
|
prune: nodeFunctionAppPruneTarget(name),
|
|
4431
4794
|
start: nodeFunctionAppStartTarget(name),
|
|
@@ -4437,11 +4800,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
|
4437
4800
|
}
|
|
4438
4801
|
|
|
4439
4802
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4440
|
-
var
|
|
4803
|
+
var import_node_path21 = require("path");
|
|
4441
4804
|
|
|
4442
4805
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
4443
|
-
var
|
|
4444
|
-
var
|
|
4806
|
+
var import_node_fs17 = require("fs");
|
|
4807
|
+
var import_node_path18 = require("path");
|
|
4445
4808
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
4446
4809
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
4447
4810
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -4464,14 +4827,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
4464
4827
|
}
|
|
4465
4828
|
function repairPublishableManifests(workspaceRoot) {
|
|
4466
4829
|
const changed = [];
|
|
4467
|
-
const manifests = (0,
|
|
4830
|
+
const manifests = (0, import_node_fs17.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
4468
4831
|
cwd: workspaceRoot
|
|
4469
4832
|
});
|
|
4470
4833
|
for (const relativePath of manifests) {
|
|
4471
|
-
const manifestPath = (0,
|
|
4472
|
-
const before = (0,
|
|
4834
|
+
const manifestPath = (0, import_node_path18.join)(workspaceRoot, relativePath);
|
|
4835
|
+
const before = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
4473
4836
|
repairPublishableManifest(manifestPath);
|
|
4474
|
-
const after = (0,
|
|
4837
|
+
const after = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
4475
4838
|
if (after !== before) {
|
|
4476
4839
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
4477
4840
|
}
|
|
@@ -4480,8 +4843,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
4480
4843
|
}
|
|
4481
4844
|
|
|
4482
4845
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4483
|
-
var
|
|
4484
|
-
var
|
|
4846
|
+
var import_node_fs18 = require("fs");
|
|
4847
|
+
var import_node_path19 = require("path");
|
|
4485
4848
|
|
|
4486
4849
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
4487
4850
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -4683,12 +5046,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
4683
5046
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4684
5047
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
4685
5048
|
const changed = [];
|
|
4686
|
-
const configs = (0,
|
|
5049
|
+
const configs = (0, import_node_fs18.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4687
5050
|
cwd: workspaceRoot
|
|
4688
5051
|
});
|
|
4689
5052
|
for (const relativePath of configs) {
|
|
4690
|
-
const configPath = (0,
|
|
4691
|
-
const before = (0,
|
|
5053
|
+
const configPath = (0, import_node_path19.join)(workspaceRoot, relativePath);
|
|
5054
|
+
const before = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4692
5055
|
const after = withRollupSourceMaps(before);
|
|
4693
5056
|
if (after !== before) {
|
|
4694
5057
|
writeFileEnsured(configPath, after);
|
|
@@ -4699,12 +5062,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
4699
5062
|
}
|
|
4700
5063
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
4701
5064
|
const changed = [];
|
|
4702
|
-
const configs = (0,
|
|
5065
|
+
const configs = (0, import_node_fs18.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4703
5066
|
cwd: workspaceRoot
|
|
4704
5067
|
});
|
|
4705
5068
|
for (const relativePath of configs) {
|
|
4706
|
-
const configPath = (0,
|
|
4707
|
-
const before = (0,
|
|
5069
|
+
const configPath = (0, import_node_path19.join)(workspaceRoot, relativePath);
|
|
5070
|
+
const before = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4708
5071
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
4709
5072
|
if (after !== before) {
|
|
4710
5073
|
writeFileEnsured(configPath, after);
|
|
@@ -4714,11 +5077,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
4714
5077
|
return changed;
|
|
4715
5078
|
}
|
|
4716
5079
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
4717
|
-
const configPath = (0,
|
|
5080
|
+
const configPath = (0, import_node_path19.join)(projectRoot, "rollup.config.cjs");
|
|
4718
5081
|
if (!fileExists(configPath)) {
|
|
4719
5082
|
return;
|
|
4720
5083
|
}
|
|
4721
|
-
const config = (0,
|
|
5084
|
+
const config = (0, import_node_fs18.readFileSync)(configPath, "utf8");
|
|
4722
5085
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
4723
5086
|
return;
|
|
4724
5087
|
}
|
|
@@ -4727,10 +5090,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
4727
5090
|
}
|
|
4728
5091
|
|
|
4729
5092
|
// src/rollup-library/rollup-config.repository.ts
|
|
4730
|
-
var
|
|
4731
|
-
var
|
|
5093
|
+
var import_node_fs19 = require("fs");
|
|
5094
|
+
var import_node_path20 = require("path");
|
|
4732
5095
|
function resolveRequireTarget(fromDir, specifier) {
|
|
4733
|
-
const base = (0,
|
|
5096
|
+
const base = (0, import_node_path20.join)(fromDir, specifier);
|
|
4734
5097
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
4735
5098
|
}
|
|
4736
5099
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -4740,7 +5103,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4740
5103
|
visited.add(configPath);
|
|
4741
5104
|
let text;
|
|
4742
5105
|
try {
|
|
4743
|
-
text = (0,
|
|
5106
|
+
text = (0, import_node_fs19.readFileSync)(configPath, "utf8");
|
|
4744
5107
|
} catch {
|
|
4745
5108
|
return "";
|
|
4746
5109
|
}
|
|
@@ -4748,15 +5111,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4748
5111
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
4749
5112
|
(match) => match[2]
|
|
4750
5113
|
);
|
|
4751
|
-
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));
|
|
4752
5115
|
return [text, ...requiredText].join("\n");
|
|
4753
5116
|
}
|
|
4754
5117
|
|
|
4755
5118
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4756
5119
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4757
5120
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4758
|
-
const projectRoot = (0,
|
|
4759
|
-
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");
|
|
4760
5123
|
runGeneratorAndRepair(
|
|
4761
5124
|
workspaceRoot,
|
|
4762
5125
|
[
|
|
@@ -4785,8 +5148,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4785
5148
|
}
|
|
4786
5149
|
|
|
4787
5150
|
// src/project-scaffolding/python.use-case.ts
|
|
4788
|
-
var
|
|
4789
|
-
var
|
|
5151
|
+
var import_node_fs20 = require("fs");
|
|
5152
|
+
var import_node_path22 = require("path");
|
|
4790
5153
|
function ensurePython(workspaceRoot) {
|
|
4791
5154
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
4792
5155
|
if (!hasPython) {
|
|
@@ -4809,7 +5172,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
4809
5172
|
registerPythonGraphPlugin(workspaceRoot);
|
|
4810
5173
|
}
|
|
4811
5174
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
4812
|
-
const nxJsonPath = (0,
|
|
5175
|
+
const nxJsonPath = (0, import_node_path22.join)(workspaceRoot, "nx.json");
|
|
4813
5176
|
if (!fileExists(nxJsonPath)) {
|
|
4814
5177
|
return;
|
|
4815
5178
|
}
|
|
@@ -4832,7 +5195,7 @@ pytest
|
|
|
4832
5195
|
pip-audit
|
|
4833
5196
|
`;
|
|
4834
5197
|
function ensureRequirementsDev(workspaceRoot) {
|
|
4835
|
-
const requirementsDevPath = (0,
|
|
5198
|
+
const requirementsDevPath = (0, import_node_path22.join)(workspaceRoot, "requirements-dev.txt");
|
|
4836
5199
|
if (!fileExists(requirementsDevPath)) {
|
|
4837
5200
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
4838
5201
|
}
|
|
@@ -4892,8 +5255,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
4892
5255
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
4893
5256
|
workspaceRoot
|
|
4894
5257
|
);
|
|
4895
|
-
writeFileEnsured((0,
|
|
4896
|
-
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"), {
|
|
4897
5260
|
package: pythonAppPackageTarget(name),
|
|
4898
5261
|
start: pythonAppStartTarget(name)
|
|
4899
5262
|
});
|
|
@@ -4915,7 +5278,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
4915
5278
|
workspaceRoot
|
|
4916
5279
|
);
|
|
4917
5280
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
4918
|
-
addProjectJsonTargets((0,
|
|
5281
|
+
addProjectJsonTargets((0, import_node_path22.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4919
5282
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
4920
5283
|
start: pythonFunctionAppStartTarget(name)
|
|
4921
5284
|
});
|
|
@@ -4956,7 +5319,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
4956
5319
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
4957
5320
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
4958
5321
|
return PYTHON_PROJECT_DIRS.find(
|
|
4959
|
-
(directory) => fileExists((0,
|
|
5322
|
+
(directory) => fileExists((0, import_node_path22.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
4960
5323
|
);
|
|
4961
5324
|
}
|
|
4962
5325
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -4995,7 +5358,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4995
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.`
|
|
4996
5359
|
);
|
|
4997
5360
|
}
|
|
4998
|
-
if (!fileExists((0,
|
|
5361
|
+
if (!fileExists((0, import_node_path22.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
4999
5362
|
throw new Error(
|
|
5000
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.`
|
|
5001
5364
|
);
|
|
@@ -5003,8 +5366,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5003
5366
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
5004
5367
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5005
5368
|
}
|
|
5006
|
-
const pyprojectPath = (0,
|
|
5007
|
-
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");
|
|
5008
5371
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5009
5372
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5010
5373
|
return;
|
|
@@ -5016,8 +5379,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5016
5379
|
}
|
|
5017
5380
|
|
|
5018
5381
|
// src/project-scaffolding/react-app.use-case.ts
|
|
5019
|
-
var
|
|
5020
|
-
var
|
|
5382
|
+
var import_node_fs21 = require("fs");
|
|
5383
|
+
var import_node_path23 = require("path");
|
|
5021
5384
|
|
|
5022
5385
|
// src/project-scaffolding/react-app-example.algorithm.ts
|
|
5023
5386
|
function reactAppExampleFiles(name) {
|
|
@@ -5134,12 +5497,12 @@ function reactAppTargets(name) {
|
|
|
5134
5497
|
return targets;
|
|
5135
5498
|
}
|
|
5136
5499
|
function allowEnvFiles(workspaceRoot) {
|
|
5137
|
-
const gitignorePath = (0,
|
|
5500
|
+
const gitignorePath = (0, import_node_path23.join)(workspaceRoot, ".gitignore");
|
|
5138
5501
|
if (!fileExists(gitignorePath)) {
|
|
5139
5502
|
return;
|
|
5140
5503
|
}
|
|
5141
5504
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
5142
|
-
const current = (0,
|
|
5505
|
+
const current = (0, import_node_fs21.readFileSync)(gitignorePath, "utf8");
|
|
5143
5506
|
if (current.includes(marker)) {
|
|
5144
5507
|
return;
|
|
5145
5508
|
}
|
|
@@ -5166,30 +5529,30 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
5166
5529
|
workspaceRoot
|
|
5167
5530
|
);
|
|
5168
5531
|
ensureAdmZip(workspaceRoot);
|
|
5169
|
-
const reactAppRoot = (0,
|
|
5532
|
+
const reactAppRoot = (0, import_node_path23.join)(workspaceRoot, "apps", name);
|
|
5170
5533
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
5171
|
-
writeFileEnsured((0,
|
|
5534
|
+
writeFileEnsured((0, import_node_path23.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
5172
5535
|
}
|
|
5173
5536
|
allowEnvFiles(workspaceRoot);
|
|
5174
|
-
addNxTargets((0,
|
|
5537
|
+
addNxTargets((0, import_node_path23.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
5175
5538
|
reshapeReactAppScaffold(reactAppRoot);
|
|
5176
|
-
(0,
|
|
5539
|
+
(0, import_node_fs21.rmSync)((0, import_node_path23.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
5177
5540
|
const example = reactAppExampleFiles(name);
|
|
5178
5541
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5179
|
-
writeFileEnsured((0,
|
|
5542
|
+
writeFileEnsured((0, import_node_path23.join)(reactAppRoot, "src", relative), contents);
|
|
5180
5543
|
}
|
|
5181
5544
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
5182
5545
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
5183
5546
|
}
|
|
5184
5547
|
|
|
5185
5548
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
5186
|
-
var
|
|
5549
|
+
var import_node_path24 = require("path");
|
|
5187
5550
|
var REACT_LIB_BUNDLER = "rollup";
|
|
5188
5551
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
5189
5552
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5190
5553
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
5191
|
-
const projectRoot = (0,
|
|
5192
|
-
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");
|
|
5193
5556
|
runGeneratorAndRepair(
|
|
5194
5557
|
workspaceRoot,
|
|
5195
5558
|
[
|
|
@@ -5219,8 +5582,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5219
5582
|
}
|
|
5220
5583
|
function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
5221
5584
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5222
|
-
const projectRoot = (0,
|
|
5223
|
-
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");
|
|
5224
5587
|
runGeneratorAndRepair(
|
|
5225
5588
|
workspaceRoot,
|
|
5226
5589
|
[
|
|
@@ -5247,8 +5610,8 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
5247
5610
|
}
|
|
5248
5611
|
|
|
5249
5612
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
5250
|
-
var
|
|
5251
|
-
var
|
|
5613
|
+
var import_node_fs22 = require("fs");
|
|
5614
|
+
var import_node_path25 = require("path");
|
|
5252
5615
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
5253
5616
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
5254
5617
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -5433,8 +5796,8 @@ export const window = {
|
|
|
5433
5796
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
5434
5797
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
5435
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}\` },`];
|
|
5436
|
-
const path = (0,
|
|
5437
|
-
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") : "";
|
|
5438
5801
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
5439
5802
|
if (line === void 0) {
|
|
5440
5803
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -5454,11 +5817,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
5454
5817
|
}
|
|
5455
5818
|
}
|
|
5456
5819
|
function defaultPublisher(workspaceRoot) {
|
|
5457
|
-
const { name } = readJson((0,
|
|
5820
|
+
const { name } = readJson((0, import_node_path25.join)(workspaceRoot, "package.json"));
|
|
5458
5821
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
5459
5822
|
}
|
|
5460
5823
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
5461
|
-
const manifestPath = (0,
|
|
5824
|
+
const manifestPath = (0, import_node_path25.join)(projectRoot, "package.json");
|
|
5462
5825
|
const manifest = readJson(manifestPath);
|
|
5463
5826
|
const { nx = {}, ...rest } = manifest;
|
|
5464
5827
|
const targets = { ...nx.targets };
|
|
@@ -5522,11 +5885,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
5522
5885
|
};
|
|
5523
5886
|
}
|
|
5524
5887
|
function addDebugLaunch(workspaceRoot, name) {
|
|
5525
|
-
const file = (0,
|
|
5888
|
+
const file = (0, import_node_fs22.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
5526
5889
|
if (file === void 0) {
|
|
5527
5890
|
return;
|
|
5528
5891
|
}
|
|
5529
|
-
const path = (0,
|
|
5892
|
+
const path = (0, import_node_path25.join)(workspaceRoot, file);
|
|
5530
5893
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
5531
5894
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
5532
5895
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -5559,39 +5922,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
5559
5922
|
);
|
|
5560
5923
|
}
|
|
5561
5924
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
5562
|
-
const apps = (0,
|
|
5925
|
+
const apps = (0, import_node_path25.join)(workspaceRoot, "apps");
|
|
5563
5926
|
let entries;
|
|
5564
5927
|
try {
|
|
5565
|
-
entries = (0,
|
|
5928
|
+
entries = (0, import_node_fs22.readdirSync)(apps);
|
|
5566
5929
|
} catch {
|
|
5567
5930
|
return false;
|
|
5568
5931
|
}
|
|
5569
5932
|
const hasExtension = entries.some((entry) => {
|
|
5570
|
-
const manifestPath = (0,
|
|
5933
|
+
const manifestPath = (0, import_node_path25.join)(apps, entry, "package.json");
|
|
5571
5934
|
if (!fileExists(manifestPath)) {
|
|
5572
5935
|
return false;
|
|
5573
5936
|
}
|
|
5574
5937
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
5575
5938
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
5576
5939
|
});
|
|
5577
|
-
const path = (0,
|
|
5578
|
-
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) {
|
|
5579
5942
|
return false;
|
|
5580
5943
|
}
|
|
5581
5944
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
5582
5945
|
return true;
|
|
5583
5946
|
}
|
|
5584
5947
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
5585
|
-
const apps = (0,
|
|
5948
|
+
const apps = (0, import_node_path25.join)(workspaceRoot, "apps");
|
|
5586
5949
|
let entries;
|
|
5587
5950
|
try {
|
|
5588
|
-
entries = (0,
|
|
5951
|
+
entries = (0, import_node_fs22.readdirSync)(apps);
|
|
5589
5952
|
} catch {
|
|
5590
5953
|
return [];
|
|
5591
5954
|
}
|
|
5592
5955
|
const updated = [];
|
|
5593
5956
|
for (const entry of entries) {
|
|
5594
|
-
const manifestPath = (0,
|
|
5957
|
+
const manifestPath = (0, import_node_path25.join)(apps, entry, "package.json");
|
|
5595
5958
|
if (!fileExists(manifestPath)) {
|
|
5596
5959
|
continue;
|
|
5597
5960
|
}
|
|
@@ -5611,22 +5974,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
5611
5974
|
}
|
|
5612
5975
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
5613
5976
|
const { sidecar } = options;
|
|
5614
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
5977
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path25.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
5615
5978
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
5616
5979
|
}
|
|
5617
5980
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
5618
5981
|
ensureVscodeToolchain(workspaceRoot);
|
|
5619
|
-
const projectRoot = (0,
|
|
5982
|
+
const projectRoot = (0, import_node_path25.join)(workspaceRoot, "apps", name);
|
|
5620
5983
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
5621
|
-
addVscodeTypes((0,
|
|
5622
|
-
addVscodeTypes((0,
|
|
5623
|
-
writeFileEnsured((0,
|
|
5624
|
-
writeFileEnsured((0,
|
|
5625
|
-
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);
|
|
5626
5989
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
5627
|
-
writeFileEnsured((0,
|
|
5628
|
-
writeFileEnsured((0,
|
|
5629
|
-
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"), {
|
|
5630
5993
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
5631
5994
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
5632
5995
|
});
|
|
@@ -5637,12 +6000,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5637
6000
|
}
|
|
5638
6001
|
|
|
5639
6002
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5640
|
-
var
|
|
5641
|
-
var
|
|
6003
|
+
var import_node_fs24 = require("fs");
|
|
6004
|
+
var import_node_path27 = require("path");
|
|
5642
6005
|
|
|
5643
6006
|
// src/dependency-management/manifest.repository.ts
|
|
5644
|
-
var
|
|
5645
|
-
var
|
|
6007
|
+
var import_node_fs23 = require("fs");
|
|
6008
|
+
var import_node_path26 = require("path");
|
|
5646
6009
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5647
6010
|
var ROOT_LABEL = "(root)";
|
|
5648
6011
|
var MANIFEST_GLOBS = {
|
|
@@ -5675,23 +6038,23 @@ function projectOf(manifestRelativePath) {
|
|
|
5675
6038
|
}
|
|
5676
6039
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
5677
6040
|
if (ecosystem === "go") {
|
|
5678
|
-
return fileExists((0,
|
|
6041
|
+
return fileExists((0, import_node_path26.join)(workspaceRoot, "go.mod"));
|
|
5679
6042
|
}
|
|
5680
6043
|
if (ecosystem === "nuget") {
|
|
5681
|
-
return (0,
|
|
6044
|
+
return (0, import_node_fs23.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
5682
6045
|
}
|
|
5683
6046
|
const rootMarker = {
|
|
5684
6047
|
npm: "package.json",
|
|
5685
6048
|
pip: "requirements-dev.txt",
|
|
5686
6049
|
pub: "pubspec.yaml"
|
|
5687
6050
|
};
|
|
5688
|
-
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;
|
|
5689
6052
|
}
|
|
5690
6053
|
function collectNpm(workspaceRoot) {
|
|
5691
6054
|
const sites = [];
|
|
5692
|
-
const relativePaths = ["package.json", ...(0,
|
|
6055
|
+
const relativePaths = ["package.json", ...(0, import_node_fs23.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
5693
6056
|
for (const relativePath of relativePaths) {
|
|
5694
|
-
const manifestPath = (0,
|
|
6057
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
5695
6058
|
try {
|
|
5696
6059
|
const manifest = readJson(manifestPath);
|
|
5697
6060
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -5752,17 +6115,17 @@ function collectPip(workspaceRoot) {
|
|
|
5752
6115
|
name: parsed.name,
|
|
5753
6116
|
ecosystem: "pip",
|
|
5754
6117
|
project: projectOf(relativePath),
|
|
5755
|
-
manifestPath: (0,
|
|
6118
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5756
6119
|
section,
|
|
5757
6120
|
spec: parsed.spec,
|
|
5758
6121
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
5759
6122
|
});
|
|
5760
6123
|
};
|
|
5761
|
-
const pyprojectPaths = (0,
|
|
6124
|
+
const pyprojectPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
5762
6125
|
for (const relativePath of pyprojectPaths) {
|
|
5763
6126
|
let content;
|
|
5764
6127
|
try {
|
|
5765
|
-
content = (0,
|
|
6128
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5766
6129
|
} catch {
|
|
5767
6130
|
continue;
|
|
5768
6131
|
}
|
|
@@ -5773,14 +6136,14 @@ function collectPip(workspaceRoot) {
|
|
|
5773
6136
|
}
|
|
5774
6137
|
const requirementsPaths = [
|
|
5775
6138
|
"requirements-dev.txt",
|
|
5776
|
-
...(0,
|
|
6139
|
+
...(0, import_node_fs23.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
5777
6140
|
];
|
|
5778
6141
|
for (const relativePath of requirementsPaths) {
|
|
5779
|
-
if (!fileExists((0,
|
|
6142
|
+
if (!fileExists((0, import_node_path26.join)(workspaceRoot, relativePath))) {
|
|
5780
6143
|
continue;
|
|
5781
6144
|
}
|
|
5782
6145
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
5783
|
-
const lines = (0,
|
|
6146
|
+
const lines = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
5784
6147
|
for (const line of lines) {
|
|
5785
6148
|
push(relativePath, section, line);
|
|
5786
6149
|
}
|
|
@@ -5818,11 +6181,11 @@ function pyprojectDependencies(content) {
|
|
|
5818
6181
|
}
|
|
5819
6182
|
function collectPub(workspaceRoot) {
|
|
5820
6183
|
const sites = [];
|
|
5821
|
-
const pubspecPaths = (0,
|
|
6184
|
+
const pubspecPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
5822
6185
|
for (const relativePath of pubspecPaths) {
|
|
5823
6186
|
let content;
|
|
5824
6187
|
try {
|
|
5825
|
-
content = (0,
|
|
6188
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5826
6189
|
} catch {
|
|
5827
6190
|
continue;
|
|
5828
6191
|
}
|
|
@@ -5832,7 +6195,7 @@ function collectPub(workspaceRoot) {
|
|
|
5832
6195
|
name: entry.name,
|
|
5833
6196
|
ecosystem: "pub",
|
|
5834
6197
|
project: projectOf(relativePath),
|
|
5835
|
-
manifestPath: (0,
|
|
6198
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5836
6199
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
5837
6200
|
spec: entry.spec,
|
|
5838
6201
|
rewritable: entry.spec !== ""
|
|
@@ -5882,11 +6245,11 @@ function stripQuotes(value) {
|
|
|
5882
6245
|
}
|
|
5883
6246
|
function collectNuget(workspaceRoot) {
|
|
5884
6247
|
const sites = [];
|
|
5885
|
-
const csprojPaths = (0,
|
|
6248
|
+
const csprojPaths = (0, import_node_fs23.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
5886
6249
|
for (const relativePath of csprojPaths) {
|
|
5887
6250
|
let content;
|
|
5888
6251
|
try {
|
|
5889
|
-
content = (0,
|
|
6252
|
+
content = (0, import_node_fs23.readFileSync)((0, import_node_path26.join)(workspaceRoot, relativePath), "utf8");
|
|
5890
6253
|
} catch {
|
|
5891
6254
|
continue;
|
|
5892
6255
|
}
|
|
@@ -5895,7 +6258,7 @@ function collectNuget(workspaceRoot) {
|
|
|
5895
6258
|
name: entry.name,
|
|
5896
6259
|
ecosystem: "nuget",
|
|
5897
6260
|
project: projectOf(relativePath),
|
|
5898
|
-
manifestPath: (0,
|
|
6261
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath),
|
|
5899
6262
|
section: "dep",
|
|
5900
6263
|
spec: entry.spec,
|
|
5901
6264
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -5920,13 +6283,13 @@ function csprojPackageReferences(content) {
|
|
|
5920
6283
|
return entries;
|
|
5921
6284
|
}
|
|
5922
6285
|
function collectGo(workspaceRoot) {
|
|
5923
|
-
const manifestPath = (0,
|
|
6286
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "go.mod");
|
|
5924
6287
|
if (!fileExists(manifestPath)) {
|
|
5925
6288
|
return [];
|
|
5926
6289
|
}
|
|
5927
6290
|
let content;
|
|
5928
6291
|
try {
|
|
5929
|
-
content = (0,
|
|
6292
|
+
content = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5930
6293
|
} catch {
|
|
5931
6294
|
return [];
|
|
5932
6295
|
}
|
|
@@ -5975,7 +6338,7 @@ var PROJECT_GLOBS = {
|
|
|
5975
6338
|
function locateProjects(workspaceRoot) {
|
|
5976
6339
|
const locations = [];
|
|
5977
6340
|
for (const ecosystem of ECOSYSTEMS) {
|
|
5978
|
-
const relativePaths = (0,
|
|
6341
|
+
const relativePaths = (0, import_node_fs23.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
5979
6342
|
for (const relativePath of relativePaths) {
|
|
5980
6343
|
const posix = toPosix(relativePath);
|
|
5981
6344
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -5983,7 +6346,7 @@ function locateProjects(workspaceRoot) {
|
|
|
5983
6346
|
ecosystem,
|
|
5984
6347
|
dir,
|
|
5985
6348
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
5986
|
-
manifestPath: (0,
|
|
6349
|
+
manifestPath: (0, import_node_path26.join)(workspaceRoot, relativePath)
|
|
5987
6350
|
});
|
|
5988
6351
|
}
|
|
5989
6352
|
}
|
|
@@ -6004,7 +6367,7 @@ function rewriteSpec(site, spec) {
|
|
|
6004
6367
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
6005
6368
|
return true;
|
|
6006
6369
|
}
|
|
6007
|
-
const before = (0,
|
|
6370
|
+
const before = (0, import_node_fs23.readFileSync)(site.manifestPath, "utf8");
|
|
6008
6371
|
const after = (() => {
|
|
6009
6372
|
switch (site.ecosystem) {
|
|
6010
6373
|
case "pip": {
|
|
@@ -6095,13 +6458,13 @@ function escapeForRegex(value) {
|
|
|
6095
6458
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
6096
6459
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
6097
6460
|
return ["apps", "libs", "packages"].some(
|
|
6098
|
-
(directory) => fileExists((0,
|
|
6461
|
+
(directory) => fileExists((0, import_node_path26.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
6099
6462
|
);
|
|
6100
6463
|
}
|
|
6101
6464
|
function isAliasedInstall(workspaceRoot, name) {
|
|
6102
6465
|
try {
|
|
6103
6466
|
const installed = readJson(
|
|
6104
|
-
(0,
|
|
6467
|
+
(0, import_node_path26.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6105
6468
|
);
|
|
6106
6469
|
return installed.name !== void 0 && installed.name !== name;
|
|
6107
6470
|
} catch {
|
|
@@ -6112,14 +6475,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6112
6475
|
if (ecosystem === "npm") {
|
|
6113
6476
|
try {
|
|
6114
6477
|
return readJson(
|
|
6115
|
-
(0,
|
|
6478
|
+
(0, import_node_path26.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6116
6479
|
).version;
|
|
6117
6480
|
} catch {
|
|
6118
6481
|
return void 0;
|
|
6119
6482
|
}
|
|
6120
6483
|
}
|
|
6121
6484
|
if (ecosystem === "pub") {
|
|
6122
|
-
const lockPath = (0,
|
|
6485
|
+
const lockPath = (0, import_node_path26.join)(workspaceRoot, "pubspec.lock");
|
|
6123
6486
|
if (!fileExists(lockPath)) {
|
|
6124
6487
|
return void 0;
|
|
6125
6488
|
}
|
|
@@ -6127,7 +6490,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6127
6490
|
const match = new RegExp(
|
|
6128
6491
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
6129
6492
|
"m"
|
|
6130
|
-
).exec((0,
|
|
6493
|
+
).exec((0, import_node_fs23.readFileSync)(lockPath, "utf8"));
|
|
6131
6494
|
return match?.[1];
|
|
6132
6495
|
} catch {
|
|
6133
6496
|
return void 0;
|
|
@@ -6193,7 +6556,7 @@ function resolveTarget(locations, target) {
|
|
|
6193
6556
|
return byName[0];
|
|
6194
6557
|
}
|
|
6195
6558
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
6196
|
-
const projectDir = (0,
|
|
6559
|
+
const projectDir = (0, import_node_path27.join)(workspaceRoot, location.dir);
|
|
6197
6560
|
switch (location.ecosystem) {
|
|
6198
6561
|
case "npm": {
|
|
6199
6562
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -6246,7 +6609,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
6246
6609
|
function addPythonDependency(manifestPath, specifier) {
|
|
6247
6610
|
let content;
|
|
6248
6611
|
try {
|
|
6249
|
-
content = (0,
|
|
6612
|
+
content = (0, import_node_fs24.readFileSync)(manifestPath, "utf8");
|
|
6250
6613
|
} catch {
|
|
6251
6614
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
6252
6615
|
return;
|
|
@@ -6275,7 +6638,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
6275
6638
|
}
|
|
6276
6639
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
6277
6640
|
if (ecosystem === "go") {
|
|
6278
|
-
return fileExists((0,
|
|
6641
|
+
return fileExists((0, import_node_path27.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path27.join)(workspaceRoot, "go.mod"));
|
|
6279
6642
|
}
|
|
6280
6643
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
6281
6644
|
}
|
|
@@ -6294,7 +6657,7 @@ function splitAtLast(value, separator) {
|
|
|
6294
6657
|
}
|
|
6295
6658
|
|
|
6296
6659
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
6297
|
-
var
|
|
6660
|
+
var import_node_path28 = require("path");
|
|
6298
6661
|
|
|
6299
6662
|
// src/dependency-management/semver.algorithm.ts
|
|
6300
6663
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -6471,7 +6834,7 @@ function describe(finding) {
|
|
|
6471
6834
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
6472
6835
|
}
|
|
6473
6836
|
function runSync(workspaceRoot, options) {
|
|
6474
|
-
if (!fileExists((0,
|
|
6837
|
+
if (!fileExists((0, import_node_path28.join)(workspaceRoot, "nx.json"))) {
|
|
6475
6838
|
throw new Error(
|
|
6476
6839
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
6477
6840
|
);
|
|
@@ -6521,7 +6884,7 @@ function runSync(workspaceRoot, options) {
|
|
|
6521
6884
|
}
|
|
6522
6885
|
|
|
6523
6886
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
6524
|
-
var
|
|
6887
|
+
var import_node_path29 = require("path");
|
|
6525
6888
|
var import_prompts2 = require("@inquirer/prompts");
|
|
6526
6889
|
|
|
6527
6890
|
// src/dependency-management/registry.client.ts
|
|
@@ -6804,7 +7167,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
6804
7167
|
function hasPythonInstallScript(workspaceRoot) {
|
|
6805
7168
|
try {
|
|
6806
7169
|
const manifest = readJson(
|
|
6807
|
-
(0,
|
|
7170
|
+
(0, import_node_path29.join)(workspaceRoot, "package.json")
|
|
6808
7171
|
);
|
|
6809
7172
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
6810
7173
|
} catch {
|
|
@@ -6820,7 +7183,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
6820
7183
|
}
|
|
6821
7184
|
}
|
|
6822
7185
|
async function runUp(workspaceRoot, options) {
|
|
6823
|
-
if (!fileExists((0,
|
|
7186
|
+
if (!fileExists((0, import_node_path29.join)(workspaceRoot, "nx.json"))) {
|
|
6824
7187
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
6825
7188
|
}
|
|
6826
7189
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -6897,7 +7260,7 @@ var PROJECT_KINDS = [
|
|
|
6897
7260
|
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
6898
7261
|
async function runAdd(kind, name, options) {
|
|
6899
7262
|
const workspaceRoot = process.cwd();
|
|
6900
|
-
if (!fileExists((0,
|
|
7263
|
+
if (!fileExists((0, import_node_path30.join)(workspaceRoot, "nx.json"))) {
|
|
6901
7264
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
6902
7265
|
}
|
|
6903
7266
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -6960,8 +7323,8 @@ async function runAdd(kind, name, options) {
|
|
|
6960
7323
|
],
|
|
6961
7324
|
workspaceRoot
|
|
6962
7325
|
);
|
|
6963
|
-
markPrivate((0,
|
|
6964
|
-
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);
|
|
6965
7328
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
6966
7329
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
6967
7330
|
break;
|
|
@@ -7053,7 +7416,7 @@ async function runAdd(kind, name, options) {
|
|
|
7053
7416
|
}
|
|
7054
7417
|
function readWorkspaceStack(workspaceRoot) {
|
|
7055
7418
|
const nxJson = readJson(
|
|
7056
|
-
(0,
|
|
7419
|
+
(0, import_node_path30.join)(workspaceRoot, "nx.json")
|
|
7057
7420
|
);
|
|
7058
7421
|
const stack = nxJson.mnci?.stack;
|
|
7059
7422
|
return {
|
|
@@ -7102,15 +7465,15 @@ function runKinds(options) {
|
|
|
7102
7465
|
|
|
7103
7466
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
7104
7467
|
var import_node_child_process = require("child_process");
|
|
7105
|
-
var
|
|
7106
|
-
var
|
|
7468
|
+
var import_node_fs25 = require("fs");
|
|
7469
|
+
var import_node_path31 = require("path");
|
|
7107
7470
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
7108
7471
|
function toPosix2(path) {
|
|
7109
7472
|
return path.replaceAll("\\", "/");
|
|
7110
7473
|
}
|
|
7111
7474
|
function checkEslintConfigs(workspaceRoot) {
|
|
7112
|
-
const rootConfigs = (0,
|
|
7113
|
-
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}", {
|
|
7114
7477
|
cwd: workspaceRoot
|
|
7115
7478
|
}).map((config) => toPosix2(config));
|
|
7116
7479
|
return [
|
|
@@ -7130,10 +7493,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
7130
7493
|
];
|
|
7131
7494
|
}
|
|
7132
7495
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
7133
|
-
const rules = (0,
|
|
7134
|
-
if (!(0,
|
|
7135
|
-
const entryPoint = (0,
|
|
7136
|
-
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") : "";
|
|
7137
7500
|
return [
|
|
7138
7501
|
{
|
|
7139
7502
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -7146,7 +7509,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
7146
7509
|
function declaredDevDependencies(workspaceRoot) {
|
|
7147
7510
|
try {
|
|
7148
7511
|
const manifest = readJson(
|
|
7149
|
-
(0,
|
|
7512
|
+
(0, import_node_path31.join)(workspaceRoot, "package.json")
|
|
7150
7513
|
);
|
|
7151
7514
|
return manifest.devDependencies ?? {};
|
|
7152
7515
|
} catch {
|
|
@@ -7154,7 +7517,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
7154
7517
|
}
|
|
7155
7518
|
}
|
|
7156
7519
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
7157
|
-
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)));
|
|
7158
7521
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
7159
7522
|
const stale = [...files, ...declared];
|
|
7160
7523
|
if (stale.length === 0) {
|
|
@@ -7180,7 +7543,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
7180
7543
|
};
|
|
7181
7544
|
}
|
|
7182
7545
|
function checkResolvedEslint(workspaceRoot) {
|
|
7183
|
-
const manifestPath = (0,
|
|
7546
|
+
const manifestPath = (0, import_node_path31.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
7184
7547
|
if (!fileExists(manifestPath)) {
|
|
7185
7548
|
return void 0;
|
|
7186
7549
|
}
|
|
@@ -7198,11 +7561,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
7198
7561
|
}
|
|
7199
7562
|
}
|
|
7200
7563
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
7201
|
-
const npmrcPath = (0,
|
|
7564
|
+
const npmrcPath = (0, import_node_path31.join)(workspaceRoot, ".npmrc");
|
|
7202
7565
|
if (!registry || !fileExists(npmrcPath)) {
|
|
7203
7566
|
return void 0;
|
|
7204
7567
|
}
|
|
7205
|
-
const npmrc = (0,
|
|
7568
|
+
const npmrc = (0, import_node_fs25.readFileSync)(npmrcPath, "utf8");
|
|
7206
7569
|
if (registry.kind === "npm") {
|
|
7207
7570
|
return {
|
|
7208
7571
|
check: ".npmrc authenticates the public registry",
|
|
@@ -7219,11 +7582,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
7219
7582
|
};
|
|
7220
7583
|
}
|
|
7221
7584
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
7222
|
-
const npmrcPath = (0,
|
|
7585
|
+
const npmrcPath = (0, import_node_path31.join)(workspaceRoot, ".npmrc");
|
|
7223
7586
|
if (!fileExists(npmrcPath)) {
|
|
7224
7587
|
return void 0;
|
|
7225
7588
|
}
|
|
7226
|
-
const npmrc = (0,
|
|
7589
|
+
const npmrc = (0, import_node_fs25.readFileSync)(npmrcPath, "utf8");
|
|
7227
7590
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7228
7591
|
const referenced = [
|
|
7229
7592
|
...new Set(
|
|
@@ -7247,13 +7610,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
7247
7610
|
};
|
|
7248
7611
|
}
|
|
7249
7612
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
7250
|
-
const npmrcPath = (0,
|
|
7251
|
-
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");
|
|
7252
7615
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
7253
7616
|
return void 0;
|
|
7254
7617
|
}
|
|
7255
|
-
const holdsCredentials = (0,
|
|
7256
|
-
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");
|
|
7257
7620
|
if (!holdsCredentials && !runsTask) {
|
|
7258
7621
|
return {
|
|
7259
7622
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -7298,13 +7661,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
7298
7661
|
}
|
|
7299
7662
|
function checkVersionActions(workspaceRoot) {
|
|
7300
7663
|
const candidates = [
|
|
7301
|
-
...(0,
|
|
7302
|
-
...(0,
|
|
7303
|
-
...(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 })
|
|
7304
7667
|
].map((manifest) => toPosix2(manifest));
|
|
7305
7668
|
return candidates.flatMap((manifest) => {
|
|
7306
7669
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
7307
|
-
const projectJsonPath = (0,
|
|
7670
|
+
const projectJsonPath = (0, import_node_path31.join)(workspaceRoot, projectRoot, "project.json");
|
|
7308
7671
|
let hasOverride = false;
|
|
7309
7672
|
try {
|
|
7310
7673
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -7333,7 +7696,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7333
7696
|
]) {
|
|
7334
7697
|
try {
|
|
7335
7698
|
const targets = extract(
|
|
7336
|
-
readJson((0,
|
|
7699
|
+
readJson((0, import_node_path31.join)(workspaceRoot, projectRoot, file))
|
|
7337
7700
|
);
|
|
7338
7701
|
if (targets && typeof targets === "object") {
|
|
7339
7702
|
sources.push({
|
|
@@ -7349,8 +7712,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7349
7712
|
function checkTargetFilesExist(workspaceRoot) {
|
|
7350
7713
|
const projectRoots = new Set(
|
|
7351
7714
|
[
|
|
7352
|
-
...(0,
|
|
7353
|
-
...(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 })
|
|
7354
7717
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
7355
7718
|
);
|
|
7356
7719
|
return [...projectRoots].flatMap(
|
|
@@ -7365,7 +7728,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
7365
7728
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
7366
7729
|
const value = target?.options?.[option];
|
|
7367
7730
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
7368
|
-
if (!checkable || fileExists((0,
|
|
7731
|
+
if (!checkable || fileExists((0, import_node_path31.join)(workspaceRoot, value))) {
|
|
7369
7732
|
return [];
|
|
7370
7733
|
}
|
|
7371
7734
|
return [
|
|
@@ -7404,15 +7767,15 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
7404
7767
|
};
|
|
7405
7768
|
}
|
|
7406
7769
|
function checkGoWorkInSync(workspaceRoot) {
|
|
7407
|
-
const goWorkPath = (0,
|
|
7770
|
+
const goWorkPath = (0, import_node_path31.join)(workspaceRoot, "go.work");
|
|
7408
7771
|
if (!fileExists(goWorkPath)) {
|
|
7409
7772
|
return void 0;
|
|
7410
7773
|
}
|
|
7411
|
-
const contents = (0,
|
|
7774
|
+
const contents = (0, import_node_fs25.existsSync)(goWorkPath) ? (0, import_node_fs25.readFileSync)(goWorkPath, "utf8") : "";
|
|
7412
7775
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
7413
7776
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
7414
7777
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
7415
|
-
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")));
|
|
7416
7779
|
return {
|
|
7417
7780
|
check: "every go.work `use` entry points to a module that still exists",
|
|
7418
7781
|
ok: stale.length === 0,
|
|
@@ -7428,9 +7791,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7428
7791
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
7429
7792
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
7430
7793
|
];
|
|
7431
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
7794
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path31.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
7432
7795
|
check: `${file} builds the native apps on every OS`,
|
|
7433
|
-
ok: (0,
|
|
7796
|
+
ok: (0, import_node_fs25.readFileSync)((0, import_node_path31.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
7434
7797
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
7435
7798
|
remedy: "run `mnci upgrade`"
|
|
7436
7799
|
}));
|
|
@@ -7443,7 +7806,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7443
7806
|
return findings;
|
|
7444
7807
|
}
|
|
7445
7808
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
7446
|
-
const manifestPath = (0,
|
|
7809
|
+
const manifestPath = (0, import_node_path31.join)(workspaceRoot, "package.json");
|
|
7447
7810
|
if (!fileExists(manifestPath)) {
|
|
7448
7811
|
return void 0;
|
|
7449
7812
|
}
|
|
@@ -7463,14 +7826,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
7463
7826
|
};
|
|
7464
7827
|
}
|
|
7465
7828
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
7466
|
-
const configs = (0,
|
|
7829
|
+
const configs = (0, import_node_fs25.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7467
7830
|
cwd: workspaceRoot
|
|
7468
7831
|
}).map((config) => toPosix2(config));
|
|
7469
7832
|
return configs.flatMap((relativePath) => {
|
|
7470
|
-
const configPath = (0,
|
|
7833
|
+
const configPath = (0, import_node_path31.join)(workspaceRoot, relativePath);
|
|
7471
7834
|
let config;
|
|
7472
7835
|
try {
|
|
7473
|
-
config = (0,
|
|
7836
|
+
config = (0, import_node_fs25.readFileSync)(configPath, "utf8");
|
|
7474
7837
|
} catch {
|
|
7475
7838
|
return [];
|
|
7476
7839
|
}
|
|
@@ -7485,11 +7848,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
7485
7848
|
});
|
|
7486
7849
|
}
|
|
7487
7850
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
7488
|
-
const configs = (0,
|
|
7851
|
+
const configs = (0, import_node_fs25.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7489
7852
|
cwd: workspaceRoot
|
|
7490
7853
|
}).map((config) => toPosix2(config));
|
|
7491
7854
|
return configs.flatMap((relativePath) => {
|
|
7492
|
-
const configPath = (0,
|
|
7855
|
+
const configPath = (0, import_node_path31.join)(workspaceRoot, relativePath);
|
|
7493
7856
|
if (!fileExists(configPath)) {
|
|
7494
7857
|
return [];
|
|
7495
7858
|
}
|
|
@@ -7523,7 +7886,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
7523
7886
|
});
|
|
7524
7887
|
}
|
|
7525
7888
|
function collectFindings(workspaceRoot) {
|
|
7526
|
-
const nxJsonPath = (0,
|
|
7889
|
+
const nxJsonPath = (0, import_node_path31.join)(workspaceRoot, "nx.json");
|
|
7527
7890
|
if (!fileExists(nxJsonPath)) {
|
|
7528
7891
|
throw new Error(
|
|
7529
7892
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -7647,11 +8010,11 @@ function runCommands(program, options) {
|
|
|
7647
8010
|
}
|
|
7648
8011
|
|
|
7649
8012
|
// src/workspace-info/list-projects.use-case.ts
|
|
7650
|
-
var
|
|
8013
|
+
var import_node_path32 = require("path");
|
|
7651
8014
|
var TYPE_TAG_PREFIX = "type:";
|
|
7652
8015
|
function listProjects(workspaceRoot) {
|
|
7653
8016
|
return locateProjects(workspaceRoot).map((location) => {
|
|
7654
|
-
const projectJsonPath = (0,
|
|
8017
|
+
const projectJsonPath = (0, import_node_path32.join)(workspaceRoot, location.dir, "project.json");
|
|
7655
8018
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
7656
8019
|
const typeTag = (project.tags ?? []).find((tag) => tag.startsWith(TYPE_TAG_PREFIX));
|
|
7657
8020
|
return {
|
|
@@ -7664,7 +8027,7 @@ function listProjects(workspaceRoot) {
|
|
|
7664
8027
|
}).toSorted((a, b) => a.dir.localeCompare(b.dir));
|
|
7665
8028
|
}
|
|
7666
8029
|
function runProjects(workspaceRoot, options) {
|
|
7667
|
-
if (!fileExists((0,
|
|
8030
|
+
if (!fileExists((0, import_node_path32.join)(workspaceRoot, "nx.json"))) {
|
|
7668
8031
|
throw new Error("No nx.json found here. Run `projects` from the workspace root.");
|
|
7669
8032
|
}
|
|
7670
8033
|
const projects = listProjects(workspaceRoot);
|
|
@@ -7678,12 +8041,12 @@ function runProjects(workspaceRoot, options) {
|
|
|
7678
8041
|
}
|
|
7679
8042
|
|
|
7680
8043
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7681
|
-
var
|
|
8044
|
+
var import_node_path34 = require("path");
|
|
7682
8045
|
|
|
7683
8046
|
// src/cli-version/check-for-update.use-case.ts
|
|
7684
|
-
var
|
|
7685
|
-
var
|
|
7686
|
-
var
|
|
8047
|
+
var import_node_fs26 = require("fs");
|
|
8048
|
+
var import_node_path33 = require("path");
|
|
8049
|
+
var import_cross_spawn3 = __toESM(require("cross-spawn"));
|
|
7687
8050
|
var PACKAGE_NAME = "@mnci/cli";
|
|
7688
8051
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
7689
8052
|
function checkForUpdate(currentVersion2) {
|
|
@@ -7701,7 +8064,7 @@ function checkForUpdate(currentVersion2) {
|
|
|
7701
8064
|
}
|
|
7702
8065
|
}
|
|
7703
8066
|
function fetchLatestVersion() {
|
|
7704
|
-
const result =
|
|
8067
|
+
const result = import_cross_spawn3.default.sync("npm", ["view", PACKAGE_NAME, "version"], {
|
|
7705
8068
|
encoding: "utf8",
|
|
7706
8069
|
timeout: REGISTRY_TIMEOUT_MS,
|
|
7707
8070
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -7741,8 +8104,8 @@ function releaseTriple(version) {
|
|
|
7741
8104
|
}
|
|
7742
8105
|
function readCliVersion(packageDirectory) {
|
|
7743
8106
|
try {
|
|
7744
|
-
const manifestPath = (0,
|
|
7745
|
-
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"));
|
|
7746
8109
|
return manifest.version ?? "0.0.0";
|
|
7747
8110
|
} catch {
|
|
7748
8111
|
return "0.0.0";
|
|
@@ -7752,7 +8115,7 @@ function readCliVersion(packageDirectory) {
|
|
|
7752
8115
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7753
8116
|
function readWorkspaceInfo(workspaceRoot, cliVersion) {
|
|
7754
8117
|
const latest = fetchLatestVersion() ?? null;
|
|
7755
|
-
const isWorkspace = fileExists((0,
|
|
8118
|
+
const isWorkspace = fileExists((0, import_node_path34.join)(workspaceRoot, "nx.json"));
|
|
7756
8119
|
return {
|
|
7757
8120
|
cli: {
|
|
7758
8121
|
version: cliVersion,
|
|
@@ -7773,8 +8136,8 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
7773
8136
|
}
|
|
7774
8137
|
|
|
7775
8138
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
7776
|
-
var
|
|
7777
|
-
var
|
|
8139
|
+
var import_node_fs27 = require("fs");
|
|
8140
|
+
var import_node_path35 = require("path");
|
|
7778
8141
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
7779
8142
|
var AGENT_AND_CI_ENTRIES = [
|
|
7780
8143
|
"AGENTS.md",
|
|
@@ -7805,13 +8168,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
7805
8168
|
"packages"
|
|
7806
8169
|
];
|
|
7807
8170
|
function assertAdoptableDirectory(target) {
|
|
7808
|
-
if (!(0,
|
|
8171
|
+
if (!(0, import_node_fs27.existsSync)(target)) {
|
|
7809
8172
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
7810
8173
|
}
|
|
7811
|
-
if (!(0,
|
|
8174
|
+
if (!(0, import_node_fs27.statSync)(target).isDirectory()) {
|
|
7812
8175
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
7813
8176
|
}
|
|
7814
|
-
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)));
|
|
7815
8178
|
if (blockers.length > 0) {
|
|
7816
8179
|
throw new Error(
|
|
7817
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.`
|
|
@@ -7819,15 +8182,15 @@ function assertAdoptableDirectory(target) {
|
|
|
7819
8182
|
}
|
|
7820
8183
|
}
|
|
7821
8184
|
function mergeGitignore(generatedFile, targetFile) {
|
|
7822
|
-
const existing = (0,
|
|
8185
|
+
const existing = (0, import_node_fs27.readFileSync)(targetFile, "utf8");
|
|
7823
8186
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
7824
|
-
const additions = (0,
|
|
8187
|
+
const additions = (0, import_node_fs27.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
7825
8188
|
const trimmed = line.trim();
|
|
7826
8189
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
7827
8190
|
});
|
|
7828
8191
|
if (additions.length === 0) return false;
|
|
7829
8192
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
7830
|
-
(0,
|
|
8193
|
+
(0, import_node_fs27.writeFileSync)(
|
|
7831
8194
|
targetFile,
|
|
7832
8195
|
`${existing}${separator}
|
|
7833
8196
|
# Added by mnci (Nx workspace)
|
|
@@ -7837,9 +8200,9 @@ ${additions.join("\n")}
|
|
|
7837
8200
|
return true;
|
|
7838
8201
|
}
|
|
7839
8202
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
7840
|
-
const entries = (0,
|
|
8203
|
+
const entries = (0, import_node_fs27.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
7841
8204
|
const collisions = entries.filter(
|
|
7842
|
-
(entry) => (0,
|
|
8205
|
+
(entry) => (0, import_node_fs27.existsSync)((0, import_node_path35.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
7843
8206
|
);
|
|
7844
8207
|
if (collisions.length > 0) {
|
|
7845
8208
|
throw new Error(
|
|
@@ -7848,28 +8211,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
7848
8211
|
}
|
|
7849
8212
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
7850
8213
|
for (const entry of entries) {
|
|
7851
|
-
const from = (0,
|
|
7852
|
-
const to = (0,
|
|
7853
|
-
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)) {
|
|
7854
8217
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
7855
8218
|
result.kept.push(entry);
|
|
7856
8219
|
continue;
|
|
7857
8220
|
}
|
|
7858
|
-
if ((0,
|
|
8221
|
+
if ((0, import_node_fs27.existsSync)(to)) {
|
|
7859
8222
|
result.kept.push(entry);
|
|
7860
8223
|
continue;
|
|
7861
8224
|
}
|
|
7862
|
-
(0,
|
|
8225
|
+
(0, import_node_fs27.cpSync)(from, to, { recursive: true });
|
|
7863
8226
|
result.copied.push(entry);
|
|
7864
8227
|
}
|
|
7865
|
-
(0,
|
|
8228
|
+
(0, import_node_fs27.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
7866
8229
|
return result;
|
|
7867
8230
|
}
|
|
7868
8231
|
|
|
7869
8232
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
7870
|
-
var
|
|
7871
|
-
var
|
|
7872
|
-
var
|
|
8233
|
+
var import_node_fs28 = require("fs");
|
|
8234
|
+
var import_node_os2 = require("os");
|
|
8235
|
+
var import_node_path36 = require("path");
|
|
7873
8236
|
function nxCloudProviderValue(ci) {
|
|
7874
8237
|
return ci === "azure" ? "azure" : "github";
|
|
7875
8238
|
}
|
|
@@ -7912,9 +8275,9 @@ async function resolveRegistry(options) {
|
|
|
7912
8275
|
return await promptRegistry();
|
|
7913
8276
|
}
|
|
7914
8277
|
async function runNew(name, options) {
|
|
7915
|
-
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);
|
|
7916
8279
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
7917
|
-
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));
|
|
7918
8281
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
7919
8282
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
7920
8283
|
const registry = await resolveRegistry(options);
|
|
@@ -7927,8 +8290,8 @@ async function runNew(name, options) {
|
|
|
7927
8290
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
7928
8291
|
const stack = await resolveStack(options);
|
|
7929
8292
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
7930
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
7931
|
-
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);
|
|
7932
8295
|
try {
|
|
7933
8296
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
7934
8297
|
runNpx(
|
|
@@ -7951,7 +8314,7 @@ async function runNew(name, options) {
|
|
|
7951
8314
|
workspaceRoot = adoptTarget;
|
|
7952
8315
|
}
|
|
7953
8316
|
} finally {
|
|
7954
|
-
if (adoptTarget !== void 0) (0,
|
|
8317
|
+
if (adoptTarget !== void 0) (0, import_node_fs28.rmSync)(stagingParent, { recursive: true, force: true });
|
|
7955
8318
|
}
|
|
7956
8319
|
logger.step(
|
|
7957
8320
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -7961,8 +8324,8 @@ async function runNew(name, options) {
|
|
|
7961
8324
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
7962
8325
|
logger.detail
|
|
7963
8326
|
);
|
|
7964
|
-
(0,
|
|
7965
|
-
(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 });
|
|
7966
8329
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
7967
8330
|
const installStatus = runShell(
|
|
7968
8331
|
"npm",
|
|
@@ -8000,12 +8363,12 @@ function projectKindHintLines(kinds = PROJECT_KINDS) {
|
|
|
8000
8363
|
}
|
|
8001
8364
|
|
|
8002
8365
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8003
|
-
var
|
|
8366
|
+
var import_node_path38 = require("path");
|
|
8004
8367
|
var import_prompts4 = require("@inquirer/prompts");
|
|
8005
8368
|
|
|
8006
8369
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
8007
|
-
var
|
|
8008
|
-
var
|
|
8370
|
+
var import_node_fs29 = require("fs");
|
|
8371
|
+
var import_node_path37 = require("path");
|
|
8009
8372
|
function resolveRegistry2(options, persisted) {
|
|
8010
8373
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
8011
8374
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -8034,7 +8397,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8034
8397
|
return persisted.workspaceName;
|
|
8035
8398
|
}
|
|
8036
8399
|
try {
|
|
8037
|
-
const existing = (0,
|
|
8400
|
+
const existing = (0, import_node_fs29.readdirSync)(workspaceRoot).find(
|
|
8038
8401
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
8039
8402
|
);
|
|
8040
8403
|
if (existing) {
|
|
@@ -8042,11 +8405,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8042
8405
|
}
|
|
8043
8406
|
} catch {
|
|
8044
8407
|
}
|
|
8045
|
-
return (0,
|
|
8408
|
+
return (0, import_node_path37.basename)(workspaceRoot);
|
|
8046
8409
|
}
|
|
8047
8410
|
function detectNpmAuth(workspaceRoot) {
|
|
8048
8411
|
try {
|
|
8049
|
-
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;
|
|
8050
8413
|
} catch {
|
|
8051
8414
|
return void 0;
|
|
8052
8415
|
}
|
|
@@ -8093,7 +8456,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
8093
8456
|
};
|
|
8094
8457
|
}
|
|
8095
8458
|
function runUpgrade(workspaceRoot, options) {
|
|
8096
|
-
if (!fileExists((0,
|
|
8459
|
+
if (!fileExists((0, import_node_path37.join)(workspaceRoot, "nx.json"))) {
|
|
8097
8460
|
throw new Error(
|
|
8098
8461
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
8099
8462
|
);
|
|
@@ -8158,7 +8521,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
8158
8521
|
|
|
8159
8522
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8160
8523
|
async function runInteractive() {
|
|
8161
|
-
const inWorkspace = fileExists((0,
|
|
8524
|
+
const inWorkspace = fileExists((0, import_node_path38.join)(process.cwd(), "nx.json"));
|
|
8162
8525
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
8163
8526
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
8164
8527
|
const choiceUpgrade = {
|
|
@@ -8211,7 +8574,7 @@ function buildProgram(cliVersion) {
|
|
|
8211
8574
|
runDoctor(process.cwd(), options);
|
|
8212
8575
|
});
|
|
8213
8576
|
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
8214
|
-
"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. 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"
|
|
8215
8578
|
).action(async (phase) => {
|
|
8216
8579
|
process.exitCode = await runCiPhase(phase, process.cwd());
|
|
8217
8580
|
});
|