@xarc/app-dev 10.0.11 → 10.1.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.
Files changed (124) hide show
  1. package/bin/xrun.js +0 -1
  2. package/config/archetype.js +4 -4
  3. package/config/archetype.js.map +1 -1
  4. package/config/babel/babelrc-client.js +27 -27
  5. package/config/babel/babelrc-client.js.map +1 -1
  6. package/config/babel/babelrc-server.js +1 -1
  7. package/config/babel/babelrc-server.js.map +1 -1
  8. package/config/babel/babelrc.js +30 -30
  9. package/config/babel/babelrc.js.map +1 -1
  10. package/config/babel/common.js +1 -1
  11. package/config/babel/common.js.map +1 -1
  12. package/config/dev-proxy.js +6 -6
  13. package/config/dev-proxy.js.map +1 -1
  14. package/config/env-app.js +1 -1
  15. package/config/env-app.js.map +1 -1
  16. package/config/env-babel.js +2 -2
  17. package/config/env-babel.js.map +1 -1
  18. package/config/env-karma.js +1 -1
  19. package/config/env-karma.js.map +1 -1
  20. package/config/env-proxy.js +2 -2
  21. package/config/env-proxy.js.map +1 -1
  22. package/config/env-webpack.js +2 -2
  23. package/config/env-webpack.js.map +1 -1
  24. package/config/eslint/js/base.js +0 -1
  25. package/config/eslint/js/es5-node.js +0 -1
  26. package/config/eslint/js/es6-node.js +0 -1
  27. package/config/eslint/js/es6-react.js +0 -1
  28. package/config/eslint/js/es6-test.js +0 -1
  29. package/config/eslint/js/opt-eslint-require.js +0 -1
  30. package/config/jest/__mocks__/framework-mock.js +2 -3
  31. package/config/jest/__mocks__/framework-mock.js.map +1 -1
  32. package/config/jest/jest.config.js +1 -1
  33. package/config/jest/jest.config.js.map +1 -1
  34. package/config/karma/browser-settings.js +1 -1
  35. package/config/karma/browser-settings.js.map +1 -1
  36. package/config/karma/entry-xarc.js +0 -1
  37. package/config/karma/entry.js +0 -1
  38. package/config/karma/karma.conf.coverage.js +3 -3
  39. package/config/karma/karma.conf.coverage.js.map +1 -1
  40. package/config/karma/karma.conf.dev.js +2 -2
  41. package/config/karma/karma.conf.dev.js.map +1 -1
  42. package/config/karma/karma.conf.js +2 -2
  43. package/config/karma/karma.conf.js.map +1 -1
  44. package/config/karma/karma.conf.watch.js +2 -2
  45. package/config/karma/karma.conf.watch.js.map +1 -1
  46. package/config/karma/util/load-user-config.js +3 -3
  47. package/config/karma/util/load-user-config.js.map +1 -1
  48. package/config/mocha/setup.js +3 -4
  49. package/config/mocha/setup.js.map +1 -1
  50. package/config/options.js +19 -21
  51. package/config/options.js.map +1 -1
  52. package/config/user-config.js +3 -3
  53. package/config/user-config.js.map +1 -1
  54. package/lib/app-dev-middleware.js +2 -2
  55. package/lib/app-dev-middleware.js.map +1 -1
  56. package/lib/babel-run.js +1 -1
  57. package/lib/babel-run.js.map +1 -1
  58. package/lib/dev-admin/admin-http.d.ts +1 -1
  59. package/lib/dev-admin/admin-http.js +3 -3
  60. package/lib/dev-admin/admin-http.js.map +1 -1
  61. package/lib/dev-admin/admin-server.js +57 -57
  62. package/lib/dev-admin/admin-server.js.map +1 -1
  63. package/lib/dev-admin/cleanup.js +3 -3
  64. package/lib/dev-admin/cleanup.js.map +1 -1
  65. package/lib/dev-admin/dev-http.js +5 -5
  66. package/lib/dev-admin/dev-http.js.map +1 -1
  67. package/lib/dev-admin/dev-server-start.js +4 -4
  68. package/lib/dev-admin/dev-server-start.js.map +1 -1
  69. package/lib/dev-admin/dev-server.js +1 -1
  70. package/lib/dev-admin/dev-server.js.map +1 -1
  71. package/lib/dev-admin/index.js +1 -1
  72. package/lib/dev-admin/index.js.map +1 -1
  73. package/lib/dev-admin/json-formatter-js.js +0 -1
  74. package/lib/dev-admin/log-view.js +0 -1
  75. package/lib/dev-admin/middleware.js +13 -13
  76. package/lib/dev-admin/middleware.js.map +1 -1
  77. package/lib/dev-admin/redbird-proxy.js +44 -44
  78. package/lib/dev-admin/redbird-proxy.js.map +1 -1
  79. package/lib/dev-admin/redbird-spawn.js +5 -5
  80. package/lib/dev-admin/redbird-spawn.js.map +1 -1
  81. package/lib/dev-tasks.d.ts +1 -1
  82. package/lib/dev-tasks.js +124 -123
  83. package/lib/dev-tasks.js.map +1 -1
  84. package/lib/fake-res.js +2 -2
  85. package/lib/fake-res.js.map +1 -1
  86. package/lib/module-processor.js +1 -1
  87. package/lib/module-processor.js.map +1 -1
  88. package/lib/stats-mapper.js +1 -1
  89. package/lib/stats-mapper.js.map +1 -1
  90. package/lib/tasks/eslint.js +27 -27
  91. package/lib/tasks/eslint.js.map +1 -1
  92. package/lib/tasks/package-json.js +3 -3
  93. package/lib/tasks/package-json.js.map +1 -1
  94. package/lib/utils.d.ts +1 -1
  95. package/lib/utils.js +12 -11
  96. package/lib/utils.js.map +1 -1
  97. package/package.json +9 -9
  98. package/require.js +0 -1
  99. package/scripts/l10n/flatten-messages.js +0 -1
  100. package/scripts/map-isomorphic-cdn.js +0 -1
  101. package/scripts/merge-isomorphic-assets.js +0 -1
  102. package/scripts/webpack5-jsonp-cdn.js +0 -1
  103. package/src/config/babel/babelrc-client.ts +25 -25
  104. package/src/config/babel/babelrc.ts +26 -26
  105. package/src/config/eslint/js/base.js +0 -1
  106. package/src/config/eslint/js/es5-node.js +0 -1
  107. package/src/config/eslint/js/es6-node.js +0 -1
  108. package/src/config/eslint/js/es6-react.js +0 -1
  109. package/src/config/eslint/js/es6-test.js +0 -1
  110. package/src/config/eslint/js/opt-eslint-require.js +0 -1
  111. package/src/config/jest/__mocks__/framework-mock.ts +3 -3
  112. package/src/config/karma/entry-xarc.js +0 -1
  113. package/src/config/karma/entry.js +0 -1
  114. package/src/config/karma/util/load-user-config.ts +2 -2
  115. package/src/config/mocha/setup.ts +2 -2
  116. package/src/config/options.ts +12 -14
  117. package/src/config/user-config.ts +1 -1
  118. package/src/lib/dev-admin/admin-server.ts +32 -32
  119. package/src/lib/dev-admin/json-formatter-js.js +0 -1
  120. package/src/lib/dev-admin/log-view.js +0 -1
  121. package/src/lib/dev-admin/redbird-proxy.ts +25 -23
  122. package/src/lib/dev-tasks.ts +110 -105
  123. package/src/lib/tasks/eslint.ts +26 -26
  124. package/src/lib/utils.ts +11 -10
