@mnci/cli 4.1.3 → 4.1.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 CHANGED
@@ -206,9 +206,63 @@ var import_node_path = require("path");
206
206
  function readJson(path) {
207
207
  return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
208
208
  }
209
+ function stripJsonComments(text) {
210
+ let result = "";
211
+ let inString = false;
212
+ let inLineComment = false;
213
+ let inBlockComment = false;
214
+ for (let i = 0; i < text.length; i++) {
215
+ const char = text[i];
216
+ if (inLineComment) {
217
+ if (char === "\n") {
218
+ inLineComment = false;
219
+ result += char;
220
+ }
221
+ continue;
222
+ }
223
+ const next = text[i + 1];
224
+ if (inBlockComment) {
225
+ if (char === "*" && next === "/") {
226
+ inBlockComment = false;
227
+ i++;
228
+ }
229
+ continue;
230
+ }
231
+ if (inString) {
232
+ result += char;
233
+ if (char === "\\") {
234
+ result += next;
235
+ i++;
236
+ continue;
237
+ }
238
+ if (char === '"') {
239
+ inString = false;
240
+ }
241
+ continue;
242
+ }
243
+ if (char === '"') {
244
+ inString = true;
245
+ result += char;
246
+ continue;
247
+ }
248
+ if (char === "/" && next === "/") {
249
+ inLineComment = true;
250
+ i++;
251
+ continue;
252
+ }
253
+ if (char === "/" && next === "*") {
254
+ inBlockComment = true;
255
+ i++;
256
+ continue;
257
+ }
258
+ result += char;
259
+ }
260
+ return result;
261
+ }
209
262
  function readCodeWorkspace(path) {
210
263
  try {
211
- return JSON.parse((0, import_node_fs.readFileSync)(path, "utf8").replaceAll(/,(\s*[}\]])/g, "$1"));
264
+ const withoutComments = stripJsonComments((0, import_node_fs.readFileSync)(path, "utf8"));
265
+ return JSON.parse(withoutComments.replaceAll(/,(\s*[}\]])/g, "$1"));
212
266
  } catch {
213
267
  return void 0;
214
268
  }
@@ -371,7 +425,7 @@ var COMMITLINT_CONFIG = `export default { extends: ['@commitlint/config-conventi
371
425
  `;
372
426
  var COMMIT_MSG_HOOK = `npx --no -- commitlint --edit "$1"
373
427
  `;
374
- var ESLINT_CONFIG_VERSION = "^0.1.0";
428
+ var ESLINT_CONFIG_VERSION = ">=0.1.0 <1.0.0";
375
429
  function eslintConfigSpec() {
376
430
  return process.env.MNCI_ESLINT_CONFIG_SPEC ?? ESLINT_CONFIG_VERSION;
377
431
  }
@@ -745,7 +799,7 @@ var FLUTTER_PUB_GET_GUARD = `node -e "const fs=require('node:fs');if(!fs.existsS
745
799
  var NPM_AUDIT_STEP = `node -e "const cp=require('node:child_process');const r=cp.spawnSync('npm',['audit','--json'],{encoding:'utf8',shell:process.platform==='win32',maxBuffer:33554432});let d;try{d=JSON.parse(r.stdout)}catch{console.log('npm audit produced no JSON (exit '+r.status+') - not blocking on a broken audit.');process.exit(0)}const all=Object.values(d.vulnerabilities||{});const BLOCK=['critical','high','moderate'];const act=all.filter(v=>v.fixAvailable&&BLOCK.includes(v.severity));const rest=all.filter(v=>!act.includes(v));for(const v of rest)console.log(' note ['+v.severity+'] '+v.name+(v.fixAvailable?' - fix available, below the blocking threshold':' - NO fix available upstream, nothing to do here'));if(act.length===0){console.log('npm audit - '+all.length+' advisory(ies), none actionable at moderate or above.');process.exit(0)}for(const v of act)console.log(' BLOCKING ['+v.severity+'] '+v.name+' - fix available'+(v.fixAvailable&&v.fixAvailable.isSemVerMajor?' (semver-major)':''));console.log('Each has a published fix. Add a targeted overrides entry in package.json rather than npm audit fix --force.');process.exit(1)"`;
746
800
  var VERIFY_TARGETS = "lint,typecheck,test,build";
747
801
  var AFFECTED_OR_ALL_GUARD = `node -e "const cp=require('node:child_process');const T='${VERIFY_TARGETS}';const all=()=>process.exit(cp.spawnSync('npx nx run-many -t '+T,{stdio:'inherit',shell:true}).status ?? 1);const ref=process.env.GITHUB_BASE_REF||process.env.SYSTEM_PULLREQUEST_TARGETBRANCH||'';if(!ref){console.log('Not a pull request - verifying EVERY project.');all()}const target=ref.replace('refs/heads/','');const mergeBase=r=>{const o=cp.spawnSync('git',['merge-base',r,'HEAD'],{encoding:'utf8'});return o.status===0?o.stdout.trim():''};let base=mergeBase('origin/'+target);if(!base){console.log('No origin/'+target+' ref - fetching it to resolve a merge-base.');cp.spawnSync('git',['fetch','--no-tags','origin',target],{stdio:'inherit'});base=mergeBase('FETCH_HEAD')}if(!base){console.log('Could not resolve a merge-base with '+target+' - verifying EVERY project.');all()}console.log('Pull request against '+target+' - verifying projects affected since '+base);process.exit(cp.spawnSync('npx nx affected -t '+T+' --base='+base,{stdio:'inherit',shell:true}).status ?? 1)"`;
748
- var PACK_APPS_GUARD = `node -e "const fs=require('node:fs');fs.mkdirSync('dist/drop',{recursive:true});if(fs.globSync('apps/*/project.json').length===0){console.log('No apps to pack - skipping.');process.exit(0)}process.exit(require('node:child_process').spawnSync('npx nx run-many -t package',{stdio:'inherit',shell:true}).status ?? 1)"`;
802
+ var PACK_APPS_GUARD = `node -e "const fs=require('node:fs');fs.mkdirSync('dist/drop',{recursive:true});const hasProjectJson=fs.globSync('apps/*/project.json').length>0;const hasInlineNx=fs.globSync('apps/*/package.json').some((f)=>{try{return Boolean(JSON.parse(fs.readFileSync(f,'utf8')).nx)}catch{return false}});if(!hasProjectJson&&!hasInlineNx){console.log('No apps to pack - skipping.');process.exit(0)}process.exit(require('node:child_process').spawnSync('npx nx run-many -t package',{stdio:'inherit',shell:true}).status ?? 1)"`;
749
803
  function releaseGuard(pythonPublishEnv) {
750
804
  return `node -e "const fs=require('node:fs'),cp=require('node:child_process');const hasNpm=fs.globSync('packages/*/package.json').length>0;const hasPython=fs.globSync('python-packages/*/pyproject.toml').length>0;if(!hasNpm&&!hasPython){console.log('Nothing to release - skipping.');process.exit(0)}const env={...process.env};${pythonPublishEnv}process.exit(cp.spawnSync('npx nx release --yes',{stdio:'inherit',shell:true,env}).status ?? 1)"`;
751
805
  }