@mnci/cli 4.54.1 → 4.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/cli.js +673 -600
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1457,9 +1457,20 @@ function launchConfigurations(workspaceName) {
|
|
|
1457
1457
|
presentation: { group: "mnci", order: index + 1 }
|
|
1458
1458
|
}));
|
|
1459
1459
|
}
|
|
1460
|
+
function projectLaunchConfiguration(workspaceName, projectName) {
|
|
1461
|
+
return {
|
|
1462
|
+
type: "node-terminal",
|
|
1463
|
+
request: "launch",
|
|
1464
|
+
name: `${LAUNCH_CONFIG_PREFIX}${projectName} start`,
|
|
1465
|
+
command: `npm run ${projectName}:start`,
|
|
1466
|
+
cwd: `\${workspaceFolder:${workspaceName}}`,
|
|
1467
|
+
presentation: { group: "mnci projects" }
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1460
1470
|
function vscodeWorkspace(workspaceName, existingTasks, existingLaunch, existingSettings) {
|
|
1471
|
+
const ownedNames = new Set(launchConfigurations(workspaceName).map((configuration) => configuration.name));
|
|
1461
1472
|
const userConfigurations = (existingLaunch?.configurations ?? []).filter(
|
|
1462
|
-
(configuration) => !
|
|
1473
|
+
(configuration) => !ownedNames.has(configuration.name)
|
|
1463
1474
|
);
|
|
1464
1475
|
const settings = { ...existingSettings, ...vscodeSettings() };
|
|
1465
1476
|
return toJson(
|
|
@@ -2901,8 +2912,8 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2901
2912
|
}
|
|
2902
2913
|
|
|
2903
2914
|
// src/ci-pipeline/setup.use-case.ts
|
|
2904
|
-
var
|
|
2905
|
-
var
|
|
2915
|
+
var import_node_fs14 = require("fs");
|
|
2916
|
+
var import_node_path12 = require("path");
|
|
2906
2917
|
|
|
2907
2918
|
// src/ci-pipeline/flutter-sdk.use-case.ts
|
|
2908
2919
|
var import_node_fs10 = require("fs");
|
|
@@ -2948,23 +2959,151 @@ function resolveDartDependencies(workspaceRoot, processes, log) {
|
|
|
2948
2959
|
|
|
2949
2960
|
// src/ci-pipeline/go-tools.use-case.ts
|
|
2950
2961
|
var import_node_crypto = require("crypto");
|
|
2951
|
-
var
|
|
2962
|
+
var import_node_fs13 = require("fs");
|
|
2952
2963
|
var import_node_os = require("os");
|
|
2964
|
+
var import_node_path11 = require("path");
|
|
2965
|
+
|
|
2966
|
+
// src/go-workspace/go-plugin.use-case.ts
|
|
2967
|
+
var import_node_fs11 = require("fs");
|
|
2953
2968
|
var import_node_path9 = require("path");
|
|
2969
|
+
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
2970
|
+
function hasGoProject(workspaceRoot) {
|
|
2971
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs11.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
2972
|
+
return projectFiles.some((projectFile) => {
|
|
2973
|
+
try {
|
|
2974
|
+
const { tags } = JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(workspaceRoot, projectFile), "utf8"));
|
|
2975
|
+
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
2976
|
+
} catch {
|
|
2977
|
+
return false;
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
function isNxGoPluginRegistered(workspaceRoot) {
|
|
2982
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
2983
|
+
if (!fileExists(nxJsonPath)) {
|
|
2984
|
+
return false;
|
|
2985
|
+
}
|
|
2986
|
+
return (readJson(nxJsonPath).plugins ?? []).some((entry) => (typeof entry === "string" ? entry : entry.plugin) === NX_GO_PLUGIN);
|
|
2987
|
+
}
|
|
2988
|
+
function modulePrefixFromRemoteUrl(url) {
|
|
2989
|
+
const trimmed = url.trim();
|
|
2990
|
+
const scpLike = /^[^@/]+@([^:]+):(.+)$/.exec(trimmed);
|
|
2991
|
+
const withScheme = /^[a-z][\w+.-]*:\/\/(?:[^@/]+@)?(.+)$/i.exec(trimmed);
|
|
2992
|
+
let path;
|
|
2993
|
+
if (scpLike) {
|
|
2994
|
+
path = `${scpLike[1]}/${scpLike[2]}`;
|
|
2995
|
+
} else if (withScheme) {
|
|
2996
|
+
path = withScheme[1];
|
|
2997
|
+
}
|
|
2998
|
+
if (path === void 0) {
|
|
2999
|
+
return void 0;
|
|
3000
|
+
}
|
|
3001
|
+
const cleaned = path.replace(/\.git$/, "").replace(/\/+$/, "");
|
|
3002
|
+
return cleaned === "" ? void 0 : cleaned;
|
|
3003
|
+
}
|
|
3004
|
+
function goModulePrefix(workspaceRoot) {
|
|
3005
|
+
const result = runCapture("git", ["remote", "get-url", "origin"], workspaceRoot);
|
|
3006
|
+
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
3007
|
+
}
|
|
3008
|
+
function rootModulePath(workspaceRoot) {
|
|
3009
|
+
try {
|
|
3010
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs11.readFileSync)((0, import_node_path9.join)(workspaceRoot, "go.mod"), "utf8"))?.[1];
|
|
3011
|
+
} catch {
|
|
3012
|
+
return void 0;
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
function registerNxGoPlugin(workspaceRoot) {
|
|
3016
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
3017
|
+
if (!fileExists(nxJsonPath)) {
|
|
3018
|
+
return false;
|
|
3019
|
+
}
|
|
3020
|
+
const modulePrefix = rootModulePath(workspaceRoot) === void 0 ? goModulePrefix(workspaceRoot) : void 0;
|
|
3021
|
+
const entry = modulePrefix === void 0 ? NX_GO_PLUGIN : { plugin: NX_GO_PLUGIN, options: { modulePrefix } };
|
|
3022
|
+
const nxJson = readJson(nxJsonPath);
|
|
3023
|
+
const plugins = [...nxJson.plugins ?? []];
|
|
3024
|
+
const index = plugins.findIndex((plugin) => (typeof plugin === "string" ? plugin : plugin.plugin) === NX_GO_PLUGIN);
|
|
3025
|
+
if (index === -1) {
|
|
3026
|
+
plugins.push(entry);
|
|
3027
|
+
} else {
|
|
3028
|
+
const current = plugins[index];
|
|
3029
|
+
const currentPrefix = typeof current === "string" ? void 0 : current.options?.modulePrefix;
|
|
3030
|
+
if (modulePrefix === void 0 || currentPrefix === modulePrefix) {
|
|
3031
|
+
return false;
|
|
3032
|
+
}
|
|
3033
|
+
plugins[index] = entry;
|
|
3034
|
+
}
|
|
3035
|
+
writeFileEnsured(nxJsonPath, toJson({ ...nxJson, plugins }));
|
|
3036
|
+
return true;
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
// src/go-workspace/go-work-uses.algorithm.ts
|
|
3040
|
+
function parseGoWorkUses(goWork) {
|
|
3041
|
+
const uses = [];
|
|
3042
|
+
let inBlock = false;
|
|
3043
|
+
for (const raw of goWork.split("\n")) {
|
|
3044
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
3045
|
+
if (line === "") {
|
|
3046
|
+
continue;
|
|
3047
|
+
}
|
|
3048
|
+
if (inBlock) {
|
|
3049
|
+
if (line.startsWith(")")) {
|
|
3050
|
+
inBlock = false;
|
|
3051
|
+
} else {
|
|
3052
|
+
uses.push(unquote(line));
|
|
3053
|
+
}
|
|
3054
|
+
} else if (/^use\s*\(/.test(line)) {
|
|
3055
|
+
inBlock = true;
|
|
3056
|
+
const rest = line.replace(/^use\s*\(/, "").trim();
|
|
3057
|
+
if (rest !== "" && !rest.startsWith(")")) {
|
|
3058
|
+
uses.push(unquote(rest));
|
|
3059
|
+
}
|
|
3060
|
+
} else if (/^use\s+\S/.test(line)) {
|
|
3061
|
+
uses.push(unquote(line.replace(/^use\s+/, "")));
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
return [...new Set(uses)];
|
|
3065
|
+
}
|
|
3066
|
+
function unquote(path) {
|
|
3067
|
+
return path.replaceAll(/^["'`]|["'`]$/g, "");
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// src/go-workspace/list-go-modules.use-case.ts
|
|
3071
|
+
var import_node_fs12 = require("fs");
|
|
3072
|
+
var import_node_path10 = require("path");
|
|
3073
|
+
function listGoModuleDirectories(workspaceRoot) {
|
|
3074
|
+
const goWork = (0, import_node_path10.join)(workspaceRoot, "go.work");
|
|
3075
|
+
if (fileExists(goWork)) {
|
|
3076
|
+
try {
|
|
3077
|
+
return parseGoWorkUses((0, import_node_fs12.readFileSync)(goWork, "utf8"));
|
|
3078
|
+
} catch {
|
|
3079
|
+
return [];
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
return fileExists((0, import_node_path10.join)(workspaceRoot, "go.mod")) ? ["."] : void 0;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
// src/ci-pipeline/go-tools.use-case.ts
|
|
2954
3086
|
function currentMachine() {
|
|
2955
3087
|
return { platform: process.platform, architecture: process.arch, home: (0, import_node_os.homedir)() };
|
|
2956
3088
|
}
|
|
2957
3089
|
var GOLANGCI_LINT_MODULE = "github.com/golangci/golangci-lint/v2/cmd/golangci-lint";
|
|
2958
3090
|
function downloadGoModules(workspaceRoot, processes, log) {
|
|
2959
|
-
|
|
3091
|
+
const modules = listGoModuleDirectories(workspaceRoot);
|
|
3092
|
+
if (modules === void 0) {
|
|
2960
3093
|
log("No Go projects - skipping.");
|
|
2961
3094
|
return 0;
|
|
2962
3095
|
}
|
|
2963
|
-
|
|
3096
|
+
for (const directory of modules) {
|
|
3097
|
+
const status = processes.run("go", directory === "." ? ["mod", "download"] : ["-C", directory, "mod", "download"]);
|
|
3098
|
+
if (status !== 0) {
|
|
3099
|
+
return status;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
return 0;
|
|
2964
3103
|
}
|
|
2965
3104
|
async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
2966
3105
|
const { processes, log, fetchBytes } = dependencies;
|
|
2967
|
-
if (
|
|
3106
|
+
if (listGoModuleDirectories(workspaceRoot) === void 0) {
|
|
2968
3107
|
log("No Go projects - skipping.");
|
|
2969
3108
|
return 0;
|
|
2970
3109
|
}
|
|
@@ -3001,30 +3140,30 @@ async function installGolangciLint(workspaceRoot, dependencies, machine) {
|
|
|
3001
3140
|
if ((0, import_node_crypto.createHash)("sha256").update(archive).digest("hex") !== entry[0]) {
|
|
3002
3141
|
throw new Error(`checksum mismatch for ${file}`);
|
|
3003
3142
|
}
|
|
3004
|
-
temporary = (0,
|
|
3005
|
-
const archivePath = (0,
|
|
3006
|
-
(0,
|
|
3007
|
-
const tar = platform === "windows" ? (0,
|
|
3143
|
+
temporary = (0, import_node_fs13.mkdtempSync)((0, import_node_path11.join)((0, import_node_os.tmpdir)(), "golangci-lint-"));
|
|
3144
|
+
const archivePath = (0, import_node_path11.join)(temporary, file);
|
|
3145
|
+
(0, import_node_fs13.writeFileSync)(archivePath, archive);
|
|
3146
|
+
const tar = platform === "windows" ? (0, import_node_path11.join)(process.env.SystemRoot ?? "", "System32", "tar.exe") : "tar";
|
|
3008
3147
|
if (processes.run(tar, ["-xf", archivePath, "-C", temporary]) !== 0) {
|
|
3009
3148
|
throw new Error(`could not extract ${file}`);
|
|
3010
3149
|
}
|
|
3011
3150
|
const executable = `golangci-lint${platform === "windows" ? ".exe" : ""}`;
|
|
3012
|
-
const bin = (0,
|
|
3013
|
-
(0,
|
|
3014
|
-
(0,
|
|
3015
|
-
(0,
|
|
3151
|
+
const bin = (0, import_node_path11.join)(gopath.stdout.trim(), "bin");
|
|
3152
|
+
(0, import_node_fs13.mkdirSync)(bin, { recursive: true });
|
|
3153
|
+
(0, import_node_fs13.copyFileSync)((0, import_node_path11.join)(temporary, name, executable), (0, import_node_path11.join)(bin, executable));
|
|
3154
|
+
(0, import_node_fs13.chmodSync)((0, import_node_path11.join)(bin, executable), 493);
|
|
3016
3155
|
log(`golangci-lint ${version} installed from its checksum-verified prebuilt release into ${bin}`);
|
|
3017
3156
|
return 0;
|
|
3018
3157
|
} catch (error) {
|
|
3019
3158
|
return fallback(error instanceof Error ? error.message : String(error));
|
|
3020
3159
|
} finally {
|
|
3021
3160
|
if (temporary !== void 0) {
|
|
3022
|
-
(0,
|
|
3161
|
+
(0, import_node_fs13.rmSync)(temporary, { recursive: true, force: true });
|
|
3023
3162
|
}
|
|
3024
3163
|
}
|
|
3025
3164
|
}
|
|
3026
3165
|
function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
3027
|
-
if (
|
|
3166
|
+
if (listGoModuleDirectories(workspaceRoot) === void 0) {
|
|
3028
3167
|
log("No Go projects - skipping.");
|
|
3029
3168
|
return;
|
|
3030
3169
|
}
|
|
@@ -3033,7 +3172,7 @@ function publishGoTools(workspaceRoot, host, environment, processes, log) {
|
|
|
3033
3172
|
log("Could not resolve GOPATH - skipping.");
|
|
3034
3173
|
return;
|
|
3035
3174
|
}
|
|
3036
|
-
addToPath(host, environment, (0,
|
|
3175
|
+
addToPath(host, environment, (0, import_node_path11.join)(gopath.stdout.trim(), "bin"), log);
|
|
3037
3176
|
}
|
|
3038
3177
|
|
|
3039
3178
|
// src/ci-pipeline/setup.use-case.ts
|
|
@@ -3041,15 +3180,15 @@ function pythonCommand(machine) {
|
|
|
3041
3180
|
return machine.platform === "win32" ? "python" : "python3";
|
|
3042
3181
|
}
|
|
3043
3182
|
function installPythonToolchain(workspaceRoot, processes, log, machine) {
|
|
3044
|
-
if (!(0,
|
|
3183
|
+
if (!(0, import_node_fs14.existsSync)((0, import_node_path12.join)(workspaceRoot, "requirements-dev.txt"))) {
|
|
3045
3184
|
log("No Python projects - skipping.");
|
|
3046
3185
|
return 0;
|
|
3047
3186
|
}
|
|
3048
3187
|
return processes.run(pythonCommand(machine), ["-m", "pip", "install", "-r", "requirements-dev.txt"]);
|
|
3049
3188
|
}
|
|
3050
3189
|
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,
|
|
3190
|
+
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));
|
|
3191
|
+
const requirements = (0, import_node_fs14.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot });
|
|
3053
3192
|
if (editable.length === 0 && requirements.length === 0) {
|
|
3054
3193
|
log("No Python projects - skipping.");
|
|
3055
3194
|
return 0;
|
|
@@ -3194,7 +3333,7 @@ function runPhase(phase, workspaceRoot, dependencies) {
|
|
|
3194
3333
|
}
|
|
3195
3334
|
|
|
3196
3335
|
// src/project-scaffolding/add-project.use-case.ts
|
|
3197
|
-
var
|
|
3336
|
+
var import_node_path38 = require("path");
|
|
3198
3337
|
var import_prompts3 = require("@inquirer/prompts");
|
|
3199
3338
|
|
|
3200
3339
|
// src/project-name/project-name.validator.ts
|
|
@@ -3207,8 +3346,8 @@ function assertValidProjectName(name, label) {
|
|
|
3207
3346
|
}
|
|
3208
3347
|
|
|
3209
3348
|
// src/project-scaffolding/csharp.use-case.ts
|
|
3210
|
-
var
|
|
3211
|
-
var
|
|
3349
|
+
var import_node_fs16 = require("fs");
|
|
3350
|
+
var import_node_path14 = require("path");
|
|
3212
3351
|
|
|
3213
3352
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
3214
3353
|
function csharpExampleFiles(identity) {
|
|
@@ -3249,10 +3388,10 @@ public class GreetUseCaseTests
|
|
|
3249
3388
|
}
|
|
3250
3389
|
|
|
3251
3390
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
3252
|
-
var
|
|
3253
|
-
var
|
|
3391
|
+
var import_node_fs15 = require("fs");
|
|
3392
|
+
var import_node_path13 = require("path");
|
|
3254
3393
|
function hasPlugin(workspaceRoot, packageName) {
|
|
3255
|
-
const manifest = readJson((0,
|
|
3394
|
+
const manifest = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3256
3395
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
3257
3396
|
return Object.hasOwn(installed, packageName);
|
|
3258
3397
|
}
|
|
@@ -3291,7 +3430,7 @@ function markPublic(manifestPath) {
|
|
|
3291
3430
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
3292
3431
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
3293
3432
|
writeFileEnsured(
|
|
3294
|
-
(0,
|
|
3433
|
+
(0, import_node_path13.join)(projectRoot, "README.md"),
|
|
3295
3434
|
[
|
|
3296
3435
|
`# ${projectName}`,
|
|
3297
3436
|
"",
|
|
@@ -3310,13 +3449,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
3310
3449
|
}
|
|
3311
3450
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
3312
3451
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
3313
|
-
const directory = (0,
|
|
3452
|
+
const directory = (0, import_node_path13.join)(workspaceRoot, scaffold);
|
|
3314
3453
|
try {
|
|
3315
|
-
const holdsAProject = (0,
|
|
3454
|
+
const holdsAProject = (0, import_node_fs15.readdirSync)(directory, { withFileTypes: true }).some(
|
|
3316
3455
|
(entry) => entry.isDirectory()
|
|
3317
3456
|
);
|
|
3318
3457
|
if (holdsAProject) {
|
|
3319
|
-
(0,
|
|
3458
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(directory, ".gitkeep"), { force: true });
|
|
3320
3459
|
}
|
|
3321
3460
|
} catch {
|
|
3322
3461
|
}
|
|
@@ -3336,7 +3475,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
3336
3475
|
}
|
|
3337
3476
|
}
|
|
3338
3477
|
function defaultScope(workspaceRoot) {
|
|
3339
|
-
const { name } = readJson((0,
|
|
3478
|
+
const { name } = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3340
3479
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
3341
3480
|
return `@${base}`;
|
|
3342
3481
|
}
|
|
@@ -3364,14 +3503,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
3364
3503
|
];
|
|
3365
3504
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
3366
3505
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
3367
|
-
(0,
|
|
3506
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
3368
3507
|
}
|
|
3369
|
-
(0,
|
|
3508
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
3370
3509
|
}
|
|
3371
3510
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
3372
3511
|
try {
|
|
3373
|
-
const entry = (0,
|
|
3374
|
-
return entry ? (0,
|
|
3512
|
+
const entry = (0, import_node_fs15.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
3513
|
+
return entry ? (0, import_node_path13.join)(workspaceRoot, entry) : void 0;
|
|
3375
3514
|
} catch {
|
|
3376
3515
|
return void 0;
|
|
3377
3516
|
}
|
|
@@ -3391,8 +3530,8 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
3391
3530
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component", empty);
|
|
3392
3531
|
}
|
|
3393
3532
|
function reshapeReactAppScaffold(projectRoot) {
|
|
3394
|
-
const appDir = (0,
|
|
3395
|
-
if (!(0,
|
|
3533
|
+
const appDir = (0, import_node_path13.join)(projectRoot, "src", "app");
|
|
3534
|
+
if (!(0, import_node_fs15.existsSync)((0, import_node_path13.join)(appDir, "app.tsx"))) {
|
|
3396
3535
|
return;
|
|
3397
3536
|
}
|
|
3398
3537
|
for (const [from, to] of [
|
|
@@ -3400,60 +3539,60 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
3400
3539
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
3401
3540
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
3402
3541
|
]) {
|
|
3403
|
-
if ((0,
|
|
3404
|
-
(0,
|
|
3542
|
+
if ((0, import_node_fs15.existsSync)((0, import_node_path13.join)(appDir, from))) {
|
|
3543
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(appDir, from), (0, import_node_path13.join)(appDir, to));
|
|
3405
3544
|
}
|
|
3406
3545
|
}
|
|
3407
3546
|
const rewrite = (file, from, to) => {
|
|
3408
|
-
if ((0,
|
|
3409
|
-
writeFileEnsured(file, repointSpecifier((0,
|
|
3547
|
+
if ((0, import_node_fs15.existsSync)(file)) {
|
|
3548
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs15.readFileSync)(file, "utf8"), from, to));
|
|
3410
3549
|
}
|
|
3411
3550
|
};
|
|
3412
|
-
rewrite((0,
|
|
3413
|
-
rewrite((0,
|
|
3414
|
-
rewrite((0,
|
|
3551
|
+
rewrite((0, import_node_path13.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
3552
|
+
rewrite((0, import_node_path13.join)(appDir, "app.component.spec.tsx"), "./app", "./app.component");
|
|
3553
|
+
rewrite((0, import_node_path13.join)(projectRoot, "src", "main.tsx"), "./app/app", "./app");
|
|
3415
3554
|
writeFileEnsured(
|
|
3416
|
-
(0,
|
|
3555
|
+
(0, import_node_path13.join)(appDir, "index.ts"),
|
|
3417
3556
|
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
3418
3557
|
);
|
|
3419
3558
|
}
|
|
3420
3559
|
function emptySlice(projectRoot, sliceDir) {
|
|
3421
|
-
for (const entry of (0,
|
|
3422
|
-
(0,
|
|
3560
|
+
for (const entry of (0, import_node_fs15.readdirSync)(sliceDir)) {
|
|
3561
|
+
(0, import_node_fs15.rmSync)((0, import_node_path13.join)(sliceDir, entry), { recursive: true, force: true });
|
|
3423
3562
|
}
|
|
3424
|
-
writeFileEnsured((0,
|
|
3425
|
-
addNxTargets((0,
|
|
3563
|
+
writeFileEnsured((0, import_node_path13.join)(sliceDir, "index.ts"), "export {}\n");
|
|
3564
|
+
addNxTargets((0, import_node_path13.join)(projectRoot, "package.json"), { test: { options: { passWithNoTests: true } } });
|
|
3426
3565
|
}
|
|
3427
3566
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
3428
|
-
const sourceDir = (0,
|
|
3429
|
-
const libDir = (0,
|
|
3430
|
-
if (!(0,
|
|
3567
|
+
const sourceDir = (0, import_node_path13.join)(projectRoot, "src");
|
|
3568
|
+
const libDir = (0, import_node_path13.join)(sourceDir, "lib");
|
|
3569
|
+
if (!(0, import_node_fs15.existsSync)((0, import_node_path13.join)(libDir, `${name}.${extension}`))) {
|
|
3431
3570
|
return;
|
|
3432
3571
|
}
|
|
3433
|
-
const sliceDir = (0,
|
|
3434
|
-
(0,
|
|
3435
|
-
for (const entry of (0,
|
|
3572
|
+
const sliceDir = (0, import_node_path13.join)(sourceDir, name);
|
|
3573
|
+
(0, import_node_fs15.mkdirSync)(sliceDir, { recursive: true });
|
|
3574
|
+
for (const entry of (0, import_node_fs15.readdirSync)(libDir)) {
|
|
3436
3575
|
if (entry === `${name}.${extension}`) {
|
|
3437
|
-
(0,
|
|
3576
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), (0, import_node_path13.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
3438
3577
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
3439
|
-
const renamed = (0,
|
|
3440
|
-
(0,
|
|
3441
|
-
writeFileEnsured(renamed, repointSpecifier((0,
|
|
3578
|
+
const renamed = (0, import_node_path13.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
3579
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), renamed);
|
|
3580
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs15.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
3442
3581
|
} else {
|
|
3443
|
-
(0,
|
|
3582
|
+
(0, import_node_fs15.renameSync)((0, import_node_path13.join)(libDir, entry), (0, import_node_path13.join)(sliceDir, entry));
|
|
3444
3583
|
}
|
|
3445
3584
|
}
|
|
3446
|
-
const barrel = (0,
|
|
3447
|
-
const esm = (0,
|
|
3448
|
-
writeFileEnsured((0,
|
|
3585
|
+
const barrel = (0, import_node_path13.join)(sourceDir, "index.ts");
|
|
3586
|
+
const esm = (0, import_node_fs15.existsSync)(barrel) && (0, import_node_fs15.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
3587
|
+
writeFileEnsured((0, import_node_path13.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
3449
3588
|
`);
|
|
3450
|
-
if ((0,
|
|
3589
|
+
if ((0, import_node_fs15.existsSync)(barrel)) {
|
|
3451
3590
|
writeFileEnsured(
|
|
3452
3591
|
barrel,
|
|
3453
|
-
(0,
|
|
3592
|
+
(0, import_node_fs15.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
3454
3593
|
);
|
|
3455
3594
|
}
|
|
3456
|
-
(0,
|
|
3595
|
+
(0, import_node_fs15.rmSync)(libDir, { recursive: true, force: true });
|
|
3457
3596
|
if (empty) {
|
|
3458
3597
|
emptySlice(projectRoot, sliceDir);
|
|
3459
3598
|
} else if (role === "use-case") {
|
|
@@ -3463,7 +3602,7 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
3463
3602
|
function writeWorkedExample(sliceDir, name, esm) {
|
|
3464
3603
|
const suffix = esm ? ".js" : "";
|
|
3465
3604
|
writeFileEnsured(
|
|
3466
|
-
(0,
|
|
3605
|
+
(0, import_node_path13.join)(sliceDir, `${name}.contract.ts`),
|
|
3467
3606
|
`/** What greeting someone returns. */
|
|
3468
3607
|
export interface Greeting {
|
|
3469
3608
|
readonly message: string
|
|
@@ -3471,7 +3610,7 @@ export interface Greeting {
|
|
|
3471
3610
|
`
|
|
3472
3611
|
);
|
|
3473
3612
|
writeFileEnsured(
|
|
3474
|
-
(0,
|
|
3613
|
+
(0, import_node_path13.join)(sliceDir, `${name}.use-case.ts`),
|
|
3475
3614
|
`import type { Greeting } from './${name}.contract${suffix}'
|
|
3476
3615
|
|
|
3477
3616
|
/**
|
|
@@ -3490,7 +3629,7 @@ export function greet (name: string): Greeting {
|
|
|
3490
3629
|
`
|
|
3491
3630
|
);
|
|
3492
3631
|
writeFileEnsured(
|
|
3493
|
-
(0,
|
|
3632
|
+
(0, import_node_path13.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
3494
3633
|
`import { greet } from './${name}.use-case${suffix}'
|
|
3495
3634
|
|
|
3496
3635
|
describe('greet', () => {
|
|
@@ -3501,7 +3640,7 @@ describe('greet', () => {
|
|
|
3501
3640
|
`
|
|
3502
3641
|
);
|
|
3503
3642
|
writeFileEnsured(
|
|
3504
|
-
(0,
|
|
3643
|
+
(0, import_node_path13.join)(sliceDir, "index.ts"),
|
|
3505
3644
|
`export * from './${name}.contract${suffix}'
|
|
3506
3645
|
export * from './${name}.use-case${suffix}'
|
|
3507
3646
|
`
|
|
@@ -3515,8 +3654,8 @@ function repointSpecifier(source, from, to) {
|
|
|
3515
3654
|
return result;
|
|
3516
3655
|
}
|
|
3517
3656
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
3518
|
-
const manifestPath = (0,
|
|
3519
|
-
if (!(0,
|
|
3657
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, "package.json");
|
|
3658
|
+
if (!(0, import_node_fs15.existsSync)(manifestPath)) {
|
|
3520
3659
|
return;
|
|
3521
3660
|
}
|
|
3522
3661
|
const manifest = readJson(manifestPath);
|
|
@@ -3543,11 +3682,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3543
3682
|
for (const [suffix, command] of extraScripts) {
|
|
3544
3683
|
scripts[`${name}:${suffix}`] = command;
|
|
3545
3684
|
}
|
|
3546
|
-
const dependabotPath = (0,
|
|
3547
|
-
if ((0,
|
|
3685
|
+
const dependabotPath = (0, import_node_path13.join)(workspaceRoot, ".github/dependabot.yml");
|
|
3686
|
+
if ((0, import_node_fs15.existsSync)(dependabotPath)) {
|
|
3548
3687
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
3549
3688
|
}
|
|
3550
|
-
const manifestPath = (0,
|
|
3689
|
+
const manifestPath = (0, import_node_path13.join)(workspaceRoot, "package.json");
|
|
3551
3690
|
const manifest = readJson(manifestPath);
|
|
3552
3691
|
const existingScripts = manifest.scripts ?? {};
|
|
3553
3692
|
writeFileEnsured(
|
|
@@ -3572,6 +3711,12 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3572
3711
|
...commands.start ? [projectTask(name, "start")] : [],
|
|
3573
3712
|
...Object.keys(commands.extra ?? {}).map((suffix) => projectTask(name, suffix))
|
|
3574
3713
|
];
|
|
3714
|
+
const folderName = workspaceFile.folders?.[0]?.name ?? (0, import_node_path13.basename)(codeWorkspacePath, ".code-workspace");
|
|
3715
|
+
const launchName = projectLaunchConfiguration(folderName, name).name;
|
|
3716
|
+
const launchConfigurations2 = [
|
|
3717
|
+
...(workspaceFile.launch?.configurations ?? []).filter((configuration) => configuration.name !== launchName),
|
|
3718
|
+
...commands.start ? [projectLaunchConfiguration(folderName, name)] : []
|
|
3719
|
+
];
|
|
3575
3720
|
writeFileEnsured(
|
|
3576
3721
|
codeWorkspacePath,
|
|
3577
3722
|
toJson({
|
|
@@ -3579,6 +3724,10 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3579
3724
|
tasks: {
|
|
3580
3725
|
version: workspaceFile.tasks?.version ?? "2.0.0",
|
|
3581
3726
|
tasks: [...existingTasks, ...newTasks]
|
|
3727
|
+
},
|
|
3728
|
+
launch: {
|
|
3729
|
+
version: workspaceFile.launch?.version ?? "0.2.0",
|
|
3730
|
+
configurations: launchConfigurations2
|
|
3582
3731
|
}
|
|
3583
3732
|
})
|
|
3584
3733
|
);
|
|
@@ -3586,7 +3735,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
3586
3735
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
3587
3736
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
3588
3737
|
try {
|
|
3589
|
-
return readJson((0,
|
|
3738
|
+
return readJson((0, import_node_path13.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
3590
3739
|
} catch {
|
|
3591
3740
|
return {};
|
|
3592
3741
|
}
|
|
@@ -3598,7 +3747,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
3598
3747
|
return;
|
|
3599
3748
|
}
|
|
3600
3749
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
3601
|
-
(root) => (0,
|
|
3750
|
+
(root) => (0, import_node_path13.join)(workspaceRoot, root, projectName, "package.json")
|
|
3602
3751
|
).find((candidate) => fileExists(candidate));
|
|
3603
3752
|
if (manifestPath === void 0) {
|
|
3604
3753
|
return;
|
|
@@ -3610,10 +3759,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
3610
3759
|
const remaining = Object.fromEntries(
|
|
3611
3760
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
3612
3761
|
);
|
|
3613
|
-
const rootManifest = readJson((0,
|
|
3762
|
+
const rootManifest = readJson((0, import_node_path13.join)(workspaceRoot, "package.json"));
|
|
3614
3763
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
3615
3764
|
writeFileEnsured(
|
|
3616
|
-
(0,
|
|
3765
|
+
(0, import_node_path13.join)(workspaceRoot, "package.json"),
|
|
3617
3766
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
3618
3767
|
);
|
|
3619
3768
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -3652,28 +3801,28 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
3652
3801
|
}
|
|
3653
3802
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
3654
3803
|
if (kind === "classlib") {
|
|
3655
|
-
(0,
|
|
3804
|
+
(0, import_node_fs16.rmSync)((0, import_node_path14.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
3656
3805
|
}
|
|
3657
3806
|
const files = csharpExampleFiles(identity);
|
|
3658
3807
|
for (const [file, contents] of Object.entries(files)) {
|
|
3659
|
-
writeFileEnsured((0,
|
|
3808
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, file), contents);
|
|
3660
3809
|
}
|
|
3661
3810
|
if (kind === "console") {
|
|
3662
|
-
writeFileEnsured((0,
|
|
3811
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
3663
3812
|
}
|
|
3664
3813
|
}
|
|
3665
3814
|
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
3666
|
-
const name = (0,
|
|
3815
|
+
const name = (0, import_node_path14.basename)(projectRoot);
|
|
3667
3816
|
const testRoot = `tests/${name}`;
|
|
3668
3817
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
3669
|
-
(0,
|
|
3670
|
-
writeFileEnsured((0,
|
|
3818
|
+
(0, import_node_fs16.rmSync)((0, import_node_path14.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
3819
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
3671
3820
|
writeFileEnsured(
|
|
3672
|
-
(0,
|
|
3821
|
+
(0, import_node_path14.join)(workspaceRoot, testRoot, "project.json"),
|
|
3673
3822
|
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
3674
3823
|
);
|
|
3675
|
-
const reference = (0,
|
|
3676
|
-
if (runShell("dotnet", ["add", (0,
|
|
3824
|
+
const reference = (0, import_node_path14.join)(workspaceRoot, projectRoot, `${identity}.csproj`);
|
|
3825
|
+
if (runShell("dotnet", ["add", (0, import_node_path14.join)(workspaceRoot, testRoot), "reference", reference], workspaceRoot) !== 0) {
|
|
3677
3826
|
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
3678
3827
|
}
|
|
3679
3828
|
}
|
|
@@ -3700,9 +3849,9 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
3700
3849
|
ensureAdmZip(workspaceRoot);
|
|
3701
3850
|
const projectRoot = `apps/${name}`;
|
|
3702
3851
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
3703
|
-
writeCsharpExample((0,
|
|
3852
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3704
3853
|
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
3705
|
-
addProjectJsonTargets((0,
|
|
3854
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3706
3855
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
3707
3856
|
start: csharpAppStartTarget(projectRoot)
|
|
3708
3857
|
});
|
|
@@ -3795,7 +3944,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
3795
3944
|
module.exports = CsharpVersionActions
|
|
3796
3945
|
`;
|
|
3797
3946
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
3798
|
-
writeFileEnsured((0,
|
|
3947
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
3799
3948
|
}
|
|
3800
3949
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
3801
3950
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -3810,7 +3959,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3810
3959
|
);
|
|
3811
3960
|
}
|
|
3812
3961
|
function addInitialVersion(csprojPath) {
|
|
3813
|
-
const contents = (0,
|
|
3962
|
+
const contents = (0, import_node_fs16.readFileSync)(csprojPath, "utf8");
|
|
3814
3963
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3815
3964
|
}
|
|
3816
3965
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3825,16 +3974,16 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3825
3974
|
const projectRoot = `packages/${name}`;
|
|
3826
3975
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3827
3976
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3828
|
-
writeCsharpExample((0,
|
|
3977
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3829
3978
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3830
|
-
addInitialVersion((0,
|
|
3979
|
+
addInitialVersion((0, import_node_path14.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3831
3980
|
writeCsharpVersionActions(workspaceRoot);
|
|
3832
|
-
addProjectJsonReleaseVersionActions((0,
|
|
3833
|
-
addProjectJsonTargets((0,
|
|
3981
|
+
addProjectJsonReleaseVersionActions((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"));
|
|
3982
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3834
3983
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
3835
3984
|
});
|
|
3836
3985
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
3837
|
-
writeFileEnsured((0,
|
|
3986
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
3838
3987
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
3839
3988
|
}
|
|
3840
3989
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -3843,7 +3992,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3843
3992
|
const projectRoot = `libs/${name}`;
|
|
3844
3993
|
const identity = pascalCase(name);
|
|
3845
3994
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3846
|
-
writeCsharpExample((0,
|
|
3995
|
+
writeCsharpExample((0, import_node_path14.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3847
3996
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3848
3997
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3849
3998
|
logger.step(
|
|
@@ -3912,20 +4061,20 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3912
4061
|
const projectRoot = `apps/${name}`;
|
|
3913
4062
|
const identity = pascalCase(name);
|
|
3914
4063
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
3915
|
-
const absoluteRoot = (0,
|
|
3916
|
-
writeFileEnsured((0,
|
|
3917
|
-
writeFileEnsured((0,
|
|
3918
|
-
writeFileEnsured((0,
|
|
4064
|
+
const absoluteRoot = (0, import_node_path14.join)(workspaceRoot, projectRoot);
|
|
4065
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
4066
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
4067
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3919
4068
|
const example = csharpExampleFiles(identity);
|
|
3920
4069
|
for (const [file, contents] of Object.entries(example)) {
|
|
3921
|
-
writeFileEnsured((0,
|
|
4070
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, file), contents);
|
|
3922
4071
|
}
|
|
3923
|
-
writeFileEnsured((0,
|
|
4072
|
+
writeFileEnsured((0, import_node_path14.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3924
4073
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3925
4074
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3926
4075
|
}
|
|
3927
4076
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3928
|
-
addProjectJsonTargets((0,
|
|
4077
|
+
addProjectJsonTargets((0, import_node_path14.join)(absoluteRoot, "project.json"), {
|
|
3929
4078
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3930
4079
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
3931
4080
|
});
|
|
@@ -3933,7 +4082,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3933
4082
|
}
|
|
3934
4083
|
|
|
3935
4084
|
// src/project-scaffolding/flutter.use-case.ts
|
|
3936
|
-
var
|
|
4085
|
+
var import_node_path15 = require("path");
|
|
3937
4086
|
function flutterAppStartTarget(name) {
|
|
3938
4087
|
return {
|
|
3939
4088
|
executor: "nx:run-commands",
|
|
@@ -3969,7 +4118,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
3969
4118
|
prepareFlutter(workspaceRoot);
|
|
3970
4119
|
ensureAdmZip(workspaceRoot);
|
|
3971
4120
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
3972
|
-
addProjectJsonTargets((0,
|
|
4121
|
+
addProjectJsonTargets((0, import_node_path15.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3973
4122
|
start: flutterAppStartTarget(name)
|
|
3974
4123
|
});
|
|
3975
4124
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -3986,8 +4135,8 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3986
4135
|
}
|
|
3987
4136
|
|
|
3988
4137
|
// src/project-scaffolding/go.use-case.ts
|
|
3989
|
-
var
|
|
3990
|
-
var
|
|
4138
|
+
var import_node_fs19 = require("fs");
|
|
4139
|
+
var import_node_path18 = require("path");
|
|
3991
4140
|
|
|
3992
4141
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
3993
4142
|
function greetingContract(packageName) {
|
|
@@ -4055,82 +4204,9 @@ function goAppExampleFiles(modulePath) {
|
|
|
4055
4204
|
};
|
|
4056
4205
|
}
|
|
4057
4206
|
|
|
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
4207
|
// src/project-scaffolding/go-release.use-case.ts
|
|
4132
|
-
var
|
|
4133
|
-
var
|
|
4208
|
+
var import_node_fs17 = require("fs");
|
|
4209
|
+
var import_node_path16 = require("path");
|
|
4134
4210
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
4135
4211
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
4136
4212
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -4256,7 +4332,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
4256
4332
|
}
|
|
4257
4333
|
};
|
|
4258
4334
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
4259
|
-
const projectJsonPath = (0,
|
|
4335
|
+
const projectJsonPath = (0, import_node_path16.join)(workspaceRoot, "apps", name, "project.json");
|
|
4260
4336
|
if (!fileExists(projectJsonPath)) {
|
|
4261
4337
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
4262
4338
|
}
|
|
@@ -4277,22 +4353,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
4277
4353
|
}
|
|
4278
4354
|
})
|
|
4279
4355
|
);
|
|
4280
|
-
writeFileEnsured((0,
|
|
4356
|
+
writeFileEnsured((0, import_node_path16.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
4281
4357
|
}
|
|
4282
4358
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
4283
|
-
const apps = (0,
|
|
4359
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4284
4360
|
let entries;
|
|
4285
4361
|
try {
|
|
4286
|
-
entries = (0,
|
|
4362
|
+
entries = (0, import_node_fs17.readdirSync)(apps);
|
|
4287
4363
|
} catch {
|
|
4288
4364
|
return false;
|
|
4289
4365
|
}
|
|
4290
4366
|
const hasReleasableApp = entries.some((entry) => {
|
|
4291
|
-
const projectJsonPath = (0,
|
|
4367
|
+
const projectJsonPath = (0, import_node_path16.join)(apps, entry, "project.json");
|
|
4292
4368
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
4293
4369
|
});
|
|
4294
|
-
const path = (0,
|
|
4295
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
4370
|
+
const path = (0, import_node_path16.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
4371
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs17.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
4296
4372
|
return false;
|
|
4297
4373
|
}
|
|
4298
4374
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -4300,8 +4376,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
4300
4376
|
}
|
|
4301
4377
|
|
|
4302
4378
|
// src/project-scaffolding/go-web.use-case.ts
|
|
4303
|
-
var
|
|
4304
|
-
var
|
|
4379
|
+
var import_node_fs18 = require("fs");
|
|
4380
|
+
var import_node_path17 = require("path");
|
|
4305
4381
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
4306
4382
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
4307
4383
|
var GO_WEB_SOURCE = `package main
|
|
@@ -4379,18 +4455,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
4379
4455
|
}
|
|
4380
4456
|
`;
|
|
4381
4457
|
function assertWebApp(workspaceRoot, web) {
|
|
4382
|
-
const directory = (0,
|
|
4383
|
-
const isReactApp = fileExists((0,
|
|
4458
|
+
const directory = (0, import_node_path17.join)(workspaceRoot, "apps", web);
|
|
4459
|
+
const isReactApp = fileExists((0, import_node_path17.join)(directory, "package.json")) && (0, import_node_fs18.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
4384
4460
|
if (!isReactApp) {
|
|
4385
4461
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
4386
4462
|
}
|
|
4387
4463
|
}
|
|
4388
4464
|
function webProjectName(workspaceRoot, web) {
|
|
4389
|
-
const manifest = readJson((0,
|
|
4465
|
+
const manifest = readJson((0, import_node_path17.join)(workspaceRoot, "apps", web, "package.json"));
|
|
4390
4466
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
4391
4467
|
}
|
|
4392
4468
|
function addApiProxy(viteConfigPath) {
|
|
4393
|
-
const source = (0,
|
|
4469
|
+
const source = (0, import_node_fs18.readFileSync)(viteConfigPath, "utf8");
|
|
4394
4470
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
4395
4471
|
return false;
|
|
4396
4472
|
}
|
|
@@ -4403,7 +4479,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
4403
4479
|
return true;
|
|
4404
4480
|
}
|
|
4405
4481
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
4406
|
-
const projectJsonPath = (0,
|
|
4482
|
+
const projectJsonPath = (0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json");
|
|
4407
4483
|
const project = readJson(projectJsonPath);
|
|
4408
4484
|
const webName = webProjectName(workspaceRoot, web);
|
|
4409
4485
|
const targets = project.targets ?? {};
|
|
@@ -4429,13 +4505,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
4429
4505
|
projectJsonPath,
|
|
4430
4506
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
4431
4507
|
);
|
|
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,
|
|
4508
|
+
const directory = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4509
|
+
writeFileEnsured((0, import_node_path17.join)(directory, ".gitignore"), "/web/\n");
|
|
4510
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
4511
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
4512
|
+
writeFileEnsured((0, import_node_path17.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
4513
|
+
const viteConfig = (0, import_node_fs18.readdirSync)((0, import_node_path17.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
4514
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path17.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
4439
4515
|
logger.warn(
|
|
4440
4516
|
`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
4517
|
);
|
|
@@ -4469,7 +4545,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
4469
4545
|
}
|
|
4470
4546
|
}
|
|
4471
4547
|
function ensureGoModule(workspaceRoot) {
|
|
4472
|
-
if (fileExists((0,
|
|
4548
|
+
if (fileExists((0, import_node_path18.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path18.join)(workspaceRoot, "go.mod"))) {
|
|
4473
4549
|
return;
|
|
4474
4550
|
}
|
|
4475
4551
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -4477,26 +4553,26 @@ function ensureGoModule(workspaceRoot) {
|
|
|
4477
4553
|
}
|
|
4478
4554
|
function readGoModModule(goModPath) {
|
|
4479
4555
|
try {
|
|
4480
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
4556
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs19.readFileSync)(goModPath, "utf8"))?.[1];
|
|
4481
4557
|
} catch {
|
|
4482
4558
|
return void 0;
|
|
4483
4559
|
}
|
|
4484
4560
|
}
|
|
4485
4561
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
4486
|
-
const projectModule = readGoModModule((0,
|
|
4562
|
+
const projectModule = readGoModModule((0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod"));
|
|
4487
4563
|
if (projectModule !== void 0) {
|
|
4488
4564
|
return projectModule;
|
|
4489
4565
|
}
|
|
4490
|
-
const rootModule = readGoModModule((0,
|
|
4566
|
+
const rootModule = readGoModModule((0, import_node_path18.join)(workspaceRoot, "go.mod"));
|
|
4491
4567
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
4492
4568
|
}
|
|
4493
4569
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
4494
4570
|
const prefix = goModulePrefix(workspaceRoot);
|
|
4495
|
-
const goModPath = (0,
|
|
4571
|
+
const goModPath = (0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod");
|
|
4496
4572
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
4497
4573
|
return;
|
|
4498
4574
|
}
|
|
4499
|
-
const rewritten = (0,
|
|
4575
|
+
const rewritten = (0, import_node_fs19.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
4500
4576
|
writeFileEnsured(goModPath, rewritten);
|
|
4501
4577
|
}
|
|
4502
4578
|
var GO_DIRECTIVE_CEILING = "1.24";
|
|
@@ -4509,7 +4585,7 @@ function clampGoDirective(filePath) {
|
|
|
4509
4585
|
if (!fileExists(filePath)) {
|
|
4510
4586
|
return;
|
|
4511
4587
|
}
|
|
4512
|
-
const before = (0,
|
|
4588
|
+
const before = (0, import_node_fs19.readFileSync)(filePath, "utf8");
|
|
4513
4589
|
const directive = /^go\s+(\d+\.\d+(?:\.\d+)?)/m.exec(before);
|
|
4514
4590
|
if (directive === null || !exceedsGoCeiling(directive[1])) {
|
|
4515
4591
|
return;
|
|
@@ -4518,19 +4594,19 @@ function clampGoDirective(filePath) {
|
|
|
4518
4594
|
writeFileEnsured(filePath, after);
|
|
4519
4595
|
}
|
|
4520
4596
|
function pinGoDirective(workspaceRoot, projectDir) {
|
|
4521
|
-
clampGoDirective((0,
|
|
4522
|
-
clampGoDirective((0,
|
|
4597
|
+
clampGoDirective((0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod"));
|
|
4598
|
+
clampGoDirective((0, import_node_path18.join)(workspaceRoot, "go.work"));
|
|
4523
4599
|
}
|
|
4524
4600
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
4525
|
-
const goModPath = (0,
|
|
4526
|
-
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0,
|
|
4601
|
+
const goModPath = (0, import_node_path18.join)(workspaceRoot, projectDir, "go.mod");
|
|
4602
|
+
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs19.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
4527
4603
|
if (modulePath === void 0) {
|
|
4528
4604
|
return;
|
|
4529
4605
|
}
|
|
4530
|
-
(0,
|
|
4606
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
4531
4607
|
const example = goAppExampleFiles(modulePath);
|
|
4532
4608
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4533
|
-
writeFileEnsured((0,
|
|
4609
|
+
writeFileEnsured((0, import_node_path18.join)(workspaceRoot, projectDir, relative), contents);
|
|
4534
4610
|
}
|
|
4535
4611
|
}
|
|
4536
4612
|
function goTestTarget() {
|
|
@@ -4608,16 +4684,16 @@ function goNativePackageTarget(name) {
|
|
|
4608
4684
|
}
|
|
4609
4685
|
function addGoPlatformTargets(workspaceRoot) {
|
|
4610
4686
|
const changed = [];
|
|
4611
|
-
const apps = (0,
|
|
4687
|
+
const apps = (0, import_node_path18.join)(workspaceRoot, "apps");
|
|
4612
4688
|
if (!fileExists(apps)) {
|
|
4613
4689
|
return changed;
|
|
4614
4690
|
}
|
|
4615
|
-
for (const name of (0,
|
|
4616
|
-
const projectJsonPath = (0,
|
|
4691
|
+
for (const name of (0, import_node_fs19.readdirSync)(apps)) {
|
|
4692
|
+
const projectJsonPath = (0, import_node_path18.join)(apps, name, "project.json");
|
|
4617
4693
|
if (!fileExists(projectJsonPath)) {
|
|
4618
4694
|
continue;
|
|
4619
4695
|
}
|
|
4620
|
-
const project = JSON.parse((0,
|
|
4696
|
+
const project = JSON.parse((0, import_node_fs19.readFileSync)(projectJsonPath, "utf8"));
|
|
4621
4697
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
4622
4698
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
4623
4699
|
continue;
|
|
@@ -4653,8 +4729,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
4653
4729
|
}
|
|
4654
4730
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
4655
4731
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
4656
|
-
(0,
|
|
4657
|
-
(0,
|
|
4732
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
4733
|
+
(0, import_node_fs19.rmSync)((0, import_node_path18.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
4658
4734
|
const files = [
|
|
4659
4735
|
[
|
|
4660
4736
|
"doc.go",
|
|
@@ -4664,7 +4740,7 @@ package ${packageName}
|
|
|
4664
4740
|
`
|
|
4665
4741
|
],
|
|
4666
4742
|
[
|
|
4667
|
-
(0,
|
|
4743
|
+
(0, import_node_path18.join)(packageName, "doc.go"),
|
|
4668
4744
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
4669
4745
|
// the outcome it delivers, and add one package per further outcome.
|
|
4670
4746
|
package ${packageName}
|
|
@@ -4672,11 +4748,11 @@ package ${packageName}
|
|
|
4672
4748
|
],
|
|
4673
4749
|
// The starter slice: a contract, a use case and its test (see goLibraryExampleFiles).
|
|
4674
4750
|
...Object.entries(goLibraryExampleFiles(packageName, fileStem)).map(
|
|
4675
|
-
([name, content]) => [(0,
|
|
4751
|
+
([name, content]) => [(0, import_node_path18.join)(packageName, name), content]
|
|
4676
4752
|
)
|
|
4677
4753
|
];
|
|
4678
4754
|
for (const [relativePath, content] of files) {
|
|
4679
|
-
const path = (0,
|
|
4755
|
+
const path = (0, import_node_path18.join)(projectRoot, relativePath);
|
|
4680
4756
|
if (!fileExists(path)) {
|
|
4681
4757
|
writeFileEnsured(path, content);
|
|
4682
4758
|
}
|
|
@@ -4715,7 +4791,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4715
4791
|
if (options.web === void 0) {
|
|
4716
4792
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4717
4793
|
}
|
|
4718
|
-
addProjectJsonTargets((0,
|
|
4794
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4719
4795
|
build: goBuildTarget(name),
|
|
4720
4796
|
test: goTestTarget(),
|
|
4721
4797
|
lint: goLintTarget(),
|
|
@@ -4756,7 +4832,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4756
4832
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4757
4833
|
pinGoDirective(workspaceRoot, `apps/${name}`);
|
|
4758
4834
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4759
|
-
addProjectJsonTargets((0,
|
|
4835
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4760
4836
|
"build": goBuildTarget(name),
|
|
4761
4837
|
"test": goTestTarget(),
|
|
4762
4838
|
"lint": goLintTarget(),
|
|
@@ -4781,11 +4857,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4781
4857
|
);
|
|
4782
4858
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4783
4859
|
pinGoDirective(workspaceRoot, `packages/${name}`);
|
|
4784
|
-
addProjectJsonTargets((0,
|
|
4860
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4785
4861
|
test: goTestTarget(),
|
|
4786
4862
|
lint: goLintTarget()
|
|
4787
4863
|
});
|
|
4788
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4864
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path18.join)(workspaceRoot, "packages", name), name);
|
|
4789
4865
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4790
4866
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
4791
4867
|
if (module2) {
|
|
@@ -4807,11 +4883,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4807
4883
|
);
|
|
4808
4884
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4809
4885
|
pinGoDirective(workspaceRoot, `libs/${name}`);
|
|
4810
|
-
addProjectJsonTargets((0,
|
|
4886
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4811
4887
|
test: goTestTarget(),
|
|
4812
4888
|
lint: goLintTarget()
|
|
4813
4889
|
});
|
|
4814
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4890
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path18.join)(workspaceRoot, "libs", name), name);
|
|
4815
4891
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4816
4892
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
4817
4893
|
if (module2) {
|
|
@@ -4820,8 +4896,8 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4820
4896
|
}
|
|
4821
4897
|
|
|
4822
4898
|
// src/esm-conversion/esm-conversion.use-case.ts
|
|
4823
|
-
var
|
|
4824
|
-
var
|
|
4899
|
+
var import_node_fs20 = require("fs");
|
|
4900
|
+
var import_node_path19 = require("path");
|
|
4825
4901
|
|
|
4826
4902
|
// src/esm-conversion/esm-specifiers.algorithm.ts
|
|
4827
4903
|
var RELATIVE_SPECIFIER = /((?:\bfrom|\bimport)\s*)(['"])(\.{1,2}\/[^'"\n]*|\.{1,2})\2/g;
|
|
@@ -4841,9 +4917,9 @@ var SAMPLE_DIRECTORIES = ["./hello"];
|
|
|
4841
4917
|
var JEST_ANCHOR = " moduleFileExtensions:";
|
|
4842
4918
|
var JEST_MAPPER = String.raw` moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },`;
|
|
4843
4919
|
function typescriptFiles(directory) {
|
|
4844
|
-
const entries = (0,
|
|
4920
|
+
const entries = (0, import_node_fs20.readdirSync)(directory, { withFileTypes: true });
|
|
4845
4921
|
return entries.flatMap((entry) => {
|
|
4846
|
-
const path = (0,
|
|
4922
|
+
const path = (0, import_node_path19.join)(directory, entry.name);
|
|
4847
4923
|
if (entry.isDirectory()) {
|
|
4848
4924
|
return typescriptFiles(path);
|
|
4849
4925
|
}
|
|
@@ -4851,7 +4927,7 @@ function typescriptFiles(directory) {
|
|
|
4851
4927
|
});
|
|
4852
4928
|
}
|
|
4853
4929
|
function convertAppToEsm(appRoot) {
|
|
4854
|
-
const manifestPath = (0,
|
|
4930
|
+
const manifestPath = (0, import_node_path19.join)(appRoot, "package.json");
|
|
4855
4931
|
const manifest = readJson(manifestPath);
|
|
4856
4932
|
const build = manifest.nx?.targets?.build;
|
|
4857
4933
|
if (build?.options === void 0) {
|
|
@@ -4859,17 +4935,17 @@ function convertAppToEsm(appRoot) {
|
|
|
4859
4935
|
}
|
|
4860
4936
|
build.options.format = ["esm"];
|
|
4861
4937
|
writeFileEnsured(manifestPath, toJson({ ...manifest, type: "module" }));
|
|
4862
|
-
const sources = typescriptFiles((0,
|
|
4938
|
+
const sources = typescriptFiles((0, import_node_path19.join)(appRoot, "src"));
|
|
4863
4939
|
for (const file of sources) {
|
|
4864
|
-
const source = (0,
|
|
4940
|
+
const source = (0, import_node_fs20.readFileSync)(file, "utf8");
|
|
4865
4941
|
const converted = withJsSpecifiers(source, SAMPLE_DIRECTORIES);
|
|
4866
4942
|
if (converted !== source) {
|
|
4867
4943
|
writeFileEnsured(file, converted);
|
|
4868
4944
|
}
|
|
4869
4945
|
}
|
|
4870
|
-
const jestPath = (0,
|
|
4946
|
+
const jestPath = (0, import_node_path19.join)(appRoot, "jest.config.cts");
|
|
4871
4947
|
if (fileExists(jestPath)) {
|
|
4872
|
-
const jest = (0,
|
|
4948
|
+
const jest = (0, import_node_fs20.readFileSync)(jestPath, "utf8");
|
|
4873
4949
|
if (!jest.includes("moduleNameMapper")) {
|
|
4874
4950
|
if (!jest.includes(JEST_ANCHOR)) {
|
|
4875
4951
|
throw new Error(`${jestPath} has no moduleFileExtensions line to put the .js mapper above; the generator's output changed.`);
|
|
@@ -4881,7 +4957,7 @@ ${JEST_ANCHOR}`));
|
|
|
4881
4957
|
}
|
|
4882
4958
|
|
|
4883
4959
|
// src/project-scaffolding/node.use-case.ts
|
|
4884
|
-
var
|
|
4960
|
+
var import_node_path20 = require("path");
|
|
4885
4961
|
|
|
4886
4962
|
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
4887
4963
|
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
@@ -5004,12 +5080,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
5004
5080
|
],
|
|
5005
5081
|
workspaceRoot
|
|
5006
5082
|
);
|
|
5007
|
-
const appRoot = (0,
|
|
5083
|
+
const appRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
5008
5084
|
separateDeclarationOutput(appRoot);
|
|
5009
5085
|
repairAssetMapping(appRoot, name);
|
|
5010
5086
|
}
|
|
5011
5087
|
function separateDeclarationOutput(appRoot) {
|
|
5012
|
-
const tsconfigPath = (0,
|
|
5088
|
+
const tsconfigPath = (0, import_node_path20.join)(appRoot, "tsconfig.app.json");
|
|
5013
5089
|
if (!fileExists(tsconfigPath)) {
|
|
5014
5090
|
return;
|
|
5015
5091
|
}
|
|
@@ -5031,7 +5107,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
5031
5107
|
);
|
|
5032
5108
|
}
|
|
5033
5109
|
function repairAssetMapping(appRoot, name) {
|
|
5034
|
-
const manifestPath = (0,
|
|
5110
|
+
const manifestPath = (0, import_node_path20.join)(appRoot, "package.json");
|
|
5035
5111
|
if (!fileExists(manifestPath)) {
|
|
5036
5112
|
return;
|
|
5037
5113
|
}
|
|
@@ -5060,14 +5136,14 @@ function addNodeApp(workspaceRoot, name, stack, framework = "none", esm = false)
|
|
|
5060
5136
|
const example = nodeAppExampleFiles(framework);
|
|
5061
5137
|
if (example !== null) {
|
|
5062
5138
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5063
|
-
writeFileEnsured((0,
|
|
5139
|
+
writeFileEnsured((0, import_node_path20.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
5064
5140
|
}
|
|
5065
5141
|
}
|
|
5066
5142
|
if (esm) {
|
|
5067
|
-
convertAppToEsm((0,
|
|
5143
|
+
convertAppToEsm((0, import_node_path20.join)(workspaceRoot, "apps", name));
|
|
5068
5144
|
}
|
|
5069
5145
|
ensureAdmZip(workspaceRoot);
|
|
5070
|
-
addNxTargets((0,
|
|
5146
|
+
addNxTargets((0, import_node_path20.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
5071
5147
|
package: nodeAppPackageTarget(name)
|
|
5072
5148
|
});
|
|
5073
5149
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -5136,10 +5212,10 @@ describe('greet', () => {
|
|
|
5136
5212
|
})
|
|
5137
5213
|
`;
|
|
5138
5214
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
5139
|
-
const manifestPath = (0,
|
|
5215
|
+
const manifestPath = (0, import_node_path20.join)(nodeFunctionAppRoot, "package.json");
|
|
5140
5216
|
const manifest = readJson(manifestPath);
|
|
5141
5217
|
const azureFunctionsVersion = readJson(
|
|
5142
|
-
(0,
|
|
5218
|
+
(0, import_node_path20.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
5143
5219
|
).version;
|
|
5144
5220
|
const dependencies = manifest.dependencies ?? {};
|
|
5145
5221
|
writeFileEnsured(
|
|
@@ -5182,23 +5258,23 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
5182
5258
|
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false, esm = false) {
|
|
5183
5259
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
5184
5260
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
5185
|
-
const nodeFunctionAppRoot = (0,
|
|
5186
|
-
writeFileEnsured((0,
|
|
5261
|
+
const nodeFunctionAppRoot = (0, import_node_path20.join)(workspaceRoot, "apps", name);
|
|
5262
|
+
writeFileEnsured((0, import_node_path20.join)(nodeFunctionAppRoot, "src/main.ts"), empty ? NODE_FUNCTION_APP_MAIN_EMPTY : NODE_FUNCTION_APP_MAIN);
|
|
5187
5263
|
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,
|
|
5264
|
+
const slice = (0, import_node_path20.join)(nodeFunctionAppRoot, "src/hello");
|
|
5265
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
5266
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greet.use-case.ts"), NODE_FUNCTION_APP_GREET_USE_CASE);
|
|
5267
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greet.use-case.spec.ts"), NODE_FUNCTION_APP_GREET_SPEC);
|
|
5268
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "greeting.contract.ts"), NODE_FUNCTION_APP_GREETING_CONTRACT);
|
|
5269
|
+
writeFileEnsured((0, import_node_path20.join)(slice, "index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
5270
|
+
}
|
|
5271
|
+
writeFileEnsured((0, import_node_path20.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
5196
5272
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
5197
5273
|
if (esm) {
|
|
5198
5274
|
convertAppToEsm(nodeFunctionAppRoot);
|
|
5199
5275
|
}
|
|
5200
5276
|
ensureAdmZip(workspaceRoot);
|
|
5201
|
-
addNxTargets((0,
|
|
5277
|
+
addNxTargets((0, import_node_path20.join)(nodeFunctionAppRoot, "package.json"), {
|
|
5202
5278
|
package: nodeFunctionAppPackageTarget(name),
|
|
5203
5279
|
prune: nodeFunctionAppPruneTarget(name),
|
|
5204
5280
|
start: nodeFunctionAppStartTarget(name),
|
|
@@ -5210,24 +5286,24 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false, esm = fal
|
|
|
5210
5286
|
}
|
|
5211
5287
|
|
|
5212
5288
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
5213
|
-
var
|
|
5289
|
+
var import_node_path26 = require("path");
|
|
5214
5290
|
|
|
5215
5291
|
// src/lockfile-pruning/prune-stale-local-registry.use-case.ts
|
|
5216
|
-
var
|
|
5217
|
-
var
|
|
5292
|
+
var import_node_fs22 = require("fs");
|
|
5293
|
+
var import_node_path22 = require("path");
|
|
5218
5294
|
|
|
5219
5295
|
// src/lockfile-pruning/stale-local-registry.validator.ts
|
|
5220
|
-
var
|
|
5221
|
-
var
|
|
5296
|
+
var import_node_fs21 = require("fs");
|
|
5297
|
+
var import_node_path21 = require("path");
|
|
5222
5298
|
var LOCAL_REGISTRY_PACKAGE = "verdaccio";
|
|
5223
5299
|
var LOCAL_REGISTRY_LOCK_KEY = `node_modules/${LOCAL_REGISTRY_PACKAGE}`;
|
|
5224
5300
|
var DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
5225
5301
|
function readJsonFile(path) {
|
|
5226
|
-
if (!(0,
|
|
5302
|
+
if (!(0, import_node_fs21.existsSync)(path)) {
|
|
5227
5303
|
return void 0;
|
|
5228
5304
|
}
|
|
5229
5305
|
try {
|
|
5230
|
-
return JSON.parse((0,
|
|
5306
|
+
return JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
|
|
5231
5307
|
} catch {
|
|
5232
5308
|
return void 0;
|
|
5233
5309
|
}
|
|
@@ -5239,13 +5315,13 @@ function declaresLocalRegistry(manifest) {
|
|
|
5239
5315
|
});
|
|
5240
5316
|
}
|
|
5241
5317
|
function hasStaleLocalRegistry(workspaceRoot) {
|
|
5242
|
-
const lock = readJsonFile((0,
|
|
5318
|
+
const lock = readJsonFile((0, import_node_path21.join)(workspaceRoot, "package-lock.json"));
|
|
5243
5319
|
const entries = lock?.packages ?? {};
|
|
5244
5320
|
if (!Object.hasOwn(entries, LOCAL_REGISTRY_LOCK_KEY)) {
|
|
5245
5321
|
return false;
|
|
5246
5322
|
}
|
|
5247
5323
|
const members = Object.keys(entries).filter((key) => key !== "" && !key.startsWith("node_modules/") && !key.includes("/node_modules/"));
|
|
5248
|
-
const manifests = ["", ...members].map((directory) => readJsonFile((0,
|
|
5324
|
+
const manifests = ["", ...members].map((directory) => readJsonFile((0, import_node_path21.join)(workspaceRoot, directory, "package.json")));
|
|
5249
5325
|
return manifests.every((manifest) => !declaresLocalRegistry(manifest));
|
|
5250
5326
|
}
|
|
5251
5327
|
|
|
@@ -5254,21 +5330,21 @@ function pruneStaleLocalRegistry(workspaceRoot, resolve2 = runShell) {
|
|
|
5254
5330
|
if (!hasStaleLocalRegistry(workspaceRoot)) {
|
|
5255
5331
|
return { stale: false, status: 0 };
|
|
5256
5332
|
}
|
|
5257
|
-
const lockPath = (0,
|
|
5258
|
-
const lock = JSON.parse((0,
|
|
5333
|
+
const lockPath = (0, import_node_path22.join)(workspaceRoot, "package-lock.json");
|
|
5334
|
+
const lock = JSON.parse((0, import_node_fs22.readFileSync)(lockPath, "utf8"));
|
|
5259
5335
|
Reflect.deleteProperty(lock.packages, LOCAL_REGISTRY_LOCK_KEY);
|
|
5260
5336
|
const root = lock.packages[""];
|
|
5261
5337
|
if (root?.devDependencies !== void 0) {
|
|
5262
5338
|
Reflect.deleteProperty(root.devDependencies, LOCAL_REGISTRY_PACKAGE);
|
|
5263
5339
|
}
|
|
5264
|
-
(0,
|
|
5340
|
+
(0, import_node_fs22.writeFileSync)(lockPath, `${JSON.stringify(lock, void 0, 2)}
|
|
5265
5341
|
`);
|
|
5266
5342
|
return { stale: true, status: resolve2("npm", ["install", "--package-lock-only", "--ignore-scripts", "--no-audit", "--no-fund"], workspaceRoot) };
|
|
5267
5343
|
}
|
|
5268
5344
|
|
|
5269
5345
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
5270
|
-
var
|
|
5271
|
-
var
|
|
5346
|
+
var import_node_fs23 = require("fs");
|
|
5347
|
+
var import_node_path23 = require("path");
|
|
5272
5348
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
5273
5349
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
5274
5350
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -5291,14 +5367,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
5291
5367
|
}
|
|
5292
5368
|
function repairPublishableManifests(workspaceRoot) {
|
|
5293
5369
|
const changed = [];
|
|
5294
|
-
const manifests = (0,
|
|
5370
|
+
const manifests = (0, import_node_fs23.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
5295
5371
|
cwd: workspaceRoot
|
|
5296
5372
|
});
|
|
5297
5373
|
for (const relativePath of manifests) {
|
|
5298
|
-
const manifestPath = (0,
|
|
5299
|
-
const before = (0,
|
|
5374
|
+
const manifestPath = (0, import_node_path23.join)(workspaceRoot, relativePath);
|
|
5375
|
+
const before = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5300
5376
|
repairPublishableManifest(manifestPath);
|
|
5301
|
-
const after = (0,
|
|
5377
|
+
const after = (0, import_node_fs23.readFileSync)(manifestPath, "utf8");
|
|
5302
5378
|
if (after !== before) {
|
|
5303
5379
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
5304
5380
|
}
|
|
@@ -5307,8 +5383,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
5307
5383
|
}
|
|
5308
5384
|
|
|
5309
5385
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5310
|
-
var
|
|
5311
|
-
var
|
|
5386
|
+
var import_node_fs24 = require("fs");
|
|
5387
|
+
var import_node_path24 = require("path");
|
|
5312
5388
|
|
|
5313
5389
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
5314
5390
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -5526,12 +5602,12 @@ ${DECLARATION_SPECIFIER_PLUGIN},`);
|
|
|
5526
5602
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5527
5603
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
5528
5604
|
const changed = [];
|
|
5529
|
-
const configs = (0,
|
|
5605
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5530
5606
|
cwd: workspaceRoot
|
|
5531
5607
|
});
|
|
5532
5608
|
for (const relativePath of configs) {
|
|
5533
|
-
const configPath = (0,
|
|
5534
|
-
const before = (0,
|
|
5609
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5610
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5535
5611
|
const after = withRollupSourceMaps(before);
|
|
5536
5612
|
if (after !== before) {
|
|
5537
5613
|
writeFileEnsured(configPath, after);
|
|
@@ -5542,12 +5618,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
5542
5618
|
}
|
|
5543
5619
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5544
5620
|
const changed = [];
|
|
5545
|
-
const configs = (0,
|
|
5621
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5546
5622
|
cwd: workspaceRoot
|
|
5547
5623
|
});
|
|
5548
5624
|
for (const relativePath of configs) {
|
|
5549
|
-
const configPath = (0,
|
|
5550
|
-
const before = (0,
|
|
5625
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5626
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5551
5627
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
5552
5628
|
if (after !== before) {
|
|
5553
5629
|
writeFileEnsured(configPath, after);
|
|
@@ -5557,11 +5633,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
5557
5633
|
return changed;
|
|
5558
5634
|
}
|
|
5559
5635
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
5560
|
-
const configPath = (0,
|
|
5636
|
+
const configPath = (0, import_node_path24.join)(projectRoot, "rollup.config.cjs");
|
|
5561
5637
|
if (!fileExists(configPath)) {
|
|
5562
5638
|
return;
|
|
5563
5639
|
}
|
|
5564
|
-
const config = (0,
|
|
5640
|
+
const config = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5565
5641
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
5566
5642
|
const repaired = withRollupSourceMaps(withDeclarationSpecifierPlugin(config));
|
|
5567
5643
|
if (repaired !== config) {
|
|
@@ -5576,12 +5652,12 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
5576
5652
|
}
|
|
5577
5653
|
function addMissingDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5578
5654
|
const changed = [];
|
|
5579
|
-
const configs = (0,
|
|
5655
|
+
const configs = (0, import_node_fs24.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5580
5656
|
cwd: workspaceRoot
|
|
5581
5657
|
});
|
|
5582
5658
|
for (const relativePath of configs) {
|
|
5583
|
-
const configPath = (0,
|
|
5584
|
-
const before = (0,
|
|
5659
|
+
const configPath = (0, import_node_path24.join)(workspaceRoot, relativePath);
|
|
5660
|
+
const before = (0, import_node_fs24.readFileSync)(configPath, "utf8");
|
|
5585
5661
|
const after = withDeclarationSpecifierPlugin(before);
|
|
5586
5662
|
if (after !== before) {
|
|
5587
5663
|
writeFileEnsured(configPath, after);
|
|
@@ -5592,10 +5668,10 @@ function addMissingDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
5592
5668
|
}
|
|
5593
5669
|
|
|
5594
5670
|
// src/rollup-library/rollup-config.repository.ts
|
|
5595
|
-
var
|
|
5596
|
-
var
|
|
5671
|
+
var import_node_fs25 = require("fs");
|
|
5672
|
+
var import_node_path25 = require("path");
|
|
5597
5673
|
function resolveRequireTarget(fromDir, specifier) {
|
|
5598
|
-
const base = (0,
|
|
5674
|
+
const base = (0, import_node_path25.join)(fromDir, specifier);
|
|
5599
5675
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
5600
5676
|
}
|
|
5601
5677
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -5605,7 +5681,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
5605
5681
|
visited.add(configPath);
|
|
5606
5682
|
let text;
|
|
5607
5683
|
try {
|
|
5608
|
-
text = (0,
|
|
5684
|
+
text = (0, import_node_fs25.readFileSync)(configPath, "utf8");
|
|
5609
5685
|
} catch {
|
|
5610
5686
|
return "";
|
|
5611
5687
|
}
|
|
@@ -5613,15 +5689,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
5613
5689
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
5614
5690
|
(match) => match[2]
|
|
5615
5691
|
);
|
|
5616
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
5692
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path25.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
5617
5693
|
return [text, ...requiredText].join("\n");
|
|
5618
5694
|
}
|
|
5619
5695
|
|
|
5620
5696
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
5621
5697
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
5622
5698
|
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,
|
|
5699
|
+
const projectRoot = (0, import_node_path26.join)(workspaceRoot, "packages", name);
|
|
5700
|
+
const manifestPath = (0, import_node_path26.join)(projectRoot, "package.json");
|
|
5625
5701
|
runGeneratorAndRepair(
|
|
5626
5702
|
workspaceRoot,
|
|
5627
5703
|
[
|
|
@@ -5654,8 +5730,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5654
5730
|
}
|
|
5655
5731
|
|
|
5656
5732
|
// src/project-scaffolding/python.use-case.ts
|
|
5657
|
-
var
|
|
5658
|
-
var
|
|
5733
|
+
var import_node_fs26 = require("fs");
|
|
5734
|
+
var import_node_path27 = require("path");
|
|
5659
5735
|
function ensurePython(workspaceRoot) {
|
|
5660
5736
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
5661
5737
|
if (!hasPython) {
|
|
@@ -5678,7 +5754,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
5678
5754
|
registerPythonGraphPlugin(workspaceRoot);
|
|
5679
5755
|
}
|
|
5680
5756
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
5681
|
-
const nxJsonPath = (0,
|
|
5757
|
+
const nxJsonPath = (0, import_node_path27.join)(workspaceRoot, "nx.json");
|
|
5682
5758
|
if (!fileExists(nxJsonPath)) {
|
|
5683
5759
|
return;
|
|
5684
5760
|
}
|
|
@@ -5701,7 +5777,7 @@ pytest
|
|
|
5701
5777
|
pip-audit
|
|
5702
5778
|
`;
|
|
5703
5779
|
function ensureRequirementsDev(workspaceRoot) {
|
|
5704
|
-
const requirementsDevPath = (0,
|
|
5780
|
+
const requirementsDevPath = (0, import_node_path27.join)(workspaceRoot, "requirements-dev.txt");
|
|
5705
5781
|
if (!fileExists(requirementsDevPath)) {
|
|
5706
5782
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
5707
5783
|
}
|
|
@@ -5761,8 +5837,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
5761
5837
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
5762
5838
|
workspaceRoot
|
|
5763
5839
|
);
|
|
5764
|
-
writeFileEnsured((0,
|
|
5765
|
-
addProjectJsonTargets((0,
|
|
5840
|
+
writeFileEnsured((0, import_node_path27.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
5841
|
+
addProjectJsonTargets((0, import_node_path27.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
5766
5842
|
package: pythonAppPackageTarget(name),
|
|
5767
5843
|
start: pythonAppStartTarget(name)
|
|
5768
5844
|
});
|
|
@@ -5784,7 +5860,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
5784
5860
|
workspaceRoot
|
|
5785
5861
|
);
|
|
5786
5862
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
5787
|
-
addProjectJsonTargets((0,
|
|
5863
|
+
addProjectJsonTargets((0, import_node_path27.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
5788
5864
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
5789
5865
|
start: pythonFunctionAppStartTarget(name)
|
|
5790
5866
|
});
|
|
@@ -5825,7 +5901,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
5825
5901
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
5826
5902
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
5827
5903
|
return PYTHON_PROJECT_DIRS.find(
|
|
5828
|
-
(directory) => fileExists((0,
|
|
5904
|
+
(directory) => fileExists((0, import_node_path27.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
5829
5905
|
);
|
|
5830
5906
|
}
|
|
5831
5907
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -5864,7 +5940,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5864
5940
|
`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
5941
|
);
|
|
5866
5942
|
}
|
|
5867
|
-
if (!fileExists((0,
|
|
5943
|
+
if (!fileExists((0, import_node_path27.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
5868
5944
|
throw new Error(
|
|
5869
5945
|
`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
5946
|
);
|
|
@@ -5872,8 +5948,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5872
5948
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
5873
5949
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5874
5950
|
}
|
|
5875
|
-
const pyprojectPath = (0,
|
|
5876
|
-
const pyprojectToml = (0,
|
|
5951
|
+
const pyprojectPath = (0, import_node_path27.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
5952
|
+
const pyprojectToml = (0, import_node_fs26.readFileSync)(pyprojectPath, "utf8");
|
|
5877
5953
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5878
5954
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5879
5955
|
return;
|
|
@@ -5885,8 +5961,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5885
5961
|
}
|
|
5886
5962
|
|
|
5887
5963
|
// src/project-scaffolding/container.use-case.ts
|
|
5888
|
-
var
|
|
5889
|
-
var
|
|
5964
|
+
var import_node_fs27 = require("fs");
|
|
5965
|
+
var import_node_path28 = require("path");
|
|
5890
5966
|
|
|
5891
5967
|
// src/project-scaffolding/container-image.algorithm.ts
|
|
5892
5968
|
var CONTAINER_TARGETS = ["node-app", "react-app", "go-app"];
|
|
@@ -6015,16 +6091,16 @@ if (command === 'build') {
|
|
|
6015
6091
|
}
|
|
6016
6092
|
`;
|
|
6017
6093
|
function detectTarget(appRoot) {
|
|
6018
|
-
if (fileExists((0,
|
|
6019
|
-
return fileExists((0,
|
|
6094
|
+
if (fileExists((0, import_node_path28.join)(appRoot, "go.mod"))) {
|
|
6095
|
+
return fileExists((0, import_node_path28.join)(appRoot, "host.json")) ? void 0 : "go-app";
|
|
6020
6096
|
}
|
|
6021
|
-
const manifestPath = (0,
|
|
6022
|
-
if (!fileExists(manifestPath) || fileExists((0,
|
|
6097
|
+
const manifestPath = (0, import_node_path28.join)(appRoot, "package.json");
|
|
6098
|
+
if (!fileExists(manifestPath) || fileExists((0, import_node_path28.join)(appRoot, "host.json"))) {
|
|
6023
6099
|
return void 0;
|
|
6024
6100
|
}
|
|
6025
6101
|
const manifest = readJson(manifestPath);
|
|
6026
6102
|
const declared = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
6027
|
-
if (declared.includes("react") && fileExists((0,
|
|
6103
|
+
if (declared.includes("react") && fileExists((0, import_node_path28.join)(appRoot, "index.html"))) {
|
|
6028
6104
|
return "react-app";
|
|
6029
6105
|
}
|
|
6030
6106
|
return manifest.nx?.targets?.build?.executor === "@nx/esbuild:esbuild" ? "node-app" : void 0;
|
|
@@ -6052,7 +6128,7 @@ function containerTargets(name, appProject, plan) {
|
|
|
6052
6128
|
};
|
|
6053
6129
|
}
|
|
6054
6130
|
function addContainer(workspaceRoot, name, options) {
|
|
6055
|
-
const appRoot = (0,
|
|
6131
|
+
const appRoot = (0, import_node_path28.join)(workspaceRoot, "apps", options.app);
|
|
6056
6132
|
if (!fileExists(appRoot)) {
|
|
6057
6133
|
throw new Error(`--app ${options.app}: there is no apps/${options.app} to put in an image. Add the app first.`);
|
|
6058
6134
|
}
|
|
@@ -6061,17 +6137,17 @@ function addContainer(workspaceRoot, name, options) {
|
|
|
6061
6137
|
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
6138
|
}
|
|
6063
6139
|
const plan = planContainer(target, options.app, options.port);
|
|
6064
|
-
const appManifestPath = (0,
|
|
6140
|
+
const appManifestPath = (0, import_node_path28.join)(appRoot, "package.json");
|
|
6065
6141
|
const appProject = fileExists(appManifestPath) ? readJson(appManifestPath).name : options.app;
|
|
6066
6142
|
const scope = appProject.startsWith("@") ? `${appProject.split("/", 1)[0]}/` : "";
|
|
6067
|
-
const projectRoot = (0,
|
|
6068
|
-
writeFileEnsured((0,
|
|
6069
|
-
writeFileEnsured((0,
|
|
6143
|
+
const projectRoot = (0, import_node_path28.join)(workspaceRoot, "apps", name);
|
|
6144
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "Dockerfile"), plan.dockerfile);
|
|
6145
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "Dockerfile.dockerignore"), plan.dockerignore);
|
|
6070
6146
|
for (const [file, text] of Object.entries(plan.files)) {
|
|
6071
|
-
writeFileEnsured((0,
|
|
6147
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "files", file), text);
|
|
6072
6148
|
}
|
|
6073
|
-
writeFileEnsured((0,
|
|
6074
|
-
writeFileEnsured((0,
|
|
6149
|
+
writeFileEnsured((0, import_node_path28.join)(workspaceRoot, CONTAINER_SCRIPT_PATH), CONTAINER_SCRIPT);
|
|
6150
|
+
writeFileEnsured((0, import_node_path28.join)(projectRoot, "package.json"), toJson({
|
|
6075
6151
|
name: `${scope}${name}`,
|
|
6076
6152
|
version: "0.0.1",
|
|
6077
6153
|
private: true,
|
|
@@ -6087,16 +6163,16 @@ function addContainer(workspaceRoot, name, options) {
|
|
|
6087
6163
|
function refreshContainerScript(workspaceRoot) {
|
|
6088
6164
|
let entries;
|
|
6089
6165
|
try {
|
|
6090
|
-
entries = (0,
|
|
6166
|
+
entries = (0, import_node_fs27.readdirSync)((0, import_node_path28.join)(workspaceRoot, "apps"));
|
|
6091
6167
|
} catch {
|
|
6092
6168
|
return false;
|
|
6093
6169
|
}
|
|
6094
6170
|
const hasContainer = entries.some((entry) => {
|
|
6095
|
-
const manifestPath = (0,
|
|
6171
|
+
const manifestPath = (0, import_node_path28.join)(workspaceRoot, "apps", entry, "package.json");
|
|
6096
6172
|
return fileExists(manifestPath) && (readJson(manifestPath).nx?.tags ?? []).includes(CONTAINER_TAG);
|
|
6097
6173
|
});
|
|
6098
|
-
const path = (0,
|
|
6099
|
-
if (!hasContainer || fileExists(path) && (0,
|
|
6174
|
+
const path = (0, import_node_path28.join)(workspaceRoot, CONTAINER_SCRIPT_PATH);
|
|
6175
|
+
if (!hasContainer || fileExists(path) && (0, import_node_fs27.readFileSync)(path, "utf8") === CONTAINER_SCRIPT) {
|
|
6100
6176
|
return false;
|
|
6101
6177
|
}
|
|
6102
6178
|
writeFileEnsured(path, CONTAINER_SCRIPT);
|
|
@@ -6104,12 +6180,12 @@ function refreshContainerScript(workspaceRoot) {
|
|
|
6104
6180
|
}
|
|
6105
6181
|
|
|
6106
6182
|
// src/project-scaffolding/react-app.use-case.ts
|
|
6107
|
-
var
|
|
6108
|
-
var
|
|
6183
|
+
var import_node_fs29 = require("fs");
|
|
6184
|
+
var import_node_path31 = require("path");
|
|
6109
6185
|
|
|
6110
6186
|
// src/react-app-output/find-react-apps-sharing-output.use-case.ts
|
|
6111
|
-
var
|
|
6112
|
-
var
|
|
6187
|
+
var import_node_fs28 = require("fs");
|
|
6188
|
+
var import_node_path29 = require("path");
|
|
6113
6189
|
|
|
6114
6190
|
// src/react-app-output/react-app-output.policy.ts
|
|
6115
6191
|
var VITE_DEFAULT_OUT_DIR = "dist";
|
|
@@ -6127,14 +6203,14 @@ function sharesOutputFolder(typescriptOutDir, viteConfig) {
|
|
|
6127
6203
|
// src/react-app-output/find-react-apps-sharing-output.use-case.ts
|
|
6128
6204
|
var VITE_CONFIGS = ["vite.config.mts", "vite.config.ts", "vite.config.mjs", "vite.config.js"];
|
|
6129
6205
|
function appSharesOutputFolder(appRoot) {
|
|
6130
|
-
const config = VITE_CONFIGS.find((name) => fileExists((0,
|
|
6131
|
-
const tsconfigPath = (0,
|
|
6206
|
+
const config = VITE_CONFIGS.find((name) => fileExists((0, import_node_path29.join)(appRoot, name)));
|
|
6207
|
+
const tsconfigPath = (0, import_node_path29.join)(appRoot, "tsconfig.app.json");
|
|
6132
6208
|
if (config === void 0 || !fileExists(tsconfigPath)) {
|
|
6133
6209
|
return false;
|
|
6134
6210
|
}
|
|
6135
6211
|
try {
|
|
6136
6212
|
const outDir = readJson(tsconfigPath).compilerOptions?.outDir;
|
|
6137
|
-
return sharesOutputFolder(outDir, (0,
|
|
6213
|
+
return sharesOutputFolder(outDir, (0, import_node_fs28.readFileSync)((0, import_node_path29.join)(appRoot, config), "utf8"));
|
|
6138
6214
|
} catch {
|
|
6139
6215
|
return false;
|
|
6140
6216
|
}
|
|
@@ -6142,20 +6218,20 @@ function appSharesOutputFolder(appRoot) {
|
|
|
6142
6218
|
function findReactAppsSharingOutput(workspaceRoot) {
|
|
6143
6219
|
let entries;
|
|
6144
6220
|
try {
|
|
6145
|
-
entries = (0,
|
|
6221
|
+
entries = (0, import_node_fs28.readdirSync)((0, import_node_path29.join)(workspaceRoot, "apps"));
|
|
6146
6222
|
} catch {
|
|
6147
6223
|
return [];
|
|
6148
6224
|
}
|
|
6149
|
-
return entries.filter((entry) => appSharesOutputFolder((0,
|
|
6225
|
+
return entries.filter((entry) => appSharesOutputFolder((0, import_node_path29.join)(workspaceRoot, "apps", entry))).map((entry) => `apps/${entry}`).toSorted((a, b) => a.localeCompare(b));
|
|
6150
6226
|
}
|
|
6151
6227
|
|
|
6152
6228
|
// src/react-app-output/separate-react-app-output.use-case.ts
|
|
6153
|
-
var
|
|
6229
|
+
var import_node_path30 = require("path");
|
|
6154
6230
|
function separateReactAppOutput(appRoot) {
|
|
6155
6231
|
if (!appSharesOutputFolder(appRoot)) {
|
|
6156
6232
|
return false;
|
|
6157
6233
|
}
|
|
6158
|
-
const tsconfigPath = (0,
|
|
6234
|
+
const tsconfigPath = (0, import_node_path30.join)(appRoot, "tsconfig.app.json");
|
|
6159
6235
|
const tsconfig = readJson(tsconfigPath);
|
|
6160
6236
|
writeFileEnsured(tsconfigPath, toJson({
|
|
6161
6237
|
...tsconfig,
|
|
@@ -6166,7 +6242,7 @@ function separateReactAppOutput(appRoot) {
|
|
|
6166
6242
|
function separateReactAppsOutput(workspaceRoot) {
|
|
6167
6243
|
const repaired = [];
|
|
6168
6244
|
for (const dir of findReactAppsSharingOutput(workspaceRoot)) {
|
|
6169
|
-
if (separateReactAppOutput((0,
|
|
6245
|
+
if (separateReactAppOutput((0, import_node_path30.join)(workspaceRoot, dir))) {
|
|
6170
6246
|
repaired.push(dir);
|
|
6171
6247
|
}
|
|
6172
6248
|
}
|
|
@@ -6297,12 +6373,12 @@ function reactAppTargets(name) {
|
|
|
6297
6373
|
return targets;
|
|
6298
6374
|
}
|
|
6299
6375
|
function allowEnvFiles(workspaceRoot) {
|
|
6300
|
-
const gitignorePath = (0,
|
|
6376
|
+
const gitignorePath = (0, import_node_path31.join)(workspaceRoot, ".gitignore");
|
|
6301
6377
|
if (!fileExists(gitignorePath)) {
|
|
6302
6378
|
return;
|
|
6303
6379
|
}
|
|
6304
6380
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
6305
|
-
const current = (0,
|
|
6381
|
+
const current = (0, import_node_fs29.readFileSync)(gitignorePath, "utf8");
|
|
6306
6382
|
if (current.includes(marker)) {
|
|
6307
6383
|
return;
|
|
6308
6384
|
}
|
|
@@ -6329,18 +6405,18 @@ function addReactApp(workspaceRoot, name, stack, e2e = false) {
|
|
|
6329
6405
|
workspaceRoot
|
|
6330
6406
|
);
|
|
6331
6407
|
ensureAdmZip(workspaceRoot);
|
|
6332
|
-
const reactAppRoot = (0,
|
|
6408
|
+
const reactAppRoot = (0, import_node_path31.join)(workspaceRoot, "apps", name);
|
|
6333
6409
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
6334
|
-
writeFileEnsured((0,
|
|
6410
|
+
writeFileEnsured((0, import_node_path31.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
6335
6411
|
}
|
|
6336
6412
|
allowEnvFiles(workspaceRoot);
|
|
6337
|
-
addNxTargets((0,
|
|
6413
|
+
addNxTargets((0, import_node_path31.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
6338
6414
|
reshapeReactAppScaffold(reactAppRoot);
|
|
6339
6415
|
separateReactAppOutput(reactAppRoot);
|
|
6340
|
-
(0,
|
|
6416
|
+
(0, import_node_fs29.rmSync)((0, import_node_path31.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
6341
6417
|
const example = reactAppExampleFiles(name);
|
|
6342
6418
|
for (const [relative, contents] of Object.entries(example)) {
|
|
6343
|
-
writeFileEnsured((0,
|
|
6419
|
+
writeFileEnsured((0, import_node_path31.join)(reactAppRoot, "src", relative), contents);
|
|
6344
6420
|
}
|
|
6345
6421
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
6346
6422
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
@@ -6350,9 +6426,9 @@ function addReactApp(workspaceRoot, name, stack, e2e = false) {
|
|
|
6350
6426
|
}
|
|
6351
6427
|
function pairE2eProject(workspaceRoot, name) {
|
|
6352
6428
|
const e2eName = `${name}-e2e`;
|
|
6353
|
-
const e2eRoot = (0,
|
|
6354
|
-
(0,
|
|
6355
|
-
writeFileEnsured((0,
|
|
6429
|
+
const e2eRoot = (0, import_node_path31.join)(workspaceRoot, "apps", e2eName);
|
|
6430
|
+
(0, import_node_fs29.rmSync)((0, import_node_path31.join)(e2eRoot, "src/example.spec.ts"), { force: true });
|
|
6431
|
+
writeFileEnsured((0, import_node_path31.join)(e2eRoot, "src/greeting.e2e.spec.ts"), reactAppE2eSpec(name));
|
|
6356
6432
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${e2eName}`);
|
|
6357
6433
|
registerProjectCommands(workspaceRoot, e2eName, {
|
|
6358
6434
|
build: false,
|
|
@@ -6361,13 +6437,13 @@ function pairE2eProject(workspaceRoot, name) {
|
|
|
6361
6437
|
}
|
|
6362
6438
|
|
|
6363
6439
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
6364
|
-
var
|
|
6440
|
+
var import_node_path32 = require("path");
|
|
6365
6441
|
var REACT_LIB_BUNDLER = "rollup";
|
|
6366
6442
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
6367
6443
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
6368
6444
|
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,
|
|
6445
|
+
const projectRoot = (0, import_node_path32.join)(workspaceRoot, "packages", name);
|
|
6446
|
+
const publishableManifest = (0, import_node_path32.join)(projectRoot, "package.json");
|
|
6371
6447
|
runGeneratorAndRepair(
|
|
6372
6448
|
workspaceRoot,
|
|
6373
6449
|
[
|
|
@@ -6411,8 +6487,8 @@ function dropNxProjectName(manifestPath) {
|
|
|
6411
6487
|
}
|
|
6412
6488
|
function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
6413
6489
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
6414
|
-
const projectRoot = (0,
|
|
6415
|
-
const privateManifest = (0,
|
|
6490
|
+
const projectRoot = (0, import_node_path32.join)(workspaceRoot, "libs", name);
|
|
6491
|
+
const privateManifest = (0, import_node_path32.join)(projectRoot, "package.json");
|
|
6416
6492
|
runGeneratorAndRepair(
|
|
6417
6493
|
workspaceRoot,
|
|
6418
6494
|
[
|
|
@@ -6439,8 +6515,8 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
6439
6515
|
}
|
|
6440
6516
|
|
|
6441
6517
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
6442
|
-
var
|
|
6443
|
-
var
|
|
6518
|
+
var import_node_fs30 = require("fs");
|
|
6519
|
+
var import_node_path33 = require("path");
|
|
6444
6520
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
6445
6521
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
6446
6522
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -6625,8 +6701,8 @@ export const window = {
|
|
|
6625
6701
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
6626
6702
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
6627
6703
|
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,
|
|
6704
|
+
const path = (0, import_node_path33.join)(projectRoot, file);
|
|
6705
|
+
const content = fileExists(path) ? (0, import_node_fs30.readFileSync)(path, "utf8") : "";
|
|
6630
6706
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
6631
6707
|
if (line === void 0) {
|
|
6632
6708
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -6646,11 +6722,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
6646
6722
|
}
|
|
6647
6723
|
}
|
|
6648
6724
|
function defaultPublisher(workspaceRoot) {
|
|
6649
|
-
const { name } = readJson((0,
|
|
6725
|
+
const { name } = readJson((0, import_node_path33.join)(workspaceRoot, "package.json"));
|
|
6650
6726
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
6651
6727
|
}
|
|
6652
6728
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
6653
|
-
const manifestPath = (0,
|
|
6729
|
+
const manifestPath = (0, import_node_path33.join)(projectRoot, "package.json");
|
|
6654
6730
|
const manifest = readJson(manifestPath);
|
|
6655
6731
|
const { nx = {}, ...rest } = manifest;
|
|
6656
6732
|
const targets = { ...nx.targets };
|
|
@@ -6714,11 +6790,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
6714
6790
|
};
|
|
6715
6791
|
}
|
|
6716
6792
|
function addDebugLaunch(workspaceRoot, name) {
|
|
6717
|
-
const file = (0,
|
|
6793
|
+
const file = (0, import_node_fs30.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
6718
6794
|
if (file === void 0) {
|
|
6719
6795
|
return;
|
|
6720
6796
|
}
|
|
6721
|
-
const path = (0,
|
|
6797
|
+
const path = (0, import_node_path33.join)(workspaceRoot, file);
|
|
6722
6798
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
6723
6799
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
6724
6800
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -6751,39 +6827,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
6751
6827
|
);
|
|
6752
6828
|
}
|
|
6753
6829
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
6754
|
-
const apps = (0,
|
|
6830
|
+
const apps = (0, import_node_path33.join)(workspaceRoot, "apps");
|
|
6755
6831
|
let entries;
|
|
6756
6832
|
try {
|
|
6757
|
-
entries = (0,
|
|
6833
|
+
entries = (0, import_node_fs30.readdirSync)(apps);
|
|
6758
6834
|
} catch {
|
|
6759
6835
|
return false;
|
|
6760
6836
|
}
|
|
6761
6837
|
const hasExtension = entries.some((entry) => {
|
|
6762
|
-
const manifestPath = (0,
|
|
6838
|
+
const manifestPath = (0, import_node_path33.join)(apps, entry, "package.json");
|
|
6763
6839
|
if (!fileExists(manifestPath)) {
|
|
6764
6840
|
return false;
|
|
6765
6841
|
}
|
|
6766
6842
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
6767
6843
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
6768
6844
|
});
|
|
6769
|
-
const path = (0,
|
|
6770
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
6845
|
+
const path = (0, import_node_path33.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
6846
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs30.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
6771
6847
|
return false;
|
|
6772
6848
|
}
|
|
6773
6849
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
6774
6850
|
return true;
|
|
6775
6851
|
}
|
|
6776
6852
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
6777
|
-
const apps = (0,
|
|
6853
|
+
const apps = (0, import_node_path33.join)(workspaceRoot, "apps");
|
|
6778
6854
|
let entries;
|
|
6779
6855
|
try {
|
|
6780
|
-
entries = (0,
|
|
6856
|
+
entries = (0, import_node_fs30.readdirSync)(apps);
|
|
6781
6857
|
} catch {
|
|
6782
6858
|
return [];
|
|
6783
6859
|
}
|
|
6784
6860
|
const updated = [];
|
|
6785
6861
|
for (const entry of entries) {
|
|
6786
|
-
const manifestPath = (0,
|
|
6862
|
+
const manifestPath = (0, import_node_path33.join)(apps, entry, "package.json");
|
|
6787
6863
|
if (!fileExists(manifestPath)) {
|
|
6788
6864
|
continue;
|
|
6789
6865
|
}
|
|
@@ -6803,22 +6879,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
6803
6879
|
}
|
|
6804
6880
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
6805
6881
|
const { sidecar } = options;
|
|
6806
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
6882
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path33.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
6807
6883
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
6808
6884
|
}
|
|
6809
6885
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
6810
6886
|
ensureVscodeToolchain(workspaceRoot);
|
|
6811
|
-
const projectRoot = (0,
|
|
6887
|
+
const projectRoot = (0, import_node_path33.join)(workspaceRoot, "apps", name);
|
|
6812
6888
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
6813
|
-
addVscodeTypes((0,
|
|
6814
|
-
addVscodeTypes((0,
|
|
6815
|
-
writeFileEnsured((0,
|
|
6816
|
-
writeFileEnsured((0,
|
|
6817
|
-
writeFileEnsured((0,
|
|
6889
|
+
addVscodeTypes((0, import_node_path33.join)(projectRoot, "tsconfig.app.json"));
|
|
6890
|
+
addVscodeTypes((0, import_node_path33.join)(projectRoot, "tsconfig.spec.json"));
|
|
6891
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
6892
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
6893
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
6818
6894
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
6819
|
-
writeFileEnsured((0,
|
|
6820
|
-
writeFileEnsured((0,
|
|
6821
|
-
addNxTargets((0,
|
|
6895
|
+
writeFileEnsured((0, import_node_path33.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
6896
|
+
writeFileEnsured((0, import_node_path33.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
6897
|
+
addNxTargets((0, import_node_path33.join)(projectRoot, "package.json"), {
|
|
6822
6898
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
6823
6899
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
6824
6900
|
});
|
|
@@ -6829,12 +6905,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
6829
6905
|
}
|
|
6830
6906
|
|
|
6831
6907
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
6832
|
-
var
|
|
6833
|
-
var
|
|
6908
|
+
var import_node_fs32 = require("fs");
|
|
6909
|
+
var import_node_path35 = require("path");
|
|
6834
6910
|
|
|
6835
6911
|
// src/dependency-management/manifest.repository.ts
|
|
6836
|
-
var
|
|
6837
|
-
var
|
|
6912
|
+
var import_node_fs31 = require("fs");
|
|
6913
|
+
var import_node_path34 = require("path");
|
|
6838
6914
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
6839
6915
|
var ROOT_LABEL = "(root)";
|
|
6840
6916
|
var MANIFEST_GLOBS = {
|
|
@@ -6867,23 +6943,23 @@ function projectOf(manifestRelativePath) {
|
|
|
6867
6943
|
}
|
|
6868
6944
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
6869
6945
|
if (ecosystem === "go") {
|
|
6870
|
-
return fileExists((0,
|
|
6946
|
+
return fileExists((0, import_node_path34.join)(workspaceRoot, "go.mod"));
|
|
6871
6947
|
}
|
|
6872
6948
|
if (ecosystem === "nuget") {
|
|
6873
|
-
return (0,
|
|
6949
|
+
return (0, import_node_fs31.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
6874
6950
|
}
|
|
6875
6951
|
const rootMarker = {
|
|
6876
6952
|
npm: "package.json",
|
|
6877
6953
|
pip: "requirements-dev.txt",
|
|
6878
6954
|
pub: "pubspec.yaml"
|
|
6879
6955
|
};
|
|
6880
|
-
return fileExists((0,
|
|
6956
|
+
return fileExists((0, import_node_path34.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs31.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
6881
6957
|
}
|
|
6882
6958
|
function collectNpm(workspaceRoot) {
|
|
6883
6959
|
const sites = [];
|
|
6884
|
-
const relativePaths = ["package.json", ...(0,
|
|
6960
|
+
const relativePaths = ["package.json", ...(0, import_node_fs31.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
6885
6961
|
for (const relativePath of relativePaths) {
|
|
6886
|
-
const manifestPath = (0,
|
|
6962
|
+
const manifestPath = (0, import_node_path34.join)(workspaceRoot, relativePath);
|
|
6887
6963
|
try {
|
|
6888
6964
|
const manifest = readJson(manifestPath);
|
|
6889
6965
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -6944,17 +7020,17 @@ function collectPip(workspaceRoot) {
|
|
|
6944
7020
|
name: parsed.name,
|
|
6945
7021
|
ecosystem: "pip",
|
|
6946
7022
|
project: projectOf(relativePath),
|
|
6947
|
-
manifestPath: (0,
|
|
7023
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
6948
7024
|
section,
|
|
6949
7025
|
spec: parsed.spec,
|
|
6950
7026
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
6951
7027
|
});
|
|
6952
7028
|
};
|
|
6953
|
-
const pyprojectPaths = (0,
|
|
7029
|
+
const pyprojectPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
6954
7030
|
for (const relativePath of pyprojectPaths) {
|
|
6955
7031
|
let content;
|
|
6956
7032
|
try {
|
|
6957
|
-
content = (0,
|
|
7033
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
6958
7034
|
} catch {
|
|
6959
7035
|
continue;
|
|
6960
7036
|
}
|
|
@@ -6965,14 +7041,14 @@ function collectPip(workspaceRoot) {
|
|
|
6965
7041
|
}
|
|
6966
7042
|
const requirementsPaths = [
|
|
6967
7043
|
"requirements-dev.txt",
|
|
6968
|
-
...(0,
|
|
7044
|
+
...(0, import_node_fs31.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
6969
7045
|
];
|
|
6970
7046
|
for (const relativePath of requirementsPaths) {
|
|
6971
|
-
if (!fileExists((0,
|
|
7047
|
+
if (!fileExists((0, import_node_path34.join)(workspaceRoot, relativePath))) {
|
|
6972
7048
|
continue;
|
|
6973
7049
|
}
|
|
6974
7050
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
6975
|
-
const lines = (0,
|
|
7051
|
+
const lines = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
6976
7052
|
for (const line of lines) {
|
|
6977
7053
|
push(relativePath, section, line);
|
|
6978
7054
|
}
|
|
@@ -7010,11 +7086,11 @@ function pyprojectDependencies(content) {
|
|
|
7010
7086
|
}
|
|
7011
7087
|
function collectPub(workspaceRoot) {
|
|
7012
7088
|
const sites = [];
|
|
7013
|
-
const pubspecPaths = (0,
|
|
7089
|
+
const pubspecPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
7014
7090
|
for (const relativePath of pubspecPaths) {
|
|
7015
7091
|
let content;
|
|
7016
7092
|
try {
|
|
7017
|
-
content = (0,
|
|
7093
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
7018
7094
|
} catch {
|
|
7019
7095
|
continue;
|
|
7020
7096
|
}
|
|
@@ -7024,7 +7100,7 @@ function collectPub(workspaceRoot) {
|
|
|
7024
7100
|
name: entry.name,
|
|
7025
7101
|
ecosystem: "pub",
|
|
7026
7102
|
project: projectOf(relativePath),
|
|
7027
|
-
manifestPath: (0,
|
|
7103
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
7028
7104
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
7029
7105
|
spec: entry.spec,
|
|
7030
7106
|
rewritable: entry.spec !== ""
|
|
@@ -7074,11 +7150,11 @@ function stripQuotes(value) {
|
|
|
7074
7150
|
}
|
|
7075
7151
|
function collectNuget(workspaceRoot) {
|
|
7076
7152
|
const sites = [];
|
|
7077
|
-
const csprojPaths = (0,
|
|
7153
|
+
const csprojPaths = (0, import_node_fs31.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
7078
7154
|
for (const relativePath of csprojPaths) {
|
|
7079
7155
|
let content;
|
|
7080
7156
|
try {
|
|
7081
|
-
content = (0,
|
|
7157
|
+
content = (0, import_node_fs31.readFileSync)((0, import_node_path34.join)(workspaceRoot, relativePath), "utf8");
|
|
7082
7158
|
} catch {
|
|
7083
7159
|
continue;
|
|
7084
7160
|
}
|
|
@@ -7087,7 +7163,7 @@ function collectNuget(workspaceRoot) {
|
|
|
7087
7163
|
name: entry.name,
|
|
7088
7164
|
ecosystem: "nuget",
|
|
7089
7165
|
project: projectOf(relativePath),
|
|
7090
|
-
manifestPath: (0,
|
|
7166
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath),
|
|
7091
7167
|
section: "dep",
|
|
7092
7168
|
spec: entry.spec,
|
|
7093
7169
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -7112,13 +7188,13 @@ function csprojPackageReferences(content) {
|
|
|
7112
7188
|
return entries;
|
|
7113
7189
|
}
|
|
7114
7190
|
function collectGo(workspaceRoot) {
|
|
7115
|
-
const manifestPath = (0,
|
|
7191
|
+
const manifestPath = (0, import_node_path34.join)(workspaceRoot, "go.mod");
|
|
7116
7192
|
if (!fileExists(manifestPath)) {
|
|
7117
7193
|
return [];
|
|
7118
7194
|
}
|
|
7119
7195
|
let content;
|
|
7120
7196
|
try {
|
|
7121
|
-
content = (0,
|
|
7197
|
+
content = (0, import_node_fs31.readFileSync)(manifestPath, "utf8");
|
|
7122
7198
|
} catch {
|
|
7123
7199
|
return [];
|
|
7124
7200
|
}
|
|
@@ -7167,7 +7243,7 @@ var PROJECT_GLOBS = {
|
|
|
7167
7243
|
function locateProjects(workspaceRoot) {
|
|
7168
7244
|
const locations = [];
|
|
7169
7245
|
for (const ecosystem of ECOSYSTEMS) {
|
|
7170
|
-
const relativePaths = (0,
|
|
7246
|
+
const relativePaths = (0, import_node_fs31.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
7171
7247
|
for (const relativePath of relativePaths) {
|
|
7172
7248
|
const posix = toPosix(relativePath);
|
|
7173
7249
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -7175,7 +7251,7 @@ function locateProjects(workspaceRoot) {
|
|
|
7175
7251
|
ecosystem,
|
|
7176
7252
|
dir,
|
|
7177
7253
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
7178
|
-
manifestPath: (0,
|
|
7254
|
+
manifestPath: (0, import_node_path34.join)(workspaceRoot, relativePath)
|
|
7179
7255
|
});
|
|
7180
7256
|
}
|
|
7181
7257
|
}
|
|
@@ -7196,7 +7272,7 @@ function rewriteSpec(site, spec) {
|
|
|
7196
7272
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
7197
7273
|
return true;
|
|
7198
7274
|
}
|
|
7199
|
-
const before = (0,
|
|
7275
|
+
const before = (0, import_node_fs31.readFileSync)(site.manifestPath, "utf8");
|
|
7200
7276
|
const after = (() => {
|
|
7201
7277
|
switch (site.ecosystem) {
|
|
7202
7278
|
case "pip": {
|
|
@@ -7287,13 +7363,13 @@ function escapeForRegex(value) {
|
|
|
7287
7363
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
7288
7364
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
7289
7365
|
return ["apps", "libs", "packages"].some(
|
|
7290
|
-
(directory) => fileExists((0,
|
|
7366
|
+
(directory) => fileExists((0, import_node_path34.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
7291
7367
|
);
|
|
7292
7368
|
}
|
|
7293
7369
|
function isAliasedInstall(workspaceRoot, name) {
|
|
7294
7370
|
try {
|
|
7295
7371
|
const installed = readJson(
|
|
7296
|
-
(0,
|
|
7372
|
+
(0, import_node_path34.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
7297
7373
|
);
|
|
7298
7374
|
return installed.name !== void 0 && installed.name !== name;
|
|
7299
7375
|
} catch {
|
|
@@ -7304,14 +7380,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
7304
7380
|
if (ecosystem === "npm") {
|
|
7305
7381
|
try {
|
|
7306
7382
|
return readJson(
|
|
7307
|
-
(0,
|
|
7383
|
+
(0, import_node_path34.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
7308
7384
|
).version;
|
|
7309
7385
|
} catch {
|
|
7310
7386
|
return void 0;
|
|
7311
7387
|
}
|
|
7312
7388
|
}
|
|
7313
7389
|
if (ecosystem === "pub") {
|
|
7314
|
-
const lockPath = (0,
|
|
7390
|
+
const lockPath = (0, import_node_path34.join)(workspaceRoot, "pubspec.lock");
|
|
7315
7391
|
if (!fileExists(lockPath)) {
|
|
7316
7392
|
return void 0;
|
|
7317
7393
|
}
|
|
@@ -7319,7 +7395,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
7319
7395
|
const match = new RegExp(
|
|
7320
7396
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
7321
7397
|
"m"
|
|
7322
|
-
).exec((0,
|
|
7398
|
+
).exec((0, import_node_fs31.readFileSync)(lockPath, "utf8"));
|
|
7323
7399
|
return match?.[1];
|
|
7324
7400
|
} catch {
|
|
7325
7401
|
return void 0;
|
|
@@ -7385,7 +7461,7 @@ function resolveTarget(locations, target) {
|
|
|
7385
7461
|
return byName[0];
|
|
7386
7462
|
}
|
|
7387
7463
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
7388
|
-
const projectDir = (0,
|
|
7464
|
+
const projectDir = (0, import_node_path35.join)(workspaceRoot, location.dir);
|
|
7389
7465
|
switch (location.ecosystem) {
|
|
7390
7466
|
case "npm": {
|
|
7391
7467
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -7438,7 +7514,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
7438
7514
|
function addPythonDependency(manifestPath, specifier) {
|
|
7439
7515
|
let content;
|
|
7440
7516
|
try {
|
|
7441
|
-
content = (0,
|
|
7517
|
+
content = (0, import_node_fs32.readFileSync)(manifestPath, "utf8");
|
|
7442
7518
|
} catch {
|
|
7443
7519
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
7444
7520
|
return;
|
|
@@ -7467,7 +7543,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
7467
7543
|
}
|
|
7468
7544
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
7469
7545
|
if (ecosystem === "go") {
|
|
7470
|
-
return fileExists((0,
|
|
7546
|
+
return fileExists((0, import_node_path35.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path35.join)(workspaceRoot, "go.mod"));
|
|
7471
7547
|
}
|
|
7472
7548
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
7473
7549
|
}
|
|
@@ -7486,7 +7562,7 @@ function splitAtLast(value, separator) {
|
|
|
7486
7562
|
}
|
|
7487
7563
|
|
|
7488
7564
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
7489
|
-
var
|
|
7565
|
+
var import_node_path36 = require("path");
|
|
7490
7566
|
|
|
7491
7567
|
// src/dependency-management/semver.algorithm.ts
|
|
7492
7568
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -7663,7 +7739,7 @@ function describe(finding) {
|
|
|
7663
7739
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
7664
7740
|
}
|
|
7665
7741
|
function runSync(workspaceRoot, options) {
|
|
7666
|
-
if (!fileExists((0,
|
|
7742
|
+
if (!fileExists((0, import_node_path36.join)(workspaceRoot, "nx.json"))) {
|
|
7667
7743
|
throw new Error(
|
|
7668
7744
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
7669
7745
|
);
|
|
@@ -7713,7 +7789,7 @@ function runSync(workspaceRoot, options) {
|
|
|
7713
7789
|
}
|
|
7714
7790
|
|
|
7715
7791
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
7716
|
-
var
|
|
7792
|
+
var import_node_path37 = require("path");
|
|
7717
7793
|
var import_prompts2 = require("@inquirer/prompts");
|
|
7718
7794
|
|
|
7719
7795
|
// src/dependency-management/registry.client.ts
|
|
@@ -7996,7 +8072,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
7996
8072
|
function hasPythonInstallScript(workspaceRoot) {
|
|
7997
8073
|
try {
|
|
7998
8074
|
const manifest = readJson(
|
|
7999
|
-
(0,
|
|
8075
|
+
(0, import_node_path37.join)(workspaceRoot, "package.json")
|
|
8000
8076
|
);
|
|
8001
8077
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
8002
8078
|
} catch {
|
|
@@ -8012,7 +8088,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
8012
8088
|
}
|
|
8013
8089
|
}
|
|
8014
8090
|
async function runUp(workspaceRoot, options) {
|
|
8015
|
-
if (!fileExists((0,
|
|
8091
|
+
if (!fileExists((0, import_node_path37.join)(workspaceRoot, "nx.json"))) {
|
|
8016
8092
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
8017
8093
|
}
|
|
8018
8094
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -8090,7 +8166,7 @@ var PROJECT_KINDS = [
|
|
|
8090
8166
|
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
8091
8167
|
async function runAdd(kind, name, options) {
|
|
8092
8168
|
const workspaceRoot = process.cwd();
|
|
8093
|
-
if (!fileExists((0,
|
|
8169
|
+
if (!fileExists((0, import_node_path38.join)(workspaceRoot, "nx.json"))) {
|
|
8094
8170
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
8095
8171
|
}
|
|
8096
8172
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -8175,8 +8251,8 @@ async function runAdd(kind, name, options) {
|
|
|
8175
8251
|
],
|
|
8176
8252
|
workspaceRoot
|
|
8177
8253
|
);
|
|
8178
|
-
markPrivate((0,
|
|
8179
|
-
renameScaffoldPlaceholder((0,
|
|
8254
|
+
markPrivate((0, import_node_path38.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
8255
|
+
renameScaffoldPlaceholder((0, import_node_path38.join)(workspaceRoot, "libs", resolvedName), resolvedName, options.empty === true);
|
|
8180
8256
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
8181
8257
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
8182
8258
|
break;
|
|
@@ -8272,7 +8348,7 @@ async function runAdd(kind, name, options) {
|
|
|
8272
8348
|
}
|
|
8273
8349
|
function readWorkspaceStack(workspaceRoot) {
|
|
8274
8350
|
const nxJson = readJson(
|
|
8275
|
-
(0,
|
|
8351
|
+
(0, import_node_path38.join)(workspaceRoot, "nx.json")
|
|
8276
8352
|
);
|
|
8277
8353
|
const stack = nxJson.mnci?.stack;
|
|
8278
8354
|
return {
|
|
@@ -8361,11 +8437,11 @@ function spawnProject(workspaceRoot, project, target, onLine) {
|
|
|
8361
8437
|
}
|
|
8362
8438
|
|
|
8363
8439
|
// src/dev-servers/startable-projects.use-case.ts
|
|
8364
|
-
var
|
|
8440
|
+
var import_node_path39 = require("path");
|
|
8365
8441
|
var START_SUFFIX = ":start";
|
|
8366
8442
|
var NX_RUN = /\bnx run [^\s:]+:(\S+)/;
|
|
8367
8443
|
function listStartableProjects(workspaceRoot) {
|
|
8368
|
-
const manifestPath = (0,
|
|
8444
|
+
const manifestPath = (0, import_node_path39.join)(workspaceRoot, "package.json");
|
|
8369
8445
|
if (!fileExists(manifestPath)) {
|
|
8370
8446
|
return [];
|
|
8371
8447
|
}
|
|
@@ -8438,8 +8514,8 @@ async function runDev(workspaceRoot, named, options = {}, dependencies = {}) {
|
|
|
8438
8514
|
|
|
8439
8515
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
8440
8516
|
var import_node_child_process2 = require("child_process");
|
|
8441
|
-
var
|
|
8442
|
-
var
|
|
8517
|
+
var import_node_fs34 = require("fs");
|
|
8518
|
+
var import_node_path41 = require("path");
|
|
8443
8519
|
|
|
8444
8520
|
// src/workspace-diagnostics/check-react-app-output.use-case.ts
|
|
8445
8521
|
function checkReactAppOutput(workspaceRoot) {
|
|
@@ -8471,8 +8547,8 @@ function createBaselineTags(repositoryRoot, stranded) {
|
|
|
8471
8547
|
}
|
|
8472
8548
|
|
|
8473
8549
|
// src/release-tag-lineage/locate-stranded-release-tags.use-case.ts
|
|
8474
|
-
var
|
|
8475
|
-
var
|
|
8550
|
+
var import_node_fs33 = require("fs");
|
|
8551
|
+
var import_node_path40 = require("path");
|
|
8476
8552
|
|
|
8477
8553
|
// src/release-tag-lineage/stranded-release-tags.algorithm.ts
|
|
8478
8554
|
function compareVersions2(left, right) {
|
|
@@ -8509,7 +8585,7 @@ function locateStrandedReleaseTags(workspaceRoot, tagPattern) {
|
|
|
8509
8585
|
if (listed.status !== 0) {
|
|
8510
8586
|
return [];
|
|
8511
8587
|
}
|
|
8512
|
-
const projects = (0,
|
|
8588
|
+
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
8589
|
return findStrandedReleaseTags(projects, listed.stdout.split(/\r?\n/).filter(Boolean));
|
|
8514
8590
|
}
|
|
8515
8591
|
|
|
@@ -8530,8 +8606,8 @@ function toPosix2(path) {
|
|
|
8530
8606
|
return path.replaceAll("\\", "/");
|
|
8531
8607
|
}
|
|
8532
8608
|
function checkEslintConfigs(workspaceRoot) {
|
|
8533
|
-
const rootConfigs = (0,
|
|
8534
|
-
const projectConfigs = (0,
|
|
8609
|
+
const rootConfigs = (0, import_node_fs34.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
8610
|
+
const projectConfigs = (0, import_node_fs34.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
8535
8611
|
cwd: workspaceRoot
|
|
8536
8612
|
}).map((config) => toPosix2(config));
|
|
8537
8613
|
return [
|
|
@@ -8551,10 +8627,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
8551
8627
|
];
|
|
8552
8628
|
}
|
|
8553
8629
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
8554
|
-
const rules = (0,
|
|
8555
|
-
if (!(0,
|
|
8556
|
-
const entryPoint = (0,
|
|
8557
|
-
const source = (0,
|
|
8630
|
+
const rules = (0, import_node_path41.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
8631
|
+
if (!(0, import_node_fs34.existsSync)(rules)) return [];
|
|
8632
|
+
const entryPoint = (0, import_node_path41.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
8633
|
+
const source = (0, import_node_fs34.existsSync)(entryPoint) ? (0, import_node_fs34.readFileSync)(entryPoint, "utf8") : "";
|
|
8558
8634
|
return [
|
|
8559
8635
|
{
|
|
8560
8636
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -8567,7 +8643,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
8567
8643
|
function declaredDevDependencies(workspaceRoot) {
|
|
8568
8644
|
try {
|
|
8569
8645
|
const manifest = readJson(
|
|
8570
|
-
(0,
|
|
8646
|
+
(0, import_node_path41.join)(workspaceRoot, "package.json")
|
|
8571
8647
|
);
|
|
8572
8648
|
return manifest.devDependencies ?? {};
|
|
8573
8649
|
} catch {
|
|
@@ -8575,7 +8651,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
8575
8651
|
}
|
|
8576
8652
|
}
|
|
8577
8653
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
8578
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
8654
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path41.join)(workspaceRoot, file)));
|
|
8579
8655
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
8580
8656
|
const stale = [...files, ...declared];
|
|
8581
8657
|
if (stale.length === 0) {
|
|
@@ -8601,7 +8677,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
8601
8677
|
};
|
|
8602
8678
|
}
|
|
8603
8679
|
function checkResolvedEslint(workspaceRoot) {
|
|
8604
|
-
const manifestPath = (0,
|
|
8680
|
+
const manifestPath = (0, import_node_path41.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
8605
8681
|
if (!fileExists(manifestPath)) {
|
|
8606
8682
|
return void 0;
|
|
8607
8683
|
}
|
|
@@ -8619,11 +8695,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
8619
8695
|
}
|
|
8620
8696
|
}
|
|
8621
8697
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
8622
|
-
const npmrcPath = (0,
|
|
8698
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8623
8699
|
if (!registry || !fileExists(npmrcPath)) {
|
|
8624
8700
|
return void 0;
|
|
8625
8701
|
}
|
|
8626
|
-
const npmrc = (0,
|
|
8702
|
+
const npmrc = (0, import_node_fs34.readFileSync)(npmrcPath, "utf8");
|
|
8627
8703
|
if (registry.kind === "npm") {
|
|
8628
8704
|
return {
|
|
8629
8705
|
check: ".npmrc authenticates the public registry",
|
|
@@ -8640,11 +8716,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
8640
8716
|
};
|
|
8641
8717
|
}
|
|
8642
8718
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
8643
|
-
const npmrcPath = (0,
|
|
8719
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8644
8720
|
if (!fileExists(npmrcPath)) {
|
|
8645
8721
|
return void 0;
|
|
8646
8722
|
}
|
|
8647
|
-
const npmrc = (0,
|
|
8723
|
+
const npmrc = (0, import_node_fs34.readFileSync)(npmrcPath, "utf8");
|
|
8648
8724
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
8649
8725
|
const referenced = [
|
|
8650
8726
|
...new Set(
|
|
@@ -8668,13 +8744,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
8668
8744
|
};
|
|
8669
8745
|
}
|
|
8670
8746
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
8671
|
-
const npmrcPath = (0,
|
|
8672
|
-
const pipelinePath = (0,
|
|
8747
|
+
const npmrcPath = (0, import_node_path41.join)(workspaceRoot, ".npmrc");
|
|
8748
|
+
const pipelinePath = (0, import_node_path41.join)(workspaceRoot, "azure-pipelines.yml");
|
|
8673
8749
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
8674
8750
|
return void 0;
|
|
8675
8751
|
}
|
|
8676
|
-
const holdsCredentials = (0,
|
|
8677
|
-
const runsTask = (0,
|
|
8752
|
+
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));
|
|
8753
|
+
const runsTask = (0, import_node_fs34.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
8678
8754
|
if (!holdsCredentials && !runsTask) {
|
|
8679
8755
|
return {
|
|
8680
8756
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -8719,13 +8795,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
8719
8795
|
}
|
|
8720
8796
|
function checkVersionActions(workspaceRoot) {
|
|
8721
8797
|
const candidates = [
|
|
8722
|
-
...(0,
|
|
8723
|
-
...(0,
|
|
8724
|
-
...(0,
|
|
8798
|
+
...(0, import_node_fs34.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
8799
|
+
...(0, import_node_fs34.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
8800
|
+
...(0, import_node_fs34.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
8725
8801
|
].map((manifest) => toPosix2(manifest));
|
|
8726
8802
|
return candidates.flatMap((manifest) => {
|
|
8727
8803
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
8728
|
-
const projectJsonPath = (0,
|
|
8804
|
+
const projectJsonPath = (0, import_node_path41.join)(workspaceRoot, projectRoot, "project.json");
|
|
8729
8805
|
let hasOverride = false;
|
|
8730
8806
|
try {
|
|
8731
8807
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -8754,7 +8830,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
8754
8830
|
]) {
|
|
8755
8831
|
try {
|
|
8756
8832
|
const targets = extract(
|
|
8757
|
-
readJson((0,
|
|
8833
|
+
readJson((0, import_node_path41.join)(workspaceRoot, projectRoot, file))
|
|
8758
8834
|
);
|
|
8759
8835
|
if (targets && typeof targets === "object") {
|
|
8760
8836
|
sources.push({
|
|
@@ -8770,8 +8846,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
8770
8846
|
function checkTargetFilesExist(workspaceRoot) {
|
|
8771
8847
|
const projectRoots = new Set(
|
|
8772
8848
|
[
|
|
8773
|
-
...(0,
|
|
8774
|
-
...(0,
|
|
8849
|
+
...(0, import_node_fs34.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
8850
|
+
...(0, import_node_fs34.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
8775
8851
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
8776
8852
|
);
|
|
8777
8853
|
return [...projectRoots].flatMap(
|
|
@@ -8786,7 +8862,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
8786
8862
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
8787
8863
|
const value = target?.options?.[option];
|
|
8788
8864
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
8789
|
-
if (!checkable || fileExists((0,
|
|
8865
|
+
if (!checkable || fileExists((0, import_node_path41.join)(workspaceRoot, value))) {
|
|
8790
8866
|
return [];
|
|
8791
8867
|
}
|
|
8792
8868
|
return [
|
|
@@ -8825,15 +8901,12 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
8825
8901
|
};
|
|
8826
8902
|
}
|
|
8827
8903
|
function checkGoWorkInSync(workspaceRoot) {
|
|
8828
|
-
const goWorkPath = (0,
|
|
8904
|
+
const goWorkPath = (0, import_node_path41.join)(workspaceRoot, "go.work");
|
|
8829
8905
|
if (!fileExists(goWorkPath)) {
|
|
8830
8906
|
return void 0;
|
|
8831
8907
|
}
|
|
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")));
|
|
8908
|
+
const uses = parseGoWorkUses((0, import_node_fs34.readFileSync)(goWorkPath, "utf8"));
|
|
8909
|
+
const stale = uses.filter((entry) => !(0, import_node_fs34.existsSync)((0, import_node_path41.join)(workspaceRoot, entry, "go.mod")));
|
|
8837
8910
|
return {
|
|
8838
8911
|
check: "every go.work `use` entry points to a module that still exists",
|
|
8839
8912
|
ok: stale.length === 0,
|
|
@@ -8849,9 +8922,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
8849
8922
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
8850
8923
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
8851
8924
|
];
|
|
8852
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
8925
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path41.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
8853
8926
|
check: `${file} builds the native apps on every OS`,
|
|
8854
|
-
ok: (0,
|
|
8927
|
+
ok: (0, import_node_fs34.readFileSync)((0, import_node_path41.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
8855
8928
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
8856
8929
|
remedy: "run `mnci upgrade`"
|
|
8857
8930
|
}));
|
|
@@ -8864,7 +8937,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
8864
8937
|
return findings;
|
|
8865
8938
|
}
|
|
8866
8939
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
8867
|
-
const manifestPath = (0,
|
|
8940
|
+
const manifestPath = (0, import_node_path41.join)(workspaceRoot, "package.json");
|
|
8868
8941
|
if (!fileExists(manifestPath)) {
|
|
8869
8942
|
return void 0;
|
|
8870
8943
|
}
|
|
@@ -8884,14 +8957,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
8884
8957
|
};
|
|
8885
8958
|
}
|
|
8886
8959
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
8887
|
-
const configs = (0,
|
|
8960
|
+
const configs = (0, import_node_fs34.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
8888
8961
|
cwd: workspaceRoot
|
|
8889
8962
|
}).map((config) => toPosix2(config));
|
|
8890
8963
|
return configs.flatMap((relativePath) => {
|
|
8891
|
-
const configPath = (0,
|
|
8964
|
+
const configPath = (0, import_node_path41.join)(workspaceRoot, relativePath);
|
|
8892
8965
|
let config;
|
|
8893
8966
|
try {
|
|
8894
|
-
config = (0,
|
|
8967
|
+
config = (0, import_node_fs34.readFileSync)(configPath, "utf8");
|
|
8895
8968
|
} catch {
|
|
8896
8969
|
return [];
|
|
8897
8970
|
}
|
|
@@ -8906,11 +8979,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
8906
8979
|
});
|
|
8907
8980
|
}
|
|
8908
8981
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
8909
|
-
const configs = (0,
|
|
8982
|
+
const configs = (0, import_node_fs34.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
8910
8983
|
cwd: workspaceRoot
|
|
8911
8984
|
}).map((config) => toPosix2(config));
|
|
8912
8985
|
return configs.flatMap((relativePath) => {
|
|
8913
|
-
const configPath = (0,
|
|
8986
|
+
const configPath = (0, import_node_path41.join)(workspaceRoot, relativePath);
|
|
8914
8987
|
if (!fileExists(configPath)) {
|
|
8915
8988
|
return [];
|
|
8916
8989
|
}
|
|
@@ -8925,7 +8998,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
8925
8998
|
// `plugins` array (what @nx/react:library writes). For any other shape it would no-op, and
|
|
8926
8999
|
// naming a command that silently does nothing is the failure mode the source-map check
|
|
8927
9000
|
// above goes out of its way to avoid, so the remedy depends on the shape.
|
|
8928
|
-
remedy: canAddDeclarationSpecifierPlugin((0,
|
|
9001
|
+
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
9002
|
}
|
|
8930
9003
|
];
|
|
8931
9004
|
}
|
|
@@ -8941,8 +9014,8 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
8941
9014
|
}
|
|
8942
9015
|
function checkPipelinePhases(workspaceRoot) {
|
|
8943
9016
|
const files = ["azure-pipelines.yml", ".github/workflows/ci.yml"];
|
|
8944
|
-
return files.filter((file) => fileExists((0,
|
|
8945
|
-
const { verifyActive, switchedOff } = inspectPipeline((0,
|
|
9017
|
+
return files.filter((file) => fileExists((0, import_node_path41.join)(workspaceRoot, file))).flatMap((file) => {
|
|
9018
|
+
const { verifyActive, switchedOff } = inspectPipeline((0, import_node_fs34.readFileSync)((0, import_node_path41.join)(workspaceRoot, file), "utf8"));
|
|
8946
9019
|
const verify = {
|
|
8947
9020
|
check: `${file} runs the enforced verify phase`,
|
|
8948
9021
|
ok: verifyActive,
|
|
@@ -8983,7 +9056,7 @@ function checkDependencyRangesNotPreserved(nxJson) {
|
|
|
8983
9056
|
};
|
|
8984
9057
|
}
|
|
8985
9058
|
function checkLockfileHasNoLocalRegistry(workspaceRoot) {
|
|
8986
|
-
if (!fileExists((0,
|
|
9059
|
+
if (!fileExists((0, import_node_path41.join)(workspaceRoot, "package-lock.json"))) {
|
|
8987
9060
|
return void 0;
|
|
8988
9061
|
}
|
|
8989
9062
|
return {
|
|
@@ -8994,7 +9067,7 @@ function checkLockfileHasNoLocalRegistry(workspaceRoot) {
|
|
|
8994
9067
|
};
|
|
8995
9068
|
}
|
|
8996
9069
|
function collectFindings(workspaceRoot) {
|
|
8997
|
-
const nxJsonPath = (0,
|
|
9070
|
+
const nxJsonPath = (0, import_node_path41.join)(workspaceRoot, "nx.json");
|
|
8998
9071
|
if (!fileExists(nxJsonPath)) {
|
|
8999
9072
|
throw new Error(
|
|
9000
9073
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -9060,8 +9133,8 @@ function runDoctor(workspaceRoot, options = {}) {
|
|
|
9060
9133
|
}
|
|
9061
9134
|
|
|
9062
9135
|
// src/dependency-adoption/adopt-dependencies.use-case.ts
|
|
9063
|
-
var
|
|
9064
|
-
var
|
|
9136
|
+
var import_node_fs35 = require("fs");
|
|
9137
|
+
var import_node_path42 = require("path");
|
|
9065
9138
|
|
|
9066
9139
|
// src/clean-working-tree/clean-working-tree.validator.ts
|
|
9067
9140
|
function requireCleanWorkingTree(repositoryRoot, capture = runCapture) {
|
|
@@ -9132,7 +9205,7 @@ var SOURCE_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
|
9132
9205
|
var TEST_FILE = /\.(?:spec|test)\.[^.]+$|[\\/](?:__tests__|tests?|e2e)[\\/]/;
|
|
9133
9206
|
var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", "out", ".git", ".nx", "tmp"]);
|
|
9134
9207
|
function sourceFiles(directory, relative = "") {
|
|
9135
|
-
const entries = (0,
|
|
9208
|
+
const entries = (0, import_node_fs35.readdirSync)((0, import_node_path42.join)(directory, relative), { withFileTypes: true });
|
|
9136
9209
|
const found = [];
|
|
9137
9210
|
for (const entry of entries) {
|
|
9138
9211
|
const path = relative === "" ? entry.name : `${relative}/${entry.name}`;
|
|
@@ -9148,7 +9221,7 @@ function sourceFiles(directory, relative = "") {
|
|
|
9148
9221
|
}
|
|
9149
9222
|
function wantedImportsOf(path, wanted) {
|
|
9150
9223
|
try {
|
|
9151
|
-
const imported = [...extractImportedPackages((0,
|
|
9224
|
+
const imported = [...extractImportedPackages((0, import_node_fs35.readFileSync)(path, "utf8"))];
|
|
9152
9225
|
return imported.filter((name) => wanted.has(name));
|
|
9153
9226
|
} catch {
|
|
9154
9227
|
return [];
|
|
@@ -9159,7 +9232,7 @@ function importsOfProject(projectDirectory, wanted) {
|
|
|
9159
9232
|
const tested = /* @__PURE__ */ new Set();
|
|
9160
9233
|
const files = sourceFiles(projectDirectory);
|
|
9161
9234
|
for (const file of files) {
|
|
9162
|
-
const names = wantedImportsOf((0,
|
|
9235
|
+
const names = wantedImportsOf((0, import_node_path42.join)(projectDirectory, file), wanted);
|
|
9163
9236
|
const target = TEST_FILE.test(file) ? tested : shipped;
|
|
9164
9237
|
for (const name of names) {
|
|
9165
9238
|
target.add(name);
|
|
@@ -9171,7 +9244,7 @@ function importsOfProject(projectDirectory, wanted) {
|
|
|
9171
9244
|
function findUsage(repositoryRoot, projectDirectories, wanted) {
|
|
9172
9245
|
const usage = {};
|
|
9173
9246
|
for (const dir of projectDirectories) {
|
|
9174
|
-
const { shipped, testsOnly } = importsOfProject((0,
|
|
9247
|
+
const { shipped, testsOnly } = importsOfProject((0, import_node_path42.join)(repositoryRoot, dir), wanted);
|
|
9175
9248
|
for (const name of shipped) {
|
|
9176
9249
|
usage[name] ??= { runtime: [], testsOnly: [] };
|
|
9177
9250
|
usage[name].runtime.push(dir);
|
|
@@ -9186,7 +9259,7 @@ function findUsage(repositoryRoot, projectDirectories, wanted) {
|
|
|
9186
9259
|
function adoptDependencies(repositoryRoot, dependencies = {}) {
|
|
9187
9260
|
const run = dependencies.run ?? runShell;
|
|
9188
9261
|
requireCleanWorkingTree(repositoryRoot, dependencies.capture ?? runCapture);
|
|
9189
|
-
const rootPath = (0,
|
|
9262
|
+
const rootPath = (0, import_node_path42.join)(repositoryRoot, "package.json");
|
|
9190
9263
|
if (!fileExists(rootPath)) {
|
|
9191
9264
|
throw new Error("No package.json at the repository root.");
|
|
9192
9265
|
}
|
|
@@ -9221,8 +9294,8 @@ function adoptDependencies(repositoryRoot, dependencies = {}) {
|
|
|
9221
9294
|
}
|
|
9222
9295
|
|
|
9223
9296
|
// src/kind-adoption/adopt-kinds.use-case.ts
|
|
9224
|
-
var
|
|
9225
|
-
var
|
|
9297
|
+
var import_node_fs36 = require("fs");
|
|
9298
|
+
var import_node_path43 = require("path");
|
|
9226
9299
|
|
|
9227
9300
|
// src/kind-adoption/infer-project-kind.algorithm.ts
|
|
9228
9301
|
var SERVER_FRAMEWORKS = ["express", "koa", "fastify", "@nestjs/core"];
|
|
@@ -9323,32 +9396,32 @@ function inferProjectKind(evidence) {
|
|
|
9323
9396
|
// src/kind-adoption/adopt-kinds.use-case.ts
|
|
9324
9397
|
var TYPE_TAG = "type:";
|
|
9325
9398
|
function readEvidence(repositoryRoot, location) {
|
|
9326
|
-
const directory = (0,
|
|
9327
|
-
const files = (0,
|
|
9399
|
+
const directory = (0, import_node_path43.join)(repositoryRoot, location.dir);
|
|
9400
|
+
const files = (0, import_node_fs36.readdirSync)(directory);
|
|
9328
9401
|
const manifest = location.ecosystem === "npm" ? readJson(location.manifestPath) : {};
|
|
9329
|
-
const text = location.ecosystem === "npm" ? "" : (0,
|
|
9402
|
+
const text = location.ecosystem === "npm" ? "" : (0, import_node_fs36.readFileSync)(location.manifestPath, "utf8");
|
|
9330
9403
|
let hasProgram = false;
|
|
9331
9404
|
if (location.ecosystem === "go") {
|
|
9332
|
-
hasProgram = files.filter((file) => file.endsWith(".go")).some((file) => /^package main\b/m.test((0,
|
|
9405
|
+
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
9406
|
} else if (location.ecosystem === "pub") {
|
|
9334
|
-
hasProgram = (0,
|
|
9407
|
+
hasProgram = (0, import_node_fs36.existsSync)((0, import_node_path43.join)(directory, "lib", "main.dart"));
|
|
9335
9408
|
}
|
|
9336
9409
|
return { ecosystem: location.ecosystem, manifest, text, files, hasProgram };
|
|
9337
9410
|
}
|
|
9338
9411
|
function existingKind(directory) {
|
|
9339
9412
|
const sources = [];
|
|
9340
|
-
if (fileExists((0,
|
|
9341
|
-
sources.push(readJson((0,
|
|
9413
|
+
if (fileExists((0, import_node_path43.join)(directory, "project.json"))) {
|
|
9414
|
+
sources.push(readJson((0, import_node_path43.join)(directory, "project.json")).tags ?? []);
|
|
9342
9415
|
}
|
|
9343
|
-
if (fileExists((0,
|
|
9344
|
-
sources.push(readJson((0,
|
|
9416
|
+
if (fileExists((0, import_node_path43.join)(directory, "package.json"))) {
|
|
9417
|
+
sources.push(readJson((0, import_node_path43.join)(directory, "package.json")).nx?.tags ?? []);
|
|
9345
9418
|
}
|
|
9346
9419
|
return sources.flat().find((tag) => tag.startsWith(TYPE_TAG))?.slice(TYPE_TAG.length);
|
|
9347
9420
|
}
|
|
9348
9421
|
function writeKindTag(directory, name, kind) {
|
|
9349
9422
|
const tag = `${TYPE_TAG}${kind}`;
|
|
9350
|
-
const projectJson = (0,
|
|
9351
|
-
const packageJson = (0,
|
|
9423
|
+
const projectJson = (0, import_node_path43.join)(directory, "project.json");
|
|
9424
|
+
const packageJson = (0, import_node_path43.join)(directory, "package.json");
|
|
9352
9425
|
if (fileExists(projectJson)) {
|
|
9353
9426
|
const project = readJson(projectJson);
|
|
9354
9427
|
writeFileEnsured(projectJson, toJson({ ...project, tags: [...project.tags ?? [], tag] }));
|
|
@@ -9372,7 +9445,7 @@ function adoptKinds(repositoryRoot, overrides = {}, dependencies = {}) {
|
|
|
9372
9445
|
}
|
|
9373
9446
|
}
|
|
9374
9447
|
return locations.map((location) => {
|
|
9375
|
-
const directory = (0,
|
|
9448
|
+
const directory = (0, import_node_path43.join)(repositoryRoot, location.dir);
|
|
9376
9449
|
const present = existingKind(directory);
|
|
9377
9450
|
if (present !== void 0) {
|
|
9378
9451
|
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 +9461,12 @@ function adoptKinds(repositoryRoot, overrides = {}, dependencies = {}) {
|
|
|
9388
9461
|
}
|
|
9389
9462
|
|
|
9390
9463
|
// src/repository-adoption/adopt-overlay.use-case.ts
|
|
9391
|
-
var
|
|
9392
|
-
var
|
|
9464
|
+
var import_node_fs38 = require("fs");
|
|
9465
|
+
var import_node_path45 = require("path");
|
|
9393
9466
|
|
|
9394
9467
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
9395
|
-
var
|
|
9396
|
-
var
|
|
9468
|
+
var import_node_fs37 = require("fs");
|
|
9469
|
+
var import_node_path44 = require("path");
|
|
9397
9470
|
function resolveRegistry(options, persisted) {
|
|
9398
9471
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
9399
9472
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -9422,7 +9495,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
9422
9495
|
return persisted.workspaceName;
|
|
9423
9496
|
}
|
|
9424
9497
|
try {
|
|
9425
|
-
const existing = (0,
|
|
9498
|
+
const existing = (0, import_node_fs37.readdirSync)(workspaceRoot).find(
|
|
9426
9499
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
9427
9500
|
);
|
|
9428
9501
|
if (existing) {
|
|
@@ -9430,11 +9503,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
9430
9503
|
}
|
|
9431
9504
|
} catch {
|
|
9432
9505
|
}
|
|
9433
|
-
return (0,
|
|
9506
|
+
return (0, import_node_path44.basename)(workspaceRoot);
|
|
9434
9507
|
}
|
|
9435
9508
|
function detectNpmAuth(workspaceRoot) {
|
|
9436
9509
|
try {
|
|
9437
|
-
return (0,
|
|
9510
|
+
return (0, import_node_fs37.readFileSync)((0, import_node_path44.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
9438
9511
|
} catch {
|
|
9439
9512
|
return void 0;
|
|
9440
9513
|
}
|
|
@@ -9481,7 +9554,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
9481
9554
|
};
|
|
9482
9555
|
}
|
|
9483
9556
|
function runUpgrade(workspaceRoot, options) {
|
|
9484
|
-
if (!fileExists((0,
|
|
9557
|
+
if (!fileExists((0, import_node_path44.join)(workspaceRoot, "nx.json"))) {
|
|
9485
9558
|
throw new Error(
|
|
9486
9559
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
9487
9560
|
);
|
|
@@ -9566,7 +9639,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
9566
9639
|
"Formatting the workspace (eslint --fix) \u2014 the slowest step, minutes on a large workspace"
|
|
9567
9640
|
);
|
|
9568
9641
|
runFormatter(workspaceRoot);
|
|
9569
|
-
const nxJson = readJson((0,
|
|
9642
|
+
const nxJson = readJson((0, import_node_path44.join)(workspaceRoot, "nx.json"));
|
|
9570
9643
|
const stranded = locateStrandedReleaseTags(workspaceRoot, nxJson.release?.releaseTag?.pattern);
|
|
9571
9644
|
for (const entry of stranded) {
|
|
9572
9645
|
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 +9650,9 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
9577
9650
|
|
|
9578
9651
|
// src/repository-adoption/adopt-overlay.use-case.ts
|
|
9579
9652
|
function detectCiProvider(repositoryRoot) {
|
|
9580
|
-
const azure = (0,
|
|
9581
|
-
const workflows = (0,
|
|
9582
|
-
const github = (0,
|
|
9653
|
+
const azure = (0, import_node_fs38.existsSync)((0, import_node_path45.join)(repositoryRoot, "azure-pipelines.yml"));
|
|
9654
|
+
const workflows = (0, import_node_path45.join)(repositoryRoot, ".github", "workflows");
|
|
9655
|
+
const github = (0, import_node_fs38.existsSync)(workflows) && (0, import_node_fs38.readdirSync)(workflows).some((file) => /\.ya?ml$/.test(file));
|
|
9583
9656
|
if (azure && github) {
|
|
9584
9657
|
return "both";
|
|
9585
9658
|
}
|
|
@@ -9589,7 +9662,7 @@ function detectCiProvider(repositoryRoot) {
|
|
|
9589
9662
|
return github ? "github" : void 0;
|
|
9590
9663
|
}
|
|
9591
9664
|
function detectTestRunner(repositoryRoot) {
|
|
9592
|
-
const manifestPath = (0,
|
|
9665
|
+
const manifestPath = (0, import_node_path45.join)(repositoryRoot, "package.json");
|
|
9593
9666
|
if (!fileExists(manifestPath)) {
|
|
9594
9667
|
return void 0;
|
|
9595
9668
|
}
|
|
@@ -9602,7 +9675,7 @@ function detectTestRunner(repositoryRoot) {
|
|
|
9602
9675
|
}
|
|
9603
9676
|
function adoptOverlay(repositoryRoot, options, dependencies = {}) {
|
|
9604
9677
|
requireCleanWorkingTree(repositoryRoot, dependencies.capture ?? runCapture);
|
|
9605
|
-
if (!fileExists((0,
|
|
9678
|
+
if (!fileExists((0, import_node_path45.join)(repositoryRoot, "nx.json"))) {
|
|
9606
9679
|
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
9680
|
}
|
|
9608
9681
|
const persisted = readMnciConfig(repositoryRoot);
|
|
@@ -9615,7 +9688,7 @@ function adoptOverlay(repositoryRoot, options, dependencies = {}) {
|
|
|
9615
9688
|
}
|
|
9616
9689
|
|
|
9617
9690
|
// src/toolchain-adoption/adopt-toolchain.use-case.ts
|
|
9618
|
-
var
|
|
9691
|
+
var import_node_path48 = require("path");
|
|
9619
9692
|
|
|
9620
9693
|
// src/toolchain-adoption/align-nx-family.algorithm.ts
|
|
9621
9694
|
var VERSION = /^[\^~]?(\d+)\.(\d+)\.(\d+)$/;
|
|
@@ -9653,7 +9726,7 @@ function alignNxFamily(dependencies, version) {
|
|
|
9653
9726
|
}
|
|
9654
9727
|
|
|
9655
9728
|
// src/toolchain-adoption/bootstrap-nx.use-case.ts
|
|
9656
|
-
var
|
|
9729
|
+
var import_node_path46 = require("path");
|
|
9657
9730
|
var BASE_PLUGIN = "@nx/js";
|
|
9658
9731
|
var TOOL_PLUGINS = [
|
|
9659
9732
|
["eslint", "@nx/eslint"],
|
|
@@ -9661,13 +9734,13 @@ var TOOL_PLUGINS = [
|
|
|
9661
9734
|
["vitest", "@nx/vite"]
|
|
9662
9735
|
];
|
|
9663
9736
|
function pluginsFor(repositoryRoot) {
|
|
9664
|
-
const manifestPath = (0,
|
|
9737
|
+
const manifestPath = (0, import_node_path46.join)(repositoryRoot, "package.json");
|
|
9665
9738
|
const manifest = fileExists(manifestPath) ? readJson(manifestPath) : {};
|
|
9666
9739
|
const declared = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
9667
9740
|
return [BASE_PLUGIN, ...TOOL_PLUGINS.filter(([tool]) => declared.includes(tool)).map(([, plugin]) => plugin)];
|
|
9668
9741
|
}
|
|
9669
9742
|
function bootstrapNx(repositoryRoot, nxVersion, dependencies) {
|
|
9670
|
-
if (fileExists((0,
|
|
9743
|
+
if (fileExists((0, import_node_path46.join)(repositoryRoot, "nx.json"))) {
|
|
9671
9744
|
return { bootstrapped: false, plugins: [] };
|
|
9672
9745
|
}
|
|
9673
9746
|
const initialised = dependencies.run("npx", ["--yes", `nx@${nxVersion ?? "latest"}`, "init", "--interactive=false", "--nxCloud=skip", "--plugins=skip"], repositoryRoot);
|
|
@@ -9684,24 +9757,24 @@ function bootstrapNx(repositoryRoot, nxVersion, dependencies) {
|
|
|
9684
9757
|
}
|
|
9685
9758
|
|
|
9686
9759
|
// src/toolchain-adoption/retire-tooling.use-case.ts
|
|
9687
|
-
var
|
|
9688
|
-
var
|
|
9760
|
+
var import_node_fs39 = require("fs");
|
|
9761
|
+
var import_node_path47 = require("path");
|
|
9689
9762
|
var RETIRED_COMMAND = /\b(?:prettier|oxfmt|oxlint)\b/;
|
|
9690
9763
|
function retireTooling(repositoryRoot) {
|
|
9691
9764
|
const removed = [];
|
|
9692
9765
|
for (const file of RETIRED_FORMATTER_FILES) {
|
|
9693
|
-
if (!fileExists((0,
|
|
9766
|
+
if (!fileExists((0, import_node_path47.join)(repositoryRoot, file))) {
|
|
9694
9767
|
continue;
|
|
9695
9768
|
}
|
|
9696
|
-
(0,
|
|
9769
|
+
(0, import_node_fs39.rmSync)((0, import_node_path47.join)(repositoryRoot, file), { force: true });
|
|
9697
9770
|
removed.push(file);
|
|
9698
9771
|
}
|
|
9699
|
-
const hadRegistry = fileExists((0,
|
|
9772
|
+
const hadRegistry = fileExists((0, import_node_path47.join)(repositoryRoot, ".verdaccio"));
|
|
9700
9773
|
removeLocalRegistryScaffolding(repositoryRoot);
|
|
9701
9774
|
if (hadRegistry) {
|
|
9702
9775
|
removed.push(".verdaccio, its dependency and the local-registry target");
|
|
9703
9776
|
}
|
|
9704
|
-
const manifestPath = (0,
|
|
9777
|
+
const manifestPath = (0, import_node_path47.join)(repositoryRoot, "package.json");
|
|
9705
9778
|
if (!fileExists(manifestPath)) {
|
|
9706
9779
|
return removed;
|
|
9707
9780
|
}
|
|
@@ -9748,7 +9821,7 @@ function adoptToolchain(repositoryRoot, options = {}, dependencies = {}) {
|
|
|
9748
9821
|
console.log(message);
|
|
9749
9822
|
});
|
|
9750
9823
|
requireCleanWorkingTree(repositoryRoot, capture);
|
|
9751
|
-
const manifestPath = (0,
|
|
9824
|
+
const manifestPath = (0, import_node_path48.join)(repositoryRoot, "package.json");
|
|
9752
9825
|
if (!fileExists(manifestPath)) {
|
|
9753
9826
|
throw new Error("No package.json at the repository root.");
|
|
9754
9827
|
}
|
|
@@ -9787,8 +9860,8 @@ function adoptToolchain(repositoryRoot, options = {}, dependencies = {}) {
|
|
|
9787
9860
|
}
|
|
9788
9861
|
|
|
9789
9862
|
// src/adoption-report/inspect-repository.use-case.ts
|
|
9790
|
-
var
|
|
9791
|
-
var
|
|
9863
|
+
var import_node_fs40 = require("fs");
|
|
9864
|
+
var import_node_path49 = require("path");
|
|
9792
9865
|
var LOCKFILES = [
|
|
9793
9866
|
["package-lock.json", "npm"],
|
|
9794
9867
|
["pnpm-lock.yaml", "pnpm"],
|
|
@@ -9809,25 +9882,25 @@ function inspectRepository(repositoryRoot) {
|
|
|
9809
9882
|
const isGitRepo = inside.status === 0 && inside.stdout.trim() === "true";
|
|
9810
9883
|
const dirty = isGitRepo && runCapture("git", ["status", "--porcelain"], repositoryRoot).stdout.trim() !== "";
|
|
9811
9884
|
const tags = isGitRepo ? runCapture("git", ["tag", "--list"], repositoryRoot).stdout.split(/\r?\n/).filter(Boolean) : [];
|
|
9812
|
-
const manifestPath = (0,
|
|
9885
|
+
const manifestPath = (0, import_node_path49.join)(repositoryRoot, "package.json");
|
|
9813
9886
|
const manifest = fileExists(manifestPath) ? readJson(manifestPath) : {};
|
|
9814
|
-
const nxJsonPath = (0,
|
|
9887
|
+
const nxJsonPath = (0, import_node_path49.join)(repositoryRoot, "nx.json");
|
|
9815
9888
|
const nxJson = fileExists(nxJsonPath) ? readJson(nxJsonPath) : {};
|
|
9816
9889
|
const ci = [];
|
|
9817
9890
|
const pipelines = [];
|
|
9818
|
-
if ((0,
|
|
9891
|
+
if ((0, import_node_fs40.existsSync)((0, import_node_path49.join)(repositoryRoot, "azure-pipelines.yml"))) {
|
|
9819
9892
|
ci.push("azure");
|
|
9820
|
-
pipelines.push((0,
|
|
9893
|
+
pipelines.push((0, import_node_path49.join)(repositoryRoot, "azure-pipelines.yml"));
|
|
9821
9894
|
}
|
|
9822
|
-
const workflows = (0,
|
|
9823
|
-
if ((0,
|
|
9824
|
-
const files = (0,
|
|
9895
|
+
const workflows = (0, import_node_path49.join)(repositoryRoot, ".github", "workflows");
|
|
9896
|
+
if ((0, import_node_fs40.existsSync)(workflows)) {
|
|
9897
|
+
const files = (0, import_node_fs40.readdirSync)(workflows).filter((file) => /\.ya?ml$/.test(file));
|
|
9825
9898
|
if (files.length > 0) {
|
|
9826
9899
|
ci.push("github");
|
|
9827
|
-
pipelines.push(...files.map((file) => (0,
|
|
9900
|
+
pipelines.push(...files.map((file) => (0, import_node_path49.join)(workflows, file)));
|
|
9828
9901
|
}
|
|
9829
9902
|
}
|
|
9830
|
-
const rootFiles = (0,
|
|
9903
|
+
const rootFiles = (0, import_node_fs40.readdirSync)(repositoryRoot);
|
|
9831
9904
|
return {
|
|
9832
9905
|
isGitRepo,
|
|
9833
9906
|
dirty,
|
|
@@ -9838,7 +9911,7 @@ function inspectRepository(repositoryRoot) {
|
|
|
9838
9911
|
tagCount: tags.length,
|
|
9839
9912
|
strandedTags: isGitRepo ? locateStrandedReleaseTags(repositoryRoot, nxJson.release?.releaseTag?.pattern) : [],
|
|
9840
9913
|
ci,
|
|
9841
|
-
pipelineUsesMnci: pipelines.some((file) => /\bmnci ci\b/.test((0,
|
|
9914
|
+
pipelineUsesMnci: pipelines.some((file) => /\bmnci ci\b/.test((0, import_node_fs40.readFileSync)(file, "utf8"))),
|
|
9842
9915
|
retiredTooling: [.../* @__PURE__ */ new Set([...rootFiles.filter((file) => RETIRED_FILE_PATTERN.test(file) || file === ".verdaccio"), ...retiredNamesIn(manifest)])],
|
|
9843
9916
|
personalFiles: PERSONAL_FILES.filter((file) => rootFiles.includes(file))
|
|
9844
9917
|
};
|
|
@@ -10141,13 +10214,13 @@ function runCommands(program, options) {
|
|
|
10141
10214
|
}
|
|
10142
10215
|
|
|
10143
10216
|
// src/workspace-info/list-projects.use-case.ts
|
|
10144
|
-
var
|
|
10217
|
+
var import_node_path50 = require("path");
|
|
10145
10218
|
var TYPE_TAG_PREFIX = "type:";
|
|
10146
10219
|
function listProjects(workspaceRoot) {
|
|
10147
10220
|
return locateProjects(workspaceRoot).map((location) => {
|
|
10148
|
-
const projectJsonPath = (0,
|
|
10221
|
+
const projectJsonPath = (0, import_node_path50.join)(workspaceRoot, location.dir, "project.json");
|
|
10149
10222
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
10150
|
-
const manifestPath = (0,
|
|
10223
|
+
const manifestPath = (0, import_node_path50.join)(workspaceRoot, location.dir, "package.json");
|
|
10151
10224
|
const manifestTags = fileExists(manifestPath) ? readJson(manifestPath).nx?.tags ?? [] : [];
|
|
10152
10225
|
const typeTag = [...project.tags ?? [], ...manifestTags].find((tag) => tag.startsWith(TYPE_TAG_PREFIX));
|
|
10153
10226
|
return {
|
|
@@ -10160,7 +10233,7 @@ function listProjects(workspaceRoot) {
|
|
|
10160
10233
|
}).toSorted((a, b) => a.dir.localeCompare(b.dir));
|
|
10161
10234
|
}
|
|
10162
10235
|
function runProjects(workspaceRoot, options) {
|
|
10163
|
-
if (!fileExists((0,
|
|
10236
|
+
if (!fileExists((0, import_node_path50.join)(workspaceRoot, "nx.json"))) {
|
|
10164
10237
|
throw new Error("No nx.json found here. Run `projects` from the workspace root.");
|
|
10165
10238
|
}
|
|
10166
10239
|
const projects = listProjects(workspaceRoot);
|
|
@@ -10174,11 +10247,11 @@ function runProjects(workspaceRoot, options) {
|
|
|
10174
10247
|
}
|
|
10175
10248
|
|
|
10176
10249
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
10177
|
-
var
|
|
10250
|
+
var import_node_path52 = require("path");
|
|
10178
10251
|
|
|
10179
10252
|
// src/cli-version/check-for-update.use-case.ts
|
|
10180
|
-
var
|
|
10181
|
-
var
|
|
10253
|
+
var import_node_fs41 = require("fs");
|
|
10254
|
+
var import_node_path51 = require("path");
|
|
10182
10255
|
var import_cross_spawn4 = __toESM(require("cross-spawn"));
|
|
10183
10256
|
var PACKAGE_NAME2 = "@mnci/cli";
|
|
10184
10257
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -10237,8 +10310,8 @@ function releaseTriple(version) {
|
|
|
10237
10310
|
}
|
|
10238
10311
|
function readCliVersion(packageDirectory) {
|
|
10239
10312
|
try {
|
|
10240
|
-
const manifestPath = (0,
|
|
10241
|
-
const manifest = JSON.parse((0,
|
|
10313
|
+
const manifestPath = (0, import_node_path51.join)(packageDirectory, "..", "package.json");
|
|
10314
|
+
const manifest = JSON.parse((0, import_node_fs41.readFileSync)(manifestPath, "utf8"));
|
|
10242
10315
|
return manifest.version ?? "0.0.0";
|
|
10243
10316
|
} catch {
|
|
10244
10317
|
return "0.0.0";
|
|
@@ -10248,7 +10321,7 @@ function readCliVersion(packageDirectory) {
|
|
|
10248
10321
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
10249
10322
|
function readWorkspaceInfo(workspaceRoot, cliVersion) {
|
|
10250
10323
|
const latest = fetchLatestVersion() ?? null;
|
|
10251
|
-
const isWorkspace = fileExists((0,
|
|
10324
|
+
const isWorkspace = fileExists((0, import_node_path52.join)(workspaceRoot, "nx.json"));
|
|
10252
10325
|
return {
|
|
10253
10326
|
cli: {
|
|
10254
10327
|
version: cliVersion,
|
|
@@ -10269,7 +10342,7 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
10269
10342
|
}
|
|
10270
10343
|
|
|
10271
10344
|
// src/interactive-wizard/interactive-wizard.use-case.ts
|
|
10272
|
-
var
|
|
10345
|
+
var import_node_path53 = require("path");
|
|
10273
10346
|
|
|
10274
10347
|
// src/interactive-wizard/adopt-steps.config.ts
|
|
10275
10348
|
var ADOPT_GLOBAL_OPTIONS = ["json"];
|
|
@@ -10450,7 +10523,7 @@ function wizardMenu(commands, inWorkspace) {
|
|
|
10450
10523
|
}
|
|
10451
10524
|
async function runInteractive(program, prompter = createInquirerPrompter(), workingDirectory = process.cwd()) {
|
|
10452
10525
|
const commands = describeCommands(program);
|
|
10453
|
-
const inWorkspace = fileExists((0,
|
|
10526
|
+
const inWorkspace = fileExists((0, import_node_path53.join)(workingDirectory, "nx.json"));
|
|
10454
10527
|
const name = await prompter.select("What would you like to do?", wizardMenu(commands, inWorkspace));
|
|
10455
10528
|
const command = commands.find((candidate) => candidate.name === name);
|
|
10456
10529
|
const argv = buildArgv(command, await askCommand(command, prompter));
|
|
@@ -10477,8 +10550,8 @@ var PRESETS = [
|
|
|
10477
10550
|
var PRESET_IDS = PRESETS.map((preset) => preset.id);
|
|
10478
10551
|
|
|
10479
10552
|
// src/workspace-presets/wire-web-api.use-case.ts
|
|
10480
|
-
var
|
|
10481
|
-
var
|
|
10553
|
+
var import_node_fs42 = require("fs");
|
|
10554
|
+
var import_node_path54 = require("path");
|
|
10482
10555
|
|
|
10483
10556
|
// src/workspace-presets/web-api-wiring.algorithm.ts
|
|
10484
10557
|
function apiHandler(shared) {
|
|
@@ -10650,18 +10723,18 @@ function declareDependency(manifestPath, name) {
|
|
|
10650
10723
|
}
|
|
10651
10724
|
function removeFiles(slice, files) {
|
|
10652
10725
|
for (const file of files) {
|
|
10653
|
-
(0,
|
|
10726
|
+
(0, import_node_fs42.rmSync)((0, import_node_path54.join)(slice, file), { force: true });
|
|
10654
10727
|
}
|
|
10655
10728
|
}
|
|
10656
10729
|
function replaceOnce(path, anchor, replacement) {
|
|
10657
|
-
const text = (0,
|
|
10730
|
+
const text = (0, import_node_fs42.readFileSync)(path, "utf8");
|
|
10658
10731
|
if (!text.includes(anchor)) {
|
|
10659
10732
|
throw new Error(`${path} has no ${anchor}; the generator's output changed, so the preset cannot wire it.`);
|
|
10660
10733
|
}
|
|
10661
10734
|
writeFileEnsured(path, text.replace(anchor, () => replacement));
|
|
10662
10735
|
}
|
|
10663
10736
|
function proxyApi(viteConfigPath) {
|
|
10664
|
-
const text = (0,
|
|
10737
|
+
const text = (0, import_node_fs42.readFileSync)(viteConfigPath, "utf8");
|
|
10665
10738
|
const proxied = withApiProxy(text, API_ORIGIN);
|
|
10666
10739
|
if (proxied === text && !text.includes("proxy:")) {
|
|
10667
10740
|
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 +10742,30 @@ function proxyApi(viteConfigPath) {
|
|
|
10669
10742
|
writeFileEnsured(viteConfigPath, proxied);
|
|
10670
10743
|
}
|
|
10671
10744
|
function wireWebApi(workspaceRoot, projects) {
|
|
10672
|
-
const sharedManifest = (0,
|
|
10745
|
+
const sharedManifest = (0, import_node_path54.join)(workspaceRoot, "libs", projects.shared, "package.json");
|
|
10673
10746
|
if (!fileExists(sharedManifest)) {
|
|
10674
10747
|
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
10748
|
}
|
|
10676
10749
|
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,
|
|
10750
|
+
const api = (0, import_node_path54.join)(workspaceRoot, "apps", projects.api);
|
|
10751
|
+
declareDependency((0, import_node_path54.join)(api, "package.json"), shared);
|
|
10752
|
+
const hello = (0, import_node_path54.join)(api, "src", "hello");
|
|
10753
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "hello.handler.ts"), apiHandler(shared));
|
|
10754
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "hello.handler.spec.ts"), apiHandlerSpec(shared));
|
|
10755
|
+
writeFileEnsured((0, import_node_path54.join)(hello, "index.ts"), apiBarrel());
|
|
10683
10756
|
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,
|
|
10757
|
+
replaceOnce((0, import_node_path54.join)(api, "src", "main.ts"), "app.get('/', helloHandler)", "app.get('/api/greeting', helloHandler)");
|
|
10758
|
+
const web = (0, import_node_path54.join)(workspaceRoot, "apps", projects.web);
|
|
10759
|
+
declareDependency((0, import_node_path54.join)(web, "package.json"), shared);
|
|
10760
|
+
const greeting = (0, import_node_path54.join)(web, "src", "greeting");
|
|
10761
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.client.ts"), webGreetingClient(shared));
|
|
10762
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.client.spec.ts"), webGreetingClientSpec());
|
|
10763
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.component.tsx"), webGreetingComponent(shared));
|
|
10764
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "greeting.component.spec.tsx"), webGreetingSpec());
|
|
10765
|
+
writeFileEnsured((0, import_node_path54.join)(greeting, "index.ts"), webGreetingBarrel());
|
|
10693
10766
|
removeFiles(greeting, ["greet.use-case.ts", "greet.use-case.spec.ts", "greeting.contract.ts"]);
|
|
10694
|
-
writeFileEnsured((0,
|
|
10695
|
-
proxyApi((0,
|
|
10767
|
+
writeFileEnsured((0, import_node_path54.join)(web, "src", "app", "app.component.spec.tsx"), webAppSpec());
|
|
10768
|
+
proxyApi((0, import_node_path54.join)(web, "vite.config.mts"));
|
|
10696
10769
|
}
|
|
10697
10770
|
|
|
10698
10771
|
// src/workspace-presets/apply-preset.use-case.ts
|
|
@@ -10735,8 +10808,8 @@ async function applyPreset(workspaceRoot, presetId, dependencies = {}) {
|
|
|
10735
10808
|
}
|
|
10736
10809
|
|
|
10737
10810
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
10738
|
-
var
|
|
10739
|
-
var
|
|
10811
|
+
var import_node_fs43 = require("fs");
|
|
10812
|
+
var import_node_path55 = require("path");
|
|
10740
10813
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
10741
10814
|
var AGENT_AND_CI_ENTRIES = [
|
|
10742
10815
|
"AGENTS.md",
|
|
@@ -10767,13 +10840,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
10767
10840
|
"packages"
|
|
10768
10841
|
];
|
|
10769
10842
|
function assertAdoptableDirectory(target) {
|
|
10770
|
-
if (!(0,
|
|
10843
|
+
if (!(0, import_node_fs43.existsSync)(target)) {
|
|
10771
10844
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
10772
10845
|
}
|
|
10773
|
-
if (!(0,
|
|
10846
|
+
if (!(0, import_node_fs43.statSync)(target).isDirectory()) {
|
|
10774
10847
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
10775
10848
|
}
|
|
10776
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
10849
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs43.existsSync)((0, import_node_path55.join)(target, entry)));
|
|
10777
10850
|
if (blockers.length > 0) {
|
|
10778
10851
|
throw new Error(
|
|
10779
10852
|
`--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 +10854,15 @@ function assertAdoptableDirectory(target) {
|
|
|
10781
10854
|
}
|
|
10782
10855
|
}
|
|
10783
10856
|
function mergeGitignore(generatedFile, targetFile) {
|
|
10784
|
-
const existing = (0,
|
|
10857
|
+
const existing = (0, import_node_fs43.readFileSync)(targetFile, "utf8");
|
|
10785
10858
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
10786
|
-
const additions = (0,
|
|
10859
|
+
const additions = (0, import_node_fs43.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
10787
10860
|
const trimmed = line.trim();
|
|
10788
10861
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
10789
10862
|
});
|
|
10790
10863
|
if (additions.length === 0) return false;
|
|
10791
10864
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
10792
|
-
(0,
|
|
10865
|
+
(0, import_node_fs43.writeFileSync)(
|
|
10793
10866
|
targetFile,
|
|
10794
10867
|
`${existing}${separator}
|
|
10795
10868
|
# Added by mnci (Nx workspace)
|
|
@@ -10799,9 +10872,9 @@ ${additions.join("\n")}
|
|
|
10799
10872
|
return true;
|
|
10800
10873
|
}
|
|
10801
10874
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
10802
|
-
const entries = (0,
|
|
10875
|
+
const entries = (0, import_node_fs43.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
10803
10876
|
const collisions = entries.filter(
|
|
10804
|
-
(entry) => (0,
|
|
10877
|
+
(entry) => (0, import_node_fs43.existsSync)((0, import_node_path55.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
10805
10878
|
);
|
|
10806
10879
|
if (collisions.length > 0) {
|
|
10807
10880
|
throw new Error(
|
|
@@ -10810,40 +10883,40 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
10810
10883
|
}
|
|
10811
10884
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
10812
10885
|
for (const entry of entries) {
|
|
10813
|
-
const from = (0,
|
|
10814
|
-
const to = (0,
|
|
10815
|
-
if (entry === ".gitignore" && (0,
|
|
10886
|
+
const from = (0, import_node_path55.join)(generatedRoot, entry);
|
|
10887
|
+
const to = (0, import_node_path55.join)(target, entry);
|
|
10888
|
+
if (entry === ".gitignore" && (0, import_node_fs43.existsSync)(to)) {
|
|
10816
10889
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
10817
10890
|
result.kept.push(entry);
|
|
10818
10891
|
continue;
|
|
10819
10892
|
}
|
|
10820
|
-
if ((0,
|
|
10893
|
+
if ((0, import_node_fs43.existsSync)(to)) {
|
|
10821
10894
|
result.kept.push(entry);
|
|
10822
10895
|
continue;
|
|
10823
10896
|
}
|
|
10824
|
-
(0,
|
|
10897
|
+
(0, import_node_fs43.cpSync)(from, to, { recursive: true });
|
|
10825
10898
|
result.copied.push(entry);
|
|
10826
10899
|
}
|
|
10827
|
-
(0,
|
|
10900
|
+
(0, import_node_fs43.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
10828
10901
|
return result;
|
|
10829
10902
|
}
|
|
10830
10903
|
|
|
10831
10904
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
10832
|
-
var
|
|
10905
|
+
var import_node_fs45 = require("fs");
|
|
10833
10906
|
var import_node_os2 = require("os");
|
|
10834
|
-
var
|
|
10907
|
+
var import_node_path57 = require("path");
|
|
10835
10908
|
|
|
10836
10909
|
// src/workspace-creation/remove-generated-pipelines.use-case.ts
|
|
10837
|
-
var
|
|
10838
|
-
var
|
|
10910
|
+
var import_node_fs44 = require("fs");
|
|
10911
|
+
var import_node_path56 = require("path");
|
|
10839
10912
|
var NX_GENERATED_PIPELINES = [".github/workflows/ci.yml", "azure-pipelines.yml"];
|
|
10840
10913
|
function removeGeneratedPipelines(generatedRoot) {
|
|
10841
10914
|
const removed = [];
|
|
10842
10915
|
for (const file of NX_GENERATED_PIPELINES) {
|
|
10843
|
-
if (!fileExists((0,
|
|
10916
|
+
if (!fileExists((0, import_node_path56.join)(generatedRoot, file))) {
|
|
10844
10917
|
continue;
|
|
10845
10918
|
}
|
|
10846
|
-
(0,
|
|
10919
|
+
(0, import_node_fs44.rmSync)((0, import_node_path56.join)(generatedRoot, file), { force: true });
|
|
10847
10920
|
removed.push(file);
|
|
10848
10921
|
}
|
|
10849
10922
|
return removed;
|
|
@@ -10892,10 +10965,10 @@ async function resolveRegistry2(options) {
|
|
|
10892
10965
|
return await promptRegistry();
|
|
10893
10966
|
}
|
|
10894
10967
|
async function runNew(name, options) {
|
|
10895
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
10968
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path57.resolve)(process.cwd(), options.into);
|
|
10896
10969
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
10897
10970
|
if (options.preset !== void 0) findPreset(options.preset);
|
|
10898
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
10971
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path57.basename)(adoptTarget));
|
|
10899
10972
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
10900
10973
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
10901
10974
|
const registry = await resolveRegistry2(options);
|
|
@@ -10908,8 +10981,8 @@ async function runNew(name, options) {
|
|
|
10908
10981
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
10909
10982
|
const stack = await resolveStack(options);
|
|
10910
10983
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
10911
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
10912
|
-
let workspaceRoot = (0,
|
|
10984
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs45.mkdtempSync)((0, import_node_path57.join)((0, import_node_os2.tmpdir)(), "mnci-new-"));
|
|
10985
|
+
let workspaceRoot = (0, import_node_path57.join)(stagingParent, workspaceName);
|
|
10913
10986
|
try {
|
|
10914
10987
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
10915
10988
|
runNpx(
|
|
@@ -10933,7 +11006,7 @@ async function runNew(name, options) {
|
|
|
10933
11006
|
workspaceRoot = adoptTarget;
|
|
10934
11007
|
}
|
|
10935
11008
|
} finally {
|
|
10936
|
-
if (adoptTarget !== void 0) (0,
|
|
11009
|
+
if (adoptTarget !== void 0) (0, import_node_fs45.rmSync)(stagingParent, { recursive: true, force: true });
|
|
10937
11010
|
}
|
|
10938
11011
|
logger.step(
|
|
10939
11012
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -10943,8 +11016,8 @@ async function runNew(name, options) {
|
|
|
10943
11016
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
10944
11017
|
logger.detail
|
|
10945
11018
|
);
|
|
10946
|
-
(0,
|
|
10947
|
-
(0,
|
|
11019
|
+
(0, import_node_fs45.rmSync)((0, import_node_path57.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
11020
|
+
(0, import_node_fs45.rmSync)((0, import_node_path57.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
10948
11021
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
10949
11022
|
const installStatus = runShell(
|
|
10950
11023
|
"npm",
|