@@ -9,7 +9,7 @@ import Fs from "fs";
9
9
  import Path from "path";
10
10
  import assert from "assert";
11
11
  import requireAt from "require-at";
12
- import makeOptionalRequire from "optional-require";
12
+ import { makeOptionalRequire } from "optional-require";
13
13
  import xrun from "@xarc/run";
14
14
  import { getDevOptions } from "../config/archetype";
15
15
  import ck from "chalker";
@@ -34,7 +34,7 @@ export {
34
34
  /** The task runner @xarc/run */
35
35
  xrun,
36
36
  /** The task runner @xarc/run */
37
- xrun as xclap
37
+ xrun as xclap,
38
38
  };
39
39
 
40
40
  let xarcCwd: string;
@@ -153,8 +153,8 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
153
153
  const mapIsomorphicCdn = require(`../scripts/map-isomorphic-cdn.js`);
154
154
 
155
155
  const config = xarcOptions.config;
156
- const karmaConfig = file => Path.join(config.karma, file);
157
- const mochaConfig = file => Path.join(config.mocha, file);
156
+ const karmaConfig = (file) => Path.join(config.karma, file);
157
+ const mochaConfig = (file) => Path.join(config.mocha, file);
158
158
 
159
159
  const shell = xsh.$;
160
160
  const exec = xsh.exec;
@@ -174,12 +174,12 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
174
174
 
