@mnci/cli 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/cli.js +55 -16
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,9 +146,17 @@ same options `new` would have and calls the exact same `applyOverlay` `new`
|
|
|
146
146
|
itself calls — the one function that does every bit of `mnci`-owned file
|
|
147
147
|
writing (`nx.json`'s `release`/`sync`/`generators`/`mnci` blocks, `.npmrc`,
|
|
148
148
|
`eslint.config.mjs`, `.prettierrc.json`, `commitlint.config.mjs`,
|
|
149
|
-
`.husky/commit-msg`, the CI pipeline file(s),
|
|
150
|
-
`
|
|
151
|
-
|
|
149
|
+
`.husky/commit-msg`, the CI pipeline file(s), the
|
|
150
|
+
`<workspace-name>.code-workspace` file, and the curated root `package.json`
|
|
151
|
+
scripts). Nothing else in the workspace — app/lib source, `project.json` targets
|
|
152
|
+
from `mnci add` — is ever touched, and it finishes by running Prettier over the
|
|
153
|
+
result, the same way `new` and every `add` do.
|
|
154
|
+
|
|
155
|
+
The `.code-workspace` file is the one partial case, and deliberately so: its
|
|
156
|
+
folders, settings and extensions are regenerated, but the **`tasks` array is read
|
|
157
|
+
back and carried through unchanged**. Those tasks are per-project state written by
|
|
158
|
+
`mnci add`, not overlay-owned, so regenerating them wholesale would wipe every
|
|
159
|
+
project's build/qa/start entry on upgrade.
|
|
152
160
|
|
|
153
161
|
`upgrade` also **deletes** things, which is stronger than the overwriting it
|
|
154
162
|
has always done — one more reason to run `git diff` first, as the command's own
|
package/dist/cli.js
CHANGED
|
@@ -150,6 +150,13 @@ var import_node_path = require("path");
|
|
|
150
150
|
function readJson(path) {
|
|
151
151
|
return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
|
|
152
152
|
}
|
|
153
|
+
function readCodeWorkspace(path) {
|
|
154
|
+
try {
|
|
155
|
+
return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8").replaceAll(/,(\s*[}\]])/g, "$1"));
|
|
156
|
+
} catch {
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
153
160
|
function toJson(value) {
|
|
154
161
|
return `${JSON.stringify(value, void 0, 2)}
|
|
155
162
|
`;
|
|
@@ -234,10 +241,6 @@ function findCodeWorkspaceFile(workspaceRoot) {
|
|
|
234
241
|
return void 0;
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
|
-
function readCodeWorkspaceFile(path) {
|
|
238
|
-
const contents = (0, import_node_fs2.readFileSync)(path, "utf8").replaceAll(/,(\s*[}\]])/g, "$1");
|
|
239
|
-
return JSON.parse(contents);
|
|
240
|
-
}
|
|
241
244
|
function projectTask(name, kind) {
|
|
242
245
|
const script = `${name}:${kind}`;
|
|
243
246
|
const base = { label: `${name}: ${kind}`, type: "npm", script, problemMatcher: [] };
|
|
@@ -264,7 +267,7 @@ function registerProjectCommands(workspaceRoot, name, commands) {
|
|
|
264
267
|
if (!codeWorkspacePath) {
|
|
265
268
|
return;
|
|
266
269
|
}
|
|
267
|
-
const workspaceFile =
|
|
270
|
+
const workspaceFile = readCodeWorkspace(codeWorkspacePath) ?? {};
|
|
268
271
|
const label = (task) => task.label ?? "";
|
|
269
272
|
const existingTasks = (workspaceFile.tasks?.tasks ?? []).filter(
|
|
270
273
|
(task) => !label(task).startsWith(`${name}: `)
|
|
@@ -1276,7 +1279,7 @@ __pycache__
|
|
|
1276
1279
|
.ruff_cache
|
|
1277
1280
|
.dart_tool
|
|
1278
1281
|
`;
|
|
1279
|
-
function vscodeWorkspace(workspaceName) {
|
|
1282
|
+
function vscodeWorkspace(workspaceName, existingTasks) {
|
|
1280
1283
|
return JSON.stringify(
|
|
1281
1284
|
{
|
|
1282
1285
|
folders: [{ path: ".", name: workspaceName }],
|
|
@@ -1314,7 +1317,10 @@ function vscodeWorkspace(workspaceName) {
|
|
|
1314
1317
|
"firsttris.vscode-jest-runner"
|
|
1315
1318
|
]
|
|
1316
1319
|
},
|
|
1317
|
-
tasks: {
|
|
1320
|
+
tasks: {
|
|
1321
|
+
version: existingTasks?.version ?? "2.0.0",
|
|
1322
|
+
tasks: existingTasks?.tasks ?? []
|
|
1323
|
+
}
|
|
1318
1324
|
},
|
|
1319
1325
|
null,
|
|
1320
1326
|
2
|
|
@@ -1356,6 +1362,12 @@ function generatorDefaults(stack) {
|
|
|
1356
1362
|
}
|
|
1357
1363
|
function mnciConfig(options) {
|
|
1358
1364
|
return {
|
|
1365
|
+
// Persisted so `mnci upgrade` can name the `<name>.code-workspace` file it
|
|
1366
|
+
// rewrites. Its absence is why upgrade used to write a file literally called
|
|
1367
|
+
// `undefined.code-workspace` and therefore never refreshed the real one —
|
|
1368
|
+
// see `resolveWorkspaceName` in `commands/upgrade.ts`, which still needs a
|
|
1369
|
+
// fallback chain for workspaces generated before this field existed.
|
|
1370
|
+
workspaceName: options.workspaceName,
|
|
1359
1371
|
scope: options.scope,
|
|
1360
1372
|
registry: options.registry,
|
|
1361
1373
|
agent: options.agent,
|
|
@@ -1856,10 +1868,12 @@ function applyOverlay(workspaceRoot, options) {
|
|
|
1856
1868
|
writeFileEnsured((0, import_node_path10.join)(workspaceRoot, ".prettierrc.json"), PRETTIER_CONFIG);
|
|
1857
1869
|
writeFileEnsured((0, import_node_path10.join)(workspaceRoot, ".prettierignore"), PRETTIER_IGNORE);
|
|
1858
1870
|
removeNxScaffolding(workspaceRoot);
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
)
|
|
1871
|
+
const codeWorkspacePath = (0, import_node_path10.join)(workspaceRoot, `${options.workspaceName}.code-workspace`);
|
|
1872
|
+
const existing = readCodeWorkspace(codeWorkspacePath);
|
|
1873
|
+
writeFileEnsured(codeWorkspacePath, vscodeWorkspace(options.workspaceName, existing?.tasks));
|
|
1874
|
+
if (options.workspaceName !== "undefined") {
|
|
1875
|
+
(0, import_node_fs6.rmSync)((0, import_node_path10.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
|
|
1876
|
+
}
|
|
1863
1877
|
const publishUrl = pythonPublishUrl(options.registry);
|
|
1864
1878
|
if (options.ci === "azure" || options.ci === "both") {
|
|
1865
1879
|
writeFileEnsured(
|
|
@@ -1976,6 +1990,7 @@ async function runNew(name, options) {
|
|
|
1976
1990
|
}
|
|
1977
1991
|
|
|
1978
1992
|
// src/commands/upgrade.ts
|
|
1993
|
+
var import_node_fs7 = require("fs");
|
|
1979
1994
|
var import_node_path12 = require("path");
|
|
1980
1995
|
function resolveRegistry2(options, persisted) {
|
|
1981
1996
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
@@ -2000,7 +2015,22 @@ function resolveRegistry2(options, persisted) {
|
|
|
2000
2015
|
"No registry found in nx.json's persisted config. Pass --registry npm or --registry azure-artifacts (with --organization/--project/--artifacts-feed)."
|
|
2001
2016
|
);
|
|
2002
2017
|
}
|
|
2003
|
-
function
|
|
2018
|
+
function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
2019
|
+
if (persisted.workspaceName) {
|
|
2020
|
+
return persisted.workspaceName;
|
|
2021
|
+
}
|
|
2022
|
+
try {
|
|
2023
|
+
const existing = (0, import_node_fs7.readdirSync)(workspaceRoot).find(
|
|
2024
|
+
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
2025
|
+
);
|
|
2026
|
+
if (existing) {
|
|
2027
|
+
return existing.replace(/\.code-workspace$/, "");
|
|
2028
|
+
}
|
|
2029
|
+
} catch {
|
|
2030
|
+
}
|
|
2031
|
+
return (0, import_node_path12.basename)(workspaceRoot);
|
|
2032
|
+
}
|
|
2033
|
+
function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
2004
2034
|
const scope = options.scope ?? persisted.scope;
|
|
2005
2035
|
if (!scope) {
|
|
2006
2036
|
throw new Error("No npm scope found in nx.json's persisted config. Pass --scope explicitly.");
|
|
@@ -2025,7 +2055,15 @@ function resolveOverlayOptions(options, persisted) {
|
|
|
2025
2055
|
"No testRunner found in nx.json's persisted config. Pass --test-runner explicitly."
|
|
2026
2056
|
);
|
|
2027
2057
|
}
|
|
2028
|
-
return {
|
|
2058
|
+
return {
|
|
2059
|
+
workspaceName: resolveWorkspaceName(workspaceRoot, persisted),
|
|
2060
|
+
scope,
|
|
2061
|
+
registry,
|
|
2062
|
+
agent,
|
|
2063
|
+
variableGroup,
|
|
2064
|
+
ci,
|
|
2065
|
+
stack: { testRunner }
|
|
2066
|
+
};
|
|
2029
2067
|
}
|
|
2030
2068
|
function runUpgrade(workspaceRoot, options) {
|
|
2031
2069
|
if (!fileExists((0, import_node_path12.join)(workspaceRoot, "nx.json"))) {
|
|
@@ -2034,11 +2072,12 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
2034
2072
|
);
|
|
2035
2073
|
}
|
|
2036
2074
|
const persisted = readMnciConfig(workspaceRoot);
|
|
2037
|
-
const resolved = resolveOverlayOptions(options, persisted);
|
|
2075
|
+
const resolved = resolveOverlayOptions(workspaceRoot, options, persisted);
|
|
2038
2076
|
logger.step(
|
|
2039
2077
|
"Re-applying the MoNecromanCI overlay (release config, .npmrc, commitlint, pipeline, stack)"
|
|
2040
2078
|
);
|
|
2041
2079
|
applyOverlay(workspaceRoot, resolved);
|
|
2080
|
+
runPrettier(workspaceRoot);
|
|
2042
2081
|
logger.success("Done. Review the changes with `git diff` before committing.");
|
|
2043
2082
|
}
|
|
2044
2083
|
|
|
@@ -2065,7 +2104,7 @@ async function runInteractive() {
|
|
|
2065
2104
|
}
|
|
2066
2105
|
|
|
2067
2106
|
// src/util/versionChecker.ts
|
|
2068
|
-
var
|
|
2107
|
+
var import_node_fs8 = require("fs");
|
|
2069
2108
|
var import_node_path14 = require("path");
|
|
2070
2109
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
2071
2110
|
var PACKAGE_NAME = "@mnci/cli";
|
|
@@ -2123,7 +2162,7 @@ function releaseTriple(version) {
|
|
|
2123
2162
|
function readCliVersion(packageDirectory) {
|
|
2124
2163
|
try {
|
|
2125
2164
|
const manifestPath = (0, import_node_path14.join)(packageDirectory, "..", "package.json");
|
|
2126
|
-
const manifest = JSON.parse((0,
|
|
2165
|
+
const manifest = JSON.parse((0, import_node_fs8.readFileSync)(manifestPath, "utf8"));
|
|
2127
2166
|
return manifest.version ?? "0.0.0";
|
|
2128
2167
|
} catch {
|
|
2129
2168
|
return "0.0.0";
|