@mnci/cli 4.0.3 → 4.0.5
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 +42 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -52,6 +52,16 @@ var logger = {
|
|
|
52
52
|
step(message) {
|
|
53
53
|
console.log(`\u2192 ${message}`);
|
|
54
54
|
},
|
|
55
|
+
/**
|
|
56
|
+
* A sub-step under the most recent {@link logger.step}, indented to read as detail.
|
|
57
|
+
*
|
|
58
|
+
* `this: void` because this one is handed to `applyOverlay` as a progress callback,
|
|
59
|
+
* detached from the object. It reads no instance state, and the annotation is what
|
|
60
|
+
* says so — without it every such call is an unbound-method error.
|
|
61
|
+
*/
|
|
62
|
+
detail(message) {
|
|
63
|
+
console.log(` \xB7 ${message}`);
|
|
64
|
+
},
|
|
55
65
|
success(message) {
|
|
56
66
|
console.log(`\u2713 ${message}`);
|
|
57
67
|
},
|
|
@@ -1630,14 +1640,15 @@ function launchConfigurations(workspaceName) {
|
|
|
1630
1640
|
presentation: { group: "mnci", order: index + 1 }
|
|
1631
1641
|
}));
|
|
1632
1642
|
}
|
|
1633
|
-
function vscodeWorkspace(workspaceName, existingTasks, existingLaunch) {
|
|
1643
|
+
function vscodeWorkspace(workspaceName, existingTasks, existingLaunch, existingSettings) {
|
|
1634
1644
|
const userConfigurations = (existingLaunch?.configurations ?? []).filter(
|
|
1635
1645
|
(configuration) => !String(configuration.name ?? "").startsWith(LAUNCH_CONFIG_PREFIX)
|
|
1636
1646
|
);
|
|
1647
|
+
const settings = { ...existingSettings, ...vscodeSettings() };
|
|
1637
1648
|
return JSON.stringify(
|
|
1638
1649
|
{
|
|
1639
1650
|
folders: [{ path: ".", name: workspaceName }],
|
|
1640
|
-
settings
|
|
1651
|
+
settings,
|
|
1641
1652
|
extensions: { recommendations: VSCODE_RECOMMENDED_EXTENSIONS },
|
|
1642
1653
|
tasks: {
|
|
1643
1654
|
version: existingTasks?.version ?? "2.0.0",
|
|
@@ -2234,7 +2245,8 @@ function removeProjectEslintConfigs(workspaceRoot) {
|
|
|
2234
2245
|
(0, import_node_fs6.rmSync)((0, import_node_path11.join)(workspaceRoot, match), { force: true });
|
|
2235
2246
|
}
|
|
2236
2247
|
}
|
|
2237
|
-
function applyOverlay(workspaceRoot, options) {
|
|
2248
|
+
function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
2249
|
+
}) {
|
|
2238
2250
|
const nxJsonPath = (0, import_node_path11.join)(workspaceRoot, "nx.json");
|
|
2239
2251
|
const nxJson = readJson(nxJsonPath);
|
|
2240
2252
|
const generators = {
|
|
@@ -2244,7 +2256,9 @@ function applyOverlay(workspaceRoot, options) {
|
|
|
2244
2256
|
const sync = { ...nxJson.sync, ...SYNC_CONFIG };
|
|
2245
2257
|
const mnci = { ...nxJson.mnci, ...mnciConfig(options) };
|
|
2246
2258
|
const patched = withSharedGlobals(withEslintPlugin(withReleaseConfig(nxJson, options.ci)));
|
|
2259
|
+
onProgress("nx.json \u2014 release, sync, generators, shared inputs, mnci block");
|
|
2247
2260
|
writeFileEnsured(nxJsonPath, toJson({ ...patched, generators, sync, mnci }));
|
|
2261
|
+
onProgress("package.json \u2014 root scripts, TS compilers, ESLint toolchain, overrides");
|
|
2248
2262
|
const manifestPath = (0, import_node_path11.join)(workspaceRoot, "package.json");
|
|
2249
2263
|
const manifest = readJson(manifestPath);
|
|
2250
2264
|
const scripts = {
|
|
@@ -2283,37 +2297,53 @@ function applyOverlay(workspaceRoot, options) {
|
|
|
2283
2297
|
nx
|
|
2284
2298
|
})
|
|
2285
2299
|
);
|
|
2300
|
+
onProgress(
|
|
2301
|
+
`.npmrc \u2014 ${options.registry.kind === "azure-artifacts" ? "Azure Artifacts feed routing and credentials" : "public npm registry auth"}`
|
|
2302
|
+
);
|
|
2286
2303
|
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, ".npmrc"), npmrcContent(options.registry, options.scope));
|
|
2304
|
+
onProgress("commitlint.config.mjs and .husky/commit-msg \u2014 conventional commit enforcement");
|
|
2287
2305
|
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, "commitlint.config.mjs"), COMMITLINT_CONFIG);
|
|
2288
2306
|
const hookPath = (0, import_node_path11.join)(workspaceRoot, ".husky/commit-msg");
|
|
2289
2307
|
writeFileEnsured(hookPath, COMMIT_MSG_HOOK);
|
|
2290
2308
|
markExecutable(hookPath);
|
|
2309
|
+
onProgress("eslint.config.mjs \u2014 the shared lint AND formatting opinion");
|
|
2291
2310
|
writeFileEnsured((0, import_node_path11.join)(workspaceRoot, "eslint.config.mjs"), ESLINT_CONFIG);
|
|
2292
2311
|
for (const retired of RETIRED_FORMATTER_FILES) {
|
|
2293
2312
|
removeIfPresent((0, import_node_path11.join)(workspaceRoot, retired));
|
|
2294
2313
|
}
|
|
2314
|
+
onProgress(".devcontainer/devcontainer.json \u2014 a local toolchain matching CI");
|
|
2295
2315
|
writeFileEnsured(
|
|
2296
2316
|
(0, import_node_path11.join)(workspaceRoot, ".devcontainer/devcontainer.json"),
|
|
2297
2317
|
devcontainerJson(options.workspaceName)
|
|
2298
2318
|
);
|
|
2299
2319
|
removeNxScaffolding(workspaceRoot);
|
|
2320
|
+
onProgress(
|
|
2321
|
+
`${options.workspaceName}.code-workspace \u2014 settings, extensions, launch configs`
|
|
2322
|
+
);
|
|
2300
2323
|
const codeWorkspacePath = (0, import_node_path11.join)(workspaceRoot, `${options.workspaceName}.code-workspace`);
|
|
2301
2324
|
const existing = readCodeWorkspace(codeWorkspacePath);
|
|
2302
2325
|
writeFileEnsured(
|
|
2303
2326
|
codeWorkspacePath,
|
|
2304
|
-
vscodeWorkspace(
|
|
2327
|
+
vscodeWorkspace(
|
|
2328
|
+
options.workspaceName,
|
|
2329
|
+
existing?.tasks,
|
|
2330
|
+
existing?.launch,
|
|
2331
|
+
existing?.settings
|
|
2332
|
+
)
|
|
2305
2333
|
);
|
|
2306
2334
|
if (options.workspaceName !== "undefined") {
|
|
2307
2335
|
(0, import_node_fs6.rmSync)((0, import_node_path11.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
|
|
2308
2336
|
}
|
|
2309
2337
|
const publishUrl = pythonPublishUrl(options.registry);
|
|
2310
2338
|
if (options.ci === "azure" || options.ci === "both") {
|
|
2339
|
+
onProgress("azure-pipelines.yml \u2014 build, verify, pack and release");
|
|
2311
2340
|
writeFileEnsured(
|
|
2312
2341
|
(0, import_node_path11.join)(workspaceRoot, "azure-pipelines.yml"),
|
|
2313
2342
|
azurePipelinesYaml(options.agent, options.variableGroup, publishUrl, options.registry.kind)
|
|
2314
2343
|
);
|
|
2315
2344
|
}
|
|
2316
2345
|
if (options.ci === "github" || options.ci === "both") {
|
|
2346
|
+
onProgress(".github/workflows/ci.yml and dependabot.yml");
|
|
2317
2347
|
writeFileEnsured(
|
|
2318
2348
|
(0, import_node_path11.join)(workspaceRoot, ".github/workflows/ci.yml"),
|
|
2319
2349
|
githubActionsYaml(options.agent, publishUrl, options.registry.kind, options.ci)
|
|
@@ -2622,7 +2652,11 @@ async function runNew(name, options) {
|
|
|
2622
2652
|
logger.step(
|
|
2623
2653
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
2624
2654
|
);
|
|
2625
|
-
applyOverlay(
|
|
2655
|
+
applyOverlay(
|
|
2656
|
+
workspaceRoot,
|
|
2657
|
+
{ workspaceName, scope, registry, agent, variableGroup, ci, stack },
|
|
2658
|
+
logger.detail
|
|
2659
|
+
);
|
|
2626
2660
|
(0, import_node_fs8.rmSync)((0, import_node_path13.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
2627
2661
|
(0, import_node_fs8.rmSync)((0, import_node_path13.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
2628
2662
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
@@ -2737,10 +2771,11 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
2737
2771
|
}
|
|
2738
2772
|
const persisted = readMnciConfig(workspaceRoot);
|
|
2739
2773
|
const resolved = resolveOverlayOptions(workspaceRoot, options, persisted);
|
|
2774
|
+
logger.step("Re-applying the MoNecromanCI overlay");
|
|
2775
|
+
applyOverlay(workspaceRoot, resolved, logger.detail);
|
|
2740
2776
|
logger.step(
|
|
2741
|
-
"
|
|
2777
|
+
"Formatting the workspace (eslint --fix) \u2014 the slowest step, minutes on a large workspace"
|
|
2742
2778
|
);
|
|
2743
|
-
applyOverlay(workspaceRoot, resolved);
|
|
2744
2779
|
runFormatter(workspaceRoot);
|
|
2745
2780
|
logger.success("Done. Review the changes with `git diff` before committing.");
|
|
2746
2781
|
}
|