175
175
  timer = setTimeout(async () => {
176
176
  timer = undefined;
177
- const run = msg => {
177
+ const run = (msg) => {
178
178
  child = true;
179
179
  console.log(`${msg} '${cmd}'`);
180
180
  const ch = spawn(cmd, {
181
181
  shell: true,
182
- stdio: "inherit"
182
+ stdio: "inherit",
183
183
  });
184
184
  ch.on("close", () => {
185
185
  if (child === "restart") {
@@ -195,7 +195,7 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
195
195
  } else if (child.kill && child.pid) {
196
196
  const ch = child;
197
197
  child = "restart";
198
- (await psChildren(ch.pid)).reverse().forEach(c => process.kill(c.pid));
198
+ (await psChildren(ch.pid)).reverse().forEach((c) => process.kill(c.pid));
199
199
  ch.kill();
200
200
  }
201
201
  }, 500);
@@ -274,7 +274,7 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
274
274
  const url = `http://${HOST}:${PORT}${PATH}`;
275
275
  const statsPath = Path.resolve(xarcCwd, "dist/server/stats.json");
276
276
  const stats = JSON.parse(Fs.readFileSync(statsPath, "utf-8"));
277
- const cssAsset = stats.assets.find(asset => asset.name.endsWith(".css"));
277
+ const cssAsset = stats.assets.find((asset) => asset.name.endsWith(".css"));
278
278
  const cssAssetPath = Path.resolve(xarcCwd, `dist/js/${cssAsset.name}`);
279
279
  const targetPath = Path.resolve(xarcCwd, "dist/js/critical.css");
280
280
  const serverPromise = require(Path.resolve(
@@ -290,7 +290,7 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
290
290
  strict: false,
291
291
  maxEmbeddedBase64Length: 1000,
292
292
  renderWaitTime: 2000,
293
- blockJSRequests: false
293
+ blockJSRequests: false,
294
294
  };
295
295
  serverPromise.then(() => {
296
296
  penthouse(penthouseOptions, (err, css) => {
@@ -298,7 +298,7 @@ export function loadXarcDevTasks(userXrun?: any, userOptions: XarcOptions = {})
298
298
  throw err;
299
299
  }
300
300
  const minifiedCSS = new CleanCSS().minify(css).styles;
301
- Fs.writeFile(targetPath, minifiedCSS, writeErr => {
301
+ Fs.writeFile(targetPath, minifiedCSS, (writeErr) => {
302
302
  if (writeErr) {
303
303
  throw writeErr;
304
304
  }
@@ -374,7 +374,7 @@ ie >= 11
374
374
  );
375
375
  };
376
376
 
377
- const optimizeModuleForProd = module => {
377
+ const optimizeModuleForProd = (module) => {
378
378
  const modulePath = Path.resolve(xarcCwd, "node_modules", module);
379
379
  assert(shell.test("-d", modulePath), `${modulePath} is not a directory`);
380
380
  createGitIgnoreDir(
@@ -400,7 +400,10 @@ ie >= 11
400
400
 
401
401
  const files = [".babelrc.js", resultFile];
402
402
 
403
- if (!Fs.existsSync(destDir) || files.find(file => Fs.existsSync(Path.join(destDir, file)))) {
403
+ if (
404
+ !Fs.existsSync(destDir) ||
405
+ files.find((file) => Fs.existsSync(Path.join(destDir, file)))
406
+ ) {
404
407
  return;
405
408
  }
406
409
 
@@ -422,25 +425,27 @@ module.exports = {
422
425
  const AppMode = xarcOptions.AppMode;
423
426
 
424
427
  const babelCliIgnore = quote(
425
- [...jestTestDirectories.map(dir => `**/${dir}`), `**/*.spec.js`, `**/*.spec.jsx`]
428
+ [...jestTestDirectories.map((dir) => `**/${dir}`), `**/*.spec.js`, `**/*.spec.jsx`]
426
429
  .concat(xarcOptions.babel.enableTypeScript && [`**/*.test.ts`, `**/*.test.tsx`])
427
430
  .concat(`**/.__dev_hmr`)
428
- .filter(x => x)
431
+ .filter((x) => x)
429
432
  .join(",")
430
433
  );
431
434
 
432
435
  const babelCliExtensions = quote(
433
436
  [".js", ".jsx"]
434
437
  .concat(xarcOptions.babel.enableTypeScript && [".ts", ".tsx"])
435
- .filter(x => x)
438
+ .filter((x) => x)
436
439
  .join(",")
437
440
  );
438
441
 
439
- const babelEnvTargetsArr = Object.keys(xarcOptions.babel.envTargets).filter(k => k !== "node");
442
+ const babelEnvTargetsArr = Object.keys(xarcOptions.babel.envTargets).filter(
443
+ (k) => k !== "node"
444
+ );
440
445
 
441
446
  const buildDistDirs = babelEnvTargetsArr
442
- .filter(name => name !== "default")
443
- .map(name => `dist-${name}`);
447
+ .filter((name) => name !== "default")
448
+ .map((name) => `dist-${name}`);
444
449
 
445
450
  let tasks = {
446
451
  ".mk-prod-dir": () =>
@@ -464,7 +469,7 @@ module.exports = {
464
469
  build: {
465
470
  dep: [".remove-log-files", ".production-env"],
466
471
  desc: `Build your app's ${AppMode.src.dir} directory into ${AppMode.lib.dir} for production`,
467
- task: [".build-lib", "build-dist", ".check.top.level.babelrc", "mv-to-dist"]
472
+ task: [".build-lib", "build-dist", ".check.top.level.babelrc", "mv-to-dist"],
468
473
  },
469
474
 
470
475
  //
@@ -486,13 +491,13 @@ module.exports = {
486
491
  ".clean.dist",
487
492
  ".build-browser-coverage-1",
488
493
  "build-dist:flatten-l10n",
489
- "build-dist:clean-tmp"
490
- ]
494
+ "build-dist:clean-tmp",
495
+ ],
491
496
  },
492
497
 
493
498
  "build-dev-static": {
494
499
  desc: "Build static copy of your app's client bundle for development",
495
- task: [".clean.dist", "build-dist-dev-static"]
500
+ task: [".clean.dist", "build-dist-dev-static"],
496
501
  },
497
502
 
498
503
  "build-dist": [
@@ -505,7 +510,7 @@ module.exports = {
505
510
  "build-dist:flatten-l10n",
506
511
  "build-dist:merge-isomorphic-assets",
507
512
  "copy-dll",
508
- "build-dist:clean-tmp"
513
+ "build-dist:clean-tmp",
509
514
  ],
510
515
 
511
516
  ".copy-xarc-options-to-dist": () => shell.cp(Path.join(eTmpDir, "xarc-options.json"), "dist"),
@@ -520,7 +525,7 @@ module.exports = {
520
525
  quote(getWebpackStartConfig("webpack.config.dev.static.js")),
521
526
  `--color`
522
527
  );
523
- }
528
+ },
524
529
  },
525
530
 
526
531
  ".ss-prod-react": () => optimizeModuleForProd("react"),
@@ -535,7 +540,7 @@ module.exports = {
535
540
  "ss-prod-react": {
536
541
  desc: `Make optimized copy of react&react-dom for server side in dir ${xarcOptions.prodModulesDir}`,
537
542
  dep: [".ss-clean.prod-react", ".mk-prod-dir"],
538
- task: xrun2.concurrent(".ss-prod-react", ".ss-prod-react-dom")
543
+ task: xrun2.concurrent(".ss-prod-react", ".ss-prod-react-dom"),
539
544
  },
540
545
 
541
546
  "build-dist-dll": () => undefined,
@@ -550,53 +555,53 @@ module.exports = {
550
555
  [
551
556
  `${webpackCmd()} --config`,
552
557
  quote(getWebpackStartConfig("webpack.config.js")),
553
- `--color`
558
+ `--color`,
554
559
  ],
555
560
  {
556
561
  xclap: {
557
- delayRunMs: index * 2000
562
+ delayRunMs: index * 2000,
558
563
  },
559
564
  execOptions: {
560
565
  env: {
561
- ENV_TARGET: name
562
- }
563
- }
566
+ ENV_TARGET: name,
567
+ },
568
+ },
564
569
  }
565
570
  )
566
571
  )
567
- )
572
+ ),
568
573
  },
569
574
 
570
575
  "mv-to-dist:clean": {
571
576
  desc: `clean static resources within ${buildDistDirs}`,
572
577
  task: () => {
573
- buildDistDirs.forEach(dir => {
578
+ buildDistDirs.forEach((dir) => {
574
579
  // clean static resources within `dist-X` built by user specified env targets
575
580
  // and leave [.js, .map, .json] files only
576
581
  const removedFiles = scanDir.sync({
577
582
  dir: Path.resolve(xarcCwd, dir),
578
583
  includeRoot: true,
579
- ignoreExt: [".js", ".map", ".json"]
584
+ ignoreExt: [".js", ".map", ".json"],
580
585
  });
581
586
  shell.rm("-rf", ...removedFiles);
582
587
  });
583
588
  return;
584
- }
589
+ },
585
590
  },
586
591
 
587
592
  "mv-to-dist:mv-dirs": {
588
593
  desc: `move ${buildDistDirs} to dist`,
589
594
  task: () => {
590
- buildDistDirs.forEach(dir => {
595
+ buildDistDirs.forEach((dir) => {
591
596
  scanDir
592
597
  .sync({
593
598
  dir,
594
599
  includeRoot: true,
595
- filterExt: [".js", ".json", ".map"]
600
+ filterExt: [".js", ".json", ".map"],
596
601
  // the regex above matches all the sw-registration.js, sw-registration.js.map,
597
602
  // main.bundle.js and main.bundle.js.map and stats.json
598
603
  })
599
- .forEach(file => {
604
+ .forEach((file) => {
600
605
  if (file.endsWith(".js")) {
601
606
  shell.cp("-r", file, "dist/js");
602
607
  } else if (file.endsWith(".map")) {
@@ -607,20 +612,20 @@ module.exports = {
607
612
  });
608
613
  });
609
614
  return;
610
- }
615
+ },
611
616
  },
612
617
 
613
618
  "mv-to-dist:keep-targets": {
614
619
  desc: `write each targets to respective isomorphic-assets.json`,
615
620
  task: () => {
616
- buildDistDirs.forEach(dir => {
621
+ buildDistDirs.forEach((dir) => {
617
622
  // add `targets` field to `dist-X/isomorphic-assets.json`
618
623
  const isomorphicPath = Path.resolve(xarcCwd, dir, "isomorphic-assets.json");
619
624
  if (Fs.existsSync(isomorphicPath)) {
620
625
  Fs.readFile(
621
626
  isomorphicPath,
622
627
  {
623
- encoding: "utf8"
628
+ encoding: "utf8",
624
629
  },
625
630
  (err, data) => {
626
631
  if (err) throw err;
@@ -628,7 +633,7 @@ module.exports = {
628
633
  const { envTargets } = xarcOptions.babel;
629
634
  assetsJson.targets = envTargets[dir.split("-")[1]];
630
635
  // eslint-disable-next-line no-shadow
631
- Fs.writeFile(isomorphicPath, JSON.stringify(assetsJson, null, 2), err => {
636
+ Fs.writeFile(isomorphicPath, JSON.stringify(assetsJson, null, 2), (err) => {
632
637
  if (err) throw err;
633
638
  });
634
639
  }
@@ -636,12 +641,12 @@ module.exports = {
636
641
  }
637
642
  });
638
643
  return;
639
- }
644
+ },
640
645
  },
641
646
 
642
647
  "build-dist:clean-tmp": {
643
648
  desc: false,
644
- task: () => shell.rm("-rf", "./tmp")
649
+ task: () => shell.rm("-rf", "./tmp"),
645
650
  },
646
651
 
647
652
  "build-dist:flatten-l10n": flattenMessagesL10n,
@@ -679,25 +684,25 @@ module.exports = {
679
684
  includeRoot: true,
680
685
  includeDir: true,
681
686
  grouping: true,
682
- filterDir: x => (x === `.__dev_hmr` && "dirs") || "otherDirs",
687
+ filterDir: (x) => (x === `.__dev_hmr` && "dirs") || "otherDirs",
683
688
  filter: (x, p) =>
684
- x.indexOf(".spec.") > 0 || x.indexOf(".test.") > 0 || p === `.__dev_hmr`
689
+ x.indexOf(".spec.") > 0 || x.indexOf(".test.") > 0 || p === `.__dev_hmr`,
685
690
  });
686
- scanned.files.forEach(f => {
691
+ scanned.files.forEach((f) => {
687
692
  try {
688
693
  Fs.unlinkSync(f);
689
694
  } catch (err) {
690
695
  //
691
696
  }
692
697
  });
693
- [].concat(scanned.dirs, scanned.otherDirs).forEach(d => {
698
+ [].concat(scanned.dirs, scanned.otherDirs).forEach((d) => {
694
699
  try {
695
700
  if (d) Fs.rmdirSync(d);
696
701
  } catch (err) {
697
702
  // ignore
698
703
  }
699
704
  });
700
- }
705
+ },
701
706
  },
702
707
 
703
708
  "build-lib:all": {
@@ -707,7 +712,7 @@ module.exports = {
707
712
  ".clean.lib:server",
708
713
  ".mk.lib.client.dir",
709
714
  ".mk.lib.server.dir",
710
- ".build.babelrc"
715
+ ".build.babelrc",
711
716
  ],
712
717
  task: xrun2.exec(
713
718
  [
@@ -715,15 +720,15 @@ module.exports = {
715
720
  `--out-dir=${AppMode.lib.dir}`,
716
721
  `--extensions=${babelCliExtensions}`,
717
722
  `--source-maps=inline --copy-files`,
718
- `--verbose --ignore=${babelCliIgnore}`
723
+ `--verbose --ignore=${babelCliIgnore}`,
719
724
  ],
720
725
  {
721
726
  env: {
722
- XARC_BABEL_TARGET: "node"
723
- }
727
+ XARC_BABEL_TARGET: "node",
728
+ },
724
729
  }
725
730
  ),
726
- finally: [".build-lib:delete-babel-ignored-files"]
731
+ finally: [".build-lib:delete-babel-ignored-files"],
727
732
  },
728
733
 
729
734
  // TODO: to be removed
@@ -738,14 +743,14 @@ module.exports = {
738
743
  dir: AppMode.src.dir,
739
744
  includeDir: true,
740
745
  grouping: true,
741
- filterDir: x => !x.startsWith("server") && "dirs",
742
- filter: () => false
746
+ filterDir: (x) => !x.startsWith("server") && "dirs",
747
+ filter: () => false,
743
748
  }).dirs
744
749
  )
745
- .filter(x => x)
750
+ .filter((x) => x)
746
751
  : [AppMode.client];
747
752
 
748
- return dirs.map(x =>
753
+ return dirs.map((x) =>
749
754
  mkCmd(
750
755
  `~$babel ${Path.posix.join(AppMode.src.dir, x)}`,
751
756
  `--out-dir=${Path.posix.join(AppMode.lib.dir, x)}`,
@@ -755,7 +760,7 @@ module.exports = {
755
760
  )
756
761
  );
757
762
  },
758
- finally: [".build-lib:delete-babel-ignored-files"]
763
+ finally: [".build-lib:delete-babel-ignored-files"],
759
764
  },
760
765
 
761
766
  ".clean.lib:server": () => shell.rm("-rf", AppMode.lib.server),
@@ -777,8 +782,8 @@ module.exports = {
777
782
  `--source-maps=inline --copy-files`,
778
783
  `--ignore=${babelCliIgnore}`
779
784
  ),
780
- ".build-lib:delete-babel-ignored-files"
781
- ]
785
+ ".build-lib:delete-babel-ignored-files",
786
+ ],
782
787
  },
783
788
 
784
789
  check: ["lint", "test-cov"],
@@ -823,7 +828,7 @@ module.exports = {
823
828
  ["config/assets.json", "lib/server"],
824
829
  `node ${context.args.join(" ")} lib/server`
825
830
  )
826
- )
831
+ ),
827
832
  ]);
828
833
 
829
834
  if (!Fs.existsSync("dist")) {
@@ -836,7 +841,7 @@ module.exports = {
836
841
  }
837
842
 
838
843
  return xrun2.serial(() => console.log("dist exist, skipping build task"), mockTask);
839
- }
844
+ },
840
845
  },
841
846
 
842
847
  "setup-dev": {
@@ -845,7 +850,7 @@ You only need to run this if you are doing something not through the xarc tasks.
845
850
  dep: [".webpack-dev", ".development-env"],
846
851
  task() {
847
852
  console.log(`xarc dev options configured.`);
848
- }
853
+ },
849
854
  },
850
855
 
851
856
  dev: {
@@ -855,7 +860,7 @@ You only need to run this if you are doing something not through the xarc tasks.
855
860
  task() {
856
861
  const args = this.args.join(" ");
857
862
  return [".webpack-dev", [`server-admin ${args}`, "generate-service-worker"]];
858
- }
863
+ },
859
864
  },
860
865
 
861
866
  hot: {
@@ -863,12 +868,12 @@ You only need to run this if you are doing something not through the xarc tasks.
863
868
  task: () => {
864
869
  xarcOptions.webpack.enableHotModuleReload = true;
865
870
  return "dev";
866
- }
871
+ },
867
872
  },
868
873
 
869
874
  "dev-static": {
870
875
  desc: "Start server in development mode with statically built files",
871
- task: ["build-dev-static", "app-server"]
876
+ task: ["build-dev-static", "app-server"],
872
877
  },
873
878
 
874
879
  "npm:test": ["check"],
@@ -878,39 +883,39 @@ You only need to run this if you are doing something not through the xarc tasks.
878
883
 
879
884
  "app-server": {
880
885
  desc: "Start the app server only. Must run 'clap build' first.",
881
- task: () => startAppServer()
886
+ task: () => startAppServer(),
882
887
  },
883
888
 
884
889
  "server-debug": {
885
890
  desc: "Start the app serve with 'node debug'",
886
- task: () => startAppServer(["debug"])
891
+ task: () => startAppServer(["debug"]),
887
892
  },
888
893
 
889
894
  "server-build-debug": {
890
895
  desc: "Build and debug with devTools",
891
- task: ["build", "server-devtools"]
896
+ task: ["build", "server-devtools"],
892
897
  },
893
898
 
894
899
  "server-build-debug-brk": {
895
900
  desc: "Build and debug with devTools with breakpoint starting the app",
896
- task: ["build", "server-devtools-debug-brk"]
901
+ task: ["build", "server-devtools-debug-brk"],
897
902
  },
898
903
 
899
904
  "server-devtools": {
900
905
  desc: "Debug the app server with 'node --inspect'",
901
- task: () => startAppServer(["--inspect"])
906
+ task: () => startAppServer(["--inspect"]),
902
907
  },
903
908
 
904
909
  "server-devtools-debug-brk": {
905
910
  desc: "Debug the app server with 'node --inspect --debug-brk'",
906
- task: () => startAppServer(["--inspect", "--debug-brk"])
911
+ task: () => startAppServer(["--inspect", "--debug-brk"]),
907
912
  },
908
913
 
909
914
  "server-prod": {
910
915
  dep: [".production-env", ".static-files-env"],
911
916
  desc:
912
917
  "Start server in production mode with static files routes. Must run 'clap build' first.",
913
- task: () => startAppServer()
918
+ task: () => startAppServer(),
914
919
  },
915
920
 
916
921
  ".init-bundle.valid.log": () =>
@@ -923,9 +928,9 @@ You only need to run this if you are doing something not through the xarc tasks.
923
928
  AppMode.setEnv(AppMode.src.dir);
924
929
  // eslint-disable-next-line no-shadow
925
930
  const exec = quote(Path.join(xarcOptions.devDir, "lib/babel-run"));
926
- const isNodeArgs = x => x.startsWith("--inspect");
931
+ const isNodeArgs = (x) => x.startsWith("--inspect");
927
932
  const nodeArgs = context.args.filter(isNodeArgs).join(" ");
928
- const otherArgs = context.args.filter(x => !isNodeArgs(x)).join(" ");
933
+ const otherArgs = context.args.filter((x) => !isNodeArgs(x)).join(" ");
929
934
 
930
935
  // get user specified port for admin
931
936
  const userPort = getDevAdminPortFromEnv(xarcOptions.adminPort);
@@ -941,7 +946,7 @@ You only need to run this if you are doing something not through the xarc tasks.
941
946
  `--watch config ${AppMode.src.server}`,
942
947
  `-- ${AppMode.src.server}`
943
948
  );
944
- }
949
+ },
945
950
  },
946
951
 
947
952
  "server-admin.test": {
@@ -951,9 +956,9 @@ You only need to run this if you are doing something not through the xarc tasks.
951
956
  AppMode.setEnv(AppMode.src.dir);
952
957
  // eslint-disable-next-line no-shadow
953
958
  const exec = quote(Path.join(xarcOptions.devDir, "lib/babel-run"));
954
- const isNodeArgs = x => x.startsWith("--inspect");
959
+ const isNodeArgs = (x) => x.startsWith("--inspect");
955
960
  const nodeArgs = context.args.filter(isNodeArgs);
956
- const otherArgs = context.args.filter(x => !isNodeArgs(x));
961
+ const otherArgs = context.args.filter((x) => !isNodeArgs(x));
957
962
  return mkCmd(
958
963
  `~(tty)$node`,
959
964
  nodeArgs.join(" "),
@@ -963,7 +968,7 @@ You only need to run this if you are doing something not through the xarc tasks.
963
968
  `--watch config ${AppMode.src.server}`,
964
969
  `-- ${AppMode.src.server}`
965
970
  );
966
- }
971
+ },
967
972
  },
