@mnci/cli 4.19.0 → 4.21.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 +501 -312
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -280,6 +280,10 @@ function runPack(workspaceRoot, dependencies = {}) {
|
|
|
280
280
|
return status;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
// src/ci-pipeline/release.use-case.ts
|
|
284
|
+
var import_node_fs4 = require("fs");
|
|
285
|
+
var import_node_path4 = require("path");
|
|
286
|
+
|
|
283
287
|
// src/workspace-overlay/overlay.use-case.ts
|
|
284
288
|
var import_node_fs3 = require("fs");
|
|
285
289
|
var import_node_path3 = require("path");
|
|
@@ -2278,6 +2282,180 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2278
2282
|
}
|
|
2279
2283
|
}
|
|
2280
2284
|
|
|
2285
|
+
// src/ci-pipeline/release.use-case.ts
|
|
2286
|
+
var SPECIFIER = /^(?:major|minor|patch|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2287
|
+
function hasTag(workspaceRoot, relativePath, tag) {
|
|
2288
|
+
try {
|
|
2289
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path4.join)(workspaceRoot, relativePath), "utf8"));
|
|
2290
|
+
const tags = relativePath.endsWith("project.json") ? parsed.tags : parsed.nx?.tags;
|
|
2291
|
+
return Array.isArray(tags) && tags.includes(tag);
|
|
2292
|
+
} catch {
|
|
2293
|
+
return false;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
function releasableCounts(workspaceRoot) {
|
|
2297
|
+
return {
|
|
2298
|
+
npm: (0, import_node_fs4.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length,
|
|
2299
|
+
csharp: (0, import_node_fs4.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }).length,
|
|
2300
|
+
python: (0, import_node_fs4.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot }).length,
|
|
2301
|
+
dart: (0, import_node_fs4.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }).length,
|
|
2302
|
+
vscode: (0, import_node_fs4.globSync)("apps/*/package.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, VSCODE_EXTENSION_TAG)).length,
|
|
2303
|
+
go: (0, import_node_fs4.globSync)("apps/*/project.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, GO_RELEASE_TAG)).length
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
function shallowCloneGuard(processes, log) {
|
|
2307
|
+
const result = processes.capture("git", ["rev-parse", "--is-shallow-repository"]);
|
|
2308
|
+
if (result.status !== 0) {
|
|
2309
|
+
log("Could not determine whether this checkout has full history (git rev-parse --is-shallow-repository failed) - refusing to release. " + result.stdout.trim());
|
|
2310
|
+
return 1;
|
|
2311
|
+
}
|
|
2312
|
+
if (result.stdout.trim() === "true") {
|
|
2313
|
+
log("This checkout is a shallow clone. nx release resolves the current version of each package from its git tag, and silently falls back to the permanently-stale on-disk version when a tag cannot be found - which can propose, and publish, a version DOWNGRADE. Fetch full history before releasing - set fetchDepth (Azure) or fetch-depth (GitHub) to 0.");
|
|
2314
|
+
return 1;
|
|
2315
|
+
}
|
|
2316
|
+
return 0;
|
|
2317
|
+
}
|
|
2318
|
+
function npmPreflight(workspaceRoot, registryKind, environment, processes, log) {
|
|
2319
|
+
if (registryKind !== "npm" || (0, import_node_fs4.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length === 0) {
|
|
2320
|
+
return 0;
|
|
2321
|
+
}
|
|
2322
|
+
if (!environment.NODE_AUTH_TOKEN) {
|
|
2323
|
+
log("NPM_TOKEN is empty or unset, so the publish would fail AFTER nx release has already tagged. Add it as a repository secret named exactly NPM_TOKEN - under Actions, not the Dependabot or Codespaces tab, and not an Environment secret. Use an npm Automation token - a Publish token is refused by 2FA in CI.");
|
|
2324
|
+
return 1;
|
|
2325
|
+
}
|
|
2326
|
+
const whoami = processes.capture("npm", ["whoami", "--registry=https://registry.npmjs.org/"]);
|
|
2327
|
+
if (whoami.status !== 0) {
|
|
2328
|
+
log("NPM_TOKEN is set but the registry rejected it - " + whoami.stdout.trim() + ". Check that it has not expired and that it grants publish rights on this scope.");
|
|
2329
|
+
return 1;
|
|
2330
|
+
}
|
|
2331
|
+
log("npm auth OK as " + whoami.stdout.trim());
|
|
2332
|
+
return 0;
|
|
2333
|
+
}
|
|
2334
|
+
async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetchStatus) {
|
|
2335
|
+
const files = (0, import_node_fs4.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot });
|
|
2336
|
+
if (registryKind !== "npm" || files.length === 0) {
|
|
2337
|
+
return 0;
|
|
2338
|
+
}
|
|
2339
|
+
if (!environment.PYPI_TOKEN) {
|
|
2340
|
+
log("PYPI_TOKEN is empty or unset, so the publish would fail AFTER nx release has already tagged. Add it as a repository secret named exactly PYPI_TOKEN - under Actions, not the Dependabot or Codespaces tab, and not an Environment secret.");
|
|
2341
|
+
return 1;
|
|
2342
|
+
}
|
|
2343
|
+
if (!environment.PYPI_TOKEN.startsWith("pypi-")) {
|
|
2344
|
+
log("PYPI_TOKEN does not look like a PyPI API token - every one of them begins with pypi-. A password or a truncated paste is rejected only at upload time, which is AFTER nx release has tagged.");
|
|
2345
|
+
return 1;
|
|
2346
|
+
}
|
|
2347
|
+
const names = files.map((file) => {
|
|
2348
|
+
const text = (0, import_node_fs4.readFileSync)((0, import_node_path4.join)(workspaceRoot, file), "utf8");
|
|
2349
|
+
const block = text.slice(text.indexOf("[project]"));
|
|
2350
|
+
const line = block.split("\n").find((entry) => entry.trimStart().startsWith("name"));
|
|
2351
|
+
return line ? line.split("=", 2)[1].replaceAll(/[^\w.-]/gi, "") : "";
|
|
2352
|
+
}).filter(Boolean);
|
|
2353
|
+
const fresh = [];
|
|
2354
|
+
for (const name of names) {
|
|
2355
|
+
try {
|
|
2356
|
+
const status = await fetchStatus("https://pypi.org/pypi/" + name.toLowerCase().replaceAll(/[-_.]+/g, "-") + "/json");
|
|
2357
|
+
if (status === 404) {
|
|
2358
|
+
fresh.push(name);
|
|
2359
|
+
}
|
|
2360
|
+
} catch {
|
|
2361
|
+
log("Could not reach PyPI to check " + name + " - continuing.");
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
if (fresh.length > 0) {
|
|
2365
|
+
log("NOTE - this release may CREATE " + fresh.length + " new PyPI project(s) - " + fresh.join(", ") + ". Project creation is rate limited per account, and a 429 there arrives AFTER nx release has tagged - leaving those versions tagged with nothing published, and skipped forever. If that happens, delete the tags for the versions that did not publish before releasing again.");
|
|
2366
|
+
}
|
|
2367
|
+
return 0;
|
|
2368
|
+
}
|
|
2369
|
+
function applyPublishCredentials(workspaceRoot, registry, counts, environment, log) {
|
|
2370
|
+
const pythonUrl = pythonPublishUrl(registry);
|
|
2371
|
+
const nugetUrl = nugetFeedUrl(registry);
|
|
2372
|
+
if (counts.python > 0) {
|
|
2373
|
+
if (pythonUrl !== void 0) {
|
|
2374
|
+
if (!environment.PAT) {
|
|
2375
|
+
log("This workspace has " + counts.python + " Python package(s) to publish to Azure Artifacts but PAT is empty. Add your base64-encoded Azure DevOps PAT as a secret named PAT, or remove the Python packages from release.projects.");
|
|
2376
|
+
return 1;
|
|
2377
|
+
}
|
|
2378
|
+
environment.TWINE_REPOSITORY_URL = pythonUrl;
|
|
2379
|
+
environment.TWINE_USERNAME = "AzureArtifacts";
|
|
2380
|
+
environment.TWINE_PASSWORD = Buffer.from(environment.PAT, "base64").toString();
|
|
2381
|
+
} else if (registry.kind === "npm") {
|
|
2382
|
+
environment.TWINE_USERNAME = "__token__";
|
|
2383
|
+
environment.TWINE_PASSWORD = environment.PYPI_TOKEN;
|
|
2384
|
+
environment.TWINE_NON_INTERACTIVE = "1";
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
if (nugetUrl !== void 0 && counts.csharp > 0) {
|
|
2388
|
+
if (!environment.PAT) {
|
|
2389
|
+
log("This workspace has " + counts.csharp + " C# package(s) to publish to Azure Artifacts but PAT is empty. Add your base64-encoded Azure DevOps PAT as a secret named PAT, or remove the C# packages from release.projects.");
|
|
2390
|
+
return 1;
|
|
2391
|
+
}
|
|
2392
|
+
environment.NUGET_PAT = Buffer.from(environment.PAT, "base64").toString();
|
|
2393
|
+
}
|
|
2394
|
+
return 0;
|
|
2395
|
+
}
|
|
2396
|
+
function runReleaseCommand(workspaceRoot, registry, counts, environment, processes, log) {
|
|
2397
|
+
const total = counts.npm + counts.python + counts.csharp + counts.dart + counts.vscode + counts.go;
|
|
2398
|
+
if (total === 0) {
|
|
2399
|
+
log("Nothing to release - skipping.");
|
|
2400
|
+
return 0;
|
|
2401
|
+
}
|
|
2402
|
+
const specifier = environment.RELEASE_SPECIFIER ?? "";
|
|
2403
|
+
const extra = [];
|
|
2404
|
+
if (specifier !== "") {
|
|
2405
|
+
if (!SPECIFIER.test(specifier)) {
|
|
2406
|
+
log("RELEASE_SPECIFIER value '" + specifier + "' is invalid - use major, minor, patch, or an exact version like 1.2.3.");
|
|
2407
|
+
return 1;
|
|
2408
|
+
}
|
|
2409
|
+
if (/^(?:major|minor|patch)$/.test(specifier) && total > 1) {
|
|
2410
|
+
log("RELEASE_SPECIFIER is a keyword ('" + specifier + "') but this workspace has " + total + " releasable packages - a keyword under-bumps interdependent packages, because nx computes the dependency-bump pass from a stale cached version. Set RELEASE_SPECIFIER to an exact version instead, or clear it.");
|
|
2411
|
+
return 1;
|
|
2412
|
+
}
|
|
2413
|
+
extra.push(specifier);
|
|
2414
|
+
}
|
|
2415
|
+
const credentials = applyPublishCredentials(workspaceRoot, registry, counts, environment, log);
|
|
2416
|
+
if (credentials !== 0) {
|
|
2417
|
+
return credentials;
|
|
2418
|
+
}
|
|
2419
|
+
return processes.run("npx", ["nx", "release", ...extra, "--yes"]);
|
|
2420
|
+
}
|
|
2421
|
+
async function runRelease(workspaceRoot, dependencies = {}) {
|
|
2422
|
+
const environment = dependencies.environment ?? process.env;
|
|
2423
|
+
const processes = dependencies.processes ?? {
|
|
2424
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2425
|
+
capture: (command, arguments_) => runCapture(command, arguments_, workspaceRoot)
|
|
2426
|
+
};
|
|
2427
|
+
const log = dependencies.log ?? ((message) => {
|
|
2428
|
+
console.log(message);
|
|
2429
|
+
});
|
|
2430
|
+
const fetchStatus = dependencies.fetchStatus ?? (async (url) => {
|
|
2431
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(1e4) });
|
|
2432
|
+
return response.status;
|
|
2433
|
+
});
|
|
2434
|
+
const host = detectCiHost(environment);
|
|
2435
|
+
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
2436
|
+
log(groupStart(host, "Release"));
|
|
2437
|
+
const close = (status) => {
|
|
2438
|
+
const closing = groupEnd(host);
|
|
2439
|
+
if (closing !== void 0) {
|
|
2440
|
+
log(closing);
|
|
2441
|
+
}
|
|
2442
|
+
return status;
|
|
2443
|
+
};
|
|
2444
|
+
const shallow = shallowCloneGuard(processes, log);
|
|
2445
|
+
if (shallow !== 0) {
|
|
2446
|
+
return close(shallow);
|
|
2447
|
+
}
|
|
2448
|
+
const npm = npmPreflight(workspaceRoot, registry.kind, environment, processes, log);
|
|
2449
|
+
if (npm !== 0) {
|
|
2450
|
+
return close(npm);
|
|
2451
|
+
}
|
|
2452
|
+
const pypi = await pypiPreflight(workspaceRoot, registry.kind, environment, log, fetchStatus);
|
|
2453
|
+
if (pypi !== 0) {
|
|
2454
|
+
return close(pypi);
|
|
2455
|
+
}
|
|
2456
|
+
return close(runReleaseCommand(workspaceRoot, registry, releasableCounts(workspaceRoot), environment, processes, log));
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2281
2459
|
// src/ci-pipeline/verify.use-case.ts
|
|
2282
2460
|
function runVerify(workspaceRoot, dependencies = {}) {
|
|
2283
2461
|
const environment = dependencies.environment ?? process.env;
|
|
@@ -2329,7 +2507,7 @@ function runVerify(workspaceRoot, dependencies = {}) {
|
|
|
2329
2507
|
}
|
|
2330
2508
|
|
|
2331
2509
|
// src/ci-pipeline/index.ts
|
|
2332
|
-
var CI_PHASES = ["verify", "pack"];
|
|
2510
|
+
var CI_PHASES = ["verify", "pack", "release"];
|
|
2333
2511
|
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
2334
2512
|
switch (phase) {
|
|
2335
2513
|
case "verify": {
|
|
@@ -2338,11 +2516,14 @@ function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
|
2338
2516
|
case "pack": {
|
|
2339
2517
|
return runPack(workspaceRoot, dependencies);
|
|
2340
2518
|
}
|
|
2519
|
+
case "release": {
|
|
2520
|
+
return runRelease(workspaceRoot, dependencies);
|
|
2521
|
+
}
|
|
2341
2522
|
}
|
|
2342
2523
|
}
|
|
2343
2524
|
|
|
2344
2525
|
// src/project-scaffolding/add-project.use-case.ts
|
|
2345
|
-
var
|
|
2526
|
+
var import_node_path25 = require("path");
|
|
2346
2527
|
var import_prompts3 = require("@inquirer/prompts");
|
|
2347
2528
|
|
|
2348
2529
|
// src/project-name/project-name.validator.ts
|
|
@@ -2355,14 +2536,14 @@ function assertValidProjectName(name, label) {
|
|
|
2355
2536
|
}
|
|
2356
2537
|
|
|
2357
2538
|
// src/project-scaffolding/csharp.use-case.ts
|
|
2358
|
-
var
|
|
2359
|
-
var
|
|
2539
|
+
var import_node_fs6 = require("fs");
|
|
2540
|
+
var import_node_path6 = require("path");
|
|
2360
2541
|
|
|
2361
2542
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2362
|
-
var
|
|
2363
|
-
var
|
|
2543
|
+
var import_node_fs5 = require("fs");
|
|
2544
|
+
var import_node_path5 = require("path");
|
|
2364
2545
|
function hasPlugin(workspaceRoot, packageName) {
|
|
2365
|
-
const manifest = readJson((0,
|
|
2546
|
+
const manifest = readJson((0, import_node_path5.join)(workspaceRoot, "package.json"));
|
|
2366
2547
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
2367
2548
|
return Object.hasOwn(installed, packageName);
|
|
2368
2549
|
}
|
|
@@ -2401,7 +2582,7 @@ function markPublic(manifestPath) {
|
|
|
2401
2582
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
2402
2583
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
2403
2584
|
writeFileEnsured(
|
|
2404
|
-
(0,
|
|
2585
|
+
(0, import_node_path5.join)(projectRoot, "README.md"),
|
|
2405
2586
|
[
|
|
2406
2587
|
`# ${projectName}`,
|
|
2407
2588
|
"",
|
|
@@ -2420,13 +2601,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
2420
2601
|
}
|
|
2421
2602
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
2422
2603
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
2423
|
-
const directory = (0,
|
|
2604
|
+
const directory = (0, import_node_path5.join)(workspaceRoot, scaffold);
|
|
2424
2605
|
try {
|
|
2425
|
-
const holdsAProject = (0,
|
|
2606
|
+
const holdsAProject = (0, import_node_fs5.readdirSync)(directory, { withFileTypes: true }).some(
|
|
2426
2607
|
(entry) => entry.isDirectory()
|
|
2427
2608
|
);
|
|
2428
2609
|
if (holdsAProject) {
|
|
2429
|
-
(0,
|
|
2610
|
+
(0, import_node_fs5.rmSync)((0, import_node_path5.join)(directory, ".gitkeep"), { force: true });
|
|
2430
2611
|
}
|
|
2431
2612
|
} catch {
|
|
2432
2613
|
}
|
|
@@ -2446,7 +2627,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
2446
2627
|
}
|
|
2447
2628
|
}
|
|
2448
2629
|
function defaultScope(workspaceRoot) {
|
|
2449
|
-
const { name } = readJson((0,
|
|
2630
|
+
const { name } = readJson((0, import_node_path5.join)(workspaceRoot, "package.json"));
|
|
2450
2631
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
2451
2632
|
return `@${base}`;
|
|
2452
2633
|
}
|
|
@@ -2474,14 +2655,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
2474
2655
|
];
|
|
2475
2656
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
2476
2657
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
2477
|
-
(0,
|
|
2658
|
+
(0, import_node_fs5.rmSync)((0, import_node_path5.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
2478
2659
|
}
|
|
2479
|
-
(0,
|
|
2660
|
+
(0, import_node_fs5.rmSync)((0, import_node_path5.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
2480
2661
|
}
|
|
2481
2662
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
2482
2663
|
try {
|
|
2483
|
-
const entry = (0,
|
|
2484
|
-
return entry ? (0,
|
|
2664
|
+
const entry = (0, import_node_fs5.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
2665
|
+
return entry ? (0, import_node_path5.join)(workspaceRoot, entry) : void 0;
|
|
2485
2666
|
} catch {
|
|
2486
2667
|
return void 0;
|
|
2487
2668
|
}
|
|
@@ -2492,34 +2673,42 @@ function projectTask(name, kind) {
|
|
|
2492
2673
|
return kind === "start" ? { ...base, isBackground: true } : { ...base, group: kind };
|
|
2493
2674
|
}
|
|
2494
2675
|
function renameScaffoldPlaceholder(projectRoot, name) {
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2676
|
+
const sourceDir = (0, import_node_path5.join)(projectRoot, "src");
|
|
2677
|
+
const placeholder = (0, import_node_path5.join)(sourceDir, "lib", `${name}.ts`);
|
|
2678
|
+
if (!(0, import_node_fs5.existsSync)(placeholder)) {
|
|
2497
2679
|
return;
|
|
2498
2680
|
}
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2681
|
+
const sliceDir = (0, import_node_path5.join)(sourceDir, name);
|
|
2682
|
+
(0, import_node_fs5.mkdirSync)(sliceDir, { recursive: true });
|
|
2683
|
+
(0, import_node_fs5.renameSync)(placeholder, (0, import_node_path5.join)(sliceDir, `${name}.use-case.ts`));
|
|
2684
|
+
const spec = (0, import_node_path5.join)(sourceDir, "lib", `${name}.spec.ts`);
|
|
2685
|
+
if ((0, import_node_fs5.existsSync)(spec)) {
|
|
2686
|
+
const renamed = (0, import_node_path5.join)(sliceDir, `${name}.use-case.spec.ts`);
|
|
2687
|
+
(0, import_node_fs5.renameSync)(spec, renamed);
|
|
2504
2688
|
writeFileEnsured(
|
|
2505
2689
|
renamed,
|
|
2506
|
-
|
|
2690
|
+
// The spec still sits beside the implementation, so only its role suffix changes.
|
|
2691
|
+
repointSpecifier((0, import_node_fs5.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.use-case`)
|
|
2507
2692
|
);
|
|
2508
2693
|
}
|
|
2509
|
-
const barrel = (0,
|
|
2510
|
-
|
|
2694
|
+
const barrel = (0, import_node_path5.join)(sourceDir, "index.ts");
|
|
2695
|
+
const esm = (0, import_node_fs5.existsSync)(barrel) && (0, import_node_fs5.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
2696
|
+
writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}.use-case${esm ? ".js" : ""}'
|
|
2697
|
+
`);
|
|
2698
|
+
if ((0, import_node_fs5.existsSync)(barrel)) {
|
|
2511
2699
|
writeFileEnsured(
|
|
2512
2700
|
barrel,
|
|
2513
|
-
|
|
2701
|
+
(0, import_node_fs5.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2514
2702
|
);
|
|
2515
2703
|
}
|
|
2704
|
+
(0, import_node_fs5.rmSync)((0, import_node_path5.join)(sourceDir, "lib"), { recursive: true, force: true });
|
|
2516
2705
|
}
|
|
2517
2706
|
function repointSpecifier(source, from, to) {
|
|
2518
2707
|
return source.replaceAll(`${from}'`, () => `${to}'`).replaceAll(`${from}.js'`, () => `${to}.js'`);
|
|
2519
2708
|
}
|
|
2520
2709
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2521
|
-
const manifestPath = (0,
|
|
2522
|
-
if (!(0,
|
|
2710
|
+
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
2711
|
+
if (!(0, import_node_fs5.existsSync)(manifestPath)) {
|
|
2523
2712
|
return;
|
|
2524
2713
|
}
|
|
2525
2714
|
const manifest = readJson(manifestPath);
|
|
@@ -2542,11 +2731,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2542
2731
|
if (commands.start) {
|
|
2543
2732
|
scripts[`${name}:start`] = commands.start;
|
|
2544
2733
|
}
|
|
2545
|
-
const dependabotPath = (0,
|
|
2546
|
-
if ((0,
|
|
2734
|
+
const dependabotPath = (0, import_node_path5.join)(workspaceRoot, ".github/dependabot.yml");
|
|
2735
|
+
if ((0, import_node_fs5.existsSync)(dependabotPath)) {
|
|
2547
2736
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
2548
2737
|
}
|
|
2549
|
-
const manifestPath = (0,
|
|
2738
|
+
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
2550
2739
|
const manifest = readJson(manifestPath);
|
|
2551
2740
|
const existingScripts = manifest.scripts ?? {};
|
|
2552
2741
|
writeFileEnsured(
|
|
@@ -2584,7 +2773,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2584
2773
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
2585
2774
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
2586
2775
|
try {
|
|
2587
|
-
return readJson((0,
|
|
2776
|
+
return readJson((0, import_node_path5.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
2588
2777
|
} catch {
|
|
2589
2778
|
return {};
|
|
2590
2779
|
}
|
|
@@ -2596,7 +2785,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2596
2785
|
return;
|
|
2597
2786
|
}
|
|
2598
2787
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
2599
|
-
(root) => (0,
|
|
2788
|
+
(root) => (0, import_node_path5.join)(workspaceRoot, root, projectName, "package.json")
|
|
2600
2789
|
).find((candidate) => fileExists(candidate));
|
|
2601
2790
|
if (manifestPath === void 0) {
|
|
2602
2791
|
return;
|
|
@@ -2608,10 +2797,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2608
2797
|
const remaining = Object.fromEntries(
|
|
2609
2798
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
2610
2799
|
);
|
|
2611
|
-
const rootManifest = readJson((0,
|
|
2800
|
+
const rootManifest = readJson((0, import_node_path5.join)(workspaceRoot, "package.json"));
|
|
2612
2801
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
2613
2802
|
writeFileEnsured(
|
|
2614
|
-
(0,
|
|
2803
|
+
(0, import_node_path5.join)(workspaceRoot, "package.json"),
|
|
2615
2804
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
2616
2805
|
);
|
|
2617
2806
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -2671,7 +2860,7 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
2671
2860
|
ensureAdmZip(workspaceRoot);
|
|
2672
2861
|
const projectRoot = `apps/${name}`;
|
|
2673
2862
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
2674
|
-
addProjectJsonTargets((0,
|
|
2863
|
+
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2675
2864
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
2676
2865
|
start: csharpAppStartTarget(projectRoot)
|
|
2677
2866
|
});
|
|
@@ -2764,7 +2953,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
2764
2953
|
module.exports = CsharpVersionActions
|
|
2765
2954
|
`;
|
|
2766
2955
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
2767
|
-
writeFileEnsured((0,
|
|
2956
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
2768
2957
|
}
|
|
2769
2958
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
2770
2959
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -2779,7 +2968,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
2779
2968
|
);
|
|
2780
2969
|
}
|
|
2781
2970
|
function addInitialVersion(csprojPath) {
|
|
2782
|
-
const contents = (0,
|
|
2971
|
+
const contents = (0, import_node_fs6.readFileSync)(csprojPath, "utf8");
|
|
2783
2972
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
2784
2973
|
}
|
|
2785
2974
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -2794,14 +2983,14 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
2794
2983
|
const projectRoot = `packages/${name}`;
|
|
2795
2984
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
2796
2985
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
2797
|
-
addInitialVersion((0,
|
|
2986
|
+
addInitialVersion((0, import_node_path6.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
2798
2987
|
writeCsharpVersionActions(workspaceRoot);
|
|
2799
|
-
addProjectJsonReleaseVersionActions((0,
|
|
2800
|
-
addProjectJsonTargets((0,
|
|
2988
|
+
addProjectJsonReleaseVersionActions((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"));
|
|
2989
|
+
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2801
2990
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
2802
2991
|
});
|
|
2803
2992
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
2804
|
-
writeFileEnsured((0,
|
|
2993
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
2805
2994
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
2806
2995
|
}
|
|
2807
2996
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -2877,15 +3066,15 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
2877
3066
|
const projectRoot = `apps/${name}`;
|
|
2878
3067
|
const identity = pascalCase(name);
|
|
2879
3068
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
2880
|
-
const absoluteRoot = (0,
|
|
2881
|
-
writeFileEnsured((0,
|
|
2882
|
-
writeFileEnsured((0,
|
|
2883
|
-
writeFileEnsured((0,
|
|
2884
|
-
writeFileEnsured((0,
|
|
3069
|
+
const absoluteRoot = (0, import_node_path6.join)(workspaceRoot, projectRoot);
|
|
3070
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
3071
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
3072
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3073
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
2885
3074
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
2886
3075
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
2887
3076
|
}
|
|
2888
|
-
addProjectJsonTargets((0,
|
|
3077
|
+
addProjectJsonTargets((0, import_node_path6.join)(absoluteRoot, "project.json"), {
|
|
2889
3078
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
2890
3079
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
2891
3080
|
});
|
|
@@ -2893,7 +3082,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
2893
3082
|
}
|
|
2894
3083
|
|
|
2895
3084
|
// src/project-scaffolding/flutter.use-case.ts
|
|
2896
|
-
var
|
|
3085
|
+
var import_node_path7 = require("path");
|
|
2897
3086
|
function flutterAppStartTarget(name) {
|
|
2898
3087
|
return {
|
|
2899
3088
|
executor: "nx:run-commands",
|
|
@@ -2929,7 +3118,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
2929
3118
|
prepareFlutter(workspaceRoot);
|
|
2930
3119
|
ensureAdmZip(workspaceRoot);
|
|
2931
3120
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
2932
|
-
addProjectJsonTargets((0,
|
|
3121
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2933
3122
|
start: flutterAppStartTarget(name)
|
|
2934
3123
|
});
|
|
2935
3124
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -2946,18 +3135,18 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
2946
3135
|
}
|
|
2947
3136
|
|
|
2948
3137
|
// src/project-scaffolding/go.use-case.ts
|
|
2949
|
-
var
|
|
2950
|
-
var
|
|
3138
|
+
var import_node_fs10 = require("fs");
|
|
3139
|
+
var import_node_path11 = require("path");
|
|
2951
3140
|
|
|
2952
3141
|
// src/go-workspace/go-plugin.use-case.ts
|
|
2953
|
-
var
|
|
2954
|
-
var
|
|
3142
|
+
var import_node_fs7 = require("fs");
|
|
3143
|
+
var import_node_path8 = require("path");
|
|
2955
3144
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
2956
3145
|
function hasGoProject(workspaceRoot) {
|
|
2957
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0,
|
|
3146
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs7.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
2958
3147
|
return projectFiles.some((projectFile) => {
|
|
2959
3148
|
try {
|
|
2960
|
-
const { tags } = JSON.parse((0,
|
|
3149
|
+
const { tags } = JSON.parse((0, import_node_fs7.readFileSync)((0, import_node_path8.join)(workspaceRoot, projectFile), "utf8"));
|
|
2961
3150
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
2962
3151
|
} catch {
|
|
2963
3152
|
return false;
|
|
@@ -2965,7 +3154,7 @@ function hasGoProject(workspaceRoot) {
|
|
|
2965
3154
|
});
|
|
2966
3155
|
}
|
|
2967
3156
|
function isNxGoPluginRegistered(workspaceRoot) {
|
|
2968
|
-
const nxJsonPath = (0,
|
|
3157
|
+
const nxJsonPath = (0, import_node_path8.join)(workspaceRoot, "nx.json");
|
|
2969
3158
|
if (!fileExists(nxJsonPath)) {
|
|
2970
3159
|
return false;
|
|
2971
3160
|
}
|
|
@@ -2992,7 +3181,7 @@ function goModulePrefix(workspaceRoot) {
|
|
|
2992
3181
|
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
2993
3182
|
}
|
|
2994
3183
|
function registerNxGoPlugin(workspaceRoot) {
|
|
2995
|
-
const nxJsonPath = (0,
|
|
3184
|
+
const nxJsonPath = (0, import_node_path8.join)(workspaceRoot, "nx.json");
|
|
2996
3185
|
if (!fileExists(nxJsonPath)) {
|
|
2997
3186
|
return false;
|
|
2998
3187
|
}
|
|
@@ -3016,8 +3205,8 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3016
3205
|
}
|
|
3017
3206
|
|
|
3018
3207
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3019
|
-
var
|
|
3020
|
-
var
|
|
3208
|
+
var import_node_fs8 = require("fs");
|
|
3209
|
+
var import_node_path9 = require("path");
|
|
3021
3210
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3022
3211
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3023
3212
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -3143,7 +3332,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
3143
3332
|
}
|
|
3144
3333
|
};
|
|
3145
3334
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
3146
|
-
const projectJsonPath = (0,
|
|
3335
|
+
const projectJsonPath = (0, import_node_path9.join)(workspaceRoot, "apps", name, "project.json");
|
|
3147
3336
|
if (!fileExists(projectJsonPath)) {
|
|
3148
3337
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
3149
3338
|
}
|
|
@@ -3164,22 +3353,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
3164
3353
|
}
|
|
3165
3354
|
})
|
|
3166
3355
|
);
|
|
3167
|
-
writeFileEnsured((0,
|
|
3356
|
+
writeFileEnsured((0, import_node_path9.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
3168
3357
|
}
|
|
3169
3358
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
3170
|
-
const apps = (0,
|
|
3359
|
+
const apps = (0, import_node_path9.join)(workspaceRoot, "apps");
|
|
3171
3360
|
let entries;
|
|
3172
3361
|
try {
|
|
3173
|
-
entries = (0,
|
|
3362
|
+
entries = (0, import_node_fs8.readdirSync)(apps);
|
|
3174
3363
|
} catch {
|
|
3175
3364
|
return false;
|
|
3176
3365
|
}
|
|
3177
3366
|
const hasReleasableApp = entries.some((entry) => {
|
|
3178
|
-
const projectJsonPath = (0,
|
|
3367
|
+
const projectJsonPath = (0, import_node_path9.join)(apps, entry, "project.json");
|
|
3179
3368
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3180
3369
|
});
|
|
3181
|
-
const path = (0,
|
|
3182
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
3370
|
+
const path = (0, import_node_path9.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3371
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs8.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
3183
3372
|
return false;
|
|
3184
3373
|
}
|
|
3185
3374
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3187,8 +3376,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3187
3376
|
}
|
|
3188
3377
|
|
|
3189
3378
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3190
|
-
var
|
|
3191
|
-
var
|
|
3379
|
+
var import_node_fs9 = require("fs");
|
|
3380
|
+
var import_node_path10 = require("path");
|
|
3192
3381
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3193
3382
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
3194
3383
|
var GO_WEB_SOURCE = `package main
|
|
@@ -3266,18 +3455,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
3266
3455
|
}
|
|
3267
3456
|
`;
|
|
3268
3457
|
function assertWebApp(workspaceRoot, web) {
|
|
3269
|
-
const directory = (0,
|
|
3270
|
-
const isReactApp = fileExists((0,
|
|
3458
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, "apps", web);
|
|
3459
|
+
const isReactApp = fileExists((0, import_node_path10.join)(directory, "package.json")) && (0, import_node_fs9.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
3271
3460
|
if (!isReactApp) {
|
|
3272
3461
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
3273
3462
|
}
|
|
3274
3463
|
}
|
|
3275
3464
|
function webProjectName(workspaceRoot, web) {
|
|
3276
|
-
const manifest = readJson((0,
|
|
3465
|
+
const manifest = readJson((0, import_node_path10.join)(workspaceRoot, "apps", web, "package.json"));
|
|
3277
3466
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
3278
3467
|
}
|
|
3279
3468
|
function addApiProxy(viteConfigPath) {
|
|
3280
|
-
const source = (0,
|
|
3469
|
+
const source = (0, import_node_fs9.readFileSync)(viteConfigPath, "utf8");
|
|
3281
3470
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
3282
3471
|
return false;
|
|
3283
3472
|
}
|
|
@@ -3290,7 +3479,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
3290
3479
|
return true;
|
|
3291
3480
|
}
|
|
3292
3481
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
3293
|
-
const projectJsonPath = (0,
|
|
3482
|
+
const projectJsonPath = (0, import_node_path10.join)(workspaceRoot, "apps", name, "project.json");
|
|
3294
3483
|
const project = readJson(projectJsonPath);
|
|
3295
3484
|
const webName = webProjectName(workspaceRoot, web);
|
|
3296
3485
|
const targets = project.targets ?? {};
|
|
@@ -3316,13 +3505,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
3316
3505
|
projectJsonPath,
|
|
3317
3506
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
3318
3507
|
);
|
|
3319
|
-
const directory = (0,
|
|
3320
|
-
writeFileEnsured((0,
|
|
3321
|
-
writeFileEnsured((0,
|
|
3322
|
-
writeFileEnsured((0,
|
|
3323
|
-
writeFileEnsured((0,
|
|
3324
|
-
const viteConfig = (0,
|
|
3325
|
-
if (viteConfig === void 0 || !addApiProxy((0,
|
|
3508
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, "apps", name);
|
|
3509
|
+
writeFileEnsured((0, import_node_path10.join)(directory, ".gitignore"), "/web/\n");
|
|
3510
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
3511
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
3512
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
3513
|
+
const viteConfig = (0, import_node_fs9.readdirSync)((0, import_node_path10.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
3514
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path10.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
3326
3515
|
logger.warn(
|
|
3327
3516
|
`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.`
|
|
3328
3517
|
);
|
|
@@ -3356,7 +3545,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
3356
3545
|
}
|
|
3357
3546
|
}
|
|
3358
3547
|
function ensureGoModule(workspaceRoot) {
|
|
3359
|
-
if (fileExists((0,
|
|
3548
|
+
if (fileExists((0, import_node_path11.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path11.join)(workspaceRoot, "go.mod"))) {
|
|
3360
3549
|
return;
|
|
3361
3550
|
}
|
|
3362
3551
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -3364,26 +3553,26 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3364
3553
|
}
|
|
3365
3554
|
function readGoModModule(goModPath) {
|
|
3366
3555
|
try {
|
|
3367
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
3556
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs10.readFileSync)(goModPath, "utf8"))?.[1];
|
|
3368
3557
|
} catch {
|
|
3369
3558
|
return void 0;
|
|
3370
3559
|
}
|
|
3371
3560
|
}
|
|
3372
3561
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
3373
|
-
const projectModule = readGoModModule((0,
|
|
3562
|
+
const projectModule = readGoModModule((0, import_node_path11.join)(workspaceRoot, projectDir, "go.mod"));
|
|
3374
3563
|
if (projectModule !== void 0) {
|
|
3375
3564
|
return projectModule;
|
|
3376
3565
|
}
|
|
3377
|
-
const rootModule = readGoModModule((0,
|
|
3566
|
+
const rootModule = readGoModModule((0, import_node_path11.join)(workspaceRoot, "go.mod"));
|
|
3378
3567
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
3379
3568
|
}
|
|
3380
3569
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
3381
3570
|
const prefix = goModulePrefix(workspaceRoot);
|
|
3382
|
-
const goModPath = (0,
|
|
3571
|
+
const goModPath = (0, import_node_path11.join)(workspaceRoot, projectDir, "go.mod");
|
|
3383
3572
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
3384
3573
|
return;
|
|
3385
3574
|
}
|
|
3386
|
-
const rewritten = (0,
|
|
3575
|
+
const rewritten = (0, import_node_fs10.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
3387
3576
|
writeFileEnsured(goModPath, rewritten);
|
|
3388
3577
|
}
|
|
3389
3578
|
function goTestTarget() {
|
|
@@ -3461,16 +3650,16 @@ function goNativePackageTarget(name) {
|
|
|
3461
3650
|
}
|
|
3462
3651
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3463
3652
|
const changed = [];
|
|
3464
|
-
const apps = (0,
|
|
3653
|
+
const apps = (0, import_node_path11.join)(workspaceRoot, "apps");
|
|
3465
3654
|
if (!fileExists(apps)) {
|
|
3466
3655
|
return changed;
|
|
3467
3656
|
}
|
|
3468
|
-
for (const name of (0,
|
|
3469
|
-
const projectJsonPath = (0,
|
|
3657
|
+
for (const name of (0, import_node_fs10.readdirSync)(apps)) {
|
|
3658
|
+
const projectJsonPath = (0, import_node_path11.join)(apps, name, "project.json");
|
|
3470
3659
|
if (!fileExists(projectJsonPath)) {
|
|
3471
3660
|
continue;
|
|
3472
3661
|
}
|
|
3473
|
-
const project = JSON.parse((0,
|
|
3662
|
+
const project = JSON.parse((0, import_node_fs10.readFileSync)(projectJsonPath, "utf8"));
|
|
3474
3663
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3475
3664
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3476
3665
|
continue;
|
|
@@ -3506,8 +3695,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
3506
3695
|
}
|
|
3507
3696
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
3508
3697
|
const { packageName, functionName, fileStem } = goLibraryIdentifiers(projectName);
|
|
3509
|
-
(0,
|
|
3510
|
-
(0,
|
|
3698
|
+
(0, import_node_fs10.rmSync)((0, import_node_path11.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
3699
|
+
(0, import_node_fs10.rmSync)((0, import_node_path11.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
3511
3700
|
const files = [
|
|
3512
3701
|
[
|
|
3513
3702
|
"doc.go",
|
|
@@ -3517,14 +3706,14 @@ package ${packageName}
|
|
|
3517
3706
|
`
|
|
3518
3707
|
],
|
|
3519
3708
|
[
|
|
3520
|
-
(0,
|
|
3709
|
+
(0, import_node_path11.join)(packageName, "doc.go"),
|
|
3521
3710
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
3522
3711
|
// the outcome it delivers, and add one package per further outcome.
|
|
3523
3712
|
package ${packageName}
|
|
3524
3713
|
`
|
|
3525
3714
|
],
|
|
3526
3715
|
[
|
|
3527
|
-
(0,
|
|
3716
|
+
(0, import_node_path11.join)(packageName, `${fileStem}_use_case.go`),
|
|
3528
3717
|
`package ${packageName}
|
|
3529
3718
|
|
|
3530
3719
|
// ${functionName} is the generator's sample behaviour, kept so the slice builds and tests.
|
|
@@ -3534,7 +3723,7 @@ func ${functionName}(name string) string {
|
|
|
3534
3723
|
`
|
|
3535
3724
|
],
|
|
3536
3725
|
[
|
|
3537
|
-
(0,
|
|
3726
|
+
(0, import_node_path11.join)(packageName, `${fileStem}_use_case_test.go`),
|
|
3538
3727
|
`package ${packageName}
|
|
3539
3728
|
|
|
3540
3729
|
import "testing"
|
|
@@ -3548,7 +3737,7 @@ func Test${functionName}(t *testing.T) {
|
|
|
3548
3737
|
]
|
|
3549
3738
|
];
|
|
3550
3739
|
for (const [relativePath, content] of files) {
|
|
3551
|
-
const path = (0,
|
|
3740
|
+
const path = (0, import_node_path11.join)(projectRoot, relativePath);
|
|
3552
3741
|
if (!fileExists(path)) {
|
|
3553
3742
|
writeFileEnsured(path, content);
|
|
3554
3743
|
}
|
|
@@ -3583,7 +3772,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
3583
3772
|
workspaceRoot
|
|
3584
3773
|
);
|
|
3585
3774
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
3586
|
-
addProjectJsonTargets((0,
|
|
3775
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3587
3776
|
build: goBuildTarget(name),
|
|
3588
3777
|
test: goTestTarget(),
|
|
3589
3778
|
lint: goLintTarget(),
|
|
@@ -3622,7 +3811,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
3622
3811
|
workspaceRoot
|
|
3623
3812
|
);
|
|
3624
3813
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
3625
|
-
addProjectJsonTargets((0,
|
|
3814
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3626
3815
|
"build": goBuildTarget(name),
|
|
3627
3816
|
"test": goTestTarget(),
|
|
3628
3817
|
"lint": goLintTarget(),
|
|
@@ -3646,11 +3835,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
3646
3835
|
workspaceRoot
|
|
3647
3836
|
);
|
|
3648
3837
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
3649
|
-
addProjectJsonTargets((0,
|
|
3838
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
3650
3839
|
test: goTestTarget(),
|
|
3651
3840
|
lint: goLintTarget()
|
|
3652
3841
|
});
|
|
3653
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3842
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path11.join)(workspaceRoot, "packages", name), name);
|
|
3654
3843
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3655
3844
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
3656
3845
|
if (module2) {
|
|
@@ -3671,11 +3860,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3671
3860
|
workspaceRoot
|
|
3672
3861
|
);
|
|
3673
3862
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
3674
|
-
addProjectJsonTargets((0,
|
|
3863
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
3675
3864
|
test: goTestTarget(),
|
|
3676
3865
|
lint: goLintTarget()
|
|
3677
3866
|
});
|
|
3678
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3867
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path11.join)(workspaceRoot, "libs", name), name);
|
|
3679
3868
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3680
3869
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
3681
3870
|
if (module2) {
|
|
@@ -3684,7 +3873,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3684
3873
|
}
|
|
3685
3874
|
|
|
3686
3875
|
// src/project-scaffolding/node.use-case.ts
|
|
3687
|
-
var
|
|
3876
|
+
var import_node_path12 = require("path");
|
|
3688
3877
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
3689
3878
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
3690
3879
|
return;
|
|
@@ -3708,12 +3897,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
3708
3897
|
],
|
|
3709
3898
|
workspaceRoot
|
|
3710
3899
|
);
|
|
3711
|
-
const appRoot = (0,
|
|
3900
|
+
const appRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
3712
3901
|
separateDeclarationOutput(appRoot);
|
|
3713
3902
|
repairAssetMapping(appRoot, name);
|
|
3714
3903
|
}
|
|
3715
3904
|
function separateDeclarationOutput(appRoot) {
|
|
3716
|
-
const tsconfigPath = (0,
|
|
3905
|
+
const tsconfigPath = (0, import_node_path12.join)(appRoot, "tsconfig.app.json");
|
|
3717
3906
|
if (!fileExists(tsconfigPath)) {
|
|
3718
3907
|
return;
|
|
3719
3908
|
}
|
|
@@ -3735,7 +3924,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
3735
3924
|
);
|
|
3736
3925
|
}
|
|
3737
3926
|
function repairAssetMapping(appRoot, name) {
|
|
3738
|
-
const manifestPath = (0,
|
|
3927
|
+
const manifestPath = (0, import_node_path12.join)(appRoot, "package.json");
|
|
3739
3928
|
if (!fileExists(manifestPath)) {
|
|
3740
3929
|
return;
|
|
3741
3930
|
}
|
|
@@ -3762,7 +3951,7 @@ function nodeAppPackageTarget(name) {
|
|
|
3762
3951
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
3763
3952
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
3764
3953
|
ensureAdmZip(workspaceRoot);
|
|
3765
|
-
addNxTargets((0,
|
|
3954
|
+
addNxTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
3766
3955
|
package: nodeAppPackageTarget(name)
|
|
3767
3956
|
});
|
|
3768
3957
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -3818,10 +4007,10 @@ describe('buildGreeting', () => {
|
|
|
3818
4007
|
})
|
|
3819
4008
|
`;
|
|
3820
4009
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
3821
|
-
const manifestPath = (0,
|
|
4010
|
+
const manifestPath = (0, import_node_path12.join)(nodeFunctionAppRoot, "package.json");
|
|
3822
4011
|
const manifest = readJson(manifestPath);
|
|
3823
4012
|
const azureFunctionsVersion = readJson(
|
|
3824
|
-
(0,
|
|
4013
|
+
(0, import_node_path12.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
3825
4014
|
).version;
|
|
3826
4015
|
const dependencies = manifest.dependencies ?? {};
|
|
3827
4016
|
writeFileEnsured(
|
|
@@ -3864,21 +4053,21 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
3864
4053
|
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
3865
4054
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
3866
4055
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
3867
|
-
const nodeFunctionAppRoot = (0,
|
|
3868
|
-
writeFileEnsured((0,
|
|
3869
|
-
writeFileEnsured((0,
|
|
4056
|
+
const nodeFunctionAppRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
4057
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
4058
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/hello.ts"), NODE_FUNCTION_APP_HELLO);
|
|
3870
4059
|
writeFileEnsured(
|
|
3871
|
-
(0,
|
|
4060
|
+
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.ts"),
|
|
3872
4061
|
NODE_FUNCTION_APP_GREETING
|
|
3873
4062
|
);
|
|
3874
4063
|
writeFileEnsured(
|
|
3875
|
-
(0,
|
|
4064
|
+
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
3876
4065
|
NODE_FUNCTION_APP_GREETING_SPEC
|
|
3877
4066
|
);
|
|
3878
|
-
writeFileEnsured((0,
|
|
4067
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
3879
4068
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
3880
4069
|
ensureAdmZip(workspaceRoot);
|
|
3881
|
-
addNxTargets((0,
|
|
4070
|
+
addNxTargets((0, import_node_path12.join)(nodeFunctionAppRoot, "package.json"), {
|
|
3882
4071
|
package: nodeFunctionAppPackageTarget(name),
|
|
3883
4072
|
prune: nodeFunctionAppPruneTarget(name),
|
|
3884
4073
|
start: nodeFunctionAppStartTarget(name)
|
|
@@ -3888,11 +4077,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
3888
4077
|
}
|
|
3889
4078
|
|
|
3890
4079
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3891
|
-
var
|
|
4080
|
+
var import_node_path16 = require("path");
|
|
3892
4081
|
|
|
3893
4082
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
3894
|
-
var
|
|
3895
|
-
var
|
|
4083
|
+
var import_node_fs11 = require("fs");
|
|
4084
|
+
var import_node_path13 = require("path");
|
|
3896
4085
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
3897
4086
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
3898
4087
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -3915,14 +4104,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
3915
4104
|
}
|
|
3916
4105
|
function repairPublishableManifests(workspaceRoot) {
|
|
3917
4106
|
const changed = [];
|
|
3918
|
-
const manifests = (0,
|
|
4107
|
+
const manifests = (0, import_node_fs11.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
3919
4108
|
cwd: workspaceRoot
|
|
3920
4109
|
});
|
|
3921
4110
|
for (const relativePath of manifests) {
|
|
3922
|
-
const manifestPath = (0,
|
|
3923
|
-
const before = (0,
|
|
4111
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, relativePath);
|
|
4112
|
+
const before = (0, import_node_fs11.readFileSync)(manifestPath, "utf8");
|
|
3924
4113
|
repairPublishableManifest(manifestPath);
|
|
3925
|
-
const after = (0,
|
|
4114
|
+
const after = (0, import_node_fs11.readFileSync)(manifestPath, "utf8");
|
|
3926
4115
|
if (after !== before) {
|
|
3927
4116
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
3928
4117
|
}
|
|
@@ -3931,8 +4120,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
3931
4120
|
}
|
|
3932
4121
|
|
|
3933
4122
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3934
|
-
var
|
|
3935
|
-
var
|
|
4123
|
+
var import_node_fs12 = require("fs");
|
|
4124
|
+
var import_node_path14 = require("path");
|
|
3936
4125
|
|
|
3937
4126
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
3938
4127
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -4134,12 +4323,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
4134
4323
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4135
4324
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
4136
4325
|
const changed = [];
|
|
4137
|
-
const configs = (0,
|
|
4326
|
+
const configs = (0, import_node_fs12.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4138
4327
|
cwd: workspaceRoot
|
|
4139
4328
|
});
|
|
4140
4329
|
for (const relativePath of configs) {
|
|
4141
|
-
const configPath = (0,
|
|
4142
|
-
const before = (0,
|
|
4330
|
+
const configPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
4331
|
+
const before = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4143
4332
|
const after = withRollupSourceMaps(before);
|
|
4144
4333
|
if (after !== before) {
|
|
4145
4334
|
writeFileEnsured(configPath, after);
|
|
@@ -4150,12 +4339,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
4150
4339
|
}
|
|
4151
4340
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
4152
4341
|
const changed = [];
|
|
4153
|
-
const configs = (0,
|
|
4342
|
+
const configs = (0, import_node_fs12.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4154
4343
|
cwd: workspaceRoot
|
|
4155
4344
|
});
|
|
4156
4345
|
for (const relativePath of configs) {
|
|
4157
|
-
const configPath = (0,
|
|
4158
|
-
const before = (0,
|
|
4346
|
+
const configPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
4347
|
+
const before = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4159
4348
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
4160
4349
|
if (after !== before) {
|
|
4161
4350
|
writeFileEnsured(configPath, after);
|
|
@@ -4165,11 +4354,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
4165
4354
|
return changed;
|
|
4166
4355
|
}
|
|
4167
4356
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
4168
|
-
const configPath = (0,
|
|
4357
|
+
const configPath = (0, import_node_path14.join)(projectRoot, "rollup.config.cjs");
|
|
4169
4358
|
if (!fileExists(configPath)) {
|
|
4170
4359
|
return;
|
|
4171
4360
|
}
|
|
4172
|
-
const config = (0,
|
|
4361
|
+
const config = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4173
4362
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
4174
4363
|
return;
|
|
4175
4364
|
}
|
|
@@ -4178,10 +4367,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
4178
4367
|
}
|
|
4179
4368
|
|
|
4180
4369
|
// src/rollup-library/rollup-config.repository.ts
|
|
4181
|
-
var
|
|
4182
|
-
var
|
|
4370
|
+
var import_node_fs13 = require("fs");
|
|
4371
|
+
var import_node_path15 = require("path");
|
|
4183
4372
|
function resolveRequireTarget(fromDir, specifier) {
|
|
4184
|
-
const base = (0,
|
|
4373
|
+
const base = (0, import_node_path15.join)(fromDir, specifier);
|
|
4185
4374
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
4186
4375
|
}
|
|
4187
4376
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -4191,7 +4380,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4191
4380
|
visited.add(configPath);
|
|
4192
4381
|
let text;
|
|
4193
4382
|
try {
|
|
4194
|
-
text = (0,
|
|
4383
|
+
text = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
4195
4384
|
} catch {
|
|
4196
4385
|
return "";
|
|
4197
4386
|
}
|
|
@@ -4199,15 +4388,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4199
4388
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
4200
4389
|
(match) => match[2]
|
|
4201
4390
|
);
|
|
4202
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
4391
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path15.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
4203
4392
|
return [text, ...requiredText].join("\n");
|
|
4204
4393
|
}
|
|
4205
4394
|
|
|
4206
4395
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4207
4396
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4208
4397
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4209
|
-
const projectRoot = (0,
|
|
4210
|
-
const manifestPath = (0,
|
|
4398
|
+
const projectRoot = (0, import_node_path16.join)(workspaceRoot, "packages", name);
|
|
4399
|
+
const manifestPath = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4211
4400
|
runGeneratorAndRepair(
|
|
4212
4401
|
workspaceRoot,
|
|
4213
4402
|
[
|
|
@@ -4236,8 +4425,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4236
4425
|
}
|
|
4237
4426
|
|
|
4238
4427
|
// src/project-scaffolding/python.use-case.ts
|
|
4239
|
-
var
|
|
4240
|
-
var
|
|
4428
|
+
var import_node_fs14 = require("fs");
|
|
4429
|
+
var import_node_path17 = require("path");
|
|
4241
4430
|
function ensurePython(workspaceRoot) {
|
|
4242
4431
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
4243
4432
|
if (!hasPython) {
|
|
@@ -4260,7 +4449,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
4260
4449
|
registerPythonGraphPlugin(workspaceRoot);
|
|
4261
4450
|
}
|
|
4262
4451
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
4263
|
-
const nxJsonPath = (0,
|
|
4452
|
+
const nxJsonPath = (0, import_node_path17.join)(workspaceRoot, "nx.json");
|
|
4264
4453
|
if (!fileExists(nxJsonPath)) {
|
|
4265
4454
|
return;
|
|
4266
4455
|
}
|
|
@@ -4283,7 +4472,7 @@ pytest
|
|
|
4283
4472
|
pip-audit
|
|
4284
4473
|
`;
|
|
4285
4474
|
function ensureRequirementsDev(workspaceRoot) {
|
|
4286
|
-
const requirementsDevPath = (0,
|
|
4475
|
+
const requirementsDevPath = (0, import_node_path17.join)(workspaceRoot, "requirements-dev.txt");
|
|
4287
4476
|
if (!fileExists(requirementsDevPath)) {
|
|
4288
4477
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
4289
4478
|
}
|
|
@@ -4343,8 +4532,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
4343
4532
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
4344
4533
|
workspaceRoot
|
|
4345
4534
|
);
|
|
4346
|
-
writeFileEnsured((0,
|
|
4347
|
-
addProjectJsonTargets((0,
|
|
4535
|
+
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
4536
|
+
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4348
4537
|
package: pythonAppPackageTarget(name),
|
|
4349
4538
|
start: pythonAppStartTarget(name)
|
|
4350
4539
|
});
|
|
@@ -4366,7 +4555,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
4366
4555
|
workspaceRoot
|
|
4367
4556
|
);
|
|
4368
4557
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
4369
|
-
addProjectJsonTargets((0,
|
|
4558
|
+
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4370
4559
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
4371
4560
|
start: pythonFunctionAppStartTarget(name)
|
|
4372
4561
|
});
|
|
@@ -4407,7 +4596,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
4407
4596
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
4408
4597
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
4409
4598
|
return PYTHON_PROJECT_DIRS.find(
|
|
4410
|
-
(directory) => fileExists((0,
|
|
4599
|
+
(directory) => fileExists((0, import_node_path17.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
4411
4600
|
);
|
|
4412
4601
|
}
|
|
4413
4602
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -4446,7 +4635,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4446
4635
|
`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.`
|
|
4447
4636
|
);
|
|
4448
4637
|
}
|
|
4449
|
-
if (!fileExists((0,
|
|
4638
|
+
if (!fileExists((0, import_node_path17.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
4450
4639
|
throw new Error(
|
|
4451
4640
|
`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.`
|
|
4452
4641
|
);
|
|
@@ -4454,8 +4643,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4454
4643
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
4455
4644
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
4456
4645
|
}
|
|
4457
|
-
const pyprojectPath = (0,
|
|
4458
|
-
const pyprojectToml = (0,
|
|
4646
|
+
const pyprojectPath = (0, import_node_path17.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
4647
|
+
const pyprojectToml = (0, import_node_fs14.readFileSync)(pyprojectPath, "utf8");
|
|
4459
4648
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
4460
4649
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
4461
4650
|
return;
|
|
@@ -4467,8 +4656,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4467
4656
|
}
|
|
4468
4657
|
|
|
4469
4658
|
// src/project-scaffolding/react-app.use-case.ts
|
|
4470
|
-
var
|
|
4471
|
-
var
|
|
4659
|
+
var import_node_fs15 = require("fs");
|
|
4660
|
+
var import_node_path18 = require("path");
|
|
4472
4661
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
4473
4662
|
function reactEnvironmentFile(environment) {
|
|
4474
4663
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -4505,12 +4694,12 @@ function reactAppTargets(name) {
|
|
|
4505
4694
|
return targets;
|
|
4506
4695
|
}
|
|
4507
4696
|
function allowEnvFiles(workspaceRoot) {
|
|
4508
|
-
const gitignorePath = (0,
|
|
4697
|
+
const gitignorePath = (0, import_node_path18.join)(workspaceRoot, ".gitignore");
|
|
4509
4698
|
if (!fileExists(gitignorePath)) {
|
|
4510
4699
|
return;
|
|
4511
4700
|
}
|
|
4512
4701
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
4513
|
-
const current = (0,
|
|
4702
|
+
const current = (0, import_node_fs15.readFileSync)(gitignorePath, "utf8");
|
|
4514
4703
|
if (current.includes(marker)) {
|
|
4515
4704
|
return;
|
|
4516
4705
|
}
|
|
@@ -4537,24 +4726,24 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4537
4726
|
workspaceRoot
|
|
4538
4727
|
);
|
|
4539
4728
|
ensureAdmZip(workspaceRoot);
|
|
4540
|
-
const reactAppRoot = (0,
|
|
4729
|
+
const reactAppRoot = (0, import_node_path18.join)(workspaceRoot, "apps", name);
|
|
4541
4730
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
4542
|
-
writeFileEnsured((0,
|
|
4731
|
+
writeFileEnsured((0, import_node_path18.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
4543
4732
|
}
|
|
4544
4733
|
allowEnvFiles(workspaceRoot);
|
|
4545
|
-
addNxTargets((0,
|
|
4734
|
+
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4546
4735
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4547
4736
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4548
4737
|
}
|
|
4549
4738
|
|
|
4550
4739
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
4551
|
-
var
|
|
4740
|
+
var import_node_path19 = require("path");
|
|
4552
4741
|
var REACT_LIB_BUNDLER = "rollup";
|
|
4553
4742
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4554
4743
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4555
4744
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4556
|
-
const projectRoot = (0,
|
|
4557
|
-
const publishableManifest = (0,
|
|
4745
|
+
const projectRoot = (0, import_node_path19.join)(workspaceRoot, "packages", name);
|
|
4746
|
+
const publishableManifest = (0, import_node_path19.join)(projectRoot, "package.json");
|
|
4558
4747
|
runGeneratorAndRepair(
|
|
4559
4748
|
workspaceRoot,
|
|
4560
4749
|
[
|
|
@@ -4583,8 +4772,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4583
4772
|
}
|
|
4584
4773
|
function addReactInternalLib(workspaceRoot, name, stack) {
|
|
4585
4774
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4586
|
-
const projectRoot = (0,
|
|
4587
|
-
const privateManifest = (0,
|
|
4775
|
+
const projectRoot = (0, import_node_path19.join)(workspaceRoot, "libs", name);
|
|
4776
|
+
const privateManifest = (0, import_node_path19.join)(projectRoot, "package.json");
|
|
4588
4777
|
runGeneratorAndRepair(
|
|
4589
4778
|
workspaceRoot,
|
|
4590
4779
|
[
|
|
@@ -4610,8 +4799,8 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
4610
4799
|
}
|
|
4611
4800
|
|
|
4612
4801
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
4613
|
-
var
|
|
4614
|
-
var
|
|
4802
|
+
var import_node_fs16 = require("fs");
|
|
4803
|
+
var import_node_path20 = require("path");
|
|
4615
4804
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
4616
4805
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
4617
4806
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -4796,8 +4985,8 @@ export const window = {
|
|
|
4796
4985
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
4797
4986
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
4798
4987
|
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}\` },`];
|
|
4799
|
-
const path = (0,
|
|
4800
|
-
const content = fileExists(path) ? (0,
|
|
4988
|
+
const path = (0, import_node_path20.join)(projectRoot, file);
|
|
4989
|
+
const content = fileExists(path) ? (0, import_node_fs16.readFileSync)(path, "utf8") : "";
|
|
4801
4990
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
4802
4991
|
if (line === void 0) {
|
|
4803
4992
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -4817,11 +5006,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
4817
5006
|
}
|
|
4818
5007
|
}
|
|
4819
5008
|
function defaultPublisher(workspaceRoot) {
|
|
4820
|
-
const { name } = readJson((0,
|
|
5009
|
+
const { name } = readJson((0, import_node_path20.join)(workspaceRoot, "package.json"));
|
|
4821
5010
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4822
5011
|
}
|
|
4823
5012
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
4824
|
-
const manifestPath = (0,
|
|
5013
|
+
const manifestPath = (0, import_node_path20.join)(projectRoot, "package.json");
|
|
4825
5014
|
const manifest = readJson(manifestPath);
|
|
4826
5015
|
const { nx = {}, ...rest } = manifest;
|
|
4827
5016
|
const targets = { ...nx.targets };
|
|
@@ -4885,11 +5074,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
4885
5074
|
};
|
|
4886
5075
|
}
|
|
4887
5076
|
function addDebugLaunch(workspaceRoot, name) {
|
|
4888
|
-
const file = (0,
|
|
5077
|
+
const file = (0, import_node_fs16.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4889
5078
|
if (file === void 0) {
|
|
4890
5079
|
return;
|
|
4891
5080
|
}
|
|
4892
|
-
const path = (0,
|
|
5081
|
+
const path = (0, import_node_path20.join)(workspaceRoot, file);
|
|
4893
5082
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
4894
5083
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4895
5084
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -4922,39 +5111,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
4922
5111
|
);
|
|
4923
5112
|
}
|
|
4924
5113
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4925
|
-
const apps = (0,
|
|
5114
|
+
const apps = (0, import_node_path20.join)(workspaceRoot, "apps");
|
|
4926
5115
|
let entries;
|
|
4927
5116
|
try {
|
|
4928
|
-
entries = (0,
|
|
5117
|
+
entries = (0, import_node_fs16.readdirSync)(apps);
|
|
4929
5118
|
} catch {
|
|
4930
5119
|
return false;
|
|
4931
5120
|
}
|
|
4932
5121
|
const hasExtension = entries.some((entry) => {
|
|
4933
|
-
const manifestPath = (0,
|
|
5122
|
+
const manifestPath = (0, import_node_path20.join)(apps, entry, "package.json");
|
|
4934
5123
|
if (!fileExists(manifestPath)) {
|
|
4935
5124
|
return false;
|
|
4936
5125
|
}
|
|
4937
5126
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4938
5127
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4939
5128
|
});
|
|
4940
|
-
const path = (0,
|
|
4941
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
5129
|
+
const path = (0, import_node_path20.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
5130
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs16.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
4942
5131
|
return false;
|
|
4943
5132
|
}
|
|
4944
5133
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4945
5134
|
return true;
|
|
4946
5135
|
}
|
|
4947
5136
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
4948
|
-
const apps = (0,
|
|
5137
|
+
const apps = (0, import_node_path20.join)(workspaceRoot, "apps");
|
|
4949
5138
|
let entries;
|
|
4950
5139
|
try {
|
|
4951
|
-
entries = (0,
|
|
5140
|
+
entries = (0, import_node_fs16.readdirSync)(apps);
|
|
4952
5141
|
} catch {
|
|
4953
5142
|
return [];
|
|
4954
5143
|
}
|
|
4955
5144
|
const updated = [];
|
|
4956
5145
|
for (const entry of entries) {
|
|
4957
|
-
const manifestPath = (0,
|
|
5146
|
+
const manifestPath = (0, import_node_path20.join)(apps, entry, "package.json");
|
|
4958
5147
|
if (!fileExists(manifestPath)) {
|
|
4959
5148
|
continue;
|
|
4960
5149
|
}
|
|
@@ -4974,22 +5163,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
4974
5163
|
}
|
|
4975
5164
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4976
5165
|
const { sidecar } = options;
|
|
4977
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
5166
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path20.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4978
5167
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4979
5168
|
}
|
|
4980
5169
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4981
5170
|
ensureVscodeToolchain(workspaceRoot);
|
|
4982
|
-
const projectRoot = (0,
|
|
5171
|
+
const projectRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
4983
5172
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
4984
|
-
addVscodeTypes((0,
|
|
4985
|
-
addVscodeTypes((0,
|
|
4986
|
-
writeFileEnsured((0,
|
|
4987
|
-
writeFileEnsured((0,
|
|
4988
|
-
writeFileEnsured((0,
|
|
5173
|
+
addVscodeTypes((0, import_node_path20.join)(projectRoot, "tsconfig.app.json"));
|
|
5174
|
+
addVscodeTypes((0, import_node_path20.join)(projectRoot, "tsconfig.spec.json"));
|
|
5175
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
5176
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
5177
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
4989
5178
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4990
|
-
writeFileEnsured((0,
|
|
4991
|
-
writeFileEnsured((0,
|
|
4992
|
-
addNxTargets((0,
|
|
5179
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
5180
|
+
writeFileEnsured((0, import_node_path20.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
5181
|
+
addNxTargets((0, import_node_path20.join)(projectRoot, "package.json"), {
|
|
4993
5182
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
4994
5183
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
4995
5184
|
});
|
|
@@ -5000,12 +5189,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5000
5189
|
}
|
|
5001
5190
|
|
|
5002
5191
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5003
|
-
var
|
|
5004
|
-
var
|
|
5192
|
+
var import_node_fs18 = require("fs");
|
|
5193
|
+
var import_node_path22 = require("path");
|
|
5005
5194
|
|
|
5006
5195
|
// src/dependency-management/manifest.repository.ts
|
|
5007
|
-
var
|
|
5008
|
-
var
|
|
5196
|
+
var import_node_fs17 = require("fs");
|
|
5197
|
+
var import_node_path21 = require("path");
|
|
5009
5198
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5010
5199
|
var ROOT_LABEL = "(root)";
|
|
5011
5200
|
var MANIFEST_GLOBS = {
|
|
@@ -5038,23 +5227,23 @@ function projectOf(manifestRelativePath) {
|
|
|
5038
5227
|
}
|
|
5039
5228
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
5040
5229
|
if (ecosystem === "go") {
|
|
5041
|
-
return fileExists((0,
|
|
5230
|
+
return fileExists((0, import_node_path21.join)(workspaceRoot, "go.mod"));
|
|
5042
5231
|
}
|
|
5043
5232
|
if (ecosystem === "nuget") {
|
|
5044
|
-
return (0,
|
|
5233
|
+
return (0, import_node_fs17.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
5045
5234
|
}
|
|
5046
5235
|
const rootMarker = {
|
|
5047
5236
|
npm: "package.json",
|
|
5048
5237
|
pip: "requirements-dev.txt",
|
|
5049
5238
|
pub: "pubspec.yaml"
|
|
5050
5239
|
};
|
|
5051
|
-
return fileExists((0,
|
|
5240
|
+
return fileExists((0, import_node_path21.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs17.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
5052
5241
|
}
|
|
5053
5242
|
function collectNpm(workspaceRoot) {
|
|
5054
5243
|
const sites = [];
|
|
5055
|
-
const relativePaths = ["package.json", ...(0,
|
|
5244
|
+
const relativePaths = ["package.json", ...(0, import_node_fs17.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
5056
5245
|
for (const relativePath of relativePaths) {
|
|
5057
|
-
const manifestPath = (0,
|
|
5246
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5058
5247
|
try {
|
|
5059
5248
|
const manifest = readJson(manifestPath);
|
|
5060
5249
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -5115,17 +5304,17 @@ function collectPip(workspaceRoot) {
|
|
|
5115
5304
|
name: parsed.name,
|
|
5116
5305
|
ecosystem: "pip",
|
|
5117
5306
|
project: projectOf(relativePath),
|
|
5118
|
-
manifestPath: (0,
|
|
5307
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5119
5308
|
section,
|
|
5120
5309
|
spec: parsed.spec,
|
|
5121
5310
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
5122
5311
|
});
|
|
5123
5312
|
};
|
|
5124
|
-
const pyprojectPaths = (0,
|
|
5313
|
+
const pyprojectPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
5125
5314
|
for (const relativePath of pyprojectPaths) {
|
|
5126
5315
|
let content;
|
|
5127
5316
|
try {
|
|
5128
|
-
content = (0,
|
|
5317
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5129
5318
|
} catch {
|
|
5130
5319
|
continue;
|
|
5131
5320
|
}
|
|
@@ -5136,14 +5325,14 @@ function collectPip(workspaceRoot) {
|
|
|
5136
5325
|
}
|
|
5137
5326
|
const requirementsPaths = [
|
|
5138
5327
|
"requirements-dev.txt",
|
|
5139
|
-
...(0,
|
|
5328
|
+
...(0, import_node_fs17.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
5140
5329
|
];
|
|
5141
5330
|
for (const relativePath of requirementsPaths) {
|
|
5142
|
-
if (!fileExists((0,
|
|
5331
|
+
if (!fileExists((0, import_node_path21.join)(workspaceRoot, relativePath))) {
|
|
5143
5332
|
continue;
|
|
5144
5333
|
}
|
|
5145
5334
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
5146
|
-
const lines = (0,
|
|
5335
|
+
const lines = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
5147
5336
|
for (const line of lines) {
|
|
5148
5337
|
push(relativePath, section, line);
|
|
5149
5338
|
}
|
|
@@ -5181,11 +5370,11 @@ function pyprojectDependencies(content) {
|
|
|
5181
5370
|
}
|
|
5182
5371
|
function collectPub(workspaceRoot) {
|
|
5183
5372
|
const sites = [];
|
|
5184
|
-
const pubspecPaths = (0,
|
|
5373
|
+
const pubspecPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
5185
5374
|
for (const relativePath of pubspecPaths) {
|
|
5186
5375
|
let content;
|
|
5187
5376
|
try {
|
|
5188
|
-
content = (0,
|
|
5377
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5189
5378
|
} catch {
|
|
5190
5379
|
continue;
|
|
5191
5380
|
}
|
|
@@ -5195,7 +5384,7 @@ function collectPub(workspaceRoot) {
|
|
|
5195
5384
|
name: entry.name,
|
|
5196
5385
|
ecosystem: "pub",
|
|
5197
5386
|
project: projectOf(relativePath),
|
|
5198
|
-
manifestPath: (0,
|
|
5387
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5199
5388
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
5200
5389
|
spec: entry.spec,
|
|
5201
5390
|
rewritable: entry.spec !== ""
|
|
@@ -5245,11 +5434,11 @@ function stripQuotes(value) {
|
|
|
5245
5434
|
}
|
|
5246
5435
|
function collectNuget(workspaceRoot) {
|
|
5247
5436
|
const sites = [];
|
|
5248
|
-
const csprojPaths = (0,
|
|
5437
|
+
const csprojPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
5249
5438
|
for (const relativePath of csprojPaths) {
|
|
5250
5439
|
let content;
|
|
5251
5440
|
try {
|
|
5252
|
-
content = (0,
|
|
5441
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5253
5442
|
} catch {
|
|
5254
5443
|
continue;
|
|
5255
5444
|
}
|
|
@@ -5258,7 +5447,7 @@ function collectNuget(workspaceRoot) {
|
|
|
5258
5447
|
name: entry.name,
|
|
5259
5448
|
ecosystem: "nuget",
|
|
5260
5449
|
project: projectOf(relativePath),
|
|
5261
|
-
manifestPath: (0,
|
|
5450
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5262
5451
|
section: "dep",
|
|
5263
5452
|
spec: entry.spec,
|
|
5264
5453
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -5283,13 +5472,13 @@ function csprojPackageReferences(content) {
|
|
|
5283
5472
|
return entries;
|
|
5284
5473
|
}
|
|
5285
5474
|
function collectGo(workspaceRoot) {
|
|
5286
|
-
const manifestPath = (0,
|
|
5475
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "go.mod");
|
|
5287
5476
|
if (!fileExists(manifestPath)) {
|
|
5288
5477
|
return [];
|
|
5289
5478
|
}
|
|
5290
5479
|
let content;
|
|
5291
5480
|
try {
|
|
5292
|
-
content = (0,
|
|
5481
|
+
content = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
5293
5482
|
} catch {
|
|
5294
5483
|
return [];
|
|
5295
5484
|
}
|
|
@@ -5338,7 +5527,7 @@ var PROJECT_GLOBS = {
|
|
|
5338
5527
|
function locateProjects(workspaceRoot) {
|
|
5339
5528
|
const locations = [];
|
|
5340
5529
|
for (const ecosystem of ECOSYSTEMS) {
|
|
5341
|
-
const relativePaths = (0,
|
|
5530
|
+
const relativePaths = (0, import_node_fs17.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
5342
5531
|
for (const relativePath of relativePaths) {
|
|
5343
5532
|
const posix = toPosix(relativePath);
|
|
5344
5533
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -5346,7 +5535,7 @@ function locateProjects(workspaceRoot) {
|
|
|
5346
5535
|
ecosystem,
|
|
5347
5536
|
dir,
|
|
5348
5537
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
5349
|
-
manifestPath: (0,
|
|
5538
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath)
|
|
5350
5539
|
});
|
|
5351
5540
|
}
|
|
5352
5541
|
}
|
|
@@ -5367,7 +5556,7 @@ function rewriteSpec(site, spec) {
|
|
|
5367
5556
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
5368
5557
|
return true;
|
|
5369
5558
|
}
|
|
5370
|
-
const before = (0,
|
|
5559
|
+
const before = (0, import_node_fs17.readFileSync)(site.manifestPath, "utf8");
|
|
5371
5560
|
const after = (() => {
|
|
5372
5561
|
switch (site.ecosystem) {
|
|
5373
5562
|
case "pip": {
|
|
@@ -5458,13 +5647,13 @@ function escapeForRegex(value) {
|
|
|
5458
5647
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
5459
5648
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
5460
5649
|
return ["apps", "libs", "packages"].some(
|
|
5461
|
-
(directory) => fileExists((0,
|
|
5650
|
+
(directory) => fileExists((0, import_node_path21.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
5462
5651
|
);
|
|
5463
5652
|
}
|
|
5464
5653
|
function isAliasedInstall(workspaceRoot, name) {
|
|
5465
5654
|
try {
|
|
5466
5655
|
const installed = readJson(
|
|
5467
|
-
(0,
|
|
5656
|
+
(0, import_node_path21.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5468
5657
|
);
|
|
5469
5658
|
return installed.name !== void 0 && installed.name !== name;
|
|
5470
5659
|
} catch {
|
|
@@ -5475,14 +5664,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5475
5664
|
if (ecosystem === "npm") {
|
|
5476
5665
|
try {
|
|
5477
5666
|
return readJson(
|
|
5478
|
-
(0,
|
|
5667
|
+
(0, import_node_path21.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5479
5668
|
).version;
|
|
5480
5669
|
} catch {
|
|
5481
5670
|
return void 0;
|
|
5482
5671
|
}
|
|
5483
5672
|
}
|
|
5484
5673
|
if (ecosystem === "pub") {
|
|
5485
|
-
const lockPath = (0,
|
|
5674
|
+
const lockPath = (0, import_node_path21.join)(workspaceRoot, "pubspec.lock");
|
|
5486
5675
|
if (!fileExists(lockPath)) {
|
|
5487
5676
|
return void 0;
|
|
5488
5677
|
}
|
|
@@ -5490,7 +5679,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5490
5679
|
const match = new RegExp(
|
|
5491
5680
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
5492
5681
|
"m"
|
|
5493
|
-
).exec((0,
|
|
5682
|
+
).exec((0, import_node_fs17.readFileSync)(lockPath, "utf8"));
|
|
5494
5683
|
return match?.[1];
|
|
5495
5684
|
} catch {
|
|
5496
5685
|
return void 0;
|
|
@@ -5556,7 +5745,7 @@ function resolveTarget(locations, target) {
|
|
|
5556
5745
|
return byName[0];
|
|
5557
5746
|
}
|
|
5558
5747
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
5559
|
-
const projectDir = (0,
|
|
5748
|
+
const projectDir = (0, import_node_path22.join)(workspaceRoot, location.dir);
|
|
5560
5749
|
switch (location.ecosystem) {
|
|
5561
5750
|
case "npm": {
|
|
5562
5751
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -5609,7 +5798,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
5609
5798
|
function addPythonDependency(manifestPath, specifier) {
|
|
5610
5799
|
let content;
|
|
5611
5800
|
try {
|
|
5612
|
-
content = (0,
|
|
5801
|
+
content = (0, import_node_fs18.readFileSync)(manifestPath, "utf8");
|
|
5613
5802
|
} catch {
|
|
5614
5803
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
5615
5804
|
return;
|
|
@@ -5638,7 +5827,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
5638
5827
|
}
|
|
5639
5828
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
5640
5829
|
if (ecosystem === "go") {
|
|
5641
|
-
return fileExists((0,
|
|
5830
|
+
return fileExists((0, import_node_path22.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path22.join)(workspaceRoot, "go.mod"));
|
|
5642
5831
|
}
|
|
5643
5832
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
5644
5833
|
}
|
|
@@ -5657,7 +5846,7 @@ function splitAtLast(value, separator) {
|
|
|
5657
5846
|
}
|
|
5658
5847
|
|
|
5659
5848
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
5660
|
-
var
|
|
5849
|
+
var import_node_path23 = require("path");
|
|
5661
5850
|
|
|
5662
5851
|
// src/dependency-management/semver.algorithm.ts
|
|
5663
5852
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -5834,7 +6023,7 @@ function describe(finding) {
|
|
|
5834
6023
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
5835
6024
|
}
|
|
5836
6025
|
function runSync(workspaceRoot, options) {
|
|
5837
|
-
if (!fileExists((0,
|
|
6026
|
+
if (!fileExists((0, import_node_path23.join)(workspaceRoot, "nx.json"))) {
|
|
5838
6027
|
throw new Error(
|
|
5839
6028
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
5840
6029
|
);
|
|
@@ -5884,7 +6073,7 @@ function runSync(workspaceRoot, options) {
|
|
|
5884
6073
|
}
|
|
5885
6074
|
|
|
5886
6075
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
5887
|
-
var
|
|
6076
|
+
var import_node_path24 = require("path");
|
|
5888
6077
|
var import_prompts2 = require("@inquirer/prompts");
|
|
5889
6078
|
|
|
5890
6079
|
// src/dependency-management/registry.client.ts
|
|
@@ -6167,7 +6356,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
6167
6356
|
function hasPythonInstallScript(workspaceRoot) {
|
|
6168
6357
|
try {
|
|
6169
6358
|
const manifest = readJson(
|
|
6170
|
-
(0,
|
|
6359
|
+
(0, import_node_path24.join)(workspaceRoot, "package.json")
|
|
6171
6360
|
);
|
|
6172
6361
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
6173
6362
|
} catch {
|
|
@@ -6183,7 +6372,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
6183
6372
|
}
|
|
6184
6373
|
}
|
|
6185
6374
|
async function runUp(workspaceRoot, options) {
|
|
6186
|
-
if (!fileExists((0,
|
|
6375
|
+
if (!fileExists((0, import_node_path24.join)(workspaceRoot, "nx.json"))) {
|
|
6187
6376
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
6188
6377
|
}
|
|
6189
6378
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -6259,7 +6448,7 @@ var PROJECT_KINDS = [
|
|
|
6259
6448
|
];
|
|
6260
6449
|
async function runAdd(kind, name, options) {
|
|
6261
6450
|
const workspaceRoot = process.cwd();
|
|
6262
|
-
if (!fileExists((0,
|
|
6451
|
+
if (!fileExists((0, import_node_path25.join)(workspaceRoot, "nx.json"))) {
|
|
6263
6452
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
6264
6453
|
}
|
|
6265
6454
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -6319,8 +6508,8 @@ async function runAdd(kind, name, options) {
|
|
|
6319
6508
|
],
|
|
6320
6509
|
workspaceRoot
|
|
6321
6510
|
);
|
|
6322
|
-
markPrivate((0,
|
|
6323
|
-
renameScaffoldPlaceholder((0,
|
|
6511
|
+
markPrivate((0, import_node_path25.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
6512
|
+
renameScaffoldPlaceholder((0, import_node_path25.join)(workspaceRoot, "libs", resolvedName), resolvedName);
|
|
6324
6513
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
6325
6514
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
6326
6515
|
break;
|
|
@@ -6412,7 +6601,7 @@ async function runAdd(kind, name, options) {
|
|
|
6412
6601
|
}
|
|
6413
6602
|
function readWorkspaceStack(workspaceRoot) {
|
|
6414
6603
|
const nxJson = readJson(
|
|
6415
|
-
(0,
|
|
6604
|
+
(0, import_node_path25.join)(workspaceRoot, "nx.json")
|
|
6416
6605
|
);
|
|
6417
6606
|
const stack = nxJson.mnci?.stack;
|
|
6418
6607
|
return {
|
|
@@ -6422,15 +6611,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
6422
6611
|
|
|
6423
6612
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
6424
6613
|
var import_node_child_process = require("child_process");
|
|
6425
|
-
var
|
|
6426
|
-
var
|
|
6614
|
+
var import_node_fs19 = require("fs");
|
|
6615
|
+
var import_node_path26 = require("path");
|
|
6427
6616
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
6428
6617
|
function toPosix2(path) {
|
|
6429
6618
|
return path.replaceAll("\\", "/");
|
|
6430
6619
|
}
|
|
6431
6620
|
function checkEslintConfigs(workspaceRoot) {
|
|
6432
|
-
const rootConfigs = (0,
|
|
6433
|
-
const projectConfigs = (0,
|
|
6621
|
+
const rootConfigs = (0, import_node_fs19.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
6622
|
+
const projectConfigs = (0, import_node_fs19.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
6434
6623
|
cwd: workspaceRoot
|
|
6435
6624
|
}).map((config) => toPosix2(config));
|
|
6436
6625
|
return [
|
|
@@ -6450,10 +6639,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
6450
6639
|
];
|
|
6451
6640
|
}
|
|
6452
6641
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
6453
|
-
const rules = (0,
|
|
6454
|
-
if (!(0,
|
|
6455
|
-
const entryPoint = (0,
|
|
6456
|
-
const source = (0,
|
|
6642
|
+
const rules = (0, import_node_path26.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
6643
|
+
if (!(0, import_node_fs19.existsSync)(rules)) return [];
|
|
6644
|
+
const entryPoint = (0, import_node_path26.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
6645
|
+
const source = (0, import_node_fs19.existsSync)(entryPoint) ? (0, import_node_fs19.readFileSync)(entryPoint, "utf8") : "";
|
|
6457
6646
|
return [
|
|
6458
6647
|
{
|
|
6459
6648
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -6466,7 +6655,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
6466
6655
|
function declaredDevDependencies(workspaceRoot) {
|
|
6467
6656
|
try {
|
|
6468
6657
|
const manifest = readJson(
|
|
6469
|
-
(0,
|
|
6658
|
+
(0, import_node_path26.join)(workspaceRoot, "package.json")
|
|
6470
6659
|
);
|
|
6471
6660
|
return manifest.devDependencies ?? {};
|
|
6472
6661
|
} catch {
|
|
@@ -6474,7 +6663,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
6474
6663
|
}
|
|
6475
6664
|
}
|
|
6476
6665
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
6477
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
6666
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path26.join)(workspaceRoot, file)));
|
|
6478
6667
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
6479
6668
|
const stale = [...files, ...declared];
|
|
6480
6669
|
if (stale.length === 0) {
|
|
@@ -6500,7 +6689,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
6500
6689
|
};
|
|
6501
6690
|
}
|
|
6502
6691
|
function checkResolvedEslint(workspaceRoot) {
|
|
6503
|
-
const manifestPath = (0,
|
|
6692
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
6504
6693
|
if (!fileExists(manifestPath)) {
|
|
6505
6694
|
return void 0;
|
|
6506
6695
|
}
|
|
@@ -6518,11 +6707,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
6518
6707
|
}
|
|
6519
6708
|
}
|
|
6520
6709
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
6521
|
-
const npmrcPath = (0,
|
|
6710
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6522
6711
|
if (!registry || !fileExists(npmrcPath)) {
|
|
6523
6712
|
return void 0;
|
|
6524
6713
|
}
|
|
6525
|
-
const npmrc = (0,
|
|
6714
|
+
const npmrc = (0, import_node_fs19.readFileSync)(npmrcPath, "utf8");
|
|
6526
6715
|
if (registry.kind === "npm") {
|
|
6527
6716
|
return {
|
|
6528
6717
|
check: ".npmrc authenticates the public registry",
|
|
@@ -6539,11 +6728,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
6539
6728
|
};
|
|
6540
6729
|
}
|
|
6541
6730
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
6542
|
-
const npmrcPath = (0,
|
|
6731
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6543
6732
|
if (!fileExists(npmrcPath)) {
|
|
6544
6733
|
return void 0;
|
|
6545
6734
|
}
|
|
6546
|
-
const npmrc = (0,
|
|
6735
|
+
const npmrc = (0, import_node_fs19.readFileSync)(npmrcPath, "utf8");
|
|
6547
6736
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
6548
6737
|
const referenced = [
|
|
6549
6738
|
...new Set(
|
|
@@ -6567,13 +6756,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
6567
6756
|
};
|
|
6568
6757
|
}
|
|
6569
6758
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
6570
|
-
const npmrcPath = (0,
|
|
6571
|
-
const pipelinePath = (0,
|
|
6759
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6760
|
+
const pipelinePath = (0, import_node_path26.join)(workspaceRoot, "azure-pipelines.yml");
|
|
6572
6761
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
6573
6762
|
return void 0;
|
|
6574
6763
|
}
|
|
6575
|
-
const holdsCredentials = (0,
|
|
6576
|
-
const runsTask = (0,
|
|
6764
|
+
const holdsCredentials = (0, import_node_fs19.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
6765
|
+
const runsTask = (0, import_node_fs19.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
6577
6766
|
if (!holdsCredentials && !runsTask) {
|
|
6578
6767
|
return {
|
|
6579
6768
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -6618,13 +6807,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
6618
6807
|
}
|
|
6619
6808
|
function checkVersionActions(workspaceRoot) {
|
|
6620
6809
|
const candidates = [
|
|
6621
|
-
...(0,
|
|
6622
|
-
...(0,
|
|
6623
|
-
...(0,
|
|
6810
|
+
...(0, import_node_fs19.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
6811
|
+
...(0, import_node_fs19.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
6812
|
+
...(0, import_node_fs19.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
6624
6813
|
].map((manifest) => toPosix2(manifest));
|
|
6625
6814
|
return candidates.flatMap((manifest) => {
|
|
6626
6815
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
6627
|
-
const projectJsonPath = (0,
|
|
6816
|
+
const projectJsonPath = (0, import_node_path26.join)(workspaceRoot, projectRoot, "project.json");
|
|
6628
6817
|
let hasOverride = false;
|
|
6629
6818
|
try {
|
|
6630
6819
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -6653,7 +6842,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6653
6842
|
]) {
|
|
6654
6843
|
try {
|
|
6655
6844
|
const targets = extract(
|
|
6656
|
-
readJson((0,
|
|
6845
|
+
readJson((0, import_node_path26.join)(workspaceRoot, projectRoot, file))
|
|
6657
6846
|
);
|
|
6658
6847
|
if (targets && typeof targets === "object") {
|
|
6659
6848
|
sources.push({
|
|
@@ -6669,8 +6858,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6669
6858
|
function checkTargetFilesExist(workspaceRoot) {
|
|
6670
6859
|
const projectRoots = new Set(
|
|
6671
6860
|
[
|
|
6672
|
-
...(0,
|
|
6673
|
-
...(0,
|
|
6861
|
+
...(0, import_node_fs19.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
6862
|
+
...(0, import_node_fs19.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
6674
6863
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
6675
6864
|
);
|
|
6676
6865
|
return [...projectRoots].flatMap(
|
|
@@ -6685,7 +6874,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
6685
6874
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
6686
6875
|
const value = target?.options?.[option];
|
|
6687
6876
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
6688
|
-
if (!checkable || fileExists((0,
|
|
6877
|
+
if (!checkable || fileExists((0, import_node_path26.join)(workspaceRoot, value))) {
|
|
6689
6878
|
return [];
|
|
6690
6879
|
}
|
|
6691
6880
|
return [
|
|
@@ -6722,15 +6911,15 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
6722
6911
|
};
|
|
6723
6912
|
}
|
|
6724
6913
|
function checkGoWorkInSync(workspaceRoot) {
|
|
6725
|
-
const goWorkPath = (0,
|
|
6914
|
+
const goWorkPath = (0, import_node_path26.join)(workspaceRoot, "go.work");
|
|
6726
6915
|
if (!fileExists(goWorkPath)) {
|
|
6727
6916
|
return void 0;
|
|
6728
6917
|
}
|
|
6729
|
-
const contents = (0,
|
|
6918
|
+
const contents = (0, import_node_fs19.existsSync)(goWorkPath) ? (0, import_node_fs19.readFileSync)(goWorkPath, "utf8") : "";
|
|
6730
6919
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
6731
6920
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
6732
6921
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
6733
|
-
const stale = uses.filter((entry) => !(0,
|
|
6922
|
+
const stale = uses.filter((entry) => !(0, import_node_fs19.existsSync)((0, import_node_path26.join)(workspaceRoot, entry, "go.mod")));
|
|
6734
6923
|
return {
|
|
6735
6924
|
check: "every go.work `use` entry points to a module that still exists",
|
|
6736
6925
|
ok: stale.length === 0,
|
|
@@ -6746,9 +6935,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6746
6935
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
6747
6936
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
6748
6937
|
];
|
|
6749
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
6938
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path26.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
6750
6939
|
check: `${file} builds the native apps on every OS`,
|
|
6751
|
-
ok: (0,
|
|
6940
|
+
ok: (0, import_node_fs19.readFileSync)((0, import_node_path26.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
6752
6941
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
6753
6942
|
remedy: "run `mnci upgrade`"
|
|
6754
6943
|
}));
|
|
@@ -6761,7 +6950,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6761
6950
|
return findings;
|
|
6762
6951
|
}
|
|
6763
6952
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
6764
|
-
const manifestPath = (0,
|
|
6953
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "package.json");
|
|
6765
6954
|
if (!fileExists(manifestPath)) {
|
|
6766
6955
|
return void 0;
|
|
6767
6956
|
}
|
|
@@ -6781,14 +6970,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
6781
6970
|
};
|
|
6782
6971
|
}
|
|
6783
6972
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
6784
|
-
const configs = (0,
|
|
6973
|
+
const configs = (0, import_node_fs19.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6785
6974
|
cwd: workspaceRoot
|
|
6786
6975
|
}).map((config) => toPosix2(config));
|
|
6787
6976
|
return configs.flatMap((relativePath) => {
|
|
6788
|
-
const configPath = (0,
|
|
6977
|
+
const configPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
6789
6978
|
let config;
|
|
6790
6979
|
try {
|
|
6791
|
-
config = (0,
|
|
6980
|
+
config = (0, import_node_fs19.readFileSync)(configPath, "utf8");
|
|
6792
6981
|
} catch {
|
|
6793
6982
|
return [];
|
|
6794
6983
|
}
|
|
@@ -6803,11 +6992,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
6803
6992
|
});
|
|
6804
6993
|
}
|
|
6805
6994
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
6806
|
-
const configs = (0,
|
|
6995
|
+
const configs = (0, import_node_fs19.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6807
6996
|
cwd: workspaceRoot
|
|
6808
6997
|
}).map((config) => toPosix2(config));
|
|
6809
6998
|
return configs.flatMap((relativePath) => {
|
|
6810
|
-
const configPath = (0,
|
|
6999
|
+
const configPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
6811
7000
|
if (!fileExists(configPath)) {
|
|
6812
7001
|
return [];
|
|
6813
7002
|
}
|
|
@@ -6841,7 +7030,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
6841
7030
|
});
|
|
6842
7031
|
}
|
|
6843
7032
|
function collectFindings(workspaceRoot) {
|
|
6844
|
-
const nxJsonPath = (0,
|
|
7033
|
+
const nxJsonPath = (0, import_node_path26.join)(workspaceRoot, "nx.json");
|
|
6845
7034
|
if (!fileExists(nxJsonPath)) {
|
|
6846
7035
|
throw new Error(
|
|
6847
7036
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -6889,8 +7078,8 @@ function runDoctor(workspaceRoot) {
|
|
|
6889
7078
|
}
|
|
6890
7079
|
|
|
6891
7080
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
6892
|
-
var
|
|
6893
|
-
var
|
|
7081
|
+
var import_node_fs20 = require("fs");
|
|
7082
|
+
var import_node_path27 = require("path");
|
|
6894
7083
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
6895
7084
|
var AGENT_AND_CI_ENTRIES = [
|
|
6896
7085
|
"AGENTS.md",
|
|
@@ -6921,13 +7110,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
6921
7110
|
"packages"
|
|
6922
7111
|
];
|
|
6923
7112
|
function assertAdoptableDirectory(target) {
|
|
6924
|
-
if (!(0,
|
|
7113
|
+
if (!(0, import_node_fs20.existsSync)(target)) {
|
|
6925
7114
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
6926
7115
|
}
|
|
6927
|
-
if (!(0,
|
|
7116
|
+
if (!(0, import_node_fs20.statSync)(target).isDirectory()) {
|
|
6928
7117
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
6929
7118
|
}
|
|
6930
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
7119
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs20.existsSync)((0, import_node_path27.join)(target, entry)));
|
|
6931
7120
|
if (blockers.length > 0) {
|
|
6932
7121
|
throw new Error(
|
|
6933
7122
|
`--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.`
|
|
@@ -6935,15 +7124,15 @@ function assertAdoptableDirectory(target) {
|
|
|
6935
7124
|
}
|
|
6936
7125
|
}
|
|
6937
7126
|
function mergeGitignore(generatedFile, targetFile) {
|
|
6938
|
-
const existing = (0,
|
|
7127
|
+
const existing = (0, import_node_fs20.readFileSync)(targetFile, "utf8");
|
|
6939
7128
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
6940
|
-
const additions = (0,
|
|
7129
|
+
const additions = (0, import_node_fs20.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
6941
7130
|
const trimmed = line.trim();
|
|
6942
7131
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
6943
7132
|
});
|
|
6944
7133
|
if (additions.length === 0) return false;
|
|
6945
7134
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
6946
|
-
(0,
|
|
7135
|
+
(0, import_node_fs20.writeFileSync)(
|
|
6947
7136
|
targetFile,
|
|
6948
7137
|
`${existing}${separator}
|
|
6949
7138
|
# Added by mnci (Nx workspace)
|
|
@@ -6953,9 +7142,9 @@ ${additions.join("\n")}
|
|
|
6953
7142
|
return true;
|
|
6954
7143
|
}
|
|
6955
7144
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
6956
|
-
const entries = (0,
|
|
7145
|
+
const entries = (0, import_node_fs20.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
6957
7146
|
const collisions = entries.filter(
|
|
6958
|
-
(entry) => (0,
|
|
7147
|
+
(entry) => (0, import_node_fs20.existsSync)((0, import_node_path27.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
6959
7148
|
);
|
|
6960
7149
|
if (collisions.length > 0) {
|
|
6961
7150
|
throw new Error(
|
|
@@ -6964,28 +7153,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
6964
7153
|
}
|
|
6965
7154
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
6966
7155
|
for (const entry of entries) {
|
|
6967
|
-
const from = (0,
|
|
6968
|
-
const to = (0,
|
|
6969
|
-
if (entry === ".gitignore" && (0,
|
|
7156
|
+
const from = (0, import_node_path27.join)(generatedRoot, entry);
|
|
7157
|
+
const to = (0, import_node_path27.join)(target, entry);
|
|
7158
|
+
if (entry === ".gitignore" && (0, import_node_fs20.existsSync)(to)) {
|
|
6970
7159
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
6971
7160
|
result.kept.push(entry);
|
|
6972
7161
|
continue;
|
|
6973
7162
|
}
|
|
6974
|
-
if ((0,
|
|
7163
|
+
if ((0, import_node_fs20.existsSync)(to)) {
|
|
6975
7164
|
result.kept.push(entry);
|
|
6976
7165
|
continue;
|
|
6977
7166
|
}
|
|
6978
|
-
(0,
|
|
7167
|
+
(0, import_node_fs20.cpSync)(from, to, { recursive: true });
|
|
6979
7168
|
result.copied.push(entry);
|
|
6980
7169
|
}
|
|
6981
|
-
(0,
|
|
7170
|
+
(0, import_node_fs20.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
6982
7171
|
return result;
|
|
6983
7172
|
}
|
|
6984
7173
|
|
|
6985
7174
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
6986
|
-
var
|
|
7175
|
+
var import_node_fs21 = require("fs");
|
|
6987
7176
|
var import_node_os = require("os");
|
|
6988
|
-
var
|
|
7177
|
+
var import_node_path28 = require("path");
|
|
6989
7178
|
function nxCloudProviderValue(ci) {
|
|
6990
7179
|
return ci === "azure" ? "azure" : "github";
|
|
6991
7180
|
}
|
|
@@ -7028,9 +7217,9 @@ async function resolveRegistry(options) {
|
|
|
7028
7217
|
return await promptRegistry();
|
|
7029
7218
|
}
|
|
7030
7219
|
async function runNew(name, options) {
|
|
7031
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
7220
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path28.resolve)(process.cwd(), options.into);
|
|
7032
7221
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
7033
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
7222
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path28.basename)(adoptTarget));
|
|
7034
7223
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
7035
7224
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
7036
7225
|
const registry = await resolveRegistry(options);
|
|
@@ -7043,8 +7232,8 @@ async function runNew(name, options) {
|
|
|
7043
7232
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
7044
7233
|
const stack = await resolveStack(options);
|
|
7045
7234
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
7046
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
7047
|
-
let workspaceRoot = (0,
|
|
7235
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs21.mkdtempSync)((0, import_node_path28.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
7236
|
+
let workspaceRoot = (0, import_node_path28.join)(stagingParent, workspaceName);
|
|
7048
7237
|
try {
|
|
7049
7238
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
7050
7239
|
runNpx(
|
|
@@ -7067,7 +7256,7 @@ async function runNew(name, options) {
|
|
|
7067
7256
|
workspaceRoot = adoptTarget;
|
|
7068
7257
|
}
|
|
7069
7258
|
} finally {
|
|
7070
|
-
if (adoptTarget !== void 0) (0,
|
|
7259
|
+
if (adoptTarget !== void 0) (0, import_node_fs21.rmSync)(stagingParent, { recursive: true, force: true });
|
|
7071
7260
|
}
|
|
7072
7261
|
logger.step(
|
|
7073
7262
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -7077,8 +7266,8 @@ async function runNew(name, options) {
|
|
|
7077
7266
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
7078
7267
|
logger.detail
|
|
7079
7268
|
);
|
|
7080
|
-
(0,
|
|
7081
|
-
(0,
|
|
7269
|
+
(0, import_node_fs21.rmSync)((0, import_node_path28.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
7270
|
+
(0, import_node_fs21.rmSync)((0, import_node_path28.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
7082
7271
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
7083
7272
|
const installStatus = runShell(
|
|
7084
7273
|
"npm",
|
|
@@ -7116,12 +7305,12 @@ function projectKindHintLines(kinds = PROJECT_KINDS) {
|
|
|
7116
7305
|
}
|
|
7117
7306
|
|
|
7118
7307
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
7119
|
-
var
|
|
7308
|
+
var import_node_path30 = require("path");
|
|
7120
7309
|
var import_prompts4 = require("@inquirer/prompts");
|
|
7121
7310
|
|
|
7122
7311
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
7123
|
-
var
|
|
7124
|
-
var
|
|
7312
|
+
var import_node_fs22 = require("fs");
|
|
7313
|
+
var import_node_path29 = require("path");
|
|
7125
7314
|
function resolveRegistry2(options, persisted) {
|
|
7126
7315
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
7127
7316
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -7150,7 +7339,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
7150
7339
|
return persisted.workspaceName;
|
|
7151
7340
|
}
|
|
7152
7341
|
try {
|
|
7153
|
-
const existing = (0,
|
|
7342
|
+
const existing = (0, import_node_fs22.readdirSync)(workspaceRoot).find(
|
|
7154
7343
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
7155
7344
|
);
|
|
7156
7345
|
if (existing) {
|
|
@@ -7158,11 +7347,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
7158
7347
|
}
|
|
7159
7348
|
} catch {
|
|
7160
7349
|
}
|
|
7161
|
-
return (0,
|
|
7350
|
+
return (0, import_node_path29.basename)(workspaceRoot);
|
|
7162
7351
|
}
|
|
7163
7352
|
function detectNpmAuth(workspaceRoot) {
|
|
7164
7353
|
try {
|
|
7165
|
-
return (0,
|
|
7354
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path29.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
7166
7355
|
} catch {
|
|
7167
7356
|
return void 0;
|
|
7168
7357
|
}
|
|
@@ -7209,7 +7398,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
7209
7398
|
};
|
|
7210
7399
|
}
|
|
7211
7400
|
function runUpgrade(workspaceRoot, options) {
|
|
7212
|
-
if (!fileExists((0,
|
|
7401
|
+
if (!fileExists((0, import_node_path29.join)(workspaceRoot, "nx.json"))) {
|
|
7213
7402
|
throw new Error(
|
|
7214
7403
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
7215
7404
|
);
|
|
@@ -7274,7 +7463,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
7274
7463
|
|
|
7275
7464
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
7276
7465
|
async function runInteractive() {
|
|
7277
|
-
const inWorkspace = fileExists((0,
|
|
7466
|
+
const inWorkspace = fileExists((0, import_node_path30.join)(process.cwd(), "nx.json"));
|
|
7278
7467
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
7279
7468
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
7280
7469
|
const choiceUpgrade = {
|
|
@@ -7295,8 +7484,8 @@ async function runInteractive() {
|
|
|
7295
7484
|
}
|
|
7296
7485
|
|
|
7297
7486
|
// src/cli-version/check-for-update.use-case.ts
|
|
7298
|
-
var
|
|
7299
|
-
var
|
|
7487
|
+
var import_node_fs23 = require("fs");
|
|
7488
|
+
var import_node_path31 = require("path");
|
|
7300
7489
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
7301
7490
|
var PACKAGE_NAME = "@mnci/cli";
|
|
7302
7491
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -7352,8 +7541,8 @@ function releaseTriple(version) {
|
|
|
7352
7541
|
}
|
|
7353
7542
|
function readCliVersion(packageDirectory) {
|
|
7354
7543
|
try {
|
|
7355
|
-
const manifestPath = (0,
|
|
7356
|
-
const manifest = JSON.parse((0,
|
|
7544
|
+
const manifestPath = (0, import_node_path31.join)(packageDirectory, "..", "package.json");
|
|
7545
|
+
const manifest = JSON.parse((0, import_node_fs23.readFileSync)(manifestPath, "utf8"));
|
|
7357
7546
|
return manifest.version ?? "0.0.0";
|
|
7358
7547
|
} catch {
|
|
7359
7548
|
return "0.0.0";
|
|
@@ -7394,8 +7583,8 @@ function buildProgram(cliVersion) {
|
|
|
7394
7583
|
});
|
|
7395
7584
|
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
7396
7585
|
"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"
|
|
7397
|
-
).action((phase) => {
|
|
7398
|
-
process.exitCode = runCiPhase(phase, process.cwd());
|
|
7586
|
+
).action(async (phase) => {
|
|
7587
|
+
process.exitCode = await runCiPhase(phase, process.cwd());
|
|
7399
7588
|
});
|
|
7400
7589
|
program.command("sync").description(
|
|
7401
7590
|
"Make every project agree: converge external dependency ranges declared at more than one version, then run 'nx sync' for TypeScript project references. Go is a no-op \u2014 one root go.mod means one version of every module"
|