@mnci/cli 1.17.1 → 1.18.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 CHANGED
@@ -141,7 +141,20 @@ async function promptStack() {
141
141
  { name: "Vitest", value: "vitest" }
142
142
  ]
143
143
  });
144
- return { testRunner };
144
+ const linter = await (0, import_prompts.select)({
145
+ message: "Linter and formatter",
146
+ choices: [
147
+ {
148
+ name: "ESLint + Prettier \u2014 every file type, the widest rule coverage",
149
+ value: "eslint"
150
+ },
151
+ {
152
+ name: "oxlint + oxfmt for JS/TS, ESLint for the rest \u2014 much faster, same style",
153
+ value: "oxlint"
154
+ }
155
+ ]
156
+ });
157
+ return { testRunner, linter };
145
158
  }
146
159
 
147
160
  // src/util/fsx.ts
@@ -1241,7 +1254,7 @@ var import_node_path12 = require("path");
1241
1254
  // src/overlay.ts
1242
1255
  var import_node_fs6 = require("fs");
1243
1256
  var import_node_path11 = require("path");
1244
- var DEFAULT_STACK = { testRunner: "jest" };
1257
+ var DEFAULT_STACK = { testRunner: "jest", linter: "eslint" };
1245
1258
  var PRETTIER_VERSION = "^3.8.1";