968
973
 
969
974
  "dev-proxy": {
@@ -973,7 +978,7 @@ You only need to run this if you are doing something not through the xarc tasks.
973
978
  const debug = context.argOpts.debug ? "--inspect-brk " : "";
974
979
  const proxySpawn = require.resolve("@xarc/app-dev/lib/dev-admin/redbird-spawn");
975
980
  return `~(tty)$node ${debug}${proxySpawn} ${context.args.join(" ")}`;
976
- }
981
+ },
977
982
  },
978
983
 
979
984
  "test-server": xrun2.concurrent(["lint-server", "lint-server-test"], "test-server-cov"),
@@ -983,8 +988,8 @@ You only need to run this if you are doing something not through the xarc tasks.
983
988
  "test-cov": [
984
989
  "?.karma.test-frontend-cov",
985
990
  "?.jest.test-frontend-cov",
986
- "test-server-cov"
987
- ].filter(x => x),
991
+ "test-server-cov",
992
+ ].filter((x) => x),
988
993
  "test-dev": ["test-frontend-dev", "test-server-dev"],
989
994
 
990
995
  "test-watch": ["test-watch-all"],
@@ -1005,25 +1010,25 @@ You only need to run this if you are doing something not through the xarc tasks.
1005
1010
  "Please ensure `options.criticalCSS = true` in your `archetype/config.js` or `archetype/config/index.js`, then reinstall your dependencies";
