@mnci/cli 4.54.1 → 4.54.2
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 +651 -599
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2901,8 +2901,8 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2901
2901
|
}
|
|
2902
2902
|
|
|
2903
2903
|
// src/ci-pipeline/setup.use-case.ts
|
|
2904
|
-
var
|
|
2905
|
-
var
|
|
2904
|
+
var import_node_fs14 = require("fs");
|
|
2905
|
+
var import_node_path12 = require("path");
|
|
2906
2906
|
|
|
2907
2907
|
// src/ci-pipeline/flutter-sdk.use-case.ts
|
|
2908
2908
|
var import_node_fs10 = require("fs");
|
|
@@ -2948,23 +2948,151 @@ function resolveDartDependencies(workspaceRoot, processes, log) {
|
|
|
2948
2948
|
|
|
2949
2949
|
// src/ci-pipeline/go-tools.use-case.ts
|
|
2950
2950
|
var import_node_crypto = require("crypto");
|
|
2951
|
-
var
|
|
2951
|
+
var import_node_fs13 = require("fs");
|
|
2952
2952
|
var import_node_os = require("os");
|
|
2953
|
+
var import_node_path11 = require("path");
|
|
2954
|
+
|
|
2955
|
+
// src/go-workspace/go-plugin.use-case.ts
|
|
2956
|
+
var import_node_fs11 = require("fs");
|
|
2953
2957
|
var import_node_path9 = require("path");
|
|
2958
|
+
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
2959
|
+
function hasGoProject(workspaceRoot) {
|
|
2960
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs11.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
2961
|
+
return projectFiles.some((projectFile) => {
|
|
2962
|
+
try {
|
|
2963
|
+
const { tags } = JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(workspaceRoot, projectFile), "utf8"));
|
|
2964
|
+
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
2965
|
+
} catch {
|
|
2966
|
+
return false;
|
|
2967
|
+
}
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
function isNxGoPluginRegistered(workspaceRoot) {
|
|
2971
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
2972
|
+
if (!fileExists(nxJsonPath)) {
|
|
2973
|
+
return false;
|
|
2974
|
+
}
|
|
2975
|
+
return (readJson(nxJsonPath).plugins ?? []).some((entry) => (typeof entry === "string" ? entry : entry.plugin) === NX_GO_PLUGIN);
|
|
2976
|
+
}
|
|
2977
|
+
function modulePrefixFromRemoteUrl(url) {
|
|
2978
|
+
const trimmed = url.trim();
|
|
2979
|
+
const scpLike = /^[^@/]+@([^:]+):(.+)$/.exec(trimmed);
|
|
2980
|
+
const withScheme = /^[a-z][\w+.-]*:\/\/(?:[^@/]+@)?(.+)$/i.exec(trimmed);
|
|
2981
|
+
let path;
|
|
2982
|
+
if (scpLike) {
|
|
2983
|
+
path = `${scpLike[1]}/${scpLike[2]}`;
|
|
2984
|
+
} else if (withScheme) {
|
|
2985
|
+
path = withScheme[1];
|
|
2986
|
+
}
|
|
2987
|
+
if (path === void 0) {
|
|
2988
|
+
return void 0;
|
|
2989
|
+
}
|
|
2990
|
+
const cleaned = path.replace(/\.git$/, "").replace(/\/+$/, "");
|
|
2991
|
+
return cleaned === "" ? void 0 : cleaned;
|
|
2992
|
+
}
|
|
2993
|
+
function goModulePrefix(workspaceRoot) {
|
|
2994
|
+
const result = runCapture("git", ["remote", "get-url", "origin"], workspaceRoot);
|
|
2995
|
+
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
2996
|
+
}
|
|
2997
|
+
function rootModulePath(workspaceRoot) {
|
|
2998
|
+
try {
|
|
2999
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(workspaceRoot, "go.mod"), "utf8"))?.[1];
|
|
3000
|
+
} catch {
|
|
3001
|
+
return void 0;
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
function registerNxGoPlugin(workspaceRoot) {
|
|
3005
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
3006
|
+
if (!fileExists(nxJsonPath)) {
|
|
3007
|
+
return false;
|
|
3008
|
+
}
|
|
3009
|
+
const modulePrefix = rootModulePath(workspaceRoot) === void 0 ? goModulePrefix(workspaceRoot) : void 0;
|
|
3010
|
+
const entry = modulePrefix === void 0 ? NX_GO_PLUGIN : { plugin: NX_GO_PLUGIN, options: { modulePrefix } };
|
|
3011
|
+
const nxJson = readJson(nxJsonPath);
|
|
3012
|
+
const plugins = [...nxJson.plugins ?? []];
|
|
3013
|
+
const index = plugins.findIndex((plugin) => (typeof plugin === "string" ? plugin : plugin.plugin) === NX_GO_PLUGIN);
|
|
3014
|
+
if (index === -1) {
|
|
3015
|
+
plugins.push(entry);
|
|
3016
|
+
} else {
|
|
3017
|
+
const current = plugins[index];
|
|
3018
|
+
const currentPrefix = typeof current === "string" ? void 0 : current.options?.modulePrefix;
|
|
3019
|
+
if (modulePrefix === void 0 || currentPrefix === modulePrefix) {
|
|
3020
|
+
return false;
|
|
3021
|
+
}
|
|
3022
|
+
plugins[index] = entry;
|
|
3023
|
+
}
|
|
3024
|
+
writeFileEnsured(nxJsonPath, toJson({ ...nxJson, plugins }));
|
|
3025
|
+
return true;
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
// src/go-workspace/go-work-uses.algorithm.ts
|
|
3029
|
+
function parseGoWorkUses(goWork) {
|
|
3030
|
+
const uses = [];
|
|
3031
|
+
let inBlock = false;
|
|
3032
|
+
for (const raw of goWork.split("\n")) {
|
|
3033
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
3034
|
+
if (line === "") {
|
|
3035
|
+
continue;
|
|
3036
|
+
}
|
|
3037
|
+
if (inBlock) {
|
|
3038
|
+
if (line.startsWith(")")) {
|
|
3039
|
+
inBlock = false;
|
|
3040
|
+
} else {
|
|
3041
|
+
uses.push(unquote(line));
|
|
3042
|
+
}
|
|
3043
|
+
} else if (/^use\s*\(/.test(line)) {
|
|
3044
|
+
inBlock = true;
|
|
3045
|
+
const rest = line.replace(/^use\s*\(/, "").trim();
|
|
3046
|
+
if (rest !== "" && !rest.startsWith(")")) {
|
|
3047
|
+
uses.push(unquote(rest));
|
|
3048
|
+
}
|
|
3049
|
+
} else if (/^use\s+\S/.test(line)) {
|
|
3050
|
+
uses.push(unquote(line.replace(/^use\s+/, "")));
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
return [...new Set(uses)];
|
|
3054
|
+
}
|
|
3055
|
+
function unquote(path) {
|
|
3056
|
+
return path.replaceAll(/^["'`]|["'`]$/g, "");
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
// src/go-workspace/list-go-modules.use-case.ts
|
|
3060
|
+
var import_node_fs12 = require("fs");
|
|
3061
|
+
var import_node_path10 = require("path");
|
|
3062
|
+
function listGoModuleDirectories(workspaceRoot) {
|
|
3063
|
+
const goWork = (0, import_node_path10.join)(workspaceRoot, "go.work");
|
|
3064
|
+
if (fileExists(goWork)) {
|
|
3065
|
+
try {
|
|
3066
|
+
return parseGoWorkUses((0, import_node_fs12.readFileSync)(goWork, "utf8"));
|
|
3067
|
+
} catch {
|
|
3068
|
+
return [];
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
return fileExists((0, import_node_path10.join)(workspaceRoot, "go.mod")) ? ["."] : void 0;
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
// src/ci-pipeline/go-tools.use-case.ts
|
|
2954
3075
|
function currentMachine() {
|
|
2955
3076
|
return { platform: process.platform, architecture: process.arch, home: (0, import_node_os.homedir)() };
|
|
2956
3077
|
}
|
|
2957
3078
|
var GOLANGCI_LINT_MODULE = "github.com/golangci/golangci-lint/v2/cmd/golangci-lint";
|
|
2958
3079
|
function downloadGoModules(workspaceRoot, processes, log) {
|
|
2959
|
-
|
|
3080
|
+
const modules = listGoModuleDirectories(workspaceRoot);
|
|
3081
|
+
if (modules === void 0) {
|
|
2960
3082
|
log("No Go projects - skipping.");
|
|
2961
3083
|
return 0;
|
|
2962
3084
|
}
|
|
2963
|
-
|
|
3085
|
+
for (const directory of modules) {
|
|
3086
|
+
const status = processes.run("go", directory === "." ? ["mod", "download"] : ["-C", directory, "mod", "download"]);
|
|
3087
|
+
if (status !== 0) {
|
|
3088
|
+
return status;
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
return 0;
|
|
2964
3092
|
}
|
|
2965
3093
|
async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
2966
3094
|
const { processes, log, fetchBytes } = dependencies;
|
|
2967
|
-
if (
|
|
3095
|
+
if (listGoModuleDirectories(workspaceRoot) === void 0) {
|
|
2968
3096
|
log("No Go projects - skipping.");
|
|
2969
3097
|
return 0;
|
|
2970
3098
|
}
|
|
@@ -3001,30 +3129,30 @@ async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
|
3001
3129
|
if ((0, import_node_crypto.createHash)("sha256").update(archive).digest("hex") !== entry[0]) {
|
|
3002
3130
|
throw new Error(`checksum mismatch for ${file}`);
|
|
3003
3131
|
}
|
|
3004
|
-
temporary = (0,
|
|
3005
|
-
const archivePath = (0,
|
|
3006
|
-
(0,
|
|
3007
|
-
const tar = platform === "windows" ? (0,
|
|
3132
|
+
temporary = (0, import_node_fs13.mkdtempSync)((0, import_node_path11.join)((0, import_node_os.tmpdir)(), "golangci-lint-"));
|
|
3133
|
+
const archivePath = (0, import_node_path11.join)(temporary, file);
|
|
3134
|
+
(0, import_node_fs13.writeFileSync)(archivePath, archive);
|
|
3135
|
+
const tar = platform === "windows" ? (0, import_node_path11.join)(process.env.SystemRoot ?? "", "System32", "tar.exe") : "tar";
|
|
3008
3136
|
if (processes.run(tar, ["-xf", archivePath, "-C", temporary]) !== 0) {
|
|
3009
3137
|
throw new Error(`could not extract ${file}`);
|
|
3010
3138
|
}
|
|
3011
3139
|
const executable = `golangci-lint${platform === "windows" ? ".exe" : ""}`;
|
|
3012
|
-
const bin = (0,
|
|
3013
|
-
(0,
|
|
3014
|
-
(0,
|
|
3015
|
-
(0,
|
|
3140
|
+
const bin = (0, import_node_path11.join)(gopath.stdout.trim(), "bin");
|
|
3141
|
+
(0, import_node_fs13.mkdirSync)(bin, { recursive: true });
|
|
3142
|
+
(0, import_node_fs13.copyFileSync)((0, import_node_path11.join)(temporary, name, executable), (0, import_node_path11.join)(bin, executable));
|
|
3143
|
+
(0, import_node_fs13.chmodSync)((0, import_node_path11.join)(bin, executable), 493);
|
|
3016
3144
|
log(`golangci-lint ${version} installed from its checksum-verified prebuilt release into ${bin}`);
|
|
3017
3145
|
return 0;
|
|
3018
3146
|
} catch (error) {
|
|
3019
3147
|
return fallback(error instanceof Error ? error.message : String(error));
|
|
3020
3148
|
} finally {
|
|
3021
3149
|
if (temporary !== void 0) {
|
|
3022
|
-
(0,
|
|
3150
|
+
(0, import_node_fs13.rmSync)(temporary, { recursive: true, force: true });
|
|
3023
3151
|
}
|
|
3024
3152
|
}
|
|
3025
3153
|
}
|
|
3026
3154
|
function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
3027
|
-
if (
|
|
3155
|
+
if (listGoModuleDirectories(workspaceRoot) === void 0) {
|
|
3028
3156
|
log("No Go projects - skipping.");
|
|
3029
3157
|
return;
|
|
3030
3158
|
}
|
|
@@ -3033,7 +3161,7 @@ function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
|
3033
3161
|
log("Could not resolve GOPATH - skipping.");
|
|
3034
3162
|
return;
|
|
3035
3163
|
}
|
|
3036
|
-
addToPath(host, environment, (0,
|
|
3164
|
+
addToPath(host, environment, (0, import_node_path11.join)(gopath.stdout.trim(), "bin"), log);
|
|
3037
3165
|
}
|
|
3038
3166
|
|
|
3039
3167
|
// src/ci-pipeline/setup.use-case.ts
|
|
@@ -3041,15 +3169,15 @@ function pythonCommand(machine) {
|
|
|
3041
3169
|
return machine.platform === "win32" ? "python" : "python3";
|
|
3042
3170
|
}
|
|
3043
3171
|
function installPythonToolchain(workspaceRoot, processes, log, machine) {
|
|
3044
|
-
if (!(0,
|
|
3172
|
+
if (!(0, import_node_fs14.existsSync)((0, import_node_path12.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
3045
3173
|
log("No Python projects - skipping.");
|
|
3046
3174
|
return 0;
|
|
3047
3175
|
}
|
|
3048
3176
|
return processes.run(pythonCommand(machine), ["-m", "pip", "install", "-r", "requirements-dev.txt"]);
|
|
3049
3177
|
}
|
|
3050
3178
|
function installPythonProjects(workspaceRoot, processes, log, machine) {
|
|
3051
|
-
const editable = ["apps/*/pyproject.toml", "python-packages/*/pyproject.toml", "libs/*/pyproject.toml"].flatMap((pattern) => (0,
|
|
3052
|
-
const requirements = (0,
|
|
3179
|
+
const editable = ["apps/*/pyproject.toml", "python-packages/*/pyproject.toml", "libs/*/pyproject.toml"].flatMap((pattern) => (0, import_node_fs14.globSync)(pattern, { cwd: workspaceRoot })).map((path) => (0, import_node_path12.dirname)(path));
|
|
3180
|
+
const requirements = (0, import_node_fs14.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot });
|
|
3053
3181
|
if (editable.length === 0 && requirements.length === 0) {
|
|
3054
3182
|
log("No Python projects - skipping.");
|
|
3055
3183
|
return 0;
|
|
@@ -3194,7 +3322,7 @@ function runPhase(phase, workspaceRoot, dependencies) {
|
|
|
3194
3322
|
}
|
|
3195
3323
|
|
|
3196
3324
|
// src/project-scaffolding/add-project.use-case.ts
|
|
3197
|
-
var
|
|
3325
|
+
var import_node_path38 = require("path");
|
|
3198
3326
|
var import_prompts3 = require("@inquirer/prompts");
|
|
3199
3327
|
|
|
3200
3328
|
// src/project-name/project-name.validator.ts
|
|
@@ -3207,8 +3335,8 @@ function assertValidProjectName(name, label) {
|
|
|
3207
3335
|
}
|
|
3208
3336
|
|
|
3209
3337
|
// src/project-scaffolding/csharp.use-case.ts
|
|
3210
|
-
var
|
|
3211
|
-
var
|
|
3338
|
+
var import_node_fs16 = require("fs");
|
|
3339
|
+
var import_node_path14 = require("path");
|
|
3212
3340
|
|
|
3213
3341
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
3214
3342
|
function csharpExampleFiles(identity) {
|
|
@@ -3249,10 +3377,10 @@ public class GreetUseCaseTests
|
|
|
3249
3377
|
}
|
|
3250
3378
|
|
|
3251
3379
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
3252
|
-
var
|
|
3253
|
-
var
|
|
3380
|
+
var import_node_fs15 = require("fs");
|
|
3381
|
+
var import_node_path13 = require("path");
|
|
3254
3382
|
function hasPlugin(workspaceRoot, packageName) {
|
|
3255
|
-
const manifest = readJson((0,
|
|
3383
|
+
const manifest = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3256
3384
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
3257
3385
|
return Object.hasOwn(installed, packageName);
|
|
3258
3386
|
}
|
|
@@ -3291,7 +3419,7 @@ function markPublic(manifestPath) {
|
|
|
3291
3419
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
3292
3420
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
3293
3421
|
writeFileEnsured(
|
|
3294
|
-
(0,
|
|
3422
|
+
(0, import_node_path13.join)(projectRoot, "README.md"),
|
|
3295
3423
|
[
|
|
3296
3424
|
`# ${projectName}`,
|
|
3297
3425
|
"",
|
|
@@ -3310,13 +3438,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
3310
3438
|
}
|
|
3311
3439
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
3312
3440
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
3313
|
-
const directory = (0,
|
|
3441
|
+
const directory = (0, import_node_path13.join)(workspaceRoot, scaffold);
|
|
3314
3442
|
try {
|
|
3315
|
-
const holdsAProject = (0,
|
|
3443
|
+
const holdsAProject = (0, import_node_fs15.readdirSync)(directory, { withFileTypes: true }).some(
|
|
3316
3444
|
(entry) => entry.isDirectory()
|
|
3317
3445
|
);
|
|
3318
3446
|
if (holdsAProject) {
|
|
3319
|
-
(0,
|
|
3447
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(directory, ".gitkeep"), { force: true });
|
|
3320
3448
|
}
|
|
3321
3449
|
} catch {
|
|
3322
3450
|
}
|
|
@@ -3336,7 +3464,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
3336
3464
|
}
|
|
3337
3465
|
}
|
|
3338
3466
|
function defaultScope(workspaceRoot) {
|
|
3339
|
-
const { name } = readJson((0,
|
|
3467
|
+
const { name } = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3340
3468
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
3341
3469
|
return `@${base}`;
|
|
3342
3470
|
}
|
|
@@ -3364,14 +3492,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
3364
3492
|
];
|
|
3365
3493
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
3366
3494
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
3367
|
-
(0,
|
|
3495
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
3368
3496
|
}
|
|
3369
|
-
(0,
|
|
3497
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
3370
3498
|
}
|
|
3371
3499
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
3372
3500
|
try {
|
|
3373
|
-
const entry = (0,
|
|
3374
|
-
return entry ? (0,
|
|
3501
|
+
const entry = (0, import_node_fs15.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
3502
|
+
return entry ? (0, import_node_path13.join)(workspaceRoot, entry) : void 0;
|
|
3375
3503
|
} catch {
|
|
3376
3504
|
return void 0;
|
|
3377
3505
|
}
|
|
@@ -3391,8 +3519,8 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
3391
3519
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component", empty);
|
|
3392
3520
|
}
|
|
3393
3521
|
function reshapeReactAppScaffold(projectRoot) {
|
|
3394
|
-
const appDir = (0,
|
|
3395
|
-
if (!(0,
|
|
3522
|
+
const appDir = (0, import_node_path13.join)(projectRoot, "src", "app");
|
|
3523
|
+
if (!(0, import_node_fs15.existsSync)((0, import_node_path13.join)(appDir, "app.tsx"))) {
|
|
3396
3524
|
return;
|
|
3397
3525
|
}
|
|
3398
3526
|
for (const [from, to] of [
|
|
@@ -3400,60 +3528,60 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
3400
3528
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
3401
3529
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
3402
3530
|
]) {
|
|
3403
|
-
if ((0,
|
|
3404
|
-
(0,
|
|
3531
|
+
if ((0, import_node_fs15.existsSync)((0, import_node_path13.join)(appDir, from))) {
|
|
3532
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(appDir, from), (0, import_node_path13.join)(appDir, to));
|
|
3405
3533
|
}
|
|
3406
3534
|
}
|
|
3407
3535
|
const rewrite = (file, from, to) => {
|
|
3408
|
-
if ((0,
|
|
3409
|
-
writeFileEnsured(file, repointSpecifier((0,
|
|
3536
|
+
if ((0, import_node_fs15.existsSync)(file)) {
|
|
3537
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs15.readFileSync)(file, "utf8"), from, to));
|
|
3410
3538
|
}
|
|
3411
3539
|
};
|
|
3412
|
-
rewrite((0,
|
|
3413
|
-
rewrite((0,
|
|
3414
|
-
rewrite((0,
|
|
3540
|
+
rewrite((0, import_node_path13.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
3541
|
+
rewrite((0, import_node_path13.join)(appDir, "app.component.spec.tsx"), "./app", "./app.component");
|
|
3542
|
+
rewrite((0, import_node_path13.join)(projectRoot, "src", "main.tsx"), "./app/app", "./app");
|
|
3415
3543
|
writeFileEnsured(
|
|
3416
|
-
(0,
|
|
3544
|
+
(0, import_node_path13.join)(appDir, "index.ts"),
|
|
3417
3545
|
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
3418
3546
|
);
|
|
3419
3547
|
}
|
|
3420
3548
|
function emptySlice(projectRoot, sliceDir) {
|
|
3421
|
-
for (const entry of (0,
|
|
3422
|
-
(0,
|
|
3549
|
+
for (const entry of (0, import_node_fs15.readdirSync)(sliceDir)) {
|
|
3550
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(sliceDir, entry), { recursive: true, force: true });
|
|
3423
3551
|
}
|
|
3424
|
-
writeFileEnsured((0,
|
|
3425
|
-
addNxTargets((0,
|
|
3552
|
+
writeFileEnsured((0, import_node_path13.join)(sliceDir, "index.ts"), "export {}\n");
|
|
3553
|
+
addNxTargets((0, import_node_path13.join)(projectRoot, "package.json"), { test: { options: { passWithNoTests: true } } });
|
|
3426
3554
|
}
|
|
3427
3555
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
3428
|
-
const sourceDir = (0,
|
|
3429
|
-
const libDir = (0,
|
|
3430
|
-
if (!(0,
|
|
3556
|
+
const sourceDir = (0, import_node_path13.join)(projectRoot, "src");
|
|
3557
|
+
const libDir = (0, import_node_path13.join)(sourceDir, "lib");
|
|
3558
|
+
if (!(0, import_node_fs15.existsSync)((0, import_node_path13.join)(libDir, `${name}.${extension}`))) {
|
|
3431
3559
|
return;
|
|
3432
3560
|
}
|
|
3433
|
-
const sliceDir = (0,
|
|
3434
|
-
(0,
|
|
3435
|
-
for (const entry of (0,
|
|
3561
|
+
const sliceDir = (0, import_node_path13.join)(sourceDir, name);
|
|
3562
|
+
(0, import_node_fs15.mkdirSync)(sliceDir, { recursive: true });
|
|
3563
|
+
for (const entry of (0, import_node_fs15.readdirSync)(libDir)) {
|
|
3436
3564
|
if (entry === `${name}.${extension}`) {
|
|
3437
|
-
(0,
|
|
3565
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), (0, import_node_path13.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
3438
3566
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
3439
|
-
const renamed = (0,
|
|
3440
|
-
(0,
|
|
3441
|
-
writeFileEnsured(renamed, repointSpecifier((0,
|
|
3567
|
+
const renamed = (0, import_node_path13.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
3568
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), renamed);
|
|
3569
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs15.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
3442
3570
|
} else {
|
|
3443
|
-
(0,
|
|
3571
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), (0, import_node_path13.join)(sliceDir, entry));
|
|
3444
3572
|
}
|
|
3445
3573
|
}
|
|
3446
|
-
const barrel = (0,
|
|
3447
|
-
const esm = (0,
|
|
3448
|
-
writeFileEnsured((0,
|
|
3574
|
+
const barrel = (0, import_node_path13.join)(sourceDir, "index.ts");
|
|
3575
|
+
const esm = (0, import_node_fs15.existsSync)(barrel) && (0, import_node_fs15.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
3576
|
+
writeFileEnsured((0, import_node_path13.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
3449
3577
|
`);
|
|
3450
|
-
if ((0,
|
|
3578
|
+
if ((0, import_node_fs15.existsSync)(barrel)) {
|
|
3451
3579
|
writeFileEnsured(
|
|
3452
3580
|
barrel,
|
|
3453
|
-
(0,
|
|
3581
|
+
(0, import_node_fs15.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
3454
3582
|
);
|
|
3455
3583
|
}
|
|
3456
|
-
(0,
|
|
3584
|
+
(0, import_node_fs15.rmSync)(libDir, { recursive: true, force: true });
|
|
3457
3585
|
if (empty) {
|
|
3458
3586
|
emptySlice(projectRoot, sliceDir);
|
|
3459
3587
|
} else if (role === "use-case") {
|
|
@@ -3463,7 +3591,7 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
3463
3591
|
function writeWorkedExample(sliceDir, name, esm) {
|
|
3464
3592
|
const suffix = esm ? ".js" : "";
|
|
3465
3593
|
writeFileEnsured(
|
|
3466
|
-
(0,
|
|
3594
|
+
(0, import_node_path13.join)(sliceDir, `${name}.contract.ts`),
|
|
3467
3595
|
`/** What greeting someone returns. */
|
|
3468
3596
|
export interface Greeting {
|
|
3469
3597
|
readonly message: string
|
|
@@ -3471,7 +3599,7 @@ export interface Greeting {
|
|
|
3471
3599
|
`
|
|
3472
3600
|
);
|
|
3473
3601
|
writeFileEnsured(
|
|
3474
|
-
(0,
|
|
3602
|
+
(0, import_node_path13.join)(sliceDir, `${name}.use-case.ts`),
|
|
3475
3603
|
`import type { Greeting } from './${name}.contract${suffix}'
|
|
3476
3604
|
|
|
3477
3605
|
/**
|
|
@@ -3490,7 +3618,7 @@ export function greet (name: string): Greeting {
|
|
|
3490
3618
|
`
|
|
3491
3619
|
);
|
|
3492
3620
|
writeFileEnsured(
|
|
3493
|
-
(0,
|
|
3621
|
+
(0, import_node_path13.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
3494
3622
|
`import { greet } from './${name}.use-case${suffix}'
|
|
3495
3623
|
|
|
3496
3624
|
describe('greet', () => {
|
|
@@ -3501,7 +3629,7 @@ describe('greet', () => {
|
|
|
3501
3629
|
`
|
|
3502
3630
|
);
|
|
3503
3631
|
writeFileEnsured(
|
|
3504
|
-
(0,
|
|
3632
|
+
(0, import_node_path13.join)(sliceDir, "index.ts"),
|
|
3505
3633
|
`export * from './${name}.contract${suffix}'
|
|
3506
3634
|
export * from './${name}.use-case${suffix}'
|
|
3507
3635
|
`
|
|
@@ -3515,8 +3643,8 @@ function repointSpecifier(source, from, to) {
|
|
|
3515
3643
|
return result;
|
|
3516
3644
|
}
|
|
3517
3645
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
3518
|
-
const manifestPath = (0,
|
|
3519
|
-
if (!(0,
|
|
3646
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, "package.json");
|
|
3647
|
+
if (!(0, import_node_fs15.existsSync)(manifestPath)) {
|
|
3520
3648
|
return;
|
|
3521
3649
|
}
|
|
3522
3650
|
const manifest = readJson(manifestPath);
|
|
@@ -3543,11 +3671,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3543
3671
|
for (const [suffix, command] of extraScripts) {
|
|
3544
3672
|
scripts[`${name}:${suffix}`] = command;
|
|
3545
3673
|
}
|
|
3546
|
-
const dependabotPath = (0,
|
|
3547
|
-
if ((0,
|
|
3674
|
+
const dependabotPath = (0, import_node_path13.join)(workspaceRoot, ".github/dependabot.yml");
|
|
3675
|
+
if ((0, import_node_fs15.existsSync)(dependabotPath)) {
|
|
3548
3676
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
3549
3677
|
}
|
|
3550
|
-
const manifestPath = (0,
|
|
3678
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, "package.json");
|
|
3551
3679
|
const manifest = readJson(manifestPath);
|
|
3552
3680
|
const existingScripts = manifest.scripts ?? {};
|
|
3553
3681
|
writeFileEnsured(
|
|
@@ -3586,7 +3714,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3586
3714
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
3587
3715
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
3588
3716
|
try {
|
|
3589
|
-
return readJson((0,
|
|
3717
|
+
return readJson((0, import_node_path13.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
3590
3718
|
} catch {
|
|
3591
3719
|
return {};
|
|
3592
3720
|
}
|
|
@@ -3598,7 +3726,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
3598
3726
|
return;
|
|
3599
3727
|
}
|
|
3600
3728
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
3601
|
-
(root) => (0,
|
|
3729
|
+
(root) => (0, import_node_path13.join)(workspaceRoot, root, projectName, "package.json")
|
|
3602
3730
|
).find((candidate) => fileExists(candidate));
|
|
3603
3731
|
if (manifestPath === void 0) {
|
|
3604
3732
|
return;
|
|
@@ -3610,10 +3738,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
3610
3738
|
const remaining = Object.fromEntries(
|
|
3611
3739
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
3612
3740
|
);
|
|
3613
|
-
const rootManifest = readJson((0,
|
|
3741
|
+
const rootManifest = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3614
3742
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
3615
3743
|
writeFileEnsured(
|
|
3616
|
-
(0,
|
|
3744
|
+
(0, import_node_path13.join)(workspaceRoot, "package.json"),
|
|
3617
3745
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
3618
3746
|
);
|
|
3619
3747
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -3652,28 +3780,28 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
3652
3780
|
}
|
|
3653
3781
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
3654
3782
|
if (kind === "classlib") {
|
|
3655
|
-
(0,
|
|
3783
|
+
(0, import_node_fs16.rmSync)((0, import_node_path14.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
3656
3784
|
}
|
|
3657
3785
|
const files = csharpExampleFiles(identity);
|
|
3658
3786
|
for (const [file, contents] of Object.entries(files)) {
|
|
3659
|
-
writeFileEnsured((0,
|
|
3787
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, file), contents);
|
|
3660
3788
|
}
|
|
3661
3789
|
if (kind === "console") {
|
|
3662
|
-
writeFileEnsured((0,
|
|
3790
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
3663
3791
|
}
|
|
3664
3792
|
}
|
|
3665
3793
|
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
3666
|
-
const name = (0,
|
|
3794
|
+
const name = (0, import_node_path14.basename)(projectRoot);
|
|
3667
3795
|
const testRoot = `tests/${name}`;
|
|
3668
3796
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
3669
|
-
(0,
|
|
3670
|
-
writeFileEnsured((0,
|
|
3797
|
+
(0, import_node_fs16.rmSync)((0, import_node_path14.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
3798
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
3671
3799
|
writeFileEnsured(
|
|
3672
|
-
(0,
|
|
3800
|
+
(0, import_node_path14.join)(workspaceRoot, testRoot, "project.json"),
|
|
3673
3801
|
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
3674
3802
|
);
|
|
3675
|
-
const reference = (0,
|
|
3676
|
-
if (runShell("dotnet", ["add", (0,
|
|
3803
|
+
const reference = (0, import_node_path14.join)(workspaceRoot, projectRoot, `${identity}.csproj`);
|
|
3804
|
+
if (runShell("dotnet", ["add", (0, import_node_path14.join)(workspaceRoot, testRoot), "reference", reference], workspaceRoot) !== 0) {
|
|
3677
3805
|
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
3678
3806
|
}
|
|
3679
3807
|
}
|
|
@@ -3700,9 +3828,9 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
3700
3828
|
ensureAdmZip(workspaceRoot);
|
|
3701
3829
|
const projectRoot = `apps/${name}`;
|
|
3702
3830
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
3703
|
-
writeCsharpExample((0,
|
|
3831
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3704
3832
|
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
3705
|
-
addProjectJsonTargets((0,
|
|
3833
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3706
3834
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
3707
3835
|
start: csharpAppStartTarget(projectRoot)
|
|
3708
3836
|
});
|
|
@@ -3795,7 +3923,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
3795
3923
|
module.exports = CsharpVersionActions
|
|
3796
3924
|
`;
|
|
3797
3925
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
3798
|
-
writeFileEnsured((0,
|
|
3926
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
3799
3927
|
}
|
|
3800
3928
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
3801
3929
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -3810,7 +3938,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3810
3938
|
);
|
|
3811
3939
|
}
|
|
3812
3940
|
function addInitialVersion(csprojPath) {
|
|
3813
|
-
const contents = (0,
|
|
3941
|
+
const contents = (0, import_node_fs16.readFileSync)(csprojPath, "utf8");
|
|
3814
3942
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3815
3943
|
}
|
|
3816
3944
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3825,16 +3953,16 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3825
3953
|
const projectRoot = `packages/${name}`;
|
|
3826
3954
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3827
3955
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3828
|
-
writeCsharpExample((0,
|
|
3956
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3829
3957
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3830
|
-
addInitialVersion((0,
|
|
3958
|
+
addInitialVersion((0, import_node_path14.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3831
3959
|
writeCsharpVersionActions(workspaceRoot);
|
|
3832
|
-
addProjectJsonReleaseVersionActions((0,
|
|
3833
|
-
addProjectJsonTargets((0,
|
|
3960
|
+
addProjectJsonReleaseVersionActions((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"));
|
|
3961
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3834
3962
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
3835
3963
|
});
|
|
3836
3964
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
3837
|
-
writeFileEnsured((0,
|
|
3965
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
3838
3966
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
3839
3967
|
}
|
|
3840
3968
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -3843,7 +3971,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3843
3971
|
const projectRoot = `libs/${name}`;
|
|
3844
3972
|
const identity = pascalCase(name);
|
|
3845
3973
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3846
|
-
writeCsharpExample((0,
|
|
3974
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3847
3975
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3848
3976
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3849
3977
|
logger.step(
|
|
@@ -3912,20 +4040,20 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3912
4040
|
const projectRoot = `apps/${name}`;
|
|
3913
4041
|
const identity = pascalCase(name);
|
|
3914
4042
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
3915
|
-
const absoluteRoot = (0,
|
|
3916
|
-
writeFileEnsured((0,
|
|
3917
|
-
writeFileEnsured((0,
|
|
3918
|
-
writeFileEnsured((0,
|
|
4043
|
+
const absoluteRoot = (0, import_node_path14.join)(workspaceRoot, projectRoot);
|
|
4044
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
4045
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
4046
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3919
4047
|
const example = csharpExampleFiles(identity);
|
|
3920
4048
|
for (const [file, contents] of Object.entries(example)) {
|
|
3921
|
-
writeFileEnsured((0,
|
|
4049
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, file), contents);
|
|
3922
4050
|
}
|
|
3923
|
-
writeFileEnsured((0,
|
|
4051
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3924
4052
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3925
4053
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3926
4054
|
}
|
|
3927
4055
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3928
|
-
addProjectJsonTargets((0,
|
|
4056
|
+
addProjectJsonTargets((0, import_node_path14.join)(absoluteRoot, "project.json"), {
|
|
3929
4057
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3930
4058
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
3931
4059
|
});
|
|
@@ -3933,7 +4061,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3933
4061
|
}
|
|
3934
4062
|
|
|
3935
4063
|
// src/project-scaffolding/flutter.use-case.ts
|
|
3936
|
-
var
|
|
4064
|
+
var import_node_path15 = require("path");
|
|
3937
4065
|
function flutterAppStartTarget(name) {
|
|
3938
4066
|
return {
|
|
3939
4067
|
executor: "nx:run-commands",
|
|
@@ -3969,7 +4097,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
3969
4097
|
prepareFlutter(workspaceRoot);
|
|
3970
4098
|
ensureAdmZip(workspaceRoot);
|
|
3971
4099
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
3972
|
-
addProjectJsonTargets((0,
|
|
4100
|
+
addProjectJsonTargets((0, import_node_path15.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3973
4101
|
start: flutterAppStartTarget(name)
|
|
3974
4102
|
});
|
|
3975
4103
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -3986,8 +4114,8 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3986
4114
|
}
|
|
3987
4115
|
|
|
3988
4116
|
// src/project-scaffolding/go.use-case.ts
|
|
3989
|
-
var
|
|
3990
|
-
var
|
|
4117
|
+
var import_node_fs19 = require("fs");
|
|
4118
|
+
var import_node_path18 = require("path");
|
|
3991
4119
|
|
|
3992
4120
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
3993
4121
|
function greetingContract(packageName) {
|
|
@@ -4055,82 +4183,9 @@ function goAppExampleFiles(modulePath) {
|
|
|
4055
4183
|
};
|
|
4056
4184
|
}
|
|
4057
4185
|
|
|
4058
|
-
// src/go-workspace/go-plugin.use-case.ts
|
|
4059
|
-
var import_node_fs15 = require("fs");
|
|
4060
|
-
var import_node_path14 = require("path");
|
|
4061
|
-
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
4062
|
-
function hasGoProject(workspaceRoot) {
|
|
4063
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs15.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
4064
|
-
return projectFiles.some((projectFile) => {
|
|
4065
|
-
try {
|
|
4066
|
-
const { tags } = JSON.parse((0, import_node_fs15.readFileSync)((0, import_node_path14.join)(workspaceRoot, projectFile), "utf8"));
|
|
4067
|
-
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
4068
|
-
} catch {
|
|
4069
|
-
return false;
|
|
4070
|
-
}
|
|
4071
|
-
});
|
|
4072
|
-
}
|
|
4073
|
-
function isNxGoPluginRegistered(workspaceRoot) {
|
|
4074
|
-
const nxJsonPath = (0, import_node_path14.join)(workspaceRoot, "nx.json");
|
|
4075
|
-
if (!fileExists(nxJsonPath)) {
|
|
4076
|
-
return false;
|
|
4077
|
-
}
|
|
4078
|
-
return (readJson(nxJsonPath).plugins ?? []).some((entry) => (typeof entry === "string" ? entry : entry.plugin) === NX_GO_PLUGIN);
|
|
4079
|
-
}
|
|
4080
|
-
function modulePrefixFromRemoteUrl(url) {
|
|
4081
|
-
const trimmed = url.trim();
|
|
4082
|
-
const scpLike = /^[^@/]+@([^:]+):(.+)$/.exec(trimmed);
|
|
4083
|
-
const withScheme = /^[a-z][\w+.-]*:\/\/(?:[^@/]+@)?(.+)$/i.exec(trimmed);
|
|
4084
|
-
let path;
|
|
4085
|
-
if (scpLike) {
|
|
4086
|
-
path = `${scpLike[1]}/${scpLike[2]}`;
|
|
4087
|
-
} else if (withScheme) {
|
|
4088
|
-
path = withScheme[1];
|
|
4089
|
-
}
|
|
4090
|
-
if (path === void 0) {
|
|
4091
|
-
return void 0;
|
|
4092
|
-
}
|
|
4093
|
-
const cleaned = path.replace(/\.git$/, "").replace(/\/+$/, "");
|
|
4094
|
-
return cleaned === "" ? void 0 : cleaned;
|
|
4095
|
-
}
|
|
4096
|
-
function goModulePrefix(workspaceRoot) {
|
|
4097
|
-
const result = runCapture("git", ["remote", "get-url", "origin"], workspaceRoot);
|
|
4098
|
-
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
4099
|
-
}
|
|
4100
|
-
function rootModulePath(workspaceRoot) {
|
|
4101
|
-
try {
|
|
4102
|
-
return /^module\s+(\S+)/m.exec((0, import_node_fs15.readFileSync)((0, import_node_path14.join)(workspaceRoot, "go.mod"), "utf8"))?.[1];
|
|
4103
|
-
} catch {
|
|
4104
|
-
return void 0;
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4107
|
-
function registerNxGoPlugin(workspaceRoot) {
|
|
4108
|
-
const nxJsonPath = (0, import_node_path14.join)(workspaceRoot, "nx.json");
|
|
4109
|
-
if (!fileExists(nxJsonPath)) {
|
|
4110
|
-
return false;
|
|
4111
|
-
}
|
|
4112
|
-
const modulePrefix = rootModulePath(workspaceRoot) === void 0 ? goModulePrefix(workspaceRoot) : void 0;
|
|
4113
|
-
const entry = modulePrefix === void 0 ? NX_GO_PLUGIN : { plugin: NX_GO_PLUGIN, options: { modulePrefix } };
|
|
4114
|
-
const nxJson = readJson(nxJsonPath);
|
|
4115
|
-
const plugins = [...nxJson.plugins ?? []];
|
|
4116
|
-
const index = plugins.findIndex((plugin) => (typeof plugin === "string" ? plugin : plugin.plugin) === NX_GO_PLUGIN);
|
|
4117
|
-
if (index === -1) {
|
|
4118
|
-
plugins.push(entry);
|
|
4119
|
-
} else {
|
|
4120
|
-
const current = plugins[index];
|
|
4121
|
-
const currentPrefix = typeof current === "string" ? void 0 : current.options?.modulePrefix;
|
|
4122
|
-
if (modulePrefix === void 0 || currentPrefix === modulePrefix) {
|
|
4123
|
-
return false;
|
|
4124
|
-
}
|
|
4125
|
-
plugins[index] = entry;
|
|
4126
|
-
}
|
|
4127
|
-
writeFileEnsured(nxJsonPath, toJson({ ...nxJson, plugins }));
|
|
4128
|
-
return true;
|
|
4129
|
-
}
|
|
4130
|
-
|
|
4131
4186
|
// src/project-scaffolding/go-release.use-case.ts
|
|
4132
|
-
var
|
|
4133
|
-
var
|
|
4187
|
+
var import_node_fs17 = require("fs");
|
|
4188
|
+
var import_node_path16 = require("path");
|
|
4134
4189
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
4135
4190
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
4136
4191
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -4256,7 +4311,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
4256
4311
|
}
|
|
4257
4312
|
};
|
|
4258
4313
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
4259
|
-
const projectJsonPath = (0,
|
|
4314
|
+
const projectJsonPath = (0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json");
|
|
4260
4315
|
if (!fileExists(projectJsonPath)) {
|
|
4261
4316
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
4262
4317
|
}
|
|
@@ -4277,22 +4332,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
4277
4332
|
}
|
|
4278
4333
|
})
|
|
4279
4334
|
);
|
|
4280
|
-
writeFileEnsured((0,
|
|
4335
|
+
writeFileEnsured((0, import_node_path16.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
4281
4336
|
}
|
|
4282
4337
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
4283
|
-
const apps = (0,
|
|
4338
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4284
4339
|
let entries;
|
|
4285
4340
|
try {
|
|
4286
|
-
entries = (0,
|
|
4341
|
+
entries = (0, import_node_fs17.readdirSync)(apps);
|
|
4287
4342
|
} catch {
|
|
4288
4343
|
return false;
|
|
4289
4344
|
}
|
|
4290
4345
|
const hasReleasableApp = entries.some((entry) => {
|
|
4291
|
-
const projectJsonPath = (0,
|
|
4346
|
+
const projectJsonPath = (0, import_node_path16.join)(apps, entry, "project.json");
|
|
4292
4347
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
4293
4348
|
});
|
|
4294
|
-
const path = (0,
|
|
4295
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
4349
|
+
const path = (0, import_node_path16.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
4350
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs17.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
4296
4351
|
return false;
|
|
4297
4352
|
}
|
|
4298
4353
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -4300,8 +4355,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
4300
4355
|
}
|
|
4301
4356
|
|
|
4302
4357
|
// src/project-scaffolding/go-web.use-case.ts
|
|
4303
|
-
var
|
|
4304
|
-
var
|
|
4358
|
+
var import_node_fs18 = require("fs");
|
|
4359
|
+
var import_node_path17 = require("path");
|
|
4305
4360
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
4306
4361
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
4307
4362
|
var GO_WEB_SOURCE = `package main
|
|
@@ -4379,18 +4434,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
4379
4434
|
}
|
|
4380
4435
|
`;
|
|
4381
4436
|
function assertWebApp(workspaceRoot, web) {
|
|
4382
|
-
const directory = (0,
|
|
4383
|
-
const isReactApp = fileExists((0,
|
|
4437
|
+
const directory = (0, import_node_path17.join)(workspaceRoot, "apps", web);
|
|
4438
|
+
const isReactApp = fileExists((0, import_node_path17.join)(directory, "package.json")) && (0, import_node_fs18.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
4384
4439
|
if (!isReactApp) {
|
|
4385
4440
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
4386
4441
|
}
|
|
4387
4442
|
}
|
|
4388
4443
|
function webProjectName(workspaceRoot, web) {
|
|
4389
|
-
const manifest = readJson((0,
|
|
4444
|
+
const manifest = readJson((0, import_node_path17.join)(workspaceRoot, "apps", web, "package.json"));
|
|
4390
4445
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
4391
4446
|
}
|
|
4392
4447
|
function addApiProxy(viteConfigPath) {
|
|
4393
|
-
const source = (0,
|
|
4448
|
+
const source = (0, import_node_fs18.readFileSync)(viteConfigPath, "utf8");
|
|
4394
4449
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
4395
4450
|
return false;
|
|
4396
4451
|
}
|
|
@@ -4403,7 +4458,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
4403
4458
|
return true;
|
|
4404
4459
|
}
|
|
4405
4460
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
4406
|
-
const projectJsonPath = (0,
|
|
4461
|
+
const projectJsonPath = (0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json");
|
|
4407
4462
|
const project = readJson(projectJsonPath);
|
|
4408
4463
|
const webName = webProjectName(workspaceRoot, web);
|
|
4409
4464
|
const targets = project.targets ?? {};
|
|
@@ -4429,13 +4484,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
4429
4484
|
projectJsonPath,
|
|
4430
4485
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
4431
4486
|
);
|
|
4432
|
-
const directory = (0,
|
|
4433
|
-
writeFileEnsured((0,
|
|
4434
|
-
writeFileEnsured((0,
|
|
4435
|
-
writeFileEnsured((0,
|
|
4436
|
-
writeFileEnsured((0,
|
|
4437
|
-
const viteConfig = (0,
|
|
4438
|
-
if (viteConfig === void 0 || !addApiProxy((0,
|
|
4487
|
+
const directory = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4488
|
+
writeFileEnsured((0, import_node_path17.join)(directory, ".gitignore"), "/web/\n");
|
|
4489
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
4490
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
4491
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
4492
|
+
const viteConfig = (0, import_node_fs18.readdirSync)((0, import_node_path17.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
4493
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path17.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
4439
4494
|
logger.warn(
|
|
4440
4495
|
`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.`
|
|
4441
4496
|
);
|
|
@@ -4469,7 +4524,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
4469
4524
|
}
|
|
4470
4525
|
}
|
|
4471
4526
|
function ensureGoModule(workspaceRoot) {
|
|
4472
|
-
if (fileExists((0,
|
|
4527
|
+
if (fileExists((0, import_node_path18.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path18.join)(workspaceRoot, "go.mod"))) {
|
|
4473
4528
|
return;
|
|
4474
4529
|
}
|
|
4475
4530
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -4477,26 +4532,26 @@ function ensureGoModule(workspaceRoot) {
|
|
|
4477
4532
|
}
|
|
4478
4533
|
function readGoModModule(goModPath) {
|
|
4479
4534
|
try {
|
|
4480
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
4535
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs19.readFileSync)(goModPath, "utf8"))?.[1];
|
|
4481
4536
|
} catch {
|
|
4482
4537
|
return void 0;
|
|
4483
4538
|
}
|
|
4484
4539
|
}
|
|
4485
4540
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
4486
|
-
const projectModule = readGoModModule((0,
|
|
4541
|
+
const projectModule = readGoModModule((0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod"));
|
|
4487
4542
|
if (projectModule !== void 0) {
|
|
4488
4543
|
return projectModule;
|
|
4489
4544
|
}
|
|
4490
|
-
const rootModule = readGoModModule((0,
|
|
4545
|
+
const rootModule = readGoModModule((0, import_node_path18.join)(workspaceRoot, "go.mod"));
|
|
4491
4546
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
4492
4547
|
}
|
|
4493
4548
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
4494
4549
|
const prefix = goModulePrefix(workspaceRoot);
|
|
4495
|
-
const goModPath = (0,
|
|
4550
|
+
const goModPath = (0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod");
|
|
4496
4551
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
4497
4552
|
return;
|
|
4498
4553
|
}
|
|
4499
|
-
const rewritten = (0,
|
|
4554
|
+
const rewritten = (0, import_node_fs19.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
4500
4555
|
writeFileEnsured(goModPath, rewritten);
|
|
4501
4556
|
}
|
|
4502
4557
|
var GO_DIRECTIVE_CEILING = "1.24";
|
|
@@ -4509,7 +4564,7 @@ function clampGoDirective(filePath) {
|
|
|
4509
4564
|
if (!fileExists(filePath)) {
|
|
4510
4565
|
return;
|
|
4511
4566
|
}
|
|
4512
|
-
const before = (0,
|
|
4567
|
+
const before = (0, import_node_fs19.readFileSync)(filePath, "utf8");
|
|
4513
4568
|
const directive = /^go\s+(\d+\.\d+(?:\.\d+)?)/m.exec(before);
|
|
4514
4569
|
if (directive === null || !exceedsGoCeiling(directive[1])) {
|
|
4515
4570
|
return;
|
|
@@ -4518,19 +4573,19 @@ function clampGoDirective(filePath) {
|
|
|
4518
4573
|
writeFileEnsured(filePath, after);
|
|
4519
4574
|
}
|
|
4520
4575
|
function pinGoDirective(workspaceRoot, projectDir) {
|
|
4521
|
-
clampGoDirective((0,
|
|
4522
|
-
clampGoDirective((0,
|
|
4576
|
+
clampGoDirective((0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod"));
|
|
4577
|
+
clampGoDirective((0, import_node_path18.join)(workspaceRoot, "go.work"));
|
|
4523
4578
|
}
|
|
4524
4579
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
4525
|
-
const goModPath = (0,
|
|
4526
|
-
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0,
|
|
4580
|
+
const goModPath = (0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod");
|
|
4581
|
+
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs19.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
4527
4582
|
if (modulePath === void 0) {
|
|
4528
4583
|
return;
|
|
4529
4584
|
}
|
|
4530
|
-
(0,
|
|
4585
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
4531
4586
|
const example = goAppExampleFiles(modulePath);
|
|
4532
4587
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4533
|
-
writeFileEnsured((0,
|
|
4588
|
+
writeFileEnsured((0, import_node_path18.join)(workspaceRoot, projectDir, relative), contents);
|
|
4534
4589
|
}
|
|
4535
4590
|
}
|
|
4536
4591
|
function goTestTarget() {
|
|
@@ -4608,16 +4663,16 @@ function goNativePackageTarget(name) {
|
|
|
4608
4663
|
}
|
|
4609
4664
|
function addGoPlatformTargets(workspaceRoot) {
|
|
4610
4665
|
const changed = [];
|
|
4611
|
-
const apps = (0,
|
|
4666
|
+
const apps = (0, import_node_path18.join)(workspaceRoot, "apps");
|
|
4612
4667
|
if (!fileExists(apps)) {
|
|
4613
4668
|
return changed;
|
|
4614
4669
|
}
|
|
4615
|
-
for (const name of (0,
|
|
4616
|
-
const projectJsonPath = (0,
|
|
4670
|
+
for (const name of (0, import_node_fs19.readdirSync)(apps)) {
|
|
4671
|
+
const projectJsonPath = (0, import_node_path18.join)(apps, name, "project.json");
|
|
4617
4672
|
if (!fileExists(projectJsonPath)) {
|
|
4618
4673
|
continue;
|
|
4619
4674
|
}
|
|
4620
|
-
const project = JSON.parse((0,
|
|
4675
|
+
const project = JSON.parse((0, import_node_fs19.readFileSync)(projectJsonPath, "utf8"));
|
|
4621
4676
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
4622
4677
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
4623
4678
|
continue;
|
|
@@ -4653,8 +4708,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
4653
4708
|
}
|
|
4654
4709
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
4655
4710
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
4656
|
-
(0,
|
|
4657
|
-
(0,
|
|
4711
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
4712
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
4658
4713
|
const files = [
|
|
4659
4714
|
[
|
|
4660
4715
|
"doc.go",
|
|
@@ -4664,7 +4719,7 @@ package ${packageName}
|
|
|
4664
4719
|
`
|
|
4665
4720
|
],
|
|
4666
4721
|
[
|
|
4667
|
-
(0,
|
|
4722
|
+
(0, import_node_path18.join)(packageName, "doc.go"),
|
|
4668
4723
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
4669
4724
|
// the outcome it delivers, and add one package per further outcome.
|
|
4670
4725
|
package ${packageName}
|
|
@@ -4672,11 +4727,11 @@ package ${packageName}
|
|
|
4672
4727
|
],
|
|
4673
4728
|
// The starter slice: a contract, a use case and its test (see goLibraryExampleFiles).
|
|
4674
4729
|
...Object.entries(goLibraryExampleFiles(packageName, fileStem)).map(
|
|
4675
|
-
([name, content]) => [(0,
|
|
4730
|
+
([name, content]) => [(0, import_node_path18.join)(packageName, name), content]
|
|
4676
4731
|
)
|
|
4677
4732
|
];
|
|
4678
4733
|
for (const [relativePath, content] of files) {
|
|
4679
|
-
const path = (0,
|
|
4734
|
+
const path = (0, import_node_path18.join)(projectRoot, relativePath);
|
|
4680
4735
|
if (!fileExists(path)) {
|
|
4681
4736
|
writeFileEnsured(path, content);
|
|
4682
4737
|
}
|
|
@@ -4715,7 +4770,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4715
4770
|
if (options.web === void 0) {
|
|
4716
4771
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4717
4772
|
}
|
|
4718
|
-
addProjectJsonTargets((0,
|
|
4773
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4719
4774
|
build: goBuildTarget(name),
|
|
4720
4775
|
test: goTestTarget(),
|
|
4721
4776
|
lint: goLintTarget(),
|
|
@@ -4756,7 +4811,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4756
4811
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4757
4812
|
pinGoDirective(workspaceRoot, `apps/${name}`);
|
|
4758
4813
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4759
|
-
addProjectJsonTargets((0,
|
|
4814
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4760
4815
|
"build": goBuildTarget(name),
|
|
4761
4816
|
"test": goTestTarget(),
|
|
4762
4817
|
"lint": goLintTarget(),
|
|
@@ -4781,11 +4836,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4781
4836
|
);
|
|
4782
4837
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4783
4838
|
pinGoDirective(workspaceRoot, `packages/${name}`);
|
|
4784
|
-
addProjectJsonTargets((0,
|
|
4839
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4785
4840
|
test: goTestTarget(),
|
|
4786
4841
|
lint: goLintTarget()
|
|
4787
4842
|
});
|
|
4788
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4843
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path18.join)(workspaceRoot, "packages", name), name);
|
|
4789
4844
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4790
4845
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
4791
4846
|
if (module2) {
|
|
@@ -4807,11 +4862,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4807
4862
|
);
|
|
4808
4863
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4809
4864
|
pinGoDirective(workspaceRoot, `libs/${name}`);
|
|
4810
|
-
addProjectJsonTargets((0,
|
|
4865
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4811
4866
|
test: goTestTarget(),
|
|
4812
4867
|
lint: goLintTarget()
|
|
4813
4868
|
});
|
|
4814
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4869
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path18.join)(workspaceRoot, "libs", name), name);
|
|
4815
4870
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4816
4871
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
4817
4872
|
if (module2) {
|
|
@@ -4820,8 +4875,8 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4820
4875
|
}
|
|
4821
4876
|
|
|
4822
4877
|
// src/esm-conversion/esm-conversion.use-case.ts
|
|
4823
|
-
var
|
|
4824
|
-
var
|
|
4878
|
+
var import_node_fs20 = require("fs");
|
|
4879
|
+
var import_node_path19 = require("path");
|
|
4825
4880
|
|
|
4826
4881
|
// src/esm-conversion/esm-specifiers.algorithm.ts
|
|
4827
4882
|
var RELATIVE_SPECIFIER = /((?:\bfrom|\bimport)\s*)(['"])(\.{1,2}\/[^'"\n]*|\.{1,2})\2/g;
|
|
@@ -4841,9 +4896,9 @@ var SAMPLE_DIRECTORIES = ["./hello"];
|
|
|
4841
4896
|
var JEST_ANCHOR = " moduleFileExtensions:";
|
|
4842
4897
|
var JEST_MAPPER = String.raw` moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },`;
|
|
4843
4898
|
function typescriptFiles(directory) {
|
|
4844
|
-
const entries = (0,
|
|
4899
|
+
const entries = (0, import_node_fs20.readdirSync)(directory, { withFileTypes: true });
|
|
4845
4900
|
return entries.flatMap((entry) => {
|
|
4846
|
-
const path = (0,
|
|
4901
|
+
const path = (0, import_node_path19.join)(directory, entry.name);
|
|
4847
4902
|
if (entry.isDirectory()) {
|
|
4848
4903
|
return typescriptFiles(path);
|
|
4849
4904
|
}
|
|
@@ -4851,7 +4906,7 @@ function typescriptFiles(directory) {
|
|
|
4851
4906
|
});
|
|
4852
4907
|
}
|
|
4853
4908
|
function convertAppToEsm(appRoot) {
|
|
4854
|
-
const manifestPath = (0,
|
|
4909
|
+
const manifestPath = (0, import_node_path19.join)(appRoot, "package.json");
|
|
4855
4910
|
const manifest = readJson(manifestPath);
|
|
4856
4911
|
const build = manifest.nx?.targets?.build;
|
|
4857
4912
|
if (build?.options === void 0) {
|
|
@@ -4859,17 +4914,17 @@ function convertAppToEsm(appRoot) {
|
|
|
4859
4914
|
}
|
|
4860
4915
|
build.options.format = ["esm"];
|
|
4861
4916
|
writeFileEnsured(manifestPath, toJson({ ...manifest, type: "module" }));
|
|
4862
|
-
const sources = typescriptFiles((0,
|
|
4917
|
+
const sources = typescriptFiles((0, import_node_path19.join)(appRoot, "src"));
|
|
4863
4918
|
for (const file of sources) {
|
|
4864
|
-
const source = (0,
|
|
4919
|
+
const source = (0, import_node_fs20.readFileSync)(file, "utf8");
|
|
4865
4920
|
const converted = withJsSpecifiers(source, SAMPLE_DIRECTORIES);
|
|
4866
4921
|
if (converted !== source) {
|
|
4867
4922
|
writeFileEnsured(file, converted);
|
|
4868
4923
|
}
|
|
4869
4924
|
}
|
|
4870
|
-
const jestPath = (0,
|
|
4925
|
+
const jestPath = (0, import_node_path19.join)(appRoot, "jest.config.cts");
|
|
4871
4926
|
if (fileExists(jestPath)) {
|
|
4872
|
-
const jest = (0,
|
|
4927
|
+
const jest = (0, import_node_fs20.readFileSync)(jestPath, "utf8");
|
|
4873
4928
|
if (!jest.includes("moduleNameMapper")) {
|
|
4874
4929
|
if (!jest.includes(JEST_ANCHOR)) {
|
|
4875
4930
|
throw new Error(`${jestPath} has no moduleFileExtensions line to put the .js mapper above; the generator's output changed.`);
|
|
@@ -4881,7 +4936,7 @@ ${JEST_ANCHOR}`));
|
|
|
4881
4936
|
}
|
|
4882
4937
|
|
|
4883
4938
|
// src/project-scaffolding/node.use-case.ts
|
|
4884
|
-
var
|
|
4939
|
+
var import_node_path20 = require("path");
|
|
4885
4940
|
|
|
4886
4941
|
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
4887
4942
|
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
@@ -5004,12 +5059,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
5004
5059
|
],
|
|
5005
5060
|
workspaceRoot
|
|
5006
5061
|
);
|
|
5007
|
-
const appRoot = (0,
|
|
5062
|
+
const appRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
5008
5063
|
separateDeclarationOutput(appRoot);
|
|
5009
5064
|
repairAssetMapping(appRoot, name);
|
|
5010
5065
|
}
|
|
5011
5066
|
function separateDeclarationOutput(appRoot) {
|
|
5012
|
-
const tsconfigPath = (0,
|
|
5067
|
+
const tsconfigPath = (0, import_node_path20.join)(appRoot, "tsconfig.app.json");
|
|
5013
5068
|
if (!fileExists(tsconfigPath)) {
|
|
5014
5069
|
return;
|
|
5015
5070
|
}
|
|
@@ -5031,7 +5086,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
5031
5086
|
);
|
|
5032
5087
|
}
|
|
5033
5088
|
function repairAssetMapping(appRoot, name) {
|
|
5034
|
-
const manifestPath = (0,
|
|
5089
|
+
const manifestPath = (0, import_node_path20.join)(appRoot, "package.json");
|
|
5035
5090
|
if (!fileExists(manifestPath)) {
|
|
5036
5091
|
return;
|
|
5037
5092
|
}
|
|
@@ -5060,14 +5115,14 @@ function addNodeApp(workspaceRoot, name, stack, framework = "none", esm = false)
|
|
|
5060
5115
|
const example = nodeAppExampleFiles(framework);
|
|
5061
5116
|
if (example !== null) {
|
|
5062
5117
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5063
|
-
writeFileEnsured((0,
|
|
5118
|
+
writeFileEnsured((0, import_node_path20.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
5064
5119
|
}
|
|
5065
5120
|
}
|
|
5066
5121
|
if (esm) {
|
|
5067
|
-
convertAppToEsm((0,
|
|
5122
|
+
convertAppToEsm((0, import_node_path20.join)(workspaceRoot, "apps", name));
|
|
5068
5123
|
}
|
|
5069
5124
|
ensureAdmZip(workspaceRoot);
|
|
5070
|
-
addNxTargets((0,
|
|
5125
|
+
addNxTargets((0, import_node_path20.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
5071
5126
|
package: nodeAppPackageTarget(name)
|
|
5072
5127
|
});
|
|
5073
5128
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -5136,10 +5191,10 @@ describe('greet', () => {
|
|
|
5136
5191
|
})
|
|
5137
5192
|
`;
|
|
5138
5193
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
5139
|
-
const manifestPath = (0,
|
|
5194
|
+
const manifestPath = (0, import_node_path20.join)(nodeFunctionAppRoot, "package.json");
|
|
5140
5195
|
const manifest = readJson(manifestPath);
|
|
5141
5196
|
const azureFunctionsVersion = readJson(
|
|
5142
|
-
(0,
|
|
5197
|
+
(0, import_node_path20.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
5143
5198
|
).version;
|
|
5144
5199
|
const dependencies = manifest.dependencies ?? {};
|
|
5145
5200
|
writeFileEnsured(
|
|
@@ -5182,23 +5237,23 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
5182
5237
|
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false, esm = false) {
|
|
5183
5238
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
5184
5239
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
5185
|
-
const nodeFunctionAppRoot = (0,
|
|
5186
|
-
writeFileEnsured((0,
|
|
5240
|
+
const nodeFunctionAppRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
5241
|
+
writeFileEnsured((0, import_node_path20.join)(nodeFunctionAppRoot, "src/main.ts"), empty ? NODE_FUNCTION_APP_MAIN_EMPTY : NODE_FUNCTION_APP_MAIN);
|
|
5187
5242
|
if (!empty) {
|
|
5188
|
-
const slice = (0,
|
|
5189
|
-
writeFileEnsured((0,
|
|
5190
|
-
writeFileEnsured((0,
|
|
5191
|
-
writeFileEnsured((0,
|
|
5192
|
-
writeFileEnsured((0,
|
|
5193
|
-
writeFileEnsured((0,
|
|
5194
|
-
}
|
|
5195
|
-
writeFileEnsured((0,
|
|
5243
|
+
const slice = (0, import_node_path20.join)(nodeFunctionAppRoot, "src/hello");
|
|
5244
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
5245
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greet.use-case.ts"), NODE_FUNCTION_APP_GREET_USE_CASE);
|
|
5246
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greet.use-case.spec.ts"), NODE_FUNCTION_APP_GREET_SPEC);
|
|
5247
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greeting.contract.ts"), NODE_FUNCTION_APP_GREETING_CONTRACT);
|
|
5248
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
5249
|
+
}
|
|
5250
|
+
writeFileEnsured((0, import_node_path20.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
5196
5251
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
5197
5252
|
if (esm) {
|
|
5198
5253
|
convertAppToEsm(nodeFunctionAppRoot);
|
|
5199
5254
|
}
|
|
5200
5255
|
ensureAdmZip(workspaceRoot);
|
|
5201
|
-
addNxTargets((0,
|
|
5256
|
+
addNxTargets((0, import_node_path20.join)(nodeFunctionAppRoot, "package.json"), {
|
|
5202
5257
|
package: nodeFunctionAppPackageTarget(name),
|
|
5203
5258
|
prune: nodeFunctionAppPruneTarget(name),
|
|
5204
5259
|
start: nodeFunctionAppStartTarget(name),
|
|
@@ -5210,24 +5265,24 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false, esm = fal
|
|
|
5210
5265
|
}
|
|
5211
5266
|
|
|
5212
5267
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
5213
|
-
var
|
|
5268
|
+
var import_node_path26 = require("path");
|
|
5214
5269
|
|
|
5215
5270
|
// src/lockfile-pruning/prune-stale-local-registry.use-case.ts
|
|
5216
|
-
var
|
|
5217
|
-
var
|
|
5271
|
+
var import_node_fs22 = require("fs");
|
|
5272
|
+
var import_node_path22 = require("path");
|
|
5218
5273
|
|
|
5219
5274
|
// src/lockfile-pruning/stale-local-registry.validator.ts
|
|
5220
|
-
var
|
|
5221
|
-
var
|
|
5275
|
+
var import_node_fs21 = require("fs");
|
|
5276
|
+
var import_node_path21 = require("path");
|
|
5222
5277
|
var LOCAL_REGISTRY_PACKAGE = "verdaccio";
|
|
5223
5278
|
var LOCAL_REGISTRY_LOCK_KEY = `node_modules/${LOCAL_REGISTRY_PACKAGE}`;
|
|
5224
5279
|
var DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
5225
5280
|
function readJsonFile(path) {
|
|
5226
|
-
if (!(0,
|
|
5281
|
+
if (!(0, import_node_fs21.existsSync)(path)) {
|
|
5227
5282
|
return void 0;
|
|
5228
5283
|
}
|
|
5229
5284
|
try {
|
|
5230
|
-
return JSON.parse((0,
|
|
5285
|
+
return JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
|
|
5231
5286
|
} catch {
|
|
5232
5287
|
return void 0;
|
|
5233
5288
|
}
|
|
@@ -5239,13 +5294,13 @@ function declaresLocalRegistry(manifest) {
|
|
|
5239
5294
|
});
|
|
5240
5295
|
}
|
|
5241
5296
|
function hasStaleLocalRegistry(workspaceRoot) {
|
|
5242
|
-
const lock = readJsonFile((0,
|
|
5297
|
+
const lock = readJsonFile((0, import_node_path21.join)(workspaceRoot, "package-lock.json"));
|
|
5243
5298
|
const entries = lock?.packages ?? {};
|
|
5244
5299
|
if (!Object.hasOwn(entries, LOCAL_REGISTRY_LOCK_KEY)) {
|
|
5245
5300
|
return false;
|
|
5246
5301
|
}
|
|
5247
5302
|
const members = Object.keys(entries).filter((key) => key !== "" && !key.startsWith("node_modules/") && !key.includes("/node_modules/"));
|
|
5248
|
-
const manifests = ["", ...members].map((directory) => readJsonFile((0,
|
|
5303
|
+
const manifests = ["", ...members].map((directory) => readJsonFile((0, import_node_path21.join)(workspaceRoot, directory, "package.json")));
|
|
5249
5304
|
return manifests.every((manifest) => !declaresLocalRegistry(manifest));
|
|
5250
5305
|
}
|
|
5251
5306
|
|
|
@@ -5254,21 +5309,21 @@ function pruneStaleLocalRegistry(workspaceRoot, resolve2 = runShell) {
|
|
|
5254
5309
|
if (!hasStaleLocalRegistry(workspaceRoot)) {
|
|
5255
5310
|
return { stale: false, status: 0 };
|
|
5256
5311
|
}
|
|
5257
|
-
const lockPath = (0,
|
|
5258
|
-
const lock = JSON.parse((0,
|
|
5312
|
+
const lockPath = (0, import_node_path22.join)(workspaceRoot, "package-lock.json");
|
|
5313
|
+
const lock = JSON.parse((0, import_node_fs22.readFileSync)(lockPath, "utf8"));
|
|
5259
5314
|
Reflect.deleteProperty(lock.packages, LOCAL_REGISTRY_LOCK_KEY);
|
|
5260
5315
|
const root = lock.packages[""];
|
|
5261
5316
|
if (root?.devDependencies !== void 0) {
|
|
5262
5317
|
Reflect.deleteProperty(root.devDependencies, LOCAL_REGISTRY_PACKAGE);
|
|
5263
5318
|
}
|
|
5264
|
-
(0,
|
|
5319
|
+
(0, import_node_fs22.writeFileSync)(lockPath, `${JSON.stringify(lock, void 0, 2)}
|
|
5265
5320
|
`);
|
|
5266
5321
|
return { stale: true, status: resolve2("npm", ["install", "--package-lock-only", "--ignore-scripts", "--no-audit", "--no-fund"], workspaceRoot) };
|
|
5267
5322
|
}
|
|
5268
5323
|
|
|
5269
5324
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
5270
|
-
var
|
|
5271
|
-
var
|
|
5325
|
+
var import_node_fs23 = require("fs");
|
|
5326
|
+
var import_node_path23 = require("path");
|
|
5272
5327
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
5273
5328
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
5274
5329
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -5291,14 +5346,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
5291
5346
|
}
|
|
5292
5347
|
function repairPublishableManifests(workspaceRoot) {
|
|
5293
5348
|
const changed = [];
|
|
5294
|
-
const manifests = (0,
|
|
5349
|
+
const manifests = (0, import_node_fs23.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
5295
5350
|
cwd: workspaceRoot
|
|
5296
5351
|
});
|
|
5297
5352
|
for (const relativePath of manifests) {
|
|
5298
|
-
const manifestPath = (0,
|
|
5299
|
-
const before = (0,
|
|
5353
|
+
const manifestPath = (0, import_node_path23.join)(workspaceRoot, relativePath);
|
|
5354
|
+
const before = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5300
5355
|
repairPublishableManifest(manifestPath);
|
|
5301
|
-
const after = (0,
|
|
5356
|
+
const after = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5302
5357
|
if (after !== before) {
|
|
5303
5358
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
5304
5359
|
}
|
|
@@ -5307,8 +5362,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
5307
5362
|
}
|
|
5308
5363
|
|
|
5309
5364
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5310
|
-
var
|
|
5311
|
-
var
|
|
5365
|
+
var import_node_fs24 = require("fs");
|
|
5366
|
+
var import_node_path24 = require("path");
|
|
5312
5367
|
|
|
5313
5368
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
5314
5369
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -5526,12 +5581,12 @@ ${DECLARATION_SPECIFIER_PLUGIN},`);
|
|
|
5526
5581
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5527
5582
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
5528
5583
|
const changed = [];
|
|
5529
|
-
const configs = (0,
|
|
5584
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5530
5585
|
cwd: workspaceRoot
|
|
5531
5586
|
});
|
|
5532
5587
|
for (const relativePath of configs) {
|
|
5533
|
-
const configPath = (0,
|
|
5534
|
-
const before = (0,
|
|
5588
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5589
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5535
5590
|
const after = withRollupSourceMaps(before);
|
|
5536
5591
|
if (after !== before) {
|
|
5537
5592
|
writeFileEnsured(configPath, after);
|
|
@@ -5542,12 +5597,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
5542
5597
|
}
|
|
5543
5598
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5544
5599
|
const changed = [];
|
|
5545
|
-
const configs = (0,
|
|
5600
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5546
5601
|
cwd: workspaceRoot
|
|
5547
5602
|
});
|
|
5548
5603
|
for (const relativePath of configs) {
|
|
5549
|
-
const configPath = (0,
|
|
5550
|
-
const before = (0,
|
|
5604
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5605
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5551
5606
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
5552
5607
|
if (after !== before) {
|
|
5553
5608
|
writeFileEnsured(configPath, after);
|
|
@@ -5557,11 +5612,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
5557
5612
|
return changed;
|
|
5558
5613
|
}
|
|
5559
5614
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
5560
|
-
const configPath = (0,
|
|
5615
|
+
const configPath = (0, import_node_path24.join)(projectRoot, "rollup.config.cjs");
|
|
5561
5616
|
if (!fileExists(configPath)) {
|
|
5562
5617
|
return;
|
|
5563
5618
|
}
|
|
5564
|
-
const config = (0,
|
|
5619
|
+
const config = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5565
5620
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
5566
5621
|
const repaired = withRollupSourceMaps(withDeclarationSpecifierPlugin(config));
|
|
5567
5622
|
if (repaired !== config) {
|
|
@@ -5576,12 +5631,12 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
5576
5631
|
}
|
|
5577
5632
|
function addMissingDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5578
5633
|
const changed = [];
|
|
5579
|
-
const configs = (0,
|
|
5634
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5580
5635
|
cwd: workspaceRoot
|
|
5581
5636
|
});
|
|
5582
5637
|
for (const relativePath of configs) {
|
|
5583
|
-
const configPath = (0,
|
|
5584
|
-
const before = (0,
|
|
5638
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5639
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5585
5640
|
const after = withDeclarationSpecifierPlugin(before);
|
|
5586
5641
|
if (after !== before) {
|
|
5587
5642
|
writeFileEnsured(configPath, after);
|
|
@@ -5592,10 +5647,10 @@ function addMissingDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
5592
5647
|
}
|
|
5593
5648
|
|
|
5594
5649
|
// src/rollup-library/rollup-config.repository.ts
|
|
5595
|
-
var
|
|
5596
|
-
var
|
|
5650
|
+
var import_node_fs25 = require("fs");
|
|
5651
|
+
var import_node_path25 = require("path");
|
|
5597
5652
|
function resolveRequireTarget(fromDir, specifier) {
|
|
5598
|
-
const base = (0,
|
|
5653
|
+
const base = (0, import_node_path25.join)(fromDir, specifier);
|
|
5599
5654
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
5600
5655
|
}
|
|
5601
5656
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -5605,7 +5660,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
5605
5660
|
visited.add(configPath);
|
|
5606
5661
|
let text;
|
|
5607
5662
|
try {
|
|
5608
|
-
text = (0,
|
|
5663
|
+
text = (0, import_node_fs25.readFileSync)(configPath, "utf8");
|
|
5609
5664
|
} catch {
|
|
5610
5665
|
return "";
|
|
5611
5666
|
}
|
|
@@ -5613,15 +5668,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
5613
5668
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
5614
5669
|
(match) => match[2]
|
|
5615
5670
|
);
|
|
5616
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
5671
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path25.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
5617
5672
|
return [text, ...requiredText].join("\n");
|
|
5618
5673
|
}
|
|
5619
5674
|
|
|
5620
5675
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
5621
5676
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
5622
5677
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
5623
|
-
const projectRoot = (0,
|
|
5624
|
-
const manifestPath = (0,
|
|
5678
|
+
const projectRoot = (0, import_node_path26.join)(workspaceRoot, "packages", name);
|
|
5679
|
+
const manifestPath = (0, import_node_path26.join)(projectRoot, "package.json");
|
|
5625
5680
|
runGeneratorAndRepair(
|
|
5626
5681
|
workspaceRoot,
|
|
5627
5682
|
[
|
|
@@ -5654,8 +5709,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5654
5709
|
}
|
|
5655
5710
|
|
|
5656
5711
|
// src/project-scaffolding/python.use-case.ts
|
|
5657
|
-
var
|
|
5658
|
-
var
|
|
5712
|
+
var import_node_fs26 = require("fs");
|
|
5713
|
+
var import_node_path27 = require("path");
|
|
5659
5714
|
function ensurePython(workspaceRoot) {
|
|
5660
5715
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
5661
5716
|
if (!hasPython) {
|
|
@@ -5678,7 +5733,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
5678
5733
|
registerPythonGraphPlugin(workspaceRoot);
|
|
5679
5734
|
}
|
|
5680
5735
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
5681
|
-
const nxJsonPath = (0,
|
|
5736
|
+
const nxJsonPath = (0, import_node_path27.join)(workspaceRoot, "nx.json");
|
|
5682
5737
|
if (!fileExists(nxJsonPath)) {
|
|
5683
5738
|
return;
|
|
5684
5739
|
}
|
|
@@ -5701,7 +5756,7 @@ pytest
|
|
|
5701
5756
|
pip-audit
|
|
5702
5757
|
`;
|
|
5703
5758
|
function ensureRequirementsDev(workspaceRoot) {
|
|
5704
|
-
const requirementsDevPath = (0,
|
|
5759
|
+
const requirementsDevPath = (0, import_node_path27.join)(workspaceRoot, "requirements-dev.txt");
|
|
5705
5760
|
if (!fileExists(requirementsDevPath)) {
|
|
5706
5761
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
5707
5762
|
}
|
|
@@ -5761,8 +5816,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
5761
5816
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
5762
5817
|
workspaceRoot
|
|
5763
5818
|
);
|
|
5764
|
-
writeFileEnsured((0,
|
|
5765
|
-
addProjectJsonTargets((0,
|
|
5819
|
+
writeFileEnsured((0, import_node_path27.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
5820
|
+
addProjectJsonTargets((0, import_node_path27.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
5766
5821
|
package: pythonAppPackageTarget(name),
|
|
5767
5822
|
start: pythonAppStartTarget(name)
|
|
5768
5823
|
});
|
|
@@ -5784,7 +5839,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
5784
5839
|
workspaceRoot
|
|
5785
5840
|
);
|
|
5786
5841
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
5787
|
-
addProjectJsonTargets((0,
|
|
5842
|
+
addProjectJsonTargets((0, import_node_path27.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
5788
5843
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
5789
5844
|
start: pythonFunctionAppStartTarget(name)
|
|
5790
5845
|
});
|
|
@@ -5825,7 +5880,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
5825
5880
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
5826
5881
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
5827
5882
|
return PYTHON_PROJECT_DIRS.find(
|
|
5828
|
-
(directory) => fileExists((0,
|
|
5883
|
+
(directory) => fileExists((0, import_node_path27.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
5829
5884
|
);
|
|
5830
5885
|
}
|
|
5831
5886
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -5864,7 +5919,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5864
5919
|
`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.`
|
|
5865
5920
|
);
|
|
5866
5921
|
}
|
|
5867
|
-
if (!fileExists((0,
|
|
5922
|
+
if (!fileExists((0, import_node_path27.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
5868
5923
|
throw new Error(
|
|
5869
5924
|
`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.`
|
|
5870
5925
|
);
|
|
@@ -5872,8 +5927,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5872
5927
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
5873
5928
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5874
5929
|
}
|
|
5875
|
-
const pyprojectPath = (0,
|
|
5876
|
-
const pyprojectToml = (0,
|
|
5930
|
+
const pyprojectPath = (0, import_node_path27.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
5931
|
+
const pyprojectToml = (0, import_node_fs26.readFileSync)(pyprojectPath, "utf8");
|
|
5877
5932
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5878
5933
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5879
5934
|
return;
|
|
@@ -5885,8 +5940,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5885
5940
|
}
|
|
5886
5941
|
|
|
5887
5942
|
// src/project-scaffolding/container.use-case.ts
|
|
5888
|
-
var
|
|
5889
|
-
var
|
|
5943
|
+
var import_node_fs27 = require("fs");
|
|
5944
|
+
var import_node_path28 = require("path");
|
|
5890
5945
|
|
|
5891
5946
|
// src/project-scaffolding/container-image.algorithm.ts
|
|
5892
5947
|
var CONTAINER_TARGETS = ["node-app", "react-app", "go-app"];
|
|
@@ -6015,16 +6070,16 @@ if (command === 'build') {
|
|
|
6015
6070
|
}
|
|
6016
6071
|
`;
|
|
6017
6072
|
function detectTarget(appRoot) {
|
|
6018
|
-
if (fileExists((0,
|
|
6019
|
-
return fileExists((0,
|
|
6073
|
+
if (fileExists((0, import_node_path28.join)(appRoot, "go.mod"))) {
|
|
6074
|
+
return fileExists((0, import_node_path28.join)(appRoot, "host.json")) ? void 0 : "go-app";
|
|
6020
6075
|
}
|
|
6021
|
-
const manifestPath = (0,
|
|
6022
|
-
if (!fileExists(manifestPath) || fileExists((0,
|
|
6076
|
+
const manifestPath = (0, import_node_path28.join)(appRoot, "package.json");
|
|
6077
|
+
if (!fileExists(manifestPath) || fileExists((0, import_node_path28.join)(appRoot, "host.json"))) {
|
|
6023
6078
|
return void 0;
|
|
6024
6079
|
}
|
|
6025
6080
|
const manifest = readJson(manifestPath);
|
|
6026
6081
|
const declared = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
6027
|
-
if (declared.includes("react") && fileExists((0,
|
|
6082
|
+
if (declared.includes("react") && fileExists((0, import_node_path28.join)(appRoot, "index.html"))) {
|
|
6028
6083
|
return "react-app";
|
|
6029
6084
|
}
|
|
6030
6085
|
return manifest.nx?.targets?.build?.executor === "@nx/esbuild:esbuild" ? "node-app" : void 0;
|
|
@@ -6052,7 +6107,7 @@ function containerTargets(name, appProject, plan) {
|
|
|
6052
6107
|
};
|
|
6053
6108
|
}
|
|
6054
6109
|
function addContainer(workspaceRoot, name, options) {
|
|
6055
|
-
const appRoot = (0,
|
|
6110
|
+
const appRoot = (0, import_node_path28.join)(workspaceRoot, "apps", options.app);
|
|
6056
6111
|
if (!fileExists(appRoot)) {
|
|
6057
6112
|
throw new Error(`--app ${options.app}: there is no apps/${options.app} to put in an image. Add the app first.`);
|
|
6058
6113
|
}
|
|
@@ -6061,17 +6116,17 @@ function addContainer(workspaceRoot, name, options) {
|
|
|
6061
6116
|
throw new Error(`--app ${options.app}: apps/${options.app} is not an app an image is built for (${CONTAINER_TARGETS.join(", ")}). An Azure Functions app has its own host image and is not supported yet.`);
|
|
6062
6117
|
}
|
|
6063
6118
|
const plan = planContainer(target, options.app, options.port);
|
|
6064
|
-
const appManifestPath = (0,
|
|
6119
|
+
const appManifestPath = (0, import_node_path28.join)(appRoot, "package.json");
|
|
6065
6120
|
const appProject = fileExists(appManifestPath) ? readJson(appManifestPath).name : options.app;
|
|
6066
6121
|
const scope = appProject.startsWith("@") ? `${appProject.split("/", 1)[0]}/` : "";
|
|
6067
|
-
const projectRoot = (0,
|
|
6068
|
-
writeFileEnsured((0,
|
|
6069
|
-
writeFileEnsured((0,
|
|
6122
|
+
const projectRoot = (0, import_node_path28.join)(workspaceRoot, "apps", name);
|
|
6123
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "Dockerfile"), plan.dockerfile);
|
|
6124
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "Dockerfile.dockerignore"), plan.dockerignore);
|
|
6070
6125
|
for (const [file, text] of Object.entries(plan.files)) {
|
|
6071
|
-
writeFileEnsured((0,
|
|
6126
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "files", file), text);
|
|
6072
6127
|
}
|
|
6073
|
-
writeFileEnsured((0,
|
|
6074
|
-
writeFileEnsured((0,
|
|
6128
|
+
writeFileEnsured((0, import_node_path28.join)(workspaceRoot, CONTAINER_SCRIPT_PATH), CONTAINER_SCRIPT);
|
|
6129
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "package.json"), toJson({
|
|
6075
6130
|
name: `${scope}${name}`,
|
|
6076
6131
|
version: "0.0.1",
|
|
6077
6132
|
private: true,
|
|
@@ -6087,16 +6142,16 @@ function addContainer(workspaceRoot, name, options) {
|
|
|
6087
6142
|
function refreshContainerScript(workspaceRoot) {
|
|
6088
6143
|
let entries;
|
|
6089
6144
|
try {
|
|
6090
|
-
entries = (0,
|
|
6145
|
+
entries = (0, import_node_fs27.readdirSync)((0, import_node_path28.join)(workspaceRoot, "apps"));
|
|
6091
6146
|
} catch {
|
|
6092
6147
|
return false;
|
|
6093
6148
|
}
|
|
6094
6149
|
const hasContainer = entries.some((entry) => {
|
|
6095
|
-
const manifestPath = (0,
|
|
6150
|
+
const manifestPath = (0, import_node_path28.join)(workspaceRoot, "apps", entry, "package.json");
|
|
6096
6151
|
return fileExists(manifestPath) && (readJson(manifestPath).nx?.tags ?? []).includes(CONTAINER_TAG);
|
|
6097
6152
|
});
|
|
6098
|
-
const path = (0,
|
|
6099
|
-
if (!hasContainer || fileExists(path) && (0,
|
|
6153
|
+
const path = (0, import_node_path28.join)(workspaceRoot, CONTAINER_SCRIPT_PATH);
|
|
6154
|
+
if (!hasContainer || fileExists(path) && (0, import_node_fs27.readFileSync)(path, "utf8") === CONTAINER_SCRIPT) {
|
|
6100
6155
|
return false;
|
|
6101
6156
|
}
|
|
6102
6157
|
writeFileEnsured(path, CONTAINER_SCRIPT);
|
|
@@ -6104,12 +6159,12 @@ function refreshContainerScript(workspaceRoot) {
|
|
|
6104
6159
|
}
|
|
6105
6160
|
|
|
6106
6161
|
// src/project-scaffolding/react-app.use-case.ts
|
|
6107
|
-
var
|
|
6108
|
-
var
|
|
6162
|
+
var import_node_fs29 = require("fs");
|
|
6163
|
+
var import_node_path31 = require("path");
|
|
6109
6164
|
|
|
6110
6165
|
// src/react-app-output/find-react-apps-sharing-output.use-case.ts
|
|
6111
|
-
var
|
|
6112
|
-
var
|
|
6166
|
+
var import_node_fs28 = require("fs");
|
|
6167
|
+
var import_node_path29 = require("path");
|
|
6113
6168
|
|
|
6114
6169
|
// src/react-app-output/react-app-output.policy.ts
|
|
6115
6170
|
var VITE_DEFAULT_OUT_DIR = "dist";
|
|
@@ -6127,14 +6182,14 @@ function sharesOutputFolder(typescriptOutDir, viteConfig) {
|
|
|
6127
6182
|
// src/react-app-output/find-react-apps-sharing-output.use-case.ts
|
|
6128
6183
|
var VITE_CONFIGS = ["vite.config.mts", "vite.config.ts", "vite.config.mjs", "vite.config.js"];
|
|
6129
6184
|
function appSharesOutputFolder(appRoot) {
|
|
6130
|
-
const config = VITE_CONFIGS.find((name) => fileExists((0,
|
|
6131
|
-
const tsconfigPath = (0,
|
|
6185
|
+
const config = VITE_CONFIGS.find((name) => fileExists((0, import_node_path29.join)(appRoot, name)));
|
|
6186
|
+
const tsconfigPath = (0, import_node_path29.join)(appRoot, "tsconfig.app.json");
|
|
6132
6187
|
if (config === void 0 || !fileExists(tsconfigPath)) {
|
|
6133
6188
|
return false;
|
|
6134
6189
|
}
|
|
6135
6190
|
try {
|
|
6136
6191
|
const outDir = readJson(tsconfigPath).compilerOptions?.outDir;
|
|
6137
|
-
return sharesOutputFolder(outDir, (0,
|
|
6192
|
+
return sharesOutputFolder(outDir, (0, import_node_fs28.readFileSync)((0, import_node_path29.join)(appRoot, config), "utf8"));
|
|
6138
6193
|
} catch {
|
|
6139
6194
|
return false;
|
|
6140
6195
|
}
|
|
@@ -6142,20 +6197,20 @@ function appSharesOutputFolder(appRoot) {
|
|
|
6142
6197
|
function findReactAppsSharingOutput(workspaceRoot) {
|
|
6143
6198
|
let entries;
|
|
6144
6199
|
try {
|
|
6145
|
-
entries = (0,
|
|
6200
|
+
entries = (0, import_node_fs28.readdirSync)((0, import_node_path29.join)(workspaceRoot, "apps"));
|
|
6146
6201
|
} catch {
|
|
6147
6202
|
return [];
|
|
6148
6203
|
}
|
|
6149
|
-
return entries.filter((entry) => appSharesOutputFolder((0,
|
|
6204
|
+
return entries.filter((entry) => appSharesOutputFolder((0, import_node_path29.join)(workspaceRoot, "apps", entry))).map((entry) => `apps/${entry}`).toSorted((a, b) => a.localeCompare(b));
|
|
6150
6205
|
}
|
|
6151
6206
|
|
|
6152
6207
|
// src/react-app-output/separate-react-app-output.use-case.ts
|
|
6153
|
-
var
|
|
6208
|
+
var import_node_path30 = require("path");
|
|
6154
6209
|
function separateReactAppOutput(appRoot) {
|
|
6155
6210
|
if (!appSharesOutputFolder(appRoot)) {
|
|
6156
6211
|
return false;
|
|
6157
6212
|
}
|
|
6158
|
-
const tsconfigPath = (0,
|
|
6213
|
+
const tsconfigPath = (0, import_node_path30.join)(appRoot, "tsconfig.app.json");
|
|
6159
6214
|
const tsconfig = readJson(tsconfigPath);
|
|
6160
6215
|
writeFileEnsured(tsconfigPath, toJson({
|
|
6161
6216
|
...tsconfig,
|
|
@@ -6166,7 +6221,7 @@ function separateReactAppOutput(appRoot) {
|
|
|
6166
6221
|
function separateReactAppsOutput(workspaceRoot) {
|
|
6167
6222
|
const repaired = [];
|
|
6168
6223
|
for (const dir of findReactAppsSharingOutput(workspaceRoot)) {
|
|
6169
|
-
if (separateReactAppOutput((0,
|
|
6224
|
+
if (separateReactAppOutput((0, import_node_path30.join)(workspaceRoot, dir))) {
|
|
6170
6225
|
repaired.push(dir);
|
|
6171
6226
|
}
|
|
6172
6227
|
}
|
|
@@ -6297,12 +6352,12 @@ function reactAppTargets(name) {
|
|
|
6297
6352
|
return targets;
|
|
6298
6353
|
}
|
|
6299
6354
|
function allowEnvFiles(workspaceRoot) {
|
|
6300
|
-
const gitignorePath = (0,
|
|
6355
|
+
const gitignorePath = (0, import_node_path31.join)(workspaceRoot, ".gitignore");
|
|
6301
6356
|
if (!fileExists(gitignorePath)) {
|
|
6302
6357
|
return;
|
|
6303
6358
|
}
|
|
6304
6359
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
6305
|
-
const current = (0,
|
|
6360
|
+
const current = (0, import_node_fs29.readFileSync)(gitignorePath, "utf8");
|
|
6306
6361
|
if (current.includes(marker)) {
|
|
6307
6362
|
return;
|
|
6308
6363
|
}
|
|
@@ -6329,18 +6384,18 @@ function addReactApp(workspaceRoot, name, stack, e2e = false) {
|
|
|
6329
6384
|
workspaceRoot
|
|
6330
6385
|
);
|
|
6331
6386
|
ensureAdmZip(workspaceRoot);
|
|
6332
|
-
const reactAppRoot = (0,
|
|
6387
|
+
const reactAppRoot = (0, import_node_path31.join)(workspaceRoot, "apps", name);
|
|
6333
6388
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
6334
|
-
writeFileEnsured((0,
|
|
6389
|
+
writeFileEnsured((0, import_node_path31.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
6335
6390
|
}
|
|
6336
6391
|
allowEnvFiles(workspaceRoot);
|
|
6337
|
-
addNxTargets((0,
|
|
6392
|
+
addNxTargets((0, import_node_path31.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
6338
6393
|
reshapeReactAppScaffold(reactAppRoot);
|
|
6339
6394
|
separateReactAppOutput(reactAppRoot);
|
|
6340
|
-
(0,
|
|
6395
|
+
(0, import_node_fs29.rmSync)((0, import_node_path31.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
6341
6396
|
const example = reactAppExampleFiles(name);
|
|
6342
6397
|
for (const [relative, contents] of Object.entries(example)) {
|
|
6343
|
-
writeFileEnsured((0,
|
|
6398
|
+
writeFileEnsured((0, import_node_path31.join)(reactAppRoot, "src", relative), contents);
|
|
6344
6399
|
}
|
|
6345
6400
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
6346
6401
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
@@ -6350,9 +6405,9 @@ function addReactApp(workspaceRoot, name, stack, e2e = false) {
|
|
|
6350
6405
|
}
|
|
6351
6406
|
function pairE2eProject(workspaceRoot, name) {
|
|
6352
6407
|
const e2eName = `${name}-e2e`;
|
|
6353
|
-
const e2eRoot = (0,
|
|
6354
|
-
(0,
|
|
6355
|
-
writeFileEnsured((0,
|
|
6408
|
+
const e2eRoot = (0, import_node_path31.join)(workspaceRoot, "apps", e2eName);
|
|
6409
|
+
(0, import_node_fs29.rmSync)((0, import_node_path31.join)(e2eRoot, "src/example.spec.ts"), { force: true });
|
|
6410
|
+
writeFileEnsured((0, import_node_path31.join)(e2eRoot, "src/greeting.e2e.spec.ts"), reactAppE2eSpec(name));
|
|
6356
6411
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${e2eName}`);
|
|
6357
6412
|
registerProjectCommands(workspaceRoot, e2eName, {
|
|
6358
6413
|
build: false,
|
|
@@ -6361,13 +6416,13 @@ function pairE2eProject(workspaceRoot, name) {
|
|
|
6361
6416
|
}
|
|
6362
6417
|
|
|
6363
6418
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
6364
|
-
var
|
|
6419
|
+
var import_node_path32 = require("path");
|
|
6365
6420
|
var REACT_LIB_BUNDLER = "rollup";
|
|
6366
6421
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
6367
6422
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
6368
6423
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
6369
|
-
const projectRoot = (0,
|
|
6370
|
-
const publishableManifest = (0,
|
|
6424
|
+
const projectRoot = (0, import_node_path32.join)(workspaceRoot, "packages", name);
|
|
6425
|
+
const publishableManifest = (0, import_node_path32.join)(projectRoot, "package.json");
|
|
6371
6426
|
runGeneratorAndRepair(
|
|
6372
6427
|
workspaceRoot,
|
|
6373
6428
|
[
|
|
@@ -6411,8 +6466,8 @@ function dropNxProjectName(manifestPath) {
|
|
|
6411
6466
|
}
|
|
6412
6467
|
function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
6413
6468
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
6414
|
-
const projectRoot = (0,
|
|
6415
|
-
const privateManifest = (0,
|
|
6469
|
+
const projectRoot = (0, import_node_path32.join)(workspaceRoot, "libs", name);
|
|
6470
|
+
const privateManifest = (0, import_node_path32.join)(projectRoot, "package.json");
|
|
6416
6471
|
runGeneratorAndRepair(
|
|
6417
6472
|
workspaceRoot,
|
|
6418
6473
|
[
|
|
@@ -6439,8 +6494,8 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
6439
6494
|
}
|
|
6440
6495
|
|
|
6441
6496
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
6442
|
-
var
|
|
6443
|
-
var
|
|
6497
|
+
var import_node_fs30 = require("fs");
|
|
6498
|
+
var import_node_path33 = require("path");
|
|
6444
6499
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
6445
6500
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
6446
6501
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -6625,8 +6680,8 @@ export const window = {
|
|
|
6625
6680
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
6626
6681
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
6627
6682
|
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}\` },`];
|
|
6628
|
-
const path = (0,
|
|
6629
|
-
const content = fileExists(path) ? (0,
|
|
6683
|
+
const path = (0, import_node_path33.join)(projectRoot, file);
|
|
6684
|
+
const content = fileExists(path) ? (0, import_node_fs30.readFileSync)(path, "utf8") : "";
|
|
6630
6685
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
6631
6686
|
if (line === void 0) {
|
|
6632
6687
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -6646,11 +6701,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
6646
6701
|
}
|
|
6647
6702
|
}
|
|
6648
6703
|
function defaultPublisher(workspaceRoot) {
|
|
6649
|
-
const { name } = readJson((0,
|
|
6704
|
+
const { name } = readJson((0, import_node_path33.join)(workspaceRoot, "package.json"));
|
|
6650
6705
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
6651
6706
|
}
|
|
6652
6707
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
6653
|
-
const manifestPath = (0,
|
|
6708
|
+
const manifestPath = (0, import_node_path33.join)(projectRoot, "package.json");
|
|
6654
6709
|
const manifest = readJson(manifestPath);
|
|
6655
6710
|
const { nx = {}, ...rest } = manifest;
|
|
6656
6711
|
const targets = { ...nx.targets };
|
|
@@ -6714,11 +6769,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
6714
6769
|
};
|
|
6715
6770
|
}
|
|
6716
6771
|
function addDebugLaunch(workspaceRoot, name) {
|
|
6717
|
-
const file = (0,
|
|
6772
|
+
const file = (0, import_node_fs30.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
6718
6773
|
if (file === void 0) {
|
|
6719
6774
|
return;
|
|
6720
6775
|
}
|
|
6721
|
-
const path = (0,
|
|
6776
|
+
const path = (0, import_node_path33.join)(workspaceRoot, file);
|
|
6722
6777
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
6723
6778
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
6724
6779
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -6751,39 +6806,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
6751
6806
|
);
|
|
6752
6807
|
}
|
|
6753
6808
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
6754
|
-
const apps = (0,
|
|
6809
|
+
const apps = (0, import_node_path33.join)(workspaceRoot, "apps");
|
|
6755
6810
|
let entries;
|
|
6756
6811
|
try {
|
|
6757
|
-
entries = (0,
|
|
6812
|
+
entries = (0, import_node_fs30.readdirSync)(apps);
|
|
6758
6813
|
} catch {
|
|
6759
6814
|
return false;
|
|
6760
6815
|
}
|
|
6761
6816
|
const hasExtension = entries.some((entry) => {
|
|
6762
|
-
const manifestPath = (0,
|
|
6817
|
+
const manifestPath = (0, import_node_path33.join)(apps, entry, "package.json");
|
|
6763
6818
|
if (!fileExists(manifestPath)) {
|
|
6764
6819
|
return false;
|
|
6765
6820
|
}
|
|
6766
6821
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
6767
6822
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
6768
6823
|
});
|
|
6769
|
-
const path = (0,
|
|
6770
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
6824
|
+
const path = (0, import_node_path33.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
6825
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs30.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
6771
6826
|
return false;
|
|
6772
6827
|
}
|
|
6773
6828
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
6774
6829
|
return true;
|
|
6775
6830
|
}
|
|
6776
6831
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
6777
|
-
const apps = (0,
|
|
6832
|
+
const apps = (0, import_node_path33.join)(workspaceRoot, "apps");
|
|
6778
6833
|
let entries;
|
|
6779
6834
|
try {
|
|
6780
|
-
entries = (0,
|
|
6835
|
+
entries = (0, import_node_fs30.readdirSync)(apps);
|
|
6781
6836
|
} catch {
|
|
6782
6837
|
return [];
|
|
6783
6838
|
}
|
|
6784
6839
|
const updated = [];
|
|
6785
6840
|
for (const entry of entries) {
|
|
6786
|
-
const manifestPath = (0,
|
|
6841
|
+
const manifestPath = (0, import_node_path33.join)(apps, entry, "package.json");
|
|
6787
6842
|
if (!fileExists(manifestPath)) {
|
|
6788
6843
|
continue;
|
|
6789
6844
|
}
|
|
@@ -6803,22 +6858,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
6803
6858
|
}
|
|
6804
6859
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
6805
6860
|
const { sidecar } = options;
|
|
6806
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
6861
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path33.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
6807
6862
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
6808
6863
|
}
|
|
6809
6864
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
6810
6865
|
ensureVscodeToolchain(workspaceRoot);
|
|
6811
|
-
const projectRoot = (0,
|
|
6866
|
+
const projectRoot = (0, import_node_path33.join)(workspaceRoot, "apps", name);
|
|
6812
6867
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
6813
|
-
addVscodeTypes((0,
|
|
6814
|
-
addVscodeTypes((0,
|
|
6815
|
-
writeFileEnsured((0,
|
|
6816
|
-
writeFileEnsured((0,
|
|
6817
|
-
writeFileEnsured((0,
|
|
6868
|
+
addVscodeTypes((0, import_node_path33.join)(projectRoot, "tsconfig.app.json"));
|
|
6869
|
+
addVscodeTypes((0, import_node_path33.join)(projectRoot, "tsconfig.spec.json"));
|
|
6870
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
6871
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
6872
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
6818
6873
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
6819
|
-
writeFileEnsured((0,
|
|
6820
|
-
writeFileEnsured((0,
|
|
6821
|
-
addNxTargets((0,
|
|
6874
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
6875
|
+
writeFileEnsured((0, import_node_path33.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
6876
|
+
addNxTargets((0, import_node_path33.join)(projectRoot, "package.json"), {
|
|
6822
6877
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
6823
6878
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
6824
6879
|
});
|
|
@@ -6829,12 +6884,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
6829
6884
|
}
|
|
6830
6885
|
|
|
6831
6886
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
6832
|
-
var
|
|
6833
|
-
var
|
|
6887
|
+
var import_node_fs32 = require("fs");
|
|
6888
|
+
var import_node_path35 = require("path");
|
|
6834
6889
|
|
|
6835
6890
|
// src/dependency-management/manifest.repository.ts
|
|
6836
|
-
var
|
|
6837
|
-
var
|
|
6891
|
+
var import_node_fs31 = require("fs");
|
|
6892
|
+
var import_node_path34 = require("path");
|
|
6838
6893
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
6839
6894
|
var ROOT_LABEL = "(root)";
|
|
6840
6895
|
var MANIFEST_GLOBS = {
|
|
@@ -6867,23 +6922,23 @@ function projectOf(manifestRelativePath) {
|
|
|
6867
6922
|
}
|
|
6868
6923
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
6869
6924
|
if (ecosystem === "go") {
|
|
6870
|
-
return fileExists((0,
|
|
6925
|
+
return fileExists((0, import_node_path34.join)(workspaceRoot, "go.mod"));
|
|
6871
6926
|
}
|
|
6872
6927
|
if (ecosystem === "nuget") {
|
|
6873
|
-
return (0,
|
|
6928
|
+
return (0, import_node_fs31.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
6874
6929
|
}
|
|
6875
6930
|
const rootMarker = {
|
|
6876
6931
|
npm: "package.json",
|
|
6877
6932
|
pip: "requirements-dev.txt",
|
|
6878
6933
|
pub: "pubspec.yaml"
|
|
6879
6934
|
};
|
|
6880
|
-
return fileExists((0,
|
|
6935
|
+
return fileExists((0, import_node_path34.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs31.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
6881
6936
|
}
|
|
6882
6937
|
function collectNpm(workspaceRoot) {
|
|
6883
6938
|
const sites = [];
|
|
6884
|
-
const relativePaths = ["package.json", ...(0,
|
|
6939
|
+
const relativePaths = ["package.json", ...(0, import_node_fs31.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
6885
6940
|
for (const relativePath of relativePaths) {
|
|
6886
|
-
const manifestPath = (0,
|
|
6941
|
+
const manifestPath = (0, import_node_path34.join)(workspaceRoot, relativePath);
|
|
6887
6942
|
try {
|
|
6888
6943
|
const manifest = readJson(manifestPath);
|
|
6889
6944
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -6944,17 +6999,17 @@ function collectPip(workspaceRoot) {
|
|
|
6944
6999
|
name: parsed.name,
|
|
6945
7000
|
ecosystem: "pip",
|
|
6946
7001
|
project: projectOf(relativePath),
|
|
6947
|
-
manifestPath: (0,
|
|
7002
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
6948
7003
|
section,
|
|
6949
7004
|
spec: parsed.spec,
|
|
6950
7005
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
6951
7006
|
});
|
|
6952
7007
|
};
|
|
6953
|
-
const pyprojectPaths = (0,
|
|
7008
|
+
const pyprojectPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
6954
7009
|
for (const relativePath of pyprojectPaths) {
|
|
6955
7010
|
let content;
|
|
6956
7011
|
try {
|
|
6957
|
-
content = (0,
|
|
7012
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
6958
7013
|
} catch {
|
|
6959
7014
|
continue;
|
|
6960
7015
|
}
|
|
@@ -6965,14 +7020,14 @@ function collectPip(workspaceRoot) {
|
|
|
6965
7020
|
}
|
|
6966
7021
|
const requirementsPaths = [
|
|
6967
7022
|
"requirements-dev.txt",
|
|
6968
|
-
...(0,
|
|
7023
|
+
...(0, import_node_fs31.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
6969
7024
|
];
|
|
6970
7025
|
for (const relativePath of requirementsPaths) {
|
|
6971
|
-
if (!fileExists((0,
|
|
7026
|
+
if (!fileExists((0, import_node_path34.join)(workspaceRoot, relativePath))) {
|
|
6972
7027
|
continue;
|
|
6973
7028
|
}
|
|
6974
7029
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
6975
|
-
const lines = (0,
|
|
7030
|
+
const lines = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
6976
7031
|
for (const line of lines) {
|
|
6977
7032
|
push(relativePath, section, line);
|
|
6978
7033
|
}
|
|
@@ -7010,11 +7065,11 @@ function pyprojectDependencies(content) {
|
|
|
7010
7065
|
}
|
|
7011
7066
|
function collectPub(workspaceRoot) {
|
|
7012
7067
|
const sites = [];
|
|
7013
|
-
const pubspecPaths = (0,
|
|
7068
|
+
const pubspecPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
7014
7069
|
for (const relativePath of pubspecPaths) {
|
|
7015
7070
|
let content;
|
|
7016
7071
|
try {
|
|
7017
|
-
content = (0,
|
|
7072
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
7018
7073
|
} catch {
|
|
7019
7074
|
continue;
|
|
7020
7075
|
}
|
|
@@ -7024,7 +7079,7 @@ function collectPub(workspaceRoot) {
|
|
|
7024
7079
|
name: entry.name,
|
|
7025
7080
|
ecosystem: "pub",
|
|
7026
7081
|
project: projectOf(relativePath),
|
|
7027
|
-
manifestPath: (0,
|
|
7082
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
7028
7083
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
7029
7084
|
spec: entry.spec,
|
|
7030
7085
|
rewritable: entry.spec !== ""
|
|
@@ -7074,11 +7129,11 @@ function stripQuotes(value) {
|
|
|
7074
7129
|
}
|
|
7075
7130
|
function collectNuget(workspaceRoot) {
|
|
7076
7131
|
const sites = [];
|
|
7077
|
-
const csprojPaths = (0,
|
|
7132
|
+
const csprojPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
7078
7133
|
for (const relativePath of csprojPaths) {
|
|
7079
7134
|
let content;
|
|
7080
7135
|
try {
|
|
7081
|
-
content = (0,
|
|
7136
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
7082
7137
|
} catch {
|
|
7083
7138
|
continue;
|
|
7084
7139
|
}
|
|
@@ -7087,7 +7142,7 @@ function collectNuget(workspaceRoot) {
|
|
|
7087
7142
|
name: entry.name,
|
|
7088
7143
|
ecosystem: "nuget",
|
|
7089
7144
|
project: projectOf(relativePath),
|
|
7090
|
-
manifestPath: (0,
|
|
7145
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
7091
7146
|
section: "dep",
|
|
7092
7147
|
spec: entry.spec,
|
|
7093
7148
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -7112,13 +7167,13 @@ function csprojPackageReferences(content) {
|
|
|
7112
7167
|
return entries;
|
|
7113
7168
|
}
|
|
7114
7169
|
function collectGo(workspaceRoot) {
|
|
7115
|
-
const manifestPath = (0,
|
|
7170
|
+
const manifestPath = (0, import_node_path34.join)(workspaceRoot, "go.mod");
|
|
7116
7171
|
if (!fileExists(manifestPath)) {
|
|
7117
7172
|
return [];
|
|
7118
7173
|
}
|
|
7119
7174
|
let content;
|
|
7120
7175
|
try {
|
|
7121
|
-
content = (0,
|
|
7176
|
+
content = (0, import_node_fs31.readFileSync)(manifestPath, "utf8");
|
|
7122
7177
|
} catch {
|
|
7123
7178
|
return [];
|
|
7124
7179
|
}
|
|
@@ -7167,7 +7222,7 @@ var PROJECT_GLOBS = {
|
|
|
7167
7222
|
function locateProjects(workspaceRoot) {
|
|
7168
7223
|
const locations = [];
|
|
7169
7224
|
for (const ecosystem of ECOSYSTEMS) {
|
|
7170
|
-
const relativePaths = (0,
|
|
7225
|
+
const relativePaths = (0, import_node_fs31.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
7171
7226
|
for (const relativePath of relativePaths) {
|
|
7172
7227
|
const posix = toPosix(relativePath);
|
|
7173
7228
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -7175,7 +7230,7 @@ function locateProjects(workspaceRoot) {
|
|
|
7175
7230
|
ecosystem,
|
|
7176
7231
|
dir,
|
|
7177
7232
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
7178
|
-
manifestPath: (0,
|
|
7233
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath)
|
|
7179
7234
|
});
|
|
7180
7235
|
}
|
|
7181
7236
|
}
|
|
@@ -7196,7 +7251,7 @@ function rewriteSpec(site, spec) {
|
|
|
7196
7251
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
7197
7252
|
return true;
|
|
7198
7253
|
}
|
|
7199
|
-
const before = (0,
|
|
7254
|
+
const before = (0, import_node_fs31.readFileSync)(site.manifestPath, "utf8");
|
|
7200
7255
|
const after = (() => {
|
|
7201
7256
|
switch (site.ecosystem) {
|
|
7202
7257
|
case "pip": {
|
|
@@ -7287,13 +7342,13 @@ function escapeForRegex(value) {
|
|
|
7287
7342
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
7288
7343
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
7289
7344
|
return ["apps", "libs", "packages"].some(
|
|
7290
|
-
(directory) => fileExists((0,
|
|
7345
|
+
(directory) => fileExists((0, import_node_path34.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
7291
7346
|
);
|
|
7292
7347
|
}
|
|
7293
7348
|
function isAliasedInstall(workspaceRoot, name) {
|
|
7294
7349
|
try {
|
|
7295
7350
|
const installed = readJson(
|
|
7296
|
-
(0,
|
|
7351
|
+
(0, import_node_path34.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
7297
7352
|
);
|
|
7298
7353
|
return installed.name !== void 0 && installed.name !== name;
|
|
7299
7354
|
} catch {
|
|
@@ -7304,14 +7359,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
7304
7359
|
if (ecosystem === "npm") {
|
|
7305
7360
|
try {
|
|
7306
7361
|
return readJson(
|
|
7307
|
-
(0,
|
|
7362
|
+
(0, import_node_path34.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
7308
7363
|
).version;
|
|
7309
7364
|
} catch {
|
|
7310
7365
|
return void 0;
|
|
7311
7366
|
}
|
|
7312
7367
|
}
|
|
7313
7368
|
if (ecosystem === "pub") {
|
|
7314
|
-
const lockPath = (0,
|
|
7369
|
+
const lockPath = (0, import_node_path34.join)(workspaceRoot, "pubspec.lock");
|
|
7315
7370
|
if (!fileExists(lockPath)) {
|
|
7316
7371
|
return void 0;
|
|
7317
7372
|
}
|
|
@@ -7319,7 +7374,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
7319
7374
|
const match = new RegExp(
|
|
7320
7375
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
7321
7376
|
"m"
|
|
7322
|
-
).exec((0,
|
|
7377
|
+
).exec((0, import_node_fs31.readFileSync)(lockPath, "utf8"));
|
|
7323
7378
|
return match?.[1];
|
|
7324
7379
|
} catch {
|
|
7325
7380
|
return void 0;
|
|
@@ -7385,7 +7440,7 @@ function resolveTarget(locations, target) {
|
|
|
7385
7440
|
return byName[0];
|
|
7386
7441
|
}
|
|
7387
7442
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
7388
|
-
const projectDir = (0,
|
|
7443
|
+
const projectDir = (0, import_node_path35.join)(workspaceRoot, location.dir);
|
|
7389
7444
|
switch (location.ecosystem) {
|
|
7390
7445
|
case "npm": {
|
|
7391
7446
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -7438,7 +7493,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
7438
7493
|
function addPythonDependency(manifestPath, specifier) {
|
|
7439
7494
|
let content;
|
|
7440
7495
|
try {
|
|
7441
|
-
content = (0,
|
|
7496
|
+
content = (0, import_node_fs32.readFileSync)(manifestPath, "utf8");
|
|
7442
7497
|
} catch {
|
|
7443
7498
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
7444
7499
|
return;
|
|
@@ -7467,7 +7522,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
7467
7522
|
}
|
|
7468
7523
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
7469
7524
|
if (ecosystem === "go") {
|
|
7470
|
-
return fileExists((0,
|
|
7525
|
+
return fileExists((0, import_node_path35.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path35.join)(workspaceRoot, "go.mod"));
|
|
7471
7526
|
}
|
|
7472
7527
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
7473
7528
|
}
|
|
@@ -7486,7 +7541,7 @@ function splitAtLast(value, separator) {
|
|
|
7486
7541
|
}
|
|
7487
7542
|
|
|
7488
7543
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
7489
|
-
var
|
|
7544
|
+
var import_node_path36 = require("path");
|
|
7490
7545
|
|
|
7491
7546
|
// src/dependency-management/semver.algorithm.ts
|
|
7492
7547
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -7663,7 +7718,7 @@ function describe(finding) {
|
|
|
7663
7718
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
7664
7719
|
}
|
|
7665
7720
|
function runSync(workspaceRoot, options) {
|
|
7666
|
-
if (!fileExists((0,
|
|
7721
|
+
if (!fileExists((0, import_node_path36.join)(workspaceRoot, "nx.json"))) {
|
|
7667
7722
|
throw new Error(
|
|
7668
7723
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
7669
7724
|
);
|
|
@@ -7713,7 +7768,7 @@ function runSync(workspaceRoot, options) {
|
|
|
7713
7768
|
}
|
|
7714
7769
|
|
|
7715
7770
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
7716
|
-
var
|
|
7771
|
+
var import_node_path37 = require("path");
|
|
7717
7772
|
var import_prompts2 = require("@inquirer/prompts");
|
|
7718
7773
|
|
|
7719
7774
|
// src/dependency-management/registry.client.ts
|
|
@@ -7996,7 +8051,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
7996
8051
|
function hasPythonInstallScript(workspaceRoot) {
|
|
7997
8052
|
try {
|
|
7998
8053
|
const manifest = readJson(
|
|
7999
|
-
(0,
|
|
8054
|
+
(0, import_node_path37.join)(workspaceRoot, "package.json")
|
|
8000
8055
|
);
|
|
8001
8056
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
8002
8057
|
} catch {
|
|
@@ -8012,7 +8067,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
8012
8067
|
}
|
|
8013
8068
|
}
|
|
8014
8069
|
async function runUp(workspaceRoot, options) {
|
|
8015
|
-
if (!fileExists((0,
|
|
8070
|
+
if (!fileExists((0, import_node_path37.join)(workspaceRoot, "nx.json"))) {
|
|
8016
8071
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
8017
8072
|
}
|
|
8018
8073
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -8090,7 +8145,7 @@ var PROJECT_KINDS = [
|
|
|
8090
8145
|
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
8091
8146
|
async function runAdd(kind, name, options) {
|
|
8092
8147
|
const workspaceRoot = process.cwd();
|
|
8093
|
-
if (!fileExists((0,
|
|
8148
|
+
if (!fileExists((0, import_node_path38.join)(workspaceRoot, "nx.json"))) {
|
|
8094
8149
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
8095
8150
|
}
|
|
8096
8151
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -8175,8 +8230,8 @@ async function runAdd(kind, name, options) {
|
|
|
8175
8230
|
],
|
|
8176
8231
|
workspaceRoot
|
|
8177
8232
|
);
|
|
8178
|
-
markPrivate((0,
|
|
8179
|
-
renameScaffoldPlaceholder((0,
|
|
8233
|
+
markPrivate((0, import_node_path38.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
8234
|
+
renameScaffoldPlaceholder((0, import_node_path38.join)(workspaceRoot, "libs", resolvedName), resolvedName, options.empty === true);
|
|
8180
8235
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
8181
8236
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
8182
8237
|
break;
|
|
@@ -8272,7 +8327,7 @@ async function runAdd(kind, name, options) {
|
|
|
8272
8327
|
}
|
|
8273
8328
|
function readWorkspaceStack(workspaceRoot) {
|
|
8274
8329
|
const nxJson = readJson(
|
|
8275
|
-
(0,
|
|
8330
|
+
(0, import_node_path38.join)(workspaceRoot, "nx.json")
|
|
8276
8331
|
);
|
|
8277
8332
|
const stack = nxJson.mnci?.stack;
|
|
8278
8333
|
return {
|
|
@@ -8361,11 +8416,11 @@ function spawnProject(workspaceRoot, project, target, onLine) {
|
|
|
8361
8416
|
}
|
|
8362
8417
|
|
|
8363
8418
|
// src/dev-servers/startable-projects.use-case.ts
|
|
8364
|
-
var
|
|
8419
|
+
var import_node_path39 = require("path");
|
|
8365
8420
|
var START_SUFFIX = ":start";
|
|
8366
8421
|
var NX_RUN = /\bnx run [^\s:]+:(\S+)/;
|
|
8367
8422
|
function listStartableProjects(workspaceRoot) {
|
|
8368
|
-
const manifestPath = (0,
|
|
8423
|
+
const manifestPath = (0, import_node_path39.join)(workspaceRoot, "package.json");
|
|
8369
8424
|
if (!fileExists(manifestPath)) {
|
|
8370
8425
|
return [];
|
|
8371
8426
|
}
|
|
@@ -8438,8 +8493,8 @@ async function runDev(workspaceRoot, named, options = {}, dependencies = {}) {
|
|
|
8438
8493
|
|
|
8439
8494
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
8440
8495
|
var import_node_child_process2 = require("child_process");
|
|
8441
|
-
var
|
|
8442
|
-
var
|
|
8496
|
+
var import_node_fs34 = require("fs");
|
|
8497
|
+
var import_node_path41 = require("path");
|
|
8443
8498
|
|
|
8444
8499
|
// src/workspace-diagnostics/check-react-app-output.use-case.ts
|
|
8445
8500
|
function checkReactAppOutput(workspaceRoot) {
|
|
@@ -8471,8 +8526,8 @@ function createBaselineTags(repositoryRoot, stranded) {
|
|
|
8471
8526
|
}
|
|
8472
8527
|
|
|
8473
8528
|
// src/release-tag-lineage/locate-stranded-release-tags.use-case.ts
|
|
8474
|
-
var
|
|
8475
|
-
var
|
|
8529
|
+
var import_node_fs33 = require("fs");
|
|
8530
|
+
var import_node_path40 = require("path");
|
|
8476
8531
|
|
|
8477
8532
|
// src/release-tag-lineage/stranded-release-tags.algorithm.ts
|
|
8478
8533
|
function compareVersions2(left, right) {
|
|
@@ -8509,7 +8564,7 @@ function locateStrandedReleaseTags(workspaceRoot, tagPattern) {
|
|
|
8509
8564
|
if (listed.status !== 0) {
|
|
8510
8565
|
return [];
|
|
8511
8566
|
}
|
|
8512
|
-
const projects = (0,
|
|
8567
|
+
const projects = (0, import_node_fs33.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot }).map((path) => readJson((0, import_node_path40.join)(workspaceRoot, path))).filter((manifest) => manifest.private !== true && manifest.name !== void 0).map((manifest) => manifest.name);
|
|
8513
8568
|
return findStrandedReleaseTags(projects, listed.stdout.split(/\r?\n/).filter(Boolean));
|
|
8514
8569
|
}
|
|
8515
8570
|
|
|
@@ -8530,8 +8585,8 @@ function toPosix2(path) {
|
|
|
8530
8585
|
return path.replaceAll("\\", "/");
|
|
8531
8586
|
}
|
|
8532
8587
|
function checkEslintConfigs(workspaceRoot) {
|
|
8533
|
-
const rootConfigs = (0,
|
|
8534
|
-
const projectConfigs = (0,
|
|
8588
|
+
const rootConfigs = (0, import_node_fs34.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
8589
|
+
const projectConfigs = (0, import_node_fs34.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
8535
8590
|
cwd: workspaceRoot
|
|
8536
8591
|
}).map((config) => toPosix2(config));
|
|
8537
8592
|
return [
|
|
@@ -8551,10 +8606,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
8551
8606
|
];
|
|
8552
8607
|
}
|
|
8553
8608
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
8554
|
-
const rules = (0,
|
|
8555
|
-
if (!(0,
|
|
8556
|
-
const entryPoint = (0,
|
|
8557
|
-
const source = (0,
|
|
8609
|
+
const rules = (0, import_node_path41.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
8610
|
+
if (!(0, import_node_fs34.existsSync)(rules)) return [];
|
|
8611
|
+
const entryPoint = (0, import_node_path41.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
8612
|
+
const source = (0, import_node_fs34.existsSync)(entryPoint) ? (0, import_node_fs34.readFileSync)(entryPoint, "utf8") : "";
|
|
8558
8613
|
return [
|
|
8559
8614
|
{
|
|
8560
8615
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -8567,7 +8622,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
8567
8622
|
function declaredDevDependencies(workspaceRoot) {
|
|
8568
8623
|
try {
|
|
8569
8624
|
const manifest = readJson(
|
|
8570
|
-
(0,
|
|
8625
|
+
(0, import_node_path41.join)(workspaceRoot, "package.json")
|
|
8571
8626
|
);
|
|
8572
8627
|
return manifest.devDependencies ?? {};
|
|
8573
8628
|
} catch {
|
|
@@ -8575,7 +8630,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
8575
8630
|
}
|
|
8576
8631
|
}
|
|
8577
8632
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
8578
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
8633
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path41.join)(workspaceRoot, file)));
|
|
8579
8634
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
8580
8635
|
const stale = [...files, ...declared];
|
|
8581
8636
|
if (stale.length === 0) {
|
|
@@ -8601,7 +8656,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
8601
8656
|
};
|
|
8602
8657
|
}
|
|
8603
8658
|
function checkResolvedEslint(workspaceRoot) {
|
|
8604
|
-
const manifestPath = (0,
|
|
8659
|
+
const manifestPath = (0, import_node_path41.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
8605
8660
|
if (!fileExists(manifestPath)) {
|
|
8606
8661
|
return void 0;
|
|
8607
8662
|
}
|
|
@@ -8619,11 +8674,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
8619
8674
|
}
|
|
8620
8675
|
}
|
|
8621
8676
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
8622
|
-
const npmrcPath = (0,
|
|
8677
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8623
8678
|
if (!registry || !fileExists(npmrcPath)) {
|
|
8624
8679
|
return void 0;
|
|
8625
8680
|
}
|
|
8626
|
-
const npmrc = (0,
|
|
8681
|
+
const npmrc = (0, import_node_fs34.readFileSync)(npmrcPath, "utf8");
|
|
8627
8682
|
if (registry.kind === "npm") {
|
|
8628
8683
|
return {
|
|
8629
8684
|
check: ".npmrc authenticates the public registry",
|
|
@@ -8640,11 +8695,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
8640
8695
|
};
|
|
8641
8696
|
}
|
|
8642
8697
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
8643
|
-
const npmrcPath = (0,
|
|
8698
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8644
8699
|
if (!fileExists(npmrcPath)) {
|
|
8645
8700
|
return void 0;
|
|
8646
8701
|
}
|
|
8647
|
-
const npmrc = (0,
|
|
8702
|
+
const npmrc = (0, import_node_fs34.readFileSync)(npmrcPath, "utf8");
|
|
8648
8703
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
8649
8704
|
const referenced = [
|
|
8650
8705
|
...new Set(
|
|
@@ -8668,13 +8723,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
8668
8723
|
};
|
|
8669
8724
|
}
|
|
8670
8725
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
8671
|
-
const npmrcPath = (0,
|
|
8672
|
-
const pipelinePath = (0,
|
|
8726
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8727
|
+
const pipelinePath = (0, import_node_path41.join)(workspaceRoot, "azure-pipelines.yml");
|
|
8673
8728
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
8674
8729
|
return void 0;
|
|
8675
8730
|
}
|
|
8676
|
-
const holdsCredentials = (0,
|
|
8677
|
-
const runsTask = (0,
|
|
8731
|
+
const holdsCredentials = (0, import_node_fs34.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
8732
|
+
const runsTask = (0, import_node_fs34.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
8678
8733
|
if (!holdsCredentials && !runsTask) {
|
|
8679
8734
|
return {
|
|
8680
8735
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -8719,13 +8774,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
8719
8774
|
}
|
|
8720
8775
|
function checkVersionActions(workspaceRoot) {
|
|
8721
8776
|
const candidates = [
|
|
8722
|
-
...(0,
|
|
8723
|
-
...(0,
|
|
8724
|
-
...(0,
|
|
8777
|
+
...(0, import_node_fs34.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
8778
|
+
...(0, import_node_fs34.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
8779
|
+
...(0, import_node_fs34.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
8725
8780
|
].map((manifest) => toPosix2(manifest));
|
|
8726
8781
|
return candidates.flatMap((manifest) => {
|
|
8727
8782
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
8728
|
-
const projectJsonPath = (0,
|
|
8783
|
+
const projectJsonPath = (0, import_node_path41.join)(workspaceRoot, projectRoot, "project.json");
|
|
8729
8784
|
let hasOverride = false;
|
|
8730
8785
|
try {
|
|
8731
8786
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -8754,7 +8809,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
8754
8809
|
]) {
|
|
8755
8810
|
try {
|
|
8756
8811
|
const targets = extract(
|
|
8757
|
-
readJson((0,
|
|
8812
|
+
readJson((0, import_node_path41.join)(workspaceRoot, projectRoot, file))
|
|
8758
8813
|
);
|
|
8759
8814
|
if (targets && typeof targets === "object") {
|
|
8760
8815
|
sources.push({
|
|
@@ -8770,8 +8825,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
8770
8825
|
function checkTargetFilesExist(workspaceRoot) {
|
|
8771
8826
|
const projectRoots = new Set(
|
|
8772
8827
|
[
|
|
8773
|
-
...(0,
|
|
8774
|
-
...(0,
|
|
8828
|
+
...(0, import_node_fs34.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
8829
|
+
...(0, import_node_fs34.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
8775
8830
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
8776
8831
|
);
|
|
8777
8832
|
return [...projectRoots].flatMap(
|
|
@@ -8786,7 +8841,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
8786
8841
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
8787
8842
|
const value = target?.options?.[option];
|
|
8788
8843
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
8789
|
-
if (!checkable || fileExists((0,
|
|
8844
|
+
if (!checkable || fileExists((0, import_node_path41.join)(workspaceRoot, value))) {
|
|
8790
8845
|
return [];
|
|
8791
8846
|
}
|
|
8792
8847
|
return [
|
|
@@ -8825,15 +8880,12 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
8825
8880
|
};
|
|
8826
8881
|
}
|
|
8827
8882
|
function checkGoWorkInSync(workspaceRoot) {
|
|
8828
|
-
const goWorkPath = (0,
|
|
8883
|
+
const goWorkPath = (0, import_node_path41.join)(workspaceRoot, "go.work");
|
|
8829
8884
|
if (!fileExists(goWorkPath)) {
|
|
8830
8885
|
return void 0;
|
|
8831
8886
|
}
|
|
8832
|
-
const
|
|
8833
|
-
const
|
|
8834
|
-
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
8835
|
-
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
8836
|
-
const stale = uses.filter((entry) => !(0, import_node_fs33.existsSync)((0, import_node_path40.join)(workspaceRoot, entry, "go.mod")));
|
|
8887
|
+
const uses = parseGoWorkUses((0, import_node_fs34.readFileSync)(goWorkPath, "utf8"));
|
|
8888
|
+
const stale = uses.filter((entry) => !(0, import_node_fs34.existsSync)((0, import_node_path41.join)(workspaceRoot, entry, "go.mod")));
|
|
8837
8889
|
return {
|
|
8838
8890
|
check: "every go.work `use` entry points to a module that still exists",
|
|
8839
8891
|
ok: stale.length === 0,
|
|
@@ -8849,9 +8901,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
8849
8901
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
8850
8902
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
8851
8903
|
];
|
|
8852
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
8904
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path41.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
8853
8905
|
check: `${file} builds the native apps on every OS`,
|
|
8854
|
-
ok: (0,
|
|
8906
|
+
ok: (0, import_node_fs34.readFileSync)((0, import_node_path41.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
8855
8907
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
8856
8908
|
remedy: "run `mnci upgrade`"
|
|
8857
8909
|
}));
|
|
@@ -8864,7 +8916,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
8864
8916
|
return findings;
|
|
8865
8917
|
}
|
|
8866
8918
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
8867
|
-
const manifestPath = (0,
|
|
8919
|
+
const manifestPath = (0, import_node_path41.join)(workspaceRoot, "package.json");
|
|
8868
8920
|
if (!fileExists(manifestPath)) {
|
|
8869
8921
|
return void 0;
|
|
8870
8922
|
}
|
|
@@ -8884,14 +8936,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
8884
8936
|
};
|
|
8885
8937
|
}
|
|
8886
8938
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
8887
|
-
const configs = (0,
|
|
8939
|
+
const configs = (0, import_node_fs34.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
8888
8940
|
cwd: workspaceRoot
|
|
8889
8941
|
}).map((config) => toPosix2(config));
|
|
8890
8942
|
return configs.flatMap((relativePath) => {
|
|
8891
|
-
const configPath = (0,
|
|
8943
|
+
const configPath = (0, import_node_path41.join)(workspaceRoot, relativePath);
|
|
8892
8944
|
let config;
|
|
8893
8945
|
try {
|
|
8894
|
-
config = (0,
|
|
8946
|
+
config = (0, import_node_fs34.readFileSync)(configPath, "utf8");
|
|
8895
8947
|
} catch {
|
|
8896
8948
|
return [];
|
|
8897
8949
|
}
|
|
@@ -8906,11 +8958,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
8906
8958
|
});
|
|
8907
8959
|
}
|
|
8908
8960
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
8909
|
-
const configs = (0,
|
|
8961
|
+
const configs = (0, import_node_fs34.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
8910
8962
|
cwd: workspaceRoot
|
|
8911
8963
|
}).map((config) => toPosix2(config));
|
|
8912
8964
|
return configs.flatMap((relativePath) => {
|
|
8913
|
-
const configPath = (0,
|
|
8965
|
+
const configPath = (0, import_node_path41.join)(workspaceRoot, relativePath);
|
|
8914
8966
|
if (!fileExists(configPath)) {
|
|
8915
8967
|
return [];
|
|
8916
8968
|
}
|
|
@@ -8925,7 +8977,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
8925
8977
|
// `plugins` array (what @nx/react:library writes). For any other shape it would no-op, and
|
|
8926
8978
|
// naming a command that silently does nothing is the failure mode the source-map check
|
|
8927
8979
|
// above goes out of its way to avoid, so the remedy depends on the shape.
|
|
8928
|
-
remedy: canAddDeclarationSpecifierPlugin((0,
|
|
8980
|
+
remedy: canAddDeclarationSpecifierPlugin((0, import_node_fs34.readFileSync)(configPath, "utf8")) ? "run `mnci upgrade`, which adds the plugin to the plugins array of withNx's second argument" : "add the plugin to withNx's second argument by hand (copy it from a freshly `mnci add npm-lib`'d project) \u2014 mnci does not recognise the shape of this config, so `mnci upgrade` cannot add it"
|
|
8929
8981
|
}
|
|
8930
8982
|
];
|
|
8931
8983
|
}
|
|
@@ -8941,8 +8993,8 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
8941
8993
|
}
|
|
8942
8994
|
function checkPipelinePhases(workspaceRoot) {
|
|
8943
8995
|
const files = ["azure-pipelines.yml", ".github/workflows/ci.yml"];
|
|
8944
|
-
return files.filter((file) => fileExists((0,
|
|
8945
|
-
const { verifyActive, switchedOff } = inspectPipeline((0,
|
|
8996
|
+
return files.filter((file) => fileExists((0, import_node_path41.join)(workspaceRoot, file))).flatMap((file) => {
|
|
8997
|
+
const { verifyActive, switchedOff } = inspectPipeline((0, import_node_fs34.readFileSync)((0, import_node_path41.join)(workspaceRoot, file), "utf8"));
|
|
8946
8998
|
const verify = {
|
|
8947
8999
|
check: `${file} runs the enforced verify phase`,
|
|
8948
9000
|
ok: verifyActive,
|
|
@@ -8983,7 +9035,7 @@ function checkDependencyRangesNotPreserved(nxJson) {
|
|
|
8983
9035
|
};
|
|
8984
9036
|
}
|
|
8985
9037
|
function checkLockfileHasNoLocalRegistry(workspaceRoot) {
|
|
8986
|
-
if (!fileExists((0,
|
|
9038
|
+
if (!fileExists((0, import_node_path41.join)(workspaceRoot, "package-lock.json"))) {
|
|
8987
9039
|
return void 0;
|
|
8988
9040
|
}
|
|
8989
9041
|
return {
|
|
@@ -8994,7 +9046,7 @@ function checkLockfileHasNoLocalRegistry(workspaceRoot) {
|
|
|
8994
9046
|
};
|
|
8995
9047
|
}
|
|
8996
9048
|
function collectFindings(workspaceRoot) {
|
|
8997
|
-
const nxJsonPath = (0,
|
|
9049
|
+
const nxJsonPath = (0, import_node_path41.join)(workspaceRoot, "nx.json");
|
|
8998
9050
|
if (!fileExists(nxJsonPath)) {
|
|
8999
9051
|
throw new Error(
|
|
9000
9052
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -9060,8 +9112,8 @@ function runDoctor(workspaceRoot, options = {}) {
|
|
|
9060
9112
|
}
|
|
9061
9113
|
|
|
9062
9114
|
// src/dependency-adoption/adopt-dependencies.use-case.ts
|
|
9063
|
-
var
|
|
9064
|
-
var
|
|
9115
|
+
var import_node_fs35 = require("fs");
|
|
9116
|
+
var import_node_path42 = require("path");
|
|
9065
9117
|
|
|
9066
9118
|
// src/clean-working-tree/clean-working-tree.validator.ts
|
|
9067
9119
|
function requireCleanWorkingTree(repositoryRoot, capture = runCapture) {
|
|
@@ -9132,7 +9184,7 @@ var SOURCE_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
|
9132
9184
|
var TEST_FILE = /\.(?:spec|test)\.[^.]+$|[\\/](?:__tests__|tests?|e2e)[\\/]/;
|
|
9133
9185
|
var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", "out", ".git", ".nx", "tmp"]);
|
|
9134
9186
|
function sourceFiles(directory, relative = "") {
|
|
9135
|
-
const entries = (0,
|
|
9187
|
+
const entries = (0, import_node_fs35.readdirSync)((0, import_node_path42.join)(directory, relative), { withFileTypes: true });
|
|
9136
9188
|
const found = [];
|
|
9137
9189
|
for (const entry of entries) {
|
|
9138
9190
|
const path = relative === "" ? entry.name : `${relative}/${entry.name}`;
|
|
@@ -9148,7 +9200,7 @@ function sourceFiles(directory, relative = "") {
|
|
|
9148
9200
|
}
|
|
9149
9201
|
function wantedImportsOf(path, wanted) {
|
|
9150
9202
|
try {
|
|
9151
|
-
const imported = [...extractImportedPackages((0,
|
|
9203
|
+
const imported = [...extractImportedPackages((0, import_node_fs35.readFileSync)(path, "utf8"))];
|
|
9152
9204
|
return imported.filter((name) => wanted.has(name));
|
|
9153
9205
|
} catch {
|
|
9154
9206
|
return [];
|
|
@@ -9159,7 +9211,7 @@ function importsOfProject(projectDirectory, wanted) {
|
|
|
9159
9211
|
const tested = /* @__PURE__ */ new Set();
|
|
9160
9212
|
const files = sourceFiles(projectDirectory);
|
|
9161
9213
|
for (const file of files) {
|
|
9162
|
-
const names = wantedImportsOf((0,
|
|
9214
|
+
const names = wantedImportsOf((0, import_node_path42.join)(projectDirectory, file), wanted);
|
|
9163
9215
|
const target = TEST_FILE.test(file) ? tested : shipped;
|
|
9164
9216
|
for (const name of names) {
|
|
9165
9217
|
target.add(name);
|
|
@@ -9171,7 +9223,7 @@ function importsOfProject(projectDirectory, wanted) {
|
|
|
9171
9223
|
function findUsage(repositoryRoot, projectDirectories, wanted) {
|
|
9172
9224
|
const usage = {};
|
|
9173
9225
|
for (const dir of projectDirectories) {
|
|
9174
|
-
const { shipped, testsOnly } = importsOfProject((0,
|
|
9226
|
+
const { shipped, testsOnly } = importsOfProject((0, import_node_path42.join)(repositoryRoot, dir), wanted);
|
|
9175
9227
|
for (const name of shipped) {
|
|
9176
9228
|
usage[name] ??= { runtime: [], testsOnly: [] };
|
|
9177
9229
|
usage[name].runtime.push(dir);
|
|
@@ -9186,7 +9238,7 @@ function findUsage(repositoryRoot, projectDirectories, wanted) {
|
|
|
9186
9238
|
function adoptDependencies(repositoryRoot, dependencies = {}) {
|
|
9187
9239
|
const run = dependencies.run ?? runShell;
|
|
9188
9240
|
requireCleanWorkingTree(repositoryRoot, dependencies.capture ?? runCapture);
|
|
9189
|
-
const rootPath = (0,
|
|
9241
|
+
const rootPath = (0, import_node_path42.join)(repositoryRoot, "package.json");
|
|
9190
9242
|
if (!fileExists(rootPath)) {
|
|
9191
9243
|
throw new Error("No package.json at the repository root.");
|
|
9192
9244
|
}
|
|
@@ -9221,8 +9273,8 @@ function adoptDependencies(repositoryRoot, dependencies = {}) {
|
|
|
9221
9273
|
}
|
|
9222
9274
|
|
|
9223
9275
|
// src/kind-adoption/adopt-kinds.use-case.ts
|
|
9224
|
-
var
|
|
9225
|
-
var
|
|
9276
|
+
var import_node_fs36 = require("fs");
|
|
9277
|
+
var import_node_path43 = require("path");
|
|
9226
9278
|
|
|
9227
9279
|
// src/kind-adoption/infer-project-kind.algorithm.ts
|
|
9228
9280
|
var SERVER_FRAMEWORKS = ["express", "koa", "fastify", "@nestjs/core"];
|
|
@@ -9323,32 +9375,32 @@ function inferProjectKind(evidence) {
|
|
|
9323
9375
|
// src/kind-adoption/adopt-kinds.use-case.ts
|
|
9324
9376
|
var TYPE_TAG = "type:";
|
|
9325
9377
|
function readEvidence(repositoryRoot, location) {
|
|
9326
|
-
const directory = (0,
|
|
9327
|
-
const files = (0,
|
|
9378
|
+
const directory = (0, import_node_path43.join)(repositoryRoot, location.dir);
|
|
9379
|
+
const files = (0, import_node_fs36.readdirSync)(directory);
|
|
9328
9380
|
const manifest = location.ecosystem === "npm" ? readJson(location.manifestPath) : {};
|
|
9329
|
-
const text = location.ecosystem === "npm" ? "" : (0,
|
|
9381
|
+
const text = location.ecosystem === "npm" ? "" : (0, import_node_fs36.readFileSync)(location.manifestPath, "utf8");
|
|
9330
9382
|
let hasProgram = false;
|
|
9331
9383
|
if (location.ecosystem === "go") {
|
|
9332
|
-
hasProgram = files.filter((file) => file.endsWith(".go")).some((file) => /^package main\b/m.test((0,
|
|
9384
|
+
hasProgram = files.filter((file) => file.endsWith(".go")).some((file) => /^package main\b/m.test((0, import_node_fs36.readFileSync)((0, import_node_path43.join)(directory, file), "utf8")));
|
|
9333
9385
|
} else if (location.ecosystem === "pub") {
|
|
9334
|
-
hasProgram = (0,
|
|
9386
|
+
hasProgram = (0, import_node_fs36.existsSync)((0, import_node_path43.join)(directory, "lib", "main.dart"));
|
|
9335
9387
|
}
|
|
9336
9388
|
return { ecosystem: location.ecosystem, manifest, text, files, hasProgram };
|
|
9337
9389
|
}
|
|
9338
9390
|
function existingKind(directory) {
|
|
9339
9391
|
const sources = [];
|
|
9340
|
-
if (fileExists((0,
|
|
9341
|
-
sources.push(readJson((0,
|
|
9392
|
+
if (fileExists((0, import_node_path43.join)(directory, "project.json"))) {
|
|
9393
|
+
sources.push(readJson((0, import_node_path43.join)(directory, "project.json")).tags ?? []);
|
|
9342
9394
|
}
|
|
9343
|
-
if (fileExists((0,
|
|
9344
|
-
sources.push(readJson((0,
|
|
9395
|
+
if (fileExists((0, import_node_path43.join)(directory, "package.json"))) {
|
|
9396
|
+
sources.push(readJson((0, import_node_path43.join)(directory, "package.json")).nx?.tags ?? []);
|
|
9345
9397
|
}
|
|
9346
9398
|
return sources.flat().find((tag) => tag.startsWith(TYPE_TAG))?.slice(TYPE_TAG.length);
|
|
9347
9399
|
}
|
|
9348
9400
|
function writeKindTag(directory, name, kind) {
|
|
9349
9401
|
const tag = `${TYPE_TAG}${kind}`;
|
|
9350
|
-
const projectJson = (0,
|
|
9351
|
-
const packageJson = (0,
|
|
9402
|
+
const projectJson = (0, import_node_path43.join)(directory, "project.json");
|
|
9403
|
+
const packageJson = (0, import_node_path43.join)(directory, "package.json");
|
|
9352
9404
|
if (fileExists(projectJson)) {
|
|
9353
9405
|
const project = readJson(projectJson);
|
|
9354
9406
|
writeFileEnsured(projectJson, toJson({ ...project, tags: [...project.tags ?? [], tag] }));
|
|
@@ -9372,7 +9424,7 @@ function adoptKinds(repositoryRoot, overrides = {}, dependencies = {}) {
|
|
|
9372
9424
|
}
|
|
9373
9425
|
}
|
|
9374
9426
|
return locations.map((location) => {
|
|
9375
|
-
const directory = (0,
|
|
9427
|
+
const directory = (0, import_node_path43.join)(repositoryRoot, location.dir);
|
|
9376
9428
|
const present = existingKind(directory);
|
|
9377
9429
|
if (present !== void 0) {
|
|
9378
9430
|
return { dir: location.dir, outcome: "already", kind: present, reason: PROJECT_KINDS.includes(present) ? "it already has a type tag" : "it already has a type tag of its own, which is not an mnci kind name; left as it is" };
|
|
@@ -9388,12 +9440,12 @@ function adoptKinds(repositoryRoot, overrides = {}, dependencies = {}) {
|
|
|
9388
9440
|
}
|
|
9389
9441
|
|
|
9390
9442
|
// src/repository-adoption/adopt-overlay.use-case.ts
|
|
9391
|
-
var
|
|
9392
|
-
var
|
|
9443
|
+
var import_node_fs38 = require("fs");
|
|
9444
|
+
var import_node_path45 = require("path");
|
|
9393
9445
|
|
|
9394
9446
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
9395
|
-
var
|
|
9396
|
-
var
|
|
9447
|
+
var import_node_fs37 = require("fs");
|
|
9448
|
+
var import_node_path44 = require("path");
|
|
9397
9449
|
function resolveRegistry(options, persisted) {
|
|
9398
9450
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
9399
9451
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -9422,7 +9474,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
9422
9474
|
return persisted.workspaceName;
|
|
9423
9475
|
}
|
|
9424
9476
|
try {
|
|
9425
|
-
const existing = (0,
|
|
9477
|
+
const existing = (0, import_node_fs37.readdirSync)(workspaceRoot).find(
|
|
9426
9478
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
9427
9479
|
);
|
|
9428
9480
|
if (existing) {
|
|
@@ -9430,11 +9482,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
9430
9482
|
}
|
|
9431
9483
|
} catch {
|
|
9432
9484
|
}
|
|
9433
|
-
return (0,
|
|
9485
|
+
return (0, import_node_path44.basename)(workspaceRoot);
|
|
9434
9486
|
}
|
|
9435
9487
|
function detectNpmAuth(workspaceRoot) {
|
|
9436
9488
|
try {
|
|
9437
|
-
return (0,
|
|
9489
|
+
return (0, import_node_fs37.readFileSync)((0, import_node_path44.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
9438
9490
|
} catch {
|
|
9439
9491
|
return void 0;
|
|
9440
9492
|
}
|
|
@@ -9481,7 +9533,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
9481
9533
|
};
|
|
9482
9534
|
}
|
|
9483
9535
|
function runUpgrade(workspaceRoot, options) {
|
|
9484
|
-
if (!fileExists((0,
|
|
9536
|
+
if (!fileExists((0, import_node_path44.join)(workspaceRoot, "nx.json"))) {
|
|
9485
9537
|
throw new Error(
|
|
9486
9538
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
9487
9539
|
);
|
|
@@ -9566,7 +9618,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
9566
9618
|
"Formatting the workspace (eslint --fix) \u2014 the slowest step, minutes on a large workspace"
|
|
9567
9619
|
);
|
|
9568
9620
|
runFormatter(workspaceRoot);
|
|
9569
|
-
const nxJson = readJson((0,
|
|
9621
|
+
const nxJson = readJson((0, import_node_path44.join)(workspaceRoot, "nx.json"));
|
|
9570
9622
|
const stranded = locateStrandedReleaseTags(workspaceRoot, nxJson.release?.releaseTag?.pattern);
|
|
9571
9623
|
for (const entry of stranded) {
|
|
9572
9624
|
logger.warn(`${entry.project} has release tags only under ${entry.oldTag}: nx release would restart it from its disk version. Run \`mnci adopt --tags\` before the next release to create ${entry.newTag} locally (\`mnci doctor\` lists them all).`);
|
|
@@ -9577,9 +9629,9 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
9577
9629
|
|
|
9578
9630
|
// src/repository-adoption/adopt-overlay.use-case.ts
|
|
9579
9631
|
function detectCiProvider(repositoryRoot) {
|
|
9580
|
-
const azure = (0,
|
|
9581
|
-
const workflows = (0,
|
|
9582
|
-
const github = (0,
|
|
9632
|
+
const azure = (0, import_node_fs38.existsSync)((0, import_node_path45.join)(repositoryRoot, "azure-pipelines.yml"));
|
|
9633
|
+
const workflows = (0, import_node_path45.join)(repositoryRoot, ".github", "workflows");
|
|
9634
|
+
const github = (0, import_node_fs38.existsSync)(workflows) && (0, import_node_fs38.readdirSync)(workflows).some((file) => /\.ya?ml$/.test(file));
|
|
9583
9635
|
if (azure && github) {
|
|
9584
9636
|
return "both";
|
|
9585
9637
|
}
|
|
@@ -9589,7 +9641,7 @@ function detectCiProvider(repositoryRoot) {
|
|
|
9589
9641
|
return github ? "github" : void 0;
|
|
9590
9642
|
}
|
|
9591
9643
|
function detectTestRunner(repositoryRoot) {
|
|
9592
|
-
const manifestPath = (0,
|
|
9644
|
+
const manifestPath = (0, import_node_path45.join)(repositoryRoot, "package.json");
|
|
9593
9645
|
if (!fileExists(manifestPath)) {
|
|
9594
9646
|
return void 0;
|
|
9595
9647
|
}
|
|
@@ -9602,7 +9654,7 @@ function detectTestRunner(repositoryRoot) {
|
|
|
9602
9654
|
}
|
|
9603
9655
|
function adoptOverlay(repositoryRoot, options, dependencies = {}) {
|
|
9604
9656
|
requireCleanWorkingTree(repositoryRoot, dependencies.capture ?? runCapture);
|
|
9605
|
-
if (!fileExists((0,
|
|
9657
|
+
if (!fileExists((0, import_node_path45.join)(repositoryRoot, "nx.json"))) {
|
|
9606
9658
|
throw new Error("There is no nx.json, so Nx is not set up here. Run `mnci adopt --toolchain` first: it sets Nx up (nx init, then nx add), and the overlay needs that.");
|
|
9607
9659
|
}
|
|
9608
9660
|
const persisted = readMnciConfig(repositoryRoot);
|
|
@@ -9615,7 +9667,7 @@ function adoptOverlay(repositoryRoot, options, dependencies = {}) {
|
|
|
9615
9667
|
}
|
|
9616
9668
|
|
|
9617
9669
|
// src/toolchain-adoption/adopt-toolchain.use-case.ts
|
|
9618
|
-
var
|
|
9670
|
+
var import_node_path48 = require("path");
|
|
9619
9671
|
|
|
9620
9672
|
// src/toolchain-adoption/align-nx-family.algorithm.ts
|
|
9621
9673
|
var VERSION = /^[\^~]?(\d+)\.(\d+)\.(\d+)$/;
|
|
@@ -9653,7 +9705,7 @@ function alignNxFamily(dependencies, version) {
|
|
|
9653
9705
|
}
|
|
9654
9706
|
|
|
9655
9707
|
// src/toolchain-adoption/bootstrap-nx.use-case.ts
|
|
9656
|
-
var
|
|
9708
|
+
var import_node_path46 = require("path");
|
|
9657
9709
|
var BASE_PLUGIN = "@nx/js";
|
|
9658
9710
|
var TOOL_PLUGINS = [
|
|
9659
9711
|
["eslint", "@nx/eslint"],
|
|
@@ -9661,13 +9713,13 @@ var TOOL_PLUGINS = [
|
|
|
9661
9713
|
["vitest", "@nx/vite"]
|
|
9662
9714
|
];
|
|
9663
9715
|
function pluginsFor(repositoryRoot) {
|
|
9664
|
-
const manifestPath = (0,
|
|
9716
|
+
const manifestPath = (0, import_node_path46.join)(repositoryRoot, "package.json");
|
|
9665
9717
|
const manifest = fileExists(manifestPath) ? readJson(manifestPath) : {};
|
|
9666
9718
|
const declared = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
9667
9719
|
return [BASE_PLUGIN, ...TOOL_PLUGINS.filter(([tool]) => declared.includes(tool)).map(([, plugin]) => plugin)];
|
|
9668
9720
|
}
|
|
9669
9721
|
function bootstrapNx(repositoryRoot, nxVersion, dependencies) {
|
|
9670
|
-
if (fileExists((0,
|
|
9722
|
+
if (fileExists((0, import_node_path46.join)(repositoryRoot, "nx.json"))) {
|
|
9671
9723
|
return { bootstrapped: false, plugins: [] };
|
|
9672
9724
|
}
|
|
9673
9725
|
const initialised = dependencies.run("npx", ["--yes", `nx@${nxVersion ?? "latest"}`, "init", "--interactive=false", "--nxCloud=skip", "--plugins=skip"], repositoryRoot);
|
|
@@ -9684,24 +9736,24 @@ function bootstrapNx(repositoryRoot, nxVersion, dependencies) {
|
|
|
9684
9736
|
}
|
|
9685
9737
|
|
|
9686
9738
|
// src/toolchain-adoption/retire-tooling.use-case.ts
|
|
9687
|
-
var
|
|
9688
|
-
var
|
|
9739
|
+
var import_node_fs39 = require("fs");
|
|
9740
|
+
var import_node_path47 = require("path");
|
|
9689
9741
|
var RETIRED_COMMAND = /\b(?:prettier|oxfmt|oxlint)\b/;
|
|
9690
9742
|
function retireTooling(repositoryRoot) {
|
|
9691
9743
|
const removed = [];
|
|
9692
9744
|
for (const file of RETIRED_FORMATTER_FILES) {
|
|
9693
|
-
if (!fileExists((0,
|
|
9745
|
+
if (!fileExists((0, import_node_path47.join)(repositoryRoot, file))) {
|
|
9694
9746
|
continue;
|
|
9695
9747
|
}
|
|
9696
|
-
(0,
|
|
9748
|
+
(0, import_node_fs39.rmSync)((0, import_node_path47.join)(repositoryRoot, file), { force: true });
|
|
9697
9749
|
removed.push(file);
|
|
9698
9750
|
}
|
|
9699
|
-
const hadRegistry = fileExists((0,
|
|
9751
|
+
const hadRegistry = fileExists((0, import_node_path47.join)(repositoryRoot, ".verdaccio"));
|
|
9700
9752
|
removeLocalRegistryScaffolding(repositoryRoot);
|
|
9701
9753
|
if (hadRegistry) {
|
|
9702
9754
|
removed.push(".verdaccio, its dependency and the local-registry target");
|
|
9703
9755
|
}
|
|
9704
|
-
const manifestPath = (0,
|
|
9756
|
+
const manifestPath = (0, import_node_path47.join)(repositoryRoot, "package.json");
|
|
9705
9757
|
if (!fileExists(manifestPath)) {
|
|
9706
9758
|
return removed;
|
|
9707
9759
|
}
|
|
@@ -9748,7 +9800,7 @@ function adoptToolchain(repositoryRoot, options = {}, dependencies = {}) {
|
|
|
9748
9800
|
console.log(message);
|
|
9749
9801
|
});
|
|
9750
9802
|
requireCleanWorkingTree(repositoryRoot, capture);
|
|
9751
|
-
const manifestPath = (0,
|
|
9803
|
+
const manifestPath = (0, import_node_path48.join)(repositoryRoot, "package.json");
|
|
9752
9804
|
if (!fileExists(manifestPath)) {
|
|
9753
9805
|
throw new Error("No package.json at the repository root.");
|
|
9754
9806
|
}
|
|
@@ -9787,8 +9839,8 @@ function adoptToolchain(repositoryRoot, options = {}, dependencies = {}) {
|
|
|
9787
9839
|
}
|
|
9788
9840
|
|
|
9789
9841
|
// src/adoption-report/inspect-repository.use-case.ts
|
|
9790
|
-
var
|
|
9791
|
-
var
|
|
9842
|
+
var import_node_fs40 = require("fs");
|
|
9843
|
+
var import_node_path49 = require("path");
|
|
9792
9844
|
var LOCKFILES = [
|
|
9793
9845
|
["package-lock.json", "npm"],
|
|
9794
9846
|
["pnpm-lock.yaml", "pnpm"],
|
|
@@ -9809,25 +9861,25 @@ function inspectRepository(repositoryRoot) {
|
|
|
9809
9861
|
const isGitRepo = inside.status === 0 && inside.stdout.trim() === "true";
|
|
9810
9862
|
const dirty = isGitRepo && runCapture("git", ["status", "--porcelain"], repositoryRoot).stdout.trim() !== "";
|
|
9811
9863
|
const tags = isGitRepo ? runCapture("git", ["tag", "--list"], repositoryRoot).stdout.split(/\r?\n/).filter(Boolean) : [];
|
|
9812
|
-
const manifestPath = (0,
|
|
9864
|
+
const manifestPath = (0, import_node_path49.join)(repositoryRoot, "package.json");
|
|
9813
9865
|
const manifest = fileExists(manifestPath) ? readJson(manifestPath) : {};
|
|
9814
|
-
const nxJsonPath = (0,
|
|
9866
|
+
const nxJsonPath = (0, import_node_path49.join)(repositoryRoot, "nx.json");
|
|
9815
9867
|
const nxJson = fileExists(nxJsonPath) ? readJson(nxJsonPath) : {};
|
|
9816
9868
|
const ci = [];
|
|
9817
9869
|
const pipelines = [];
|
|
9818
|
-
if ((0,
|
|
9870
|
+
if ((0, import_node_fs40.existsSync)((0, import_node_path49.join)(repositoryRoot, "azure-pipelines.yml"))) {
|
|
9819
9871
|
ci.push("azure");
|
|
9820
|
-
pipelines.push((0,
|
|
9872
|
+
pipelines.push((0, import_node_path49.join)(repositoryRoot, "azure-pipelines.yml"));
|
|
9821
9873
|
}
|
|
9822
|
-
const workflows = (0,
|
|
9823
|
-
if ((0,
|
|
9824
|
-
const files = (0,
|
|
9874
|
+
const workflows = (0, import_node_path49.join)(repositoryRoot, ".github", "workflows");
|
|
9875
|
+
if ((0, import_node_fs40.existsSync)(workflows)) {
|
|
9876
|
+
const files = (0, import_node_fs40.readdirSync)(workflows).filter((file) => /\.ya?ml$/.test(file));
|
|
9825
9877
|
if (files.length > 0) {
|
|
9826
9878
|
ci.push("github");
|
|
9827
|
-
pipelines.push(...files.map((file) => (0,
|
|
9879
|
+
pipelines.push(...files.map((file) => (0, import_node_path49.join)(workflows, file)));
|
|
9828
9880
|
}
|
|
9829
9881
|
}
|
|
9830
|
-
const rootFiles = (0,
|
|
9882
|
+
const rootFiles = (0, import_node_fs40.readdirSync)(repositoryRoot);
|
|
9831
9883
|
return {
|
|
9832
9884
|
isGitRepo,
|
|
9833
9885
|
dirty,
|
|
@@ -9838,7 +9890,7 @@ function inspectRepository(repositoryRoot) {
|
|
|
9838
9890
|
tagCount: tags.length,
|
|
9839
9891
|
strandedTags: isGitRepo ? locateStrandedReleaseTags(repositoryRoot, nxJson.release?.releaseTag?.pattern) : [],
|
|
9840
9892
|
ci,
|
|
9841
|
-
pipelineUsesMnci: pipelines.some((file) => /\bmnci ci\b/.test((0,
|
|
9893
|
+
pipelineUsesMnci: pipelines.some((file) => /\bmnci ci\b/.test((0, import_node_fs40.readFileSync)(file, "utf8"))),
|
|
9842
9894
|
retiredTooling: [.../* @__PURE__ */ new Set([...rootFiles.filter((file) => RETIRED_FILE_PATTERN.test(file) || file === ".verdaccio"), ...retiredNamesIn(manifest)])],
|
|
9843
9895
|
personalFiles: PERSONAL_FILES.filter((file) => rootFiles.includes(file))
|
|
9844
9896
|
};
|
|
@@ -10141,13 +10193,13 @@ function runCommands(program, options) {
|
|
|
10141
10193
|
}
|
|
10142
10194
|
|
|
10143
10195
|
// src/workspace-info/list-projects.use-case.ts
|
|
10144
|
-
var
|
|
10196
|
+
var import_node_path50 = require("path");
|
|
10145
10197
|
var TYPE_TAG_PREFIX = "type:";
|
|
10146
10198
|
function listProjects(workspaceRoot) {
|
|
10147
10199
|
return locateProjects(workspaceRoot).map((location) => {
|
|
10148
|
-
const projectJsonPath = (0,
|
|
10200
|
+
const projectJsonPath = (0, import_node_path50.join)(workspaceRoot, location.dir, "project.json");
|
|
10149
10201
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
10150
|
-
const manifestPath = (0,
|
|
10202
|
+
const manifestPath = (0, import_node_path50.join)(workspaceRoot, location.dir, "package.json");
|
|
10151
10203
|
const manifestTags = fileExists(manifestPath) ? readJson(manifestPath).nx?.tags ?? [] : [];
|
|
10152
10204
|
const typeTag = [...project.tags ?? [], ...manifestTags].find((tag) => tag.startsWith(TYPE_TAG_PREFIX));
|
|
10153
10205
|
return {
|
|
@@ -10160,7 +10212,7 @@ function listProjects(workspaceRoot) {
|
|
|
10160
10212
|
}).toSorted((a, b) => a.dir.localeCompare(b.dir));
|
|
10161
10213
|
}
|
|
10162
10214
|
function runProjects(workspaceRoot, options) {
|
|
10163
|
-
if (!fileExists((0,
|
|
10215
|
+
if (!fileExists((0, import_node_path50.join)(workspaceRoot, "nx.json"))) {
|
|
10164
10216
|
throw new Error("No nx.json found here. Run `projects` from the workspace root.");
|
|
10165
10217
|
}
|
|
10166
10218
|
const projects = listProjects(workspaceRoot);
|
|
@@ -10174,11 +10226,11 @@ function runProjects(workspaceRoot, options) {
|
|
|
10174
10226
|
}
|
|
10175
10227
|
|
|
10176
10228
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
10177
|
-
var
|
|
10229
|
+
var import_node_path52 = require("path");
|
|
10178
10230
|
|
|
10179
10231
|
// src/cli-version/check-for-update.use-case.ts
|
|
10180
|
-
var
|
|
10181
|
-
var
|
|
10232
|
+
var import_node_fs41 = require("fs");
|
|
10233
|
+
var import_node_path51 = require("path");
|
|
10182
10234
|
var import_cross_spawn4 = __toESM(require("cross-spawn"));
|
|
10183
10235
|
var PACKAGE_NAME2 = "@mnci/cli";
|
|
10184
10236
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -10237,8 +10289,8 @@ function releaseTriple(version) {
|
|
|
10237
10289
|
}
|
|
10238
10290
|
function readCliVersion(packageDirectory) {
|
|
10239
10291
|
try {
|
|
10240
|
-
const manifestPath = (0,
|
|
10241
|
-
const manifest = JSON.parse((0,
|
|
10292
|
+
const manifestPath = (0, import_node_path51.join)(packageDirectory, "..", "package.json");
|
|
10293
|
+
const manifest = JSON.parse((0, import_node_fs41.readFileSync)(manifestPath, "utf8"));
|
|
10242
10294
|
return manifest.version ?? "0.0.0";
|
|
10243
10295
|
} catch {
|
|
10244
10296
|
return "0.0.0";
|
|
@@ -10248,7 +10300,7 @@ function readCliVersion(packageDirectory) {
|
|
|
10248
10300
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
10249
10301
|
function readWorkspaceInfo(workspaceRoot, cliVersion) {
|
|
10250
10302
|
const latest = fetchLatestVersion() ?? null;
|
|
10251
|
-
const isWorkspace = fileExists((0,
|
|
10303
|
+
const isWorkspace = fileExists((0, import_node_path52.join)(workspaceRoot, "nx.json"));
|
|
10252
10304
|
return {
|
|
10253
10305
|
cli: {
|
|
10254
10306
|
version: cliVersion,
|
|
@@ -10269,7 +10321,7 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
10269
10321
|
}
|
|
10270
10322
|
|
|
10271
10323
|
// src/interactive-wizard/interactive-wizard.use-case.ts
|
|
10272
|
-
var
|
|
10324
|
+
var import_node_path53 = require("path");
|
|
10273
10325
|
|
|
10274
10326
|
// src/interactive-wizard/adopt-steps.config.ts
|
|
10275
10327
|
var ADOPT_GLOBAL_OPTIONS = ["json"];
|
|
@@ -10450,7 +10502,7 @@ function wizardMenu(commands, inWorkspace) {
|
|
|
10450
10502
|
}
|
|
10451
10503
|
async function runInteractive(program, prompter = createInquirerPrompter(), workingDirectory = process.cwd()) {
|
|
10452
10504
|
const commands = describeCommands(program);
|
|
10453
|
-
const inWorkspace = fileExists((0,
|
|
10505
|
+
const inWorkspace = fileExists((0, import_node_path53.join)(workingDirectory, "nx.json"));
|
|
10454
10506
|
const name = await prompter.select("What would you like to do?", wizardMenu(commands, inWorkspace));
|
|
10455
10507
|
const command = commands.find((candidate) => candidate.name === name);
|
|
10456
10508
|
const argv = buildArgv(command, await askCommand(command, prompter));
|
|
@@ -10477,8 +10529,8 @@ var PRESETS = [
|
|
|
10477
10529
|
var PRESET_IDS = PRESETS.map((preset) => preset.id);
|
|
10478
10530
|
|
|
10479
10531
|
// src/workspace-presets/wire-web-api.use-case.ts
|
|
10480
|
-
var
|
|
10481
|
-
var
|
|
10532
|
+
var import_node_fs42 = require("fs");
|
|
10533
|
+
var import_node_path54 = require("path");
|
|
10482
10534
|
|
|
10483
10535
|
// src/workspace-presets/web-api-wiring.algorithm.ts
|
|
10484
10536
|
function apiHandler(shared) {
|
|
@@ -10650,18 +10702,18 @@ function declareDependency(manifestPath, name) {
|
|
|
10650
10702
|
}
|
|
10651
10703
|
function removeFiles(slice, files) {
|
|
10652
10704
|
for (const file of files) {
|
|
10653
|
-
(0,
|
|
10705
|
+
(0, import_node_fs42.rmSync)((0, import_node_path54.join)(slice, file), { force: true });
|
|
10654
10706
|
}
|
|
10655
10707
|
}
|
|
10656
10708
|
function replaceOnce(path, anchor, replacement) {
|
|
10657
|
-
const text = (0,
|
|
10709
|
+
const text = (0, import_node_fs42.readFileSync)(path, "utf8");
|
|
10658
10710
|
if (!text.includes(anchor)) {
|
|
10659
10711
|
throw new Error(`${path} has no ${anchor}; the generator's output changed, so the preset cannot wire it.`);
|
|
10660
10712
|
}
|
|
10661
10713
|
writeFileEnsured(path, text.replace(anchor, () => replacement));
|
|
10662
10714
|
}
|
|
10663
10715
|
function proxyApi(viteConfigPath) {
|
|
10664
|
-
const text = (0,
|
|
10716
|
+
const text = (0, import_node_fs42.readFileSync)(viteConfigPath, "utf8");
|
|
10665
10717
|
const proxied = withApiProxy(text, API_ORIGIN);
|
|
10666
10718
|
if (proxied === text && !text.includes("proxy:")) {
|
|
10667
10719
|
throw new Error(`${viteConfigPath} has no server block to add the /api proxy to; the generator's output changed, so the preset cannot wire it.`);
|
|
@@ -10669,30 +10721,30 @@ function proxyApi(viteConfigPath) {
|
|
|
10669
10721
|
writeFileEnsured(viteConfigPath, proxied);
|
|
10670
10722
|
}
|
|
10671
10723
|
function wireWebApi(workspaceRoot, projects) {
|
|
10672
|
-
const sharedManifest = (0,
|
|
10724
|
+
const sharedManifest = (0, import_node_path54.join)(workspaceRoot, "libs", projects.shared, "package.json");
|
|
10673
10725
|
if (!fileExists(sharedManifest)) {
|
|
10674
10726
|
throw new Error(`The shared library was not added at libs/${projects.shared}, so there is nothing to wire the API and the frontend to.`);
|
|
10675
10727
|
}
|
|
10676
10728
|
const shared = readJson(sharedManifest).name;
|
|
10677
|
-
const api = (0,
|
|
10678
|
-
declareDependency((0,
|
|
10679
|
-
const hello = (0,
|
|
10680
|
-
writeFileEnsured((0,
|
|
10681
|
-
writeFileEnsured((0,
|
|
10682
|
-
writeFileEnsured((0,
|
|
10729
|
+
const api = (0, import_node_path54.join)(workspaceRoot, "apps", projects.api);
|
|
10730
|
+
declareDependency((0, import_node_path54.join)(api, "package.json"), shared);
|
|
10731
|
+
const hello = (0, import_node_path54.join)(api, "src", "hello");
|
|
10732
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "hello.handler.ts"), apiHandler(shared));
|
|
10733
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "hello.handler.spec.ts"), apiHandlerSpec(shared));
|
|
10734
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "index.ts"), apiBarrel());
|
|
10683
10735
|
removeFiles(hello, ["greet.use-case.ts", "greet.use-case.spec.ts", "greeting.contract.ts"]);
|
|
10684
|
-
replaceOnce((0,
|
|
10685
|
-
const web = (0,
|
|
10686
|
-
declareDependency((0,
|
|
10687
|
-
const greeting = (0,
|
|
10688
|
-
writeFileEnsured((0,
|
|
10689
|
-
writeFileEnsured((0,
|
|
10690
|
-
writeFileEnsured((0,
|
|
10691
|
-
writeFileEnsured((0,
|
|
10692
|
-
writeFileEnsured((0,
|
|
10736
|
+
replaceOnce((0, import_node_path54.join)(api, "src", "main.ts"), "app.get('/', helloHandler)", "app.get('/api/greeting', helloHandler)");
|
|
10737
|
+
const web = (0, import_node_path54.join)(workspaceRoot, "apps", projects.web);
|
|
10738
|
+
declareDependency((0, import_node_path54.join)(web, "package.json"), shared);
|
|
10739
|
+
const greeting = (0, import_node_path54.join)(web, "src", "greeting");
|
|
10740
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.client.ts"), webGreetingClient(shared));
|
|
10741
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.client.spec.ts"), webGreetingClientSpec());
|
|
10742
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.component.tsx"), webGreetingComponent(shared));
|
|
10743
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.component.spec.tsx"), webGreetingSpec());
|
|
10744
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "index.ts"), webGreetingBarrel());
|
|
10693
10745
|
removeFiles(greeting, ["greet.use-case.ts", "greet.use-case.spec.ts", "greeting.contract.ts"]);
|
|
10694
|
-
writeFileEnsured((0,
|
|
10695
|
-
proxyApi((0,
|
|
10746
|
+
writeFileEnsured((0, import_node_path54.join)(web, "src", "app", "app.component.spec.tsx"), webAppSpec());
|
|
10747
|
+
proxyApi((0, import_node_path54.join)(web, "vite.config.mts"));
|
|
10696
10748
|
}
|
|
10697
10749
|
|
|
10698
10750
|
// src/workspace-presets/apply-preset.use-case.ts
|
|
@@ -10735,8 +10787,8 @@ async function applyPreset(workspaceRoot, presetId, dependencies = {}) {
|
|
|
10735
10787
|
}
|
|
10736
10788
|
|
|
10737
10789
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
10738
|
-
var
|
|
10739
|
-
var
|
|
10790
|
+
var import_node_fs43 = require("fs");
|
|
10791
|
+
var import_node_path55 = require("path");
|
|
10740
10792
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
10741
10793
|
var AGENT_AND_CI_ENTRIES = [
|
|
10742
10794
|
"AGENTS.md",
|
|
@@ -10767,13 +10819,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
10767
10819
|
"packages"
|
|
10768
10820
|
];
|
|
10769
10821
|
function assertAdoptableDirectory(target) {
|
|
10770
|
-
if (!(0,
|
|
10822
|
+
if (!(0, import_node_fs43.existsSync)(target)) {
|
|
10771
10823
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
10772
10824
|
}
|
|
10773
|
-
if (!(0,
|
|
10825
|
+
if (!(0, import_node_fs43.statSync)(target).isDirectory()) {
|
|
10774
10826
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
10775
10827
|
}
|
|
10776
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
10828
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs43.existsSync)((0, import_node_path55.join)(target, entry)));
|
|
10777
10829
|
if (blockers.length > 0) {
|
|
10778
10830
|
throw new Error(
|
|
10779
10831
|
`--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.`
|
|
@@ -10781,15 +10833,15 @@ function assertAdoptableDirectory(target) {
|
|
|
10781
10833
|
}
|
|
10782
10834
|
}
|
|
10783
10835
|
function mergeGitignore(generatedFile, targetFile) {
|
|
10784
|
-
const existing = (0,
|
|
10836
|
+
const existing = (0, import_node_fs43.readFileSync)(targetFile, "utf8");
|
|
10785
10837
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
10786
|
-
const additions = (0,
|
|
10838
|
+
const additions = (0, import_node_fs43.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
10787
10839
|
const trimmed = line.trim();
|
|
10788
10840
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
10789
10841
|
});
|
|
10790
10842
|
if (additions.length === 0) return false;
|
|
10791
10843
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
10792
|
-
(0,
|
|
10844
|
+
(0, import_node_fs43.writeFileSync)(
|
|
10793
10845
|
targetFile,
|
|
10794
10846
|
`${existing}${separator}
|
|
10795
10847
|
# Added by mnci (Nx workspace)
|
|
@@ -10799,9 +10851,9 @@ ${additions.join("\n")}
|
|
|
10799
10851
|
return true;
|
|
10800
10852
|
}
|
|
10801
10853
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
10802
|
-
const entries = (0,
|
|
10854
|
+
const entries = (0, import_node_fs43.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
10803
10855
|
const collisions = entries.filter(
|
|
10804
|
-
(entry) => (0,
|
|
10856
|
+
(entry) => (0, import_node_fs43.existsSync)((0, import_node_path55.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
10805
10857
|
);
|
|
10806
10858
|
if (collisions.length > 0) {
|
|
10807
10859
|
throw new Error(
|
|
@@ -10810,40 +10862,40 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
10810
10862
|
}
|
|
10811
10863
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
10812
10864
|
for (const entry of entries) {
|
|
10813
|
-
const from = (0,
|
|
10814
|
-
const to = (0,
|
|
10815
|
-
if (entry === ".gitignore" && (0,
|
|
10865
|
+
const from = (0, import_node_path55.join)(generatedRoot, entry);
|
|
10866
|
+
const to = (0, import_node_path55.join)(target, entry);
|
|
10867
|
+
if (entry === ".gitignore" && (0, import_node_fs43.existsSync)(to)) {
|
|
10816
10868
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
10817
10869
|
result.kept.push(entry);
|
|
10818
10870
|
continue;
|
|
10819
10871
|
}
|
|
10820
|
-
if ((0,
|
|
10872
|
+
if ((0, import_node_fs43.existsSync)(to)) {
|
|
10821
10873
|
result.kept.push(entry);
|
|
10822
10874
|
continue;
|
|
10823
10875
|
}
|
|
10824
|
-
(0,
|
|
10876
|
+
(0, import_node_fs43.cpSync)(from, to, { recursive: true });
|
|
10825
10877
|
result.copied.push(entry);
|
|
10826
10878
|
}
|
|
10827
|
-
(0,
|
|
10879
|
+
(0, import_node_fs43.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
10828
10880
|
return result;
|
|
10829
10881
|
}
|
|
10830
10882
|
|
|
10831
10883
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
10832
|
-
var
|
|
10884
|
+
var import_node_fs45 = require("fs");
|
|
10833
10885
|
var import_node_os2 = require("os");
|
|
10834
|
-
var
|
|
10886
|
+
var import_node_path57 = require("path");
|
|
10835
10887
|
|
|
10836
10888
|
// src/workspace-creation/remove-generated-pipelines.use-case.ts
|
|
10837
|
-
var
|
|
10838
|
-
var
|
|
10889
|
+
var import_node_fs44 = require("fs");
|
|
10890
|
+
var import_node_path56 = require("path");
|
|
10839
10891
|
var NX_GENERATED_PIPELINES = [".github/workflows/ci.yml", "azure-pipelines.yml"];
|
|
10840
10892
|
function removeGeneratedPipelines(generatedRoot) {
|
|
10841
10893
|
const removed = [];
|
|
10842
10894
|
for (const file of NX_GENERATED_PIPELINES) {
|
|
10843
|
-
if (!fileExists((0,
|
|
10895
|
+
if (!fileExists((0, import_node_path56.join)(generatedRoot, file))) {
|
|
10844
10896
|
continue;
|
|
10845
10897
|
}
|
|
10846
|
-
(0,
|
|
10898
|
+
(0, import_node_fs44.rmSync)((0, import_node_path56.join)(generatedRoot, file), { force: true });
|
|
10847
10899
|
removed.push(file);
|
|
10848
10900
|
}
|
|
10849
10901
|
return removed;
|
|
@@ -10892,10 +10944,10 @@ async function resolveRegistry2(options) {
|
|
|
10892
10944
|
return await promptRegistry();
|
|
10893
10945
|
}
|
|
10894
10946
|
async function runNew(name, options) {
|
|
10895
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
10947
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path57.resolve)(process.cwd(), options.into);
|
|
10896
10948
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
10897
10949
|
if (options.preset !== void 0) findPreset(options.preset);
|
|
10898
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
10950
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path57.basename)(adoptTarget));
|
|
10899
10951
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
10900
10952
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
10901
10953
|
const registry = await resolveRegistry2(options);
|
|
@@ -10908,8 +10960,8 @@ async function runNew(name, options) {
|
|
|
10908
10960
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
10909
10961
|
const stack = await resolveStack(options);
|
|
10910
10962
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
10911
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
10912
|
-
let workspaceRoot = (0,
|
|
10963
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs45.mkdtempSync)((0, import_node_path57.join)((0, import_node_os2.tmpdir)(), "mnci-new-"));
|
|
10964
|
+
let workspaceRoot = (0, import_node_path57.join)(stagingParent, workspaceName);
|
|
10913
10965
|
try {
|
|
10914
10966
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
10915
10967
|
runNpx(
|
|
@@ -10933,7 +10985,7 @@ async function runNew(name, options) {
|
|
|
10933
10985
|
workspaceRoot = adoptTarget;
|
|
10934
10986
|
}
|
|
10935
10987
|
} finally {
|
|
10936
|
-
if (adoptTarget !== void 0) (0,
|
|
10988
|
+
if (adoptTarget !== void 0) (0, import_node_fs45.rmSync)(stagingParent, { recursive: true, force: true });
|
|
10937
10989
|
}
|
|
10938
10990
|
logger.step(
|
|
10939
10991
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -10943,8 +10995,8 @@ async function runNew(name, options) {
|
|
|
10943
10995
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
10944
10996
|
logger.detail
|
|
10945
10997
|
);
|
|
10946
|
-
(0,
|
|
10947
|
-
(0,
|
|
10998
|
+
(0, import_node_fs45.rmSync)((0, import_node_path57.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
10999
|
+
(0, import_node_fs45.rmSync)((0, import_node_path57.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
10948
11000
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
10949
11001
|
const installStatus = runShell(
|
|
10950
11002
|
"npm",
|