@mnci/cli 4.38.0 → 4.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +446 -171
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -492,6 +492,189 @@ function fileExists(path) {
|
|
|
492
492
|
return (0, import_node_fs4.existsSync)(path);
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
+
// src/pipeline-customization/legacy-pipeline-steps.algorithm.ts
|
|
496
|
+
var MNCI_STEP_NAMES = /* @__PURE__ */ new Set([
|
|
497
|
+
"Add Go tool bin to PATH",
|
|
498
|
+
"Add the Flutter SDK to PATH",
|
|
499
|
+
"Attach HEAD and fetch refs",
|
|
500
|
+
"Attach HEAD to the source branch",
|
|
501
|
+
"Attach the per-platform zips to the GitHub Release (releasable Go apps)",
|
|
502
|
+
"Attach this OS's zip to the GitHub Release (releasable native apps)",
|
|
503
|
+
"Audit dependencies (fails on an actionable npm advisory)",
|
|
504
|
+
"Authenticate npm against the feed (build identity, no PAT)",
|
|
505
|
+
"Authenticate npm registry",
|
|
506
|
+
"Build all deployables",
|
|
507
|
+
"Cache npm packages",
|
|
508
|
+
"Check formatting (run 'npm run format' locally to fix)",
|
|
509
|
+
"Detect .NET projects",
|
|
510
|
+
"Download Go module dependencies",
|
|
511
|
+
"Ensure the function-apps folder exists",
|
|
512
|
+
"Fetch branches and release tags",
|
|
513
|
+
"Install Azure Functions Core Tools",
|
|
514
|
+
"Install dependencies",
|
|
515
|
+
"Install golangci-lint",
|
|
516
|
+
"Install native prerequisites (Linux)",
|
|
517
|
+
"Install Python dependencies (ruff, pytest, build, twine)",
|
|
518
|
+
"Install Python dependencies (ruff, pytest, build, twine, pip-audit)",
|
|
519
|
+
"Install Python project dependencies (editable, workspace-wide)",
|
|
520
|
+
"Lint",
|
|
521
|
+
"Lint, test and build affected projects",
|
|
522
|
+
"Lint, test and build affected projects (PR)",
|
|
523
|
+
"Lint, test and build everything",
|
|
524
|
+
"Lint, test, build and package the native apps",
|
|
525
|
+
"Lint, typecheck, test and build everything",
|
|
526
|
+
"npm audit (fails on an actionable advisory)",
|
|
527
|
+
"npm audit (non-blocking)",
|
|
528
|
+
"Pack all apps (one zip per app -> dist/drop)",
|
|
529
|
+
"Package function apps",
|
|
530
|
+
"Pin npm to the major mnci verifies against",
|
|
531
|
+
"pip-audit (non-blocking)",
|
|
532
|
+
"Preflight \u2014 name the PyPI projects this release would create",
|
|
533
|
+
"Preflight \u2014 npm must accept the token before anything is tagged",
|
|
534
|
+
"Publish function app packages",
|
|
535
|
+
"Publish packages and tag main",
|
|
536
|
+
"Publish Python packages (uv)",
|
|
537
|
+
"Publish the drop (one zip per app)",
|
|
538
|
+
"Push release tags (nx release's own push never runs without a remote Release configured)",
|
|
539
|
+
"Release (version from commits, tag-only, publish)",
|
|
540
|
+
"Resolve Dart dependencies (one pub get for the whole workspace)",
|
|
541
|
+
"Set the git identity used for release tags",
|
|
542
|
+
"Set up the Go toolchain",
|
|
543
|
+
"Set up the language toolchains (Python, Go, Flutter)",
|
|
544
|
+
"Sign in to Microsoft Entra ID (VS Code Marketplace)",
|
|
545
|
+
"Tag the run per app (type-name)",
|
|
546
|
+
"Test and build everything",
|
|
547
|
+
"Verify the workspace is synced (run 'npx nx sync' locally and commit if this fails)",
|
|
548
|
+
"Verify this is a full checkout (nx release needs the real tag history)"
|
|
549
|
+
]);
|
|
550
|
+
var MNCI_STEP_NAME_PATTERNS = [
|
|
551
|
+
/^Install the (\.NET SDK|Flutter SDK)/,
|
|
552
|
+
/^Release — version, tag/,
|
|
553
|
+
/^Verify \(/,
|
|
554
|
+
/^Publish this OS's native zips/
|
|
555
|
+
];
|
|
556
|
+
var MNCI_USES = ["actions/checkout@", "actions/setup-node@", "actions/setup-dotnet@", "actions/upload-artifact@", "azure/login@"];
|
|
557
|
+
var MNCI_TASKS = ["UseNode@", "Cache@", "PublishBuildArtifacts@", "UseDotNet@", "npmAuthenticate@"];
|
|
558
|
+
var MNCI_COMMANDS = ["npm ci", "npm install -g npm@", "git fetch --all", 'git config user.name "github-actions', "git checkout -B", "npx mnci ci", "npx nx sync"];
|
|
559
|
+
function findFirstStepList(lines) {
|
|
560
|
+
const keyAt = lines.findIndex((line) => line.trim() === "steps:");
|
|
561
|
+
if (keyAt === -1) {
|
|
562
|
+
return void 0;
|
|
563
|
+
}
|
|
564
|
+
const firstItem = lines.findIndex((line, index) => index > keyAt && /^\s*- /.test(line));
|
|
565
|
+
if (firstItem === -1) {
|
|
566
|
+
return void 0;
|
|
567
|
+
}
|
|
568
|
+
const indent = lines[firstItem].length - lines[firstItem].trimStart().length;
|
|
569
|
+
const itemStart = " ".repeat(indent) + "- ";
|
|
570
|
+
const steps = [];
|
|
571
|
+
let pending = [];
|
|
572
|
+
let current;
|
|
573
|
+
for (let index = firstItem; index < lines.length; index++) {
|
|
574
|
+
const line = lines[index];
|
|
575
|
+
const lineIndent = line.length - line.trimStart().length;
|
|
576
|
+
const isBlank = line.trim() === "";
|
|
577
|
+
const isComment = line.trimStart().startsWith("#");
|
|
578
|
+
if (line.startsWith(itemStart)) {
|
|
579
|
+
current = { lead: pending, body: [line] };
|
|
580
|
+
steps.push(current);
|
|
581
|
+
pending = [];
|
|
582
|
+
} else if (isBlank || isComment && lineIndent <= indent) {
|
|
583
|
+
pending.push(line);
|
|
584
|
+
} else if (current && lineIndent > indent) {
|
|
585
|
+
current.body.push(...pending, line);
|
|
586
|
+
pending = [];
|
|
587
|
+
} else {
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return { steps, indent };
|
|
592
|
+
}
|
|
593
|
+
function topLevelFields(step) {
|
|
594
|
+
const fields = /* @__PURE__ */ new Map();
|
|
595
|
+
const keyIndent = step.body[0].length - step.body[0].trimStart().length + 2;
|
|
596
|
+
for (const [index, line] of step.body.entries()) {
|
|
597
|
+
const text = index === 0 ? line.trimStart().replace(/^- /, "") : line;
|
|
598
|
+
const lineIndent = index === 0 ? keyIndent : line.length - line.trimStart().length;
|
|
599
|
+
const trimmed = text.trimStart();
|
|
600
|
+
const colon = trimmed.indexOf(":");
|
|
601
|
+
const key = colon === -1 ? "" : trimmed.slice(0, colon);
|
|
602
|
+
if (lineIndent === keyIndent && /^[\w-]+$/.test(key) && !fields.has(key)) {
|
|
603
|
+
fields.set(key, trimmed.slice(colon + 1).trim().replaceAll(/^["']|["']$/g, ""));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return fields;
|
|
607
|
+
}
|
|
608
|
+
function isGeneratedStep(step) {
|
|
609
|
+
const fields = topLevelFields(step);
|
|
610
|
+
const name = fields.get("name") ?? fields.get("displayName");
|
|
611
|
+
if (name !== void 0 && (MNCI_STEP_NAMES.has(name) || MNCI_STEP_NAME_PATTERNS.some((pattern) => pattern.test(name)))) {
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
const uses = fields.get("uses");
|
|
615
|
+
if (uses !== void 0 && MNCI_USES.some((prefix) => uses.startsWith(prefix))) {
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
618
|
+
const task = fields.get("task");
|
|
619
|
+
if (task !== void 0 && MNCI_TASKS.some((prefix) => task.startsWith(prefix))) {
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
if (fields.has("checkout")) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
const command = fields.get("run") ?? fields.get("script");
|
|
626
|
+
return command !== void 0 && MNCI_COMMANDS.some((prefix) => command.startsWith(prefix));
|
|
627
|
+
}
|
|
628
|
+
function describeStep(step) {
|
|
629
|
+
const fields = topLevelFields(step);
|
|
630
|
+
return fields.get("name") ?? fields.get("displayName") ?? (fields.get("run") ?? fields.get("script") ?? step.body[0].trim()).slice(0, 60);
|
|
631
|
+
}
|
|
632
|
+
function landmark(step) {
|
|
633
|
+
const name = topLevelFields(step).get("name") ?? topLevelFields(step).get("displayName") ?? "";
|
|
634
|
+
if (/^(?:Verify \(|Lint|Test and build|Typecheck)/.test(name)) {
|
|
635
|
+
return "verify";
|
|
636
|
+
}
|
|
637
|
+
if (name.startsWith("Pack all apps")) {
|
|
638
|
+
return "pack";
|
|
639
|
+
}
|
|
640
|
+
if (/^(?:Release|Publish packages and tag)/.test(name)) {
|
|
641
|
+
return "release";
|
|
642
|
+
}
|
|
643
|
+
return void 0;
|
|
644
|
+
}
|
|
645
|
+
function readLegacyPipeline(lines) {
|
|
646
|
+
const reading = { slots: /* @__PURE__ */ new Map(), kept: [], hasPack: false, hasRelease: false };
|
|
647
|
+
const list = findFirstStepList(lines);
|
|
648
|
+
if (!list) {
|
|
649
|
+
return reading;
|
|
650
|
+
}
|
|
651
|
+
const marks = list.steps.map((step) => landmark(step));
|
|
652
|
+
const gate = marks.indexOf("verify");
|
|
653
|
+
const release = marks.indexOf("release");
|
|
654
|
+
reading.hasPack = marks.includes("pack");
|
|
655
|
+
reading.hasRelease = release !== -1;
|
|
656
|
+
for (const [index, step] of list.steps.entries()) {
|
|
657
|
+
if (isGeneratedStep(step)) {
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
let slot = "after-install";
|
|
661
|
+
if (release !== -1 && index > release) {
|
|
662
|
+
slot = "after-release";
|
|
663
|
+
} else if (gate !== -1 && index > gate) {
|
|
664
|
+
slot = "before-release";
|
|
665
|
+
}
|
|
666
|
+
const lines_ = [...step.lead, ...step.body].map((line) => line.startsWith(" ".repeat(list.indent)) ? line.slice(list.indent) : line.trimStart());
|
|
667
|
+
const existing = reading.slots.get(slot) ?? [];
|
|
668
|
+
reading.slots.set(slot, [...existing, ...existing.length > 0 ? [""] : [], ...trimBlank(lines_)]);
|
|
669
|
+
reading.kept.push(describeStep(step));
|
|
670
|
+
}
|
|
671
|
+
return reading;
|
|
672
|
+
}
|
|
673
|
+
function trimBlank(lines) {
|
|
674
|
+
const first = lines.findIndex((line) => line.trim() !== "");
|
|
675
|
+
return first === -1 ? [] : lines.slice(first);
|
|
676
|
+
}
|
|
677
|
+
|
|
495
678
|
// src/pipeline-customization/pipeline-markers.algorithm.ts
|
|
496
679
|
var CHOOSABLE_PHASES = ["pack", "release"];
|
|
497
680
|
var SLOT_BEGIN = /^(\s*)# mnci:slot (\S+)/;
|
|
@@ -597,6 +780,31 @@ function inspectPipeline(text) {
|
|
|
597
780
|
};
|
|
598
781
|
}
|
|
599
782
|
|
|
783
|
+
// src/pipeline-customization/migrate-legacy-pipeline.use-case.ts
|
|
784
|
+
function migrateLegacyPipeline(legacy, generated) {
|
|
785
|
+
const reading = readLegacyPipeline(legacy.split("\n"));
|
|
786
|
+
const off = [];
|
|
787
|
+
if (reading.kept.length > 0 || reading.hasPack || reading.hasRelease) {
|
|
788
|
+
if (!reading.hasPack) {
|
|
789
|
+
off.push("pack");
|
|
790
|
+
}
|
|
791
|
+
if (!reading.hasRelease) {
|
|
792
|
+
off.push("release");
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
const text = commentOutPhases(injectSlots(generated, reading.slots), off);
|
|
796
|
+
const notes = [
|
|
797
|
+
"This pipeline was written before mnci kept user slots, so it was regenerated. Edits to the steps mnci generated, and anything outside the step list (triggers, variables, extra jobs), are in git history."
|
|
798
|
+
];
|
|
799
|
+
if (reading.kept.length > 0) {
|
|
800
|
+
notes.push(`Kept ${reading.kept.length} step${reading.kept.length === 1 ? "" : "s"} of your own in the new slots: ${reading.kept.join("; ")}. Check their order.`);
|
|
801
|
+
}
|
|
802
|
+
for (const phase of off) {
|
|
803
|
+
notes.push(`The old pipeline had no ${phase} step, so the ${phase} phase is switched off.`);
|
|
804
|
+
}
|
|
805
|
+
return { text, notes };
|
|
806
|
+
}
|
|
807
|
+
|
|
600
808
|
// src/pipeline-customization/merge-pipeline.use-case.ts
|
|
601
809
|
function mergePipeline(existing, generated) {
|
|
602
810
|
if (existing === void 0) {
|
|
@@ -604,10 +812,7 @@ function mergePipeline(existing, generated) {
|
|
|
604
812
|
}
|
|
605
813
|
const normalized = existing.replaceAll("\r\n", "\n");
|
|
606
814
|
if (!/^\s*# mnci:(?:slot|phase) /m.test(normalized)) {
|
|
607
|
-
return
|
|
608
|
-
text: generated,
|
|
609
|
-
notes: ['This pipeline was written before mnci kept user slots, so it was regenerated whole. Edits outside the generated steps are in git history: re-apply them inside the new "# mnci:slot" blocks.']
|
|
610
|
-
};
|
|
815
|
+
return migrateLegacyPipeline(normalized, generated);
|
|
611
816
|
}
|
|
612
817
|
const off = switchedOffPhases(normalized);
|
|
613
818
|
const text = commentOutPhases(injectSlots(generated, extractSlots(normalized)), off);
|
|
@@ -2376,13 +2581,80 @@ function runPack(workspaceRoot, dependencies = {}) {
|
|
|
2376
2581
|
return status;
|
|
2377
2582
|
}
|
|
2378
2583
|
|
|
2379
|
-
// src/ci-pipeline/
|
|
2584
|
+
// src/ci-pipeline/report-phase.use-case.ts
|
|
2380
2585
|
var import_node_fs8 = require("fs");
|
|
2586
|
+
|
|
2587
|
+
// src/ci-pipeline/phase-timing.algorithm.ts
|
|
2588
|
+
function formatDuration(milliseconds) {
|
|
2589
|
+
const seconds = Math.max(0, milliseconds) / 1e3;
|
|
2590
|
+
if (seconds < 60) {
|
|
2591
|
+
return `${seconds.toFixed(1)}s`;
|
|
2592
|
+
}
|
|
2593
|
+
const whole = Math.round(seconds);
|
|
2594
|
+
return `${Math.floor(whole / 60)}m ${String(whole % 60).padStart(2, "0")}s`;
|
|
2595
|
+
}
|
|
2596
|
+
function escapeCommandData(text) {
|
|
2597
|
+
return text.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
2598
|
+
}
|
|
2599
|
+
function describePhaseOutcome(host, phase, status, milliseconds) {
|
|
2600
|
+
const took = formatDuration(milliseconds);
|
|
2601
|
+
if (status === 0) {
|
|
2602
|
+
return {
|
|
2603
|
+
log: `mnci ci ${phase}: passed in ${took}`,
|
|
2604
|
+
summary: `- \u2705 **${phase}** passed in ${took}`
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
const message = `The ${phase} phase failed with exit status ${status} after ${took}`;
|
|
2608
|
+
let annotation;
|
|
2609
|
+
if (host === "github") {
|
|
2610
|
+
annotation = `::error title=mnci ci ${phase}::${escapeCommandData(message)}`;
|
|
2611
|
+
} else if (host === "azure") {
|
|
2612
|
+
annotation = `##vso[task.logissue type=error;]${message}`;
|
|
2613
|
+
}
|
|
2614
|
+
return {
|
|
2615
|
+
log: `mnci ci ${phase}: failed (exit ${status}) in ${took}`,
|
|
2616
|
+
annotation,
|
|
2617
|
+
summary: `- \u274C **${phase}** failed (exit ${status}) after ${took}`
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
// src/ci-pipeline/report-phase.use-case.ts
|
|
2622
|
+
async function reportPhase(phase, run, dependencies = {}) {
|
|
2623
|
+
const environment = dependencies.environment ?? process.env;
|
|
2624
|
+
const log = dependencies.log ?? ((message) => {
|
|
2625
|
+
console.log(message);
|
|
2626
|
+
});
|
|
2627
|
+
const clock = dependencies.clock ?? (() => Date.now());
|
|
2628
|
+
const host = detectCiHost(environment);
|
|
2629
|
+
const started = clock();
|
|
2630
|
+
const finish = (status) => {
|
|
2631
|
+
const outcome = describePhaseOutcome(host, phase, status, clock() - started);
|
|
2632
|
+
log(outcome.log);
|
|
2633
|
+
if (outcome.annotation !== void 0) {
|
|
2634
|
+
log(outcome.annotation);
|
|
2635
|
+
}
|
|
2636
|
+
if (host === "github" && environment.GITHUB_STEP_SUMMARY) {
|
|
2637
|
+
(0, import_node_fs8.appendFileSync)(environment.GITHUB_STEP_SUMMARY, `${outcome.summary}
|
|
2638
|
+
`);
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2641
|
+
try {
|
|
2642
|
+
const status = await run();
|
|
2643
|
+
finish(status);
|
|
2644
|
+
return status;
|
|
2645
|
+
} catch (error) {
|
|
2646
|
+
finish(1);
|
|
2647
|
+
throw error;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// src/ci-pipeline/release.use-case.ts
|
|
2652
|
+
var import_node_fs9 = require("fs");
|
|
2381
2653
|
var import_node_path7 = require("path");
|
|
2382
2654
|
var SPECIFIER = /^(?:major|minor|patch|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2383
2655
|
function hasTag(workspaceRoot, relativePath, tag) {
|
|
2384
2656
|
try {
|
|
2385
|
-
const parsed = JSON.parse((0,
|
|
2657
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)((0, import_node_path7.join)(workspaceRoot, relativePath), "utf8"));
|
|
2386
2658
|
const tags = relativePath.endsWith("project.json") ? parsed.tags : parsed.nx?.tags;
|
|
2387
2659
|
return Array.isArray(tags) && tags.includes(tag);
|
|
2388
2660
|
} catch {
|
|
@@ -2391,12 +2663,12 @@ function hasTag(workspaceRoot, relativePath, tag) {
|
|
|
2391
2663
|
}
|
|
2392
2664
|
function releasableCounts(workspaceRoot) {
|
|
2393
2665
|
return {
|
|
2394
|
-
npm: (0,
|
|
2395
|
-
csharp: (0,
|
|
2396
|
-
python: (0,
|
|
2397
|
-
dart: (0,
|
|
2398
|
-
vscode: (0,
|
|
2399
|
-
go: (0,
|
|
2666
|
+
npm: (0, import_node_fs9.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length,
|
|
2667
|
+
csharp: (0, import_node_fs9.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }).length,
|
|
2668
|
+
python: (0, import_node_fs9.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot }).length,
|
|
2669
|
+
dart: (0, import_node_fs9.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }).length,
|
|
2670
|
+
vscode: (0, import_node_fs9.globSync)("apps/*/package.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, VSCODE_EXTENSION_TAG)).length,
|
|
2671
|
+
go: (0, import_node_fs9.globSync)("apps/*/project.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, GO_RELEASE_TAG)).length
|
|
2400
2672
|
};
|
|
2401
2673
|
}
|
|
2402
2674
|
function shallowCloneGuard(processes, log) {
|
|
@@ -2412,7 +2684,7 @@ function shallowCloneGuard(processes, log) {
|
|
|
2412
2684
|
return 0;
|
|
2413
2685
|
}
|
|
2414
2686
|
function npmPreflight(workspaceRoot, registryKind, environment, processes, log) {
|
|
2415
|
-
if (registryKind !== "npm" || (0,
|
|
2687
|
+
if (registryKind !== "npm" || (0, import_node_fs9.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length === 0) {
|
|
2416
2688
|
return 0;
|
|
2417
2689
|
}
|
|
2418
2690
|
if (!environment.NODE_AUTH_TOKEN) {
|
|
@@ -2428,7 +2700,7 @@ function npmPreflight(workspaceRoot, registryKind, environment, processes, log)
|
|
|
2428
2700
|
return 0;
|
|
2429
2701
|
}
|
|
2430
2702
|
async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetchStatus) {
|
|
2431
|
-
const files = (0,
|
|
2703
|
+
const files = (0, import_node_fs9.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot });
|
|
2432
2704
|
if (registryKind !== "npm" || files.length === 0) {
|
|
2433
2705
|
return 0;
|
|
2434
2706
|
}
|
|
@@ -2441,7 +2713,7 @@ async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetc
|
|
|
2441
2713
|
return 1;
|
|
2442
2714
|
}
|
|
2443
2715
|
const names = files.map((file) => {
|
|
2444
|
-
const text = (0,
|
|
2716
|
+
const text = (0, import_node_fs9.readFileSync)((0, import_node_path7.join)(workspaceRoot, file), "utf8");
|
|
2445
2717
|
const block = text.slice(text.indexOf("[project]"));
|
|
2446
2718
|
const line = block.split("\n").find((entry) => entry.trimStart().startsWith("name"));
|
|
2447
2719
|
return line ? line.split("=", 2)[1].replaceAll(/[^\w.-]/gi, "") : "";
|
|
@@ -2516,14 +2788,14 @@ function runReleaseCommand(workspaceRoot, registry, counts, environment, process
|
|
|
2516
2788
|
}
|
|
2517
2789
|
function nxPushesTags(workspaceRoot) {
|
|
2518
2790
|
try {
|
|
2519
|
-
const nx = JSON.parse((0,
|
|
2791
|
+
const nx = JSON.parse((0, import_node_fs9.readFileSync)((0, import_node_path7.join)(workspaceRoot, "nx.json"), "utf8"));
|
|
2520
2792
|
return nx.release?.git?.push === true;
|
|
2521
2793
|
} catch {
|
|
2522
2794
|
return false;
|
|
2523
2795
|
}
|
|
2524
2796
|
}
|
|
2525
2797
|
function afterRelease(workspaceRoot, processes, githubReleases) {
|
|
2526
|
-
if (githubReleases && (0,
|
|
2798
|
+
if (githubReleases && (0, import_node_fs9.existsSync)((0, import_node_path7.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2527
2799
|
const assets = processes.run("node", ["tools/go-app-release.cjs", "assets"]);
|
|
2528
2800
|
if (assets !== 0) {
|
|
2529
2801
|
return assets;
|
|
@@ -2574,17 +2846,17 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2574
2846
|
}
|
|
2575
2847
|
|
|
2576
2848
|
// src/ci-pipeline/setup.use-case.ts
|
|
2577
|
-
var
|
|
2849
|
+
var import_node_fs12 = require("fs");
|
|
2578
2850
|
var import_node_path10 = require("path");
|
|
2579
2851
|
|
|
2580
2852
|
// src/ci-pipeline/flutter-sdk.use-case.ts
|
|
2581
|
-
var
|
|
2853
|
+
var import_node_fs10 = require("fs");
|
|
2582
2854
|
var import_node_path8 = require("path");
|
|
2583
2855
|
function flutterSdkDirectory(machine) {
|
|
2584
2856
|
return (0, import_node_path8.join)(machine.home, `.mnci-flutter-${FLUTTER_SDK_VERSION}`);
|
|
2585
2857
|
}
|
|
2586
2858
|
function installFlutterSdk(workspaceRoot, processes, log, machine) {
|
|
2587
|
-
if (!(0,
|
|
2859
|
+
if (!(0, import_node_fs10.existsSync)((0, import_node_path8.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2588
2860
|
log("No Flutter projects - skipping.");
|
|
2589
2861
|
return 0;
|
|
2590
2862
|
}
|
|
@@ -2593,26 +2865,26 @@ function installFlutterSdk(workspaceRoot, processes, log, machine) {
|
|
|
2593
2865
|
return 0;
|
|
2594
2866
|
}
|
|
2595
2867
|
const sdk = flutterSdkDirectory(machine);
|
|
2596
|
-
if ((0,
|
|
2868
|
+
if ((0, import_node_fs10.existsSync)(sdk)) {
|
|
2597
2869
|
log(`Flutter SDK already installed at ${sdk} - skipping.`);
|
|
2598
2870
|
return 0;
|
|
2599
2871
|
}
|
|
2600
2872
|
return processes.run("git", ["clone", "--depth", "1", "--branch", FLUTTER_SDK_VERSION, "https://github.com/flutter/flutter.git", sdk]);
|
|
2601
2873
|
}
|
|
2602
2874
|
function publishFlutterSdk(workspaceRoot, host, environment, log, machine) {
|
|
2603
|
-
if (!(0,
|
|
2875
|
+
if (!(0, import_node_fs10.existsSync)((0, import_node_path8.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2604
2876
|
log("No Flutter projects - skipping.");
|
|
2605
2877
|
return;
|
|
2606
2878
|
}
|
|
2607
2879
|
const sdk = flutterSdkDirectory(machine);
|
|
2608
|
-
if (!(0,
|
|
2880
|
+
if (!(0, import_node_fs10.existsSync)(sdk)) {
|
|
2609
2881
|
log("Flutter SDK was not installed by mnci (already on PATH) - skipping.");
|
|
2610
2882
|
return;
|
|
2611
2883
|
}
|
|
2612
2884
|
addToPath(host, environment, (0, import_node_path8.join)(sdk, "bin"), log);
|
|
2613
2885
|
}
|
|
2614
2886
|
function resolveDartDependencies(workspaceRoot, processes, log) {
|
|
2615
|
-
if (!(0,
|
|
2887
|
+
if (!(0, import_node_fs10.existsSync)((0, import_node_path8.join)(workspaceRoot, "pubspec.yaml"))) {
|
|
2616
2888
|
log("No Flutter projects - skipping.");
|
|
2617
2889
|
return 0;
|
|
2618
2890
|
}
|
|
@@ -2621,7 +2893,7 @@ function resolveDartDependencies(workspaceRoot, processes, log) {
|
|
|
2621
2893
|
|
|
2622
2894
|
// src/ci-pipeline/go-tools.use-case.ts
|
|
2623
2895
|
var import_node_crypto = require("crypto");
|
|
2624
|
-
var
|
|
2896
|
+
var import_node_fs11 = require("fs");
|
|
2625
2897
|
var import_node_os = require("os");
|
|
2626
2898
|
var import_node_path9 = require("path");
|
|
2627
2899
|
function currentMachine() {
|
|
@@ -2629,7 +2901,7 @@ function currentMachine() {
|
|
|
2629
2901
|
}
|
|
2630
2902
|
var GOLANGCI_LINT_MODULE = "github.com/golangci/golangci-lint/v2/cmd/golangci-lint";
|
|
2631
2903
|
function downloadGoModules(workspaceRoot, processes, log) {
|
|
2632
|
-
if (!(0,
|
|
2904
|
+
if (!(0, import_node_fs11.existsSync)((0, import_node_path9.join)(workspaceRoot, "go.mod"))) {
|
|
2633
2905
|
log("No Go projects - skipping.");
|
|
2634
2906
|
return 0;
|
|
2635
2907
|
}
|
|
@@ -2637,7 +2909,7 @@ function downloadGoModules(workspaceRoot, processes, log) {
|
|
|
2637
2909
|
}
|
|
2638
2910
|
async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
2639
2911
|
const { processes, log, fetchBytes } = dependencies;
|
|
2640
|
-
if (!(0,
|
|
2912
|
+
if (!(0, import_node_fs11.existsSync)((0, import_node_path9.join)(workspaceRoot, "go.mod"))) {
|
|
2641
2913
|
log("No Go projects - skipping.");
|
|
2642
2914
|
return 0;
|
|
2643
2915
|
}
|
|
@@ -2674,30 +2946,30 @@ async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
|
2674
2946
|
if ((0, import_node_crypto.createHash)("sha256").update(archive).digest("hex") !== entry[0]) {
|
|
2675
2947
|
throw new Error(`checksum mismatch for ${file}`);
|
|
2676
2948
|
}
|
|
2677
|
-
temporary = (0,
|
|
2949
|
+
temporary = (0, import_node_fs11.mkdtempSync)((0, import_node_path9.join)((0, import_node_os.tmpdir)(), "golangci-lint-"));
|
|
2678
2950
|
const archivePath = (0, import_node_path9.join)(temporary, file);
|
|
2679
|
-
(0,
|
|
2951
|
+
(0, import_node_fs11.writeFileSync)(archivePath, archive);
|
|
2680
2952
|
const tar = platform === "windows" ? (0, import_node_path9.join)(process.env.SystemRoot ?? "", "System32", "tar.exe") : "tar";
|
|
2681
2953
|
if (processes.run(tar, ["-xf", archivePath, "-C", temporary]) !== 0) {
|
|
2682
2954
|
throw new Error(`could not extract ${file}`);
|
|
2683
2955
|
}
|
|
2684
2956
|
const executable = `golangci-lint${platform === "windows" ? ".exe" : ""}`;
|
|
2685
2957
|
const bin = (0, import_node_path9.join)(gopath.stdout.trim(), "bin");
|
|
2686
|
-
(0,
|
|
2687
|
-
(0,
|
|
2688
|
-
(0,
|
|
2958
|
+
(0, import_node_fs11.mkdirSync)(bin, { recursive: true });
|
|
2959
|
+
(0, import_node_fs11.copyFileSync)((0, import_node_path9.join)(temporary, name, executable), (0, import_node_path9.join)(bin, executable));
|
|
2960
|
+
(0, import_node_fs11.chmodSync)((0, import_node_path9.join)(bin, executable), 493);
|
|
2689
2961
|
log(`golangci-lint ${version} installed from its checksum-verified prebuilt release into ${bin}`);
|
|
2690
2962
|
return 0;
|
|
2691
2963
|
} catch (error) {
|
|
2692
2964
|
return fallback(error instanceof Error ? error.message : String(error));
|
|
2693
2965
|
} finally {
|
|
2694
2966
|
if (temporary !== void 0) {
|
|
2695
|
-
(0,
|
|
2967
|
+
(0, import_node_fs11.rmSync)(temporary, { recursive: true, force: true });
|
|
2696
2968
|
}
|
|
2697
2969
|
}
|
|
2698
2970
|
}
|
|
2699
2971
|
function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
2700
|
-
if (!(0,
|
|
2972
|
+
if (!(0, import_node_fs11.existsSync)((0, import_node_path9.join)(workspaceRoot, "go.mod"))) {
|
|
2701
2973
|
log("No Go projects - skipping.");
|
|
2702
2974
|
return;
|
|
2703
2975
|
}
|
|
@@ -2714,15 +2986,15 @@ function pythonCommand(machine) {
|
|
|
2714
2986
|
return machine.platform === "win32" ? "python" : "python3";
|
|
2715
2987
|
}
|
|
2716
2988
|
function installPythonToolchain(workspaceRoot, processes, log, machine) {
|
|
2717
|
-
if (!(0,
|
|
2989
|
+
if (!(0, import_node_fs12.existsSync)((0, import_node_path10.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
2718
2990
|
log("No Python projects - skipping.");
|
|
2719
2991
|
return 0;
|
|
2720
2992
|
}
|
|
2721
2993
|
return processes.run(pythonCommand(machine), ["-m", "pip", "install", "-r", "requirements-dev.txt"]);
|
|
2722
2994
|
}
|
|
2723
2995
|
function installPythonProjects(workspaceRoot, processes, log, machine) {
|
|
2724
|
-
const editable = ["apps/*/pyproject.toml", "python-packages/*/pyproject.toml", "libs/*/pyproject.toml"].flatMap((pattern) => (0,
|
|
2725
|
-
const requirements = (0,
|
|
2996
|
+
const editable = ["apps/*/pyproject.toml", "python-packages/*/pyproject.toml", "libs/*/pyproject.toml"].flatMap((pattern) => (0, import_node_fs12.globSync)(pattern, { cwd: workspaceRoot })).map((path) => (0, import_node_path10.dirname)(path));
|
|
2997
|
+
const requirements = (0, import_node_fs12.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot });
|
|
2726
2998
|
if (editable.length === 0 && requirements.length === 0) {
|
|
2727
2999
|
log("No Python projects - skipping.");
|
|
2728
3000
|
return 0;
|
|
@@ -2841,6 +3113,9 @@ function runVerify(workspaceRoot, dependencies = {}) {
|
|
|
2841
3113
|
// src/ci-pipeline/index.ts
|
|
2842
3114
|
var CI_PHASES = ["setup", "audit", "verify", "pack", "release", "native"];
|
|
2843
3115
|
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
3116
|
+
return reportPhase(phase, () => runPhase(phase, workspaceRoot, dependencies), dependencies);
|
|
3117
|
+
}
|
|
3118
|
+
function runPhase(phase, workspaceRoot, dependencies) {
|
|
2844
3119
|
switch (phase) {
|
|
2845
3120
|
case "verify": {
|
|
2846
3121
|
return runVerify(workspaceRoot, dependencies);
|
|
@@ -2877,7 +3152,7 @@ function assertValidProjectName(name, label) {
|
|
|
2877
3152
|
}
|
|
2878
3153
|
|
|
2879
3154
|
// src/project-scaffolding/csharp.use-case.ts
|
|
2880
|
-
var
|
|
3155
|
+
var import_node_fs14 = require("fs");
|
|
2881
3156
|
var import_node_path12 = require("path");
|
|
2882
3157
|
|
|
2883
3158
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
@@ -2919,7 +3194,7 @@ public class GreetUseCaseTests
|
|
|
2919
3194
|
}
|
|
2920
3195
|
|
|
2921
3196
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2922
|
-
var
|
|
3197
|
+
var import_node_fs13 = require("fs");
|
|
2923
3198
|
var import_node_path11 = require("path");
|
|
2924
3199
|
function hasPlugin(workspaceRoot, packageName) {
|
|
2925
3200
|
const manifest = readJson((0, import_node_path11.join)(workspaceRoot, "package.json"));
|
|
@@ -2982,11 +3257,11 @@ function removeStaleGitkeeps(workspaceRoot) {
|
|
|
2982
3257
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
2983
3258
|
const directory = (0, import_node_path11.join)(workspaceRoot, scaffold);
|
|
2984
3259
|
try {
|
|
2985
|
-
const holdsAProject = (0,
|
|
3260
|
+
const holdsAProject = (0, import_node_fs13.readdirSync)(directory, { withFileTypes: true }).some(
|
|
2986
3261
|
(entry) => entry.isDirectory()
|
|
2987
3262
|
);
|
|
2988
3263
|
if (holdsAProject) {
|
|
2989
|
-
(0,
|
|
3264
|
+
(0, import_node_fs13.rmSync)((0, import_node_path11.join)(directory, ".gitkeep"), { force: true });
|
|
2990
3265
|
}
|
|
2991
3266
|
} catch {
|
|
2992
3267
|
}
|
|
@@ -3034,13 +3309,13 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
3034
3309
|
];
|
|
3035
3310
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
3036
3311
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
3037
|
-
(0,
|
|
3312
|
+
(0, import_node_fs13.rmSync)((0, import_node_path11.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
3038
3313
|
}
|
|
3039
|
-
(0,
|
|
3314
|
+
(0, import_node_fs13.rmSync)((0, import_node_path11.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
3040
3315
|
}
|
|
3041
3316
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
3042
3317
|
try {
|
|
3043
|
-
const entry = (0,
|
|
3318
|
+
const entry = (0, import_node_fs13.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
3044
3319
|
return entry ? (0, import_node_path11.join)(workspaceRoot, entry) : void 0;
|
|
3045
3320
|
} catch {
|
|
3046
3321
|
return void 0;
|
|
@@ -3059,7 +3334,7 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
3059
3334
|
}
|
|
3060
3335
|
function reshapeReactAppScaffold(projectRoot) {
|
|
3061
3336
|
const appDir = (0, import_node_path11.join)(projectRoot, "src", "app");
|
|
3062
|
-
if (!(0,
|
|
3337
|
+
if (!(0, import_node_fs13.existsSync)((0, import_node_path11.join)(appDir, "app.tsx"))) {
|
|
3063
3338
|
return;
|
|
3064
3339
|
}
|
|
3065
3340
|
for (const [from, to] of [
|
|
@@ -3067,13 +3342,13 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
3067
3342
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
3068
3343
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
3069
3344
|
]) {
|
|
3070
|
-
if ((0,
|
|
3071
|
-
(0,
|
|
3345
|
+
if ((0, import_node_fs13.existsSync)((0, import_node_path11.join)(appDir, from))) {
|
|
3346
|
+
(0, import_node_fs13.renameSync)((0, import_node_path11.join)(appDir, from), (0, import_node_path11.join)(appDir, to));
|
|
3072
3347
|
}
|
|
3073
3348
|
}
|
|
3074
3349
|
const rewrite = (file, from, to) => {
|
|
3075
|
-
if ((0,
|
|
3076
|
-
writeFileEnsured(file, repointSpecifier((0,
|
|
3350
|
+
if ((0, import_node_fs13.existsSync)(file)) {
|
|
3351
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs13.readFileSync)(file, "utf8"), from, to));
|
|
3077
3352
|
}
|
|
3078
3353
|
};
|
|
3079
3354
|
rewrite((0, import_node_path11.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
@@ -3085,8 +3360,8 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
3085
3360
|
);
|
|
3086
3361
|
}
|
|
3087
3362
|
function emptySlice(projectRoot, sliceDir) {
|
|
3088
|
-
for (const entry of (0,
|
|
3089
|
-
(0,
|
|
3363
|
+
for (const entry of (0, import_node_fs13.readdirSync)(sliceDir)) {
|
|
3364
|
+
(0, import_node_fs13.rmSync)((0, import_node_path11.join)(sliceDir, entry), { recursive: true, force: true });
|
|
3090
3365
|
}
|
|
3091
3366
|
writeFileEnsured((0, import_node_path11.join)(sliceDir, "index.ts"), "export {}\n");
|
|
3092
3367
|
addNxTargets((0, import_node_path11.join)(projectRoot, "package.json"), { test: { options: { passWithNoTests: true } } });
|
|
@@ -3094,33 +3369,33 @@ function emptySlice(projectRoot, sliceDir) {
|
|
|
3094
3369
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
3095
3370
|
const sourceDir = (0, import_node_path11.join)(projectRoot, "src");
|
|
3096
3371
|
const libDir = (0, import_node_path11.join)(sourceDir, "lib");
|
|
3097
|
-
if (!(0,
|
|
3372
|
+
if (!(0, import_node_fs13.existsSync)((0, import_node_path11.join)(libDir, `${name}.${extension}`))) {
|
|
3098
3373
|
return;
|
|
3099
3374
|
}
|
|
3100
3375
|
const sliceDir = (0, import_node_path11.join)(sourceDir, name);
|
|
3101
|
-
(0,
|
|
3102
|
-
for (const entry of (0,
|
|
3376
|
+
(0, import_node_fs13.mkdirSync)(sliceDir, { recursive: true });
|
|
3377
|
+
for (const entry of (0, import_node_fs13.readdirSync)(libDir)) {
|
|
3103
3378
|
if (entry === `${name}.${extension}`) {
|
|
3104
|
-
(0,
|
|
3379
|
+
(0, import_node_fs13.renameSync)((0, import_node_path11.join)(libDir, entry), (0, import_node_path11.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
3105
3380
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
3106
3381
|
const renamed = (0, import_node_path11.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
3107
|
-
(0,
|
|
3108
|
-
writeFileEnsured(renamed, repointSpecifier((0,
|
|
3382
|
+
(0, import_node_fs13.renameSync)((0, import_node_path11.join)(libDir, entry), renamed);
|
|
3383
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs13.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
3109
3384
|
} else {
|
|
3110
|
-
(0,
|
|
3385
|
+
(0, import_node_fs13.renameSync)((0, import_node_path11.join)(libDir, entry), (0, import_node_path11.join)(sliceDir, entry));
|
|
3111
3386
|
}
|
|
3112
3387
|
}
|
|
3113
3388
|
const barrel = (0, import_node_path11.join)(sourceDir, "index.ts");
|
|
3114
|
-
const esm = (0,
|
|
3389
|
+
const esm = (0, import_node_fs13.existsSync)(barrel) && (0, import_node_fs13.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
3115
3390
|
writeFileEnsured((0, import_node_path11.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
3116
3391
|
`);
|
|
3117
|
-
if ((0,
|
|
3392
|
+
if ((0, import_node_fs13.existsSync)(barrel)) {
|
|
3118
3393
|
writeFileEnsured(
|
|
3119
3394
|
barrel,
|
|
3120
|
-
(0,
|
|
3395
|
+
(0, import_node_fs13.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
3121
3396
|
);
|
|
3122
3397
|
}
|
|
3123
|
-
(0,
|
|
3398
|
+
(0, import_node_fs13.rmSync)(libDir, { recursive: true, force: true });
|
|
3124
3399
|
if (empty) {
|
|
3125
3400
|
emptySlice(projectRoot, sliceDir);
|
|
3126
3401
|
} else if (role === "use-case") {
|
|
@@ -3183,7 +3458,7 @@ function repointSpecifier(source, from, to) {
|
|
|
3183
3458
|
}
|
|
3184
3459
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
3185
3460
|
const manifestPath = (0, import_node_path11.join)(workspaceRoot, "package.json");
|
|
3186
|
-
if (!(0,
|
|
3461
|
+
if (!(0, import_node_fs13.existsSync)(manifestPath)) {
|
|
3187
3462
|
return;
|
|
3188
3463
|
}
|
|
3189
3464
|
const manifest = readJson(manifestPath);
|
|
@@ -3207,7 +3482,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3207
3482
|
scripts[`${name}:start`] = commands.start;
|
|
3208
3483
|
}
|
|
3209
3484
|
const dependabotPath = (0, import_node_path11.join)(workspaceRoot, ".github/dependabot.yml");
|
|
3210
|
-
if ((0,
|
|
3485
|
+
if ((0, import_node_fs13.existsSync)(dependabotPath)) {
|
|
3211
3486
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
3212
3487
|
}
|
|
3213
3488
|
const manifestPath = (0, import_node_path11.join)(workspaceRoot, "package.json");
|
|
@@ -3314,7 +3589,7 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
3314
3589
|
}
|
|
3315
3590
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
3316
3591
|
if (kind === "classlib") {
|
|
3317
|
-
(0,
|
|
3592
|
+
(0, import_node_fs14.rmSync)((0, import_node_path12.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
3318
3593
|
}
|
|
3319
3594
|
const files = csharpExampleFiles(identity);
|
|
3320
3595
|
for (const [file, contents] of Object.entries(files)) {
|
|
@@ -3328,7 +3603,7 @@ function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
|
3328
3603
|
const name = (0, import_node_path12.basename)(projectRoot);
|
|
3329
3604
|
const testRoot = `tests/${name}`;
|
|
3330
3605
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
3331
|
-
(0,
|
|
3606
|
+
(0, import_node_fs14.rmSync)((0, import_node_path12.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
3332
3607
|
writeFileEnsured((0, import_node_path12.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
3333
3608
|
writeFileEnsured(
|
|
3334
3609
|
(0, import_node_path12.join)(workspaceRoot, testRoot, "project.json"),
|
|
@@ -3472,7 +3747,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3472
3747
|
);
|
|
3473
3748
|
}
|
|
3474
3749
|
function addInitialVersion(csprojPath) {
|
|
3475
|
-
const contents = (0,
|
|
3750
|
+
const contents = (0, import_node_fs14.readFileSync)(csprojPath, "utf8");
|
|
3476
3751
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3477
3752
|
}
|
|
3478
3753
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3648,7 +3923,7 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3648
3923
|
}
|
|
3649
3924
|
|
|
3650
3925
|
// src/project-scaffolding/go.use-case.ts
|
|
3651
|
-
var
|
|
3926
|
+
var import_node_fs18 = require("fs");
|
|
3652
3927
|
var import_node_path17 = require("path");
|
|
3653
3928
|
|
|
3654
3929
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
@@ -3718,14 +3993,14 @@ function goAppExampleFiles(modulePath) {
|
|
|
3718
3993
|
}
|
|
3719
3994
|
|
|
3720
3995
|
// src/go-workspace/go-plugin.use-case.ts
|
|
3721
|
-
var
|
|
3996
|
+
var import_node_fs15 = require("fs");
|
|
3722
3997
|
var import_node_path14 = require("path");
|
|
3723
3998
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
3724
3999
|
function hasGoProject(workspaceRoot) {
|
|
3725
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0,
|
|
4000
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs15.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
3726
4001
|
return projectFiles.some((projectFile) => {
|
|
3727
4002
|
try {
|
|
3728
|
-
const { tags } = JSON.parse((0,
|
|
4003
|
+
const { tags } = JSON.parse((0, import_node_fs15.readFileSync)((0, import_node_path14.join)(workspaceRoot, projectFile), "utf8"));
|
|
3729
4004
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
3730
4005
|
} catch {
|
|
3731
4006
|
return false;
|
|
@@ -3784,7 +4059,7 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3784
4059
|
}
|
|
3785
4060
|
|
|
3786
4061
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3787
|
-
var
|
|
4062
|
+
var import_node_fs16 = require("fs");
|
|
3788
4063
|
var import_node_path15 = require("path");
|
|
3789
4064
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3790
4065
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
@@ -3938,7 +4213,7 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3938
4213
|
const apps = (0, import_node_path15.join)(workspaceRoot, "apps");
|
|
3939
4214
|
let entries;
|
|
3940
4215
|
try {
|
|
3941
|
-
entries = (0,
|
|
4216
|
+
entries = (0, import_node_fs16.readdirSync)(apps);
|
|
3942
4217
|
} catch {
|
|
3943
4218
|
return false;
|
|
3944
4219
|
}
|
|
@@ -3947,7 +4222,7 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3947
4222
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3948
4223
|
});
|
|
3949
4224
|
const path = (0, import_node_path15.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3950
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
4225
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs16.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
3951
4226
|
return false;
|
|
3952
4227
|
}
|
|
3953
4228
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3955,7 +4230,7 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3955
4230
|
}
|
|
3956
4231
|
|
|
3957
4232
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3958
|
-
var
|
|
4233
|
+
var import_node_fs17 = require("fs");
|
|
3959
4234
|
var import_node_path16 = require("path");
|
|
3960
4235
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3961
4236
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
@@ -4035,7 +4310,7 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
4035
4310
|
`;
|
|
4036
4311
|
function assertWebApp(workspaceRoot, web) {
|
|
4037
4312
|
const directory = (0, import_node_path16.join)(workspaceRoot, "apps", web);
|
|
4038
|
-
const isReactApp = fileExists((0, import_node_path16.join)(directory, "package.json")) && (0,
|
|
4313
|
+
const isReactApp = fileExists((0, import_node_path16.join)(directory, "package.json")) && (0, import_node_fs17.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
4039
4314
|
if (!isReactApp) {
|
|
4040
4315
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
4041
4316
|
}
|
|
@@ -4045,7 +4320,7 @@ function webProjectName(workspaceRoot, web) {
|
|
|
4045
4320
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
4046
4321
|
}
|
|
4047
4322
|
function addApiProxy(viteConfigPath) {
|
|
4048
|
-
const source = (0,
|
|
4323
|
+
const source = (0, import_node_fs17.readFileSync)(viteConfigPath, "utf8");
|
|
4049
4324
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
4050
4325
|
return false;
|
|
4051
4326
|
}
|
|
@@ -4089,7 +4364,7 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
4089
4364
|
writeFileEnsured((0, import_node_path16.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
4090
4365
|
writeFileEnsured((0, import_node_path16.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
4091
4366
|
writeFileEnsured((0, import_node_path16.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
4092
|
-
const viteConfig = (0,
|
|
4367
|
+
const viteConfig = (0, import_node_fs17.readdirSync)((0, import_node_path16.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
4093
4368
|
if (viteConfig === void 0 || !addApiProxy((0, import_node_path16.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
4094
4369
|
logger.warn(
|
|
4095
4370
|
`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.`
|
|
@@ -4132,7 +4407,7 @@ function ensureGoModule(workspaceRoot) {
|
|
|
4132
4407
|
}
|
|
4133
4408
|
function readGoModModule(goModPath) {
|
|
4134
4409
|
try {
|
|
4135
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
4410
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs18.readFileSync)(goModPath, "utf8"))?.[1];
|
|
4136
4411
|
} catch {
|
|
4137
4412
|
return void 0;
|
|
4138
4413
|
}
|
|
@@ -4151,16 +4426,16 @@ function setGoModulePath(workspaceRoot, projectDir) {
|
|
|
4151
4426
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
4152
4427
|
return;
|
|
4153
4428
|
}
|
|
4154
|
-
const rewritten = (0,
|
|
4429
|
+
const rewritten = (0, import_node_fs18.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
4155
4430
|
writeFileEnsured(goModPath, rewritten);
|
|
4156
4431
|
}
|
|
4157
4432
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
4158
4433
|
const goModPath = (0, import_node_path17.join)(workspaceRoot, projectDir, "go.mod");
|
|
4159
|
-
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0,
|
|
4434
|
+
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs18.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
4160
4435
|
if (modulePath === void 0) {
|
|
4161
4436
|
return;
|
|
4162
4437
|
}
|
|
4163
|
-
(0,
|
|
4438
|
+
(0, import_node_fs18.rmSync)((0, import_node_path17.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
4164
4439
|
const example = goAppExampleFiles(modulePath);
|
|
4165
4440
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4166
4441
|
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, projectDir, relative), contents);
|
|
@@ -4245,12 +4520,12 @@ function addGoPlatformTargets(workspaceRoot) {
|
|
|
4245
4520
|
if (!fileExists(apps)) {
|
|
4246
4521
|
return changed;
|
|
4247
4522
|
}
|
|
4248
|
-
for (const name of (0,
|
|
4523
|
+
for (const name of (0, import_node_fs18.readdirSync)(apps)) {
|
|
4249
4524
|
const projectJsonPath = (0, import_node_path17.join)(apps, name, "project.json");
|
|
4250
4525
|
if (!fileExists(projectJsonPath)) {
|
|
4251
4526
|
continue;
|
|
4252
4527
|
}
|
|
4253
|
-
const project = JSON.parse((0,
|
|
4528
|
+
const project = JSON.parse((0, import_node_fs18.readFileSync)(projectJsonPath, "utf8"));
|
|
4254
4529
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
4255
4530
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
4256
4531
|
continue;
|
|
@@ -4286,8 +4561,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
4286
4561
|
}
|
|
4287
4562
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
4288
4563
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
4289
|
-
(0,
|
|
4290
|
-
(0,
|
|
4564
|
+
(0, import_node_fs18.rmSync)((0, import_node_path17.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
4565
|
+
(0, import_node_fs18.rmSync)((0, import_node_path17.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
4291
4566
|
const files = [
|
|
4292
4567
|
[
|
|
4293
4568
|
"doc.go",
|
|
@@ -4775,7 +5050,7 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
|
4775
5050
|
var import_node_path22 = require("path");
|
|
4776
5051
|
|
|
4777
5052
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
4778
|
-
var
|
|
5053
|
+
var import_node_fs19 = require("fs");
|
|
4779
5054
|
var import_node_path19 = require("path");
|
|
4780
5055
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
4781
5056
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
@@ -4799,14 +5074,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
4799
5074
|
}
|
|
4800
5075
|
function repairPublishableManifests(workspaceRoot) {
|
|
4801
5076
|
const changed = [];
|
|
4802
|
-
const manifests = (0,
|
|
5077
|
+
const manifests = (0, import_node_fs19.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
4803
5078
|
cwd: workspaceRoot
|
|
4804
5079
|
});
|
|
4805
5080
|
for (const relativePath of manifests) {
|
|
4806
5081
|
const manifestPath = (0, import_node_path19.join)(workspaceRoot, relativePath);
|
|
4807
|
-
const before = (0,
|
|
5082
|
+
const before = (0, import_node_fs19.readFileSync)(manifestPath, "utf8");
|
|
4808
5083
|
repairPublishableManifest(manifestPath);
|
|
4809
|
-
const after = (0,
|
|
5084
|
+
const after = (0, import_node_fs19.readFileSync)(manifestPath, "utf8");
|
|
4810
5085
|
if (after !== before) {
|
|
4811
5086
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
4812
5087
|
}
|
|
@@ -4815,7 +5090,7 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
4815
5090
|
}
|
|
4816
5091
|
|
|
4817
5092
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4818
|
-
var
|
|
5093
|
+
var import_node_fs20 = require("fs");
|
|
4819
5094
|
var import_node_path20 = require("path");
|
|
4820
5095
|
|
|
4821
5096
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
@@ -5018,12 +5293,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
5018
5293
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5019
5294
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
5020
5295
|
const changed = [];
|
|
5021
|
-
const configs = (0,
|
|
5296
|
+
const configs = (0, import_node_fs20.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5022
5297
|
cwd: workspaceRoot
|
|
5023
5298
|
});
|
|
5024
5299
|
for (const relativePath of configs) {
|
|
5025
5300
|
const configPath = (0, import_node_path20.join)(workspaceRoot, relativePath);
|
|
5026
|
-
const before = (0,
|
|
5301
|
+
const before = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
5027
5302
|
const after = withRollupSourceMaps(before);
|
|
5028
5303
|
if (after !== before) {
|
|
5029
5304
|
writeFileEnsured(configPath, after);
|
|
@@ -5034,12 +5309,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
5034
5309
|
}
|
|
5035
5310
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5036
5311
|
const changed = [];
|
|
5037
|
-
const configs = (0,
|
|
5312
|
+
const configs = (0, import_node_fs20.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5038
5313
|
cwd: workspaceRoot
|
|
5039
5314
|
});
|
|
5040
5315
|
for (const relativePath of configs) {
|
|
5041
5316
|
const configPath = (0, import_node_path20.join)(workspaceRoot, relativePath);
|
|
5042
|
-
const before = (0,
|
|
5317
|
+
const before = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
5043
5318
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
5044
5319
|
if (after !== before) {
|
|
5045
5320
|
writeFileEnsured(configPath, after);
|
|
@@ -5053,7 +5328,7 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
5053
5328
|
if (!fileExists(configPath)) {
|
|
5054
5329
|
return;
|
|
5055
5330
|
}
|
|
5056
|
-
const config = (0,
|
|
5331
|
+
const config = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
5057
5332
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
5058
5333
|
return;
|
|
5059
5334
|
}
|
|
@@ -5062,7 +5337,7 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
5062
5337
|
}
|
|
5063
5338
|
|
|
5064
5339
|
// src/rollup-library/rollup-config.repository.ts
|
|
5065
|
-
var
|
|
5340
|
+
var import_node_fs21 = require("fs");
|
|
5066
5341
|
var import_node_path21 = require("path");
|
|
5067
5342
|
function resolveRequireTarget(fromDir, specifier) {
|
|
5068
5343
|
const base = (0, import_node_path21.join)(fromDir, specifier);
|
|
@@ -5075,7 +5350,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
5075
5350
|
visited.add(configPath);
|
|
5076
5351
|
let text;
|
|
5077
5352
|
try {
|
|
5078
|
-
text = (0,
|
|
5353
|
+
text = (0, import_node_fs21.readFileSync)(configPath, "utf8");
|
|
5079
5354
|
} catch {
|
|
5080
5355
|
return "";
|
|
5081
5356
|
}
|
|
@@ -5120,7 +5395,7 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5120
5395
|
}
|
|
5121
5396
|
|
|
5122
5397
|
// src/project-scaffolding/python.use-case.ts
|
|
5123
|
-
var
|
|
5398
|
+
var import_node_fs22 = require("fs");
|
|
5124
5399
|
var import_node_path23 = require("path");
|
|
5125
5400
|
function ensurePython(workspaceRoot) {
|
|
5126
5401
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
@@ -5339,7 +5614,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5339
5614
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5340
5615
|
}
|
|
5341
5616
|
const pyprojectPath = (0, import_node_path23.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
5342
|
-
const pyprojectToml = (0,
|
|
5617
|
+
const pyprojectToml = (0, import_node_fs22.readFileSync)(pyprojectPath, "utf8");
|
|
5343
5618
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5344
5619
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5345
5620
|
return;
|
|
@@ -5351,7 +5626,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5351
5626
|
}
|
|
5352
5627
|
|
|
5353
5628
|
// src/project-scaffolding/react-app.use-case.ts
|
|
5354
|
-
var
|
|
5629
|
+
var import_node_fs23 = require("fs");
|
|
5355
5630
|
var import_node_path24 = require("path");
|
|
5356
5631
|
|
|
5357
5632
|
// src/project-scaffolding/react-app-example.algorithm.ts
|
|
@@ -5474,7 +5749,7 @@ function allowEnvFiles(workspaceRoot) {
|
|
|
5474
5749
|
return;
|
|
5475
5750
|
}
|
|
5476
5751
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
5477
|
-
const current = (0,
|
|
5752
|
+
const current = (0, import_node_fs23.readFileSync)(gitignorePath, "utf8");
|
|
5478
5753
|
if (current.includes(marker)) {
|
|
5479
5754
|
return;
|
|
5480
5755
|
}
|
|
@@ -5508,7 +5783,7 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
5508
5783
|
allowEnvFiles(workspaceRoot);
|
|
5509
5784
|
addNxTargets((0, import_node_path24.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
5510
5785
|
reshapeReactAppScaffold(reactAppRoot);
|
|
5511
|
-
(0,
|
|
5786
|
+
(0, import_node_fs23.rmSync)((0, import_node_path24.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
5512
5787
|
const example = reactAppExampleFiles(name);
|
|
5513
5788
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5514
5789
|
writeFileEnsured((0, import_node_path24.join)(reactAppRoot, "src", relative), contents);
|
|
@@ -5582,7 +5857,7 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
5582
5857
|
}
|
|
5583
5858
|
|
|
5584
5859
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
5585
|
-
var
|
|
5860
|
+
var import_node_fs24 = require("fs");
|
|
5586
5861
|
var import_node_path26 = require("path");
|
|
5587
5862
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
5588
5863
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
@@ -5769,7 +6044,7 @@ var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
|
5769
6044
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
5770
6045
|
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}\` },`];
|
|
5771
6046
|
const path = (0, import_node_path26.join)(projectRoot, file);
|
|
5772
|
-
const content = fileExists(path) ? (0,
|
|
6047
|
+
const content = fileExists(path) ? (0, import_node_fs24.readFileSync)(path, "utf8") : "";
|
|
5773
6048
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
5774
6049
|
if (line === void 0) {
|
|
5775
6050
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -5857,7 +6132,7 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
5857
6132
|
};
|
|
5858
6133
|
}
|
|
5859
6134
|
function addDebugLaunch(workspaceRoot, name) {
|
|
5860
|
-
const file = (0,
|
|
6135
|
+
const file = (0, import_node_fs24.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
5861
6136
|
if (file === void 0) {
|
|
5862
6137
|
return;
|
|
5863
6138
|
}
|
|
@@ -5897,7 +6172,7 @@ function refreshVscodeExtensionScript(workspaceRoot) {
|
|
|
5897
6172
|
const apps = (0, import_node_path26.join)(workspaceRoot, "apps");
|
|
5898
6173
|
let entries;
|
|
5899
6174
|
try {
|
|
5900
|
-
entries = (0,
|
|
6175
|
+
entries = (0, import_node_fs24.readdirSync)(apps);
|
|
5901
6176
|
} catch {
|
|
5902
6177
|
return false;
|
|
5903
6178
|
}
|
|
@@ -5910,7 +6185,7 @@ function refreshVscodeExtensionScript(workspaceRoot) {
|
|
|
5910
6185
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
5911
6186
|
});
|
|
5912
6187
|
const path = (0, import_node_path26.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
5913
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
6188
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs24.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
5914
6189
|
return false;
|
|
5915
6190
|
}
|
|
5916
6191
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
@@ -5920,7 +6195,7 @@ function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
|
5920
6195
|
const apps = (0, import_node_path26.join)(workspaceRoot, "apps");
|
|
5921
6196
|
let entries;
|
|
5922
6197
|
try {
|
|
5923
|
-
entries = (0,
|
|
6198
|
+
entries = (0, import_node_fs24.readdirSync)(apps);
|
|
5924
6199
|
} catch {
|
|
5925
6200
|
return [];
|
|
5926
6201
|
}
|
|
@@ -5972,11 +6247,11 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5972
6247
|
}
|
|
5973
6248
|
|
|
5974
6249
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5975
|
-
var
|
|
6250
|
+
var import_node_fs26 = require("fs");
|
|
5976
6251
|
var import_node_path28 = require("path");
|
|
5977
6252
|
|
|
5978
6253
|
// src/dependency-management/manifest.repository.ts
|
|
5979
|
-
var
|
|
6254
|
+
var import_node_fs25 = require("fs");
|
|
5980
6255
|
var import_node_path27 = require("path");
|
|
5981
6256
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5982
6257
|
var ROOT_LABEL = "(root)";
|
|
@@ -6013,18 +6288,18 @@ function hasEcosystem(workspaceRoot, ecosystem) {
|
|
|
6013
6288
|
return fileExists((0, import_node_path27.join)(workspaceRoot, "go.mod"));
|
|
6014
6289
|
}
|
|
6015
6290
|
if (ecosystem === "nuget") {
|
|
6016
|
-
return (0,
|
|
6291
|
+
return (0, import_node_fs25.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
6017
6292
|
}
|
|
6018
6293
|
const rootMarker = {
|
|
6019
6294
|
npm: "package.json",
|
|
6020
6295
|
pip: "requirements-dev.txt",
|
|
6021
6296
|
pub: "pubspec.yaml"
|
|
6022
6297
|
};
|
|
6023
|
-
return fileExists((0, import_node_path27.join)(workspaceRoot, rootMarker[ecosystem])) || (0,
|
|
6298
|
+
return fileExists((0, import_node_path27.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs25.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
6024
6299
|
}
|
|
6025
6300
|
function collectNpm(workspaceRoot) {
|
|
6026
6301
|
const sites = [];
|
|
6027
|
-
const relativePaths = ["package.json", ...(0,
|
|
6302
|
+
const relativePaths = ["package.json", ...(0, import_node_fs25.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
6028
6303
|
for (const relativePath of relativePaths) {
|
|
6029
6304
|
const manifestPath = (0, import_node_path27.join)(workspaceRoot, relativePath);
|
|
6030
6305
|
try {
|
|
@@ -6093,11 +6368,11 @@ function collectPip(workspaceRoot) {
|
|
|
6093
6368
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
6094
6369
|
});
|
|
6095
6370
|
};
|
|
6096
|
-
const pyprojectPaths = (0,
|
|
6371
|
+
const pyprojectPaths = (0, import_node_fs25.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
6097
6372
|
for (const relativePath of pyprojectPaths) {
|
|
6098
6373
|
let content;
|
|
6099
6374
|
try {
|
|
6100
|
-
content = (0,
|
|
6375
|
+
content = (0, import_node_fs25.readFileSync)((0, import_node_path27.join)(workspaceRoot, relativePath), "utf8");
|
|
6101
6376
|
} catch {
|
|
6102
6377
|
continue;
|
|
6103
6378
|
}
|
|
@@ -6108,14 +6383,14 @@ function collectPip(workspaceRoot) {
|
|
|
6108
6383
|
}
|
|
6109
6384
|
const requirementsPaths = [
|
|
6110
6385
|
"requirements-dev.txt",
|
|
6111
|
-
...(0,
|
|
6386
|
+
...(0, import_node_fs25.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
6112
6387
|
];
|
|
6113
6388
|
for (const relativePath of requirementsPaths) {
|
|
6114
6389
|
if (!fileExists((0, import_node_path27.join)(workspaceRoot, relativePath))) {
|
|
6115
6390
|
continue;
|
|
6116
6391
|
}
|
|
6117
6392
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
6118
|
-
const lines = (0,
|
|
6393
|
+
const lines = (0, import_node_fs25.readFileSync)((0, import_node_path27.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
6119
6394
|
for (const line of lines) {
|
|
6120
6395
|
push(relativePath, section, line);
|
|
6121
6396
|
}
|
|
@@ -6153,11 +6428,11 @@ function pyprojectDependencies(content) {
|
|
|
6153
6428
|
}
|
|
6154
6429
|
function collectPub(workspaceRoot) {
|
|
6155
6430
|
const sites = [];
|
|
6156
|
-
const pubspecPaths = (0,
|
|
6431
|
+
const pubspecPaths = (0, import_node_fs25.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
6157
6432
|
for (const relativePath of pubspecPaths) {
|
|
6158
6433
|
let content;
|
|
6159
6434
|
try {
|
|
6160
|
-
content = (0,
|
|
6435
|
+
content = (0, import_node_fs25.readFileSync)((0, import_node_path27.join)(workspaceRoot, relativePath), "utf8");
|
|
6161
6436
|
} catch {
|
|
6162
6437
|
continue;
|
|
6163
6438
|
}
|
|
@@ -6217,11 +6492,11 @@ function stripQuotes(value) {
|
|
|
6217
6492
|
}
|
|
6218
6493
|
function collectNuget(workspaceRoot) {
|
|
6219
6494
|
const sites = [];
|
|
6220
|
-
const csprojPaths = (0,
|
|
6495
|
+
const csprojPaths = (0, import_node_fs25.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
6221
6496
|
for (const relativePath of csprojPaths) {
|
|
6222
6497
|
let content;
|
|
6223
6498
|
try {
|
|
6224
|
-
content = (0,
|
|
6499
|
+
content = (0, import_node_fs25.readFileSync)((0, import_node_path27.join)(workspaceRoot, relativePath), "utf8");
|
|
6225
6500
|
} catch {
|
|
6226
6501
|
continue;
|
|
6227
6502
|
}
|
|
@@ -6261,7 +6536,7 @@ function collectGo(workspaceRoot) {
|
|
|
6261
6536
|
}
|
|
6262
6537
|
let content;
|
|
6263
6538
|
try {
|
|
6264
|
-
content = (0,
|
|
6539
|
+
content = (0, import_node_fs25.readFileSync)(manifestPath, "utf8");
|
|
6265
6540
|
} catch {
|
|
6266
6541
|
return [];
|
|
6267
6542
|
}
|
|
@@ -6310,7 +6585,7 @@ var PROJECT_GLOBS = {
|
|
|
6310
6585
|
function locateProjects(workspaceRoot) {
|
|
6311
6586
|
const locations = [];
|
|
6312
6587
|
for (const ecosystem of ECOSYSTEMS) {
|
|
6313
|
-
const relativePaths = (0,
|
|
6588
|
+
const relativePaths = (0, import_node_fs25.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
6314
6589
|
for (const relativePath of relativePaths) {
|
|
6315
6590
|
const posix = toPosix(relativePath);
|
|
6316
6591
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -6339,7 +6614,7 @@ function rewriteSpec(site, spec) {
|
|
|
6339
6614
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
6340
6615
|
return true;
|
|
6341
6616
|
}
|
|
6342
|
-
const before = (0,
|
|
6617
|
+
const before = (0, import_node_fs25.readFileSync)(site.manifestPath, "utf8");
|
|
6343
6618
|
const after = (() => {
|
|
6344
6619
|
switch (site.ecosystem) {
|
|
6345
6620
|
case "pip": {
|
|
@@ -6462,7 +6737,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6462
6737
|
const match = new RegExp(
|
|
6463
6738
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
6464
6739
|
"m"
|
|
6465
|
-
).exec((0,
|
|
6740
|
+
).exec((0, import_node_fs25.readFileSync)(lockPath, "utf8"));
|
|
6466
6741
|
return match?.[1];
|
|
6467
6742
|
} catch {
|
|
6468
6743
|
return void 0;
|
|
@@ -6581,7 +6856,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
6581
6856
|
function addPythonDependency(manifestPath, specifier) {
|
|
6582
6857
|
let content;
|
|
6583
6858
|
try {
|
|
6584
|
-
content = (0,
|
|
6859
|
+
content = (0, import_node_fs26.readFileSync)(manifestPath, "utf8");
|
|
6585
6860
|
} catch {
|
|
6586
6861
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
6587
6862
|
return;
|
|
@@ -7437,15 +7712,15 @@ function runKinds(options) {
|
|
|
7437
7712
|
|
|
7438
7713
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
7439
7714
|
var import_node_child_process = require("child_process");
|
|
7440
|
-
var
|
|
7715
|
+
var import_node_fs27 = require("fs");
|
|
7441
7716
|
var import_node_path32 = require("path");
|
|
7442
7717
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
7443
7718
|
function toPosix2(path) {
|
|
7444
7719
|
return path.replaceAll("\\", "/");
|
|
7445
7720
|
}
|
|
7446
7721
|
function checkEslintConfigs(workspaceRoot) {
|
|
7447
|
-
const rootConfigs = (0,
|
|
7448
|
-
const projectConfigs = (0,
|
|
7722
|
+
const rootConfigs = (0, import_node_fs27.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
7723
|
+
const projectConfigs = (0, import_node_fs27.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
7449
7724
|
cwd: workspaceRoot
|
|
7450
7725
|
}).map((config) => toPosix2(config));
|
|
7451
7726
|
return [
|
|
@@ -7466,9 +7741,9 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
7466
7741
|
}
|
|
7467
7742
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
7468
7743
|
const rules = (0, import_node_path32.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
7469
|
-
if (!(0,
|
|
7744
|
+
if (!(0, import_node_fs27.existsSync)(rules)) return [];
|
|
7470
7745
|
const entryPoint = (0, import_node_path32.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
7471
|
-
const source = (0,
|
|
7746
|
+
const source = (0, import_node_fs27.existsSync)(entryPoint) ? (0, import_node_fs27.readFileSync)(entryPoint, "utf8") : "";
|
|
7472
7747
|
return [
|
|
7473
7748
|
{
|
|
7474
7749
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -7537,7 +7812,7 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
7537
7812
|
if (!registry || !fileExists(npmrcPath)) {
|
|
7538
7813
|
return void 0;
|
|
7539
7814
|
}
|
|
7540
|
-
const npmrc = (0,
|
|
7815
|
+
const npmrc = (0, import_node_fs27.readFileSync)(npmrcPath, "utf8");
|
|
7541
7816
|
if (registry.kind === "npm") {
|
|
7542
7817
|
return {
|
|
7543
7818
|
check: ".npmrc authenticates the public registry",
|
|
@@ -7558,7 +7833,7 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
7558
7833
|
if (!fileExists(npmrcPath)) {
|
|
7559
7834
|
return void 0;
|
|
7560
7835
|
}
|
|
7561
|
-
const npmrc = (0,
|
|
7836
|
+
const npmrc = (0, import_node_fs27.readFileSync)(npmrcPath, "utf8");
|
|
7562
7837
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7563
7838
|
const referenced = [
|
|
7564
7839
|
...new Set(
|
|
@@ -7587,8 +7862,8 @@ function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
|
7587
7862
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
7588
7863
|
return void 0;
|
|
7589
7864
|
}
|
|
7590
|
-
const holdsCredentials = (0,
|
|
7591
|
-
const runsTask = (0,
|
|
7865
|
+
const holdsCredentials = (0, import_node_fs27.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7866
|
+
const runsTask = (0, import_node_fs27.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
7592
7867
|
if (!holdsCredentials && !runsTask) {
|
|
7593
7868
|
return {
|
|
7594
7869
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -7633,9 +7908,9 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
7633
7908
|
}
|
|
7634
7909
|
function checkVersionActions(workspaceRoot) {
|
|
7635
7910
|
const candidates = [
|
|
7636
|
-
...(0,
|
|
7637
|
-
...(0,
|
|
7638
|
-
...(0,
|
|
7911
|
+
...(0, import_node_fs27.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
7912
|
+
...(0, import_node_fs27.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
7913
|
+
...(0, import_node_fs27.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
7639
7914
|
].map((manifest) => toPosix2(manifest));
|
|
7640
7915
|
return candidates.flatMap((manifest) => {
|
|
7641
7916
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
@@ -7684,8 +7959,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7684
7959
|
function checkTargetFilesExist(workspaceRoot) {
|
|
7685
7960
|
const projectRoots = new Set(
|
|
7686
7961
|
[
|
|
7687
|
-
...(0,
|
|
7688
|
-
...(0,
|
|
7962
|
+
...(0, import_node_fs27.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
7963
|
+
...(0, import_node_fs27.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
7689
7964
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
7690
7965
|
);
|
|
7691
7966
|
return [...projectRoots].flatMap(
|
|
@@ -7743,11 +8018,11 @@ function checkGoWorkInSync(workspaceRoot) {
|
|
|
7743
8018
|
if (!fileExists(goWorkPath)) {
|
|
7744
8019
|
return void 0;
|
|
7745
8020
|
}
|
|
7746
|
-
const contents = (0,
|
|
8021
|
+
const contents = (0, import_node_fs27.existsSync)(goWorkPath) ? (0, import_node_fs27.readFileSync)(goWorkPath, "utf8") : "";
|
|
7747
8022
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
7748
8023
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
7749
8024
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
7750
|
-
const stale = uses.filter((entry) => !(0,
|
|
8025
|
+
const stale = uses.filter((entry) => !(0, import_node_fs27.existsSync)((0, import_node_path32.join)(workspaceRoot, entry, "go.mod")));
|
|
7751
8026
|
return {
|
|
7752
8027
|
check: "every go.work `use` entry points to a module that still exists",
|
|
7753
8028
|
ok: stale.length === 0,
|
|
@@ -7765,7 +8040,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7765
8040
|
];
|
|
7766
8041
|
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path32.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
7767
8042
|
check: `${file} builds the native apps on every OS`,
|
|
7768
|
-
ok: (0,
|
|
8043
|
+
ok: (0, import_node_fs27.readFileSync)((0, import_node_path32.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
7769
8044
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
7770
8045
|
remedy: "run `mnci upgrade`"
|
|
7771
8046
|
}));
|
|
@@ -7798,14 +8073,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
7798
8073
|
};
|
|
7799
8074
|
}
|
|
7800
8075
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
7801
|
-
const configs = (0,
|
|
8076
|
+
const configs = (0, import_node_fs27.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7802
8077
|
cwd: workspaceRoot
|
|
7803
8078
|
}).map((config) => toPosix2(config));
|
|
7804
8079
|
return configs.flatMap((relativePath) => {
|
|
7805
8080
|
const configPath = (0, import_node_path32.join)(workspaceRoot, relativePath);
|
|
7806
8081
|
let config;
|
|
7807
8082
|
try {
|
|
7808
|
-
config = (0,
|
|
8083
|
+
config = (0, import_node_fs27.readFileSync)(configPath, "utf8");
|
|
7809
8084
|
} catch {
|
|
7810
8085
|
return [];
|
|
7811
8086
|
}
|
|
@@ -7820,7 +8095,7 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
7820
8095
|
});
|
|
7821
8096
|
}
|
|
7822
8097
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
7823
|
-
const configs = (0,
|
|
8098
|
+
const configs = (0, import_node_fs27.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7824
8099
|
cwd: workspaceRoot
|
|
7825
8100
|
}).map((config) => toPosix2(config));
|
|
7826
8101
|
return configs.flatMap((relativePath) => {
|
|
@@ -7860,7 +8135,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
7860
8135
|
function checkPipelinePhases(workspaceRoot) {
|
|
7861
8136
|
const files = ["azure-pipelines.yml", ".github/workflows/ci.yml"];
|
|
7862
8137
|
return files.filter((file) => fileExists((0, import_node_path32.join)(workspaceRoot, file))).flatMap((file) => {
|
|
7863
|
-
const { verifyActive, switchedOff } = inspectPipeline((0,
|
|
8138
|
+
const { verifyActive, switchedOff } = inspectPipeline((0, import_node_fs27.readFileSync)((0, import_node_path32.join)(workspaceRoot, file), "utf8"));
|
|
7864
8139
|
const verify = {
|
|
7865
8140
|
check: `${file} runs the enforced verify phase`,
|
|
7866
8141
|
ok: verifyActive,
|
|
@@ -8055,7 +8330,7 @@ function runProjects(workspaceRoot, options) {
|
|
|
8055
8330
|
var import_node_path35 = require("path");
|
|
8056
8331
|
|
|
8057
8332
|
// src/cli-version/check-for-update.use-case.ts
|
|
8058
|
-
var
|
|
8333
|
+
var import_node_fs28 = require("fs");
|
|
8059
8334
|
var import_node_path34 = require("path");
|
|
8060
8335
|
var import_cross_spawn3 = __toESM(require("cross-spawn"));
|
|
8061
8336
|
var PACKAGE_NAME2 = "@mnci/cli";
|
|
@@ -8116,7 +8391,7 @@ function releaseTriple(version) {
|
|
|
8116
8391
|
function readCliVersion(packageDirectory) {
|
|
8117
8392
|
try {
|
|
8118
8393
|
const manifestPath = (0, import_node_path34.join)(packageDirectory, "..", "package.json");
|
|
8119
|
-
const manifest = JSON.parse((0,
|
|
8394
|
+
const manifest = JSON.parse((0, import_node_fs28.readFileSync)(manifestPath, "utf8"));
|
|
8120
8395
|
return manifest.version ?? "0.0.0";
|
|
8121
8396
|
} catch {
|
|
8122
8397
|
return "0.0.0";
|
|
@@ -8147,7 +8422,7 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
8147
8422
|
}
|
|
8148
8423
|
|
|
8149
8424
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
8150
|
-
var
|
|
8425
|
+
var import_node_fs29 = require("fs");
|
|
8151
8426
|
var import_node_path36 = require("path");
|
|
8152
8427
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
8153
8428
|
var AGENT_AND_CI_ENTRIES = [
|
|
@@ -8179,13 +8454,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
8179
8454
|
"packages"
|
|
8180
8455
|
];
|
|
8181
8456
|
function assertAdoptableDirectory(target) {
|
|
8182
|
-
if (!(0,
|
|
8457
|
+
if (!(0, import_node_fs29.existsSync)(target)) {
|
|
8183
8458
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
8184
8459
|
}
|
|
8185
|
-
if (!(0,
|
|
8460
|
+
if (!(0, import_node_fs29.statSync)(target).isDirectory()) {
|
|
8186
8461
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
8187
8462
|
}
|
|
8188
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
8463
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs29.existsSync)((0, import_node_path36.join)(target, entry)));
|
|
8189
8464
|
if (blockers.length > 0) {
|
|
8190
8465
|
throw new Error(
|
|
8191
8466
|
`--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.`
|
|
@@ -8193,15 +8468,15 @@ function assertAdoptableDirectory(target) {
|
|
|
8193
8468
|
}
|
|
8194
8469
|
}
|
|
8195
8470
|
function mergeGitignore(generatedFile, targetFile) {
|
|
8196
|
-
const existing = (0,
|
|
8471
|
+
const existing = (0, import_node_fs29.readFileSync)(targetFile, "utf8");
|
|
8197
8472
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
8198
|
-
const additions = (0,
|
|
8473
|
+
const additions = (0, import_node_fs29.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
8199
8474
|
const trimmed = line.trim();
|
|
8200
8475
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
8201
8476
|
});
|
|
8202
8477
|
if (additions.length === 0) return false;
|
|
8203
8478
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
8204
|
-
(0,
|
|
8479
|
+
(0, import_node_fs29.writeFileSync)(
|
|
8205
8480
|
targetFile,
|
|
8206
8481
|
`${existing}${separator}
|
|
8207
8482
|
# Added by mnci (Nx workspace)
|
|
@@ -8211,9 +8486,9 @@ ${additions.join("\n")}
|
|
|
8211
8486
|
return true;
|
|
8212
8487
|
}
|
|
8213
8488
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
8214
|
-
const entries = (0,
|
|
8489
|
+
const entries = (0, import_node_fs29.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
8215
8490
|
const collisions = entries.filter(
|
|
8216
|
-
(entry) => (0,
|
|
8491
|
+
(entry) => (0, import_node_fs29.existsSync)((0, import_node_path36.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
8217
8492
|
);
|
|
8218
8493
|
if (collisions.length > 0) {
|
|
8219
8494
|
throw new Error(
|
|
@@ -8224,24 +8499,24 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
8224
8499
|
for (const entry of entries) {
|
|
8225
8500
|
const from = (0, import_node_path36.join)(generatedRoot, entry);
|
|
8226
8501
|
const to = (0, import_node_path36.join)(target, entry);
|
|
8227
|
-
if (entry === ".gitignore" && (0,
|
|
8502
|
+
if (entry === ".gitignore" && (0, import_node_fs29.existsSync)(to)) {
|
|
8228
8503
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
8229
8504
|
result.kept.push(entry);
|
|
8230
8505
|
continue;
|
|
8231
8506
|
}
|
|
8232
|
-
if ((0,
|
|
8507
|
+
if ((0, import_node_fs29.existsSync)(to)) {
|
|
8233
8508
|
result.kept.push(entry);
|
|
8234
8509
|
continue;
|
|
8235
8510
|
}
|
|
8236
|
-
(0,
|
|
8511
|
+
(0, import_node_fs29.cpSync)(from, to, { recursive: true });
|
|
8237
8512
|
result.copied.push(entry);
|
|
8238
8513
|
}
|
|
8239
|
-
(0,
|
|
8514
|
+
(0, import_node_fs29.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
8240
8515
|
return result;
|
|
8241
8516
|
}
|
|
8242
8517
|
|
|
8243
8518
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
8244
|
-
var
|
|
8519
|
+
var import_node_fs30 = require("fs");
|
|
8245
8520
|
var import_node_os2 = require("os");
|
|
8246
8521
|
var import_node_path37 = require("path");
|
|
8247
8522
|
function nxCloudProviderValue(ci) {
|
|
@@ -8301,7 +8576,7 @@ async function runNew(name, options) {
|
|
|
8301
8576
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
8302
8577
|
const stack = await resolveStack(options);
|
|
8303
8578
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
8304
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
8579
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs30.mkdtempSync)((0, import_node_path37.join)((0, import_node_os2.tmpdir)(), "mnci-new-"));
|
|
8305
8580
|
let workspaceRoot = (0, import_node_path37.join)(stagingParent, workspaceName);
|
|
8306
8581
|
try {
|
|
8307
8582
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
@@ -8325,7 +8600,7 @@ async function runNew(name, options) {
|
|
|
8325
8600
|
workspaceRoot = adoptTarget;
|
|
8326
8601
|
}
|
|
8327
8602
|
} finally {
|
|
8328
|
-
if (adoptTarget !== void 0) (0,
|
|
8603
|
+
if (adoptTarget !== void 0) (0, import_node_fs30.rmSync)(stagingParent, { recursive: true, force: true });
|
|
8329
8604
|
}
|
|
8330
8605
|
logger.step(
|
|
8331
8606
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -8335,8 +8610,8 @@ async function runNew(name, options) {
|
|
|
8335
8610
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
8336
8611
|
logger.detail
|
|
8337
8612
|
);
|
|
8338
|
-
(0,
|
|
8339
|
-
(0,
|
|
8613
|
+
(0, import_node_fs30.rmSync)((0, import_node_path37.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
8614
|
+
(0, import_node_fs30.rmSync)((0, import_node_path37.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
8340
8615
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
8341
8616
|
const installStatus = runShell(
|
|
8342
8617
|
"npm",
|
|
@@ -8378,7 +8653,7 @@ var import_node_path39 = require("path");
|
|
|
8378
8653
|
var import_prompts4 = require("@inquirer/prompts");
|
|
8379
8654
|
|
|
8380
8655
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
8381
|
-
var
|
|
8656
|
+
var import_node_fs31 = require("fs");
|
|
8382
8657
|
var import_node_path38 = require("path");
|
|
8383
8658
|
function resolveRegistry2(options, persisted) {
|
|
8384
8659
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
@@ -8408,7 +8683,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8408
8683
|
return persisted.workspaceName;
|
|
8409
8684
|
}
|
|
8410
8685
|
try {
|
|
8411
|
-
const existing = (0,
|
|
8686
|
+
const existing = (0, import_node_fs31.readdirSync)(workspaceRoot).find(
|
|
8412
8687
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
8413
8688
|
);
|
|
8414
8689
|
if (existing) {
|
|
@@ -8420,7 +8695,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8420
8695
|
}
|
|
8421
8696
|
function detectNpmAuth(workspaceRoot) {
|
|
8422
8697
|
try {
|
|
8423
|
-
return (0,
|
|
8698
|
+
return (0, import_node_fs31.readFileSync)((0, import_node_path38.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
8424
8699
|
} catch {
|
|
8425
8700
|
return void 0;
|
|
8426
8701
|
}
|