1006
1011
  throw new Error(`Missing Dependencies\n${error}`);
1007
1012
  }
1008
- }
1013
+ },
1009
1014
  },
1010
1015
  "generate-service-worker": {
1011
1016
  desc:
1012
1017
  "Generate Service Worker using the options provided in the app/config/sw-precache-config.json " +
1013
1018
  "file for prod/dev mode",
1014
- task: () => generateServiceWorker()
1019
+ task: () => generateServiceWorker(),
1015
1020
  },
1016
1021
  pwa: {
1017
1022
  desc:
1018
1023
  "PWA must have dist by running `clap build` first and then start the app server only.",
1019
- task: ["build", "server"]
1024
+ task: ["build", "server"],
1020
1025
  },
1021
1026
 
1022
1027
  "generate-browsers-listrc": {
1023
1028
  desc:
1024
1029
  "Generate .browserlistrc config file, it's used by Browserlist for AutoPrefixer/PostCSS",
1025
- task: () => generateBrowsersListRc()
1026
- }
1030
+ task: () => generateBrowsersListRc(),
1031
+ },
1027
1032
  };
1028
1033
 
1029
1034
  tasks = Object.assign(tasks, {
@@ -1037,8 +1042,8 @@ You only need to run this if you are doing something not through the xarc tasks.
1037
1042
  ".build-lib": {
1038
1043
  desc: false,
1039
1044
  dep: [".clean.lib", ".mk-prod-dir"],
1040
- task: ["build-lib:all", ".build-lib:app-mode"]
1041
- }
1045
+ task: ["build-lib:all", ".build-lib:app-mode"],
1046
+ },
1042
1047
  });
