@mnci/cli 4.32.3 → 4.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +567 -514
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -37,9 +37,9 @@ __export(main_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(main_exports);
|
|
38
38
|
var import_commander = require("commander");
|
|
39
39
|
|
|
40
|
-
// src/ci-pipeline/
|
|
41
|
-
var
|
|
42
|
-
var
|
|
40
|
+
// src/ci-pipeline/native.use-case.ts
|
|
41
|
+
var import_node_fs3 = require("fs");
|
|
42
|
+
var import_node_path3 = require("path");
|
|
43
43
|
|
|
44
44
|
// src/nx-workspace/nx.client.ts
|
|
45
45
|
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
@@ -206,99 +206,15 @@ function runFormatter(cwd, target = ".") {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// src/ci-pipeline/ci-environment.client.ts
|
|
210
|
-
function detectCiHost(environment) {
|
|
211
|
-
if (environment.GITHUB_ACTIONS === "true") {
|
|
212
|
-
return "github";
|
|
213
|
-
}
|
|
214
|
-
if (environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "") {
|
|
215
|
-
return "azure";
|
|
216
|
-
}
|
|
217
|
-
return "local";
|
|
218
|
-
}
|
|
219
|
-
function pullRequestTarget(environment) {
|
|
220
|
-
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
221
|
-
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
222
|
-
}
|
|
223
|
-
function groupStart(host, title) {
|
|
224
|
-
switch (host) {
|
|
225
|
-
case "github": {
|
|
226
|
-
return `::group::${title}`;
|
|
227
|
-
}
|
|
228
|
-
case "azure": {
|
|
229
|
-
return `##[group]${title}`;
|
|
230
|
-
}
|
|
231
|
-
case "local": {
|
|
232
|
-
return `
|
|
233
|
-
\u25B8 ${title}`;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function groupEnd(host) {
|
|
238
|
-
switch (host) {
|
|
239
|
-
case "github": {
|
|
240
|
-
return "::endgroup::";
|
|
241
|
-
}
|
|
242
|
-
case "azure": {
|
|
243
|
-
return "##[endgroup]";
|
|
244
|
-
}
|
|
245
|
-
case "local": {
|
|
246
|
-
return void 0;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// src/ci-pipeline/pack.use-case.ts
|
|
252
|
-
function hasAppToPack(workspaceRoot) {
|
|
253
|
-
const hasProjectJson = (0, import_node_fs.globSync)("apps/*/project.json", { cwd: workspaceRoot }).length > 0;
|
|
254
|
-
const hasInlineNx = (0, import_node_fs.globSync)("apps/*/package.json", { cwd: workspaceRoot }).some((manifest) => {
|
|
255
|
-
try {
|
|
256
|
-
const parsed = JSON.parse((0, import_node_fs.readFileSync)((0, import_node_path.join)(workspaceRoot, manifest), "utf8"));
|
|
257
|
-
return Boolean(parsed.nx);
|
|
258
|
-
} catch {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
const hasCsproj = (0, import_node_fs.globSync)("apps/*/*.csproj", { cwd: workspaceRoot }).length > 0;
|
|
263
|
-
return hasProjectJson || hasInlineNx || hasCsproj;
|
|
264
|
-
}
|
|
265
|
-
function runPack(workspaceRoot, dependencies = {}) {
|
|
266
|
-
const environment = dependencies.environment ?? process.env;
|
|
267
|
-
const processes = dependencies.processes ?? {
|
|
268
|
-
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
269
|
-
capture: () => ({ status: 1, stdout: "" })
|
|
270
|
-
};
|
|
271
|
-
const log = dependencies.log ?? ((message) => {
|
|
272
|
-
console.log(message);
|
|
273
|
-
});
|
|
274
|
-
const host = detectCiHost(environment);
|
|
275
|
-
(0, import_node_fs.mkdirSync)((0, import_node_path.join)(workspaceRoot, "dist", "drop"), { recursive: true });
|
|
276
|
-
if (!hasAppToPack(workspaceRoot)) {
|
|
277
|
-
log("No apps to pack - skipping.");
|
|
278
|
-
return 0;
|
|
279
|
-
}
|
|
280
|
-
log(groupStart(host, "Pack all apps"));
|
|
281
|
-
const status = processes.run("npx", ["nx", "run-many", "-t", "package"]);
|
|
282
|
-
const closing = groupEnd(host);
|
|
283
|
-
if (closing !== void 0) {
|
|
284
|
-
log(closing);
|
|
285
|
-
}
|
|
286
|
-
return status;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// src/ci-pipeline/release.use-case.ts
|
|
290
|
-
var import_node_fs4 = require("fs");
|
|
291
|
-
var import_node_path4 = require("path");
|
|
292
|
-
|
|
293
209
|
// src/workspace-overlay/overlay.use-case.ts
|
|
294
|
-
var import_node_fs3 = require("fs");
|
|
295
|
-
var import_node_path3 = require("path");
|
|
296
|
-
|
|
297
|
-
// src/file-system/file-system.client.ts
|
|
298
210
|
var import_node_fs2 = require("fs");
|
|
299
211
|
var import_node_path2 = require("path");
|
|
212
|
+
|
|
213
|
+
// src/file-system/file-system.client.ts
|
|
214
|
+
var import_node_fs = require("fs");
|
|
215
|
+
var import_node_path = require("path");
|
|
300
216
|
function readJson(path) {
|
|
301
|
-
return JSON.parse((0,
|
|
217
|
+
return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
|
|
302
218
|
}
|
|
303
219
|
function stripJsonComments(text) {
|
|
304
220
|
let result = "";
|
|
@@ -355,7 +271,7 @@ function stripJsonComments(text) {
|
|
|
355
271
|
}
|
|
356
272
|
function readCodeWorkspace(path) {
|
|
357
273
|
try {
|
|
358
|
-
const withoutComments = stripJsonComments((0,
|
|
274
|
+
const withoutComments = stripJsonComments((0, import_node_fs.readFileSync)(path, "utf8"));
|
|
359
275
|
return JSON.parse(withoutComments.replaceAll(/,(\s*[}\]])/g, "$1"));
|
|
360
276
|
} catch {
|
|
361
277
|
return void 0;
|
|
@@ -366,14 +282,14 @@ function toJson(value) {
|
|
|
366
282
|
`;
|
|
367
283
|
}
|
|
368
284
|
function writeFileEnsured(path, content) {
|
|
369
|
-
(0,
|
|
370
|
-
(0,
|
|
285
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path), { recursive: true });
|
|
286
|
+
(0, import_node_fs.writeFileSync)(path, content);
|
|
371
287
|
}
|
|
372
288
|
function markExecutable(path) {
|
|
373
|
-
(0,
|
|
289
|
+
(0, import_node_fs.chmodSync)(path, 493);
|
|
374
290
|
}
|
|
375
291
|
function fileExists(path) {
|
|
376
|
-
return (0,
|
|
292
|
+
return (0, import_node_fs.existsSync)(path);
|
|
377
293
|
}
|
|
378
294
|
|
|
379
295
|
// src/workspace-overlay/overlay.use-case.ts
|
|
@@ -516,9 +432,9 @@ var VSCODE_EXTENSION_TAG = "type:vscode-extension";
|
|
|
516
432
|
var GO_RELEASE_TAG = "release:go";
|
|
517
433
|
var GO_CGO_TAG = "build:cgo";
|
|
518
434
|
function hasNativeGoApp(workspaceRoot) {
|
|
519
|
-
return (0,
|
|
435
|
+
return (0, import_node_fs2.globSync)("apps/*/project.json", { cwd: workspaceRoot }).some((projectJson) => {
|
|
520
436
|
try {
|
|
521
|
-
const { tags } = JSON.parse((0,
|
|
437
|
+
const { tags } = JSON.parse((0, import_node_fs2.readFileSync)((0, import_node_path2.join)(workspaceRoot, projectJson), "utf8"));
|
|
522
438
|
return (tags ?? []).includes(GO_CGO_TAG);
|
|
523
439
|
} catch {
|
|
524
440
|
return false;
|
|
@@ -859,8 +775,8 @@ function isUnmodifiedMnciEslintConfig(content) {
|
|
|
859
775
|
return code.length === 2 && code[0] === "import mnci from '@mnci/eslint-config'" && code[1] === "export default mnci({ workspaceRoot: import.meta.dirname })";
|
|
860
776
|
}
|
|
861
777
|
function writeEslintEntryPoint(workspaceRoot, onProgress) {
|
|
862
|
-
const path = (0,
|
|
863
|
-
if ((0,
|
|
778
|
+
const path = (0, import_node_path2.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
779
|
+
if ((0, import_node_fs2.existsSync)(path) && !isUnmodifiedMnciEslintConfig((0, import_node_fs2.readFileSync)(path, "utf8"))) {
|
|
864
780
|
onProgress(`${ESLINT_USER_FILENAME} \u2014 kept as it is, it is yours`);
|
|
865
781
|
return;
|
|
866
782
|
}
|
|
@@ -1028,7 +944,7 @@ function mnciConfig(options) {
|
|
|
1028
944
|
};
|
|
1029
945
|
}
|
|
1030
946
|
function readMnciConfig(workspaceRoot) {
|
|
1031
|
-
const nxJson = readJson((0,
|
|
947
|
+
const nxJson = readJson((0, import_node_path2.join)(workspaceRoot, "nx.json"));
|
|
1032
948
|
return nxJson.mnci ?? {};
|
|
1033
949
|
}
|
|
1034
950
|
function pythonPublishUrl(registry) {
|
|
@@ -1131,7 +1047,8 @@ function affectedOrAllGuard(exclude = "") {
|
|
|
1131
1047
|
}
|
|
1132
1048
|
var AFFECTED_OR_ALL_GUARD = affectedOrAllGuard();
|
|
1133
1049
|
var AFFECTED_OR_ALL_GUARD_WITHOUT_NATIVE = affectedOrAllGuard(`--exclude=tag:${GO_CGO_TAG}`);
|
|
1134
|
-
var
|
|
1050
|
+
var NATIVE_TARGETS = "lint,test,build-native,package-native";
|
|
1051
|
+
var NATIVE_BUILD_COMMAND = `npx nx run-many -t ${NATIVE_TARGETS} --projects=tag:${GO_CGO_TAG}`;
|
|
1135
1052
|
var NATIVE_LINUX_PREREQUISITES = "sudo apt-get update && sudo apt-get install -y gcc pkg-config";
|
|
1136
1053
|
function githubNativeJob(npmAuthName, npmAuthValue, onMain) {
|
|
1137
1054
|
return `
|
|
@@ -1955,12 +1872,12 @@ var ECOSYSTEM_MANIFESTS = {
|
|
|
1955
1872
|
};
|
|
1956
1873
|
function hasEcosystemProject(workspaceRoot, roots, manifests) {
|
|
1957
1874
|
return roots.some((root) => {
|
|
1958
|
-
const base = (0,
|
|
1959
|
-
if (!(0,
|
|
1875
|
+
const base = (0, import_node_path2.join)(workspaceRoot, root);
|
|
1876
|
+
if (!(0, import_node_fs2.existsSync)(base)) {
|
|
1960
1877
|
return false;
|
|
1961
1878
|
}
|
|
1962
|
-
return (0,
|
|
1963
|
-
(entry) => entry.isDirectory() && manifests.some((manifest) => (0,
|
|
1879
|
+
return (0, import_node_fs2.readdirSync)(base, { withFileTypes: true }).some(
|
|
1880
|
+
(entry) => entry.isDirectory() && manifests.some((manifest) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(base, entry.name, manifest)))
|
|
1964
1881
|
);
|
|
1965
1882
|
});
|
|
1966
1883
|
}
|
|
@@ -2038,11 +1955,11 @@ var LOCAL_REGISTRY_SCAFFOLDING = {
|
|
|
2038
1955
|
rootTarget: "local-registry"
|
|
2039
1956
|
};
|
|
2040
1957
|
function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
2041
|
-
(0,
|
|
1958
|
+
(0, import_node_fs2.rmSync)((0, import_node_path2.join)(workspaceRoot, LOCAL_REGISTRY_SCAFFOLDING.directory), {
|
|
2042
1959
|
recursive: true,
|
|
2043
1960
|
force: true
|
|
2044
1961
|
});
|
|
2045
|
-
const manifestPath = (0,
|
|
1962
|
+
const manifestPath = (0, import_node_path2.join)(workspaceRoot, "package.json");
|
|
2046
1963
|
if (!fileExists(manifestPath)) return;
|
|
2047
1964
|
const manifest = readJson(manifestPath);
|
|
2048
1965
|
if (manifest.devDependencies?.[LOCAL_REGISTRY_SCAFFOLDING.devDependency] !== void 0) {
|
|
@@ -2058,23 +1975,23 @@ function removeLocalRegistryScaffolding(workspaceRoot) {
|
|
|
2058
1975
|
}
|
|
2059
1976
|
function removeNxScaffolding(workspaceRoot) {
|
|
2060
1977
|
for (const entry of NX_SCAFFOLDING_TO_REMOVE) {
|
|
2061
|
-
(0,
|
|
1978
|
+
(0, import_node_fs2.rmSync)((0, import_node_path2.join)(workspaceRoot, entry), { recursive: true, force: true });
|
|
2062
1979
|
}
|
|
2063
1980
|
removeNxAuthoredAgentFiles(workspaceRoot);
|
|
2064
1981
|
removeProjectEslintConfigs(workspaceRoot);
|
|
2065
1982
|
}
|
|
2066
1983
|
function removeNxAuthoredAgentFiles(workspaceRoot) {
|
|
2067
|
-
(0,
|
|
2068
|
-
const claudeDirectory = (0,
|
|
2069
|
-
if ((0,
|
|
2070
|
-
(0,
|
|
1984
|
+
(0, import_node_fs2.rmSync)((0, import_node_path2.join)(workspaceRoot, NX_CLAUDE_SETTINGS), { force: true });
|
|
1985
|
+
const claudeDirectory = (0, import_node_path2.join)(workspaceRoot, (0, import_node_path2.dirname)(NX_CLAUDE_SETTINGS));
|
|
1986
|
+
if ((0, import_node_fs2.existsSync)(claudeDirectory) && (0, import_node_fs2.readdirSync)(claudeDirectory).length === 0) {
|
|
1987
|
+
(0, import_node_fs2.rmSync)(claudeDirectory, { recursive: true, force: true });
|
|
2071
1988
|
}
|
|
2072
1989
|
for (const name of NX_AUTHORED_AGENT_FILES) {
|
|
2073
|
-
const path = (0,
|
|
2074
|
-
if (!(0,
|
|
2075
|
-
const kept = withoutNxAgentRules((0,
|
|
1990
|
+
const path = (0, import_node_path2.join)(workspaceRoot, name);
|
|
1991
|
+
if (!(0, import_node_fs2.existsSync)(path)) continue;
|
|
1992
|
+
const kept = withoutNxAgentRules((0, import_node_fs2.readFileSync)(path, "utf8"));
|
|
2076
1993
|
if (kept === void 0) continue;
|
|
2077
|
-
if (kept.trim() === "") (0,
|
|
1994
|
+
if (kept.trim() === "") (0, import_node_fs2.rmSync)(path, { force: true });
|
|
2078
1995
|
else writeFileEnsured(path, kept);
|
|
2079
1996
|
}
|
|
2080
1997
|
}
|
|
@@ -2089,14 +2006,14 @@ function withoutNxAgentRules(content) {
|
|
|
2089
2006
|
return `${content.slice(0, start)}${rest}`.replace(/^[\r\n]+/, "");
|
|
2090
2007
|
}
|
|
2091
2008
|
function removeIfPresent(path) {
|
|
2092
|
-
(0,
|
|
2009
|
+
(0, import_node_fs2.rmSync)(path, { recursive: true, force: true });
|
|
2093
2010
|
}
|
|
2094
2011
|
function ensureEslintCacheIgnored(workspaceRoot) {
|
|
2095
|
-
const gitignorePath = (0,
|
|
2012
|
+
const gitignorePath = (0, import_node_path2.join)(workspaceRoot, ".gitignore");
|
|
2096
2013
|
if (!fileExists(gitignorePath)) {
|
|
2097
2014
|
return;
|
|
2098
2015
|
}
|
|
2099
|
-
const current = (0,
|
|
2016
|
+
const current = (0, import_node_fs2.readFileSync)(gitignorePath, "utf8");
|
|
2100
2017
|
if (current.split("\n").some((line) => line.trim() === ".eslintcache")) {
|
|
2101
2018
|
return;
|
|
2102
2019
|
}
|
|
@@ -2111,18 +2028,18 @@ function ensureEslintCacheIgnored(workspaceRoot) {
|
|
|
2111
2028
|
}
|
|
2112
2029
|
var PYTHON_ARTEFACT_IGNORES = ["__pycache__/", "*.py[cod]"];
|
|
2113
2030
|
function ensurePythonArtefactsIgnored(workspaceRoot) {
|
|
2114
|
-
const gitignorePath = (0,
|
|
2031
|
+
const gitignorePath = (0, import_node_path2.join)(workspaceRoot, ".gitignore");
|
|
2115
2032
|
if (!fileExists(gitignorePath)) {
|
|
2116
2033
|
return;
|
|
2117
2034
|
}
|
|
2118
|
-
const hasPython = (0,
|
|
2035
|
+
const hasPython = (0, import_node_fs2.globSync)(
|
|
2119
2036
|
["python-packages/*/pyproject.toml", "apps/*/pyproject.toml", "libs/*/pyproject.toml"],
|
|
2120
2037
|
{ cwd: workspaceRoot }
|
|
2121
2038
|
).length > 0;
|
|
2122
2039
|
if (!hasPython) {
|
|
2123
2040
|
return;
|
|
2124
2041
|
}
|
|
2125
|
-
const current = (0,
|
|
2042
|
+
const current = (0, import_node_fs2.readFileSync)(gitignorePath, "utf8");
|
|
2126
2043
|
const present = new Set(current.split("\n").map((line) => line.trim()));
|
|
2127
2044
|
const missing = PYTHON_ARTEFACT_IGNORES.filter((line) => !present.has(line));
|
|
2128
2045
|
if (missing.length === 0) {
|
|
@@ -2142,16 +2059,16 @@ ${missing.join("\n")}
|
|
|
2142
2059
|
);
|
|
2143
2060
|
}
|
|
2144
2061
|
function removeProjectEslintConfigs(workspaceRoot) {
|
|
2145
|
-
const matches = (0,
|
|
2062
|
+
const matches = (0, import_node_fs2.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
2146
2063
|
cwd: workspaceRoot
|
|
2147
2064
|
});
|
|
2148
2065
|
for (const match of matches) {
|
|
2149
|
-
(0,
|
|
2066
|
+
(0, import_node_fs2.rmSync)((0, import_node_path2.join)(workspaceRoot, match), { force: true });
|
|
2150
2067
|
}
|
|
2151
2068
|
}
|
|
2152
2069
|
function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
2153
2070
|
}) {
|
|
2154
|
-
const nxJsonPath = (0,
|
|
2071
|
+
const nxJsonPath = (0, import_node_path2.join)(workspaceRoot, "nx.json");
|
|
2155
2072
|
const nxJson = readJson(nxJsonPath);
|
|
2156
2073
|
const generators = {
|
|
2157
2074
|
...nxJson.generators,
|
|
@@ -2159,7 +2076,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2159
2076
|
};
|
|
2160
2077
|
const sync = { ...nxJson.sync, ...SYNC_CONFIG };
|
|
2161
2078
|
const mnci = { ...nxJson.mnci, ...mnciConfig(options) };
|
|
2162
|
-
const rootManifest = readJson((0,
|
|
2079
|
+
const rootManifest = readJson((0, import_node_path2.join)(workspaceRoot, "package.json"));
|
|
2163
2080
|
const hasPythonPlugin = (rootManifest.devDependencies ?? {})["@mnci/nx-python-pip"] !== void 0 || (rootManifest.dependencies ?? {})["@mnci/nx-python-pip"] !== void 0;
|
|
2164
2081
|
const withRelease = withReleaseConfig(nxJson, options.ci);
|
|
2165
2082
|
const patched = withPythonGraphPlugin(
|
|
@@ -2169,7 +2086,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2169
2086
|
onProgress("nx.json \u2014 release, sync, generators, shared inputs, mnci block");
|
|
2170
2087
|
writeFileEnsured(nxJsonPath, toJson({ ...patched, generators, sync, mnci }));
|
|
2171
2088
|
onProgress("package.json \u2014 root scripts, TS compilers, ESLint toolchain, overrides");
|
|
2172
|
-
const manifestPath = (0,
|
|
2089
|
+
const manifestPath = (0, import_node_path2.join)(workspaceRoot, "package.json");
|
|
2173
2090
|
const manifest = readJson(manifestPath);
|
|
2174
2091
|
const scripts = {
|
|
2175
2092
|
...manifest.scripts,
|
|
@@ -2221,32 +2138,32 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2221
2138
|
`.npmrc \u2014 ${options.registry.kind === "azure-artifacts" ? "Azure Artifacts feed routing and credentials" : "public npm registry auth"}`
|
|
2222
2139
|
);
|
|
2223
2140
|
writeFileEnsured(
|
|
2224
|
-
(0,
|
|
2141
|
+
(0, import_node_path2.join)(workspaceRoot, ".npmrc"),
|
|
2225
2142
|
npmrcContent(options.registry, options.scope, options.npmAuth)
|
|
2226
2143
|
);
|
|
2227
2144
|
onProgress("commitlint.config.mjs and .husky/commit-msg \u2014 conventional commit enforcement");
|
|
2228
|
-
writeFileEnsured((0,
|
|
2229
|
-
const hookPath = (0,
|
|
2145
|
+
writeFileEnsured((0, import_node_path2.join)(workspaceRoot, "commitlint.config.mjs"), COMMITLINT_CONFIG);
|
|
2146
|
+
const hookPath = (0, import_node_path2.join)(workspaceRoot, ".husky/commit-msg");
|
|
2230
2147
|
writeFileEnsured(hookPath, COMMIT_MSG_HOOK);
|
|
2231
2148
|
markExecutable(hookPath);
|
|
2232
2149
|
onProgress(`${ESLINT_MNCI_FILENAME} \u2014 the shared lint AND formatting opinion`);
|
|
2233
|
-
writeFileEnsured((0,
|
|
2150
|
+
writeFileEnsured((0, import_node_path2.join)(workspaceRoot, ESLINT_MNCI_FILENAME), ESLINT_MNCI_CONFIG);
|
|
2234
2151
|
writeEslintEntryPoint(workspaceRoot, onProgress);
|
|
2235
2152
|
ensureEslintCacheIgnored(workspaceRoot);
|
|
2236
2153
|
ensurePythonArtefactsIgnored(workspaceRoot);
|
|
2237
2154
|
for (const retired of RETIRED_FORMATTER_FILES) {
|
|
2238
|
-
removeIfPresent((0,
|
|
2155
|
+
removeIfPresent((0, import_node_path2.join)(workspaceRoot, retired));
|
|
2239
2156
|
}
|
|
2240
2157
|
onProgress(".devcontainer/devcontainer.json \u2014 a local toolchain matching CI");
|
|
2241
2158
|
writeFileEnsured(
|
|
2242
|
-
(0,
|
|
2159
|
+
(0, import_node_path2.join)(workspaceRoot, ".devcontainer/devcontainer.json"),
|
|
2243
2160
|
devcontainerJson(options.workspaceName)
|
|
2244
2161
|
);
|
|
2245
2162
|
removeNxScaffolding(workspaceRoot);
|
|
2246
2163
|
onProgress(
|
|
2247
2164
|
`${options.workspaceName}.code-workspace \u2014 settings, extensions, launch configs`
|
|
2248
2165
|
);
|
|
2249
|
-
const codeWorkspacePath = (0,
|
|
2166
|
+
const codeWorkspacePath = (0, import_node_path2.join)(workspaceRoot, `${options.workspaceName}.code-workspace`);
|
|
2250
2167
|
const existing = readCodeWorkspace(codeWorkspacePath);
|
|
2251
2168
|
writeFileEnsured(
|
|
2252
2169
|
codeWorkspacePath,
|
|
@@ -2258,7 +2175,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2258
2175
|
)
|
|
2259
2176
|
);
|
|
2260
2177
|
if (options.workspaceName !== "undefined") {
|
|
2261
|
-
(0,
|
|
2178
|
+
(0, import_node_fs2.rmSync)((0, import_node_path2.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
|
|
2262
2179
|
}
|
|
2263
2180
|
const publishUrl = pythonPublishUrl(options.registry);
|
|
2264
2181
|
const nugetUrl = nugetFeedUrl(options.registry);
|
|
@@ -2266,7 +2183,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2266
2183
|
if (options.ci === "azure" || options.ci === "both") {
|
|
2267
2184
|
onProgress("azure-pipelines.yml \u2014 build, verify, pack and release");
|
|
2268
2185
|
writeFileEnsured(
|
|
2269
|
-
(0,
|
|
2186
|
+
(0, import_node_path2.join)(workspaceRoot, "azure-pipelines.yml"),
|
|
2270
2187
|
azurePipelinesYaml(
|
|
2271
2188
|
options.agent,
|
|
2272
2189
|
options.variableGroup,
|
|
@@ -2281,18 +2198,138 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
2281
2198
|
if (options.ci === "github" || options.ci === "both") {
|
|
2282
2199
|
onProgress(".github/workflows/ci.yml and dependabot.yml");
|
|
2283
2200
|
writeFileEnsured(
|
|
2284
|
-
(0,
|
|
2201
|
+
(0, import_node_path2.join)(workspaceRoot, ".github/workflows/ci.yml"),
|
|
2285
2202
|
githubActionsYaml(options.agent, publishUrl, options.registry.kind, options.ci, nugetUrl, nativeApps)
|
|
2286
2203
|
);
|
|
2287
|
-
writeFileEnsured((0,
|
|
2204
|
+
writeFileEnsured((0, import_node_path2.join)(workspaceRoot, ".github/dependabot.yml"), dependabotConfig(workspaceRoot));
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
// src/ci-pipeline/ci-environment.client.ts
|
|
2209
|
+
function detectCiHost(environment) {
|
|
2210
|
+
if (environment.GITHUB_ACTIONS === "true") {
|
|
2211
|
+
return "github";
|
|
2212
|
+
}
|
|
2213
|
+
if (environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "") {
|
|
2214
|
+
return "azure";
|
|
2215
|
+
}
|
|
2216
|
+
return "local";
|
|
2217
|
+
}
|
|
2218
|
+
function pullRequestTarget(environment) {
|
|
2219
|
+
const reference = environment.GITHUB_BASE_REF || environment.SYSTEM_PULLREQUEST_TARGETBRANCH || "";
|
|
2220
|
+
return reference === "" ? void 0 : reference.replace("refs/heads/", "");
|
|
2221
|
+
}
|
|
2222
|
+
function isMainPush(environment) {
|
|
2223
|
+
if (environment.GITHUB_ACTIONS === "true") {
|
|
2224
|
+
return environment.GITHUB_EVENT_NAME === "push" && environment.GITHUB_REF_NAME === "main";
|
|
2225
|
+
}
|
|
2226
|
+
return environment.TF_BUILD !== void 0 && environment.TF_BUILD !== "" && ["IndividualCI", "BatchedCI"].includes(environment.BUILD_REASON ?? "") && environment.BUILD_SOURCEBRANCHNAME === "main";
|
|
2227
|
+
}
|
|
2228
|
+
function groupStart(host, title) {
|
|
2229
|
+
switch (host) {
|
|
2230
|
+
case "github": {
|
|
2231
|
+
return `::group::${title}`;
|
|
2232
|
+
}
|
|
2233
|
+
case "azure": {
|
|
2234
|
+
return `##[group]${title}`;
|
|
2235
|
+
}
|
|
2236
|
+
case "local": {
|
|
2237
|
+
return `
|
|
2238
|
+
\u25B8 ${title}`;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
function groupEnd(host) {
|
|
2243
|
+
switch (host) {
|
|
2244
|
+
case "github": {
|
|
2245
|
+
return "::endgroup::";
|
|
2246
|
+
}
|
|
2247
|
+
case "azure": {
|
|
2248
|
+
return "##[endgroup]";
|
|
2249
|
+
}
|
|
2250
|
+
case "local": {
|
|
2251
|
+
return void 0;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
// src/ci-pipeline/native.use-case.ts
|
|
2257
|
+
function runNative(workspaceRoot, dependencies = {}) {
|
|
2258
|
+
const environment = dependencies.environment ?? process.env;
|
|
2259
|
+
const processes = dependencies.processes ?? {
|
|
2260
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2261
|
+
capture: (command, arguments_) => runCapture(command, arguments_, workspaceRoot)
|
|
2262
|
+
};
|
|
2263
|
+
const log = dependencies.log ?? ((message) => {
|
|
2264
|
+
console.log(message);
|
|
2265
|
+
});
|
|
2266
|
+
const host = detectCiHost(environment);
|
|
2267
|
+
const inGroup = (title, command, arguments_) => {
|
|
2268
|
+
log(groupStart(host, title));
|
|
2269
|
+
const status = processes.run(command, arguments_);
|
|
2270
|
+
const closing = groupEnd(host);
|
|
2271
|
+
if (closing !== void 0) {
|
|
2272
|
+
log(closing);
|
|
2273
|
+
}
|
|
2274
|
+
return status;
|
|
2275
|
+
};
|
|
2276
|
+
const built = inGroup("Lint, test, build and package the native apps", "npx", ["nx", "run-many", "-t", NATIVE_TARGETS, `--projects=tag:${GO_CGO_TAG}`]);
|
|
2277
|
+
if (built !== 0) {
|
|
2278
|
+
return built;
|
|
2279
|
+
}
|
|
2280
|
+
if (!isMainPush(environment) || !(0, import_node_fs3.existsSync)((0, import_node_path3.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2281
|
+
return 0;
|
|
2282
|
+
}
|
|
2283
|
+
return inGroup("Attach this OS's zip to the GitHub Release", "node", ["tools/go-app-release.cjs", "assets", "--native"]);
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
// src/ci-pipeline/pack.use-case.ts
|
|
2287
|
+
var import_node_fs4 = require("fs");
|
|
2288
|
+
var import_node_path4 = require("path");
|
|
2289
|
+
function hasAppToPack(workspaceRoot) {
|
|
2290
|
+
const hasProjectJson = (0, import_node_fs4.globSync)("apps/*/project.json", { cwd: workspaceRoot }).length > 0;
|
|
2291
|
+
const hasInlineNx = (0, import_node_fs4.globSync)("apps/*/package.json", { cwd: workspaceRoot }).some((manifest) => {
|
|
2292
|
+
try {
|
|
2293
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path4.join)(workspaceRoot, manifest), "utf8"));
|
|
2294
|
+
return Boolean(parsed.nx);
|
|
2295
|
+
} catch {
|
|
2296
|
+
return false;
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
const hasCsproj = (0, import_node_fs4.globSync)("apps/*/*.csproj", { cwd: workspaceRoot }).length > 0;
|
|
2300
|
+
return hasProjectJson || hasInlineNx || hasCsproj;
|
|
2301
|
+
}
|
|
2302
|
+
function runPack(workspaceRoot, dependencies = {}) {
|
|
2303
|
+
const environment = dependencies.environment ?? process.env;
|
|
2304
|
+
const processes = dependencies.processes ?? {
|
|
2305
|
+
run: (command, arguments_) => runShell(command, arguments_, workspaceRoot),
|
|
2306
|
+
capture: () => ({ status: 1, stdout: "" })
|
|
2307
|
+
};
|
|
2308
|
+
const log = dependencies.log ?? ((message) => {
|
|
2309
|
+
console.log(message);
|
|
2310
|
+
});
|
|
2311
|
+
const host = detectCiHost(environment);
|
|
2312
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path4.join)(workspaceRoot, "dist", "drop"), { recursive: true });
|
|
2313
|
+
if (!hasAppToPack(workspaceRoot)) {
|
|
2314
|
+
log("No apps to pack - skipping.");
|
|
2315
|
+
return 0;
|
|
2316
|
+
}
|
|
2317
|
+
log(groupStart(host, "Pack all apps"));
|
|
2318
|
+
const status = processes.run("npx", ["nx", "run-many", "-t", "package"]);
|
|
2319
|
+
const closing = groupEnd(host);
|
|
2320
|
+
if (closing !== void 0) {
|
|
2321
|
+
log(closing);
|
|
2288
2322
|
}
|
|
2323
|
+
return status;
|
|
2289
2324
|
}
|
|
2290
2325
|
|
|
2291
2326
|
// src/ci-pipeline/release.use-case.ts
|
|
2327
|
+
var import_node_fs5 = require("fs");
|
|
2328
|
+
var import_node_path5 = require("path");
|
|
2292
2329
|
var SPECIFIER = /^(?:major|minor|patch|\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2293
2330
|
function hasTag(workspaceRoot, relativePath, tag) {
|
|
2294
2331
|
try {
|
|
2295
|
-
const parsed = JSON.parse((0,
|
|
2332
|
+
const parsed = JSON.parse((0, import_node_fs5.readFileSync)((0, import_node_path5.join)(workspaceRoot, relativePath), "utf8"));
|
|
2296
2333
|
const tags = relativePath.endsWith("project.json") ? parsed.tags : parsed.nx?.tags;
|
|
2297
2334
|
return Array.isArray(tags) && tags.includes(tag);
|
|
2298
2335
|
} catch {
|
|
@@ -2301,12 +2338,12 @@ function hasTag(workspaceRoot, relativePath, tag) {
|
|
|
2301
2338
|
}
|
|
2302
2339
|
function releasableCounts(workspaceRoot) {
|
|
2303
2340
|
return {
|
|
2304
|
-
npm: (0,
|
|
2305
|
-
csharp: (0,
|
|
2306
|
-
python: (0,
|
|
2307
|
-
dart: (0,
|
|
2308
|
-
vscode: (0,
|
|
2309
|
-
go: (0,
|
|
2341
|
+
npm: (0, import_node_fs5.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length,
|
|
2342
|
+
csharp: (0, import_node_fs5.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }).length,
|
|
2343
|
+
python: (0, import_node_fs5.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot }).length,
|
|
2344
|
+
dart: (0, import_node_fs5.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }).length,
|
|
2345
|
+
vscode: (0, import_node_fs5.globSync)("apps/*/package.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, VSCODE_EXTENSION_TAG)).length,
|
|
2346
|
+
go: (0, import_node_fs5.globSync)("apps/*/project.json", { cwd: workspaceRoot }).filter((path) => hasTag(workspaceRoot, path, GO_RELEASE_TAG)).length
|
|
2310
2347
|
};
|
|
2311
2348
|
}
|
|
2312
2349
|
function shallowCloneGuard(processes, log) {
|
|
@@ -2322,7 +2359,7 @@ function shallowCloneGuard(processes, log) {
|
|
|
2322
2359
|
return 0;
|
|
2323
2360
|
}
|
|
2324
2361
|
function npmPreflight(workspaceRoot, registryKind, environment, processes, log) {
|
|
2325
|
-
if (registryKind !== "npm" || (0,
|
|
2362
|
+
if (registryKind !== "npm" || (0, import_node_fs5.globSync)("packages/*/package.json", { cwd: workspaceRoot }).length === 0) {
|
|
2326
2363
|
return 0;
|
|
2327
2364
|
}
|
|
2328
2365
|
if (!environment.NODE_AUTH_TOKEN) {
|
|
@@ -2338,7 +2375,7 @@ function npmPreflight(workspaceRoot, registryKind, environment, processes, log)
|
|
|
2338
2375
|
return 0;
|
|
2339
2376
|
}
|
|
2340
2377
|
async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetchStatus) {
|
|
2341
|
-
const files = (0,
|
|
2378
|
+
const files = (0, import_node_fs5.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot });
|
|
2342
2379
|
if (registryKind !== "npm" || files.length === 0) {
|
|
2343
2380
|
return 0;
|
|
2344
2381
|
}
|
|
@@ -2351,7 +2388,7 @@ async function pypiPreflight(workspaceRoot, registryKind, environment, log, fetc
|
|
|
2351
2388
|
return 1;
|
|
2352
2389
|
}
|
|
2353
2390
|
const names = files.map((file) => {
|
|
2354
|
-
const text = (0,
|
|
2391
|
+
const text = (0, import_node_fs5.readFileSync)((0, import_node_path5.join)(workspaceRoot, file), "utf8");
|
|
2355
2392
|
const block = text.slice(text.indexOf("[project]"));
|
|
2356
2393
|
const line = block.split("\n").find((entry) => entry.trimStart().startsWith("name"));
|
|
2357
2394
|
return line ? line.split("=", 2)[1].replaceAll(/[^\w.-]/gi, "") : "";
|
|
@@ -2424,6 +2461,15 @@ function runReleaseCommand(workspaceRoot, registry, counts, environment, process
|
|
|
2424
2461
|
}
|
|
2425
2462
|
return processes.run("npx", ["nx", "release", ...extra, "--yes"]);
|
|
2426
2463
|
}
|
|
2464
|
+
function afterRelease(workspaceRoot, processes) {
|
|
2465
|
+
if ((0, import_node_fs5.existsSync)((0, import_node_path5.join)(workspaceRoot, "tools", "go-app-release.cjs"))) {
|
|
2466
|
+
const assets = processes.run("node", ["tools/go-app-release.cjs", "assets"]);
|
|
2467
|
+
if (assets !== 0) {
|
|
2468
|
+
return assets;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
return processes.run("git", ["push", "origin", "--tags"]);
|
|
2472
|
+
}
|
|
2427
2473
|
async function runRelease(workspaceRoot, dependencies = {}) {
|
|
2428
2474
|
const environment = dependencies.environment ?? process.env;
|
|
2429
2475
|
const processes = dependencies.processes ?? {
|
|
@@ -2459,7 +2505,11 @@ async function runRelease(workspaceRoot, dependencies = {}) {
|
|
|
2459
2505
|
if (pypi !== 0) {
|
|
2460
2506
|
return close(pypi);
|
|
2461
2507
|
}
|
|
2462
|
-
|
|
2508
|
+
const released = runReleaseCommand(workspaceRoot, registry, releasableCounts(workspaceRoot), environment, processes, log);
|
|
2509
|
+
if (released !== 0) {
|
|
2510
|
+
return close(released);
|
|
2511
|
+
}
|
|
2512
|
+
return close(afterRelease(workspaceRoot, processes));
|
|
2463
2513
|
}
|
|
2464
2514
|
|
|
2465
2515
|
// src/ci-pipeline/verify.use-case.ts
|
|
@@ -2513,7 +2563,7 @@ function runVerify(workspaceRoot, dependencies = {}) {
|
|
|
2513
2563
|
}
|
|
2514
2564
|
|
|
2515
2565
|
// src/ci-pipeline/index.ts
|
|
2516
|
-
var CI_PHASES = ["verify", "pack", "release"];
|
|
2566
|
+
var CI_PHASES = ["verify", "pack", "release", "native"];
|
|
2517
2567
|
function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
2518
2568
|
switch (phase) {
|
|
2519
2569
|
case "verify": {
|
|
@@ -2525,11 +2575,14 @@ function runCiPhase(phase, workspaceRoot, dependencies = {}) {
|
|
|
2525
2575
|
case "release": {
|
|
2526
2576
|
return runRelease(workspaceRoot, dependencies);
|
|
2527
2577
|
}
|
|
2578
|
+
case "native": {
|
|
2579
|
+
return runNative(workspaceRoot, dependencies);
|
|
2580
|
+
}
|
|
2528
2581
|
}
|
|
2529
2582
|
}
|
|
2530
2583
|
|
|
2531
2584
|
// src/project-scaffolding/add-project.use-case.ts
|
|
2532
|
-
var
|
|
2585
|
+
var import_node_path26 = require("path");
|
|
2533
2586
|
var import_prompts3 = require("@inquirer/prompts");
|
|
2534
2587
|
|
|
2535
2588
|
// src/project-name/project-name.validator.ts
|
|
@@ -2542,8 +2595,8 @@ function assertValidProjectName(name, label) {
|
|
|
2542
2595
|
}
|
|
2543
2596
|
|
|
2544
2597
|
// src/project-scaffolding/csharp.use-case.ts
|
|
2545
|
-
var
|
|
2546
|
-
var
|
|
2598
|
+
var import_node_fs7 = require("fs");
|
|
2599
|
+
var import_node_path7 = require("path");
|
|
2547
2600
|
|
|
2548
2601
|
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
2549
2602
|
function csharpExampleFiles(identity) {
|
|
@@ -2584,10 +2637,10 @@ public class GreetUseCaseTests
|
|
|
2584
2637
|
}
|
|
2585
2638
|
|
|
2586
2639
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2587
|
-
var
|
|
2588
|
-
var
|
|
2640
|
+
var import_node_fs6 = require("fs");
|
|
2641
|
+
var import_node_path6 = require("path");
|
|
2589
2642
|
function hasPlugin(workspaceRoot, packageName) {
|
|
2590
|
-
const manifest = readJson((0,
|
|
2643
|
+
const manifest = readJson((0, import_node_path6.join)(workspaceRoot, "package.json"));
|
|
2591
2644
|
const installed = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
2592
2645
|
return Object.hasOwn(installed, packageName);
|
|
2593
2646
|
}
|
|
@@ -2626,7 +2679,7 @@ function markPublic(manifestPath) {
|
|
|
2626
2679
|
function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
2627
2680
|
const runner = testRunner === "vitest" ? "[Vitest](https://vitest.dev)" : "[Jest](https://jestjs.io)";
|
|
2628
2681
|
writeFileEnsured(
|
|
2629
|
-
(0,
|
|
2682
|
+
(0, import_node_path6.join)(projectRoot, "README.md"),
|
|
2630
2683
|
[
|
|
2631
2684
|
`# ${projectName}`,
|
|
2632
2685
|
"",
|
|
@@ -2645,13 +2698,13 @@ function writeProjectReadme(projectRoot, projectName, testRunner) {
|
|
|
2645
2698
|
}
|
|
2646
2699
|
function removeStaleGitkeeps(workspaceRoot) {
|
|
2647
2700
|
for (const scaffold of ["apps", "libs", "packages"]) {
|
|
2648
|
-
const directory = (0,
|
|
2701
|
+
const directory = (0, import_node_path6.join)(workspaceRoot, scaffold);
|
|
2649
2702
|
try {
|
|
2650
|
-
const holdsAProject = (0,
|
|
2703
|
+
const holdsAProject = (0, import_node_fs6.readdirSync)(directory, { withFileTypes: true }).some(
|
|
2651
2704
|
(entry) => entry.isDirectory()
|
|
2652
2705
|
);
|
|
2653
2706
|
if (holdsAProject) {
|
|
2654
|
-
(0,
|
|
2707
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(directory, ".gitkeep"), { force: true });
|
|
2655
2708
|
}
|
|
2656
2709
|
} catch {
|
|
2657
2710
|
}
|
|
@@ -2671,7 +2724,7 @@ function ensureAdmZip(workspaceRoot) {
|
|
|
2671
2724
|
}
|
|
2672
2725
|
}
|
|
2673
2726
|
function defaultScope(workspaceRoot) {
|
|
2674
|
-
const { name } = readJson((0,
|
|
2727
|
+
const { name } = readJson((0, import_node_path6.join)(workspaceRoot, "package.json"));
|
|
2675
2728
|
const base = (name.startsWith("@") ? name.slice(1) : name).split("/", 1)[0];
|
|
2676
2729
|
return `@${base}`;
|
|
2677
2730
|
}
|
|
@@ -2699,14 +2752,14 @@ var ESLINT_CONFIG_FILENAMES = [
|
|
|
2699
2752
|
];
|
|
2700
2753
|
function removeGeneratedEslintConfig(workspaceRoot, projectRoot) {
|
|
2701
2754
|
for (const filename of ESLINT_CONFIG_FILENAMES) {
|
|
2702
|
-
(0,
|
|
2755
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(workspaceRoot, projectRoot, filename), { force: true });
|
|
2703
2756
|
}
|
|
2704
|
-
(0,
|
|
2757
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(workspaceRoot, ".vscode"), { recursive: true, force: true });
|
|
2705
2758
|
}
|
|
2706
2759
|
function findCodeWorkspaceFile(workspaceRoot) {
|
|
2707
2760
|
try {
|
|
2708
|
-
const entry = (0,
|
|
2709
|
-
return entry ? (0,
|
|
2761
|
+
const entry = (0, import_node_fs6.readdirSync)(workspaceRoot).find((file) => file.endsWith(".code-workspace"));
|
|
2762
|
+
return entry ? (0, import_node_path6.join)(workspaceRoot, entry) : void 0;
|
|
2710
2763
|
} catch {
|
|
2711
2764
|
return void 0;
|
|
2712
2765
|
}
|
|
@@ -2723,8 +2776,8 @@ function reshapeReactScaffold(projectRoot, name, empty = false) {
|
|
|
2723
2776
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component", empty);
|
|
2724
2777
|
}
|
|
2725
2778
|
function reshapeReactAppScaffold(projectRoot) {
|
|
2726
|
-
const appDir = (0,
|
|
2727
|
-
if (!(0,
|
|
2779
|
+
const appDir = (0, import_node_path6.join)(projectRoot, "src", "app");
|
|
2780
|
+
if (!(0, import_node_fs6.existsSync)((0, import_node_path6.join)(appDir, "app.tsx"))) {
|
|
2728
2781
|
return;
|
|
2729
2782
|
}
|
|
2730
2783
|
for (const [from, to] of [
|
|
@@ -2732,60 +2785,60 @@ function reshapeReactAppScaffold(projectRoot) {
|
|
|
2732
2785
|
["app.spec.tsx", "app.component.spec.tsx"],
|
|
2733
2786
|
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
2734
2787
|
]) {
|
|
2735
|
-
if ((0,
|
|
2736
|
-
(0,
|
|
2788
|
+
if ((0, import_node_fs6.existsSync)((0, import_node_path6.join)(appDir, from))) {
|
|
2789
|
+
(0, import_node_fs6.renameSync)((0, import_node_path6.join)(appDir, from), (0, import_node_path6.join)(appDir, to));
|
|
2737
2790
|
}
|
|
2738
2791
|
}
|
|
2739
2792
|
const rewrite = (file, from, to) => {
|
|
2740
|
-
if ((0,
|
|
2741
|
-
writeFileEnsured(file, repointSpecifier((0,
|
|
2793
|
+
if ((0, import_node_fs6.existsSync)(file)) {
|
|
2794
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs6.readFileSync)(file, "utf8"), from, to));
|
|
2742
2795
|
}
|
|
2743
2796
|
};
|
|
2744
|
-
rewrite((0,
|
|
2745
|
-
rewrite((0,
|
|
2746
|
-
rewrite((0,
|
|
2797
|
+
rewrite((0, import_node_path6.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
2798
|
+
rewrite((0, import_node_path6.join)(appDir, "app.component.spec.tsx"), "./app", "./app.component");
|
|
2799
|
+
rewrite((0, import_node_path6.join)(projectRoot, "src", "main.tsx"), "./app/app", "./app");
|
|
2747
2800
|
writeFileEnsured(
|
|
2748
|
-
(0,
|
|
2801
|
+
(0, import_node_path6.join)(appDir, "index.ts"),
|
|
2749
2802
|
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
2750
2803
|
);
|
|
2751
2804
|
}
|
|
2752
2805
|
function emptySlice(projectRoot, sliceDir) {
|
|
2753
|
-
for (const entry of (0,
|
|
2754
|
-
(0,
|
|
2806
|
+
for (const entry of (0, import_node_fs6.readdirSync)(sliceDir)) {
|
|
2807
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(sliceDir, entry), { recursive: true, force: true });
|
|
2755
2808
|
}
|
|
2756
|
-
writeFileEnsured((0,
|
|
2757
|
-
addNxTargets((0,
|
|
2809
|
+
writeFileEnsured((0, import_node_path6.join)(sliceDir, "index.ts"), "export {}\n");
|
|
2810
|
+
addNxTargets((0, import_node_path6.join)(projectRoot, "package.json"), { test: { options: { passWithNoTests: true } } });
|
|
2758
2811
|
}
|
|
2759
2812
|
function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
2760
|
-
const sourceDir = (0,
|
|
2761
|
-
const libDir = (0,
|
|
2762
|
-
if (!(0,
|
|
2813
|
+
const sourceDir = (0, import_node_path6.join)(projectRoot, "src");
|
|
2814
|
+
const libDir = (0, import_node_path6.join)(sourceDir, "lib");
|
|
2815
|
+
if (!(0, import_node_fs6.existsSync)((0, import_node_path6.join)(libDir, `${name}.${extension}`))) {
|
|
2763
2816
|
return;
|
|
2764
2817
|
}
|
|
2765
|
-
const sliceDir = (0,
|
|
2766
|
-
(0,
|
|
2767
|
-
for (const entry of (0,
|
|
2818
|
+
const sliceDir = (0, import_node_path6.join)(sourceDir, name);
|
|
2819
|
+
(0, import_node_fs6.mkdirSync)(sliceDir, { recursive: true });
|
|
2820
|
+
for (const entry of (0, import_node_fs6.readdirSync)(libDir)) {
|
|
2768
2821
|
if (entry === `${name}.${extension}`) {
|
|
2769
|
-
(0,
|
|
2822
|
+
(0, import_node_fs6.renameSync)((0, import_node_path6.join)(libDir, entry), (0, import_node_path6.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
2770
2823
|
} else if (entry === `${name}.spec.${extension}`) {
|
|
2771
|
-
const renamed = (0,
|
|
2772
|
-
(0,
|
|
2773
|
-
writeFileEnsured(renamed, repointSpecifier((0,
|
|
2824
|
+
const renamed = (0, import_node_path6.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
2825
|
+
(0, import_node_fs6.renameSync)((0, import_node_path6.join)(libDir, entry), renamed);
|
|
2826
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs6.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
2774
2827
|
} else {
|
|
2775
|
-
(0,
|
|
2828
|
+
(0, import_node_fs6.renameSync)((0, import_node_path6.join)(libDir, entry), (0, import_node_path6.join)(sliceDir, entry));
|
|
2776
2829
|
}
|
|
2777
2830
|
}
|
|
2778
|
-
const barrel = (0,
|
|
2779
|
-
const esm = (0,
|
|
2780
|
-
writeFileEnsured((0,
|
|
2831
|
+
const barrel = (0, import_node_path6.join)(sourceDir, "index.ts");
|
|
2832
|
+
const esm = (0, import_node_fs6.existsSync)(barrel) && (0, import_node_fs6.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
2833
|
+
writeFileEnsured((0, import_node_path6.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
2781
2834
|
`);
|
|
2782
|
-
if ((0,
|
|
2835
|
+
if ((0, import_node_fs6.existsSync)(barrel)) {
|
|
2783
2836
|
writeFileEnsured(
|
|
2784
2837
|
barrel,
|
|
2785
|
-
(0,
|
|
2838
|
+
(0, import_node_fs6.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2786
2839
|
);
|
|
2787
2840
|
}
|
|
2788
|
-
(0,
|
|
2841
|
+
(0, import_node_fs6.rmSync)(libDir, { recursive: true, force: true });
|
|
2789
2842
|
if (empty) {
|
|
2790
2843
|
emptySlice(projectRoot, sliceDir);
|
|
2791
2844
|
} else if (role === "use-case") {
|
|
@@ -2795,7 +2848,7 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
2795
2848
|
function writeWorkedExample(sliceDir, name, esm) {
|
|
2796
2849
|
const suffix = esm ? ".js" : "";
|
|
2797
2850
|
writeFileEnsured(
|
|
2798
|
-
(0,
|
|
2851
|
+
(0, import_node_path6.join)(sliceDir, `${name}.contract.ts`),
|
|
2799
2852
|
`/** What greeting someone returns. */
|
|
2800
2853
|
export interface Greeting {
|
|
2801
2854
|
readonly message: string
|
|
@@ -2803,7 +2856,7 @@ export interface Greeting {
|
|
|
2803
2856
|
`
|
|
2804
2857
|
);
|
|
2805
2858
|
writeFileEnsured(
|
|
2806
|
-
(0,
|
|
2859
|
+
(0, import_node_path6.join)(sliceDir, `${name}.use-case.ts`),
|
|
2807
2860
|
`import type { Greeting } from './${name}.contract${suffix}'
|
|
2808
2861
|
|
|
2809
2862
|
/**
|
|
@@ -2822,7 +2875,7 @@ export function greet (name: string): Greeting {
|
|
|
2822
2875
|
`
|
|
2823
2876
|
);
|
|
2824
2877
|
writeFileEnsured(
|
|
2825
|
-
(0,
|
|
2878
|
+
(0, import_node_path6.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
2826
2879
|
`import { greet } from './${name}.use-case${suffix}'
|
|
2827
2880
|
|
|
2828
2881
|
describe('greet', () => {
|
|
@@ -2833,7 +2886,7 @@ describe('greet', () => {
|
|
|
2833
2886
|
`
|
|
2834
2887
|
);
|
|
2835
2888
|
writeFileEnsured(
|
|
2836
|
-
(0,
|
|
2889
|
+
(0, import_node_path6.join)(sliceDir, "index.ts"),
|
|
2837
2890
|
`export * from './${name}.contract${suffix}'
|
|
2838
2891
|
export * from './${name}.use-case${suffix}'
|
|
2839
2892
|
`
|
|
@@ -2847,8 +2900,8 @@ function repointSpecifier(source, from, to) {
|
|
|
2847
2900
|
return result;
|
|
2848
2901
|
}
|
|
2849
2902
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2850
|
-
const manifestPath = (0,
|
|
2851
|
-
if (!(0,
|
|
2903
|
+
const manifestPath = (0, import_node_path6.join)(workspaceRoot, "package.json");
|
|
2904
|
+
if (!(0, import_node_fs6.existsSync)(manifestPath)) {
|
|
2852
2905
|
return;
|
|
2853
2906
|
}
|
|
2854
2907
|
const manifest = readJson(manifestPath);
|
|
@@ -2871,11 +2924,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2871
2924
|
if (commands.start) {
|
|
2872
2925
|
scripts[`${name}:start`] = commands.start;
|
|
2873
2926
|
}
|
|
2874
|
-
const dependabotPath = (0,
|
|
2875
|
-
if ((0,
|
|
2927
|
+
const dependabotPath = (0, import_node_path6.join)(workspaceRoot, ".github/dependabot.yml");
|
|
2928
|
+
if ((0, import_node_fs6.existsSync)(dependabotPath)) {
|
|
2876
2929
|
writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
|
|
2877
2930
|
}
|
|
2878
|
-
const manifestPath = (0,
|
|
2931
|
+
const manifestPath = (0, import_node_path6.join)(workspaceRoot, "package.json");
|
|
2879
2932
|
const manifest = readJson(manifestPath);
|
|
2880
2933
|
const existingScripts = manifest.scripts ?? {};
|
|
2881
2934
|
writeFileEnsured(
|
|
@@ -2913,7 +2966,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
2913
2966
|
var PROJECT_MANIFEST_ROOTS = ["apps", "packages", "libs"];
|
|
2914
2967
|
function rootRuntimeDependencies(workspaceRoot) {
|
|
2915
2968
|
try {
|
|
2916
|
-
return readJson((0,
|
|
2969
|
+
return readJson((0, import_node_path6.join)(workspaceRoot, "package.json")).dependencies ?? {};
|
|
2917
2970
|
} catch {
|
|
2918
2971
|
return {};
|
|
2919
2972
|
}
|
|
@@ -2925,7 +2978,7 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2925
2978
|
return;
|
|
2926
2979
|
}
|
|
2927
2980
|
const manifestPath = PROJECT_MANIFEST_ROOTS.map(
|
|
2928
|
-
(root) => (0,
|
|
2981
|
+
(root) => (0, import_node_path6.join)(workspaceRoot, root, projectName, "package.json")
|
|
2929
2982
|
).find((candidate) => fileExists(candidate));
|
|
2930
2983
|
if (manifestPath === void 0) {
|
|
2931
2984
|
return;
|
|
@@ -2937,10 +2990,10 @@ function relocateRootRuntimeDependencies(workspaceRoot, projectName, before) {
|
|
|
2937
2990
|
const remaining = Object.fromEntries(
|
|
2938
2991
|
Object.entries(after).filter(([name]) => !added.includes(name))
|
|
2939
2992
|
);
|
|
2940
|
-
const rootManifest = readJson((0,
|
|
2993
|
+
const rootManifest = readJson((0, import_node_path6.join)(workspaceRoot, "package.json"));
|
|
2941
2994
|
const { dependencies: _dropped, ...rest } = rootManifest;
|
|
2942
2995
|
writeFileEnsured(
|
|
2943
|
-
(0,
|
|
2996
|
+
(0, import_node_path6.join)(workspaceRoot, "package.json"),
|
|
2944
2997
|
toJson(Object.keys(remaining).length > 0 ? { ...rest, dependencies: remaining } : rest)
|
|
2945
2998
|
);
|
|
2946
2999
|
logger.step(`Moved ${added.join(", ")} into ${projectName}'s own manifest`);
|
|
@@ -2979,28 +3032,28 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
2979
3032
|
}
|
|
2980
3033
|
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
2981
3034
|
if (kind === "classlib") {
|
|
2982
|
-
(0,
|
|
3035
|
+
(0, import_node_fs7.rmSync)((0, import_node_path7.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
2983
3036
|
}
|
|
2984
3037
|
const files = csharpExampleFiles(identity);
|
|
2985
3038
|
for (const [file, contents] of Object.entries(files)) {
|
|
2986
|
-
writeFileEnsured((0,
|
|
3039
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, file), contents);
|
|
2987
3040
|
}
|
|
2988
3041
|
if (kind === "console") {
|
|
2989
|
-
writeFileEnsured((0,
|
|
3042
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
2990
3043
|
}
|
|
2991
3044
|
}
|
|
2992
3045
|
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
2993
|
-
const name = (0,
|
|
3046
|
+
const name = (0, import_node_path7.basename)(projectRoot);
|
|
2994
3047
|
const testRoot = `tests/${name}`;
|
|
2995
3048
|
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
2996
|
-
(0,
|
|
2997
|
-
writeFileEnsured((0,
|
|
3049
|
+
(0, import_node_fs7.rmSync)((0, import_node_path7.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
3050
|
+
writeFileEnsured((0, import_node_path7.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
2998
3051
|
writeFileEnsured(
|
|
2999
|
-
(0,
|
|
3052
|
+
(0, import_node_path7.join)(workspaceRoot, testRoot, "project.json"),
|
|
3000
3053
|
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
3001
3054
|
);
|
|
3002
|
-
const reference = (0,
|
|
3003
|
-
if (runShell("dotnet", ["add", (0,
|
|
3055
|
+
const reference = (0, import_node_path7.join)(workspaceRoot, projectRoot, `${identity}.csproj`);
|
|
3056
|
+
if (runShell("dotnet", ["add", (0, import_node_path7.join)(workspaceRoot, testRoot), "reference", reference], workspaceRoot) !== 0) {
|
|
3004
3057
|
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
3005
3058
|
}
|
|
3006
3059
|
}
|
|
@@ -3027,9 +3080,9 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
3027
3080
|
ensureAdmZip(workspaceRoot);
|
|
3028
3081
|
const projectRoot = `apps/${name}`;
|
|
3029
3082
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
3030
|
-
writeCsharpExample((0,
|
|
3083
|
+
writeCsharpExample((0, import_node_path7.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3031
3084
|
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
3032
|
-
addProjectJsonTargets((0,
|
|
3085
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3033
3086
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
3034
3087
|
start: csharpAppStartTarget(projectRoot)
|
|
3035
3088
|
});
|
|
@@ -3122,7 +3175,7 @@ class CsharpVersionActions extends VersionActions {
|
|
|
3122
3175
|
module.exports = CsharpVersionActions
|
|
3123
3176
|
`;
|
|
3124
3177
|
function writeCsharpVersionActions(workspaceRoot) {
|
|
3125
|
-
writeFileEnsured((0,
|
|
3178
|
+
writeFileEnsured((0, import_node_path7.join)(workspaceRoot, CSHARP_VERSION_ACTIONS_PATH), CSHARP_VERSION_ACTIONS);
|
|
3126
3179
|
}
|
|
3127
3180
|
function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
3128
3181
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
@@ -3137,7 +3190,7 @@ function addProjectJsonReleaseVersionActions(projectJsonPath) {
|
|
|
3137
3190
|
);
|
|
3138
3191
|
}
|
|
3139
3192
|
function addInitialVersion(csprojPath) {
|
|
3140
|
-
const contents = (0,
|
|
3193
|
+
const contents = (0, import_node_fs7.readFileSync)(csprojPath, "utf8");
|
|
3141
3194
|
writeFileEnsured(csprojPath, contents.replace("<PropertyGroup>", "<PropertyGroup>\n <Version>0.1.0</Version>"));
|
|
3142
3195
|
}
|
|
3143
3196
|
function csharpLibPublishTarget(projectRoot) {
|
|
@@ -3152,16 +3205,16 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3152
3205
|
const projectRoot = `packages/${name}`;
|
|
3153
3206
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3154
3207
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3155
|
-
writeCsharpExample((0,
|
|
3208
|
+
writeCsharpExample((0, import_node_path7.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3156
3209
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3157
|
-
addInitialVersion((0,
|
|
3210
|
+
addInitialVersion((0, import_node_path7.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3158
3211
|
writeCsharpVersionActions(workspaceRoot);
|
|
3159
|
-
addProjectJsonReleaseVersionActions((0,
|
|
3160
|
-
addProjectJsonTargets((0,
|
|
3212
|
+
addProjectJsonReleaseVersionActions((0, import_node_path7.join)(workspaceRoot, projectRoot, "project.json"));
|
|
3213
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
3161
3214
|
"nx-release-publish": csharpLibPublishTarget(projectRoot)
|
|
3162
3215
|
});
|
|
3163
3216
|
const registry = readMnciConfig(workspaceRoot).registry ?? { kind: "npm" };
|
|
3164
|
-
writeFileEnsured((0,
|
|
3217
|
+
writeFileEnsured((0, import_node_path7.join)(workspaceRoot, "nuget.config"), nugetConfigContent(registry, scope));
|
|
3165
3218
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
3166
3219
|
}
|
|
3167
3220
|
function addCsharpInternalLib(workspaceRoot, name) {
|
|
@@ -3170,7 +3223,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3170
3223
|
const projectRoot = `libs/${name}`;
|
|
3171
3224
|
const identity = pascalCase(name);
|
|
3172
3225
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3173
|
-
writeCsharpExample((0,
|
|
3226
|
+
writeCsharpExample((0, import_node_path7.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3174
3227
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3175
3228
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3176
3229
|
logger.step(
|
|
@@ -3239,20 +3292,20 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3239
3292
|
const projectRoot = `apps/${name}`;
|
|
3240
3293
|
const identity = pascalCase(name);
|
|
3241
3294
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "console");
|
|
3242
|
-
const absoluteRoot = (0,
|
|
3243
|
-
writeFileEnsured((0,
|
|
3244
|
-
writeFileEnsured((0,
|
|
3245
|
-
writeFileEnsured((0,
|
|
3295
|
+
const absoluteRoot = (0, import_node_path7.join)(workspaceRoot, projectRoot);
|
|
3296
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
3297
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
3298
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3246
3299
|
const example = csharpExampleFiles(identity);
|
|
3247
3300
|
for (const [file, contents] of Object.entries(example)) {
|
|
3248
|
-
writeFileEnsured((0,
|
|
3301
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, file), contents);
|
|
3249
3302
|
}
|
|
3250
|
-
writeFileEnsured((0,
|
|
3303
|
+
writeFileEnsured((0, import_node_path7.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3251
3304
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3252
3305
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3253
3306
|
}
|
|
3254
3307
|
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3255
|
-
addProjectJsonTargets((0,
|
|
3308
|
+
addProjectJsonTargets((0, import_node_path7.join)(absoluteRoot, "project.json"), {
|
|
3256
3309
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3257
3310
|
start: csharpFunctionAppStartTarget(projectRoot)
|
|
3258
3311
|
});
|
|
@@ -3260,7 +3313,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3260
3313
|
}
|
|
3261
3314
|
|
|
3262
3315
|
// src/project-scaffolding/flutter.use-case.ts
|
|
3263
|
-
var
|
|
3316
|
+
var import_node_path8 = require("path");
|
|
3264
3317
|
function flutterAppStartTarget(name) {
|
|
3265
3318
|
return {
|
|
3266
3319
|
executor: "nx:run-commands",
|
|
@@ -3296,7 +3349,7 @@ function addFlutterApp(workspaceRoot, name) {
|
|
|
3296
3349
|
prepareFlutter(workspaceRoot);
|
|
3297
3350
|
ensureAdmZip(workspaceRoot);
|
|
3298
3351
|
runNx(["g", "@mnci/nx-flutter:application", name, "--no-interactive"], workspaceRoot);
|
|
3299
|
-
addProjectJsonTargets((0,
|
|
3352
|
+
addProjectJsonTargets((0, import_node_path8.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3300
3353
|
start: flutterAppStartTarget(name)
|
|
3301
3354
|
});
|
|
3302
3355
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -3313,8 +3366,8 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
3313
3366
|
}
|
|
3314
3367
|
|
|
3315
3368
|
// src/project-scaffolding/go.use-case.ts
|
|
3316
|
-
var
|
|
3317
|
-
var
|
|
3369
|
+
var import_node_fs11 = require("fs");
|
|
3370
|
+
var import_node_path12 = require("path");
|
|
3318
3371
|
|
|
3319
3372
|
// src/project-scaffolding/go-example.algorithm.ts
|
|
3320
3373
|
function greetingContract(packageName) {
|
|
@@ -3383,14 +3436,14 @@ function goAppExampleFiles(modulePath) {
|
|
|
3383
3436
|
}
|
|
3384
3437
|
|
|
3385
3438
|
// src/go-workspace/go-plugin.use-case.ts
|
|
3386
|
-
var
|
|
3387
|
-
var
|
|
3439
|
+
var import_node_fs8 = require("fs");
|
|
3440
|
+
var import_node_path9 = require("path");
|
|
3388
3441
|
var NX_GO_PLUGIN = "@nx-go/nx-go";
|
|
3389
3442
|
function hasGoProject(workspaceRoot) {
|
|
3390
|
-
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0,
|
|
3443
|
+
const projectFiles = ["apps", "libs", "packages"].flatMap((directory) => (0, import_node_fs8.globSync)(`${directory}/*/project.json`, { cwd: workspaceRoot }));
|
|
3391
3444
|
return projectFiles.some((projectFile) => {
|
|
3392
3445
|
try {
|
|
3393
|
-
const { tags } = JSON.parse((0,
|
|
3446
|
+
const { tags } = JSON.parse((0, import_node_fs8.readFileSync)((0, import_node_path9.join)(workspaceRoot, projectFile), "utf8"));
|
|
3394
3447
|
return (tags ?? []).some((tag) => tag.startsWith("type:go-"));
|
|
3395
3448
|
} catch {
|
|
3396
3449
|
return false;
|
|
@@ -3398,7 +3451,7 @@ function hasGoProject(workspaceRoot) {
|
|
|
3398
3451
|
});
|
|
3399
3452
|
}
|
|
3400
3453
|
function isNxGoPluginRegistered(workspaceRoot) {
|
|
3401
|
-
const nxJsonPath = (0,
|
|
3454
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
3402
3455
|
if (!fileExists(nxJsonPath)) {
|
|
3403
3456
|
return false;
|
|
3404
3457
|
}
|
|
@@ -3425,7 +3478,7 @@ function goModulePrefix(workspaceRoot) {
|
|
|
3425
3478
|
return result.status === 0 ? modulePrefixFromRemoteUrl(result.stdout) : void 0;
|
|
3426
3479
|
}
|
|
3427
3480
|
function registerNxGoPlugin(workspaceRoot) {
|
|
3428
|
-
const nxJsonPath = (0,
|
|
3481
|
+
const nxJsonPath = (0, import_node_path9.join)(workspaceRoot, "nx.json");
|
|
3429
3482
|
if (!fileExists(nxJsonPath)) {
|
|
3430
3483
|
return false;
|
|
3431
3484
|
}
|
|
@@ -3449,8 +3502,8 @@ function registerNxGoPlugin(workspaceRoot) {
|
|
|
3449
3502
|
}
|
|
3450
3503
|
|
|
3451
3504
|
// src/project-scaffolding/go-release.use-case.ts
|
|
3452
|
-
var
|
|
3453
|
-
var
|
|
3505
|
+
var import_node_fs9 = require("fs");
|
|
3506
|
+
var import_node_path10 = require("path");
|
|
3454
3507
|
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
3455
3508
|
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3456
3509
|
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
@@ -3576,7 +3629,7 @@ var GO_RELEASE_PUBLISH_TARGET = {
|
|
|
3576
3629
|
}
|
|
3577
3630
|
};
|
|
3578
3631
|
function makeGoAppReleasable(workspaceRoot, name) {
|
|
3579
|
-
const projectJsonPath = (0,
|
|
3632
|
+
const projectJsonPath = (0, import_node_path10.join)(workspaceRoot, "apps", name, "project.json");
|
|
3580
3633
|
if (!fileExists(projectJsonPath)) {
|
|
3581
3634
|
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
3582
3635
|
}
|
|
@@ -3597,22 +3650,22 @@ function makeGoAppReleasable(workspaceRoot, name) {
|
|
|
3597
3650
|
}
|
|
3598
3651
|
})
|
|
3599
3652
|
);
|
|
3600
|
-
writeFileEnsured((0,
|
|
3653
|
+
writeFileEnsured((0, import_node_path10.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
3601
3654
|
}
|
|
3602
3655
|
function refreshGoReleaseScript(workspaceRoot) {
|
|
3603
|
-
const apps = (0,
|
|
3656
|
+
const apps = (0, import_node_path10.join)(workspaceRoot, "apps");
|
|
3604
3657
|
let entries;
|
|
3605
3658
|
try {
|
|
3606
|
-
entries = (0,
|
|
3659
|
+
entries = (0, import_node_fs9.readdirSync)(apps);
|
|
3607
3660
|
} catch {
|
|
3608
3661
|
return false;
|
|
3609
3662
|
}
|
|
3610
3663
|
const hasReleasableApp = entries.some((entry) => {
|
|
3611
|
-
const projectJsonPath = (0,
|
|
3664
|
+
const projectJsonPath = (0, import_node_path10.join)(apps, entry, "project.json");
|
|
3612
3665
|
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
3613
3666
|
});
|
|
3614
|
-
const path = (0,
|
|
3615
|
-
if (!hasReleasableApp || fileExists(path) && (0,
|
|
3667
|
+
const path = (0, import_node_path10.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
3668
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs9.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
3616
3669
|
return false;
|
|
3617
3670
|
}
|
|
3618
3671
|
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
@@ -3620,8 +3673,8 @@ function refreshGoReleaseScript(workspaceRoot) {
|
|
|
3620
3673
|
}
|
|
3621
3674
|
|
|
3622
3675
|
// src/project-scaffolding/go-web.use-case.ts
|
|
3623
|
-
var
|
|
3624
|
-
var
|
|
3676
|
+
var import_node_fs10 = require("fs");
|
|
3677
|
+
var import_node_path11 = require("path");
|
|
3625
3678
|
var TARGETS_NEEDING_THE_FRONTEND = ["build", "test", "lint", "start", "build-all", "build-native"];
|
|
3626
3679
|
var DEFAULT_ADDRESS = "127.0.0.1:8080";
|
|
3627
3680
|
var GO_WEB_SOURCE = `package main
|
|
@@ -3699,18 +3752,18 @@ func TestWebHandlerServesTheBuiltFrontend(t *testing.T) {
|
|
|
3699
3752
|
}
|
|
3700
3753
|
`;
|
|
3701
3754
|
function assertWebApp(workspaceRoot, web) {
|
|
3702
|
-
const directory = (0,
|
|
3703
|
-
const isReactApp = fileExists((0,
|
|
3755
|
+
const directory = (0, import_node_path11.join)(workspaceRoot, "apps", web);
|
|
3756
|
+
const isReactApp = fileExists((0, import_node_path11.join)(directory, "package.json")) && (0, import_node_fs10.readdirSync)(directory).some((entry) => entry.startsWith("vite.config."));
|
|
3704
3757
|
if (!isReactApp) {
|
|
3705
3758
|
throw new Error(`--web ${web}: no React app at apps/${web}. Add it first with \`mnci add react-app ${web}\`.`);
|
|
3706
3759
|
}
|
|
3707
3760
|
}
|
|
3708
3761
|
function webProjectName(workspaceRoot, web) {
|
|
3709
|
-
const manifest = readJson((0,
|
|
3762
|
+
const manifest = readJson((0, import_node_path11.join)(workspaceRoot, "apps", web, "package.json"));
|
|
3710
3763
|
return manifest.nx?.name ?? manifest.name ?? web;
|
|
3711
3764
|
}
|
|
3712
3765
|
function addApiProxy(viteConfigPath) {
|
|
3713
|
-
const source = (0,
|
|
3766
|
+
const source = (0, import_node_fs10.readFileSync)(viteConfigPath, "utf8");
|
|
3714
3767
|
if (source.includes("'/api'") || source.includes('"/api"')) {
|
|
3715
3768
|
return false;
|
|
3716
3769
|
}
|
|
@@ -3723,7 +3776,7 @@ function addApiProxy(viteConfigPath) {
|
|
|
3723
3776
|
return true;
|
|
3724
3777
|
}
|
|
3725
3778
|
function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
3726
|
-
const projectJsonPath = (0,
|
|
3779
|
+
const projectJsonPath = (0, import_node_path11.join)(workspaceRoot, "apps", name, "project.json");
|
|
3727
3780
|
const project = readJson(projectJsonPath);
|
|
3728
3781
|
const webName = webProjectName(workspaceRoot, web);
|
|
3729
3782
|
const targets = project.targets ?? {};
|
|
@@ -3749,13 +3802,13 @@ function wireGoAppToWeb(workspaceRoot, name, web) {
|
|
|
3749
3802
|
projectJsonPath,
|
|
3750
3803
|
toJson({ ...project, implicitDependencies: [.../* @__PURE__ */ new Set([...project.implicitDependencies ?? [], webName])], targets })
|
|
3751
3804
|
);
|
|
3752
|
-
const directory = (0,
|
|
3753
|
-
writeFileEnsured((0,
|
|
3754
|
-
writeFileEnsured((0,
|
|
3755
|
-
writeFileEnsured((0,
|
|
3756
|
-
writeFileEnsured((0,
|
|
3757
|
-
const viteConfig = (0,
|
|
3758
|
-
if (viteConfig === void 0 || !addApiProxy((0,
|
|
3805
|
+
const directory = (0, import_node_path11.join)(workspaceRoot, "apps", name);
|
|
3806
|
+
writeFileEnsured((0, import_node_path11.join)(directory, ".gitignore"), "/web/\n");
|
|
3807
|
+
writeFileEnsured((0, import_node_path11.join)(directory, "web.go"), GO_WEB_SOURCE);
|
|
3808
|
+
writeFileEnsured((0, import_node_path11.join)(directory, "main.go"), GO_WEB_MAIN);
|
|
3809
|
+
writeFileEnsured((0, import_node_path11.join)(directory, "main_test.go"), GO_WEB_MAIN_TEST);
|
|
3810
|
+
const viteConfig = (0, import_node_fs10.readdirSync)((0, import_node_path11.join)(workspaceRoot, "apps", web)).find((entry) => entry.startsWith("vite.config."));
|
|
3811
|
+
if (viteConfig === void 0 || !addApiProxy((0, import_node_path11.join)(workspaceRoot, "apps", web, viteConfig))) {
|
|
3759
3812
|
logger.warn(
|
|
3760
3813
|
`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.`
|
|
3761
3814
|
);
|
|
@@ -3789,7 +3842,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
3789
3842
|
}
|
|
3790
3843
|
}
|
|
3791
3844
|
function ensureGoModule(workspaceRoot) {
|
|
3792
|
-
if (fileExists((0,
|
|
3845
|
+
if (fileExists((0, import_node_path12.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path12.join)(workspaceRoot, "go.mod"))) {
|
|
3793
3846
|
return;
|
|
3794
3847
|
}
|
|
3795
3848
|
logger.step("Bootstrapping the Go workspace (go.work, one module per project)");
|
|
@@ -3797,38 +3850,38 @@ function ensureGoModule(workspaceRoot) {
|
|
|
3797
3850
|
}
|
|
3798
3851
|
function readGoModModule(goModPath) {
|
|
3799
3852
|
try {
|
|
3800
|
-
return /^module\s+(\S+)/m.exec((0,
|
|
3853
|
+
return /^module\s+(\S+)/m.exec((0, import_node_fs11.readFileSync)(goModPath, "utf8"))?.[1];
|
|
3801
3854
|
} catch {
|
|
3802
3855
|
return void 0;
|
|
3803
3856
|
}
|
|
3804
3857
|
}
|
|
3805
3858
|
function goModulePathFor(workspaceRoot, projectDir) {
|
|
3806
|
-
const projectModule = readGoModModule((0,
|
|
3859
|
+
const projectModule = readGoModModule((0, import_node_path12.join)(workspaceRoot, projectDir, "go.mod"));
|
|
3807
3860
|
if (projectModule !== void 0) {
|
|
3808
3861
|
return projectModule;
|
|
3809
3862
|
}
|
|
3810
|
-
const rootModule = readGoModModule((0,
|
|
3863
|
+
const rootModule = readGoModModule((0, import_node_path12.join)(workspaceRoot, "go.mod"));
|
|
3811
3864
|
return rootModule === void 0 ? void 0 : `${rootModule}/${projectDir}`;
|
|
3812
3865
|
}
|
|
3813
3866
|
function setGoModulePath(workspaceRoot, projectDir) {
|
|
3814
3867
|
const prefix = goModulePrefix(workspaceRoot);
|
|
3815
|
-
const goModPath = (0,
|
|
3868
|
+
const goModPath = (0, import_node_path12.join)(workspaceRoot, projectDir, "go.mod");
|
|
3816
3869
|
if (prefix === void 0 || !fileExists(goModPath)) {
|
|
3817
3870
|
return;
|
|
3818
3871
|
}
|
|
3819
|
-
const rewritten = (0,
|
|
3872
|
+
const rewritten = (0, import_node_fs11.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
3820
3873
|
writeFileEnsured(goModPath, rewritten);
|
|
3821
3874
|
}
|
|
3822
3875
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
3823
|
-
const goModPath = (0,
|
|
3824
|
-
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0,
|
|
3876
|
+
const goModPath = (0, import_node_path12.join)(workspaceRoot, projectDir, "go.mod");
|
|
3877
|
+
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs11.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
3825
3878
|
if (modulePath === void 0) {
|
|
3826
3879
|
return;
|
|
3827
3880
|
}
|
|
3828
|
-
(0,
|
|
3881
|
+
(0, import_node_fs11.rmSync)((0, import_node_path12.join)(workspaceRoot, projectDir, "main_test.go"), { force: true });
|
|
3829
3882
|
const example = goAppExampleFiles(modulePath);
|
|
3830
3883
|
for (const [relative, contents] of Object.entries(example)) {
|
|
3831
|
-
writeFileEnsured((0,
|
|
3884
|
+
writeFileEnsured((0, import_node_path12.join)(workspaceRoot, projectDir, relative), contents);
|
|
3832
3885
|
}
|
|
3833
3886
|
}
|
|
3834
3887
|
function goTestTarget() {
|
|
@@ -3906,16 +3959,16 @@ function goNativePackageTarget(name) {
|
|
|
3906
3959
|
}
|
|
3907
3960
|
function addGoPlatformTargets(workspaceRoot) {
|
|
3908
3961
|
const changed = [];
|
|
3909
|
-
const apps = (0,
|
|
3962
|
+
const apps = (0, import_node_path12.join)(workspaceRoot, "apps");
|
|
3910
3963
|
if (!fileExists(apps)) {
|
|
3911
3964
|
return changed;
|
|
3912
3965
|
}
|
|
3913
|
-
for (const name of (0,
|
|
3914
|
-
const projectJsonPath = (0,
|
|
3966
|
+
for (const name of (0, import_node_fs11.readdirSync)(apps)) {
|
|
3967
|
+
const projectJsonPath = (0, import_node_path12.join)(apps, name, "project.json");
|
|
3915
3968
|
if (!fileExists(projectJsonPath)) {
|
|
3916
3969
|
continue;
|
|
3917
3970
|
}
|
|
3918
|
-
const project = JSON.parse((0,
|
|
3971
|
+
const project = JSON.parse((0, import_node_fs11.readFileSync)(projectJsonPath, "utf8"));
|
|
3919
3972
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
3920
3973
|
if (tag === void 0 || (project.tags ?? []).includes(GO_CGO_TAG)) {
|
|
3921
3974
|
continue;
|
|
@@ -3951,8 +4004,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
3951
4004
|
}
|
|
3952
4005
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
3953
4006
|
const { packageName, fileStem } = goLibraryIdentifiers(projectName);
|
|
3954
|
-
(0,
|
|
3955
|
-
(0,
|
|
4007
|
+
(0, import_node_fs11.rmSync)((0, import_node_path12.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
4008
|
+
(0, import_node_fs11.rmSync)((0, import_node_path12.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
3956
4009
|
const files = [
|
|
3957
4010
|
[
|
|
3958
4011
|
"doc.go",
|
|
@@ -3962,7 +4015,7 @@ package ${packageName}
|
|
|
3962
4015
|
`
|
|
3963
4016
|
],
|
|
3964
4017
|
[
|
|
3965
|
-
(0,
|
|
4018
|
+
(0, import_node_path12.join)(packageName, "doc.go"),
|
|
3966
4019
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
3967
4020
|
// the outcome it delivers, and add one package per further outcome.
|
|
3968
4021
|
package ${packageName}
|
|
@@ -3970,11 +4023,11 @@ package ${packageName}
|
|
|
3970
4023
|
],
|
|
3971
4024
|
// The starter slice: a contract, a use case and its test (see goLibraryExampleFiles).
|
|
3972
4025
|
...Object.entries(goLibraryExampleFiles(packageName, fileStem)).map(
|
|
3973
|
-
([name, content]) => [(0,
|
|
4026
|
+
([name, content]) => [(0, import_node_path12.join)(packageName, name), content]
|
|
3974
4027
|
)
|
|
3975
4028
|
];
|
|
3976
4029
|
for (const [relativePath, content] of files) {
|
|
3977
|
-
const path = (0,
|
|
4030
|
+
const path = (0, import_node_path12.join)(projectRoot, relativePath);
|
|
3978
4031
|
if (!fileExists(path)) {
|
|
3979
4032
|
writeFileEnsured(path, content);
|
|
3980
4033
|
}
|
|
@@ -4012,7 +4065,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4012
4065
|
if (options.web === void 0) {
|
|
4013
4066
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4014
4067
|
}
|
|
4015
|
-
addProjectJsonTargets((0,
|
|
4068
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4016
4069
|
build: goBuildTarget(name),
|
|
4017
4070
|
test: goTestTarget(),
|
|
4018
4071
|
lint: goLintTarget(),
|
|
@@ -4052,7 +4105,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4052
4105
|
);
|
|
4053
4106
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4054
4107
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4055
|
-
addProjectJsonTargets((0,
|
|
4108
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4056
4109
|
"build": goBuildTarget(name),
|
|
4057
4110
|
"test": goTestTarget(),
|
|
4058
4111
|
"lint": goLintTarget(),
|
|
@@ -4076,11 +4129,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4076
4129
|
workspaceRoot
|
|
4077
4130
|
);
|
|
4078
4131
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4079
|
-
addProjectJsonTargets((0,
|
|
4132
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4080
4133
|
test: goTestTarget(),
|
|
4081
4134
|
lint: goLintTarget()
|
|
4082
4135
|
});
|
|
4083
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4136
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path12.join)(workspaceRoot, "packages", name), name);
|
|
4084
4137
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4085
4138
|
const module2 = goModulePathFor(workspaceRoot, `packages/${name}`);
|
|
4086
4139
|
if (module2) {
|
|
@@ -4101,11 +4154,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4101
4154
|
workspaceRoot
|
|
4102
4155
|
);
|
|
4103
4156
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4104
|
-
addProjectJsonTargets((0,
|
|
4157
|
+
addProjectJsonTargets((0, import_node_path12.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4105
4158
|
test: goTestTarget(),
|
|
4106
4159
|
lint: goLintTarget()
|
|
4107
4160
|
});
|
|
4108
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
4161
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path12.join)(workspaceRoot, "libs", name), name);
|
|
4109
4162
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
4110
4163
|
const module2 = goModulePathFor(workspaceRoot, `libs/${name}`);
|
|
4111
4164
|
if (module2) {
|
|
@@ -4114,7 +4167,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4114
4167
|
}
|
|
4115
4168
|
|
|
4116
4169
|
// src/project-scaffolding/node.use-case.ts
|
|
4117
|
-
var
|
|
4170
|
+
var import_node_path13 = require("path");
|
|
4118
4171
|
|
|
4119
4172
|
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
4120
4173
|
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
@@ -4237,12 +4290,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
4237
4290
|
],
|
|
4238
4291
|
workspaceRoot
|
|
4239
4292
|
);
|
|
4240
|
-
const appRoot = (0,
|
|
4293
|
+
const appRoot = (0, import_node_path13.join)(workspaceRoot, "apps", name);
|
|
4241
4294
|
separateDeclarationOutput(appRoot);
|
|
4242
4295
|
repairAssetMapping(appRoot, name);
|
|
4243
4296
|
}
|
|
4244
4297
|
function separateDeclarationOutput(appRoot) {
|
|
4245
|
-
const tsconfigPath = (0,
|
|
4298
|
+
const tsconfigPath = (0, import_node_path13.join)(appRoot, "tsconfig.app.json");
|
|
4246
4299
|
if (!fileExists(tsconfigPath)) {
|
|
4247
4300
|
return;
|
|
4248
4301
|
}
|
|
@@ -4264,7 +4317,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
4264
4317
|
);
|
|
4265
4318
|
}
|
|
4266
4319
|
function repairAssetMapping(appRoot, name) {
|
|
4267
|
-
const manifestPath = (0,
|
|
4320
|
+
const manifestPath = (0, import_node_path13.join)(appRoot, "package.json");
|
|
4268
4321
|
if (!fileExists(manifestPath)) {
|
|
4269
4322
|
return;
|
|
4270
4323
|
}
|
|
@@ -4293,11 +4346,11 @@ function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
|
4293
4346
|
const example = nodeAppExampleFiles(framework);
|
|
4294
4347
|
if (example !== null) {
|
|
4295
4348
|
for (const [relative, contents] of Object.entries(example)) {
|
|
4296
|
-
writeFileEnsured((0,
|
|
4349
|
+
writeFileEnsured((0, import_node_path13.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
4297
4350
|
}
|
|
4298
4351
|
}
|
|
4299
4352
|
ensureAdmZip(workspaceRoot);
|
|
4300
|
-
addNxTargets((0,
|
|
4353
|
+
addNxTargets((0, import_node_path13.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
4301
4354
|
package: nodeAppPackageTarget(name)
|
|
4302
4355
|
});
|
|
4303
4356
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -4366,10 +4419,10 @@ describe('greet', () => {
|
|
|
4366
4419
|
})
|
|
4367
4420
|
`;
|
|
4368
4421
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
4369
|
-
const manifestPath = (0,
|
|
4422
|
+
const manifestPath = (0, import_node_path13.join)(nodeFunctionAppRoot, "package.json");
|
|
4370
4423
|
const manifest = readJson(manifestPath);
|
|
4371
4424
|
const azureFunctionsVersion = readJson(
|
|
4372
|
-
(0,
|
|
4425
|
+
(0, import_node_path13.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
4373
4426
|
).version;
|
|
4374
4427
|
const dependencies = manifest.dependencies ?? {};
|
|
4375
4428
|
writeFileEnsured(
|
|
@@ -4412,20 +4465,20 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
4412
4465
|
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
4413
4466
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4414
4467
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4415
|
-
const nodeFunctionAppRoot = (0,
|
|
4416
|
-
writeFileEnsured((0,
|
|
4468
|
+
const nodeFunctionAppRoot = (0, import_node_path13.join)(workspaceRoot, "apps", name);
|
|
4469
|
+
writeFileEnsured((0, import_node_path13.join)(nodeFunctionAppRoot, "src/main.ts"), empty ? NODE_FUNCTION_APP_MAIN_EMPTY : NODE_FUNCTION_APP_MAIN);
|
|
4417
4470
|
if (!empty) {
|
|
4418
|
-
const slice = (0,
|
|
4419
|
-
writeFileEnsured((0,
|
|
4420
|
-
writeFileEnsured((0,
|
|
4421
|
-
writeFileEnsured((0,
|
|
4422
|
-
writeFileEnsured((0,
|
|
4423
|
-
writeFileEnsured((0,
|
|
4424
|
-
}
|
|
4425
|
-
writeFileEnsured((0,
|
|
4471
|
+
const slice = (0, import_node_path13.join)(nodeFunctionAppRoot, "src/hello");
|
|
4472
|
+
writeFileEnsured((0, import_node_path13.join)(slice, "hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
4473
|
+
writeFileEnsured((0, import_node_path13.join)(slice, "greet.use-case.ts"), NODE_FUNCTION_APP_GREET_USE_CASE);
|
|
4474
|
+
writeFileEnsured((0, import_node_path13.join)(slice, "greet.use-case.spec.ts"), NODE_FUNCTION_APP_GREET_SPEC);
|
|
4475
|
+
writeFileEnsured((0, import_node_path13.join)(slice, "greeting.contract.ts"), NODE_FUNCTION_APP_GREETING_CONTRACT);
|
|
4476
|
+
writeFileEnsured((0, import_node_path13.join)(slice, "index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
4477
|
+
}
|
|
4478
|
+
writeFileEnsured((0, import_node_path13.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
4426
4479
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4427
4480
|
ensureAdmZip(workspaceRoot);
|
|
4428
|
-
addNxTargets((0,
|
|
4481
|
+
addNxTargets((0, import_node_path13.join)(nodeFunctionAppRoot, "package.json"), {
|
|
4429
4482
|
package: nodeFunctionAppPackageTarget(name),
|
|
4430
4483
|
prune: nodeFunctionAppPruneTarget(name),
|
|
4431
4484
|
start: nodeFunctionAppStartTarget(name),
|
|
@@ -4437,11 +4490,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
|
4437
4490
|
}
|
|
4438
4491
|
|
|
4439
4492
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4440
|
-
var
|
|
4493
|
+
var import_node_path17 = require("path");
|
|
4441
4494
|
|
|
4442
4495
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
4443
|
-
var
|
|
4444
|
-
var
|
|
4496
|
+
var import_node_fs12 = require("fs");
|
|
4497
|
+
var import_node_path14 = require("path");
|
|
4445
4498
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
4446
4499
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
4447
4500
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -4464,14 +4517,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
4464
4517
|
}
|
|
4465
4518
|
function repairPublishableManifests(workspaceRoot) {
|
|
4466
4519
|
const changed = [];
|
|
4467
|
-
const manifests = (0,
|
|
4520
|
+
const manifests = (0, import_node_fs12.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
4468
4521
|
cwd: workspaceRoot
|
|
4469
4522
|
});
|
|
4470
4523
|
for (const relativePath of manifests) {
|
|
4471
|
-
const manifestPath = (0,
|
|
4472
|
-
const before = (0,
|
|
4524
|
+
const manifestPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
4525
|
+
const before = (0, import_node_fs12.readFileSync)(manifestPath, "utf8");
|
|
4473
4526
|
repairPublishableManifest(manifestPath);
|
|
4474
|
-
const after = (0,
|
|
4527
|
+
const after = (0, import_node_fs12.readFileSync)(manifestPath, "utf8");
|
|
4475
4528
|
if (after !== before) {
|
|
4476
4529
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
4477
4530
|
}
|
|
@@ -4480,8 +4533,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
4480
4533
|
}
|
|
4481
4534
|
|
|
4482
4535
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4483
|
-
var
|
|
4484
|
-
var
|
|
4536
|
+
var import_node_fs13 = require("fs");
|
|
4537
|
+
var import_node_path15 = require("path");
|
|
4485
4538
|
|
|
4486
4539
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
4487
4540
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -4683,12 +4736,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
4683
4736
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
4684
4737
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
4685
4738
|
const changed = [];
|
|
4686
|
-
const configs = (0,
|
|
4739
|
+
const configs = (0, import_node_fs13.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4687
4740
|
cwd: workspaceRoot
|
|
4688
4741
|
});
|
|
4689
4742
|
for (const relativePath of configs) {
|
|
4690
|
-
const configPath = (0,
|
|
4691
|
-
const before = (0,
|
|
4743
|
+
const configPath = (0, import_node_path15.join)(workspaceRoot, relativePath);
|
|
4744
|
+
const before = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
4692
4745
|
const after = withRollupSourceMaps(before);
|
|
4693
4746
|
if (after !== before) {
|
|
4694
4747
|
writeFileEnsured(configPath, after);
|
|
@@ -4699,12 +4752,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
4699
4752
|
}
|
|
4700
4753
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
4701
4754
|
const changed = [];
|
|
4702
|
-
const configs = (0,
|
|
4755
|
+
const configs = (0, import_node_fs13.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
4703
4756
|
cwd: workspaceRoot
|
|
4704
4757
|
});
|
|
4705
4758
|
for (const relativePath of configs) {
|
|
4706
|
-
const configPath = (0,
|
|
4707
|
-
const before = (0,
|
|
4759
|
+
const configPath = (0, import_node_path15.join)(workspaceRoot, relativePath);
|
|
4760
|
+
const before = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
4708
4761
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
4709
4762
|
if (after !== before) {
|
|
4710
4763
|
writeFileEnsured(configPath, after);
|
|
@@ -4714,11 +4767,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
4714
4767
|
return changed;
|
|
4715
4768
|
}
|
|
4716
4769
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
4717
|
-
const configPath = (0,
|
|
4770
|
+
const configPath = (0, import_node_path15.join)(projectRoot, "rollup.config.cjs");
|
|
4718
4771
|
if (!fileExists(configPath)) {
|
|
4719
4772
|
return;
|
|
4720
4773
|
}
|
|
4721
|
-
const config = (0,
|
|
4774
|
+
const config = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
4722
4775
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
4723
4776
|
return;
|
|
4724
4777
|
}
|
|
@@ -4727,10 +4780,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
4727
4780
|
}
|
|
4728
4781
|
|
|
4729
4782
|
// src/rollup-library/rollup-config.repository.ts
|
|
4730
|
-
var
|
|
4731
|
-
var
|
|
4783
|
+
var import_node_fs14 = require("fs");
|
|
4784
|
+
var import_node_path16 = require("path");
|
|
4732
4785
|
function resolveRequireTarget(fromDir, specifier) {
|
|
4733
|
-
const base = (0,
|
|
4786
|
+
const base = (0, import_node_path16.join)(fromDir, specifier);
|
|
4734
4787
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
4735
4788
|
}
|
|
4736
4789
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -4740,7 +4793,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4740
4793
|
visited.add(configPath);
|
|
4741
4794
|
let text;
|
|
4742
4795
|
try {
|
|
4743
|
-
text = (0,
|
|
4796
|
+
text = (0, import_node_fs14.readFileSync)(configPath, "utf8");
|
|
4744
4797
|
} catch {
|
|
4745
4798
|
return "";
|
|
4746
4799
|
}
|
|
@@ -4748,15 +4801,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
4748
4801
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
4749
4802
|
(match) => match[2]
|
|
4750
4803
|
);
|
|
4751
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
4804
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path16.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
4752
4805
|
return [text, ...requiredText].join("\n");
|
|
4753
4806
|
}
|
|
4754
4807
|
|
|
4755
4808
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
4756
4809
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
4757
4810
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
4758
|
-
const projectRoot = (0,
|
|
4759
|
-
const manifestPath = (0,
|
|
4811
|
+
const projectRoot = (0, import_node_path17.join)(workspaceRoot, "packages", name);
|
|
4812
|
+
const manifestPath = (0, import_node_path17.join)(projectRoot, "package.json");
|
|
4760
4813
|
runGeneratorAndRepair(
|
|
4761
4814
|
workspaceRoot,
|
|
4762
4815
|
[
|
|
@@ -4785,8 +4838,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4785
4838
|
}
|
|
4786
4839
|
|
|
4787
4840
|
// src/project-scaffolding/python.use-case.ts
|
|
4788
|
-
var
|
|
4789
|
-
var
|
|
4841
|
+
var import_node_fs15 = require("fs");
|
|
4842
|
+
var import_node_path18 = require("path");
|
|
4790
4843
|
function ensurePython(workspaceRoot) {
|
|
4791
4844
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
4792
4845
|
if (!hasPython) {
|
|
@@ -4809,7 +4862,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
4809
4862
|
registerPythonGraphPlugin(workspaceRoot);
|
|
4810
4863
|
}
|
|
4811
4864
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
4812
|
-
const nxJsonPath = (0,
|
|
4865
|
+
const nxJsonPath = (0, import_node_path18.join)(workspaceRoot, "nx.json");
|
|
4813
4866
|
if (!fileExists(nxJsonPath)) {
|
|
4814
4867
|
return;
|
|
4815
4868
|
}
|
|
@@ -4832,7 +4885,7 @@ pytest
|
|
|
4832
4885
|
pip-audit
|
|
4833
4886
|
`;
|
|
4834
4887
|
function ensureRequirementsDev(workspaceRoot) {
|
|
4835
|
-
const requirementsDevPath = (0,
|
|
4888
|
+
const requirementsDevPath = (0, import_node_path18.join)(workspaceRoot, "requirements-dev.txt");
|
|
4836
4889
|
if (!fileExists(requirementsDevPath)) {
|
|
4837
4890
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
4838
4891
|
}
|
|
@@ -4892,8 +4945,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
4892
4945
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
4893
4946
|
workspaceRoot
|
|
4894
4947
|
);
|
|
4895
|
-
writeFileEnsured((0,
|
|
4896
|
-
addProjectJsonTargets((0,
|
|
4948
|
+
writeFileEnsured((0, import_node_path18.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
4949
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4897
4950
|
package: pythonAppPackageTarget(name),
|
|
4898
4951
|
start: pythonAppStartTarget(name)
|
|
4899
4952
|
});
|
|
@@ -4915,7 +4968,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
4915
4968
|
workspaceRoot
|
|
4916
4969
|
);
|
|
4917
4970
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
4918
|
-
addProjectJsonTargets((0,
|
|
4971
|
+
addProjectJsonTargets((0, import_node_path18.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4919
4972
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
4920
4973
|
start: pythonFunctionAppStartTarget(name)
|
|
4921
4974
|
});
|
|
@@ -4956,7 +5009,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
4956
5009
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
4957
5010
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
4958
5011
|
return PYTHON_PROJECT_DIRS.find(
|
|
4959
|
-
(directory) => fileExists((0,
|
|
5012
|
+
(directory) => fileExists((0, import_node_path18.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
4960
5013
|
);
|
|
4961
5014
|
}
|
|
4962
5015
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -4995,7 +5048,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4995
5048
|
`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.`
|
|
4996
5049
|
);
|
|
4997
5050
|
}
|
|
4998
|
-
if (!fileExists((0,
|
|
5051
|
+
if (!fileExists((0, import_node_path18.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
4999
5052
|
throw new Error(
|
|
5000
5053
|
`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.`
|
|
5001
5054
|
);
|
|
@@ -5003,8 +5056,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5003
5056
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
5004
5057
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
5005
5058
|
}
|
|
5006
|
-
const pyprojectPath = (0,
|
|
5007
|
-
const pyprojectToml = (0,
|
|
5059
|
+
const pyprojectPath = (0, import_node_path18.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
5060
|
+
const pyprojectToml = (0, import_node_fs15.readFileSync)(pyprojectPath, "utf8");
|
|
5008
5061
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
5009
5062
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
5010
5063
|
return;
|
|
@@ -5016,8 +5069,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
5016
5069
|
}
|
|
5017
5070
|
|
|
5018
5071
|
// src/project-scaffolding/react-app.use-case.ts
|
|
5019
|
-
var
|
|
5020
|
-
var
|
|
5072
|
+
var import_node_fs16 = require("fs");
|
|
5073
|
+
var import_node_path19 = require("path");
|
|
5021
5074
|
|
|
5022
5075
|
// src/project-scaffolding/react-app-example.algorithm.ts
|
|
5023
5076
|
function reactAppExampleFiles(name) {
|
|
@@ -5134,12 +5187,12 @@ function reactAppTargets(name) {
|
|
|
5134
5187
|
return targets;
|
|
5135
5188
|
}
|
|
5136
5189
|
function allowEnvFiles(workspaceRoot) {
|
|
5137
|
-
const gitignorePath = (0,
|
|
5190
|
+
const gitignorePath = (0, import_node_path19.join)(workspaceRoot, ".gitignore");
|
|
5138
5191
|
if (!fileExists(gitignorePath)) {
|
|
5139
5192
|
return;
|
|
5140
5193
|
}
|
|
5141
5194
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
5142
|
-
const current = (0,
|
|
5195
|
+
const current = (0, import_node_fs16.readFileSync)(gitignorePath, "utf8");
|
|
5143
5196
|
if (current.includes(marker)) {
|
|
5144
5197
|
return;
|
|
5145
5198
|
}
|
|
@@ -5166,30 +5219,30 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
5166
5219
|
workspaceRoot
|
|
5167
5220
|
);
|
|
5168
5221
|
ensureAdmZip(workspaceRoot);
|
|
5169
|
-
const reactAppRoot = (0,
|
|
5222
|
+
const reactAppRoot = (0, import_node_path19.join)(workspaceRoot, "apps", name);
|
|
5170
5223
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
5171
|
-
writeFileEnsured((0,
|
|
5224
|
+
writeFileEnsured((0, import_node_path19.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
5172
5225
|
}
|
|
5173
5226
|
allowEnvFiles(workspaceRoot);
|
|
5174
|
-
addNxTargets((0,
|
|
5227
|
+
addNxTargets((0, import_node_path19.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
5175
5228
|
reshapeReactAppScaffold(reactAppRoot);
|
|
5176
|
-
(0,
|
|
5229
|
+
(0, import_node_fs16.rmSync)((0, import_node_path19.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
5177
5230
|
const example = reactAppExampleFiles(name);
|
|
5178
5231
|
for (const [relative, contents] of Object.entries(example)) {
|
|
5179
|
-
writeFileEnsured((0,
|
|
5232
|
+
writeFileEnsured((0, import_node_path19.join)(reactAppRoot, "src", relative), contents);
|
|
5180
5233
|
}
|
|
5181
5234
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
5182
5235
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
5183
5236
|
}
|
|
5184
5237
|
|
|
5185
5238
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
5186
|
-
var
|
|
5239
|
+
var import_node_path20 = require("path");
|
|
5187
5240
|
var REACT_LIB_BUNDLER = "rollup";
|
|
5188
5241
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
5189
5242
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5190
5243
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
5191
|
-
const projectRoot = (0,
|
|
5192
|
-
const publishableManifest = (0,
|
|
5244
|
+
const projectRoot = (0, import_node_path20.join)(workspaceRoot, "packages", name);
|
|
5245
|
+
const publishableManifest = (0, import_node_path20.join)(projectRoot, "package.json");
|
|
5193
5246
|
runGeneratorAndRepair(
|
|
5194
5247
|
workspaceRoot,
|
|
5195
5248
|
[
|
|
@@ -5219,8 +5272,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
5219
5272
|
}
|
|
5220
5273
|
function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
5221
5274
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
5222
|
-
const projectRoot = (0,
|
|
5223
|
-
const privateManifest = (0,
|
|
5275
|
+
const projectRoot = (0, import_node_path20.join)(workspaceRoot, "libs", name);
|
|
5276
|
+
const privateManifest = (0, import_node_path20.join)(projectRoot, "package.json");
|
|
5224
5277
|
runGeneratorAndRepair(
|
|
5225
5278
|
workspaceRoot,
|
|
5226
5279
|
[
|
|
@@ -5247,8 +5300,8 @@ function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
|
|
|
5247
5300
|
}
|
|
5248
5301
|
|
|
5249
5302
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
5250
|
-
var
|
|
5251
|
-
var
|
|
5303
|
+
var import_node_fs17 = require("fs");
|
|
5304
|
+
var import_node_path21 = require("path");
|
|
5252
5305
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
5253
5306
|
var VSCODE_ENGINE_FLOOR = "1.96.0";
|
|
5254
5307
|
var VSCODE_SIDECAR_TARGETS = {
|
|
@@ -5433,8 +5486,8 @@ export const window = {
|
|
|
5433
5486
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
5434
5487
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
5435
5488
|
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}\` },`];
|
|
5436
|
-
const path = (0,
|
|
5437
|
-
const content = fileExists(path) ? (0,
|
|
5489
|
+
const path = (0, import_node_path21.join)(projectRoot, file);
|
|
5490
|
+
const content = fileExists(path) ? (0, import_node_fs17.readFileSync)(path, "utf8") : "";
|
|
5438
5491
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
5439
5492
|
if (line === void 0) {
|
|
5440
5493
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -5454,11 +5507,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
5454
5507
|
}
|
|
5455
5508
|
}
|
|
5456
5509
|
function defaultPublisher(workspaceRoot) {
|
|
5457
|
-
const { name } = readJson((0,
|
|
5510
|
+
const { name } = readJson((0, import_node_path21.join)(workspaceRoot, "package.json"));
|
|
5458
5511
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
5459
5512
|
}
|
|
5460
5513
|
function reshapeManifest(projectRoot, name, publisher) {
|
|
5461
|
-
const manifestPath = (0,
|
|
5514
|
+
const manifestPath = (0, import_node_path21.join)(projectRoot, "package.json");
|
|
5462
5515
|
const manifest = readJson(manifestPath);
|
|
5463
5516
|
const { nx = {}, ...rest } = manifest;
|
|
5464
5517
|
const targets = { ...nx.targets };
|
|
@@ -5522,11 +5575,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
5522
5575
|
};
|
|
5523
5576
|
}
|
|
5524
5577
|
function addDebugLaunch(workspaceRoot, name) {
|
|
5525
|
-
const file = (0,
|
|
5578
|
+
const file = (0, import_node_fs17.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
5526
5579
|
if (file === void 0) {
|
|
5527
5580
|
return;
|
|
5528
5581
|
}
|
|
5529
|
-
const path = (0,
|
|
5582
|
+
const path = (0, import_node_path21.join)(workspaceRoot, file);
|
|
5530
5583
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
5531
5584
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
5532
5585
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -5559,39 +5612,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
5559
5612
|
);
|
|
5560
5613
|
}
|
|
5561
5614
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
5562
|
-
const apps = (0,
|
|
5615
|
+
const apps = (0, import_node_path21.join)(workspaceRoot, "apps");
|
|
5563
5616
|
let entries;
|
|
5564
5617
|
try {
|
|
5565
|
-
entries = (0,
|
|
5618
|
+
entries = (0, import_node_fs17.readdirSync)(apps);
|
|
5566
5619
|
} catch {
|
|
5567
5620
|
return false;
|
|
5568
5621
|
}
|
|
5569
5622
|
const hasExtension = entries.some((entry) => {
|
|
5570
|
-
const manifestPath = (0,
|
|
5623
|
+
const manifestPath = (0, import_node_path21.join)(apps, entry, "package.json");
|
|
5571
5624
|
if (!fileExists(manifestPath)) {
|
|
5572
5625
|
return false;
|
|
5573
5626
|
}
|
|
5574
5627
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
5575
5628
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
5576
5629
|
});
|
|
5577
|
-
const path = (0,
|
|
5578
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
5630
|
+
const path = (0, import_node_path21.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
5631
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs17.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
5579
5632
|
return false;
|
|
5580
5633
|
}
|
|
5581
5634
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
5582
5635
|
return true;
|
|
5583
5636
|
}
|
|
5584
5637
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
5585
|
-
const apps = (0,
|
|
5638
|
+
const apps = (0, import_node_path21.join)(workspaceRoot, "apps");
|
|
5586
5639
|
let entries;
|
|
5587
5640
|
try {
|
|
5588
|
-
entries = (0,
|
|
5641
|
+
entries = (0, import_node_fs17.readdirSync)(apps);
|
|
5589
5642
|
} catch {
|
|
5590
5643
|
return [];
|
|
5591
5644
|
}
|
|
5592
5645
|
const updated = [];
|
|
5593
5646
|
for (const entry of entries) {
|
|
5594
|
-
const manifestPath = (0,
|
|
5647
|
+
const manifestPath = (0, import_node_path21.join)(apps, entry, "package.json");
|
|
5595
5648
|
if (!fileExists(manifestPath)) {
|
|
5596
5649
|
continue;
|
|
5597
5650
|
}
|
|
@@ -5611,22 +5664,22 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
5611
5664
|
}
|
|
5612
5665
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
5613
5666
|
const { sidecar } = options;
|
|
5614
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
5667
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path21.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
5615
5668
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
5616
5669
|
}
|
|
5617
5670
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
5618
5671
|
ensureVscodeToolchain(workspaceRoot);
|
|
5619
|
-
const projectRoot = (0,
|
|
5672
|
+
const projectRoot = (0, import_node_path21.join)(workspaceRoot, "apps", name);
|
|
5620
5673
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot));
|
|
5621
|
-
addVscodeTypes((0,
|
|
5622
|
-
addVscodeTypes((0,
|
|
5623
|
-
writeFileEnsured((0,
|
|
5624
|
-
writeFileEnsured((0,
|
|
5625
|
-
writeFileEnsured((0,
|
|
5674
|
+
addVscodeTypes((0, import_node_path21.join)(projectRoot, "tsconfig.app.json"));
|
|
5675
|
+
addVscodeTypes((0, import_node_path21.join)(projectRoot, "tsconfig.spec.json"));
|
|
5676
|
+
writeFileEnsured((0, import_node_path21.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
5677
|
+
writeFileEnsured((0, import_node_path21.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
5678
|
+
writeFileEnsured((0, import_node_path21.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
5626
5679
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
5627
|
-
writeFileEnsured((0,
|
|
5628
|
-
writeFileEnsured((0,
|
|
5629
|
-
addNxTargets((0,
|
|
5680
|
+
writeFileEnsured((0, import_node_path21.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
5681
|
+
writeFileEnsured((0, import_node_path21.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
5682
|
+
addNxTargets((0, import_node_path21.join)(projectRoot, "package.json"), {
|
|
5630
5683
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
5631
5684
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
5632
5685
|
});
|
|
@@ -5637,12 +5690,12 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
5637
5690
|
}
|
|
5638
5691
|
|
|
5639
5692
|
// src/dependency-management/install-dependencies.use-case.ts
|
|
5640
|
-
var
|
|
5641
|
-
var
|
|
5693
|
+
var import_node_fs19 = require("fs");
|
|
5694
|
+
var import_node_path23 = require("path");
|
|
5642
5695
|
|
|
5643
5696
|
// src/dependency-management/manifest.repository.ts
|
|
5644
|
-
var
|
|
5645
|
-
var
|
|
5697
|
+
var import_node_fs18 = require("fs");
|
|
5698
|
+
var import_node_path22 = require("path");
|
|
5646
5699
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
5647
5700
|
var ROOT_LABEL = "(root)";
|
|
5648
5701
|
var MANIFEST_GLOBS = {
|
|
@@ -5675,23 +5728,23 @@ function projectOf(manifestRelativePath) {
|
|
|
5675
5728
|
}
|
|
5676
5729
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
5677
5730
|
if (ecosystem === "go") {
|
|
5678
|
-
return fileExists((0,
|
|
5731
|
+
return fileExists((0, import_node_path22.join)(workspaceRoot, "go.mod"));
|
|
5679
5732
|
}
|
|
5680
5733
|
if (ecosystem === "nuget") {
|
|
5681
|
-
return (0,
|
|
5734
|
+
return (0, import_node_fs18.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
5682
5735
|
}
|
|
5683
5736
|
const rootMarker = {
|
|
5684
5737
|
npm: "package.json",
|
|
5685
5738
|
pip: "requirements-dev.txt",
|
|
5686
5739
|
pub: "pubspec.yaml"
|
|
5687
5740
|
};
|
|
5688
|
-
return fileExists((0,
|
|
5741
|
+
return fileExists((0, import_node_path22.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs18.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
5689
5742
|
}
|
|
5690
5743
|
function collectNpm(workspaceRoot) {
|
|
5691
5744
|
const sites = [];
|
|
5692
|
-
const relativePaths = ["package.json", ...(0,
|
|
5745
|
+
const relativePaths = ["package.json", ...(0, import_node_fs18.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
5693
5746
|
for (const relativePath of relativePaths) {
|
|
5694
|
-
const manifestPath = (0,
|
|
5747
|
+
const manifestPath = (0, import_node_path22.join)(workspaceRoot, relativePath);
|
|
5695
5748
|
try {
|
|
5696
5749
|
const manifest = readJson(manifestPath);
|
|
5697
5750
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -5752,17 +5805,17 @@ function collectPip(workspaceRoot) {
|
|
|
5752
5805
|
name: parsed.name,
|
|
5753
5806
|
ecosystem: "pip",
|
|
5754
5807
|
project: projectOf(relativePath),
|
|
5755
|
-
manifestPath: (0,
|
|
5808
|
+
manifestPath: (0, import_node_path22.join)(workspaceRoot, relativePath),
|
|
5756
5809
|
section,
|
|
5757
5810
|
spec: parsed.spec,
|
|
5758
5811
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
5759
5812
|
});
|
|
5760
5813
|
};
|
|
5761
|
-
const pyprojectPaths = (0,
|
|
5814
|
+
const pyprojectPaths = (0, import_node_fs18.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
5762
5815
|
for (const relativePath of pyprojectPaths) {
|
|
5763
5816
|
let content;
|
|
5764
5817
|
try {
|
|
5765
|
-
content = (0,
|
|
5818
|
+
content = (0, import_node_fs18.readFileSync)((0, import_node_path22.join)(workspaceRoot, relativePath), "utf8");
|
|
5766
5819
|
} catch {
|
|
5767
5820
|
continue;
|
|
5768
5821
|
}
|
|
@@ -5773,14 +5826,14 @@ function collectPip(workspaceRoot) {
|
|
|
5773
5826
|
}
|
|
5774
5827
|
const requirementsPaths = [
|
|
5775
5828
|
"requirements-dev.txt",
|
|
5776
|
-
...(0,
|
|
5829
|
+
...(0, import_node_fs18.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
5777
5830
|
];
|
|
5778
5831
|
for (const relativePath of requirementsPaths) {
|
|
5779
|
-
if (!fileExists((0,
|
|
5832
|
+
if (!fileExists((0, import_node_path22.join)(workspaceRoot, relativePath))) {
|
|
5780
5833
|
continue;
|
|
5781
5834
|
}
|
|
5782
5835
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
5783
|
-
const lines = (0,
|
|
5836
|
+
const lines = (0, import_node_fs18.readFileSync)((0, import_node_path22.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
5784
5837
|
for (const line of lines) {
|
|
5785
5838
|
push(relativePath, section, line);
|
|
5786
5839
|
}
|
|
@@ -5818,11 +5871,11 @@ function pyprojectDependencies(content) {
|
|
|
5818
5871
|
}
|
|
5819
5872
|
function collectPub(workspaceRoot) {
|
|
5820
5873
|
const sites = [];
|
|
5821
|
-
const pubspecPaths = (0,
|
|
5874
|
+
const pubspecPaths = (0, import_node_fs18.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
5822
5875
|
for (const relativePath of pubspecPaths) {
|
|
5823
5876
|
let content;
|
|
5824
5877
|
try {
|
|
5825
|
-
content = (0,
|
|
5878
|
+
content = (0, import_node_fs18.readFileSync)((0, import_node_path22.join)(workspaceRoot, relativePath), "utf8");
|
|
5826
5879
|
} catch {
|
|
5827
5880
|
continue;
|
|
5828
5881
|
}
|
|
@@ -5832,7 +5885,7 @@ function collectPub(workspaceRoot) {
|
|
|
5832
5885
|
name: entry.name,
|
|
5833
5886
|
ecosystem: "pub",
|
|
5834
5887
|
project: projectOf(relativePath),
|
|
5835
|
-
manifestPath: (0,
|
|
5888
|
+
manifestPath: (0, import_node_path22.join)(workspaceRoot, relativePath),
|
|
5836
5889
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
5837
5890
|
spec: entry.spec,
|
|
5838
5891
|
rewritable: entry.spec !== ""
|
|
@@ -5882,11 +5935,11 @@ function stripQuotes(value) {
|
|
|
5882
5935
|
}
|
|
5883
5936
|
function collectNuget(workspaceRoot) {
|
|
5884
5937
|
const sites = [];
|
|
5885
|
-
const csprojPaths = (0,
|
|
5938
|
+
const csprojPaths = (0, import_node_fs18.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
5886
5939
|
for (const relativePath of csprojPaths) {
|
|
5887
5940
|
let content;
|
|
5888
5941
|
try {
|
|
5889
|
-
content = (0,
|
|
5942
|
+
content = (0, import_node_fs18.readFileSync)((0, import_node_path22.join)(workspaceRoot, relativePath), "utf8");
|
|
5890
5943
|
} catch {
|
|
5891
5944
|
continue;
|
|
5892
5945
|
}
|
|
@@ -5895,7 +5948,7 @@ function collectNuget(workspaceRoot) {
|
|
|
5895
5948
|
name: entry.name,
|
|
5896
5949
|
ecosystem: "nuget",
|
|
5897
5950
|
project: projectOf(relativePath),
|
|
5898
|
-
manifestPath: (0,
|
|
5951
|
+
manifestPath: (0, import_node_path22.join)(workspaceRoot, relativePath),
|
|
5899
5952
|
section: "dep",
|
|
5900
5953
|
spec: entry.spec,
|
|
5901
5954
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -5920,13 +5973,13 @@ function csprojPackageReferences(content) {
|
|
|
5920
5973
|
return entries;
|
|
5921
5974
|
}
|
|
5922
5975
|
function collectGo(workspaceRoot) {
|
|
5923
|
-
const manifestPath = (0,
|
|
5976
|
+
const manifestPath = (0, import_node_path22.join)(workspaceRoot, "go.mod");
|
|
5924
5977
|
if (!fileExists(manifestPath)) {
|
|
5925
5978
|
return [];
|
|
5926
5979
|
}
|
|
5927
5980
|
let content;
|
|
5928
5981
|
try {
|
|
5929
|
-
content = (0,
|
|
5982
|
+
content = (0, import_node_fs18.readFileSync)(manifestPath, "utf8");
|
|
5930
5983
|
} catch {
|
|
5931
5984
|
return [];
|
|
5932
5985
|
}
|
|
@@ -5975,7 +6028,7 @@ var PROJECT_GLOBS = {
|
|
|
5975
6028
|
function locateProjects(workspaceRoot) {
|
|
5976
6029
|
const locations = [];
|
|
5977
6030
|
for (const ecosystem of ECOSYSTEMS) {
|
|
5978
|
-
const relativePaths = (0,
|
|
6031
|
+
const relativePaths = (0, import_node_fs18.globSync)(PROJECT_GLOBS[ecosystem], { cwd: workspaceRoot });
|
|
5979
6032
|
for (const relativePath of relativePaths) {
|
|
5980
6033
|
const posix = toPosix(relativePath);
|
|
5981
6034
|
const dir = posix.slice(0, posix.lastIndexOf("/"));
|
|
@@ -5983,7 +6036,7 @@ function locateProjects(workspaceRoot) {
|
|
|
5983
6036
|
ecosystem,
|
|
5984
6037
|
dir,
|
|
5985
6038
|
name: dir.slice(dir.lastIndexOf("/") + 1),
|
|
5986
|
-
manifestPath: (0,
|
|
6039
|
+
manifestPath: (0, import_node_path22.join)(workspaceRoot, relativePath)
|
|
5987
6040
|
});
|
|
5988
6041
|
}
|
|
5989
6042
|
}
|
|
@@ -6004,7 +6057,7 @@ function rewriteSpec(site, spec) {
|
|
|
6004
6057
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
6005
6058
|
return true;
|
|
6006
6059
|
}
|
|
6007
|
-
const before = (0,
|
|
6060
|
+
const before = (0, import_node_fs18.readFileSync)(site.manifestPath, "utf8");
|
|
6008
6061
|
const after = (() => {
|
|
6009
6062
|
switch (site.ecosystem) {
|
|
6010
6063
|
case "pip": {
|
|
@@ -6095,13 +6148,13 @@ function escapeForRegex(value) {
|
|
|
6095
6148
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
6096
6149
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
6097
6150
|
return ["apps", "libs", "packages"].some(
|
|
6098
|
-
(directory) => fileExists((0,
|
|
6151
|
+
(directory) => fileExists((0, import_node_path22.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
6099
6152
|
);
|
|
6100
6153
|
}
|
|
6101
6154
|
function isAliasedInstall(workspaceRoot, name) {
|
|
6102
6155
|
try {
|
|
6103
6156
|
const installed = readJson(
|
|
6104
|
-
(0,
|
|
6157
|
+
(0, import_node_path22.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6105
6158
|
);
|
|
6106
6159
|
return installed.name !== void 0 && installed.name !== name;
|
|
6107
6160
|
} catch {
|
|
@@ -6112,14 +6165,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6112
6165
|
if (ecosystem === "npm") {
|
|
6113
6166
|
try {
|
|
6114
6167
|
return readJson(
|
|
6115
|
-
(0,
|
|
6168
|
+
(0, import_node_path22.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
6116
6169
|
).version;
|
|
6117
6170
|
} catch {
|
|
6118
6171
|
return void 0;
|
|
6119
6172
|
}
|
|
6120
6173
|
}
|
|
6121
6174
|
if (ecosystem === "pub") {
|
|
6122
|
-
const lockPath = (0,
|
|
6175
|
+
const lockPath = (0, import_node_path22.join)(workspaceRoot, "pubspec.lock");
|
|
6123
6176
|
if (!fileExists(lockPath)) {
|
|
6124
6177
|
return void 0;
|
|
6125
6178
|
}
|
|
@@ -6127,7 +6180,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
6127
6180
|
const match = new RegExp(
|
|
6128
6181
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
6129
6182
|
"m"
|
|
6130
|
-
).exec((0,
|
|
6183
|
+
).exec((0, import_node_fs18.readFileSync)(lockPath, "utf8"));
|
|
6131
6184
|
return match?.[1];
|
|
6132
6185
|
} catch {
|
|
6133
6186
|
return void 0;
|
|
@@ -6193,7 +6246,7 @@ function resolveTarget(locations, target) {
|
|
|
6193
6246
|
return byName[0];
|
|
6194
6247
|
}
|
|
6195
6248
|
function installInto(workspaceRoot, location, packages, saveDev) {
|
|
6196
|
-
const projectDir = (0,
|
|
6249
|
+
const projectDir = (0, import_node_path23.join)(workspaceRoot, location.dir);
|
|
6197
6250
|
switch (location.ecosystem) {
|
|
6198
6251
|
case "npm": {
|
|
6199
6252
|
const flags = saveDev ? ["--save-dev"] : [];
|
|
@@ -6246,7 +6299,7 @@ function installInto(workspaceRoot, location, packages, saveDev) {
|
|
|
6246
6299
|
function addPythonDependency(manifestPath, specifier) {
|
|
6247
6300
|
let content;
|
|
6248
6301
|
try {
|
|
6249
|
-
content = (0,
|
|
6302
|
+
content = (0, import_node_fs19.readFileSync)(manifestPath, "utf8");
|
|
6250
6303
|
} catch {
|
|
6251
6304
|
logger.warn(`Could not read ${manifestPath} \u2014 skipped ${specifier}`);
|
|
6252
6305
|
return;
|
|
@@ -6275,7 +6328,7 @@ function installEverything(workspaceRoot, only) {
|
|
|
6275
6328
|
}
|
|
6276
6329
|
function ecosystemPresent(workspaceRoot, ecosystem) {
|
|
6277
6330
|
if (ecosystem === "go") {
|
|
6278
|
-
return fileExists((0,
|
|
6331
|
+
return fileExists((0, import_node_path23.join)(workspaceRoot, "go.work")) || fileExists((0, import_node_path23.join)(workspaceRoot, "go.mod"));
|
|
6279
6332
|
}
|
|
6280
6333
|
return hasEcosystem(workspaceRoot, ecosystem);
|
|
6281
6334
|
}
|
|
@@ -6294,7 +6347,7 @@ function splitAtLast(value, separator) {
|
|
|
6294
6347
|
}
|
|
6295
6348
|
|
|
6296
6349
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
6297
|
-
var
|
|
6350
|
+
var import_node_path24 = require("path");
|
|
6298
6351
|
|
|
6299
6352
|
// src/dependency-management/semver.algorithm.ts
|
|
6300
6353
|
var UPDATE_KINDS = ["patch", "minor", "major", "non-semver"];
|
|
@@ -6471,7 +6524,7 @@ function describe(finding) {
|
|
|
6471
6524
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
6472
6525
|
}
|
|
6473
6526
|
function runSync(workspaceRoot, options) {
|
|
6474
|
-
if (!fileExists((0,
|
|
6527
|
+
if (!fileExists((0, import_node_path24.join)(workspaceRoot, "nx.json"))) {
|
|
6475
6528
|
throw new Error(
|
|
6476
6529
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
6477
6530
|
);
|
|
@@ -6521,7 +6574,7 @@ function runSync(workspaceRoot, options) {
|
|
|
6521
6574
|
}
|
|
6522
6575
|
|
|
6523
6576
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
6524
|
-
var
|
|
6577
|
+
var import_node_path25 = require("path");
|
|
6525
6578
|
var import_prompts2 = require("@inquirer/prompts");
|
|
6526
6579
|
|
|
6527
6580
|
// src/dependency-management/registry.client.ts
|
|
@@ -6804,7 +6857,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
6804
6857
|
function hasPythonInstallScript(workspaceRoot) {
|
|
6805
6858
|
try {
|
|
6806
6859
|
const manifest = readJson(
|
|
6807
|
-
(0,
|
|
6860
|
+
(0, import_node_path25.join)(workspaceRoot, "package.json")
|
|
6808
6861
|
);
|
|
6809
6862
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
6810
6863
|
} catch {
|
|
@@ -6820,7 +6873,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
6820
6873
|
}
|
|
6821
6874
|
}
|
|
6822
6875
|
async function runUp(workspaceRoot, options) {
|
|
6823
|
-
if (!fileExists((0,
|
|
6876
|
+
if (!fileExists((0, import_node_path25.join)(workspaceRoot, "nx.json"))) {
|
|
6824
6877
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
6825
6878
|
}
|
|
6826
6879
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -6897,7 +6950,7 @@ var PROJECT_KINDS = [
|
|
|
6897
6950
|
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
6898
6951
|
async function runAdd(kind, name, options) {
|
|
6899
6952
|
const workspaceRoot = process.cwd();
|
|
6900
|
-
if (!fileExists((0,
|
|
6953
|
+
if (!fileExists((0, import_node_path26.join)(workspaceRoot, "nx.json"))) {
|
|
6901
6954
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
6902
6955
|
}
|
|
6903
6956
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -6960,8 +7013,8 @@ async function runAdd(kind, name, options) {
|
|
|
6960
7013
|
],
|
|
6961
7014
|
workspaceRoot
|
|
6962
7015
|
);
|
|
6963
|
-
markPrivate((0,
|
|
6964
|
-
renameScaffoldPlaceholder((0,
|
|
7016
|
+
markPrivate((0, import_node_path26.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
7017
|
+
renameScaffoldPlaceholder((0, import_node_path26.join)(workspaceRoot, "libs", resolvedName), resolvedName, options.empty === true);
|
|
6965
7018
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
6966
7019
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
6967
7020
|
break;
|
|
@@ -7053,7 +7106,7 @@ async function runAdd(kind, name, options) {
|
|
|
7053
7106
|
}
|
|
7054
7107
|
function readWorkspaceStack(workspaceRoot) {
|
|
7055
7108
|
const nxJson = readJson(
|
|
7056
|
-
(0,
|
|
7109
|
+
(0, import_node_path26.join)(workspaceRoot, "nx.json")
|
|
7057
7110
|
);
|
|
7058
7111
|
const stack = nxJson.mnci?.stack;
|
|
7059
7112
|
return {
|
|
@@ -7102,15 +7155,15 @@ function runKinds(options) {
|
|
|
7102
7155
|
|
|
7103
7156
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
7104
7157
|
var import_node_child_process = require("child_process");
|
|
7105
|
-
var
|
|
7106
|
-
var
|
|
7158
|
+
var import_node_fs20 = require("fs");
|
|
7159
|
+
var import_node_path27 = require("path");
|
|
7107
7160
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
7108
7161
|
function toPosix2(path) {
|
|
7109
7162
|
return path.replaceAll("\\", "/");
|
|
7110
7163
|
}
|
|
7111
7164
|
function checkEslintConfigs(workspaceRoot) {
|
|
7112
|
-
const rootConfigs = (0,
|
|
7113
|
-
const projectConfigs = (0,
|
|
7165
|
+
const rootConfigs = (0, import_node_fs20.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
7166
|
+
const projectConfigs = (0, import_node_fs20.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
7114
7167
|
cwd: workspaceRoot
|
|
7115
7168
|
}).map((config) => toPosix2(config));
|
|
7116
7169
|
return [
|
|
@@ -7130,10 +7183,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
7130
7183
|
];
|
|
7131
7184
|
}
|
|
7132
7185
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
7133
|
-
const rules = (0,
|
|
7134
|
-
if (!(0,
|
|
7135
|
-
const entryPoint = (0,
|
|
7136
|
-
const source = (0,
|
|
7186
|
+
const rules = (0, import_node_path27.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
7187
|
+
if (!(0, import_node_fs20.existsSync)(rules)) return [];
|
|
7188
|
+
const entryPoint = (0, import_node_path27.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
7189
|
+
const source = (0, import_node_fs20.existsSync)(entryPoint) ? (0, import_node_fs20.readFileSync)(entryPoint, "utf8") : "";
|
|
7137
7190
|
return [
|
|
7138
7191
|
{
|
|
7139
7192
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -7146,7 +7199,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
7146
7199
|
function declaredDevDependencies(workspaceRoot) {
|
|
7147
7200
|
try {
|
|
7148
7201
|
const manifest = readJson(
|
|
7149
|
-
(0,
|
|
7202
|
+
(0, import_node_path27.join)(workspaceRoot, "package.json")
|
|
7150
7203
|
);
|
|
7151
7204
|
return manifest.devDependencies ?? {};
|
|
7152
7205
|
} catch {
|
|
@@ -7154,7 +7207,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
7154
7207
|
}
|
|
7155
7208
|
}
|
|
7156
7209
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
7157
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
7210
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path27.join)(workspaceRoot, file)));
|
|
7158
7211
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
7159
7212
|
const stale = [...files, ...declared];
|
|
7160
7213
|
if (stale.length === 0) {
|
|
@@ -7180,7 +7233,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
7180
7233
|
};
|
|
7181
7234
|
}
|
|
7182
7235
|
function checkResolvedEslint(workspaceRoot) {
|
|
7183
|
-
const manifestPath = (0,
|
|
7236
|
+
const manifestPath = (0, import_node_path27.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
7184
7237
|
if (!fileExists(manifestPath)) {
|
|
7185
7238
|
return void 0;
|
|
7186
7239
|
}
|
|
@@ -7198,11 +7251,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
7198
7251
|
}
|
|
7199
7252
|
}
|
|
7200
7253
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
7201
|
-
const npmrcPath = (0,
|
|
7254
|
+
const npmrcPath = (0, import_node_path27.join)(workspaceRoot, ".npmrc");
|
|
7202
7255
|
if (!registry || !fileExists(npmrcPath)) {
|
|
7203
7256
|
return void 0;
|
|
7204
7257
|
}
|
|
7205
|
-
const npmrc = (0,
|
|
7258
|
+
const npmrc = (0, import_node_fs20.readFileSync)(npmrcPath, "utf8");
|
|
7206
7259
|
if (registry.kind === "npm") {
|
|
7207
7260
|
return {
|
|
7208
7261
|
check: ".npmrc authenticates the public registry",
|
|
@@ -7219,11 +7272,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
7219
7272
|
};
|
|
7220
7273
|
}
|
|
7221
7274
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
7222
|
-
const npmrcPath = (0,
|
|
7275
|
+
const npmrcPath = (0, import_node_path27.join)(workspaceRoot, ".npmrc");
|
|
7223
7276
|
if (!fileExists(npmrcPath)) {
|
|
7224
7277
|
return void 0;
|
|
7225
7278
|
}
|
|
7226
|
-
const npmrc = (0,
|
|
7279
|
+
const npmrc = (0, import_node_fs20.readFileSync)(npmrcPath, "utf8");
|
|
7227
7280
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7228
7281
|
const referenced = [
|
|
7229
7282
|
...new Set(
|
|
@@ -7247,13 +7300,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
7247
7300
|
};
|
|
7248
7301
|
}
|
|
7249
7302
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
7250
|
-
const npmrcPath = (0,
|
|
7251
|
-
const pipelinePath = (0,
|
|
7303
|
+
const npmrcPath = (0, import_node_path27.join)(workspaceRoot, ".npmrc");
|
|
7304
|
+
const pipelinePath = (0, import_node_path27.join)(workspaceRoot, "azure-pipelines.yml");
|
|
7252
7305
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
7253
7306
|
return void 0;
|
|
7254
7307
|
}
|
|
7255
|
-
const holdsCredentials = (0,
|
|
7256
|
-
const runsTask = (0,
|
|
7308
|
+
const holdsCredentials = (0, import_node_fs20.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
7309
|
+
const runsTask = (0, import_node_fs20.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
7257
7310
|
if (!holdsCredentials && !runsTask) {
|
|
7258
7311
|
return {
|
|
7259
7312
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -7298,13 +7351,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
7298
7351
|
}
|
|
7299
7352
|
function checkVersionActions(workspaceRoot) {
|
|
7300
7353
|
const candidates = [
|
|
7301
|
-
...(0,
|
|
7302
|
-
...(0,
|
|
7303
|
-
...(0,
|
|
7354
|
+
...(0, import_node_fs20.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
7355
|
+
...(0, import_node_fs20.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
7356
|
+
...(0, import_node_fs20.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
7304
7357
|
].map((manifest) => toPosix2(manifest));
|
|
7305
7358
|
return candidates.flatMap((manifest) => {
|
|
7306
7359
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
7307
|
-
const projectJsonPath = (0,
|
|
7360
|
+
const projectJsonPath = (0, import_node_path27.join)(workspaceRoot, projectRoot, "project.json");
|
|
7308
7361
|
let hasOverride = false;
|
|
7309
7362
|
try {
|
|
7310
7363
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -7333,7 +7386,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7333
7386
|
]) {
|
|
7334
7387
|
try {
|
|
7335
7388
|
const targets = extract(
|
|
7336
|
-
readJson((0,
|
|
7389
|
+
readJson((0, import_node_path27.join)(workspaceRoot, projectRoot, file))
|
|
7337
7390
|
);
|
|
7338
7391
|
if (targets && typeof targets === "object") {
|
|
7339
7392
|
sources.push({
|
|
@@ -7349,8 +7402,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
7349
7402
|
function checkTargetFilesExist(workspaceRoot) {
|
|
7350
7403
|
const projectRoots = new Set(
|
|
7351
7404
|
[
|
|
7352
|
-
...(0,
|
|
7353
|
-
...(0,
|
|
7405
|
+
...(0, import_node_fs20.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
7406
|
+
...(0, import_node_fs20.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
7354
7407
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
7355
7408
|
);
|
|
7356
7409
|
return [...projectRoots].flatMap(
|
|
@@ -7365,7 +7418,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
7365
7418
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
7366
7419
|
const value = target?.options?.[option];
|
|
7367
7420
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
7368
|
-
if (!checkable || fileExists((0,
|
|
7421
|
+
if (!checkable || fileExists((0, import_node_path27.join)(workspaceRoot, value))) {
|
|
7369
7422
|
return [];
|
|
7370
7423
|
}
|
|
7371
7424
|
return [
|
|
@@ -7404,15 +7457,15 @@ function checkGoPluginRegistered(workspaceRoot) {
|
|
|
7404
7457
|
};
|
|
7405
7458
|
}
|
|
7406
7459
|
function checkGoWorkInSync(workspaceRoot) {
|
|
7407
|
-
const goWorkPath = (0,
|
|
7460
|
+
const goWorkPath = (0, import_node_path27.join)(workspaceRoot, "go.work");
|
|
7408
7461
|
if (!fileExists(goWorkPath)) {
|
|
7409
7462
|
return void 0;
|
|
7410
7463
|
}
|
|
7411
|
-
const contents = (0,
|
|
7464
|
+
const contents = (0, import_node_fs20.existsSync)(goWorkPath) ? (0, import_node_fs20.readFileSync)(goWorkPath, "utf8") : "";
|
|
7412
7465
|
const blockEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+\(([^)]*)\)/g), (match) => match[1].split("\n")).flat();
|
|
7413
7466
|
const singleEntries = Array.from(contents.matchAll(/(?:^|\n)\s*use\s+(\.\S+)/g), (match) => match[1]);
|
|
7414
7467
|
const uses = [...blockEntries, ...singleEntries].map((entry) => entry.trim()).filter(Boolean);
|
|
7415
|
-
const stale = uses.filter((entry) => !(0,
|
|
7468
|
+
const stale = uses.filter((entry) => !(0, import_node_fs20.existsSync)((0, import_node_path27.join)(workspaceRoot, entry, "go.mod")));
|
|
7416
7469
|
return {
|
|
7417
7470
|
check: "every go.work `use` entry points to a module that still exists",
|
|
7418
7471
|
ok: stale.length === 0,
|
|
@@ -7428,9 +7481,9 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7428
7481
|
{ file: ".github/workflows/ci.yml", marker: "native (${{ matrix.os }})" },
|
|
7429
7482
|
{ file: "azure-pipelines.yml", marker: "- job: native" }
|
|
7430
7483
|
];
|
|
7431
|
-
const findings = pipelines.filter(({ file }) => fileExists((0,
|
|
7484
|
+
const findings = pipelines.filter(({ file }) => fileExists((0, import_node_path27.join)(workspaceRoot, file))).map(({ file, marker }) => ({
|
|
7432
7485
|
check: `${file} builds the native apps on every OS`,
|
|
7433
|
-
ok: (0,
|
|
7486
|
+
ok: (0, import_node_fs20.readFileSync)((0, import_node_path27.join)(workspaceRoot, file), "utf8").includes(marker),
|
|
7434
7487
|
detail: `${file} has no native job: CI would verify a cgo app on the one agent that cannot build it`,
|
|
7435
7488
|
remedy: "run `mnci upgrade`"
|
|
7436
7489
|
}));
|
|
@@ -7443,7 +7496,7 @@ function checkNativeApps(workspaceRoot) {
|
|
|
7443
7496
|
return findings;
|
|
7444
7497
|
}
|
|
7445
7498
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
7446
|
-
const manifestPath = (0,
|
|
7499
|
+
const manifestPath = (0, import_node_path27.join)(workspaceRoot, "package.json");
|
|
7447
7500
|
if (!fileExists(manifestPath)) {
|
|
7448
7501
|
return void 0;
|
|
7449
7502
|
}
|
|
@@ -7463,14 +7516,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
7463
7516
|
};
|
|
7464
7517
|
}
|
|
7465
7518
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
7466
|
-
const configs = (0,
|
|
7519
|
+
const configs = (0, import_node_fs20.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7467
7520
|
cwd: workspaceRoot
|
|
7468
7521
|
}).map((config) => toPosix2(config));
|
|
7469
7522
|
return configs.flatMap((relativePath) => {
|
|
7470
|
-
const configPath = (0,
|
|
7523
|
+
const configPath = (0, import_node_path27.join)(workspaceRoot, relativePath);
|
|
7471
7524
|
let config;
|
|
7472
7525
|
try {
|
|
7473
|
-
config = (0,
|
|
7526
|
+
config = (0, import_node_fs20.readFileSync)(configPath, "utf8");
|
|
7474
7527
|
} catch {
|
|
7475
7528
|
return [];
|
|
7476
7529
|
}
|
|
@@ -7485,11 +7538,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
7485
7538
|
});
|
|
7486
7539
|
}
|
|
7487
7540
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
7488
|
-
const configs = (0,
|
|
7541
|
+
const configs = (0, import_node_fs20.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
7489
7542
|
cwd: workspaceRoot
|
|
7490
7543
|
}).map((config) => toPosix2(config));
|
|
7491
7544
|
return configs.flatMap((relativePath) => {
|
|
7492
|
-
const configPath = (0,
|
|
7545
|
+
const configPath = (0, import_node_path27.join)(workspaceRoot, relativePath);
|
|
7493
7546
|
if (!fileExists(configPath)) {
|
|
7494
7547
|
return [];
|
|
7495
7548
|
}
|
|
@@ -7523,7 +7576,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
7523
7576
|
});
|
|
7524
7577
|
}
|
|
7525
7578
|
function collectFindings(workspaceRoot) {
|
|
7526
|
-
const nxJsonPath = (0,
|
|
7579
|
+
const nxJsonPath = (0, import_node_path27.join)(workspaceRoot, "nx.json");
|
|
7527
7580
|
if (!fileExists(nxJsonPath)) {
|
|
7528
7581
|
throw new Error(
|
|
7529
7582
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -7647,11 +7700,11 @@ function runCommands(program, options) {
|
|
|
7647
7700
|
}
|
|
7648
7701
|
|
|
7649
7702
|
// src/workspace-info/list-projects.use-case.ts
|
|
7650
|
-
var
|
|
7703
|
+
var import_node_path28 = require("path");
|
|
7651
7704
|
var TYPE_TAG_PREFIX = "type:";
|
|
7652
7705
|
function listProjects(workspaceRoot) {
|
|
7653
7706
|
return locateProjects(workspaceRoot).map((location) => {
|
|
7654
|
-
const projectJsonPath = (0,
|
|
7707
|
+
const projectJsonPath = (0, import_node_path28.join)(workspaceRoot, location.dir, "project.json");
|
|
7655
7708
|
const project = fileExists(projectJsonPath) ? readJson(projectJsonPath) : {};
|
|
7656
7709
|
const typeTag = (project.tags ?? []).find((tag) => tag.startsWith(TYPE_TAG_PREFIX));
|
|
7657
7710
|
return {
|
|
@@ -7664,7 +7717,7 @@ function listProjects(workspaceRoot) {
|
|
|
7664
7717
|
}).toSorted((a, b) => a.dir.localeCompare(b.dir));
|
|
7665
7718
|
}
|
|
7666
7719
|
function runProjects(workspaceRoot, options) {
|
|
7667
|
-
if (!fileExists((0,
|
|
7720
|
+
if (!fileExists((0, import_node_path28.join)(workspaceRoot, "nx.json"))) {
|
|
7668
7721
|
throw new Error("No nx.json found here. Run `projects` from the workspace root.");
|
|
7669
7722
|
}
|
|
7670
7723
|
const projects = listProjects(workspaceRoot);
|
|
@@ -7678,11 +7731,11 @@ function runProjects(workspaceRoot, options) {
|
|
|
7678
7731
|
}
|
|
7679
7732
|
|
|
7680
7733
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7681
|
-
var
|
|
7734
|
+
var import_node_path30 = require("path");
|
|
7682
7735
|
|
|
7683
7736
|
// src/cli-version/check-for-update.use-case.ts
|
|
7684
|
-
var
|
|
7685
|
-
var
|
|
7737
|
+
var import_node_fs21 = require("fs");
|
|
7738
|
+
var import_node_path29 = require("path");
|
|
7686
7739
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
7687
7740
|
var PACKAGE_NAME = "@mnci/cli";
|
|
7688
7741
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -7741,8 +7794,8 @@ function releaseTriple(version) {
|
|
|
7741
7794
|
}
|
|
7742
7795
|
function readCliVersion(packageDirectory) {
|
|
7743
7796
|
try {
|
|
7744
|
-
const manifestPath = (0,
|
|
7745
|
-
const manifest = JSON.parse((0,
|
|
7797
|
+
const manifestPath = (0, import_node_path29.join)(packageDirectory, "..", "package.json");
|
|
7798
|
+
const manifest = JSON.parse((0, import_node_fs21.readFileSync)(manifestPath, "utf8"));
|
|
7746
7799
|
return manifest.version ?? "0.0.0";
|
|
7747
7800
|
} catch {
|
|
7748
7801
|
return "0.0.0";
|
|
@@ -7752,7 +7805,7 @@ function readCliVersion(packageDirectory) {
|
|
|
7752
7805
|
// src/workspace-info/read-workspace-info.use-case.ts
|
|
7753
7806
|
function readWorkspaceInfo(workspaceRoot, cliVersion) {
|
|
7754
7807
|
const latest = fetchLatestVersion() ?? null;
|
|
7755
|
-
const isWorkspace = fileExists((0,
|
|
7808
|
+
const isWorkspace = fileExists((0, import_node_path30.join)(workspaceRoot, "nx.json"));
|
|
7756
7809
|
return {
|
|
7757
7810
|
cli: {
|
|
7758
7811
|
version: cliVersion,
|
|
@@ -7773,8 +7826,8 @@ function runInfo(workspaceRoot, cliVersion, options) {
|
|
|
7773
7826
|
}
|
|
7774
7827
|
|
|
7775
7828
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
7776
|
-
var
|
|
7777
|
-
var
|
|
7829
|
+
var import_node_fs22 = require("fs");
|
|
7830
|
+
var import_node_path31 = require("path");
|
|
7778
7831
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
7779
7832
|
var AGENT_AND_CI_ENTRIES = [
|
|
7780
7833
|
"AGENTS.md",
|
|
@@ -7805,13 +7858,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
7805
7858
|
"packages"
|
|
7806
7859
|
];
|
|
7807
7860
|
function assertAdoptableDirectory(target) {
|
|
7808
|
-
if (!(0,
|
|
7861
|
+
if (!(0, import_node_fs22.existsSync)(target)) {
|
|
7809
7862
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
7810
7863
|
}
|
|
7811
|
-
if (!(0,
|
|
7864
|
+
if (!(0, import_node_fs22.statSync)(target).isDirectory()) {
|
|
7812
7865
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
7813
7866
|
}
|
|
7814
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
7867
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs22.existsSync)((0, import_node_path31.join)(target, entry)));
|
|
7815
7868
|
if (blockers.length > 0) {
|
|
7816
7869
|
throw new Error(
|
|
7817
7870
|
`--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.`
|
|
@@ -7819,15 +7872,15 @@ function assertAdoptableDirectory(target) {
|
|
|
7819
7872
|
}
|
|
7820
7873
|
}
|
|
7821
7874
|
function mergeGitignore(generatedFile, targetFile) {
|
|
7822
|
-
const existing = (0,
|
|
7875
|
+
const existing = (0, import_node_fs22.readFileSync)(targetFile, "utf8");
|
|
7823
7876
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
7824
|
-
const additions = (0,
|
|
7877
|
+
const additions = (0, import_node_fs22.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
7825
7878
|
const trimmed = line.trim();
|
|
7826
7879
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
7827
7880
|
});
|
|
7828
7881
|
if (additions.length === 0) return false;
|
|
7829
7882
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
7830
|
-
(0,
|
|
7883
|
+
(0, import_node_fs22.writeFileSync)(
|
|
7831
7884
|
targetFile,
|
|
7832
7885
|
`${existing}${separator}
|
|
7833
7886
|
# Added by mnci (Nx workspace)
|
|
@@ -7837,9 +7890,9 @@ ${additions.join("\n")}
|
|
|
7837
7890
|
return true;
|
|
7838
7891
|
}
|
|
7839
7892
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
7840
|
-
const entries = (0,
|
|
7893
|
+
const entries = (0, import_node_fs22.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
7841
7894
|
const collisions = entries.filter(
|
|
7842
|
-
(entry) => (0,
|
|
7895
|
+
(entry) => (0, import_node_fs22.existsSync)((0, import_node_path31.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
7843
7896
|
);
|
|
7844
7897
|
if (collisions.length > 0) {
|
|
7845
7898
|
throw new Error(
|
|
@@ -7848,28 +7901,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
7848
7901
|
}
|
|
7849
7902
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
7850
7903
|
for (const entry of entries) {
|
|
7851
|
-
const from = (0,
|
|
7852
|
-
const to = (0,
|
|
7853
|
-
if (entry === ".gitignore" && (0,
|
|
7904
|
+
const from = (0, import_node_path31.join)(generatedRoot, entry);
|
|
7905
|
+
const to = (0, import_node_path31.join)(target, entry);
|
|
7906
|
+
if (entry === ".gitignore" && (0, import_node_fs22.existsSync)(to)) {
|
|
7854
7907
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
7855
7908
|
result.kept.push(entry);
|
|
7856
7909
|
continue;
|
|
7857
7910
|
}
|
|
7858
|
-
if ((0,
|
|
7911
|
+
if ((0, import_node_fs22.existsSync)(to)) {
|
|
7859
7912
|
result.kept.push(entry);
|
|
7860
7913
|
continue;
|
|
7861
7914
|
}
|
|
7862
|
-
(0,
|
|
7915
|
+
(0, import_node_fs22.cpSync)(from, to, { recursive: true });
|
|
7863
7916
|
result.copied.push(entry);
|
|
7864
7917
|
}
|
|
7865
|
-
(0,
|
|
7918
|
+
(0, import_node_fs22.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
7866
7919
|
return result;
|
|
7867
7920
|
}
|
|
7868
7921
|
|
|
7869
7922
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
7870
|
-
var
|
|
7923
|
+
var import_node_fs23 = require("fs");
|
|
7871
7924
|
var import_node_os = require("os");
|
|
7872
|
-
var
|
|
7925
|
+
var import_node_path32 = require("path");
|
|
7873
7926
|
function nxCloudProviderValue(ci) {
|
|
7874
7927
|
return ci === "azure" ? "azure" : "github";
|
|
7875
7928
|
}
|
|
@@ -7912,9 +7965,9 @@ async function resolveRegistry(options) {
|
|
|
7912
7965
|
return await promptRegistry();
|
|
7913
7966
|
}
|
|
7914
7967
|
async function runNew(name, options) {
|
|
7915
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
7968
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path32.resolve)(process.cwd(), options.into);
|
|
7916
7969
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
7917
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
7970
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path32.basename)(adoptTarget));
|
|
7918
7971
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
7919
7972
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
7920
7973
|
const registry = await resolveRegistry(options);
|
|
@@ -7927,8 +7980,8 @@ async function runNew(name, options) {
|
|
|
7927
7980
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
7928
7981
|
const stack = await resolveStack(options);
|
|
7929
7982
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
7930
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
7931
|
-
let workspaceRoot = (0,
|
|
7983
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs23.mkdtempSync)((0, import_node_path32.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
7984
|
+
let workspaceRoot = (0, import_node_path32.join)(stagingParent, workspaceName);
|
|
7932
7985
|
try {
|
|
7933
7986
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
7934
7987
|
runNpx(
|
|
@@ -7951,7 +8004,7 @@ async function runNew(name, options) {
|
|
|
7951
8004
|
workspaceRoot = adoptTarget;
|
|
7952
8005
|
}
|
|
7953
8006
|
} finally {
|
|
7954
|
-
if (adoptTarget !== void 0) (0,
|
|
8007
|
+
if (adoptTarget !== void 0) (0, import_node_fs23.rmSync)(stagingParent, { recursive: true, force: true });
|
|
7955
8008
|
}
|
|
7956
8009
|
logger.step(
|
|
7957
8010
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -7961,8 +8014,8 @@ async function runNew(name, options) {
|
|
|
7961
8014
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
7962
8015
|
logger.detail
|
|
7963
8016
|
);
|
|
7964
|
-
(0,
|
|
7965
|
-
(0,
|
|
8017
|
+
(0, import_node_fs23.rmSync)((0, import_node_path32.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
8018
|
+
(0, import_node_fs23.rmSync)((0, import_node_path32.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
7966
8019
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
7967
8020
|
const installStatus = runShell(
|
|
7968
8021
|
"npm",
|
|
@@ -8000,12 +8053,12 @@ function projectKindHintLines(kinds = PROJECT_KINDS) {
|
|
|
8000
8053
|
}
|
|
8001
8054
|
|
|
8002
8055
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8003
|
-
var
|
|
8056
|
+
var import_node_path34 = require("path");
|
|
8004
8057
|
var import_prompts4 = require("@inquirer/prompts");
|
|
8005
8058
|
|
|
8006
8059
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
8007
|
-
var
|
|
8008
|
-
var
|
|
8060
|
+
var import_node_fs24 = require("fs");
|
|
8061
|
+
var import_node_path33 = require("path");
|
|
8009
8062
|
function resolveRegistry2(options, persisted) {
|
|
8010
8063
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
8011
8064
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -8034,7 +8087,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8034
8087
|
return persisted.workspaceName;
|
|
8035
8088
|
}
|
|
8036
8089
|
try {
|
|
8037
|
-
const existing = (0,
|
|
8090
|
+
const existing = (0, import_node_fs24.readdirSync)(workspaceRoot).find(
|
|
8038
8091
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
8039
8092
|
);
|
|
8040
8093
|
if (existing) {
|
|
@@ -8042,11 +8095,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
8042
8095
|
}
|
|
8043
8096
|
} catch {
|
|
8044
8097
|
}
|
|
8045
|
-
return (0,
|
|
8098
|
+
return (0, import_node_path33.basename)(workspaceRoot);
|
|
8046
8099
|
}
|
|
8047
8100
|
function detectNpmAuth(workspaceRoot) {
|
|
8048
8101
|
try {
|
|
8049
|
-
return (0,
|
|
8102
|
+
return (0, import_node_fs24.readFileSync)((0, import_node_path33.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
8050
8103
|
} catch {
|
|
8051
8104
|
return void 0;
|
|
8052
8105
|
}
|
|
@@ -8093,7 +8146,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
8093
8146
|
};
|
|
8094
8147
|
}
|
|
8095
8148
|
function runUpgrade(workspaceRoot, options) {
|
|
8096
|
-
if (!fileExists((0,
|
|
8149
|
+
if (!fileExists((0, import_node_path33.join)(workspaceRoot, "nx.json"))) {
|
|
8097
8150
|
throw new Error(
|
|
8098
8151
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
8099
8152
|
);
|
|
@@ -8158,7 +8211,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
8158
8211
|
|
|
8159
8212
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
8160
8213
|
async function runInteractive() {
|
|
8161
|
-
const inWorkspace = fileExists((0,
|
|
8214
|
+
const inWorkspace = fileExists((0, import_node_path34.join)(process.cwd(), "nx.json"));
|
|
8162
8215
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
8163
8216
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
8164
8217
|
const choiceUpgrade = {
|
|
@@ -8211,7 +8264,7 @@ function buildProgram(cliVersion) {
|
|
|
8211
8264
|
runDoctor(process.cwd(), options);
|
|
8212
8265
|
});
|
|
8213
8266
|
program.command("ci").addArgument(new import_commander.Argument("<phase>", "which phase of the pipeline to run").choices(CI_PHASES)).description(
|
|
8214
|
-
"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"
|
|
8267
|
+
"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. `pack` builds the per-app artifacts, `release` versions, tags and publishes, and `native` builds the apps that need a C toolchain on this OS. Exits non-zero when it fails"
|
|
8215
8268
|
).action(async (phase) => {
|
|
8216
8269
|
process.exitCode = await runCiPhase(phase, process.cwd());
|
|
8217
8270
|
});
|