@mnci/cli 4.15.0 → 4.16.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 +90 -1
- package/dist/cli.js +404 -244
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -37,10 +37,6 @@ __export(main_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(main_exports);
|
|
38
38
|
var import_commander = require("commander");
|
|
39
39
|
|
|
40
|
-
// src/project-scaffolding/add-project.use-case.ts
|
|
41
|
-
var import_node_path20 = require("path");
|
|
42
|
-
var import_prompts3 = require("@inquirer/prompts");
|
|
43
|
-
|
|
44
40
|
// src/nx-workspace/nx.client.ts
|
|
45
41
|
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
46
42
|
|
|
@@ -200,6 +196,10 @@ function runFormatter(cwd, target = ".") {
|
|
|
200
196
|
}
|
|
201
197
|
}
|
|
202
198
|
|
|
199
|
+
// src/workspace-overlay/overlay.use-case.ts
|
|
200
|
+
var import_node_fs2 = require("fs");
|
|
201
|
+
var import_node_path2 = require("path");
|
|
202
|
+
|
|
203
203
|
// src/file-system/file-system.client.ts
|
|
204
204
|
var import_node_fs = require("fs");
|
|
205
205
|
var import_node_path = require("path");
|
|
@@ -282,22 +282,7 @@ function fileExists(path) {
|
|
|
282
282
|
return (0, import_node_fs.existsSync)(path);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
// src/project-name/project-name.validator.ts
|
|
286
|
-
function assertValidProjectName(name, label) {
|
|
287
|
-
if (!/^[a-z][a-z0-9-]*(?:\.[a-z0-9-]+)*$/.test(name)) {
|
|
288
|
-
throw new Error(
|
|
289
|
-
`${label} '${name}' is invalid \u2014 use lowercase letters, digits, hyphens and dots, starting with a letter, with no leading, trailing or repeated dot (e.g. 'my-project', 'my.service').`
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/project-scaffolding/csharp.use-case.ts
|
|
295
|
-
var import_node_fs4 = require("fs");
|
|
296
|
-
var import_node_path4 = require("path");
|
|
297
|
-
|
|
298
285
|
// src/workspace-overlay/overlay.use-case.ts
|
|
299
|
-
var import_node_fs2 = require("fs");
|
|
300
|
-
var import_node_path2 = require("path");
|
|
301
286
|
var DEFAULT_STACK = { testRunner: "jest" };
|
|
302
287
|
var TS_COMPILER_DEPENDENCIES = {
|
|
303
288
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
@@ -2209,6 +2194,125 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2209
2194
|
}
|
|
2210
2195
|
}
|
|
2211
2196
|
|
|
2197
|
+
// src/ci-pipeline/ci-environment.client.ts
|
|
2198
|
+
function detectCiHost(environment) {
|
|
2199
|
+
if (environment.GITHUB_ACTIONS === "true") {
|
|
2200
|
+
return "github";
|
|
2201
|
+
}
|
|
2202
|
+
if (environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "") {
|
|
2203
|
+
return "azure";
|
|
2204
|
+
}
|
|
2205
|
+
return "local";
|
|
2206
|
+
}
|
|
2207
|
+
function pullRequestTarget(environment) {
|
|
2208
|
+
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
2209
|
+
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
2210
|
+
}
|
|
2211
|
+
function groupStart(host, title) {
|
|
2212
|
+
switch (host) {
|
|
2213
|
+
case "github": {
|
|
2214
|
+
return `::group::${title}`;
|
|
2215
|
+
}
|
|
2216
|
+
case "azure": {
|
|
2217
|
+
return `##[group]${title}`;
|
|
2218
|
+
}
|
|
2219
|
+
case "local": {
|
|
2220
|
+
return `
|
|
2221
|
+
\u25B8 ${title}`;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
function groupEnd(host) {
|
|
2226
|
+
switch (host) {
|
|
2227
|
+
case "github": {
|
|
2228
|
+
return "::endgroup::";
|
|
2229
|
+
}
|
|
2230
|
+
case "azure": {
|
|
2231
|
+
return "##[endgroup]";
|
|
2232
|
+
}
|
|
2233
|
+
case "local": {
|
|
2234
|
+
return void 0;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
// src/ci-pipeline/verify.use-case.ts
|
|
2240
|
+
function runVerify(workspaceRoot, dependencies = {}) {
|
|
2241
|
+
const environment = dependencies.environment ?? process.env;
|
|
2242
|
+
const processes = dependencies.processes ?? {
|
|
2243
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2244
|
+
capture: (command, arguments_) => runCapture(command, arguments_, workspaceRoot)
|
|
2245
|
+
};
|
|
2246
|
+
const log = dependencies.log ?? ((message) => {
|
|
2247
|
+
console.log(message);
|
|
2248
|
+
});
|
|
2249
|
+
const host = detectCiHost(environment);
|
|
2250
|
+
const inGroup = (title, command, arguments_) => {
|
|
2251
|
+
log(groupStart(host, title));
|
|
2252
|
+
const status = processes.run(command, arguments_);
|
|
2253
|
+
const closing = groupEnd(host);
|
|
2254
|
+
if (closing !== void 0) {
|
|
2255
|
+
log(closing);
|
|
2256
|
+
}
|
|
2257
|
+
return status;
|
|
2258
|
+
};
|
|
2259
|
+
const synced = inGroup("Verify the workspace is synced", "npx", ["nx", "sync:check"]);
|
|
2260
|
+
if (synced !== 0) {
|
|
2261
|
+
log("The workspace is not synced: run 'npx nx sync' locally and commit the result.");
|
|
2262
|
+
return synced;
|
|
2263
|
+
}
|
|
2264
|
+
const exclude = hasNativeGoApp(workspaceRoot) ? [`--exclude=tag:${GO_CGO_TAG}`] : [];
|
|
2265
|
+
const everything = () => inGroup("Verify every project", "npx", ["nx", "run-many", "-t", VERIFY_TARGETS, ...exclude]);
|
|
2266
|
+
const target = pullRequestTarget(environment);
|
|
2267
|
+
if (target === void 0) {
|
|
2268
|
+
log("Not a pull request - verifying EVERY project.");
|
|
2269
|
+
return everything();
|
|
2270
|
+
}
|
|
2271
|
+
const mergeBase = (reference) => {
|
|
2272
|
+
const result = processes.capture("git", ["merge-base", reference, "HEAD"]);
|
|
2273
|
+
return result.status === 0 ? result.stdout.trim() : "";
|
|
2274
|
+
};
|
|
2275
|
+
let base = mergeBase(`origin/${target}`);
|
|
2276
|
+
if (base === "") {
|
|
2277
|
+
log(`No origin/${target} ref - fetching it to resolve a merge-base.`);
|
|
2278
|
+
processes.run("git", ["fetch", "--no-tags", "origin", target]);
|
|
2279
|
+
base = mergeBase("FETCH_HEAD");
|
|
2280
|
+
}
|
|
2281
|
+
if (base === "") {
|
|
2282
|
+
log(`Could not resolve a merge-base with ${target} - verifying EVERY project.`);
|
|
2283
|
+
return everything();
|
|
2284
|
+
}
|
|
2285
|
+
log(`Pull request against ${target} - verifying projects affected since ${base}`);
|
|
2286
|
+
return inGroup("Verify the affected projects", "npx", ["nx", "affected", "-t", VERIFY_TARGETS, `--base=${base}`, ...exclude]);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
// src/ci-pipeline/index.ts
|
|
2290
|
+
var CI_PHASES = ["verify"];
|
|
2291
|
+
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
2292
|
+
switch (phase) {
|
|
2293
|
+
case "verify": {
|
|
2294
|
+
return runVerify(workspaceRoot, dependencies);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
// src/project-scaffolding/add-project.use-case.ts
|
|
2300
|
+
var import_node_path21 = require("path");
|
|
2301
|
+
var import_prompts3 = require("@inquirer/prompts");
|
|
2302
|
+
|
|
2303
|
+
// src/project-name/project-name.validator.ts
|
|
2304
|
+
function assertValidProjectName(name, label) {
|
|
2305
|
+
if (!/^[a-z][a-z0-9-]*(?:\.[a-z0-9-]+)*$/.test(name)) {
|
|
2306
|
+
throw new Error(
|
|
2307
|
+
`${label} '${name}' is invalid \u2014 use lowercase letters, digits, hyphens and dots, starting with a letter, with no leading, trailing or repeated dot (e.g. 'my-project', 'my.service').`
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// src/project-scaffolding/csharp.use-case.ts
|
|
2313
|
+
var import_node_fs4 = require("fs");
|
|
2314
|
+
var import_node_path4 = require("path");
|
|
2315
|
+
|
|
2212
2316
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2213
2317
|
var import_node_fs3 = require("fs");
|
|
2214
2318
|
var import_node_path3 = require("path");
|
|
@@ -2797,12 +2901,44 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
2797
2901
|
}
|
|
2798
2902
|
|
|
2799
2903
|
// src/project-scaffolding/go.use-case.ts
|
|
2800
|
-
var
|
|
2801
|
-
var
|
|
2904
|
+
var import_node_fs7 = require("fs");
|
|
2905
|
+
var import_node_path8 = require("path");
|
|
2802
2906
|
|
|
2803
|
-
// src/
|
|
2907
|
+
// src/go-workspace/go-plugin.use-case.ts
|
|
2804
2908
|
var import_node_fs5 = require("fs");
|
|
2805
2909
|
var import_node_path6 = require("path");
|
|
2910
|
+
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
2911
|
+
function hasGoProject(workspaceRoot) {
|
|
2912
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs5.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
2913
|
+
return projectFiles.some((projectFile) => {
|
|
2914
|
+
try {
|
|
2915
|
+
const { tags } = JSON.parse((0, import_node_fs5.readFileSync)((0, import_node_path6.join)(workspaceRoot, projectFile), "utf8"));
|
|
2916
|
+
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
2917
|
+
} catch {
|
|
2918
|
+
return false;
|
|
2919
|
+
}
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
function isNxGoPluginRegistered(workspaceRoot) {
|
|
2923
|
+
const nxJsonPath = (0, import_node_path6.join)(workspaceRoot, "nx.json");
|
|
2924
|
+
if (!fileExists(nxJsonPath)) {
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
return (readJson(nxJsonPath).plugins ?? []).some((entry) => (typeof entry === "string" ? entry : entry.plugin) === NX_GO_PLUGIN);
|
|
2928
|
+
}
|
|
2929
|
+
function registerNxGoPlugin(workspaceRoot) {
|
|
2930
|
+
const nxJsonPath = (0, import_node_path6.join)(workspaceRoot, "nx.json");
|
|
2931
|
+
if (!fileExists(nxJsonPath) || isNxGoPluginRegistered(workspaceRoot)) {
|
|
2932
|
+
return false;
|
|
2933
|
+
}
|
|
2934
|
+
const nxJson = readJson(nxJsonPath);
|
|
2935
|
+
writeFileEnsured(nxJsonPath, toJson({ ...nxJson, plugins: [...nxJson.plugins ?? [], NX_GO_PLUGIN] }));
|
|
2936
|
+
return true;
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
// src/project-scaffolding/go-release.use-case.ts
|
|
2940
|
+
var import_node_fs6 = require("fs");
|
|
2941
|
+
var import_node_path7 = require("path");
|
|
2806
2942
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
2807
2943
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
2808
2944
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -2928,7 +3064,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
2928
3064
|
}
|
|
2929
3065
|
};
|
|
2930
3066
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
2931
|
-
const projectJsonPath = (0,
|
|
3067
|
+
const projectJsonPath = (0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json");
|
|
2932
3068
|
if (!fileExists(projectJsonPath)) {
|
|
2933
3069
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
2934
3070
|
}
|
|
@@ -2949,22 +3085,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
2949
3085
|
}
|
|
2950
3086
|
})
|
|
2951
3087
|
);
|
|
2952
|
-
writeFileEnsured((0,
|
|
3088
|
+
writeFileEnsured((0, import_node_path7.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
2953
3089
|
}
|
|
2954
3090
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
2955
|
-
const apps = (0,
|
|
3091
|
+
const apps = (0, import_node_path7.join)(workspaceRoot, "apps");
|
|
2956
3092
|
let entries;
|
|
2957
3093
|
try {
|
|
2958
|
-
entries = (0,
|
|
3094
|
+
entries = (0, import_node_fs6.readdirSync)(apps);
|
|
2959
3095
|
} catch {
|
|
2960
3096
|
return false;
|
|
2961
3097
|
}
|
|
2962
3098
|
const hasReleasableApp = entries.some((entry) => {
|
|
2963
|
-
const projectJsonPath = (0,
|
|
3099
|
+
const projectJsonPath = (0, import_node_path7.join)(apps, entry, "project.json");
|
|
2964
3100
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
2965
3101
|
});
|
|
2966
|
-
const path = (0,
|
|
2967
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
3102
|
+
const path = (0, import_node_path7.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3103
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs6.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
2968
3104
|
return false;
|
|
2969
3105
|
}
|
|
2970
3106
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -2998,7 +3134,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
2998
3134
|
}
|
|
2999
3135
|
}
|
|
3000
3136
|
function ensureGoModule(workspaceRoot) {
|
|
3001
|
-
if (fileExists((0,
|
|
3137
|
+
if (fileExists((0, import_node_path8.join)(workspaceRoot, "go.mod"))) {
|
|
3002
3138
|
return;
|
|
3003
3139
|
}
|
|
3004
3140
|
logger.step("Bootstrapping the workspace Go module (single root go.mod)");
|
|
@@ -3007,7 +3143,7 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3007
3143
|
}
|
|
3008
3144
|
function goModulePath(workspaceRoot) {
|
|
3009
3145
|
try {
|
|
3010
|
-
const contents = (0,
|
|
3146
|
+
const contents = (0, import_node_fs7.readFileSync)((0, import_node_path8.join)(workspaceRoot, "go.mod"), "utf8");
|
|
3011
3147
|
return /^module\s+(\S+)/m.exec(contents)?.[1];
|
|
3012
3148
|
} catch {
|
|
3013
3149
|
return void 0;
|
|
@@ -3088,16 +3224,16 @@ function goNativePackageTarget(name) {
|
|
|
3088
3224
|
}
|
|
3089
3225
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3090
3226
|
const changed = [];
|
|
3091
|
-
const apps = (0,
|
|
3227
|
+
const apps = (0, import_node_path8.join)(workspaceRoot, "apps");
|
|
3092
3228
|
if (!fileExists(apps)) {
|
|
3093
3229
|
return changed;
|
|
3094
3230
|
}
|
|
3095
|
-
for (const name of (0,
|
|
3096
|
-
const projectJsonPath = (0,
|
|
3231
|
+
for (const name of (0, import_node_fs7.readdirSync)(apps)) {
|
|
3232
|
+
const projectJsonPath = (0, import_node_path8.join)(apps, name, "project.json");
|
|
3097
3233
|
if (!fileExists(projectJsonPath)) {
|
|
3098
3234
|
continue;
|
|
3099
3235
|
}
|
|
3100
|
-
const project = JSON.parse((0,
|
|
3236
|
+
const project = JSON.parse((0, import_node_fs7.readFileSync)(projectJsonPath, "utf8"));
|
|
3101
3237
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3102
3238
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3103
3239
|
continue;
|
|
@@ -3133,8 +3269,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
3133
3269
|
}
|
|
3134
3270
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
3135
3271
|
const { packageName, functionName, fileStem } = goLibraryIdentifiers(projectName);
|
|
3136
|
-
(0,
|
|
3137
|
-
(0,
|
|
3272
|
+
(0, import_node_fs7.rmSync)((0, import_node_path8.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
3273
|
+
(0, import_node_fs7.rmSync)((0, import_node_path8.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
3138
3274
|
const files = [
|
|
3139
3275
|
[
|
|
3140
3276
|
"doc.go",
|
|
@@ -3144,14 +3280,14 @@ package ${packageName}
|
|
|
3144
3280
|
`
|
|
3145
3281
|
],
|
|
3146
3282
|
[
|
|
3147
|
-
(0,
|
|
3283
|
+
(0, import_node_path8.join)(packageName, "doc.go"),
|
|
3148
3284
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
3149
3285
|
// the outcome it delivers, and add one package per further outcome.
|
|
3150
3286
|
package ${packageName}
|
|
3151
3287
|
`
|
|
3152
3288
|
],
|
|
3153
3289
|
[
|
|
3154
|
-
(0,
|
|
3290
|
+
(0, import_node_path8.join)(packageName, `${fileStem}_use_case.go`),
|
|
3155
3291
|
`package ${packageName}
|
|
3156
3292
|
|
|
3157
3293
|
// ${functionName} is the generator's sample behaviour, kept so the slice builds and tests.
|
|
@@ -3161,7 +3297,7 @@ func ${functionName}(name string) string {
|
|
|
3161
3297
|
`
|
|
3162
3298
|
],
|
|
3163
3299
|
[
|
|
3164
|
-
(0,
|
|
3300
|
+
(0, import_node_path8.join)(packageName, `${fileStem}_use_case_test.go`),
|
|
3165
3301
|
`package ${packageName}
|
|
3166
3302
|
|
|
3167
3303
|
import "testing"
|
|
@@ -3175,7 +3311,7 @@ func Test${functionName}(t *testing.T) {
|
|
|
3175
3311
|
]
|
|
3176
3312
|
];
|
|
3177
3313
|
for (const [relativePath, content] of files) {
|
|
3178
|
-
const path = (0,
|
|
3314
|
+
const path = (0, import_node_path8.join)(projectRoot, relativePath);
|
|
3179
3315
|
if (!fileExists(path)) {
|
|
3180
3316
|
writeFileEnsured(path, content);
|
|
3181
3317
|
}
|
|
@@ -3187,6 +3323,9 @@ function prepareGo(workspaceRoot) {
|
|
|
3187
3323
|
warnIfNoGolangciLint(workspaceRoot);
|
|
3188
3324
|
ensureNxGoPlugin(workspaceRoot);
|
|
3189
3325
|
ensureGoModule(workspaceRoot);
|
|
3326
|
+
if (registerNxGoPlugin(workspaceRoot)) {
|
|
3327
|
+
logger.step("Registering the Go plugin in nx.json, so Nx can see which Go project imports which");
|
|
3328
|
+
}
|
|
3190
3329
|
}
|
|
3191
3330
|
function addGoApp(workspaceRoot, name, options = {}) {
|
|
3192
3331
|
const cgo = options.cgo === true;
|
|
@@ -3203,7 +3342,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
3203
3342
|
],
|
|
3204
3343
|
workspaceRoot
|
|
3205
3344
|
);
|
|
3206
|
-
addProjectJsonTargets((0,
|
|
3345
|
+
addProjectJsonTargets((0, import_node_path8.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3207
3346
|
build: goBuildTarget(name),
|
|
3208
3347
|
test: goTestTarget(),
|
|
3209
3348
|
lint: goLintTarget(),
|
|
@@ -3238,7 +3377,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
3238
3377
|
],
|
|
3239
3378
|
workspaceRoot
|
|
3240
3379
|
);
|
|
3241
|
-
addProjectJsonTargets((0,
|
|
3380
|
+
addProjectJsonTargets((0, import_node_path8.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3242
3381
|
"build": goBuildTarget(name),
|
|
3243
3382
|
"test": goTestTarget(),
|
|
3244
3383
|
"lint": goLintTarget(),
|
|
@@ -3261,11 +3400,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
3261
3400
|
],
|
|
3262
3401
|
workspaceRoot
|
|
3263
3402
|
);
|
|
3264
|
-
addProjectJsonTargets((0,
|
|
3403
|
+
addProjectJsonTargets((0, import_node_path8.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
3265
3404
|
test: goTestTarget(),
|
|
3266
3405
|
lint: goLintTarget()
|
|
3267
3406
|
});
|
|
3268
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3407
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path8.join)(workspaceRoot, "packages", name), name);
|
|
3269
3408
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3270
3409
|
const module2 = goModulePath(workspaceRoot);
|
|
3271
3410
|
if (module2) {
|
|
@@ -3285,11 +3424,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3285
3424
|
],
|
|
3286
3425
|
workspaceRoot
|
|
3287
3426
|
);
|
|
3288
|
-
addProjectJsonTargets((0,
|
|
3427
|
+
addProjectJsonTargets((0, import_node_path8.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
3289
3428
|
test: goTestTarget(),
|
|
3290
3429
|
lint: goLintTarget()
|
|
3291
3430
|
});
|
|
3292
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3431
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path8.join)(workspaceRoot, "libs", name), name);
|
|
3293
3432
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3294
3433
|
const module2 = goModulePath(workspaceRoot);
|
|
3295
3434
|
if (module2) {
|
|
@@ -3298,7 +3437,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3298
3437
|
}
|
|
3299
3438
|
|
|
3300
3439
|
// src/project-scaffolding/node.use-case.ts
|
|
3301
|
-
var
|
|
3440
|
+
var import_node_path9 = require("path");
|
|
3302
3441
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
3303
3442
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
3304
3443
|
return;
|
|
@@ -3322,12 +3461,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
3322
3461
|
],
|
|
3323
3462
|
workspaceRoot
|
|
3324
3463
|
);
|
|
3325
|
-
const appRoot = (0,
|
|
3464
|
+
const appRoot = (0, import_node_path9.join)(workspaceRoot, "apps", name);
|
|
3326
3465
|
separateDeclarationOutput(appRoot);
|
|
3327
3466
|
repairAssetMapping(appRoot, name);
|
|
3328
3467
|
}
|
|
3329
3468
|
function separateDeclarationOutput(appRoot) {
|
|
3330
|
-
const tsconfigPath = (0,
|
|
3469
|
+
const tsconfigPath = (0, import_node_path9.join)(appRoot, "tsconfig.app.json");
|
|
3331
3470
|
if (!fileExists(tsconfigPath)) {
|
|
3332
3471
|
return;
|
|
3333
3472
|
}
|
|
@@ -3349,7 +3488,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
3349
3488
|
);
|
|
3350
3489
|
}
|
|
3351
3490
|
function repairAssetMapping(appRoot, name) {
|
|
3352
|
-
const manifestPath = (0,
|
|
3491
|
+
const manifestPath = (0, import_node_path9.join)(appRoot, "package.json");
|
|
3353
3492
|
if (!fileExists(manifestPath)) {
|
|
3354
3493
|
return;
|
|
3355
3494
|
}
|
|
@@ -3376,7 +3515,7 @@ function nodeAppPackageTarget(name) {
|
|
|
3376
3515
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
3377
3516
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
3378
3517
|
ensureAdmZip(workspaceRoot);
|
|
3379
|
-
addNxTargets((0,
|
|
3518
|
+
addNxTargets((0, import_node_path9.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
3380
3519
|
package: nodeAppPackageTarget(name)
|
|
3381
3520
|
});
|
|
3382
3521
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -3432,10 +3571,10 @@ describe('buildGreeting', () => {
|
|
|
3432
3571
|
})
|
|
3433
3572
|
`;
|
|
3434
3573
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
3435
|
-
const manifestPath = (0,
|
|
3574
|
+
const manifestPath = (0, import_node_path9.join)(nodeFunctionAppRoot, "package.json");
|
|
3436
3575
|
const manifest = readJson(manifestPath);
|
|
3437
3576
|
const azureFunctionsVersion = readJson(
|
|
3438
|
-
(0,
|
|
3577
|
+
(0, import_node_path9.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
3439
3578
|
).version;
|
|
3440
3579
|
const dependencies = manifest.dependencies ?? {};
|
|
3441
3580
|
writeFileEnsured(
|
|
@@ -3478,21 +3617,21 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
3478
3617
|
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
3479
3618
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
3480
3619
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
3481
|
-
const nodeFunctionAppRoot = (0,
|
|
3482
|
-
writeFileEnsured((0,
|
|
3483
|
-
writeFileEnsured((0,
|
|
3620
|
+
const nodeFunctionAppRoot = (0, import_node_path9.join)(workspaceRoot, "apps", name);
|
|
3621
|
+
writeFileEnsured((0, import_node_path9.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
3622
|
+
writeFileEnsured((0, import_node_path9.join)(nodeFunctionAppRoot, "src/functions/hello.ts"), NODE_FUNCTION_APP_HELLO);
|
|
3484
3623
|
writeFileEnsured(
|
|
3485
|
-
(0,
|
|
3624
|
+
(0, import_node_path9.join)(nodeFunctionAppRoot, "src/functions/greeting.ts"),
|
|
3486
3625
|
NODE_FUNCTION_APP_GREETING
|
|
3487
3626
|
);
|
|
3488
3627
|
writeFileEnsured(
|
|
3489
|
-
(0,
|
|
3628
|
+
(0, import_node_path9.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
3490
3629
|
NODE_FUNCTION_APP_GREETING_SPEC
|
|
3491
3630
|
);
|
|
3492
|
-
writeFileEnsured((0,
|
|
3631
|
+
writeFileEnsured((0, import_node_path9.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
3493
3632
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
3494
3633
|
ensureAdmZip(workspaceRoot);
|
|
3495
|
-
addNxTargets((0,
|
|
3634
|
+
addNxTargets((0, import_node_path9.join)(nodeFunctionAppRoot, "package.json"), {
|
|
3496
3635
|
package: nodeFunctionAppPackageTarget(name),
|
|
3497
3636
|
prune: nodeFunctionAppPruneTarget(name),
|
|
3498
3637
|
start: nodeFunctionAppStartTarget(name)
|
|
@@ -3502,11 +3641,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
3502
3641
|
}
|
|
3503
3642
|
|
|
3504
3643
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3505
|
-
var
|
|
3644
|
+
var import_node_path13 = require("path");
|
|
3506
3645
|
|
|
3507
3646
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
3508
|
-
var
|
|
3509
|
-
var
|
|
3647
|
+
var import_node_fs8 = require("fs");
|
|
3648
|
+
var import_node_path10 = require("path");
|
|
3510
3649
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
3511
3650
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
3512
3651
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -3529,14 +3668,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
3529
3668
|
}
|
|
3530
3669
|
function repairPublishableManifests(workspaceRoot) {
|
|
3531
3670
|
const changed = [];
|
|
3532
|
-
const manifests = (0,
|
|
3671
|
+
const manifests = (0, import_node_fs8.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
3533
3672
|
cwd: workspaceRoot
|
|
3534
3673
|
});
|
|
3535
3674
|
for (const relativePath of manifests) {
|
|
3536
|
-
const manifestPath = (0,
|
|
3537
|
-
const before = (0,
|
|
3675
|
+
const manifestPath = (0, import_node_path10.join)(workspaceRoot, relativePath);
|
|
3676
|
+
const before = (0, import_node_fs8.readFileSync)(manifestPath, "utf8");
|
|
3538
3677
|
repairPublishableManifest(manifestPath);
|
|
3539
|
-
const after = (0,
|
|
3678
|
+
const after = (0, import_node_fs8.readFileSync)(manifestPath, "utf8");
|
|
3540
3679
|
if (after !== before) {
|
|
3541
3680
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
3542
3681
|
}
|
|
@@ -3545,8 +3684,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
3545
3684
|
}
|
|
3546
3685
|
|
|
3547
3686
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3548
|
-
var
|
|
3549
|
-
var
|
|
3687
|
+
var import_node_fs9 = require("fs");
|
|
3688
|
+
var import_node_path11 = require("path");
|
|
3550
3689
|
|
|
3551
3690
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
3552
3691
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -3748,12 +3887,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
3748
3887
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3749
3888
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
3750
3889
|
const changed = [];
|
|
3751
|
-
const configs = (0,
|
|
3890
|
+
const configs = (0, import_node_fs9.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3752
3891
|
cwd: workspaceRoot
|
|
3753
3892
|
});
|
|
3754
3893
|
for (const relativePath of configs) {
|
|
3755
|
-
const configPath = (0,
|
|
3756
|
-
const before = (0,
|
|
3894
|
+
const configPath = (0, import_node_path11.join)(workspaceRoot, relativePath);
|
|
3895
|
+
const before = (0, import_node_fs9.readFileSync)(configPath, "utf8");
|
|
3757
3896
|
const after = withRollupSourceMaps(before);
|
|
3758
3897
|
if (after !== before) {
|
|
3759
3898
|
writeFileEnsured(configPath, after);
|
|
@@ -3764,12 +3903,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
3764
3903
|
}
|
|
3765
3904
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
3766
3905
|
const changed = [];
|
|
3767
|
-
const configs = (0,
|
|
3906
|
+
const configs = (0, import_node_fs9.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3768
3907
|
cwd: workspaceRoot
|
|
3769
3908
|
});
|
|
3770
3909
|
for (const relativePath of configs) {
|
|
3771
|
-
const configPath = (0,
|
|
3772
|
-
const before = (0,
|
|
3910
|
+
const configPath = (0, import_node_path11.join)(workspaceRoot, relativePath);
|
|
3911
|
+
const before = (0, import_node_fs9.readFileSync)(configPath, "utf8");
|
|
3773
3912
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
3774
3913
|
if (after !== before) {
|
|
3775
3914
|
writeFileEnsured(configPath, after);
|
|
@@ -3779,11 +3918,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
3779
3918
|
return changed;
|
|
3780
3919
|
}
|
|
3781
3920
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
3782
|
-
const configPath = (0,
|
|
3921
|
+
const configPath = (0, import_node_path11.join)(projectRoot, "rollup.config.cjs");
|
|
3783
3922
|
if (!fileExists(configPath)) {
|
|
3784
3923
|
return;
|
|
3785
3924
|
}
|
|
3786
|
-
const config = (0,
|
|
3925
|
+
const config = (0, import_node_fs9.readFileSync)(configPath, "utf8");
|
|
3787
3926
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
3788
3927
|
return;
|
|
3789
3928
|
}
|
|
@@ -3792,10 +3931,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
3792
3931
|
}
|
|
3793
3932
|
|
|
3794
3933
|
// src/rollup-library/rollup-config.repository.ts
|
|
3795
|
-
var
|
|
3796
|
-
var
|
|
3934
|
+
var import_node_fs10 = require("fs");
|
|
3935
|
+
var import_node_path12 = require("path");
|
|
3797
3936
|
function resolveRequireTarget(fromDir, specifier) {
|
|
3798
|
-
const base = (0,
|
|
3937
|
+
const base = (0, import_node_path12.join)(fromDir, specifier);
|
|
3799
3938
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
3800
3939
|
}
|
|
3801
3940
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -3805,7 +3944,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3805
3944
|
visited.add(configPath);
|
|
3806
3945
|
let text;
|
|
3807
3946
|
try {
|
|
3808
|
-
text = (0,
|
|
3947
|
+
text = (0, import_node_fs10.readFileSync)(configPath, "utf8");
|
|
3809
3948
|
} catch {
|
|
3810
3949
|
return "";
|
|
3811
3950
|
}
|
|
@@ -3813,15 +3952,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3813
3952
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
3814
3953
|
(match) => match[2]
|
|
3815
3954
|
);
|
|
3816
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
3955
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path12.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
3817
3956
|
return [text, ...requiredText].join("\n");
|
|
3818
3957
|
}
|
|
3819
3958
|
|
|
3820
3959
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3821
3960
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
3822
3961
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
3823
|
-
const projectRoot = (0,
|
|
3824
|
-
const manifestPath = (0,
|
|
3962
|
+
const projectRoot = (0, import_node_path13.join)(workspaceRoot, "packages", name);
|
|
3963
|
+
const manifestPath = (0, import_node_path13.join)(projectRoot, "package.json");
|
|
3825
3964
|
runGeneratorAndRepair(
|
|
3826
3965
|
workspaceRoot,
|
|
3827
3966
|
[
|
|
@@ -3850,8 +3989,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
3850
3989
|
}
|
|
3851
3990
|
|
|
3852
3991
|
// src/project-scaffolding/python.use-case.ts
|
|
3853
|
-
var
|
|
3854
|
-
var
|
|
3992
|
+
var import_node_fs11 = require("fs");
|
|
3993
|
+
var import_node_path14 = require("path");
|
|
3855
3994
|
function ensurePython(workspaceRoot) {
|
|
3856
3995
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
3857
3996
|
if (!hasPython) {
|
|
@@ -3874,7 +4013,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
3874
4013
|
registerPythonGraphPlugin(workspaceRoot);
|
|
3875
4014
|
}
|
|
3876
4015
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
3877
|
-
const nxJsonPath = (0,
|
|
4016
|
+
const nxJsonPath = (0, import_node_path14.join)(workspaceRoot, "nx.json");
|
|
3878
4017
|
if (!fileExists(nxJsonPath)) {
|
|
3879
4018
|
return;
|
|
3880
4019
|
}
|
|
@@ -3897,7 +4036,7 @@ pytest
|
|
|
3897
4036
|
pip-audit
|
|
3898
4037
|
`;
|
|
3899
4038
|
function ensureRequirementsDev(workspaceRoot) {
|
|
3900
|
-
const requirementsDevPath = (0,
|
|
4039
|
+
const requirementsDevPath = (0, import_node_path14.join)(workspaceRoot, "requirements-dev.txt");
|
|
3901
4040
|
if (!fileExists(requirementsDevPath)) {
|
|
3902
4041
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
3903
4042
|
}
|
|
@@ -3957,8 +4096,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
3957
4096
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
3958
4097
|
workspaceRoot
|
|
3959
4098
|
);
|
|
3960
|
-
writeFileEnsured((0,
|
|
3961
|
-
addProjectJsonTargets((0,
|
|
4099
|
+
writeFileEnsured((0, import_node_path14.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
4100
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3962
4101
|
package: pythonAppPackageTarget(name),
|
|
3963
4102
|
start: pythonAppStartTarget(name)
|
|
3964
4103
|
});
|
|
@@ -3980,7 +4119,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
3980
4119
|
workspaceRoot
|
|
3981
4120
|
);
|
|
3982
4121
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
3983
|
-
addProjectJsonTargets((0,
|
|
4122
|
+
addProjectJsonTargets((0, import_node_path14.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3984
4123
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
3985
4124
|
start: pythonFunctionAppStartTarget(name)
|
|
3986
4125
|
});
|
|
@@ -4021,7 +4160,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
4021
4160
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
4022
4161
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
4023
4162
|
return PYTHON_PROJECT_DIRS.find(
|
|
4024
|
-
(directory) => fileExists((0,
|
|
4163
|
+
(directory) => fileExists((0, import_node_path14.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
4025
4164
|
);
|
|
4026
4165
|
}
|
|
4027
4166
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -4060,7 +4199,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4060
4199
|
`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.`
|
|
4061
4200
|
);
|
|
4062
4201
|
}
|
|
4063
|
-
if (!fileExists((0,
|
|
4202
|
+
if (!fileExists((0, import_node_path14.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
4064
4203
|
throw new Error(
|
|
4065
4204
|
`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.`
|
|
4066
4205
|
);
|
|
@@ -4068,8 +4207,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4068
4207
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
4069
4208
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
4070
4209
|
}
|
|
4071
|
-
const pyprojectPath = (0,
|
|
4072
|
-
const pyprojectToml = (0,
|
|
4210
|
+
const pyprojectPath = (0, import_node_path14.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
4211
|
+
const pyprojectToml = (0, import_node_fs11.readFileSync)(pyprojectPath, "utf8");
|
|
4073
4212
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
4074
4213
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
4075
4214
|
return;
|
|
@@ -4081,8 +4220,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4081
4220
|
}
|
|
4082
4221
|
|
|
4083
4222
|
// src/project-scaffolding/react-app.use-case.ts
|
|
4084
|
-
var
|
|
4085
|
-
var
|
|
4223
|
+
var import_node_fs12 = require("fs");
|
|
4224
|
+
var import_node_path15 = require("path");
|
|
4086
4225
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
4087
4226
|
function reactEnvironmentFile(environment) {
|
|
4088
4227
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -4119,12 +4258,12 @@ function reactAppTargets(name) {
|
|
|
4119
4258
|
return targets;
|
|
4120
4259
|
}
|
|
4121
4260
|
function allowEnvFiles(workspaceRoot) {
|
|
4122
|
-
const gitignorePath = (0,
|
|
4261
|
+
const gitignorePath = (0, import_node_path15.join)(workspaceRoot, ".gitignore");
|
|
4123
4262
|
if (!fileExists(gitignorePath)) {
|
|
4124
4263
|
return;
|
|
4125
4264
|
}
|
|
4126
4265
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
4127
|
-
const current = (0,
|
|
4266
|
+
const current = (0, import_node_fs12.readFileSync)(gitignorePath, "utf8");
|
|
4128
4267
|
if (current.includes(marker)) {
|
|
4129
4268
|
return;
|
|
4130
4269
|
}
|
|
@@ -4151,24 +4290,24 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4151
4290
|
workspaceRoot
|
|
4152
4291
|
);
|
|
4153
4292
|
ensureAdmZip(workspaceRoot);
|
|
4154
|
-
const reactAppRoot = (0,
|
|
4293
|
+
const reactAppRoot = (0, import_node_path15.join)(workspaceRoot, "apps", name);
|
|
4155
4294
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
4156
|
-
writeFileEnsured((0,
|
|
4295
|
+
writeFileEnsured((0, import_node_path15.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
4157
4296
|
}
|
|
4158
4297
|
allowEnvFiles(workspaceRoot);
|
|
4159
|
-
addNxTargets((0,
|
|
4298
|
+
addNxTargets((0, import_node_path15.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4160
4299
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4161
4300
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4162
4301
|
}
|
|
4163
4302
|
|
|
4164
4303
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
4165
|
-
var
|
|
4304
|
+
var import_node_path16 = require("path");
|
|
4166
4305
|
var REACT_LIB_BUNDLER = "rollup";
|
|
4167
4306
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4168
4307
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4169
4308
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4170
|
-
const projectRoot = (0,
|
|
4171
|
-
const publishableManifest = (0,
|
|
4309
|
+
const projectRoot = (0, import_node_path16.join)(workspaceRoot, "packages", name);
|
|
4310
|
+
const publishableManifest = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4172
4311
|
runGeneratorAndRepair(
|
|
4173
4312
|
workspaceRoot,
|
|
4174
4313
|
[
|
|
@@ -4197,8 +4336,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4197
4336
|
}
|
|
4198
4337
|
function addReactInternalLib(workspaceRoot, name, stack) {
|
|
4199
4338
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
4200
|
-
const projectRoot = (0,
|
|
4201
|
-
const privateManifest = (0,
|
|
4339
|
+
const projectRoot = (0, import_node_path16.join)(workspaceRoot, "libs", name);
|
|
4340
|
+
const privateManifest = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4202
4341
|
runGeneratorAndRepair(
|
|
4203
4342
|
workspaceRoot,
|
|
4204
4343
|
[
|
|
@@ -4224,8 +4363,8 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
4224
4363
|
}
|
|
4225
4364
|
|
|
4226
4365
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
4227
|
-
var
|
|
4228
|
-
var
|
|
4366
|
+
var import_node_fs13 = require("fs");
|
|
4367
|
+
var import_node_path17 = require("path");
|
|
4229
4368
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
4230
4369
|
var VSCODE_SIDECAR_TARGETS = {
|
|
4231
4370
|
"win32-x64": "windows-amd64",
|
|
@@ -4409,8 +4548,8 @@ export const window = {
|
|
|
4409
4548
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
4410
4549
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
4411
4550
|
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}\` },`];
|
|
4412
|
-
const path = (0,
|
|
4413
|
-
const content = fileExists(path) ? (0,
|
|
4551
|
+
const path = (0, import_node_path17.join)(projectRoot, file);
|
|
4552
|
+
const content = fileExists(path) ? (0, import_node_fs13.readFileSync)(path, "utf8") : "";
|
|
4414
4553
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
4415
4554
|
if (line === void 0) {
|
|
4416
4555
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -4430,11 +4569,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
4430
4569
|
}
|
|
4431
4570
|
}
|
|
4432
4571
|
function defaultPublisher(workspaceRoot) {
|
|
4433
|
-
const { name } = readJson((0,
|
|
4572
|
+
const { name } = readJson((0, import_node_path17.join)(workspaceRoot, "package.json"));
|
|
4434
4573
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4435
4574
|
}
|
|
4436
4575
|
function reshapeManifest(projectRoot, name, publisher, typesVersion) {
|
|
4437
|
-
const manifestPath = (0,
|
|
4576
|
+
const manifestPath = (0, import_node_path17.join)(projectRoot, "package.json");
|
|
4438
4577
|
const manifest = readJson(manifestPath);
|
|
4439
4578
|
const { nx = {}, ...rest } = manifest;
|
|
4440
4579
|
const targets = { ...nx.targets };
|
|
@@ -4498,11 +4637,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
4498
4637
|
};
|
|
4499
4638
|
}
|
|
4500
4639
|
function addDebugLaunch(workspaceRoot, name) {
|
|
4501
|
-
const file = (0,
|
|
4640
|
+
const file = (0, import_node_fs13.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4502
4641
|
if (file === void 0) {
|
|
4503
4642
|
return;
|
|
4504
4643
|
}
|
|
4505
|
-
const path = (0,
|
|
4644
|
+
const path = (0, import_node_path17.join)(workspaceRoot, file);
|
|
4506
4645
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
4507
4646
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4508
4647
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -4535,39 +4674,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
4535
4674
|
);
|
|
4536
4675
|
}
|
|
4537
4676
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4538
|
-
const apps = (0,
|
|
4677
|
+
const apps = (0, import_node_path17.join)(workspaceRoot, "apps");
|
|
4539
4678
|
let entries;
|
|
4540
4679
|
try {
|
|
4541
|
-
entries = (0,
|
|
4680
|
+
entries = (0, import_node_fs13.readdirSync)(apps);
|
|
4542
4681
|
} catch {
|
|
4543
4682
|
return false;
|
|
4544
4683
|
}
|
|
4545
4684
|
const hasExtension = entries.some((entry) => {
|
|
4546
|
-
const manifestPath = (0,
|
|
4685
|
+
const manifestPath = (0, import_node_path17.join)(apps, entry, "package.json");
|
|
4547
4686
|
if (!fileExists(manifestPath)) {
|
|
4548
4687
|
return false;
|
|
4549
4688
|
}
|
|
4550
4689
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4551
4690
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4552
4691
|
});
|
|
4553
|
-
const path = (0,
|
|
4554
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
4692
|
+
const path = (0, import_node_path17.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
4693
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs13.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
4555
4694
|
return false;
|
|
4556
4695
|
}
|
|
4557
4696
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4558
4697
|
return true;
|
|
4559
4698
|
}
|
|
4560
4699
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
4561
|
-
const apps = (0,
|
|
4700
|
+
const apps = (0, import_node_path17.join)(workspaceRoot, "apps");
|
|
4562
4701
|
let entries;
|
|
4563
4702
|
try {
|
|
4564
|
-
entries = (0,
|
|
4703
|
+
entries = (0, import_node_fs13.readdirSync)(apps);
|
|
4565
4704
|
} catch {
|
|
4566
4705
|
return [];
|
|
4567
4706
|
}
|
|
4568
4707
|
const updated = [];
|
|
4569
4708
|
for (const entry of entries) {
|
|
4570
|
-
const manifestPath = (0,
|
|
4709
|
+
const manifestPath = (0, import_node_path17.join)(apps, entry, "package.json");
|
|
4571
4710
|
if (!fileExists(manifestPath)) {
|
|
4572
4711
|
continue;
|
|
4573
4712
|
}
|
|
@@ -4587,23 +4726,23 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
4587
4726
|
}
|
|
4588
4727
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4589
4728
|
const { sidecar } = options;
|
|
4590
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
4729
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path17.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4591
4730
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4592
4731
|
}
|
|
4593
4732
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4594
4733
|
ensureVscodeToolchain(workspaceRoot);
|
|
4595
|
-
const projectRoot = (0,
|
|
4596
|
-
const typesVersion = readJson((0,
|
|
4734
|
+
const projectRoot = (0, import_node_path17.join)(workspaceRoot, "apps", name);
|
|
4735
|
+
const typesVersion = readJson((0, import_node_path17.join)(workspaceRoot, "node_modules/@types/vscode/package.json")).version;
|
|
4597
4736
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot), typesVersion);
|
|
4598
|
-
addVscodeTypes((0,
|
|
4599
|
-
addVscodeTypes((0,
|
|
4600
|
-
writeFileEnsured((0,
|
|
4601
|
-
writeFileEnsured((0,
|
|
4602
|
-
writeFileEnsured((0,
|
|
4737
|
+
addVscodeTypes((0, import_node_path17.join)(projectRoot, "tsconfig.app.json"));
|
|
4738
|
+
addVscodeTypes((0, import_node_path17.join)(projectRoot, "tsconfig.spec.json"));
|
|
4739
|
+
writeFileEnsured((0, import_node_path17.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
4740
|
+
writeFileEnsured((0, import_node_path17.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
4741
|
+
writeFileEnsured((0, import_node_path17.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
4603
4742
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4604
|
-
writeFileEnsured((0,
|
|
4605
|
-
writeFileEnsured((0,
|
|
4606
|
-
addNxTargets((0,
|
|
4743
|
+
writeFileEnsured((0, import_node_path17.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
4744
|
+
writeFileEnsured((0, import_node_path17.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
4745
|
+
addNxTargets((0, import_node_path17.join)(projectRoot, "package.json"), {
|
|
4607
4746
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
4608
4747
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
4609
4748
|
});
|
|
@@ -4614,11 +4753,11 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
4614
4753
|
}
|
|
4615
4754
|
|
|
4616
4755
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
4617
|
-
var
|
|
4756
|
+
var import_node_path19 = require("path");
|
|
4618
4757
|
|
|
4619
4758
|
// src/dependency-management/manifest.repository.ts
|
|
4620
|
-
var
|
|
4621
|
-
var
|
|
4759
|
+
var import_node_fs14 = require("fs");
|
|
4760
|
+
var import_node_path18 = require("path");
|
|
4622
4761
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
4623
4762
|
var ROOT_LABEL = "(root)";
|
|
4624
4763
|
var MANIFEST_GLOBS = {
|
|
@@ -4651,23 +4790,23 @@ function projectOf(manifestRelativePath) {
|
|
|
4651
4790
|
}
|
|
4652
4791
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
4653
4792
|
if (ecosystem === "go") {
|
|
4654
|
-
return fileExists((0,
|
|
4793
|
+
return fileExists((0, import_node_path18.join)(workspaceRoot, "go.mod"));
|
|
4655
4794
|
}
|
|
4656
4795
|
if (ecosystem === "nuget") {
|
|
4657
|
-
return (0,
|
|
4796
|
+
return (0, import_node_fs14.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
4658
4797
|
}
|
|
4659
4798
|
const rootMarker = {
|
|
4660
4799
|
npm: "package.json",
|
|
4661
4800
|
pip: "requirements-dev.txt",
|
|
4662
4801
|
pub: "pubspec.yaml"
|
|
4663
4802
|
};
|
|
4664
|
-
return fileExists((0,
|
|
4803
|
+
return fileExists((0, import_node_path18.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs14.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
4665
4804
|
}
|
|
4666
4805
|
function collectNpm(workspaceRoot) {
|
|
4667
4806
|
const sites = [];
|
|
4668
|
-
const relativePaths = ["package.json", ...(0,
|
|
4807
|
+
const relativePaths = ["package.json", ...(0, import_node_fs14.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
4669
4808
|
for (const relativePath of relativePaths) {
|
|
4670
|
-
const manifestPath = (0,
|
|
4809
|
+
const manifestPath = (0, import_node_path18.join)(workspaceRoot, relativePath);
|
|
4671
4810
|
try {
|
|
4672
4811
|
const manifest = readJson(manifestPath);
|
|
4673
4812
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -4728,17 +4867,17 @@ function collectPip(workspaceRoot) {
|
|
|
4728
4867
|
name: parsed.name,
|
|
4729
4868
|
ecosystem: "pip",
|
|
4730
4869
|
project: projectOf(relativePath),
|
|
4731
|
-
manifestPath: (0,
|
|
4870
|
+
manifestPath: (0, import_node_path18.join)(workspaceRoot, relativePath),
|
|
4732
4871
|
section,
|
|
4733
4872
|
spec: parsed.spec,
|
|
4734
4873
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
4735
4874
|
});
|
|
4736
4875
|
};
|
|
4737
|
-
const pyprojectPaths = (0,
|
|
4876
|
+
const pyprojectPaths = (0, import_node_fs14.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
4738
4877
|
for (const relativePath of pyprojectPaths) {
|
|
4739
4878
|
let content;
|
|
4740
4879
|
try {
|
|
4741
|
-
content = (0,
|
|
4880
|
+
content = (0, import_node_fs14.readFileSync)((0, import_node_path18.join)(workspaceRoot, relativePath), "utf8");
|
|
4742
4881
|
} catch {
|
|
4743
4882
|
continue;
|
|
4744
4883
|
}
|
|
@@ -4749,14 +4888,14 @@ function collectPip(workspaceRoot) {
|
|
|
4749
4888
|
}
|
|
4750
4889
|
const requirementsPaths = [
|
|
4751
4890
|
"requirements-dev.txt",
|
|
4752
|
-
...(0,
|
|
4891
|
+
...(0, import_node_fs14.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
4753
4892
|
];
|
|
4754
4893
|
for (const relativePath of requirementsPaths) {
|
|
4755
|
-
if (!fileExists((0,
|
|
4894
|
+
if (!fileExists((0, import_node_path18.join)(workspaceRoot, relativePath))) {
|
|
4756
4895
|
continue;
|
|
4757
4896
|
}
|
|
4758
4897
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
4759
|
-
const lines = (0,
|
|
4898
|
+
const lines = (0, import_node_fs14.readFileSync)((0, import_node_path18.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
4760
4899
|
for (const line of lines) {
|
|
4761
4900
|
push(relativePath, section, line);
|
|
4762
4901
|
}
|
|
@@ -4794,11 +4933,11 @@ function pyprojectDependencies(content) {
|
|
|
4794
4933
|
}
|
|
4795
4934
|
function collectPub(workspaceRoot) {
|
|
4796
4935
|
const sites = [];
|
|
4797
|
-
const pubspecPaths = (0,
|
|
4936
|
+
const pubspecPaths = (0, import_node_fs14.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
4798
4937
|
for (const relativePath of pubspecPaths) {
|
|
4799
4938
|
let content;
|
|
4800
4939
|
try {
|
|
4801
|
-
content = (0,
|
|
4940
|
+
content = (0, import_node_fs14.readFileSync)((0, import_node_path18.join)(workspaceRoot, relativePath), "utf8");
|
|
4802
4941
|
} catch {
|
|
4803
4942
|
continue;
|
|
4804
4943
|
}
|
|
@@ -4808,7 +4947,7 @@ function collectPub(workspaceRoot) {
|
|
|
4808
4947
|
name: entry.name,
|
|
4809
4948
|
ecosystem: "pub",
|
|
4810
4949
|
project: projectOf(relativePath),
|
|
4811
|
-
manifestPath: (0,
|
|
4950
|
+
manifestPath: (0, import_node_path18.join)(workspaceRoot, relativePath),
|
|
4812
4951
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
4813
4952
|
spec: entry.spec,
|
|
4814
4953
|
rewritable: entry.spec !== ""
|
|
@@ -4858,11 +4997,11 @@ function stripQuotes(value) {
|
|
|
4858
4997
|
}
|
|
4859
4998
|
function collectNuget(workspaceRoot) {
|
|
4860
4999
|
const sites = [];
|
|
4861
|
-
const csprojPaths = (0,
|
|
5000
|
+
const csprojPaths = (0, import_node_fs14.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
4862
5001
|
for (const relativePath of csprojPaths) {
|
|
4863
5002
|
let content;
|
|
4864
5003
|
try {
|
|
4865
|
-
content = (0,
|
|
5004
|
+
content = (0, import_node_fs14.readFileSync)((0, import_node_path18.join)(workspaceRoot, relativePath), "utf8");
|
|
4866
5005
|
} catch {
|
|
4867
5006
|
continue;
|
|
4868
5007
|
}
|
|
@@ -4871,7 +5010,7 @@ function collectNuget(workspaceRoot) {
|
|
|
4871
5010
|
name: entry.name,
|
|
4872
5011
|
ecosystem: "nuget",
|
|
4873
5012
|
project: projectOf(relativePath),
|
|
4874
|
-
manifestPath: (0,
|
|
5013
|
+
manifestPath: (0, import_node_path18.join)(workspaceRoot, relativePath),
|
|
4875
5014
|
section: "dep",
|
|
4876
5015
|
spec: entry.spec,
|
|
4877
5016
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -4896,13 +5035,13 @@ function csprojPackageReferences(content) {
|
|
|
4896
5035
|
return entries;
|
|
4897
5036
|
}
|
|
4898
5037
|
function collectGo(workspaceRoot) {
|
|
4899
|
-
const manifestPath = (0,
|
|
5038
|
+
const manifestPath = (0, import_node_path18.join)(workspaceRoot, "go.mod");
|
|
4900
5039
|
if (!fileExists(manifestPath)) {
|
|
4901
5040
|
return [];
|
|
4902
5041
|
}
|
|
4903
5042
|
let content;
|
|
4904
5043
|
try {
|
|
4905
|
-
content = (0,
|
|
5044
|
+
content = (0, import_node_fs14.readFileSync)(manifestPath, "utf8");
|
|
4906
5045
|
} catch {
|
|
4907
5046
|
return [];
|
|
4908
5047
|
}
|
|
@@ -4959,7 +5098,7 @@ function rewriteSpec(site, spec) {
|
|
|
4959
5098
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
4960
5099
|
return true;
|
|
4961
5100
|
}
|
|
4962
|
-
const before = (0,
|
|
5101
|
+
const before = (0, import_node_fs14.readFileSync)(site.manifestPath, "utf8");
|
|
4963
5102
|
const after = (() => {
|
|
4964
5103
|
switch (site.ecosystem) {
|
|
4965
5104
|
case "pip": {
|
|
@@ -5015,13 +5154,13 @@ function escapeForRegex(value) {
|
|
|
5015
5154
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
5016
5155
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
5017
5156
|
return ["apps", "libs", "packages"].some(
|
|
5018
|
-
(directory) => fileExists((0,
|
|
5157
|
+
(directory) => fileExists((0, import_node_path18.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
5019
5158
|
);
|
|
5020
5159
|
}
|
|
5021
5160
|
function isAliasedInstall(workspaceRoot, name) {
|
|
5022
5161
|
try {
|
|
5023
5162
|
const installed = readJson(
|
|
5024
|
-
(0,
|
|
5163
|
+
(0, import_node_path18.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5025
5164
|
);
|
|
5026
5165
|
return installed.name !== void 0 && installed.name !== name;
|
|
5027
5166
|
} catch {
|
|
@@ -5032,14 +5171,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5032
5171
|
if (ecosystem === "npm") {
|
|
5033
5172
|
try {
|
|
5034
5173
|
return readJson(
|
|
5035
|
-
(0,
|
|
5174
|
+
(0, import_node_path18.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
5036
5175
|
).version;
|
|
5037
5176
|
} catch {
|
|
5038
5177
|
return void 0;
|
|
5039
5178
|
}
|
|
5040
5179
|
}
|
|
5041
5180
|
if (ecosystem === "pub") {
|
|
5042
|
-
const lockPath = (0,
|
|
5181
|
+
const lockPath = (0, import_node_path18.join)(workspaceRoot, "pubspec.lock");
|
|
5043
5182
|
if (!fileExists(lockPath)) {
|
|
5044
5183
|
return void 0;
|
|
5045
5184
|
}
|
|
@@ -5047,7 +5186,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
5047
5186
|
const match = new RegExp(
|
|
5048
5187
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
5049
5188
|
"m"
|
|
5050
|
-
).exec((0,
|
|
5189
|
+
).exec((0, import_node_fs14.readFileSync)(lockPath, "utf8"));
|
|
5051
5190
|
return match?.[1];
|
|
5052
5191
|
} catch {
|
|
5053
5192
|
return void 0;
|
|
@@ -5239,7 +5378,7 @@ function describe(finding) {
|
|
|
5239
5378
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
5240
5379
|
}
|
|
5241
5380
|
function runSync(workspaceRoot, options) {
|
|
5242
|
-
if (!fileExists((0,
|
|
5381
|
+
if (!fileExists((0, import_node_path19.join)(workspaceRoot, "nx.json"))) {
|
|
5243
5382
|
throw new Error(
|
|
5244
5383
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
5245
5384
|
);
|
|
@@ -5289,7 +5428,7 @@ function runSync(workspaceRoot, options) {
|
|
|
5289
5428
|
}
|
|
5290
5429
|
|
|
5291
5430
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
5292
|
-
var
|
|
5431
|
+
var import_node_path20 = require("path");
|
|
5293
5432
|
var import_prompts2 = require("@inquirer/prompts");
|
|
5294
5433
|
|
|
5295
5434
|
// src/dependency-management/registry.client.ts
|
|
@@ -5572,7 +5711,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
5572
5711
|
function hasPythonInstallScript(workspaceRoot) {
|
|
5573
5712
|
try {
|
|
5574
5713
|
const manifest = readJson(
|
|
5575
|
-
(0,
|
|
5714
|
+
(0, import_node_path20.join)(workspaceRoot, "package.json")
|
|
5576
5715
|
);
|
|
5577
5716
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
5578
5717
|
} catch {
|
|
@@ -5588,7 +5727,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
5588
5727
|
}
|
|
5589
5728
|
}
|
|
5590
5729
|
async function runUp(workspaceRoot, options) {
|
|
5591
|
-
if (!fileExists((0,
|
|
5730
|
+
if (!fileExists((0, import_node_path20.join)(workspaceRoot, "nx.json"))) {
|
|
5592
5731
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
5593
5732
|
}
|
|
5594
5733
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -5664,7 +5803,7 @@ var PROJECT_KINDS = [
|
|
|
5664
5803
|
];
|
|
5665
5804
|
async function runAdd(kind, name, options) {
|
|
5666
5805
|
const workspaceRoot = process.cwd();
|
|
5667
|
-
if (!fileExists((0,
|
|
5806
|
+
if (!fileExists((0, import_node_path21.join)(workspaceRoot, "nx.json"))) {
|
|
5668
5807
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
5669
5808
|
}
|
|
5670
5809
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -5720,8 +5859,8 @@ async function runAdd(kind, name, options) {
|
|
|
5720
5859
|
],
|
|
5721
5860
|
workspaceRoot
|
|
5722
5861
|
);
|
|
5723
|
-
markPrivate((0,
|
|
5724
|
-
renameScaffoldPlaceholder((0,
|
|
5862
|
+
markPrivate((0, import_node_path21.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
5863
|
+
renameScaffoldPlaceholder((0, import_node_path21.join)(workspaceRoot, "libs", resolvedName), resolvedName);
|
|
5725
5864
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
5726
5865
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
5727
5866
|
break;
|
|
@@ -5813,7 +5952,7 @@ async function runAdd(kind, name, options) {
|
|
|
5813
5952
|
}
|
|
5814
5953
|
function readWorkspaceStack(workspaceRoot) {
|
|
5815
5954
|
const nxJson = readJson(
|
|
5816
|
-
(0,
|
|
5955
|
+
(0, import_node_path21.join)(workspaceRoot, "nx.json")
|
|
5817
5956
|
);
|
|
5818
5957
|
const stack = nxJson.mnci?.stack;
|
|
5819
5958
|
return {
|
|
@@ -5823,15 +5962,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
5823
5962
|
|
|
5824
5963
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
5825
5964
|
var import_node_child_process = require("child_process");
|
|
5826
|
-
var
|
|
5827
|
-
var
|
|
5965
|
+
var import_node_fs15 = require("fs");
|
|
5966
|
+
var import_node_path22 = require("path");
|
|
5828
5967
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
5829
5968
|
function toPosix2(path) {
|
|
5830
5969
|
return path.replaceAll("\\", "/");
|
|
5831
5970
|
}
|
|
5832
5971
|
function checkEslintConfigs(workspaceRoot) {
|
|
5833
|
-
const rootConfigs = (0,
|
|
5834
|
-
const projectConfigs = (0,
|
|
5972
|
+
const rootConfigs = (0, import_node_fs15.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
5973
|
+
const projectConfigs = (0, import_node_fs15.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
5835
5974
|
cwd: workspaceRoot
|
|
5836
5975
|
}).map((config) => toPosix2(config));
|
|
5837
5976
|
return [
|
|
@@ -5851,10 +5990,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
5851
5990
|
];
|
|
5852
5991
|
}
|
|
5853
5992
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
5854
|
-
const rules = (0,
|
|
5855
|
-
if (!(0,
|
|
5856
|
-
const entryPoint = (0,
|
|
5857
|
-
const source = (0,
|
|
5993
|
+
const rules = (0, import_node_path22.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
5994
|
+
if (!(0, import_node_fs15.existsSync)(rules)) return [];
|
|
5995
|
+
const entryPoint = (0, import_node_path22.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
5996
|
+
const source = (0, import_node_fs15.existsSync)(entryPoint) ? (0, import_node_fs15.readFileSync)(entryPoint, "utf8") : "";
|
|
5858
5997
|
return [
|
|
5859
5998
|
{
|
|
5860
5999
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -5867,7 +6006,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
5867
6006
|
function declaredDevDependencies(workspaceRoot) {
|
|
5868
6007
|
try {
|
|
5869
6008
|
const manifest = readJson(
|
|
5870
|
-
(0,
|
|
6009
|
+
(0, import_node_path22.join)(workspaceRoot, "package.json")
|
|
5871
6010
|
);
|
|
5872
6011
|
return manifest.devDependencies ?? {};
|
|
5873
6012
|
} catch {
|
|
@@ -5875,7 +6014,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
5875
6014
|
}
|
|
5876
6015
|
}
|
|
5877
6016
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
5878
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
6017
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path22.join)(workspaceRoot, file)));
|
|
5879
6018
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
5880
6019
|
const stale = [...files, ...declared];
|
|
5881
6020
|
if (stale.length === 0) {
|
|
@@ -5901,7 +6040,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
5901
6040
|
};
|
|
5902
6041
|
}
|
|
5903
6042
|
function checkResolvedEslint(workspaceRoot) {
|
|
5904
|
-
const manifestPath = (0,
|
|
6043
|
+
const manifestPath = (0, import_node_path22.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
5905
6044
|
if (!fileExists(manifestPath)) {
|
|
5906
6045
|
return void 0;
|
|
5907
6046
|
}
|
|
@@ -5919,11 +6058,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
5919
6058
|
}
|
|
5920
6059
|
}
|
|
5921
6060
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
5922
|
-
const npmrcPath = (0,
|
|
6061
|
+
const npmrcPath = (0, import_node_path22.join)(workspaceRoot, ".npmrc");
|
|
5923
6062
|
if (!registry || !fileExists(npmrcPath)) {
|
|
5924
6063
|
return void 0;
|
|
5925
6064
|
}
|
|
5926
|
-
const npmrc = (0,
|
|
6065
|
+
const npmrc = (0, import_node_fs15.readFileSync)(npmrcPath, "utf8");
|
|
5927
6066
|
if (registry.kind === "npm") {
|
|
5928
6067
|
return {
|
|
5929
6068
|
check: ".npmrc authenticates the public registry",
|
|
@@ -5940,11 +6079,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
5940
6079
|
};
|
|
5941
6080
|
}
|
|
5942
6081
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
5943
|
-
const npmrcPath = (0,
|
|
6082
|
+
const npmrcPath = (0, import_node_path22.join)(workspaceRoot, ".npmrc");
|
|
5944
6083
|
if (!fileExists(npmrcPath)) {
|
|
5945
6084
|
return void 0;
|
|
5946
6085
|
}
|
|
5947
|
-
const npmrc = (0,
|
|
6086
|
+
const npmrc = (0, import_node_fs15.readFileSync)(npmrcPath, "utf8");
|
|
5948
6087
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5949
6088
|
const referenced = [
|
|
5950
6089
|
...new Set(
|
|
@@ -5968,13 +6107,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
5968
6107
|
};
|
|
5969
6108
|
}
|
|
5970
6109
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
5971
|
-
const npmrcPath = (0,
|
|
5972
|
-
const pipelinePath = (0,
|
|
6110
|
+
const npmrcPath = (0, import_node_path22.join)(workspaceRoot, ".npmrc");
|
|
6111
|
+
const pipelinePath = (0, import_node_path22.join)(workspaceRoot, "azure-pipelines.yml");
|
|
5973
6112
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
5974
6113
|
return void 0;
|
|
5975
6114
|
}
|
|
5976
|
-
const holdsCredentials = (0,
|
|
5977
|
-
const runsTask = (0,
|
|
6115
|
+
const holdsCredentials = (0, import_node_fs15.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
6116
|
+
const runsTask = (0, import_node_fs15.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
5978
6117
|
if (!holdsCredentials && !runsTask) {
|
|
5979
6118
|
return {
|
|
5980
6119
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -6019,13 +6158,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
6019
6158
|
}
|
|
6020
6159
|
function checkVersionActions(workspaceRoot) {
|
|
6021
6160
|
const candidates = [
|
|
6022
|
-
...(0,
|
|
6023
|
-
...(0,
|
|
6024
|
-
...(0,
|
|
6161
|
+
...(0, import_node_fs15.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
6162
|
+
...(0, import_node_fs15.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
6163
|
+
...(0, import_node_fs15.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
6025
6164
|
].map((manifest) => toPosix2(manifest));
|
|
6026
6165
|
return candidates.flatMap((manifest) => {
|
|
6027
6166
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
6028
|
-
const projectJsonPath = (0,
|
|
6167
|
+
const projectJsonPath = (0, import_node_path22.join)(workspaceRoot, projectRoot, "project.json");
|
|
6029
6168
|
let hasOverride = false;
|
|
6030
6169
|
try {
|
|
6031
6170
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -6054,7 +6193,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6054
6193
|
]) {
|
|
6055
6194
|
try {
|
|
6056
6195
|
const targets = extract(
|
|
6057
|
-
readJson((0,
|
|
6196
|
+
readJson((0, import_node_path22.join)(workspaceRoot, projectRoot, file))
|
|
6058
6197
|
);
|
|
6059
6198
|
if (targets && typeof targets === "object") {
|
|
6060
6199
|
sources.push({
|
|
@@ -6070,8 +6209,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
6070
6209
|
function checkTargetFilesExist(workspaceRoot) {
|
|
6071
6210
|
const projectRoots = new Set(
|
|
6072
6211
|
[
|
|
6073
|
-
...(0,
|
|
6074
|
-
...(0,
|
|
6212
|
+
...(0, import_node_fs15.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
6213
|
+
...(0, import_node_fs15.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
6075
6214
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
6076
6215
|
);
|
|
6077
6216
|
return [...projectRoots].flatMap(
|
|
@@ -6086,7 +6225,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
6086
6225
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
6087
6226
|
const value = target?.options?.[option];
|
|
6088
6227
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
6089
|
-
if (!checkable || fileExists((0,
|
|
6228
|
+
if (!checkable || fileExists((0, import_node_path22.join)(workspaceRoot, value))) {
|
|
6090
6229
|
return [];
|
|
6091
6230
|
}
|
|
6092
6231
|
return [
|
|
@@ -6111,6 +6250,17 @@ function hasCCompiler() {
|
|
|
6111
6250
|
const candidates = [process.env.CC?.split(" ", 1)[0], "gcc", "clang", "cc"];
|
|
6112
6251
|
return candidates.some((command) => command !== void 0 && command !== "" && (0, import_node_child_process.spawnSync)(command, ["--version"], { stdio: "ignore" }).status === 0);
|
|
6113
6252
|
}
|
|
6253
|
+
function checkGoPluginRegistered(workspaceRoot) {
|
|
6254
|
+
if (!hasGoProject(workspaceRoot)) {
|
|
6255
|
+
return void 0;
|
|
6256
|
+
}
|
|
6257
|
+
return {
|
|
6258
|
+
check: `${NX_GO_PLUGIN} is registered in nx.json, so Nx knows which Go project imports which`,
|
|
6259
|
+
ok: isNxGoPluginRegistered(workspaceRoot),
|
|
6260
|
+
detail: `${NX_GO_PLUGIN} is not in nx.json plugins: the project graph has no Go edge, so \`nx affected\` skips an app that imports a changed library`,
|
|
6261
|
+
remedy: "run `mnci upgrade`"
|
|
6262
|
+
};
|
|
6263
|
+
}
|
|
6114
6264
|
function checkNativeApps(workspaceRoot) {
|
|
6115
6265
|
if (!hasNativeGoApp(workspaceRoot)) {
|
|
6116
6266
|
return [];
|
|
@@ -6119,9 +6269,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6119
6269
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
6120
6270
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
6121
6271
|
];
|
|
6122
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
6272
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path22.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
6123
6273
|
check: `${file} builds the native apps on every OS`,
|
|
6124
|
-
ok: (0,
|
|
6274
|
+
ok: (0, import_node_fs15.readFileSync)((0, import_node_path22.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
6125
6275
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
6126
6276
|
remedy: "run `mnci upgrade`"
|
|
6127
6277
|
}));
|
|
@@ -6134,7 +6284,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
6134
6284
|
return findings;
|
|
6135
6285
|
}
|
|
6136
6286
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
6137
|
-
const manifestPath = (0,
|
|
6287
|
+
const manifestPath = (0, import_node_path22.join)(workspaceRoot, "package.json");
|
|
6138
6288
|
if (!fileExists(manifestPath)) {
|
|
6139
6289
|
return void 0;
|
|
6140
6290
|
}
|
|
@@ -6154,14 +6304,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
6154
6304
|
};
|
|
6155
6305
|
}
|
|
6156
6306
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
6157
|
-
const configs = (0,
|
|
6307
|
+
const configs = (0, import_node_fs15.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6158
6308
|
cwd: workspaceRoot
|
|
6159
6309
|
}).map((config) => toPosix2(config));
|
|
6160
6310
|
return configs.flatMap((relativePath) => {
|
|
6161
|
-
const configPath = (0,
|
|
6311
|
+
const configPath = (0, import_node_path22.join)(workspaceRoot, relativePath);
|
|
6162
6312
|
let config;
|
|
6163
6313
|
try {
|
|
6164
|
-
config = (0,
|
|
6314
|
+
config = (0, import_node_fs15.readFileSync)(configPath, "utf8");
|
|
6165
6315
|
} catch {
|
|
6166
6316
|
return [];
|
|
6167
6317
|
}
|
|
@@ -6176,11 +6326,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
6176
6326
|
});
|
|
6177
6327
|
}
|
|
6178
6328
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
6179
|
-
const configs = (0,
|
|
6329
|
+
const configs = (0, import_node_fs15.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
6180
6330
|
cwd: workspaceRoot
|
|
6181
6331
|
}).map((config) => toPosix2(config));
|
|
6182
6332
|
return configs.flatMap((relativePath) => {
|
|
6183
|
-
const configPath = (0,
|
|
6333
|
+
const configPath = (0, import_node_path22.join)(workspaceRoot, relativePath);
|
|
6184
6334
|
if (!fileExists(configPath)) {
|
|
6185
6335
|
return [];
|
|
6186
6336
|
}
|
|
@@ -6214,7 +6364,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
6214
6364
|
});
|
|
6215
6365
|
}
|
|
6216
6366
|
function collectFindings(workspaceRoot) {
|
|
6217
|
-
const nxJsonPath = (0,
|
|
6367
|
+
const nxJsonPath = (0, import_node_path22.join)(workspaceRoot, "nx.json");
|
|
6218
6368
|
if (!fileExists(nxJsonPath)) {
|
|
6219
6369
|
throw new Error(
|
|
6220
6370
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -6235,6 +6385,7 @@ function collectFindings(workspaceRoot) {
|
|
|
6235
6385
|
...checkVersionActions(workspaceRoot),
|
|
6236
6386
|
...checkTargetFilesExist(workspaceRoot),
|
|
6237
6387
|
checkSync(workspaceRoot),
|
|
6388
|
+
checkGoPluginRegistered(workspaceRoot),
|
|
6238
6389
|
...checkNativeApps(workspaceRoot)
|
|
6239
6390
|
].filter((finding) => finding !== void 0);
|
|
6240
6391
|
}
|
|
@@ -6260,8 +6411,8 @@ function runDoctor(workspaceRoot) {
|
|
|
6260
6411
|
}
|
|
6261
6412
|
|
|
6262
6413
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
6263
|
-
var
|
|
6264
|
-
var
|
|
6414
|
+
var import_node_fs16 = require("fs");
|
|
6415
|
+
var import_node_path23 = require("path");
|
|
6265
6416
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
6266
6417
|
var AGENT_AND_CI_ENTRIES = [
|
|
6267
6418
|
"AGENTS.md",
|
|
@@ -6292,13 +6443,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
6292
6443
|
"packages"
|
|
6293
6444
|
];
|
|
6294
6445
|
function assertAdoptableDirectory(target) {
|
|
6295
|
-
if (!(0,
|
|
6446
|
+
if (!(0, import_node_fs16.existsSync)(target)) {
|
|
6296
6447
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
6297
6448
|
}
|
|
6298
|
-
if (!(0,
|
|
6449
|
+
if (!(0, import_node_fs16.statSync)(target).isDirectory()) {
|
|
6299
6450
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
6300
6451
|
}
|
|
6301
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
6452
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs16.existsSync)((0, import_node_path23.join)(target, entry)));
|
|
6302
6453
|
if (blockers.length > 0) {
|
|
6303
6454
|
throw new Error(
|
|
6304
6455
|
`--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.`
|
|
@@ -6306,15 +6457,15 @@ function assertAdoptableDirectory(target) {
|
|
|
6306
6457
|
}
|
|
6307
6458
|
}
|
|
6308
6459
|
function mergeGitignore(generatedFile, targetFile) {
|
|
6309
|
-
const existing = (0,
|
|
6460
|
+
const existing = (0, import_node_fs16.readFileSync)(targetFile, "utf8");
|
|
6310
6461
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
6311
|
-
const additions = (0,
|
|
6462
|
+
const additions = (0, import_node_fs16.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
6312
6463
|
const trimmed = line.trim();
|
|
6313
6464
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
6314
6465
|
});
|
|
6315
6466
|
if (additions.length === 0) return false;
|
|
6316
6467
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
6317
|
-
(0,
|
|
6468
|
+
(0, import_node_fs16.writeFileSync)(
|
|
6318
6469
|
targetFile,
|
|
6319
6470
|
`${existing}${separator}
|
|
6320
6471
|
# Added by mnci (Nx workspace)
|
|
@@ -6324,9 +6475,9 @@ ${additions.join("\n")}
|
|
|
6324
6475
|
return true;
|
|
6325
6476
|
}
|
|
6326
6477
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
6327
|
-
const entries = (0,
|
|
6478
|
+
const entries = (0, import_node_fs16.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
6328
6479
|
const collisions = entries.filter(
|
|
6329
|
-
(entry) => (0,
|
|
6480
|
+
(entry) => (0, import_node_fs16.existsSync)((0, import_node_path23.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
6330
6481
|
);
|
|
6331
6482
|
if (collisions.length > 0) {
|
|
6332
6483
|
throw new Error(
|
|
@@ -6335,28 +6486,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
6335
6486
|
}
|
|
6336
6487
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
6337
6488
|
for (const entry of entries) {
|
|
6338
|
-
const from = (0,
|
|
6339
|
-
const to = (0,
|
|
6340
|
-
if (entry === ".gitignore" && (0,
|
|
6489
|
+
const from = (0, import_node_path23.join)(generatedRoot, entry);
|
|
6490
|
+
const to = (0, import_node_path23.join)(target, entry);
|
|
6491
|
+
if (entry === ".gitignore" && (0, import_node_fs16.existsSync)(to)) {
|
|
6341
6492
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
6342
6493
|
result.kept.push(entry);
|
|
6343
6494
|
continue;
|
|
6344
6495
|
}
|
|
6345
|
-
if ((0,
|
|
6496
|
+
if ((0, import_node_fs16.existsSync)(to)) {
|
|
6346
6497
|
result.kept.push(entry);
|
|
6347
6498
|
continue;
|
|
6348
6499
|
}
|
|
6349
|
-
(0,
|
|
6500
|
+
(0, import_node_fs16.cpSync)(from, to, { recursive: true });
|
|
6350
6501
|
result.copied.push(entry);
|
|
6351
6502
|
}
|
|
6352
|
-
(0,
|
|
6503
|
+
(0, import_node_fs16.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
6353
6504
|
return result;
|
|
6354
6505
|
}
|
|
6355
6506
|
|
|
6356
6507
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
6357
|
-
var
|
|
6508
|
+
var import_node_fs17 = require("fs");
|
|
6358
6509
|
var import_node_os = require("os");
|
|
6359
|
-
var
|
|
6510
|
+
var import_node_path24 = require("path");
|
|
6360
6511
|
function nxCloudProviderValue(ci) {
|
|
6361
6512
|
return ci === "azure" ? "azure" : "github";
|
|
6362
6513
|
}
|
|
@@ -6392,9 +6543,9 @@ async function resolveRegistry(options) {
|
|
|
6392
6543
|
return await promptRegistry();
|
|
6393
6544
|
}
|
|
6394
6545
|
async function runNew(name, options) {
|
|
6395
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
6546
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path24.resolve)(process.cwd(), options.into);
|
|
6396
6547
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
6397
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
6548
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path24.basename)(adoptTarget));
|
|
6398
6549
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
6399
6550
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
6400
6551
|
const registry = await resolveRegistry(options);
|
|
@@ -6407,8 +6558,8 @@ async function runNew(name, options) {
|
|
|
6407
6558
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
6408
6559
|
const stack = await resolveStack(options);
|
|
6409
6560
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
6410
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
6411
|
-
let workspaceRoot = (0,
|
|
6561
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs17.mkdtempSync)((0, import_node_path24.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
6562
|
+
let workspaceRoot = (0, import_node_path24.join)(stagingParent, workspaceName);
|
|
6412
6563
|
try {
|
|
6413
6564
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
6414
6565
|
runNpx(
|
|
@@ -6431,7 +6582,7 @@ async function runNew(name, options) {
|
|
|
6431
6582
|
workspaceRoot = adoptTarget;
|
|
6432
6583
|
}
|
|
6433
6584
|
} finally {
|
|
6434
|
-
if (adoptTarget !== void 0) (0,
|
|
6585
|
+
if (adoptTarget !== void 0) (0, import_node_fs17.rmSync)(stagingParent, { recursive: true, force: true });
|
|
6435
6586
|
}
|
|
6436
6587
|
logger.step(
|
|
6437
6588
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -6441,8 +6592,8 @@ async function runNew(name, options) {
|
|
|
6441
6592
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
6442
6593
|
logger.detail
|
|
6443
6594
|
);
|
|
6444
|
-
(0,
|
|
6445
|
-
(0,
|
|
6595
|
+
(0, import_node_fs17.rmSync)((0, import_node_path24.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
6596
|
+
(0, import_node_fs17.rmSync)((0, import_node_path24.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
6446
6597
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
6447
6598
|
const installStatus = runShell(
|
|
6448
6599
|
"npm",
|
|
@@ -6473,12 +6624,12 @@ async function runNew(name, options) {
|
|
|
6473
6624
|
}
|
|
6474
6625
|
|
|
6475
6626
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6476
|
-
var
|
|
6627
|
+
var import_node_path26 = require("path");
|
|
6477
6628
|
var import_prompts4 = require("@inquirer/prompts");
|
|
6478
6629
|
|
|
6479
6630
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
6480
|
-
var
|
|
6481
|
-
var
|
|
6631
|
+
var import_node_fs18 = require("fs");
|
|
6632
|
+
var import_node_path25 = require("path");
|
|
6482
6633
|
function resolveRegistry2(options, persisted) {
|
|
6483
6634
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
6484
6635
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -6507,7 +6658,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6507
6658
|
return persisted.workspaceName;
|
|
6508
6659
|
}
|
|
6509
6660
|
try {
|
|
6510
|
-
const existing = (0,
|
|
6661
|
+
const existing = (0, import_node_fs18.readdirSync)(workspaceRoot).find(
|
|
6511
6662
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
6512
6663
|
);
|
|
6513
6664
|
if (existing) {
|
|
@@ -6515,11 +6666,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6515
6666
|
}
|
|
6516
6667
|
} catch {
|
|
6517
6668
|
}
|
|
6518
|
-
return (0,
|
|
6669
|
+
return (0, import_node_path25.basename)(workspaceRoot);
|
|
6519
6670
|
}
|
|
6520
6671
|
function detectNpmAuth(workspaceRoot) {
|
|
6521
6672
|
try {
|
|
6522
|
-
return (0,
|
|
6673
|
+
return (0, import_node_fs18.readFileSync)((0, import_node_path25.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
6523
6674
|
} catch {
|
|
6524
6675
|
return void 0;
|
|
6525
6676
|
}
|
|
@@ -6566,7 +6717,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
6566
6717
|
};
|
|
6567
6718
|
}
|
|
6568
6719
|
function runUpgrade(workspaceRoot, options) {
|
|
6569
|
-
if (!fileExists((0,
|
|
6720
|
+
if (!fileExists((0, import_node_path25.join)(workspaceRoot, "nx.json"))) {
|
|
6570
6721
|
throw new Error(
|
|
6571
6722
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
6572
6723
|
);
|
|
@@ -6611,6 +6762,10 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6611
6762
|
logger.step("Updating the releasable Go app script");
|
|
6612
6763
|
logger.detail(`updated ${GO_RELEASE_SCRIPT_PATH}`);
|
|
6613
6764
|
}
|
|
6765
|
+
if (hasGoProject(workspaceRoot) && registerNxGoPlugin(workspaceRoot)) {
|
|
6766
|
+
logger.step("Registering the Go plugin in nx.json, so Nx can see which Go project imports which");
|
|
6767
|
+
logger.detail("updated nx.json");
|
|
6768
|
+
}
|
|
6614
6769
|
const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
|
|
6615
6770
|
if (upgradedDtsPlugins.length > 0) {
|
|
6616
6771
|
logger.step("Upgrading declaration specifiers to resolve under nodenext");
|
|
@@ -6627,7 +6782,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6627
6782
|
|
|
6628
6783
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6629
6784
|
async function runInteractive() {
|
|
6630
|
-
const inWorkspace = fileExists((0,
|
|
6785
|
+
const inWorkspace = fileExists((0, import_node_path26.join)(process.cwd(), "nx.json"));
|
|
6631
6786
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
6632
6787
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
6633
6788
|
const choiceUpgrade = {
|
|
@@ -6648,8 +6803,8 @@ async function runInteractive() {
|
|
|
6648
6803
|
}
|
|
6649
6804
|
|
|
6650
6805
|
// src/cli-version/check-for-update.use-case.ts
|
|
6651
|
-
var
|
|
6652
|
-
var
|
|
6806
|
+
var import_node_fs19 = require("fs");
|
|
6807
|
+
var import_node_path27 = require("path");
|
|
6653
6808
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
6654
6809
|
var PACKAGE_NAME = "@mnci/cli";
|
|
6655
6810
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -6705,8 +6860,8 @@ function releaseTriple(version) {
|
|
|
6705
6860
|
}
|
|
6706
6861
|
function readCliVersion(packageDirectory) {
|
|
6707
6862
|
try {
|
|
6708
|
-
const manifestPath = (0,
|
|
6709
|
-
const manifest = JSON.parse((0,
|
|
6863
|
+
const manifestPath = (0, import_node_path27.join)(packageDirectory, "..", "package.json");
|
|
6864
|
+
const manifest = JSON.parse((0, import_node_fs19.readFileSync)(manifestPath, "utf8"));
|
|
6710
6865
|
return manifest.version ?? "0.0.0";
|
|
6711
6866
|
} catch {
|
|
6712
6867
|
return "0.0.0";
|
|
@@ -6745,6 +6900,11 @@ function buildProgram(cliVersion) {
|
|
|
6745
6900
|
).action(() => {
|
|
6746
6901
|
runDoctor(process.cwd());
|
|
6747
6902
|
});
|
|
6903
|
+
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
6904
|
+
"Run a phase of the CI pipeline here, the same way CI runs it: `verify` is the sync check and then every project (or, in a pull request, the affected ones) through lint, typecheck, test and build. Exits non-zero when it fails"
|
|
6905
|
+
).action((phase) => {
|
|
6906
|
+
process.exitCode = runCiPhase(phase, process.cwd());
|
|
6907
|
+
});
|
|
6748
6908
|
program.command("sync").description(
|
|
6749
6909
|
"Make every project agree: converge external dependency ranges declared at more than one version, then run 'nx sync' for TypeScript project references. Go is a no-op \u2014 one root go.mod means one version of every module"
|
|
6750
6910
|
).option("--check", "report drift and exit non-zero without writing anything").option("--ecosystem <name>", "restrict to one ecosystem: npm | pip | pub | go").action((options) => {
|