1043
1048
 
1044
1049
  if (Fs.existsSync(Path.resolve(xarcCwd, AppMode.src.client, "dll.config.js"))) {
@@ -1052,9 +1057,9 @@ You only need to run this if you are doing something not through the xarc tasks.
1052
1057
  quote(getWebpackStartConfig("webpack.config.dll.js")),
1053
1058
  `--color`
1054
1059
  );
1055
- }
1060
+ },
1056
1061
  },
1057
- "copy-dll": () => shell.cp("-r", "dll/*", "dist")
1062
+ "copy-dll": () => shell.cp("-r", "dll/*", "dist"),
1058
1063
  });
1059
1064
  }
1060
1065
 
@@ -1074,7 +1079,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1074
1079
  `--colors`,
1075
1080
  noSingleRun
1076
1081
  );
1077
- }
1082
+ },
1078
1083
  },
1079
1084
 
1080
1085
  ".karma.test-frontend-ci": {
@@ -1087,7 +1092,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1087
1092
  `--colors`,
1088
1093
  noSingleRun
1089
1094
  );
1090
- }
1095
+ },
1091
1096
  },
1092
1097
 
1093
1098
  ".karma.test-frontend-cov": {
@@ -1104,7 +1109,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1104
1109
  );
1105
1110
  }