1246
1259
  var TS_COMPILER_DEPENDENCIES = {
1247
1260
  "@typescript/native": "npm:typescript@^7.0.2",
@@ -1375,7 +1388,7 @@ function eslintConfigSpec() {
1375
1388
  return process.env.MNCI_ESLINT_CONFIG_SPEC ?? ESLINT_CONFIG_VERSION;
1376
1389
  }
1377
1390
  var ESLINT_VERSION = "^10.8.0";
1378
- function devcontainerJson(workspaceName) {
1391
+ function devcontainerJson(workspaceName, linter) {
1379
1392
  return `${toJson({
1380
1393
  name: workspaceName,
1381
1394
  image: `mcr.microsoft.com/devcontainers/typescript-node:${NODE_VERSION}-bookworm`,
@@ -1394,7 +1407,7 @@ function devcontainerJson(workspaceName) {
1394
1407
  // The same recommendations the `.code-workspace` file carries, so opening
1395
1408
  // the folder in a container suggests the identical toolset.
1396
1409
  customizations: {
1397
- vscode: { extensions: [...VSCODE_RECOMMENDED_EXTENSIONS] }
1410
+ vscode: { extensions: vscodeExtensions(linter) }
1398
1411
  }
1399
1412
  })}
1400
1413
  `;
@@ -1501,43 +1514,47 @@ __pycache__
1501
1514
  .ruff_cache
1502
1515
  .dart_tool
1503
1516
  `;
1504
- var VSCODE_RECOMMENDED_EXTENSIONS = [
1505
- "dbaeumer.vscode-eslint",
1506
- "esbenp.prettier-vscode",
1517
+ var LINTER_EXTENSIONS = {
1518
+ eslint: ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
1519
+ oxlint: ["oxc.oxc-vscode", "dbaeumer.vscode-eslint"]
1520
+ };
1521
+ var SHARED_VSCODE_EXTENSIONS = [
1507
1522
  "nrwl.angular-console",
1508
1523
  "firsttris.vscode-jest-runner"
1509
1524
  ];
1510
- function vscodeWorkspace(workspaceName, existingTasks) {
1525
+ function vscodeExtensions(linter) {
1526
+ return [...LINTER_EXTENSIONS[linter], ...SHARED_VSCODE_EXTENSIONS];
1527
+ }
1528
+ function vscodeSettings(linter) {
1529
+ const formatter = linter === "oxlint" ? "oxc.oxc-vscode" : "esbenp.prettier-vscode";
1530
+ const eslintLanguages = linter === "oxlint" ? ["json", "jsonc", "markdown", "yaml", "html", "css"] : [
1531
+ "javascript",
1532
+ "javascriptreact",
1533
+ "typescript",
1534
+ "typescriptreact",
1535
+ "json",
1536
+ "jsonc",
1537
+ "markdown",
1538
+ "yaml"
1539
+ ];
1540
+ return {
1541
+ "eslint.validate": eslintLanguages,
1542
+ "editor.codeActionsOnSave": {
1543
+ "source.fixAll.eslint": "explicit"
1544
+ },
1545
+ "editor.defaultFormatter": formatter,
1546
+ "editor.formatOnSave": true,
1547
+ "[json]": { "editor.defaultFormatter": formatter },
1548
+ "[jsonc]": { "editor.defaultFormatter": formatter },
1549
+ "[yaml]": { "editor.defaultFormatter": formatter }
1550
+ };
1551
+ }
1552
+ function vscodeWorkspace(workspaceName, linter, existingTasks) {
1511
1553
  return JSON.stringify(
1512
1554
  {
1513
1555
  folders: [{ path: ".", name: workspaceName }],
1514
- settings: {
1515
- "eslint.validate": [
1516
- "javascript",
1517
- "javascriptreact",
1518
- "typescript",
1519
- "typescriptreact",
1520
- "json",
1521
- "jsonc",
1522
- "markdown",
1523
- "yaml"
1524
- ],
1525
- "editor.codeActionsOnSave": {
1526
- "source.fixAll.eslint": "explicit"
1527
- },
1528
- "editor.defaultFormatter": "esbenp.prettier-vscode",
1529
- "editor.formatOnSave": true,
1530
- "[json]": {
1531
- "editor.defaultFormatter": "esbenp.prettier-vscode"
1532
- },
1533
- "[jsonc]": {
1534
- "editor.defaultFormatter": "esbenp.prettier-vscode"
1535
- },
1536
- "[yaml]": {
1537
- "editor.defaultFormatter": "esbenp.prettier-vscode"
1538
- }
1539
- },
1540
- extensions: { recommendations: [...VSCODE_RECOMMENDED_EXTENSIONS] },
1556
+ settings: vscodeSettings(linter),
1557
+ extensions: { recommendations: vscodeExtensions(linter) },
1541
1558
  tasks: {
1542
1559
  version: existingTasks?.version ?? "2.0.0",
1543
1560
  tasks: existingTasks?.tasks ?? []
@@ -1595,7 +1612,7 @@ function mnciConfig(options) {
1595
1612
  agent: options.agent,
1596
1613
  variableGroup: options.variableGroup,
1597
1614
  ci: options.ci,
1598
- stack: { testRunner: options.stack.testRunner }
1615
+ stack: { testRunner: options.stack.testRunner, linter: options.stack.linter }
1599
1616
  };
1600
1617
  }
1601
1618
  function readMnciConfig(workspaceRoot) {
@@ -2172,13 +2189,16 @@ function applyOverlay(workspaceRoot, options) {
2172
2189
  writeFileEnsured((0, import_node_path11.join)(workspaceRoot, ".prettierrc.mjs"), PRETTIER_CONFIG);
2173
2190
  writeFileEnsured(
2174
2191
  (0, import_node_path11.join)(workspaceRoot, ".devcontainer/devcontainer.json"),
2175
- devcontainerJson(options.workspaceName)
2192
+ devcontainerJson(options.workspaceName, options.stack.linter)
2176
2193
  );
2177
2194
  writeFileEnsured((0, import_node_path11.join)(workspaceRoot, ".prettierignore"), PRETTIER_IGNORE);
2178
2195
  removeNxScaffolding(workspaceRoot);
2179
2196
  const codeWorkspacePath = (0, import_node_path11.join)(workspaceRoot, `${options.workspaceName}.code-workspace`);
2180
2197
  const existing = readCodeWorkspace(codeWorkspacePath);
2181
- writeFileEnsured(codeWorkspacePath, vscodeWorkspace(options.workspaceName, existing?.tasks));
2198
+ writeFileEnsured(
2199
+ codeWorkspacePath,
2200
+ vscodeWorkspace(options.workspaceName, options.stack.linter, existing?.tasks)
2201
+ );
2182
2202
  if (options.workspaceName !== "undefined") {
2183
2203
  (0, import_node_fs6.rmSync)((0, import_node_path11.join)(workspaceRoot, "undefined.code-workspace"), { force: true });
2184
2204
  }
@@ -2361,14 +2381,16 @@ function nxCloudProviderValue(ci) {
2361
2381
  return ci === "azure" ? "azure" : "github";
2362
2382
  }
2363
2383
  async function resolveStack(options) {
2364
- if (options.testRunner || options.yes) {
2384
+ if (options.testRunner || options.linter || options.yes) {
2365
2385
  return {
2366
- testRunner: options.testRunner ?? DEFAULT_STACK.testRunner
2386
+ testRunner: options.testRunner ?? DEFAULT_STACK.testRunner,
2387
+ linter: options.linter ?? DEFAULT_STACK.linter
2367
2388
  };
2368
2389
  }
2369
2390
  const prompted = await promptStack();
2370
2391
  return {
2371
- testRunner: prompted.testRunner
2392
+ testRunner: prompted.testRunner,
2393
+ linter: prompted.linter
2372
2394
  };
2373
2395
  }
2374
2396
  var CI_PROVIDERS = /* @__PURE__ */ new Set(["azure", "github", "both"]);
@@ -2514,6 +2536,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
2514
2536
  );
2515
2537
  }
2516
2538
  const variableGroup = options.variableGroup ?? persisted.variableGroup ?? "Build";
2539
+ const linter = options.linter ?? persisted.stack?.linter ?? "eslint";
2517
2540
  const testRunner = options.testRunner ?? persisted.stack?.testRunner;
2518
2541
  if (!testRunner) {
2519
2542
  throw new Error(
@@ -2527,7 +2550,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
2527
2550
  agent,
2528
2551
  variableGroup,
2529
2552
  ci,
2530
- stack: { testRunner }
2553
+ stack: { testRunner, linter }
2531
2554
  };
2532
2555
  }
2533
2556
  function runUpgrade(workspaceRoot, options) {
@@ -2641,7 +2664,10 @@ function buildProgram(cliVersion) {
2641
2664
  program.command("new").argument("[name]", "workspace name").description("Create a new monorepo (Nx TS preset + release/pipeline overlay)").option("-y, --yes", "accept defaults for anything not passed as a flag").option("--scope <scope>", "npm scope for publishable packages (e.g. @demo)").option("--registry <kind>", "azure-artifacts | npm").option("--organization <name>", "Azure DevOps organization").option("--project <name>", "Azure DevOps project").option("--artifacts-feed <name>", "Azure Artifacts feed").option(
2642
2665
  "--agent <pool>",
2643
2666
  "CI build agent: a vmImage (e.g. ubuntu-latest) or self-hosted pool name"
2644
- ).option("--variable-group <name>", "Azure DevOps variable group holding the npm PAT").option("--ci <provider>", "CI provider: azure | github | both").option("--test-runner <runner>", "unit-test runner: jest | vitest").option("--nx-cloud", "connect the workspace to Nx Cloud (remote caching + CI insights)").action(async (name, options) => {
2667
+ ).option("--variable-group <name>", "Azure DevOps variable group holding the npm PAT").option("--ci <provider>", "CI provider: azure | github | both").option("--test-runner <runner>", "unit-test runner: jest | vitest").option(
2668
+ "--linter <linter>",
2669
+ "linter + formatter: eslint (ESLint + Prettier) | oxlint (oxlint + oxfmt for JS/TS, ESLint for the rest)"
2670
+ ).option("--nx-cloud", "connect the workspace to Nx Cloud (remote caching + CI insights)").action(async (name, options) => {
2645
2671
  await runNew(name, options);
2646
2672
  });
2647
2673
  program.command("upgrade").description(
@@ -2649,6 +2675,9 @@ function buildProgram(cliVersion) {
2649
2675
  ).option("--scope <scope>", "npm scope for publishable packages (overrides the persisted value)").option("--registry <kind>", "azure-artifacts | npm (overrides the persisted value)").option("--organization <name>", "Azure DevOps organization").option("--project <name>", "Azure DevOps project").option("--artifacts-feed <name>", "Azure Artifacts feed").option("--agent <pool>", "CI build agent (overrides the persisted value)").option("--variable-group <name>", "Azure DevOps variable group holding the npm PAT").option("--ci <provider>", "CI provider: azure | github | both (overrides the persisted value)").option(
2650
2676
  "--test-runner <runner>",
2651
2677
  "unit-test runner: jest | vitest (overrides the persisted value)"
2678
+ ).option(
2679
+ "--linter <linter>",
2680
+ "linter + formatter: eslint | oxlint (overrides the persisted value)"
2652
2681
  ).action((options) => {
2653
2682
  runUpgrade(process.cwd(), options);
2654
2683
  });