@mnci/cli 4.20.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +511 -323
- 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,42 +2673,48 @@ function projectTask(name, kind) {
|
|
|
2492
2673
|
return kind === "start" ? { ...base, isBackground: true } : { ...base, group: kind };
|
|
2493
2674
|
}
|
|
2494
2675
|
function renameScaffoldPlaceholder(projectRoot, name) {
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2676
|
+
reshapeScaffoldSlice(projectRoot, name, "ts", "use-case");
|
|
2677
|
+
}
|
|
2678
|
+
function reshapeReactScaffold(projectRoot, name) {
|
|
2679
|
+
reshapeScaffoldSlice(projectRoot, name, "tsx", "component");
|
|
2680
|
+
}
|
|
2681
|
+
function reshapeScaffoldSlice(projectRoot, name, extension, role) {
|
|
2682
|
+
const sourceDir = (0, import_node_path5.join)(projectRoot, "src");
|
|
2683
|
+
const libDir = (0, import_node_path5.join)(sourceDir, "lib");
|
|
2684
|
+
if (!(0, import_node_fs5.existsSync)((0, import_node_path5.join)(libDir, `${name}.${extension}`))) {
|
|
2498
2685
|
return;
|
|
2499
2686
|
}
|
|
2500
|
-
const sliceDir = (0,
|
|
2501
|
-
(0,
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
renamed,
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2687
|
+
const sliceDir = (0, import_node_path5.join)(sourceDir, name);
|
|
2688
|
+
(0, import_node_fs5.mkdirSync)(sliceDir, { recursive: true });
|
|
2689
|
+
for (const entry of (0, import_node_fs5.readdirSync)(libDir)) {
|
|
2690
|
+
if (entry === `${name}.${extension}`) {
|
|
2691
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
2692
|
+
} else if (entry === `${name}.spec.${extension}`) {
|
|
2693
|
+
const renamed = (0, import_node_path5.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
2694
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), renamed);
|
|
2695
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs5.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
2696
|
+
} else {
|
|
2697
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, entry));
|
|
2698
|
+
}
|
|
2512
2699
|
}
|
|
2513
|
-
const barrel = (0,
|
|
2514
|
-
const esm = (0,
|
|
2515
|
-
writeFileEnsured((0,
|
|
2700
|
+
const barrel = (0, import_node_path5.join)(sourceDir, "index.ts");
|
|
2701
|
+
const esm = (0, import_node_fs5.existsSync)(barrel) && (0, import_node_fs5.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
2702
|
+
writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
2516
2703
|
`);
|
|
2517
|
-
if ((0,
|
|
2704
|
+
if ((0, import_node_fs5.existsSync)(barrel)) {
|
|
2518
2705
|
writeFileEnsured(
|
|
2519
2706
|
barrel,
|
|
2520
|
-
(0,
|
|
2707
|
+
(0, import_node_fs5.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2521
2708
|
);
|
|
2522
2709
|
}
|
|
2523
|
-
(0,
|
|
2710
|
+
(0, import_node_fs5.rmSync)(libDir, { recursive: true, force: true });
|
|
2524
2711
|
}
|
|
2525
2712
|
function repointSpecifier(source, from, to) {
|
|
2526
2713
|
return source.replaceAll(`${from}'`, () => `${to}'`).replaceAll(`${from}.js'`, () => `${to}.js'`);
|
|
2527
2714
|
}
|
|
2528
2715
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2529
|
-
const manifestPath = (0,
|
|
2530
|
-
if (!(0,
|
|
2716
|
+
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
2717
|
+
if (!(0, import_node_fs5.existsSync)(manifestPath)) {
|
|
2531
2718
|
return;
|
|
2532
2719
|
}
|
|
2533
2720
|
const manifest = readJson(manifestPath);
|
|
@@ -2550,11 +2737,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2550
2737
|
if (commands.start) {
|
|
2551
2738
|
scripts[`${name}:start`] = commands.start;
|
|
2552
2739
|
}
|
|
2553
|
-
const dependabotPath = (0,
|
|
2554
|
-
if ((0,
|
|
2740
|
+
const dependabotPath = (0, import_node_path5.join)(workspaceRoot, ".github/dependabot.yml");
|
|
2741
|
+
if ((0, import_node_fs5.existsSync)(dependabotPath)) {
|
|
2555
2742
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
2556
2743
|
}
|
|
2557
|
-
const manifestPath = (0,
|
|
2744
|
+
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
2558
2745
|
const manifest = readJson(manifestPath);
|
|
2559
2746
|
const existingScripts = manifest.scripts ?? {};
|
|
2560
2747
|
writeFileEnsured(
|
|
@@ -2592,7 +2779,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2592
2779
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
2593
2780
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
2594
2781
|
try {
|
|
2595
|
-
return readJson((0,
|
|
2782
|
+
return readJson((0, import_node_path5.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
2596
2783
|
} catch {
|
|
2597
2784
|
return {};
|
|
2598
2785
|
}
|
|
@@ -2604,7 +2791,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2604
2791
|
return;
|
|
2605
2792
|
}
|
|
2606
2793
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
2607
|
-
(root) => (0,
|
|
2794
|
+
(root) => (0, import_node_path5.join)(workspaceRoot, root, projectName, "package.json")
|
|
2608
2795
|
).find((candidate) => fileExists(candidate));
|
|
2609
2796
|
if (manifestPath === void 0) {
|
|
2610
2797
|
return;
|
|
@@ -2616,10 +2803,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2616
2803
|
const remaining = Object.fromEntries(
|
|
2617
2804
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
2618
2805
|
);
|
|
2619
|
-
const rootManifest = readJson((0,
|
|
2806
|
+
const rootManifest = readJson((0, import_node_path5.join)(workspaceRoot, "package.json"));
|
|
2620
2807
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
2621
2808
|
writeFileEnsured(
|
|
2622
|
-
(0,
|
|
2809
|
+
(0, import_node_path5.join)(workspaceRoot, "package.json"),
|
|
2623
2810
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
2624
2811
|
);
|
|
2625
2812
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -2679,7 +2866,7 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
2679
2866
|
ensureAdmZip(workspaceRoot);
|
|
2680
2867
|
const projectRoot = `apps/${name}`;
|
|
2681
2868
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
2682
|
-
addProjectJsonTargets((0,
|
|
2869
|
+
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2683
2870
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
2684
2871
|
start: csharpAppStartTarget(projectRoot)
|
|
2685
2872
|
});
|
|
@@ -2772,7 +2959,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
2772
2959
|
module.exports = CsharpVersionActions
|
|
2773
2960
|
`;
|
|
2774
2961
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
2775
|
-
writeFileEnsured((0,
|
|
2962
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
2776
2963
|
}
|
|
2777
2964
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
2778
2965
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -2787,7 +2974,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
2787
2974
|
);
|
|
2788
2975
|
}
|
|
2789
2976
|
function addInitialVersion(csprojPath) {
|
|
2790
|
-
const contents = (0,
|
|
2977
|
+
const contents = (0, import_node_fs6.readFileSync)(csprojPath, "utf8");
|
|
2791
2978
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
2792
2979
|
}
|
|
2793
2980
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -2802,14 +2989,14 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
2802
2989
|
const projectRoot = `packages/${name}`;
|
|
2803
2990
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
2804
2991
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
2805
|
-
addInitialVersion((0,
|
|
2992
|
+
addInitialVersion((0, import_node_path6.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
2806
2993
|
writeCsharpVersionActions(workspaceRoot);
|
|
2807
|
-
addProjectJsonReleaseVersionActions((0,
|
|
2808
|
-
addProjectJsonTargets((0,
|
|
2994
|
+
addProjectJsonReleaseVersionActions((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"));
|
|
2995
|
+
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2809
2996
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
2810
2997
|
});
|
|
2811
2998
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
2812
|
-
writeFileEnsured((0,
|
|
2999
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
2813
3000
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
2814
3001
|
}
|
|
2815
3002
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -2885,15 +3072,15 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
2885
3072
|
const projectRoot = `apps/${name}`;
|
|
2886
3073
|
const identity = pascalCase(name);
|
|
2887
3074
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
2888
|
-
const absoluteRoot = (0,
|
|
2889
|
-
writeFileEnsured((0,
|
|
2890
|
-
writeFileEnsured((0,
|
|
2891
|
-
writeFileEnsured((0,
|
|
2892
|
-
writeFileEnsured((0,
|
|
3075
|
+
const absoluteRoot = (0, import_node_path6.join)(workspaceRoot, projectRoot);
|
|
3076
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
3077
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
3078
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3079
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
2893
3080
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
2894
3081
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
2895
3082
|
}
|
|
2896
|
-
addProjectJsonTargets((0,
|
|
3083
|
+
addProjectJsonTargets((0, import_node_path6.join)(absoluteRoot, "project.json"), {
|
|
2897
3084
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
2898
3085
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
2899
3086
|
});
|
|
@@ -2901,7 +3088,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
2901
3088
|
}
|
|
2902
3089
|
|
|
2903
3090
|
// src/project-scaffolding/flutter.use-case.ts
|
|
2904
|
-
var
|
|
3091
|
+
var import_node_path7 = require("path");
|
|
2905
3092
|
function flutterAppStartTarget(name) {
|
|
2906
3093
|
return {
|
|
2907
3094
|
executor: "nx:run-commands",
|
|
@@ -2937,7 +3124,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
2937
3124
|
prepareFlutter(workspaceRoot);
|
|
2938
3125
|
ensureAdmZip(workspaceRoot);
|
|
2939
3126
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
2940
|
-
addProjectJsonTargets((0,
|
|
3127
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2941
3128
|
start: flutterAppStartTarget(name)
|
|
2942
3129
|
});
|
|
2943
3130
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -2954,18 +3141,18 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
2954
3141
|
}
|
|
2955
3142
|
|
|
2956
3143
|
// src/project-scaffolding/go.use-case.ts
|
|
2957
|
-
var
|
|
2958
|
-
var
|
|
3144
|
+
var import_node_fs10 = require("fs");
|
|
3145
|
+
var import_node_path11 = require("path");
|
|
2959
3146
|
|
|
2960
3147
|
// src/go-workspace/go-plugin.use-case.ts
|
|
2961
|
-
var
|
|
2962
|
-
var
|
|
3148
|
+
var import_node_fs7 = require("fs");
|
|
3149
|
+
var import_node_path8 = require("path");
|
|
2963
3150
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
2964
3151
|
function hasGoProject(workspaceRoot) {
|
|
2965
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0,
|
|
3152
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs7.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
2966
3153
|
return projectFiles.some((projectFile) => {
|
|
2967
3154
|
try {
|
|
2968
|
-
const { tags } = JSON.parse((0,
|
|
3155
|
+
const { tags } = JSON.parse((0, import_node_fs7.readFileSync)((0, import_node_path8.join)(workspaceRoot, projectFile), "utf8"));
|
|
2969
3156
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
2970
3157
|
} catch {
|
|
2971
3158
|
return false;
|
|
@@ -2973,7 +3160,7 @@ function hasGoProject(workspaceRoot) {
|
|
|
2973
3160
|
});
|
|
2974
3161
|
}
|
|
2975
3162
|
function isNxGoPluginRegistered(workspaceRoot) {
|
|
2976
|
-
const nxJsonPath = (0,
|
|
3163
|
+
const nxJsonPath = (0, import_node_path8.join)(workspaceRoot, "nx.json");
|
|
2977
3164
|
if (!fileExists(nxJsonPath)) {
|
|
2978
3165
|
return false;
|
|
2979
3166
|
}
|
|
@@ -3000,7 +3187,7 @@ function goModulePrefix(workspaceRoot) {
|
|
|
3000
3187
|
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
3001
3188
|
}
|
|
3002
3189
|
function registerNxGoPlugin(workspaceRoot) {
|
|
3003
|
-
const nxJsonPath = (0,
|
|
3190
|
+
const nxJsonPath = (0, import_node_path8.join)(workspaceRoot, "nx.json");
|
|
3004
3191
|
if (!fileExists(nxJsonPath)) {
|
|
3005
3192
|
return false;
|
|
3006
3193
|
}
|
|
@@ -3024,8 +3211,8 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3024
3211
|
}
|
|
3025
3212
|
|
|
3026
3213
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3027
|
-
var
|
|
3028
|
-
var
|
|
3214
|
+
var import_node_fs8 = require("fs");
|
|
3215
|
+
var import_node_path9 = require("path");
|
|
3029
3216
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3030
3217
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3031
3218
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -3151,7 +3338,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
3151
3338
|
}
|
|
3152
3339
|
};
|
|
3153
3340
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
3154
|
-
const projectJsonPath = (0,
|
|
3341
|
+
const projectJsonPath = (0, import_node_path9.join)(workspaceRoot, "apps", name, "project.json");
|
|
3155
3342
|
if (!fileExists(projectJsonPath)) {
|
|
3156
3343
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
3157
3344
|
}
|
|
@@ -3172,22 +3359,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
3172
3359
|
}
|
|
3173
3360
|
})
|
|
3174
3361
|
);
|
|
3175
|
-
writeFileEnsured((0,
|
|
3362
|
+
writeFileEnsured((0, import_node_path9.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
3176
3363
|
}
|
|
3177
3364
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
3178
|
-
const apps = (0,
|
|
3365
|
+
const apps = (0, import_node_path9.join)(workspaceRoot, "apps");
|
|
3179
3366
|
let entries;
|
|
3180
3367
|
try {
|
|
3181
|
-
entries = (0,
|
|
3368
|
+
entries = (0, import_node_fs8.readdirSync)(apps);
|
|
3182
3369
|
} catch {
|
|
3183
3370
|
return false;
|
|
3184
3371
|
}
|
|
3185
3372
|
const hasReleasableApp = entries.some((entry) => {
|
|
3186
|
-
const projectJsonPath = (0,
|
|
3373
|
+
const projectJsonPath = (0, import_node_path9.join)(apps, entry, "project.json");
|
|
3187
3374
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3188
3375
|
});
|
|
3189
|
-
const path = (0,
|
|
3190
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
3376
|
+
const path = (0, import_node_path9.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3377
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs8.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
3191
3378
|
return false;
|
|
3192
3379
|
}
|
|
3193
3380
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3195,8 +3382,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3195
3382
|
}
|
|
3196
3383
|
|
|
3197
3384
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3198
|
-
var
|
|
3199
|
-
var
|
|
3385
|
+
var import_node_fs9 = require("fs");
|
|
3386
|
+
var import_node_path10 = require("path");
|
|
3200
3387
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3201
3388
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
3202
3389
|
var GO_WEB_SOURCE = `package main
|
|
@@ -3274,18 +3461,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
3274
3461
|
}
|
|
3275
3462
|
`;
|
|
3276
3463
|
function assertWebApp(workspaceRoot, web) {
|
|
3277
|
-
const directory = (0,
|
|
3278
|
-
const isReactApp = fileExists((0,
|
|
3464
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, "apps", web);
|
|
3465
|
+
const isReactApp = fileExists((0, import_node_path10.join)(directory, "package.json")) && (0, import_node_fs9.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
3279
3466
|
if (!isReactApp) {
|
|
3280
3467
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
3281
3468
|
}
|
|
3282
3469
|
}
|
|
3283
3470
|
function webProjectName(workspaceRoot, web) {
|
|
3284
|
-
const manifest = readJson((0,
|
|
3471
|
+
const manifest = readJson((0, import_node_path10.join)(workspaceRoot, "apps", web, "package.json"));
|
|
3285
3472
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
3286
3473
|
}
|
|
3287
3474
|
function addApiProxy(viteConfigPath) {
|
|
3288
|
-
const source = (0,
|
|
3475
|
+
const source = (0, import_node_fs9.readFileSync)(viteConfigPath, "utf8");
|
|
3289
3476
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
3290
3477
|
return false;
|
|
3291
3478
|
}
|
|
@@ -3298,7 +3485,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
3298
3485
|
return true;
|
|
3299
3486
|
}
|
|
3300
3487
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
3301
|
-
const projectJsonPath = (0,
|
|
3488
|
+
const projectJsonPath = (0, import_node_path10.join)(workspaceRoot, "apps", name, "project.json");
|
|
3302
3489
|
const project = readJson(projectJsonPath);
|
|
3303
3490
|
const webName = webProjectName(workspaceRoot, web);
|
|
3304
3491
|
const targets = project.targets ?? {};
|
|
@@ -3324,13 +3511,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
3324
3511
|
projectJsonPath,
|
|
3325
3512
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
3326
3513
|
);
|
|
3327
|
-
const directory = (0,
|
|
3328
|
-
writeFileEnsured((0,
|
|
3329
|
-
writeFileEnsured((0,
|
|
3330
|
-
writeFileEnsured((0,
|
|
3331
|
-
writeFileEnsured((0,
|
|
3332
|
-
const viteConfig = (0,
|
|
3333
|
-
if (viteConfig === void 0 || !addApiProxy((0,
|
|
3514
|
+
const directory = (0, import_node_path10.join)(workspaceRoot, "apps", name);
|
|
3515
|
+
writeFileEnsured((0, import_node_path10.join)(directory, ".gitignore"), "/web/\n");
|
|
3516
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
3517
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
3518
|
+
writeFileEnsured((0, import_node_path10.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
3519
|
+
const viteConfig = (0, import_node_fs9.readdirSync)((0, import_node_path10.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
3520
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path10.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
3334
3521
|
logger.warn(
|
|
3335
3522
|
`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.`
|
|
3336
3523
|
);
|
|
@@ -3364,7 +3551,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
3364
3551
|
}
|
|
3365
3552
|
}
|
|
3366
3553
|
function ensureGoModule(workspaceRoot) {
|
|
3367
|
-
if (fileExists((0,
|
|
3554
|
+
if (fileExists((0, import_node_path11.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path11.join)(workspaceRoot, "go.mod"))) {
|
|
3368
3555
|
return;
|
|
3369
3556
|
}
|
|
3370
3557
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -3372,26 +3559,26 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3372
3559
|
}
|
|
3373
3560
|
function readGoModModule(goModPath) {
|
|
3374
3561
|
try {
|
|
3375
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
3562
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs10.readFileSync)(goModPath, "utf8"))?.[1];
|
|
3376
3563
|
} catch {
|
|
3377
3564
|
return void 0;
|
|
3378
3565
|
}
|
|
3379
3566
|
}
|
|
3380
3567
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
3381
|
-
const projectModule = readGoModModule((0,
|
|
3568
|
+
const projectModule = readGoModModule((0, import_node_path11.join)(workspaceRoot, projectDir, "go.mod"));
|
|
3382
3569
|
if (projectModule !== void 0) {
|
|
3383
3570
|
return projectModule;
|
|
3384
3571
|
}
|
|
3385
|
-
const rootModule = readGoModModule((0,
|
|
3572
|
+
const rootModule = readGoModModule((0, import_node_path11.join)(workspaceRoot, "go.mod"));
|
|
3386
3573
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
3387
3574
|
}
|
|
3388
3575
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
3389
3576
|
const prefix = goModulePrefix(workspaceRoot);
|
|
3390
|
-
const goModPath = (0,
|
|
3577
|
+
const goModPath = (0, import_node_path11.join)(workspaceRoot, projectDir, "go.mod");
|
|
3391
3578
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
3392
3579
|
return;
|
|
3393
3580
|
}
|
|
3394
|
-
const rewritten = (0,
|
|
3581
|
+
const rewritten = (0, import_node_fs10.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
3395
3582
|
writeFileEnsured(goModPath, rewritten);
|
|
3396
3583
|
}
|
|
3397
3584
|
function goTestTarget() {
|
|
@@ -3469,16 +3656,16 @@ function goNativePackageTarget(name) {
|
|
|
3469
3656
|
}
|
|
3470
3657
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3471
3658
|
const changed = [];
|
|
3472
|
-
const apps = (0,
|
|
3659
|
+
const apps = (0, import_node_path11.join)(workspaceRoot, "apps");
|
|
3473
3660
|
if (!fileExists(apps)) {
|
|
3474
3661
|
return changed;
|
|
3475
3662
|
}
|
|
3476
|
-
for (const name of (0,
|
|
3477
|
-
const projectJsonPath = (0,
|
|
3663
|
+
for (const name of (0, import_node_fs10.readdirSync)(apps)) {
|
|
3664
|
+
const projectJsonPath = (0, import_node_path11.join)(apps, name, "project.json");
|
|
3478
3665
|
if (!fileExists(projectJsonPath)) {
|
|
3479
3666
|
continue;
|
|
3480
3667
|
}
|
|
3481
|
-
const project = JSON.parse((0,
|
|
3668
|
+
const project = JSON.parse((0, import_node_fs10.readFileSync)(projectJsonPath, "utf8"));
|
|
3482
3669
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3483
3670
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3484
3671
|
continue;
|
|
@@ -3514,8 +3701,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
3514
3701
|
}
|
|
3515
3702
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
3516
3703
|
const { packageName, functionName, fileStem } = goLibraryIdentifiers(projectName);
|
|
3517
|
-
(0,
|
|
3518
|
-
(0,
|
|
3704
|
+
(0, import_node_fs10.rmSync)((0, import_node_path11.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
3705
|
+
(0, import_node_fs10.rmSync)((0, import_node_path11.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
3519
3706
|
const files = [
|
|
3520
3707
|
[
|
|
3521
3708
|
"doc.go",
|
|
@@ -3525,14 +3712,14 @@ package ${packageName}
|
|
|
3525
3712
|
`
|
|
3526
3713
|
],
|
|
3527
3714
|
[
|
|
3528
|
-
(0,
|
|
3715
|
+
(0, import_node_path11.join)(packageName, "doc.go"),
|
|
3529
3716
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
3530
3717
|
// the outcome it delivers, and add one package per further outcome.
|
|
3531
3718
|
package ${packageName}
|
|
3532
3719
|
`
|
|
3533
3720
|
],
|
|
3534
3721
|
[
|
|
3535
|
-
(0,
|
|
3722
|
+
(0, import_node_path11.join)(packageName, `${fileStem}_use_case.go`),
|
|
3536
3723
|
`package ${packageName}
|
|
3537
3724
|
|
|
3538
3725
|
// ${functionName} is the generator's sample behaviour, kept so the slice builds and tests.
|
|
@@ -3542,7 +3729,7 @@ func ${functionName}(name string) string {
|
|
|
3542
3729
|
`
|
|
3543
3730
|
],
|
|
3544
3731
|
[
|
|
3545
|
-
(0,
|
|
3732
|
+
(0, import_node_path11.join)(packageName, `${fileStem}_use_case_test.go`),
|
|
3546
3733
|
`package ${packageName}
|
|
3547
3734
|
|
|
3548
3735
|
import "testing"
|
|
@@ -3556,7 +3743,7 @@ func Test${functionName}(t *testing.T) {
|
|
|
3556
3743
|
]
|
|
3557
3744
|
];
|
|
3558
3745
|
for (const [relativePath, content] of files) {
|
|
3559
|
-
const path = (0,
|
|
3746
|
+
const path = (0, import_node_path11.join)(projectRoot, relativePath);
|
|
3560
3747
|
if (!fileExists(path)) {
|
|
3561
3748
|
writeFileEnsured(path, content);
|
|
3562
3749
|
}
|
|
@@ -3591,7 +3778,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
3591
3778
|
workspaceRoot
|
|
3592
3779
|
);
|
|
3593
3780
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
3594
|
-
addProjectJsonTargets((0,
|
|
3781
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3595
3782
|
build: goBuildTarget(name),
|
|
3596
3783
|
test: goTestTarget(),
|
|
3597
3784
|
lint: goLintTarget(),
|
|
@@ -3630,7 +3817,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
3630
3817
|
workspaceRoot
|
|
3631
3818
|
);
|
|
3632
3819
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
3633
|
-
addProjectJsonTargets((0,
|
|
3820
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3634
3821
|
"build": goBuildTarget(name),
|
|
3635
3822
|
"test": goTestTarget(),
|
|
3636
3823
|
"lint": goLintTarget(),
|
|
@@ -3654,11 +3841,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
3654
3841
|
workspaceRoot
|
|
3655
3842
|
);
|
|
3656
3843
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
3657
|
-
addProjectJsonTargets((0,
|
|
3844
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
3658
3845
|
test: goTestTarget(),
|
|
3659
3846
|
lint: goLintTarget()
|
|
3660
3847
|
});
|
|
3661
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3848
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path11.join)(workspaceRoot, "packages", name), name);
|
|
3662
3849
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3663
3850
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
3664
3851
|
if (module2) {
|
|
@@ -3679,11 +3866,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3679
3866
|
workspaceRoot
|
|
3680
3867
|
);
|
|
3681
3868
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
3682
|
-
addProjectJsonTargets((0,
|
|
3869
|
+
addProjectJsonTargets((0, import_node_path11.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
3683
3870
|
test: goTestTarget(),
|
|
3684
3871
|
lint: goLintTarget()
|
|
3685
3872
|
});
|
|
3686
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3873
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path11.join)(workspaceRoot, "libs", name), name);
|
|
3687
3874
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3688
3875
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
3689
3876
|
if (module2) {
|
|
@@ -3692,7 +3879,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3692
3879
|
}
|
|
3693
3880
|
|
|
3694
3881
|
// src/project-scaffolding/node.use-case.ts
|
|
3695
|
-
var
|
|
3882
|
+
var import_node_path12 = require("path");
|
|
3696
3883
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
3697
3884
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
3698
3885
|
return;
|
|
@@ -3716,12 +3903,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
3716
3903
|
],
|
|
3717
3904
|
workspaceRoot
|
|
3718
3905
|
);
|
|
3719
|
-
const appRoot = (0,
|
|
3906
|
+
const appRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
3720
3907
|
separateDeclarationOutput(appRoot);
|
|
3721
3908
|
repairAssetMapping(appRoot, name);
|
|
3722
3909
|
}
|
|
3723
3910
|
function separateDeclarationOutput(appRoot) {
|
|
3724
|
-
const tsconfigPath = (0,
|
|
3911
|
+
const tsconfigPath = (0, import_node_path12.join)(appRoot, "tsconfig.app.json");
|
|
3725
3912
|
if (!fileExists(tsconfigPath)) {
|
|
3726
3913
|
return;
|
|
3727
3914
|
}
|
|
@@ -3743,7 +3930,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
3743
3930
|
);
|
|
3744
3931
|
}
|
|
3745
3932
|
function repairAssetMapping(appRoot, name) {
|
|
3746
|
-
const manifestPath = (0,
|
|
3933
|
+
const manifestPath = (0, import_node_path12.join)(appRoot, "package.json");
|
|
3747
3934
|
if (!fileExists(manifestPath)) {
|
|
3748
3935
|
return;
|
|
3749
3936
|
}
|
|
@@ -3770,7 +3957,7 @@ function nodeAppPackageTarget(name) {
|
|
|
3770
3957
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
3771
3958
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
3772
3959
|
ensureAdmZip(workspaceRoot);
|
|
3773
|
-
addNxTargets((0,
|
|
3960
|
+
addNxTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
3774
3961
|
package: nodeAppPackageTarget(name)
|
|
3775
3962
|
});
|
|
3776
3963
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -3826,10 +4013,10 @@ describe('buildGreeting', () => {
|
|
|
3826
4013
|
})
|
|
3827
4014
|
`;
|
|
3828
4015
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
3829
|
-
const manifestPath = (0,
|
|
4016
|
+
const manifestPath = (0, import_node_path12.join)(nodeFunctionAppRoot, "package.json");
|
|
3830
4017
|
const manifest = readJson(manifestPath);
|
|
3831
4018
|
const azureFunctionsVersion = readJson(
|
|
3832
|
-
(0,
|
|
4019
|
+
(0, import_node_path12.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
3833
4020
|
).version;
|
|
3834
4021
|
const dependencies = manifest.dependencies ?? {};
|
|
3835
4022
|
writeFileEnsured(
|
|
@@ -3872,21 +4059,21 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
3872
4059
|
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
3873
4060
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
3874
4061
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
3875
|
-
const nodeFunctionAppRoot = (0,
|
|
3876
|
-
writeFileEnsured((0,
|
|
3877
|
-
writeFileEnsured((0,
|
|
4062
|
+
const nodeFunctionAppRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
4063
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
4064
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/hello.ts"), NODE_FUNCTION_APP_HELLO);
|
|
3878
4065
|
writeFileEnsured(
|
|
3879
|
-
(0,
|
|
4066
|
+
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.ts"),
|
|
3880
4067
|
NODE_FUNCTION_APP_GREETING
|
|
3881
4068
|
);
|
|
3882
4069
|
writeFileEnsured(
|
|
3883
|
-
(0,
|
|
4070
|
+
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
3884
4071
|
NODE_FUNCTION_APP_GREETING_SPEC
|
|
3885
4072
|
);
|
|
3886
|
-
writeFileEnsured((0,
|
|
4073
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
3887
4074
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
3888
4075
|
ensureAdmZip(workspaceRoot);
|
|
3889
|
-
addNxTargets((0,
|
|
4076
|
+
addNxTargets((0, import_node_path12.join)(nodeFunctionAppRoot, "package.json"), {
|
|
3890
4077
|
package: nodeFunctionAppPackageTarget(name),
|
|
3891
4078
|
prune: nodeFunctionAppPruneTarget(name),
|
|
3892
4079
|
start: nodeFunctionAppStartTarget(name)
|
|
@@ -3896,11 +4083,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
3896
4083
|
}
|
|
3897
4084
|
|
|
3898
4085
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3899
|
-
var
|
|
4086
|
+
var import_node_path16 = require("path");
|
|
3900
4087
|
|
|
3901
4088
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
3902
|
-
var
|
|
3903
|
-
var
|
|
4089
|
+
var import_node_fs11 = require("fs");
|
|
4090
|
+
var import_node_path13 = require("path");
|
|
3904
4091
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
3905
4092
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
3906
4093
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -3923,14 +4110,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
3923
4110
|
}
|
|
3924
4111
|
function repairPublishableManifests(workspaceRoot) {
|
|
3925
4112
|
const changed = [];
|
|
3926
|
-
const manifests = (0,
|
|
4113
|
+
const manifests = (0, import_node_fs11.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
3927
4114
|
cwd: workspaceRoot
|
|
3928
4115
|
});
|
|
3929
4116
|
for (const relativePath of manifests) {
|
|
3930
|
-
const manifestPath = (0,
|
|
3931
|
-
const before = (0,
|
|
4117
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, relativePath);
|
|
4118
|
+
const before = (0, import_node_fs11.readFileSync)(manifestPath, "utf8");
|
|
3932
4119
|
repairPublishableManifest(manifestPath);
|
|
3933
|
-
const after = (0,
|
|
4120
|
+
const after = (0, import_node_fs11.readFileSync)(manifestPath, "utf8");
|
|
3934
4121
|
if (after !== before) {
|
|
3935
4122
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
3936
4123
|
}
|
|
@@ -3939,8 +4126,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
3939
4126
|
}
|
|
3940
4127
|
|
|
3941
4128
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3942
|
-
var
|
|
3943
|
-
var
|
|
4129
|
+
var import_node_fs12 = require("fs");
|
|
4130
|
+
var import_node_path14 = require("path");
|
|
3944
4131
|
|
|
3945
4132
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
3946
4133
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -3955,7 +4142,7 @@ function sourceMapCapableCompiler(indent) {
|
|
|
3955
4142
|
return [
|
|
3956
4143
|
`${indent}// Swapped from swc by MoNecromanCI. @nx/rollup runs swc without`,
|
|
3957
4144
|
`${indent}// sourceMaps, so it returns no map and the bundle's map comes out empty -`,
|
|
3958
|
-
`${indent}// valid-looking, and useless for debugging. See
|
|
4145
|
+
`${indent}// valid-looking, and useless for debugging. See issue #308.`,
|
|
3959
4146
|
`${indent}compiler: 'babel',`
|
|
3960
4147
|
].join("\n");
|
|
3961
4148
|
}
|
|
@@ -4142,12 +4329,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
4142
4329
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4143
4330
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
4144
4331
|
const changed = [];
|
|
4145
|
-
const configs = (0,
|
|
4332
|
+
const configs = (0, import_node_fs12.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4146
4333
|
cwd: workspaceRoot
|
|
4147
4334
|
});
|
|
4148
4335
|
for (const relativePath of configs) {
|
|
4149
|
-
const configPath = (0,
|
|
4150
|
-
const before = (0,
|
|
4336
|
+
const configPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
4337
|
+
const before = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4151
4338
|
const after = withRollupSourceMaps(before);
|
|
4152
4339
|
if (after !== before) {
|
|
4153
4340
|
writeFileEnsured(configPath, after);
|
|
@@ -4158,12 +4345,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
4158
4345
|
}
|
|
4159
4346
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
4160
4347
|
const changed = [];
|
|
4161
|
-
const configs = (0,
|
|
4348
|
+
const configs = (0, import_node_fs12.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4162
4349
|
cwd: workspaceRoot
|
|
4163
4350
|
});
|
|
4164
4351
|
for (const relativePath of configs) {
|
|
4165
|
-
const configPath = (0,
|
|
4166
|
-
const before = (0,
|
|
4352
|
+
const configPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
4353
|
+
const before = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4167
4354
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
4168
4355
|
if (after !== before) {
|
|
4169
4356
|
writeFileEnsured(configPath, after);
|
|
@@ -4173,11 +4360,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
4173
4360
|
return changed;
|
|
4174
4361
|
}
|
|
4175
4362
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
4176
|
-
const configPath = (0,
|
|
4363
|
+
const configPath = (0, import_node_path14.join)(projectRoot, "rollup.config.cjs");
|
|
4177
4364
|
if (!fileExists(configPath)) {
|
|
4178
4365
|
return;
|
|
4179
4366
|
}
|
|
4180
|
-
const config = (0,
|
|
4367
|
+
const config = (0, import_node_fs12.readFileSync)(configPath, "utf8");
|
|
4181
4368
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
4182
4369
|
return;
|
|
4183
4370
|
}
|
|
@@ -4186,10 +4373,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
4186
4373
|
}
|
|
4187
4374
|
|
|
4188
4375
|
// src/rollup-library/rollup-config.repository.ts
|
|
4189
|
-
var
|
|
4190
|
-
var
|
|
4376
|
+
var import_node_fs13 = require("fs");
|
|
4377
|
+
var import_node_path15 = require("path");
|
|
4191
4378
|
function resolveRequireTarget(fromDir, specifier) {
|
|
4192
|
-
const base = (0,
|
|
4379
|
+
const base = (0, import_node_path15.join)(fromDir, specifier);
|
|
4193
4380
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
4194
4381
|
}
|
|
4195
4382
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -4199,7 +4386,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4199
4386
|
visited.add(configPath);
|
|
4200
4387
|
let text;
|
|
4201
4388
|
try {
|
|
4202
|
-
text = (0,
|
|
4389
|
+
text = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
4203
4390
|
} catch {
|
|
4204
4391
|
return "";
|
|
4205
4392
|
}
|
|
@@ -4207,15 +4394,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4207
4394
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
4208
4395
|
(match) => match[2]
|
|
4209
4396
|
);
|
|
4210
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
4397
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path15.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
4211
4398
|
return [text, ...requiredText].join("\n");
|
|
4212
4399
|
}
|
|
4213
4400
|
|
|
4214
4401
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4215
4402
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4216
4403
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4217
|
-
const projectRoot = (0,
|
|
4218
|
-
const manifestPath = (0,
|
|
4404
|
+
const projectRoot = (0, import_node_path16.join)(workspaceRoot, "packages", name);
|
|
4405
|
+
const manifestPath = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4219
4406
|
runGeneratorAndRepair(
|
|
4220
4407
|
workspaceRoot,
|
|
4221
4408
|
[
|
|
@@ -4244,8 +4431,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4244
4431
|
}
|
|
4245
4432
|
|
|
4246
4433
|
// src/project-scaffolding/python.use-case.ts
|
|
4247
|
-
var
|
|
4248
|
-
var
|
|
4434
|
+
var import_node_fs14 = require("fs");
|
|
4435
|
+
var import_node_path17 = require("path");
|
|
4249
4436
|
function ensurePython(workspaceRoot) {
|
|
4250
4437
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
4251
4438
|
if (!hasPython) {
|
|
@@ -4268,7 +4455,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
4268
4455
|
registerPythonGraphPlugin(workspaceRoot);
|
|
4269
4456
|
}
|
|
4270
4457
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
4271
|
-
const nxJsonPath = (0,
|
|
4458
|
+
const nxJsonPath = (0, import_node_path17.join)(workspaceRoot, "nx.json");
|
|
4272
4459
|
if (!fileExists(nxJsonPath)) {
|
|
4273
4460
|
return;
|
|
4274
4461
|
}
|
|
@@ -4291,7 +4478,7 @@ pytest
|
|
|
4291
4478
|
pip-audit
|
|
4292
4479
|
`;
|
|
4293
4480
|
function ensureRequirementsDev(workspaceRoot) {
|
|
4294
|
-
const requirementsDevPath = (0,
|
|
4481
|
+
const requirementsDevPath = (0, import_node_path17.join)(workspaceRoot, "requirements-dev.txt");
|
|
4295
4482
|
if (!fileExists(requirementsDevPath)) {
|
|
4296
4483
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
4297
4484
|
}
|
|
@@ -4351,8 +4538,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
4351
4538
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
4352
4539
|
workspaceRoot
|
|
4353
4540
|
);
|
|
4354
|
-
writeFileEnsured((0,
|
|
4355
|
-
addProjectJsonTargets((0,
|
|
4541
|
+
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
4542
|
+
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4356
4543
|
package: pythonAppPackageTarget(name),
|
|
4357
4544
|
start: pythonAppStartTarget(name)
|
|
4358
4545
|
});
|
|
@@ -4374,7 +4561,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
4374
4561
|
workspaceRoot
|
|
4375
4562
|
);
|
|
4376
4563
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
4377
|
-
addProjectJsonTargets((0,
|
|
4564
|
+
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4378
4565
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
4379
4566
|
start: pythonFunctionAppStartTarget(name)
|
|
4380
4567
|
});
|
|
@@ -4415,7 +4602,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
4415
4602
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
4416
4603
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
4417
4604
|
return PYTHON_PROJECT_DIRS.find(
|
|
4418
|
-
(directory) => fileExists((0,
|
|
4605
|
+
(directory) => fileExists((0, import_node_path17.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
4419
4606
|
);
|
|
4420
4607
|
}
|
|
4421
4608
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -4454,7 +4641,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4454
4641
|
`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.`
|
|
4455
4642
|
);
|
|
4456
4643
|
}
|
|
4457
|
-
if (!fileExists((0,
|
|
4644
|
+
if (!fileExists((0, import_node_path17.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
4458
4645
|
throw new Error(
|
|
4459
4646
|
`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.`
|
|
4460
4647
|
);
|
|
@@ -4462,8 +4649,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4462
4649
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
4463
4650
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
4464
4651
|
}
|
|
4465
|
-
const pyprojectPath = (0,
|
|
4466
|
-
const pyprojectToml = (0,
|
|
4652
|
+
const pyprojectPath = (0, import_node_path17.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
4653
|
+
const pyprojectToml = (0, import_node_fs14.readFileSync)(pyprojectPath, "utf8");
|
|
4467
4654
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
4468
4655
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
4469
4656
|
return;
|
|
@@ -4475,8 +4662,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4475
4662
|
}
|
|
4476
4663
|
|
|
4477
4664
|
// src/project-scaffolding/react-app.use-case.ts
|
|
4478
|
-
var
|
|
4479
|
-
var
|
|
4665
|
+
var import_node_fs15 = require("fs");
|
|
4666
|
+
var import_node_path18 = require("path");
|
|
4480
4667
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
4481
4668
|
function reactEnvironmentFile(environment) {
|
|
4482
4669
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -4513,12 +4700,12 @@ function reactAppTargets(name) {
|
|
|
4513
4700
|
return targets;
|
|
4514
4701
|
}
|
|
4515
4702
|
function allowEnvFiles(workspaceRoot) {
|
|
4516
|
-
const gitignorePath = (0,
|
|
4703
|
+
const gitignorePath = (0, import_node_path18.join)(workspaceRoot, ".gitignore");
|
|
4517
4704
|
if (!fileExists(gitignorePath)) {
|
|
4518
4705
|
return;
|
|
4519
4706
|
}
|
|
4520
4707
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
4521
|
-
const current = (0,
|
|
4708
|
+
const current = (0, import_node_fs15.readFileSync)(gitignorePath, "utf8");
|
|
4522
4709
|
if (current.includes(marker)) {
|
|
4523
4710
|
return;
|
|
4524
4711
|
}
|
|
@@ -4545,24 +4732,24 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4545
4732
|
workspaceRoot
|
|
4546
4733
|
);
|
|
4547
4734
|
ensureAdmZip(workspaceRoot);
|
|
4548
|
-
const reactAppRoot = (0,
|
|
4735
|
+
const reactAppRoot = (0, import_node_path18.join)(workspaceRoot, "apps", name);
|
|
4549
4736
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
4550
|
-
writeFileEnsured((0,
|
|
4737
|
+
writeFileEnsured((0, import_node_path18.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
4551
4738
|
}
|
|
4552
4739
|
allowEnvFiles(workspaceRoot);
|
|
4553
|
-
addNxTargets((0,
|
|
4740
|
+
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4554
4741
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4555
4742
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4556
4743
|
}
|
|
4557
4744
|
|
|
4558
4745
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
4559
|
-
var
|
|
4746
|
+
var import_node_path19 = require("path");
|
|
4560
4747
|
var REACT_LIB_BUNDLER = "rollup";
|
|
4561
4748
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4562
4749
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4563
4750
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4564
|
-
const projectRoot = (0,
|
|
4565
|
-
const publishableManifest = (0,
|
|
4751
|
+
const projectRoot = (0, import_node_path19.join)(workspaceRoot, "packages", name);
|
|
4752
|
+
const publishableManifest = (0, import_node_path19.join)(projectRoot, "package.json");
|
|
4566
4753
|
runGeneratorAndRepair(
|
|
4567
4754
|
workspaceRoot,
|
|
4568
4755
|
[
|
|
@@ -4583,6 +4770,7 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4583
4770
|
repairPublishableManifest(publishableManifest);
|
|
4584
4771
|
repairDeclarationSpecifiers(projectRoot);
|
|
4585
4772
|
writeProjectReadme(projectRoot, `${scope}/${name}`, stack.testRunner);
|
|
4773
|
+
reshapeReactScaffold(projectRoot, name);
|
|
4586
4774
|
removeGeneratedEslintConfig(workspaceRoot, `packages/${name}`);
|
|
4587
4775
|
removeLocalRegistryScaffolding(workspaceRoot);
|
|
4588
4776
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
@@ -4591,8 +4779,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4591
4779
|
}
|
|
4592
4780
|
function addReactInternalLib(workspaceRoot, name, stack) {
|
|
4593
4781
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4594
|
-
const projectRoot = (0,
|
|
4595
|
-
const privateManifest = (0,
|
|
4782
|
+
const projectRoot = (0, import_node_path19.join)(workspaceRoot, "libs", name);
|
|
4783
|
+
const privateManifest = (0, import_node_path19.join)(projectRoot, "package.json");
|
|
4596
4784
|
runGeneratorAndRepair(
|
|
4597
4785
|
workspaceRoot,
|
|
4598
4786
|
[
|
|
@@ -4618,8 +4806,8 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
4618
4806
|
}
|
|
4619
4807
|
|
|
4620
4808
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
4621
|
-
var
|
|
4622
|
-
var
|
|
4809
|
+
var import_node_fs16 = require("fs");
|
|
4810
|
+
var import_node_path20 = require("path");
|
|
4623
4811
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
4624
4812
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
4625
4813
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -4804,8 +4992,8 @@ export const window = {
|
|
|
4804
4992
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
4805
4993
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
4806
4994
|
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}\` },`];
|
|
4807
|
-
const path = (0,
|
|
4808
|
-
const content = fileExists(path) ? (0,
|
|
4995
|
+
const path = (0, import_node_path20.join)(projectRoot, file);
|
|
4996
|
+
const content = fileExists(path) ? (0, import_node_fs16.readFileSync)(path, "utf8") : "";
|
|
4809
4997
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
4810
4998
|
if (line === void 0) {
|
|
4811
4999
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -4825,11 +5013,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
4825
5013
|
}
|
|
4826
5014
|
}
|
|
4827
5015
|
function defaultPublisher(workspaceRoot) {
|
|
4828
|
-
const { name } = readJson((0,
|
|
5016
|
+
const { name } = readJson((0, import_node_path20.join)(workspaceRoot, "package.json"));
|
|
4829
5017
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4830
5018
|
}
|
|
4831
5019
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
4832
|
-
const manifestPath = (0,
|
|
5020
|
+
const manifestPath = (0, import_node_path20.join)(projectRoot, "package.json");
|
|
4833
5021
|
const manifest = readJson(manifestPath);
|
|
4834
5022
|
const { nx = {}, ...rest } = manifest;
|
|
4835
5023
|
const targets = { ...nx.targets };
|
|
@@ -4893,11 +5081,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
4893
5081
|
};
|
|
4894
5082
|
}
|
|
4895
5083
|
function addDebugLaunch(workspaceRoot, name) {
|
|
4896
|
-
const file = (0,
|
|
5084
|
+
const file = (0, import_node_fs16.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4897
5085
|
if (file === void 0) {
|
|
4898
5086
|
return;
|
|
4899
5087
|
}
|
|
4900
|
-
const path = (0,
|
|
5088
|
+
const path = (0, import_node_path20.join)(workspaceRoot, file);
|
|
4901
5089
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
4902
5090
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4903
5091
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -4930,39 +5118,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
4930
5118
|
);
|
|
4931
5119
|
}
|
|
4932
5120
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4933
|
-
const apps = (0,
|
|
5121
|
+
const apps = (0, import_node_path20.join)(workspaceRoot, "apps");
|
|
4934
5122
|
let entries;
|
|
4935
5123
|
try {
|
|
4936
|
-
entries = (0,
|
|
5124
|
+
entries = (0, import_node_fs16.readdirSync)(apps);
|
|
4937
5125
|
} catch {
|
|
4938
5126
|
return false;
|
|
4939
5127
|
}
|
|
4940
5128
|
const hasExtension = entries.some((entry) => {
|
|
4941
|
-
const manifestPath = (0,
|
|
5129
|
+
const manifestPath = (0, import_node_path20.join)(apps, entry, "package.json");
|
|
4942
5130
|
if (!fileExists(manifestPath)) {
|
|
4943
5131
|
return false;
|
|
4944
5132
|
}
|
|
4945
5133
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4946
5134
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4947
5135
|
});
|
|
4948
|
-
const path = (0,
|
|
4949
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
5136
|
+
const path = (0, import_node_path20.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
5137
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs16.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
4950
5138
|
return false;
|
|
4951
5139
|
}
|
|
4952
5140
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4953
5141
|
return true;
|
|
4954
5142
|
}
|
|
4955
5143
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
4956
|
-
const apps = (0,
|
|
5144
|
+
const apps = (0, import_node_path20.join)(workspaceRoot, "apps");
|
|
4957
5145
|
let entries;
|
|
4958
5146
|
try {
|
|
4959
|
-
entries = (0,
|
|
5147
|
+
entries = (0, import_node_fs16.readdirSync)(apps);
|
|
4960
5148
|
} catch {
|
|
4961
5149
|
return [];
|
|
4962
5150
|
}
|
|
4963
5151
|
const updated = [];
|
|
4964
5152
|
for (const entry of entries) {
|
|
4965
|
-
const manifestPath = (0,
|
|
5153
|
+
const manifestPath = (0, import_node_path20.join)(apps, entry, "package.json");
|
|
4966
5154
|
if (!fileExists(manifestPath)) {
|
|
4967
5155
|
continue;
|
|
4968
5156
|
}
|
|
@@ -4982,22 +5170,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
4982
5170
|
}
|
|
4983
5171
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4984
5172
|
const { sidecar } = options;
|
|
4985
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
5173
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path20.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4986
5174
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4987
5175
|
}
|
|
4988
5176
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4989
5177
|
ensureVscodeToolchain(workspaceRoot);
|
|
4990
|
-
const projectRoot = (0,
|
|
5178
|
+
const projectRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
4991
5179
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
4992
|
-
addVscodeTypes((0,
|
|
4993
|
-
addVscodeTypes((0,
|
|
4994
|
-
writeFileEnsured((0,
|
|
4995
|
-
writeFileEnsured((0,
|
|
4996
|
-
writeFileEnsured((0,
|
|
5180
|
+
addVscodeTypes((0, import_node_path20.join)(projectRoot, "tsconfig.app.json"));
|
|
5181
|
+
addVscodeTypes((0, import_node_path20.join)(projectRoot, "tsconfig.spec.json"));
|
|
5182
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
5183
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
5184
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
4997
5185
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4998
|
-
writeFileEnsured((0,
|
|
4999
|
-
writeFileEnsured((0,
|
|
5000
|
-
addNxTargets((0,
|
|
5186
|
+
writeFileEnsured((0, import_node_path20.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
5187
|
+
writeFileEnsured((0, import_node_path20.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
5188
|
+
addNxTargets((0, import_node_path20.join)(projectRoot, "package.json"), {
|
|
5001
5189
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
5002
5190
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
5003
5191
|
});
|
|
@@ -5008,12 +5196,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5008
5196
|
}
|
|
5009
5197
|
|
|
5010
5198
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5011
|
-
var
|
|
5012
|
-
var
|
|
5199
|
+
var import_node_fs18 = require("fs");
|
|
5200
|
+
var import_node_path22 = require("path");
|
|
5013
5201
|
|
|
5014
5202
|
// src/dependency-management/manifest.repository.ts
|
|
5015
|
-
var
|
|
5016
|
-
var
|
|
5203
|
+
var import_node_fs17 = require("fs");
|
|
5204
|
+
var import_node_path21 = require("path");
|
|
5017
5205
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5018
5206
|
var ROOT_LABEL = "(root)";
|
|
5019
5207
|
var MANIFEST_GLOBS = {
|
|
@@ -5046,23 +5234,23 @@ function projectOf(manifestRelativePath) {
|
|
|
5046
5234
|
}
|
|
5047
5235
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
5048
5236
|
if (ecosystem === "go") {
|
|
5049
|
-
return fileExists((0,
|
|
5237
|
+
return fileExists((0, import_node_path21.join)(workspaceRoot, "go.mod"));
|
|
5050
5238
|
}
|
|
5051
5239
|
if (ecosystem === "nuget") {
|
|
5052
|
-
return (0,
|
|
5240
|
+
return (0, import_node_fs17.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
5053
5241
|
}
|
|
5054
5242
|
const rootMarker = {
|
|
5055
5243
|
npm: "package.json",
|
|
5056
5244
|
pip: "requirements-dev.txt",
|
|
5057
5245
|
pub: "pubspec.yaml"
|
|
5058
5246
|
};
|
|
5059
|
-
return fileExists((0,
|
|
5247
|
+
return fileExists((0, import_node_path21.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs17.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
5060
5248
|
}
|
|
5061
5249
|
function collectNpm(workspaceRoot) {
|
|
5062
5250
|
const sites = [];
|
|
5063
|
-
const relativePaths = ["package.json", ...(0,
|
|
5251
|
+
const relativePaths = ["package.json", ...(0, import_node_fs17.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
5064
5252
|
for (const relativePath of relativePaths) {
|
|
5065
|
-
const manifestPath = (0,
|
|
5253
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5066
5254
|
try {
|
|
5067
5255
|
const manifest = readJson(manifestPath);
|
|
5068
5256
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -5123,17 +5311,17 @@ function collectPip(workspaceRoot) {
|
|
|
5123
5311
|
name: parsed.name,
|
|
5124
5312
|
ecosystem: "pip",
|
|
5125
5313
|
project: projectOf(relativePath),
|
|
5126
|
-
manifestPath: (0,
|
|
5314
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5127
5315
|
section,
|
|
5128
5316
|
spec: parsed.spec,
|
|
5129
5317
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
5130
5318
|
});
|
|
5131
5319
|
};
|
|
5132
|
-
const pyprojectPaths = (0,
|
|
5320
|
+
const pyprojectPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
5133
5321
|
for (const relativePath of pyprojectPaths) {
|
|
5134
5322
|
let content;
|
|
5135
5323
|
try {
|
|
5136
|
-
content = (0,
|
|
5324
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5137
5325
|
} catch {
|
|
5138
5326
|
continue;
|
|
5139
5327
|
}
|
|
@@ -5144,14 +5332,14 @@ function collectPip(workspaceRoot) {
|
|
|
5144
5332
|
}
|
|
5145
5333
|
const requirementsPaths = [
|
|
5146
5334
|
"requirements-dev.txt",
|
|
5147
|
-
...(0,
|
|
5335
|
+
...(0, import_node_fs17.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
5148
5336
|
];
|
|
5149
5337
|
for (const relativePath of requirementsPaths) {
|
|
5150
|
-
if (!fileExists((0,
|
|
5338
|
+
if (!fileExists((0, import_node_path21.join)(workspaceRoot, relativePath))) {
|
|
5151
5339
|
continue;
|
|
5152
5340
|
}
|
|
5153
5341
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
5154
|
-
const lines = (0,
|
|
5342
|
+
const lines = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
5155
5343
|
for (const line of lines) {
|
|
5156
5344
|
push(relativePath, section, line);
|
|
5157
5345
|
}
|
|
@@ -5189,11 +5377,11 @@ function pyprojectDependencies(content) {
|
|
|
5189
5377
|
}
|
|
5190
5378
|
function collectPub(workspaceRoot) {
|
|
5191
5379
|
const sites = [];
|
|
5192
|
-
const pubspecPaths = (0,
|
|
5380
|
+
const pubspecPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
5193
5381
|
for (const relativePath of pubspecPaths) {
|
|
5194
5382
|
let content;
|
|
5195
5383
|
try {
|
|
5196
|
-
content = (0,
|
|
5384
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5197
5385
|
} catch {
|
|
5198
5386
|
continue;
|
|
5199
5387
|
}
|
|
@@ -5203,7 +5391,7 @@ function collectPub(workspaceRoot) {
|
|
|
5203
5391
|
name: entry.name,
|
|
5204
5392
|
ecosystem: "pub",
|
|
5205
5393
|
project: projectOf(relativePath),
|
|
5206
|
-
manifestPath: (0,
|
|
5394
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5207
5395
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
5208
5396
|
spec: entry.spec,
|
|
5209
5397
|
rewritable: entry.spec !== ""
|
|
@@ -5253,11 +5441,11 @@ function stripQuotes(value) {
|
|
|
5253
5441
|
}
|
|
5254
5442
|
function collectNuget(workspaceRoot) {
|
|
5255
5443
|
const sites = [];
|
|
5256
|
-
const csprojPaths = (0,
|
|
5444
|
+
const csprojPaths = (0, import_node_fs17.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
5257
5445
|
for (const relativePath of csprojPaths) {
|
|
5258
5446
|
let content;
|
|
5259
5447
|
try {
|
|
5260
|
-
content = (0,
|
|
5448
|
+
content = (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(workspaceRoot, relativePath), "utf8");
|
|
5261
5449
|
} catch {
|
|
5262
5450
|
continue;
|
|
5263
5451
|
}
|
|
@@ -5266,7 +5454,7 @@ function collectNuget(workspaceRoot) {
|
|
|
5266
5454
|
name: entry.name,
|
|
5267
5455
|
ecosystem: "nuget",
|
|
5268
5456
|
project: projectOf(relativePath),
|
|
5269
|
-
manifestPath: (0,
|
|
5457
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath),
|
|
5270
5458
|
section: "dep",
|
|
5271
5459
|
spec: entry.spec,
|
|
5272
5460
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -5291,13 +5479,13 @@ function csprojPackageReferences(content) {
|
|
|
5291
5479
|
return entries;
|
|
5292
5480
|
}
|
|
5293
5481
|
function collectGo(workspaceRoot) {
|
|
5294
|
-
const manifestPath = (0,
|
|
5482
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "go.mod");
|
|
5295
5483
|
if (!fileExists(manifestPath)) {
|
|
5296
5484
|
return [];
|
|
5297
5485
|
}
|
|
5298
5486
|
let content;
|
|
5299
5487
|
try {
|
|
5300
|
-
content = (0,
|
|
5488
|
+
content = (0, import_node_fs17.readFileSync)(manifestPath, "utf8");
|
|
5301
5489
|
} catch {
|
|
5302
5490
|
return [];
|
|
5303
5491
|
}
|
|
@@ -5346,7 +5534,7 @@ var PROJECT_GLOBS = {
|
|
|
5346
5534
|
function locateProjects(workspaceRoot) {
|
|
5347
5535
|
const locations = [];
|
|
5348
5536
|
for (const ecosystem of ECOSYSTEMS) {
|
|
5349
|
-
const relativePaths = (0,
|
|
5537
|
+
const relativePaths = (0, import_node_fs17.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
5350
5538
|
for (const relativePath of relativePaths) {
|
|
5351
5539
|
const posix = toPosix(relativePath);
|
|
5352
5540
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -5354,7 +5542,7 @@ function locateProjects(workspaceRoot) {
|
|
|
5354
5542
|
ecosystem,
|
|
5355
5543
|
dir,
|
|
5356
5544
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
5357
|
-
manifestPath: (0,
|
|
5545
|
+
manifestPath: (0, import_node_path21.join)(workspaceRoot, relativePath)
|
|
5358
5546
|
});
|
|
5359
5547
|
}
|
|
5360
5548
|
}
|
|
@@ -5375,7 +5563,7 @@ function rewriteSpec(site, spec) {
|
|
|
5375
5563
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
5376
5564
|
return true;
|
|
5377
5565
|
}
|
|
5378
|
-
const before = (0,
|
|
5566
|
+
const before = (0, import_node_fs17.readFileSync)(site.manifestPath, "utf8");
|
|
5379
5567
|
const after = (() => {
|
|
5380
5568
|
switch (site.ecosystem) {
|
|
5381
5569
|
case "pip": {
|
|
@@ -5466,13 +5654,13 @@ function escapeForRegex(value) {
|
|
|
5466
5654
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
5467
5655
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
5468
5656
|
return ["apps", "libs", "packages"].some(
|
|
5469
|
-
(directory) => fileExists((0,
|
|
5657
|
+
(directory) => fileExists((0, import_node_path21.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
5470
5658
|
);
|
|
5471
5659
|
}
|
|
5472
5660
|
function isAliasedInstall(workspaceRoot, name) {
|
|
5473
5661
|
try {
|
|
5474
5662
|
const installed = readJson(
|
|
5475
|
-
(0,
|
|
5663
|
+
(0, import_node_path21.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5476
5664
|
);
|
|
5477
5665
|
return installed.name !== void 0 && installed.name !== name;
|
|
5478
5666
|
} catch {
|
|
@@ -5483,14 +5671,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5483
5671
|
if (ecosystem === "npm") {
|
|
5484
5672
|
try {
|
|
5485
5673
|
return readJson(
|
|
5486
|
-
(0,
|
|
5674
|
+
(0, import_node_path21.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5487
5675
|
).version;
|
|
5488
5676
|
} catch {
|
|
5489
5677
|
return void 0;
|
|
5490
5678
|
}
|
|
5491
5679
|
}
|
|
5492
5680
|
if (ecosystem === "pub") {
|
|
5493
|
-
const lockPath = (0,
|
|
5681
|
+
const lockPath = (0, import_node_path21.join)(workspaceRoot, "pubspec.lock");
|
|
5494
5682
|
if (!fileExists(lockPath)) {
|
|
5495
5683
|
return void 0;
|
|
5496
5684
|
}
|
|
@@ -5498,7 +5686,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5498
5686
|
const match = new RegExp(
|
|
5499
5687
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
5500
5688
|
"m"
|
|
5501
|
-
).exec((0,
|
|
5689
|
+
).exec((0, import_node_fs17.readFileSync)(lockPath, "utf8"));
|
|
5502
5690
|
return match?.[1];
|
|
5503
5691
|
} catch {
|
|
5504
5692
|
return void 0;
|
|
@@ -5564,7 +5752,7 @@ function resolveTarget(locations, target) {
|
|
|
5564
5752
|
return byName[0];
|
|
5565
5753
|
}
|
|
5566
5754
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
5567
|
-
const projectDir = (0,
|
|
5755
|
+
const projectDir = (0, import_node_path22.join)(workspaceRoot, location.dir);
|
|
5568
5756
|
switch (location.ecosystem) {
|
|
5569
5757
|
case "npm": {
|
|
5570
5758
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -5617,7 +5805,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
5617
5805
|
function addPythonDependency(manifestPath, specifier) {
|
|
5618
5806
|
let content;
|
|
5619
5807
|
try {
|
|
5620
|
-
content = (0,
|
|
5808
|
+
content = (0, import_node_fs18.readFileSync)(manifestPath, "utf8");
|
|
5621
5809
|
} catch {
|
|
5622
5810
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
5623
5811
|
return;
|
|
@@ -5646,7 +5834,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
5646
5834
|
}
|
|
5647
5835
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
5648
5836
|
if (ecosystem === "go") {
|
|
5649
|
-
return fileExists((0,
|
|
5837
|
+
return fileExists((0, import_node_path22.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path22.join)(workspaceRoot, "go.mod"));
|
|
5650
5838
|
}
|
|
5651
5839
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
5652
5840
|
}
|
|
@@ -5665,7 +5853,7 @@ function splitAtLast(value, separator) {
|
|
|
5665
5853
|
}
|
|
5666
5854
|
|
|
5667
5855
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
5668
|
-
var
|
|
5856
|
+
var import_node_path23 = require("path");
|
|
5669
5857
|
|
|
5670
5858
|
// src/dependency-management/semver.algorithm.ts
|
|
5671
5859
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -5842,7 +6030,7 @@ function describe(finding) {
|
|
|
5842
6030
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
5843
6031
|
}
|
|
5844
6032
|
function runSync(workspaceRoot, options) {
|
|
5845
|
-
if (!fileExists((0,
|
|
6033
|
+
if (!fileExists((0, import_node_path23.join)(workspaceRoot, "nx.json"))) {
|
|
5846
6034
|
throw new Error(
|
|
5847
6035
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
5848
6036
|
);
|
|
@@ -5892,7 +6080,7 @@ function runSync(workspaceRoot, options) {
|
|
|
5892
6080
|
}
|
|
5893
6081
|
|
|
5894
6082
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
5895
|
-
var
|
|
6083
|
+
var import_node_path24 = require("path");
|
|
5896
6084
|
var import_prompts2 = require("@inquirer/prompts");
|
|
5897
6085
|
|
|
5898
6086
|
// src/dependency-management/registry.client.ts
|
|
@@ -6175,7 +6363,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
6175
6363
|
function hasPythonInstallScript(workspaceRoot) {
|
|
6176
6364
|
try {
|
|
6177
6365
|
const manifest = readJson(
|
|
6178
|
-
(0,
|
|
6366
|
+
(0, import_node_path24.join)(workspaceRoot, "package.json")
|
|
6179
6367
|
);
|
|
6180
6368
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
6181
6369
|
} catch {
|
|
@@ -6191,7 +6379,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
6191
6379
|
}
|
|
6192
6380
|
}
|
|
6193
6381
|
async function runUp(workspaceRoot, options) {
|
|
6194
|
-
if (!fileExists((0,
|
|
6382
|
+
if (!fileExists((0, import_node_path24.join)(workspaceRoot, "nx.json"))) {
|
|
6195
6383
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
6196
6384
|
}
|
|
6197
6385
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -6267,7 +6455,7 @@ var PROJECT_KINDS = [
|
|
|
6267
6455
|
];
|
|
6268
6456
|
async function runAdd(kind, name, options) {
|
|
6269
6457
|
const workspaceRoot = process.cwd();
|
|
6270
|
-
if (!fileExists((0,
|
|
6458
|
+
if (!fileExists((0, import_node_path25.join)(workspaceRoot, "nx.json"))) {
|
|
6271
6459
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
6272
6460
|
}
|
|
6273
6461
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -6327,8 +6515,8 @@ async function runAdd(kind, name, options) {
|
|
|
6327
6515
|
],
|
|
6328
6516
|
workspaceRoot
|
|
6329
6517
|
);
|
|
6330
|
-
markPrivate((0,
|
|
6331
|
-
renameScaffoldPlaceholder((0,
|
|
6518
|
+
markPrivate((0, import_node_path25.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
6519
|
+
renameScaffoldPlaceholder((0, import_node_path25.join)(workspaceRoot, "libs", resolvedName), resolvedName);
|
|
6332
6520
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
6333
6521
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
6334
6522
|
break;
|
|
@@ -6420,7 +6608,7 @@ async function runAdd(kind, name, options) {
|
|
|
6420
6608
|
}
|
|
6421
6609
|
function readWorkspaceStack(workspaceRoot) {
|
|
6422
6610
|
const nxJson = readJson(
|
|
6423
|
-
(0,
|
|
6611
|
+
(0, import_node_path25.join)(workspaceRoot, "nx.json")
|
|
6424
6612
|
);
|
|
6425
6613
|
const stack = nxJson.mnci?.stack;
|
|
6426
6614
|
return {
|
|
@@ -6430,15 +6618,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
6430
6618
|
|
|
6431
6619
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
6432
6620
|
var import_node_child_process = require("child_process");
|
|
6433
|
-
var
|
|
6434
|
-
var
|
|
6621
|
+
var import_node_fs19 = require("fs");
|
|
6622
|
+
var import_node_path26 = require("path");
|
|
6435
6623
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
6436
6624
|
function toPosix2(path) {
|
|
6437
6625
|
return path.replaceAll("\\", "/");
|
|
6438
6626
|
}
|
|
6439
6627
|
function checkEslintConfigs(workspaceRoot) {
|
|
6440
|
-
const rootConfigs = (0,
|
|
6441
|
-
const projectConfigs = (0,
|
|
6628
|
+
const rootConfigs = (0, import_node_fs19.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
6629
|
+
const projectConfigs = (0, import_node_fs19.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
6442
6630
|
cwd: workspaceRoot
|
|
6443
6631
|
}).map((config) => toPosix2(config));
|
|
6444
6632
|
return [
|
|
@@ -6458,10 +6646,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
6458
6646
|
];
|
|
6459
6647
|
}
|
|
6460
6648
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
6461
|
-
const rules = (0,
|
|
6462
|
-
if (!(0,
|
|
6463
|
-
const entryPoint = (0,
|
|
6464
|
-
const source = (0,
|
|
6649
|
+
const rules = (0, import_node_path26.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
6650
|
+
if (!(0, import_node_fs19.existsSync)(rules)) return [];
|
|
6651
|
+
const entryPoint = (0, import_node_path26.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
6652
|
+
const source = (0, import_node_fs19.existsSync)(entryPoint) ? (0, import_node_fs19.readFileSync)(entryPoint, "utf8") : "";
|
|
6465
6653
|
return [
|
|
6466
6654
|
{
|
|
6467
6655
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -6474,7 +6662,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
6474
6662
|
function declaredDevDependencies(workspaceRoot) {
|
|
6475
6663
|
try {
|
|
6476
6664
|
const manifest = readJson(
|
|
6477
|
-
(0,
|
|
6665
|
+
(0, import_node_path26.join)(workspaceRoot, "package.json")
|
|
6478
6666
|
);
|
|
6479
6667
|
return manifest.devDependencies ?? {};
|
|
6480
6668
|
} catch {
|
|
@@ -6482,7 +6670,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
6482
6670
|
}
|
|
6483
6671
|
}
|
|
6484
6672
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
6485
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
6673
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path26.join)(workspaceRoot, file)));
|
|
6486
6674
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
6487
6675
|
const stale = [...files, ...declared];
|
|
6488
6676
|
if (stale.length === 0) {
|
|
@@ -6508,7 +6696,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
6508
6696
|
};
|
|
6509
6697
|
}
|
|
6510
6698
|
function checkResolvedEslint(workspaceRoot) {
|
|
6511
|
-
const manifestPath = (0,
|
|
6699
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
6512
6700
|
if (!fileExists(manifestPath)) {
|
|
6513
6701
|
return void 0;
|
|
6514
6702
|
}
|
|
@@ -6526,11 +6714,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
6526
6714
|
}
|
|
6527
6715
|
}
|
|
6528
6716
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
6529
|
-
const npmrcPath = (0,
|
|
6717
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6530
6718
|
if (!registry || !fileExists(npmrcPath)) {
|
|
6531
6719
|
return void 0;
|
|
6532
6720
|
}
|
|
6533
|
-
const npmrc = (0,
|
|
6721
|
+
const npmrc = (0, import_node_fs19.readFileSync)(npmrcPath, "utf8");
|
|
6534
6722
|
if (registry.kind === "npm") {
|
|
6535
6723
|
return {
|
|
6536
6724
|
check: ".npmrc authenticates the public registry",
|
|
@@ -6547,11 +6735,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
6547
6735
|
};
|
|
6548
6736
|
}
|
|
6549
6737
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
6550
|
-
const npmrcPath = (0,
|
|
6738
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6551
6739
|
if (!fileExists(npmrcPath)) {
|
|
6552
6740
|
return void 0;
|
|
6553
6741
|
}
|
|
6554
|
-
const npmrc = (0,
|
|
6742
|
+
const npmrc = (0, import_node_fs19.readFileSync)(npmrcPath, "utf8");
|
|
6555
6743
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
6556
6744
|
const referenced = [
|
|
6557
6745
|
...new Set(
|
|
@@ -6575,13 +6763,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
6575
6763
|
};
|
|
6576
6764
|
}
|
|
6577
6765
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
6578
|
-
const npmrcPath = (0,
|
|
6579
|
-
const pipelinePath = (0,
|
|
6766
|
+
const npmrcPath = (0, import_node_path26.join)(workspaceRoot, ".npmrc");
|
|
6767
|
+
const pipelinePath = (0, import_node_path26.join)(workspaceRoot, "azure-pipelines.yml");
|
|
6580
6768
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
6581
6769
|
return void 0;
|
|
6582
6770
|
}
|
|
6583
|
-
const holdsCredentials = (0,
|
|
6584
|
-
const runsTask = (0,
|
|
6771
|
+
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));
|
|
6772
|
+
const runsTask = (0, import_node_fs19.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
6585
6773
|
if (!holdsCredentials && !runsTask) {
|
|
6586
6774
|
return {
|
|
6587
6775
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -6626,13 +6814,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
6626
6814
|
}
|
|
6627
6815
|
function checkVersionActions(workspaceRoot) {
|
|
6628
6816
|
const candidates = [
|
|
6629
|
-
...(0,
|
|
6630
|
-
...(0,
|
|
6631
|
-
...(0,
|
|
6817
|
+
...(0, import_node_fs19.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
6818
|
+
...(0, import_node_fs19.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
6819
|
+
...(0, import_node_fs19.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
6632
6820
|
].map((manifest) => toPosix2(manifest));
|
|
6633
6821
|
return candidates.flatMap((manifest) => {
|
|
6634
6822
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
6635
|
-
const projectJsonPath = (0,
|
|
6823
|
+
const projectJsonPath = (0, import_node_path26.join)(workspaceRoot, projectRoot, "project.json");
|
|
6636
6824
|
let hasOverride = false;
|
|
6637
6825
|
try {
|
|
6638
6826
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -6661,7 +6849,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6661
6849
|
]) {
|
|
6662
6850
|
try {
|
|
6663
6851
|
const targets = extract(
|
|
6664
|
-
readJson((0,
|
|
6852
|
+
readJson((0, import_node_path26.join)(workspaceRoot, projectRoot, file))
|
|
6665
6853
|
);
|
|
6666
6854
|
if (targets && typeof targets === "object") {
|
|
6667
6855
|
sources.push({
|
|
@@ -6677,8 +6865,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6677
6865
|
function checkTargetFilesExist(workspaceRoot) {
|
|
6678
6866
|
const projectRoots = new Set(
|
|
6679
6867
|
[
|
|
6680
|
-
...(0,
|
|
6681
|
-
...(0,
|
|
6868
|
+
...(0, import_node_fs19.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
6869
|
+
...(0, import_node_fs19.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
6682
6870
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
6683
6871
|
);
|
|
6684
6872
|
return [...projectRoots].flatMap(
|
|
@@ -6693,7 +6881,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
6693
6881
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
6694
6882
|
const value = target?.options?.[option];
|
|
6695
6883
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
6696
|
-
if (!checkable || fileExists((0,
|
|
6884
|
+
if (!checkable || fileExists((0, import_node_path26.join)(workspaceRoot, value))) {
|
|
6697
6885
|
return [];
|
|
6698
6886
|
}
|
|
6699
6887
|
return [
|
|
@@ -6730,15 +6918,15 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
6730
6918
|
};
|
|
6731
6919
|
}
|
|
6732
6920
|
function checkGoWorkInSync(workspaceRoot) {
|
|
6733
|
-
const goWorkPath = (0,
|
|
6921
|
+
const goWorkPath = (0, import_node_path26.join)(workspaceRoot, "go.work");
|
|
6734
6922
|
if (!fileExists(goWorkPath)) {
|
|
6735
6923
|
return void 0;
|
|
6736
6924
|
}
|
|
6737
|
-
const contents = (0,
|
|
6925
|
+
const contents = (0, import_node_fs19.existsSync)(goWorkPath) ? (0, import_node_fs19.readFileSync)(goWorkPath, "utf8") : "";
|
|
6738
6926
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
6739
6927
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
6740
6928
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
6741
|
-
const stale = uses.filter((entry) => !(0,
|
|
6929
|
+
const stale = uses.filter((entry) => !(0, import_node_fs19.existsSync)((0, import_node_path26.join)(workspaceRoot, entry, "go.mod")));
|
|
6742
6930
|
return {
|
|
6743
6931
|
check: "every go.work `use` entry points to a module that still exists",
|
|
6744
6932
|
ok: stale.length === 0,
|
|
@@ -6754,9 +6942,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6754
6942
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
6755
6943
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
6756
6944
|
];
|
|
6757
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
6945
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path26.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
6758
6946
|
check: `${file} builds the native apps on every OS`,
|
|
6759
|
-
ok: (0,
|
|
6947
|
+
ok: (0, import_node_fs19.readFileSync)((0, import_node_path26.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
6760
6948
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
6761
6949
|
remedy: "run `mnci upgrade`"
|
|
6762
6950
|
}));
|
|
@@ -6769,7 +6957,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6769
6957
|
return findings;
|
|
6770
6958
|
}
|
|
6771
6959
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
6772
|
-
const manifestPath = (0,
|
|
6960
|
+
const manifestPath = (0, import_node_path26.join)(workspaceRoot, "package.json");
|
|
6773
6961
|
if (!fileExists(manifestPath)) {
|
|
6774
6962
|
return void 0;
|
|
6775
6963
|
}
|
|
@@ -6789,14 +6977,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
6789
6977
|
};
|
|
6790
6978
|
}
|
|
6791
6979
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
6792
|
-
const configs = (0,
|
|
6980
|
+
const configs = (0, import_node_fs19.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6793
6981
|
cwd: workspaceRoot
|
|
6794
6982
|
}).map((config) => toPosix2(config));
|
|
6795
6983
|
return configs.flatMap((relativePath) => {
|
|
6796
|
-
const configPath = (0,
|
|
6984
|
+
const configPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
6797
6985
|
let config;
|
|
6798
6986
|
try {
|
|
6799
|
-
config = (0,
|
|
6987
|
+
config = (0, import_node_fs19.readFileSync)(configPath, "utf8");
|
|
6800
6988
|
} catch {
|
|
6801
6989
|
return [];
|
|
6802
6990
|
}
|
|
@@ -6811,11 +6999,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
6811
6999
|
});
|
|
6812
7000
|
}
|
|
6813
7001
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
6814
|
-
const configs = (0,
|
|
7002
|
+
const configs = (0, import_node_fs19.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6815
7003
|
cwd: workspaceRoot
|
|
6816
7004
|
}).map((config) => toPosix2(config));
|
|
6817
7005
|
return configs.flatMap((relativePath) => {
|
|
6818
|
-
const configPath = (0,
|
|
7006
|
+
const configPath = (0, import_node_path26.join)(workspaceRoot, relativePath);
|
|
6819
7007
|
if (!fileExists(configPath)) {
|
|
6820
7008
|
return [];
|
|
6821
7009
|
}
|
|
@@ -6849,7 +7037,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
6849
7037
|
});
|
|
6850
7038
|
}
|
|
6851
7039
|
function collectFindings(workspaceRoot) {
|
|
6852
|
-
const nxJsonPath = (0,
|
|
7040
|
+
const nxJsonPath = (0, import_node_path26.join)(workspaceRoot, "nx.json");
|
|
6853
7041
|
if (!fileExists(nxJsonPath)) {
|
|
6854
7042
|
throw new Error(
|
|
6855
7043
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -6897,8 +7085,8 @@ function runDoctor(workspaceRoot) {
|
|
|
6897
7085
|
}
|
|
6898
7086
|
|
|
6899
7087
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
6900
|
-
var
|
|
6901
|
-
var
|
|
7088
|
+
var import_node_fs20 = require("fs");
|
|
7089
|
+
var import_node_path27 = require("path");
|
|
6902
7090
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
6903
7091
|
var AGENT_AND_CI_ENTRIES = [
|
|
6904
7092
|
"AGENTS.md",
|
|
@@ -6929,13 +7117,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
6929
7117
|
"packages"
|
|
6930
7118
|
];
|
|
6931
7119
|
function assertAdoptableDirectory(target) {
|
|
6932
|
-
if (!(0,
|
|
7120
|
+
if (!(0, import_node_fs20.existsSync)(target)) {
|
|
6933
7121
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
6934
7122
|
}
|
|
6935
|
-
if (!(0,
|
|
7123
|
+
if (!(0, import_node_fs20.statSync)(target).isDirectory()) {
|
|
6936
7124
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
6937
7125
|
}
|
|
6938
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
7126
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs20.existsSync)((0, import_node_path27.join)(target, entry)));
|
|
6939
7127
|
if (blockers.length > 0) {
|
|
6940
7128
|
throw new Error(
|
|
6941
7129
|
`--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.`
|
|
@@ -6943,15 +7131,15 @@ function assertAdoptableDirectory(target) {
|
|
|
6943
7131
|
}
|
|
6944
7132
|
}
|
|
6945
7133
|
function mergeGitignore(generatedFile, targetFile) {
|
|
6946
|
-
const existing = (0,
|
|
7134
|
+
const existing = (0, import_node_fs20.readFileSync)(targetFile, "utf8");
|
|
6947
7135
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
6948
|
-
const additions = (0,
|
|
7136
|
+
const additions = (0, import_node_fs20.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
6949
7137
|
const trimmed = line.trim();
|
|
6950
7138
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
6951
7139
|
});
|
|
6952
7140
|
if (additions.length === 0) return false;
|
|
6953
7141
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
6954
|
-
(0,
|
|
7142
|
+
(0, import_node_fs20.writeFileSync)(
|
|
6955
7143
|
targetFile,
|
|
6956
7144
|
`${existing}${separator}
|
|
6957
7145
|
# Added by mnci (Nx workspace)
|
|
@@ -6961,9 +7149,9 @@ ${additions.join("\n")}
|
|
|
6961
7149
|
return true;
|
|
6962
7150
|
}
|
|
6963
7151
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
6964
|
-
const entries = (0,
|
|
7152
|
+
const entries = (0, import_node_fs20.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
6965
7153
|
const collisions = entries.filter(
|
|
6966
|
-
(entry) => (0,
|
|
7154
|
+
(entry) => (0, import_node_fs20.existsSync)((0, import_node_path27.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
6967
7155
|
);
|
|
6968
7156
|
if (collisions.length > 0) {
|
|
6969
7157
|
throw new Error(
|
|
@@ -6972,28 +7160,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
6972
7160
|
}
|
|
6973
7161
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
6974
7162
|
for (const entry of entries) {
|
|
6975
|
-
const from = (0,
|
|
6976
|
-
const to = (0,
|
|
6977
|
-
if (entry === ".gitignore" && (0,
|
|
7163
|
+
const from = (0, import_node_path27.join)(generatedRoot, entry);
|
|
7164
|
+
const to = (0, import_node_path27.join)(target, entry);
|
|
7165
|
+
if (entry === ".gitignore" && (0, import_node_fs20.existsSync)(to)) {
|
|
6978
7166
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
6979
7167
|
result.kept.push(entry);
|
|
6980
7168
|
continue;
|
|
6981
7169
|
}
|
|
6982
|
-
if ((0,
|
|
7170
|
+
if ((0, import_node_fs20.existsSync)(to)) {
|
|
6983
7171
|
result.kept.push(entry);
|
|
6984
7172
|
continue;
|
|
6985
7173
|
}
|
|
6986
|
-
(0,
|
|
7174
|
+
(0, import_node_fs20.cpSync)(from, to, { recursive: true });
|
|
6987
7175
|
result.copied.push(entry);
|
|
6988
7176
|
}
|
|
6989
|
-
(0,
|
|
7177
|
+
(0, import_node_fs20.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
6990
7178
|
return result;
|
|
6991
7179
|
}
|
|
6992
7180
|
|
|
6993
7181
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
6994
|
-
var
|
|
7182
|
+
var import_node_fs21 = require("fs");
|
|
6995
7183
|
var import_node_os = require("os");
|
|
6996
|
-
var
|
|
7184
|
+
var import_node_path28 = require("path");
|
|
6997
7185
|
function nxCloudProviderValue(ci) {
|
|
6998
7186
|
return ci === "azure" ? "azure" : "github";
|
|
6999
7187
|
}
|
|
@@ -7036,9 +7224,9 @@ async function resolveRegistry(options) {
|
|
|
7036
7224
|
return await promptRegistry();
|
|
7037
7225
|
}
|
|
7038
7226
|
async function runNew(name, options) {
|
|
7039
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
7227
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path28.resolve)(process.cwd(), options.into);
|
|
7040
7228
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
7041
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
7229
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path28.basename)(adoptTarget));
|
|
7042
7230
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
7043
7231
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
7044
7232
|
const registry = await resolveRegistry(options);
|
|
@@ -7051,8 +7239,8 @@ async function runNew(name, options) {
|
|
|
7051
7239
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
7052
7240
|
const stack = await resolveStack(options);
|
|
7053
7241
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
7054
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
7055
|
-
let workspaceRoot = (0,
|
|
7242
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs21.mkdtempSync)((0, import_node_path28.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
7243
|
+
let workspaceRoot = (0, import_node_path28.join)(stagingParent, workspaceName);
|
|
7056
7244
|
try {
|
|
7057
7245
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
7058
7246
|
runNpx(
|
|
@@ -7075,7 +7263,7 @@ async function runNew(name, options) {
|
|
|
7075
7263
|
workspaceRoot = adoptTarget;
|
|
7076
7264
|
}
|
|
7077
7265
|
} finally {
|
|
7078
|
-
if (adoptTarget !== void 0) (0,
|
|
7266
|
+
if (adoptTarget !== void 0) (0, import_node_fs21.rmSync)(stagingParent, { recursive: true, force: true });
|
|
7079
7267
|
}
|
|
7080
7268
|
logger.step(
|
|
7081
7269
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -7085,8 +7273,8 @@ async function runNew(name, options) {
|
|
|
7085
7273
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
7086
7274
|
logger.detail
|
|
7087
7275
|
);
|
|
7088
|
-
(0,
|
|
7089
|
-
(0,
|
|
7276
|
+
(0, import_node_fs21.rmSync)((0, import_node_path28.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
7277
|
+
(0, import_node_fs21.rmSync)((0, import_node_path28.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
7090
7278
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
7091
7279
|
const installStatus = runShell(
|
|
7092
7280
|
"npm",
|
|
@@ -7124,12 +7312,12 @@ function projectKindHintLines(kinds = PROJECT_KINDS) {
|
|
|
7124
7312
|
}
|
|
7125
7313
|
|
|
7126
7314
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
7127
|
-
var
|
|
7315
|
+
var import_node_path30 = require("path");
|
|
7128
7316
|
var import_prompts4 = require("@inquirer/prompts");
|
|
7129
7317
|
|
|
7130
7318
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
7131
|
-
var
|
|
7132
|
-
var
|
|
7319
|
+
var import_node_fs22 = require("fs");
|
|
7320
|
+
var import_node_path29 = require("path");
|
|
7133
7321
|
function resolveRegistry2(options, persisted) {
|
|
7134
7322
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
7135
7323
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -7158,7 +7346,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
7158
7346
|
return persisted.workspaceName;
|
|
7159
7347
|
}
|
|
7160
7348
|
try {
|
|
7161
|
-
const existing = (0,
|
|
7349
|
+
const existing = (0, import_node_fs22.readdirSync)(workspaceRoot).find(
|
|
7162
7350
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
7163
7351
|
);
|
|
7164
7352
|
if (existing) {
|
|
@@ -7166,11 +7354,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
7166
7354
|
}
|
|
7167
7355
|
} catch {
|
|
7168
7356
|
}
|
|
7169
|
-
return (0,
|
|
7357
|
+
return (0, import_node_path29.basename)(workspaceRoot);
|
|
7170
7358
|
}
|
|
7171
7359
|
function detectNpmAuth(workspaceRoot) {
|
|
7172
7360
|
try {
|
|
7173
|
-
return (0,
|
|
7361
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path29.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
7174
7362
|
} catch {
|
|
7175
7363
|
return void 0;
|
|
7176
7364
|
}
|
|
@@ -7217,7 +7405,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
7217
7405
|
};
|
|
7218
7406
|
}
|
|
7219
7407
|
function runUpgrade(workspaceRoot, options) {
|
|
7220
|
-
if (!fileExists((0,
|
|
7408
|
+
if (!fileExists((0, import_node_path29.join)(workspaceRoot, "nx.json"))) {
|
|
7221
7409
|
throw new Error(
|
|
7222
7410
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
7223
7411
|
);
|
|
@@ -7282,7 +7470,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
7282
7470
|
|
|
7283
7471
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
7284
7472
|
async function runInteractive() {
|
|
7285
|
-
const inWorkspace = fileExists((0,
|
|
7473
|
+
const inWorkspace = fileExists((0, import_node_path30.join)(process.cwd(), "nx.json"));
|
|
7286
7474
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
7287
7475
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
7288
7476
|
const choiceUpgrade = {
|
|
@@ -7303,8 +7491,8 @@ async function runInteractive() {
|
|
|
7303
7491
|
}
|
|
7304
7492
|
|
|
7305
7493
|
// src/cli-version/check-for-update.use-case.ts
|
|
7306
|
-
var
|
|
7307
|
-
var
|
|
7494
|
+
var import_node_fs23 = require("fs");
|
|
7495
|
+
var import_node_path31 = require("path");
|
|
7308
7496
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
7309
7497
|
var PACKAGE_NAME = "@mnci/cli";
|
|
7310
7498
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -7360,8 +7548,8 @@ function releaseTriple(version) {
|
|
|
7360
7548
|
}
|
|
7361
7549
|
function readCliVersion(packageDirectory) {
|
|
7362
7550
|
try {
|
|
7363
|
-
const manifestPath = (0,
|
|
7364
|
-
const manifest = JSON.parse((0,
|
|
7551
|
+
const manifestPath = (0, import_node_path31.join)(packageDirectory, "..", "package.json");
|
|
7552
|
+
const manifest = JSON.parse((0, import_node_fs23.readFileSync)(manifestPath, "utf8"));
|
|
7365
7553
|
return manifest.version ?? "0.0.0";
|
|
7366
7554
|
} catch {
|
|
7367
7555
|
return "0.0.0";
|
|
@@ -7402,8 +7590,8 @@ function buildProgram(cliVersion) {
|
|
|
7402
7590
|
});
|
|
7403
7591
|
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
7404
7592
|
"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"
|
|
7405
|
-
).action((phase) => {
|
|
7406
|
-
process.exitCode = runCiPhase(phase, process.cwd());
|
|
7593
|
+
).action(async (phase) => {
|
|
7594
|
+
process.exitCode = await runCiPhase(phase, process.cwd());
|
|
7407
7595
|
});
|
|
7408
7596
|
program.command("sync").description(
|
|
7409
7597
|
"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"
|