1106
1111
  return undefined;
1107
- }
1112
+ },
1108
1113
  },
1109
1114
 
1110
1115
  ".karma.test-frontend-dev": ["test-frontend"],
@@ -1117,7 +1122,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1117
1122
  `--colors --browsers Chrome --no-single-run --auto-watch`,
1118
1123
  noSingleRun
1119
1124
  );
1120
- }
1125
+ },
1121
1126
  });
1122
1127
  } else {
1123
1128
  const karmaTasksDisabled = () => {
@@ -1129,7 +1134,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1129
1134
  ".karma.test-frontend-ci": karmaTasksDisabled,
1130
1135
  ".karma.test-frontend-cov": karmaTasksDisabled,
1131
1136
  ".karma.test-frontend-dev": karmaTasksDisabled,
1132
- ".karma.test-frontend-dev-watch": karmaTasksDisabled
1137
+ ".karma.test-frontend-dev-watch": karmaTasksDisabled,
1133
1138
  });
1134
1139
  }
1135
1140
 
@@ -1139,19 +1144,19 @@ You only need to run this if you are doing something not through the xarc tasks.
1139
1144
  desc: "Run jest tests (--inspect-brk to start debugger)",
1140
1145
  task() {
1141
1146
  return `.jest.test-frontend-cov ${this.argv.slice(1).join(" ")}`;
1142
- }
1147
+ },
1143
1148
  },
