@mnci/cli 4.40.5 → 4.40.6
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 +55 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5200,6 +5200,10 @@ function sourceMapCapableCompiler(indent) {
|
|
|
5200
5200
|
].join("\n");
|
|
5201
5201
|
}
|
|
5202
5202
|
var ROLLUP_ARG_ONE_BOUNDARY = [" },", " {", ""].join("\n");
|
|
5203
|
+
var ROLLUP_ARG_ONE_BOUNDARY_ONE_LINE = /^ {2}\},[ \t]*\{[ \t]*$/m;
|
|
5204
|
+
function withBoundaryOnTwoLines(config) {
|
|
5205
|
+
return config.replace(ROLLUP_ARG_ONE_BOUNDARY_ONE_LINE, () => ROLLUP_ARG_ONE_BOUNDARY.replace(/\n$/, ""));
|
|
5206
|
+
}
|
|
5203
5207
|
var ROLLUP_ARG_ONE_WITH_SOURCE_MAPS = [
|
|
5204
5208
|
" // Added by MoNecromanCI: without this rollup emits no .js.map at all, so",
|
|
5205
5209
|
" // a breakpoint in a .ts file can never bind. Not published - see `files`.",
|
|
@@ -5212,12 +5216,13 @@ function hasRollupSourceMaps(config) {
|
|
|
5212
5216
|
return /sourceMap\s*:\s*true\b/.test(config);
|
|
5213
5217
|
}
|
|
5214
5218
|
function canRepairRollupConfig(config) {
|
|
5215
|
-
return config.includes(ROLLUP_ARG_ONE_BOUNDARY);
|
|
5219
|
+
return config.includes(ROLLUP_ARG_ONE_BOUNDARY) || ROLLUP_ARG_ONE_BOUNDARY_ONE_LINE.test(config);
|
|
5216
5220
|
}
|
|
5217
|
-
function withRollupSourceMaps(
|
|
5218
|
-
if (hasRollupSourceMaps(
|
|
5219
|
-
return
|
|
5221
|
+
function withRollupSourceMaps(original) {
|
|
5222
|
+
if (hasRollupSourceMaps(original) || !canRepairRollupConfig(original)) {
|
|
5223
|
+
return original;
|
|
5220
5224
|
}
|
|
5225
|
+
const config = withBoundaryOnTwoLines(original);
|
|
5221
5226
|
const withCompiler = config.replace(
|
|
5222
5227
|
GENERATED_COMPILER_PATTERN,
|
|
5223
5228
|
(_match, indent) => sourceMapCapableCompiler(indent)
|
|
@@ -5378,6 +5383,17 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
5378
5383
|
const [start, end] = span;
|
|
5379
5384
|
return `${config.slice(0, start)}${DECLARATION_SPECIFIER_PLUGIN}${config.slice(end)}`;
|
|
5380
5385
|
}
|
|
5386
|
+
var PLUGINS_ARRAY_OPEN = /^ {4}plugins\s*:\s*\[[ \t]*$/m;
|
|
5387
|
+
function canAddDeclarationSpecifierPlugin(config) {
|
|
5388
|
+
return !hasDeclarationSpecifierPlugin(config) && !config.includes(ROLLUP_CONFIG_PLACEHOLDER) && PLUGINS_ARRAY_OPEN.test(config);
|
|
5389
|
+
}
|
|
5390
|
+
function withDeclarationSpecifierPlugin(config) {
|
|
5391
|
+
if (!canAddDeclarationSpecifierPlugin(config)) {
|
|
5392
|
+
return config;
|
|
5393
|
+
}
|
|
5394
|
+
return config.replace(PLUGINS_ARRAY_OPEN, (opening) => `${opening}
|
|
5395
|
+
${DECLARATION_SPECIFIER_PLUGIN},`);
|
|
5396
|
+
}
|
|
5381
5397
|
|
|
5382
5398
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
5383
5399
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
@@ -5419,11 +5435,33 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
5419
5435
|
}
|
|
5420
5436
|
const config = (0, import_node_fs22.readFileSync)(configPath, "utf8");
|
|
5421
5437
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
5438
|
+
const repaired = withRollupSourceMaps(withDeclarationSpecifierPlugin(config));
|
|
5439
|
+
if (repaired !== config) {
|
|
5440
|
+
writeFileEnsured(configPath, repaired);
|
|
5441
|
+
} else if (!hasDeclarationSpecifierPlugin(config)) {
|
|
5442
|
+
logger.warn(`${configPath} has a shape mnci does not recognise, so its source maps and declaration repairs were not applied; \`mnci doctor\` names what to add by hand`);
|
|
5443
|
+
}
|
|
5422
5444
|
return;
|
|
5423
5445
|
}
|
|
5424
5446
|
const withDtsFix = config.split(ROLLUP_CONFIG_PLACEHOLDER).join(ROLLUP_CONFIG_WITH_DTS_FIX);
|
|
5425
5447
|
writeFileEnsured(configPath, withRollupSourceMaps(withDtsFix));
|
|
5426
5448
|
}
|
|
5449
|
+
function addMissingDeclarationSpecifierPlugins(workspaceRoot) {
|
|
5450
|
+
const changed = [];
|
|
5451
|
+
const configs = (0, import_node_fs22.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5452
|
+
cwd: workspaceRoot
|
|
5453
|
+
});
|
|
5454
|
+
for (const relativePath of configs) {
|
|
5455
|
+
const configPath = (0, import_node_path22.join)(workspaceRoot, relativePath);
|
|
5456
|
+
const before = (0, import_node_fs22.readFileSync)(configPath, "utf8");
|
|
5457
|
+
const after = withDeclarationSpecifierPlugin(before);
|
|
5458
|
+
if (after !== before) {
|
|
5459
|
+
writeFileEnsured(configPath, after);
|
|
5460
|
+
changed.push(relativePath.replaceAll("\\", "/"));
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
return changed;
|
|
5464
|
+
}
|
|
5427
5465
|
|
|
5428
5466
|
// src/rollup-library/rollup-config.repository.ts
|
|
5429
5467
|
var import_node_fs23 = require("fs");
|
|
@@ -8186,7 +8224,7 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
8186
8224
|
check: `source maps enabled in ${relativePath}`,
|
|
8187
8225
|
ok: hasRollupSourceMaps(resolveRollupConfigText(configPath)),
|
|
8188
8226
|
detail: "rollup emits no .js.map without it, so a breakpoint in a .ts file can never bind",
|
|
8189
|
-
remedy: canRepairRollupConfig(config) ? "run `mnci upgrade`, which adds it to every rollup config" : "this config delegates via require() to a shared base
|
|
8227
|
+
remedy: canRepairRollupConfig(config) ? "run `mnci upgrade`, which adds it to every rollup config" : "mnci does not recognise the shape of this config (it edits the boundary between withNx's two arguments, which is not here; a config that delegates via require() to a shared base is one such shape) \u2014 add `sourceMap: true` to withNx's first argument by hand; `mnci upgrade` cannot repair a config in this shape"
|
|
8190
8228
|
}
|
|
8191
8229
|
];
|
|
8192
8230
|
});
|
|
@@ -8207,15 +8245,11 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
8207
8245
|
check: `${relativePath} normalises declaration specifiers`,
|
|
8208
8246
|
ok: false,
|
|
8209
8247
|
detail: "no mnci-normalise-declaration-specifiers plugin \u2014 the emitted .d.ts files keep the extensionless imports tsconfig.lib.json allows, which a nodenext consumer cannot resolve",
|
|
8210
|
-
//
|
|
8211
|
-
//
|
|
8212
|
-
//
|
|
8213
|
-
//
|
|
8214
|
-
|
|
8215
|
-
// command against exactly this shape — it no-ops. Naming a command
|
|
8216
|
-
// that silently does nothing is the failure mode this file's own
|
|
8217
|
-
// source-map check already goes out of its way to avoid.
|
|
8218
|
-
remedy: "add the plugin to withNx's second argument by hand (copy it from a freshly `mnci add npm-lib`'d project) \u2014 `mnci upgrade` only updates a plugin that is already present, it cannot restore a missing one"
|
|
8248
|
+
// `mnci upgrade` adds the plugin only to a config whose second argument already has a
|
|
8249
|
+
// `plugins` array (what @nx/react:library writes). For any other shape it would no-op, and
|
|
8250
|
+
// naming a command that silently does nothing is the failure mode the source-map check
|
|
8251
|
+
// above goes out of its way to avoid, so the remedy depends on the shape.
|
|
8252
|
+
remedy: canAddDeclarationSpecifierPlugin((0, import_node_fs29.readFileSync)(configPath, "utf8")) ? "run `mnci upgrade`, which adds the plugin to the plugins array of withNx's second argument" : "add the plugin to withNx's second argument by hand (copy it from a freshly `mnci add npm-lib`'d project) \u2014 mnci does not recognise the shape of this config, so `mnci upgrade` cannot add it"
|
|
8219
8253
|
}
|
|
8220
8254
|
];
|
|
8221
8255
|
}
|
|
@@ -8919,6 +8953,13 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
8919
8953
|
logger.step("Registering the Go plugin in nx.json, so Nx can see which Go project imports which");
|
|
8920
8954
|
logger.detail("updated nx.json");
|
|
8921
8955
|
}
|
|
8956
|
+
const addedDtsPlugins = addMissingDeclarationSpecifierPlugins(workspaceRoot);
|
|
8957
|
+
if (addedDtsPlugins.length > 0) {
|
|
8958
|
+
logger.step("Adding the declaration-specifier plugin to rollup configs that lacked it");
|
|
8959
|
+
for (const path of addedDtsPlugins) {
|
|
8960
|
+
logger.detail(`updated ${path}`);
|
|
8961
|
+
}
|
|
8962
|
+
}
|
|
8922
8963
|
const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
|
|
8923
8964
|
if (upgradedDtsPlugins.length > 0) {
|
|
8924
8965
|
logger.step("Upgrading declaration specifiers to resolve under nodenext");
|