1144
1149
  ".jest.test-frontend-cov"() {
1145
- const testDir = jestTestDirectories.find(x => shell.test("-d", x));
1150
+ const testDir = jestTestDirectories.find((x) => shell.test("-d", x));
1146
1151
  let runJest: any = testDir;
1147
1152
  if (!runJest) {
1148
1153
  const scanned = scanDir.sync({
1149
1154
  dir: Path.resolve(xarcCwd, AppMode.src.dir),
1150
1155
  grouping: true,
1151
1156
  includeDir: true,
1152
- filterDir: d => (jestTestDirectories.indexOf(d) >= 0 ? "dirs" : "otherDirs"),
1157
+ filterDir: (d) => (jestTestDirectories.indexOf(d) >= 0 ? "dirs" : "otherDirs"),
1153
1158
  filterExt: [".js", ".jsx", ".ts", ".tsx"],
1154
- filter: x => x.indexOf(".spec.") > 0 || x.indexOf(".test.") > 0
1159
+ filter: (x) => x.indexOf(".spec.") > 0 || x.indexOf(".test.") > 0,
1155
1160
  });
1156
1161
 
1157
1162
  runJest = Boolean(scanned.dirs || scanned.files.length > 0);
@@ -1167,7 +1172,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1167
1172
  logger.info("Running jest unit tests");
1168
1173
 
1169
1174
  const brk = this.argv.indexOf("--inspect-brk") >= 0 ? "--inspect-brk" : "";
1170
- const jestOpts = this.argv.slice(1).filter(x => x !== "--inspect-brk");
1175
+ const jestOpts = this.argv.slice(1).filter((x) => x !== "--inspect-brk");
1171
1176
 
1172
1177
  return mkCmd(
1173
1178
  `~(tty)$node`,
@@ -1179,14 +1184,14 @@ You only need to run this if you are doing something not through the xarc tasks.
1179
1184
  } else {
1180
1185
  return undefined;
1181
1186
  }
1182
- }
1187
+ },
1183
1188
  });
1184
1189
  } else {
1185
1190
  Object.assign(tasks, {
1186
1191
  jest: () => {
1187
1192
  logger.info(`Running jest tests is not enabled because @xarc/opt-jest is not installed.
1188
1193
  Please add it to your devDependencies to enable running jest tests.`);
1189
- }
1194
+ },
1190
1195
  });
1191
1196
  }
1192
1197
 
@@ -1211,7 +1216,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1211
1216
  return mkCmd(`~$mocha -c --opts`, quote(mochaConfig("mocha.opts")), `test/server`);
1212
1217
  }
1213
1218
  return undefined;
1214
- }
1219
+ },
1215
1220
  });
1216
1221
  } else {
1217
1222
  const mochaTestDisabled = () => {
@@ -1220,7 +1225,7 @@ You only need to run this if you are doing something not through the xarc tasks.
1220
1225
  };
1221
1226
  Object.assign(tasks, {
1222
1227
  "test-server-cov": mochaTestDisabled,
1223
- "test-server-dev": mochaTestDisabled
1228
+ "test-server-dev": mochaTestDisabled,
1224
1229
  });
1225
1230
  }
1226
1231