create-vue 2.1.0-beta → 2.1.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.
Files changed (59) hide show
  1. package/outfile.cjs +315 -104
  2. package/package.json +6 -3
  3. package/template/base/node_modules/.bin/vite +17 -0
  4. package/template/base/package.json +5 -5
  5. package/template/{code/default/cypress/integration/example.spec.js → config/cypress/cypress/e2e/example.cy.js} +0 -0
  6. package/template/config/cypress/cypress/{jsconfig.json → e2e/jsconfig.json} +1 -1
  7. package/template/config/cypress/cypress/support/commands.ts +37 -0
  8. package/template/config/cypress/cypress/support/{index.js → e2e.js} +0 -0
  9. package/template/config/cypress/cypress.config.js +8 -0
  10. package/template/config/cypress/cypress.config.ts +8 -0
  11. package/template/config/cypress/node_modules/.bin/cypress +17 -0
  12. package/template/config/cypress/node_modules/.bin/server-test +17 -0
  13. package/template/config/cypress/node_modules/.bin/start-server-and-test +17 -0
  14. package/template/config/cypress/node_modules/.bin/start-test +17 -0
  15. package/template/config/cypress/package.json +4 -9
  16. package/template/config/cypress-ct/cypress/support/component-index.html +12 -0
  17. package/template/config/cypress-ct/cypress/support/component.js +27 -0
  18. package/template/config/cypress-ct/cypress/support/component.ts +39 -0
  19. package/template/config/cypress-ct/cypress.config.js +15 -0
  20. package/template/config/cypress-ct/cypress.config.ts +15 -0
  21. package/template/config/cypress-ct/node_modules/.bin/cypress +17 -0
  22. package/template/config/cypress-ct/package.json +12 -0
  23. package/template/{code/typescript-default/src/components/__tests__/HelloWorld.spec.ts → config/cypress-ct/src/components/__tests__/HelloWorld.cy.js} +2 -3
  24. package/template/config/jsx/node_modules/.bin/vite +17 -0
  25. package/template/config/jsx/package.json +9 -0
  26. package/template/config/jsx/vite.config.js +23 -0
  27. package/template/config/pinia/package.json +2 -1
  28. package/template/config/router/package.json +1 -1
  29. package/template/config/typescript/node_modules/.bin/npm-run-all +17 -0
  30. package/template/config/typescript/node_modules/.bin/run-p +17 -0
  31. package/template/config/typescript/node_modules/.bin/run-s +17 -0
  32. package/template/config/typescript/node_modules/.bin/tsc +17 -0
  33. package/template/config/typescript/node_modules/.bin/tsserver +17 -0
  34. package/template/config/typescript/node_modules/.bin/vue-tsc +17 -0
  35. package/template/config/typescript/package.json +7 -5
  36. package/template/config/vitest/node_modules/.bin/vitest +17 -0
  37. package/template/config/vitest/package.json +14 -0
  38. package/template/config/vitest/src/components/__tests__/HelloWorld.spec.js +11 -0
  39. package/template/eslint/package.json +11 -0
  40. package/template/tsconfig/base/package.json +5 -0
  41. package/template/tsconfig/base/tsconfig.config.json +8 -0
  42. package/template/tsconfig/base/tsconfig.json +16 -0
  43. package/template/tsconfig/cypress/cypress/e2e/tsconfig.json +10 -0
  44. package/template/tsconfig/cypress-ct/tsconfig.app.json +12 -0
  45. package/template/tsconfig/cypress-ct/tsconfig.cypress-ct.json +8 -0
  46. package/template/tsconfig/cypress-ct/tsconfig.json +14 -0
  47. package/template/tsconfig/vitest/package.json +8 -0
  48. package/template/tsconfig/vitest/tsconfig.app.json +12 -0
  49. package/template/tsconfig/vitest/tsconfig.json +14 -0
  50. package/template/tsconfig/vitest/tsconfig.vitest.json +9 -0
  51. package/template/code/default/src/components/__tests__/HelloWorld.spec.js +0 -13
  52. package/template/code/router/cypress/integration/example.spec.js +0 -13
  53. package/template/code/router/src/components/__tests__/HelloWorld.spec.js +0 -13
  54. package/template/code/typescript-default/cypress/integration/example.spec.ts +0 -8
  55. package/template/code/typescript-router/cypress/integration/example.spec.ts +0 -13
  56. package/template/code/typescript-router/src/components/__tests__/HelloWorld.spec.ts +0 -13
  57. package/template/config/cypress/cypress/plugins/index.js +0 -28
  58. package/template/config/cypress/cypress.json +0 -7
  59. package/template/config/typescript/tsconfig.json +0 -24
package/outfile.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /*! create-vue v2.1.0-beta | MIT */
2
+ /*! create-vue v2.1.0 | MIT */
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -761,7 +761,7 @@ var require_prompt = __commonJS({
761
761
  var require_text = __commonJS({
762
762
  "node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js"(exports, module2) {
763
763
  "use strict";
764
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
764
+ function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
765
765
  try {
766
766
  var info = gen[key](arg);
767
767
  var value = info.value;
@@ -770,7 +770,7 @@ var require_text = __commonJS({
770
770
  return;
771
771
  }
772
772
  if (info.done) {
773
- resolve(value);
773
+ resolve5(value);
774
774
  } else {
775
775
  Promise.resolve(value).then(_next, _throw);
776
776
  }
@@ -778,13 +778,13 @@ var require_text = __commonJS({
778
778
  function _asyncToGenerator(fn) {
779
779
  return function() {
780
780
  var self2 = this, args = arguments;
781
- return new Promise(function(resolve, reject) {
781
+ return new Promise(function(resolve5, reject) {
782
782
  var gen = fn.apply(self2, args);
783
783
  function _next(value) {
784
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
784
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
785
785
  }
786
786
  function _throw(err) {
787
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
787
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
788
788
  }
789
789
  _next(void 0);
790
790
  });
@@ -1521,7 +1521,7 @@ var require_dateparts = __commonJS({
1521
1521
  var require_date = __commonJS({
1522
1522
  "node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js"(exports, module2) {
1523
1523
  "use strict";
1524
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1524
+ function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
1525
1525
  try {
1526
1526
  var info = gen[key](arg);
1527
1527
  var value = info.value;
@@ -1530,7 +1530,7 @@ var require_date = __commonJS({
1530
1530
  return;
1531
1531
  }
1532
1532
  if (info.done) {
1533
- resolve(value);
1533
+ resolve5(value);
1534
1534
  } else {
1535
1535
  Promise.resolve(value).then(_next, _throw);
1536
1536
  }
@@ -1538,13 +1538,13 @@ var require_date = __commonJS({
1538
1538
  function _asyncToGenerator(fn) {
1539
1539
  return function() {
1540
1540
  var self2 = this, args = arguments;
1541
- return new Promise(function(resolve, reject) {
1541
+ return new Promise(function(resolve5, reject) {
1542
1542
  var gen = fn.apply(self2, args);
1543
1543
  function _next(value) {
1544
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1544
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
1545
1545
  }
1546
1546
  function _throw(err) {
1547
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1547
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
1548
1548
  }
1549
1549
  _next(void 0);
1550
1550
  });
@@ -1747,7 +1747,7 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
1747
1747
  var require_number = __commonJS({
1748
1748
  "node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/number.js"(exports, module2) {
1749
1749
  "use strict";
1750
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1750
+ function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
1751
1751
  try {
1752
1752
  var info = gen[key](arg);
1753
1753
  var value = info.value;
@@ -1756,7 +1756,7 @@ var require_number = __commonJS({
1756
1756
  return;
1757
1757
  }
1758
1758
  if (info.done) {
1759
- resolve(value);
1759
+ resolve5(value);
1760
1760
  } else {
1761
1761
  Promise.resolve(value).then(_next, _throw);
1762
1762
  }
@@ -1764,13 +1764,13 @@ var require_number = __commonJS({
1764
1764
  function _asyncToGenerator(fn) {
1765
1765
  return function() {
1766
1766
  var self2 = this, args = arguments;
1767
- return new Promise(function(resolve, reject) {
1767
+ return new Promise(function(resolve5, reject) {
1768
1768
  var gen = fn.apply(self2, args);
1769
1769
  function _next(value) {
1770
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1770
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
1771
1771
  }
1772
1772
  function _throw(err) {
1773
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1773
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
1774
1774
  }
1775
1775
  _next(void 0);
1776
1776
  });
@@ -2205,7 +2205,7 @@ Instructions:
2205
2205
  var require_autocomplete = __commonJS({
2206
2206
  "node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocomplete.js"(exports, module2) {
2207
2207
  "use strict";
2208
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2208
+ function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
2209
2209
  try {
2210
2210
  var info = gen[key](arg);
2211
2211
  var value = info.value;
@@ -2214,7 +2214,7 @@ var require_autocomplete = __commonJS({
2214
2214
  return;
2215
2215
  }
2216
2216
  if (info.done) {
2217
- resolve(value);
2217
+ resolve5(value);
2218
2218
  } else {
2219
2219
  Promise.resolve(value).then(_next, _throw);
2220
2220
  }
@@ -2222,13 +2222,13 @@ var require_autocomplete = __commonJS({
2222
2222
  function _asyncToGenerator(fn) {
2223
2223
  return function() {
2224
2224
  var self2 = this, args = arguments;
2225
- return new Promise(function(resolve, reject) {
2225
+ return new Promise(function(resolve5, reject) {
2226
2226
  var gen = fn.apply(self2, args);
2227
2227
  function _next(value) {
2228
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2228
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
2229
2229
  }
2230
2230
  function _throw(err) {
2231
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2231
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
2232
2232
  }
2233
2233
  _next(void 0);
2234
2234
  });
@@ -2891,7 +2891,7 @@ var require_dist = __commonJS({
2891
2891
  arr2[i] = arr[i];
2892
2892
  return arr2;
2893
2893
  }
2894
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2894
+ function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
2895
2895
  try {
2896
2896
  var info = gen[key](arg);
2897
2897
  var value = info.value;
@@ -2900,7 +2900,7 @@ var require_dist = __commonJS({
2900
2900
  return;
2901
2901
  }
2902
2902
  if (info.done) {
2903
- resolve(value);
2903
+ resolve5(value);
2904
2904
  } else {
2905
2905
  Promise.resolve(value).then(_next, _throw);
2906
2906
  }
@@ -2908,13 +2908,13 @@ var require_dist = __commonJS({
2908
2908
  function _asyncToGenerator(fn) {
2909
2909
  return function() {
2910
2910
  var self2 = this, args = arguments;
2911
- return new Promise(function(resolve, reject) {
2911
+ return new Promise(function(resolve5, reject) {
2912
2912
  var gen = fn.apply(self2, args);
2913
2913
  function _next(value) {
2914
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2914
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
2915
2915
  }
2916
2916
  function _throw(err) {
2917
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2917
+ asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
2918
2918
  }
2919
2919
  _next(void 0);
2920
2920
  });
@@ -5255,9 +5255,9 @@ var require_prompts3 = __commonJS({
5255
5255
  }
5256
5256
  });
5257
5257
 
5258
- // index.js
5259
- var import_fs3 = __toESM(require("fs"), 1);
5260
- var import_path3 = __toESM(require("path"), 1);
5258
+ // index.ts
5259
+ var fs4 = __toESM(require("fs"), 1);
5260
+ var path4 = __toESM(require("path"), 1);
5261
5261
  var import_minimist = __toESM(require_minimist(), 1);
5262
5262
  var import_prompts = __toESM(require_prompts3(), 1);
5263
5263
 
@@ -5343,11 +5343,11 @@ var bgLightMagenta = kolorist(105, 49);
5343
5343
  var bgLightCyan = kolorist(106, 49);
5344
5344
  var bgLightGray = kolorist(47, 49);
5345
5345
 
5346
- // utils/renderTemplate.js
5347
- var import_fs = __toESM(require("fs"), 1);
5348
- var import_path = __toESM(require("path"), 1);
5346
+ // utils/renderTemplate.ts
5347
+ var fs = __toESM(require("fs"), 1);
5348
+ var path = __toESM(require("path"), 1);
5349
5349
 
5350
- // utils/deepMerge.js
5350
+ // utils/deepMerge.ts
5351
5351
  var isObject = (val) => val && typeof val === "object";
5352
5352
  var mergeArrayWithDedupe = (a, b) => Array.from(/* @__PURE__ */ new Set([...a, ...b]));
5353
5353
  function deepMerge(target, obj) {
@@ -5366,7 +5366,7 @@ function deepMerge(target, obj) {
5366
5366
  }
5367
5367
  var deepMerge_default = deepMerge;
5368
5368
 
5369
- // utils/sortDependencies.js
5369
+ // utils/sortDependencies.ts
5370
5370
  function sortDependencies(packageJson) {
5371
5371
  const sorted = {};
5372
5372
  const depTypes = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
@@ -5384,40 +5384,43 @@ function sortDependencies(packageJson) {
5384
5384
  };
5385
5385
  }
5386
5386
 
5387
- // utils/renderTemplate.js
5387
+ // utils/renderTemplate.ts
5388
5388
  function renderTemplate(src, dest) {
5389
- const stats = import_fs.default.statSync(src);
5389
+ const stats = fs.statSync(src);
5390
5390
  if (stats.isDirectory()) {
5391
- import_fs.default.mkdirSync(dest, { recursive: true });
5392
- for (const file of import_fs.default.readdirSync(src)) {
5393
- renderTemplate(import_path.default.resolve(src, file), import_path.default.resolve(dest, file));
5391
+ if (path.basename(src) === "node_modules") {
5392
+ return;
5393
+ }
5394
+ fs.mkdirSync(dest, { recursive: true });
5395
+ for (const file of fs.readdirSync(src)) {
5396
+ renderTemplate(path.resolve(src, file), path.resolve(dest, file));
5394
5397
  }
5395
5398
  return;
5396
5399
  }
5397
- const filename = import_path.default.basename(src);
5398
- if (filename === "package.json" && import_fs.default.existsSync(dest)) {
5399
- const existing = JSON.parse(import_fs.default.readFileSync(dest));
5400
- const newPackage = JSON.parse(import_fs.default.readFileSync(src));
5400
+ const filename = path.basename(src);
5401
+ if (filename === "package.json" && fs.existsSync(dest)) {
5402
+ const existing = JSON.parse(fs.readFileSync(dest, "utf8"));
5403
+ const newPackage = JSON.parse(fs.readFileSync(src, "utf8"));
5401
5404
  const pkg = sortDependencies(deepMerge_default(existing, newPackage));
5402
- import_fs.default.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
5405
+ fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
5403
5406
  return;
5404
5407
  }
5405
5408
  if (filename.startsWith("_")) {
5406
- dest = import_path.default.resolve(import_path.default.dirname(dest), filename.replace(/^_/, "."));
5409
+ dest = path.resolve(path.dirname(dest), filename.replace(/^_/, "."));
5407
5410
  }
5408
- import_fs.default.copyFileSync(src, dest);
5411
+ fs.copyFileSync(src, dest);
5409
5412
  }
5410
5413
  var renderTemplate_default = renderTemplate;
5411
5414
 
5412
- // utils/directoryTraverse.js
5413
- var import_fs2 = __toESM(require("fs"), 1);
5414
- var import_path2 = __toESM(require("path"), 1);
5415
+ // utils/directoryTraverse.ts
5416
+ var fs2 = __toESM(require("fs"), 1);
5417
+ var path2 = __toESM(require("path"), 1);
5415
5418
  function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
5416
- for (const filename of import_fs2.default.readdirSync(dir)) {
5417
- const fullpath = import_path2.default.resolve(dir, filename);
5418
- if (import_fs2.default.lstatSync(fullpath).isDirectory()) {
5419
+ for (const filename of fs2.readdirSync(dir)) {
5420
+ const fullpath = path2.resolve(dir, filename);
5421
+ if (fs2.lstatSync(fullpath).isDirectory()) {
5419
5422
  dirCallback(fullpath);
5420
- if (import_fs2.default.existsSync(fullpath)) {
5423
+ if (fs2.existsSync(fullpath)) {
5421
5424
  preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
5422
5425
  }
5423
5426
  continue;
@@ -5426,9 +5429,9 @@ function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
5426
5429
  }
5427
5430
  }
5428
5431
  function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
5429
- for (const filename of import_fs2.default.readdirSync(dir)) {
5430
- const fullpath = import_path2.default.resolve(dir, filename);
5431
- if (import_fs2.default.lstatSync(fullpath).isDirectory()) {
5432
+ for (const filename of fs2.readdirSync(dir)) {
5433
+ const fullpath = path2.resolve(dir, filename);
5434
+ if (fs2.lstatSync(fullpath).isDirectory()) {
5432
5435
  postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
5433
5436
  dirCallback(fullpath);
5434
5437
  continue;
@@ -5437,7 +5440,7 @@ function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
5437
5440
  }
5438
5441
  }
5439
5442
 
5440
- // utils/getCommand.js
5443
+ // utils/getCommand.ts
5441
5444
  function getCommand(packageManager, scriptName) {
5442
5445
  if (scriptName === "install") {
5443
5446
  return packageManager === "yarn" ? "yarn" : `${packageManager} install`;
@@ -5445,21 +5448,37 @@ function getCommand(packageManager, scriptName) {
5445
5448
  return packageManager === "npm" ? `npm run ${scriptName}` : `${packageManager} ${scriptName}`;
5446
5449
  }
5447
5450
 
5448
- // utils/generateReadme.js
5449
- var sfcTypeSupportDoc = "\n## Type Support for `.vue` Imports in TS\n\nSince TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates.\n\nHowever, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can run `Volar: Switch TS Plugin on/off` from VSCode command palette.\n";
5451
+ // utils/generateReadme.ts
5452
+ var sfcTypeSupportDoc = [
5453
+ "",
5454
+ "## Type Support for `.vue` Imports in TS",
5455
+ "",
5456
+ "TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.",
5457
+ "",
5458
+ "If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:",
5459
+ "",
5460
+ "1. Disable the built-in TypeScript Extension",
5461
+ " 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette",
5462
+ " 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`",
5463
+ "2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.",
5464
+ ""
5465
+ ].join("\n");
5450
5466
  function generateReadme({
5451
5467
  projectName,
5452
5468
  packageManager,
5453
5469
  needsTypeScript,
5454
- needsTests
5470
+ needsCypress,
5471
+ needsCypressCT,
5472
+ needsVitest,
5473
+ needsEslint
5455
5474
  }) {
5456
5475
  let readme = `# ${projectName}
5457
5476
 
5458
- This template should help get you started developing with Vue 2 in Vite.
5477
+ This template should help get you started developing with Vue 3 in Vite.
5459
5478
 
5460
5479
  ## Recommended IDE Setup
5461
5480
 
5462
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur).
5481
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
5463
5482
  ${needsTypeScript ? sfcTypeSupportDoc : ""}
5464
5483
  ## Customize configuration
5465
5484
 
@@ -5484,27 +5503,139 @@ ${getCommand(packageManager, "dev")}
5484
5503
  ${getCommand(packageManager, "build")}
5485
5504
  \`\`\`
5486
5505
  `;
5487
- if (needsTests) {
5506
+ if (needsVitest) {
5488
5507
  npmScriptsDescriptions += `
5489
- ### Run Unit Tests with [Cypress Component Testing](https://docs.cypress.io/guides/component-testing/introduction)
5508
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
5490
5509
 
5491
5510
  \`\`\`sh
5492
- ${getCommand(packageManager, "test:unit")} # or \`${getCommand(packageManager, "test:unit:ci")}\` for headless testing
5511
+ ${getCommand(packageManager, "test:unit")}
5493
5512
  \`\`\`
5513
+ `;
5514
+ }
5515
+ if (needsCypressCT) {
5516
+ npmScriptsDescriptions += `
5517
+ ### Run Headed Component Tests with [Cypress Component Testing](https://on.cypress.io/component)
5494
5518
 
5519
+ \`\`\`sh
5520
+ ${getCommand(packageManager, "test:unit")} # or \`${getCommand(packageManager, "test:unit:ci")}\` for headless testing
5521
+ \`\`\`
5522
+ `;
5523
+ }
5524
+ if (needsCypress) {
5525
+ npmScriptsDescriptions += `
5495
5526
  ### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
5496
5527
 
5497
5528
  \`\`\`sh
5498
5529
  ${getCommand(packageManager, "build")}
5499
5530
  ${getCommand(packageManager, "test:e2e")} # or \`${getCommand(packageManager, "test:e2e:ci")}\` for headless testing
5500
5531
  \`\`\`
5532
+ `;
5533
+ }
5534
+ if (needsEslint) {
5535
+ npmScriptsDescriptions += `
5536
+ ### Lint with [ESLint](https://eslint.org/)
5537
+
5538
+ \`\`\`sh
5539
+ ${getCommand(packageManager, "lint")}
5540
+ \`\`\`
5501
5541
  `;
5502
5542
  }
5503
5543
  readme += npmScriptsDescriptions;
5504
5544
  return readme;
5505
5545
  }
5506
5546
 
5507
- // index.js
5547
+ // utils/renderEslint.ts
5548
+ var fs3 = __toESM(require("fs"), 1);
5549
+ var path3 = __toESM(require("path"), 1);
5550
+
5551
+ // template/eslint/package.json
5552
+ var devDependencies = {
5553
+ "@rushstack/eslint-patch": "^1.1.0",
5554
+ "@vue/eslint-config-prettier": "^7.0.0",
5555
+ "@vue/eslint-config-typescript": "^11.0.0",
5556
+ eslint: "^8.5.0",
5557
+ "eslint-plugin-cypress": "^2.12.1",
5558
+ "eslint-plugin-vue": "^9.0.0",
5559
+ prettier: "^2.5.1"
5560
+ };
5561
+
5562
+ // utils/renderEslint.ts
5563
+ var dependencies = {};
5564
+ function addEslintDependency(name) {
5565
+ dependencies[name] = devDependencies[name];
5566
+ }
5567
+ addEslintDependency("eslint");
5568
+ addEslintDependency("eslint-plugin-vue");
5569
+ var config = {
5570
+ root: true,
5571
+ extends: ["plugin:vue/essential"]
5572
+ };
5573
+ function configureEslint({ language, styleGuide, needsPrettier, needsCypress, needsCypressCT }) {
5574
+ switch (`${styleGuide}-${language}`) {
5575
+ case "default-javascript":
5576
+ config.extends.push("eslint:recommended");
5577
+ break;
5578
+ case "default-typescript":
5579
+ addEslintDependency("@vue/eslint-config-typescript");
5580
+ config.extends.push("eslint:recommended");
5581
+ config.extends.push("@vue/eslint-config-typescript/recommended");
5582
+ break;
5583
+ }
5584
+ if (needsPrettier) {
5585
+ addEslintDependency("prettier");
5586
+ addEslintDependency("@vue/eslint-config-prettier");
5587
+ config.extends.push("@vue/eslint-config-prettier");
5588
+ }
5589
+ if (needsCypress) {
5590
+ const cypressOverrides = [
5591
+ {
5592
+ files: needsCypressCT ? ["**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}", "cypress/e2e/**.{cy,spec}.{js,ts,jsx,tsx}"] : ["cypress/e2e/**.{cy,spec}.{js,ts,jsx,tsx}"],
5593
+ extends: ["plugin:cypress/recommended"]
5594
+ }
5595
+ ];
5596
+ addEslintDependency("eslint-plugin-cypress");
5597
+ config.overrides = cypressOverrides;
5598
+ }
5599
+ let configuration = "/* eslint-env node */\n";
5600
+ if (styleGuide !== "default" || language !== "javascript" || needsPrettier) {
5601
+ addEslintDependency("@rushstack/eslint-patch");
5602
+ configuration += `require("@rushstack/eslint-patch/modern-module-resolution");
5603
+
5604
+ `;
5605
+ }
5606
+ configuration += `module.exports = ${JSON.stringify(config, void 0, 2)}
5607
+ `;
5608
+ return {
5609
+ dependencies,
5610
+ configuration
5611
+ };
5612
+ }
5613
+ function renderEslint(rootDir, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier }) {
5614
+ const { dependencies: dependencies2, configuration } = configureEslint({
5615
+ language: needsTypeScript ? "typescript" : "javascript",
5616
+ styleGuide: "default",
5617
+ needsPrettier,
5618
+ needsCypress,
5619
+ needsCypressCT
5620
+ });
5621
+ const packageJsonPath = path3.resolve(rootDir, "package.json");
5622
+ const existingPkg = JSON.parse(fs3.readFileSync(packageJsonPath, "utf8"));
5623
+ const pkg = sortDependencies(deepMerge_default(existingPkg, {
5624
+ scripts: {
5625
+ lint: needsTypeScript ? "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" : "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
5626
+ },
5627
+ devDependencies: dependencies2
5628
+ }));
5629
+ fs3.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
5630
+ const eslintrcPath = path3.resolve(rootDir, ".eslintrc.cjs");
5631
+ fs3.writeFileSync(eslintrcPath, configuration);
5632
+ }
5633
+
5634
+ // utils/banner.ts
5635
+ var banner = "\x1B[38;2;66;211;146mV\x1B[39m\x1B[38;2;66;211;146mu\x1B[39m\x1B[38;2;66;211;146me\x1B[39m\x1B[38;2;66;211;146m.\x1B[39m\x1B[38;2;66;211;146mj\x1B[39m\x1B[38;2;67;209;149ms\x1B[39m \x1B[38;2;68;206;152m-\x1B[39m \x1B[38;2;69;204;155mT\x1B[39m\x1B[38;2;70;201;158mh\x1B[39m\x1B[38;2;71;199;162me\x1B[39m \x1B[38;2;72;196;165mP\x1B[39m\x1B[38;2;73;194;168mr\x1B[39m\x1B[38;2;74;192;171mo\x1B[39m\x1B[38;2;75;189;174mg\x1B[39m\x1B[38;2;76;187;177mr\x1B[39m\x1B[38;2;77;184;180me\x1B[39m\x1B[38;2;78;182;183ms\x1B[39m\x1B[38;2;79;179;186ms\x1B[39m\x1B[38;2;80;177;190mi\x1B[39m\x1B[38;2;81;175;193mv\x1B[39m\x1B[38;2;82;172;196me\x1B[39m \x1B[38;2;83;170;199mJ\x1B[39m\x1B[38;2;83;167;202ma\x1B[39m\x1B[38;2;84;165;205mv\x1B[39m\x1B[38;2;85;162;208ma\x1B[39m\x1B[38;2;86;160;211mS\x1B[39m\x1B[38;2;87;158;215mc\x1B[39m\x1B[38;2;88;155;218mr\x1B[39m\x1B[38;2;89;153;221mi\x1B[39m\x1B[38;2;90;150;224mp\x1B[39m\x1B[38;2;91;148;227mt\x1B[39m \x1B[38;2;92;145;230mF\x1B[39m\x1B[38;2;93;143;233mr\x1B[39m\x1B[38;2;94;141;236ma\x1B[39m\x1B[38;2;95;138;239mm\x1B[39m\x1B[38;2;96;136;243me\x1B[39m\x1B[38;2;97;133;246mw\x1B[39m\x1B[38;2;98;131;249mo\x1B[39m\x1B[38;2;99;128;252mr\x1B[39m\x1B[38;2;100;126;255mk\x1B[39m";
5636
+ var banner_default = banner;
5637
+
5638
+ // index.ts
5508
5639
  function isValidPackageName(projectName) {
5509
5640
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
5510
5641
  }
@@ -5512,22 +5643,28 @@ function toValidPackageName(projectName) {
5512
5643
  return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
5513
5644
  }
5514
5645
  function canSafelyOverwrite(dir) {
5515
- return !import_fs3.default.existsSync(dir) || import_fs3.default.readdirSync(dir).length === 0;
5646
+ return !fs4.existsSync(dir) || fs4.readdirSync(dir).length === 0;
5516
5647
  }
5517
5648
  function emptyDir(dir) {
5518
- postOrderDirectoryTraverse(dir, (dir2) => import_fs3.default.rmdirSync(dir2), (file) => import_fs3.default.unlinkSync(file));
5649
+ if (!fs4.existsSync(dir)) {
5650
+ return;
5651
+ }
5652
+ postOrderDirectoryTraverse(dir, (dir2) => fs4.rmdirSync(dir2), (file) => fs4.unlinkSync(file));
5519
5653
  }
5520
5654
  async function init() {
5655
+ console.log(`
5656
+ ${banner_default}
5657
+ `);
5521
5658
  const cwd = process.cwd();
5522
5659
  const argv = (0, import_minimist.default)(process.argv.slice(2), {
5523
5660
  alias: {
5524
5661
  typescript: ["ts"],
5525
- "with-tests": ["tests", "cypress"],
5662
+ "with-tests": ["tests"],
5526
5663
  router: ["vue-router"]
5527
5664
  },
5528
5665
  boolean: true
5529
5666
  });
5530
- const isFeatureFlagsUsed = typeof (argv.default || argv.ts || argv.router || argv.pinia || argv.tests) === "boolean";
5667
+ const isFeatureFlagsUsed = typeof (argv.default ?? argv.ts ?? argv.jsx ?? argv.router ?? argv.pinia ?? argv.tests ?? argv.vitest ?? argv.cypress ?? argv.eslint) === "boolean";
5531
5668
  let targetDir = argv._[0];
5532
5669
  const defaultProjectName = !targetDir ? "vue-project" : targetDir;
5533
5670
  const forceOverwrite = argv.force;
@@ -5551,7 +5688,7 @@ async function init() {
5551
5688
  },
5552
5689
  {
5553
5690
  name: "overwriteChecker",
5554
- type: (prev, values = {}) => {
5691
+ type: (prev, values) => {
5555
5692
  if (values.shouldOverwrite === false) {
5556
5693
  throw new Error(red("\u2716") + " Operation cancelled");
5557
5694
  }
@@ -5573,6 +5710,14 @@ async function init() {
5573
5710
  active: "Yes",
5574
5711
  inactive: "No"
5575
5712
  },
5713
+ {
5714
+ name: "needsJsx",
5715
+ type: () => isFeatureFlagsUsed ? null : "toggle",
5716
+ message: "Add JSX Support?",
5717
+ initial: false,
5718
+ active: "Yes",
5719
+ inactive: "No"
5720
+ },
5576
5721
  {
5577
5722
  name: "needsRouter",
5578
5723
  type: () => isFeatureFlagsUsed ? null : "toggle",
@@ -5590,9 +5735,38 @@ async function init() {
5590
5735
  inactive: "No"
5591
5736
  },
5592
5737
  {
5593
- name: "needsTests",
5738
+ name: "needsVitest",
5594
5739
  type: () => isFeatureFlagsUsed ? null : "toggle",
5595
- message: "Add Cypress for testing?",
5740
+ message: "Add Vitest for Unit Testing?",
5741
+ initial: false,
5742
+ active: "Yes",
5743
+ inactive: "No"
5744
+ },
5745
+ {
5746
+ name: "needsCypress",
5747
+ type: () => isFeatureFlagsUsed ? null : "toggle",
5748
+ message: (prev, answers) => answers.needsVitest ? "Add Cypress for End-to-End testing?" : "Add Cypress for both Unit and End-to-End testing?",
5749
+ initial: false,
5750
+ active: "Yes",
5751
+ inactive: "No"
5752
+ },
5753
+ {
5754
+ name: "needsEslint",
5755
+ type: () => isFeatureFlagsUsed ? null : "toggle",
5756
+ message: "Add ESLint for code quality?",
5757
+ initial: false,
5758
+ active: "Yes",
5759
+ inactive: "No"
5760
+ },
5761
+ {
5762
+ name: "needsPrettier",
5763
+ type: (prev, values) => {
5764
+ if (isFeatureFlagsUsed || !values.needsEslint) {
5765
+ return null;
5766
+ }
5767
+ return "toggle";
5768
+ },
5769
+ message: "Add Prettier for code formatting?",
5596
5770
  initial: false,
5597
5771
  active: "Yes",
5598
5772
  inactive: "No"
@@ -5607,40 +5781,68 @@ async function init() {
5607
5781
  process.exit(1);
5608
5782
  }
5609
5783
  const {
5610
- packageName = toValidPackageName(defaultProjectName),
5611
- shouldOverwrite,
5784
+ projectName,
5785
+ packageName = projectName ?? defaultProjectName,
5786
+ shouldOverwrite = argv.force,
5787
+ needsJsx = argv.jsx,
5612
5788
  needsTypeScript = argv.typescript,
5613
5789
  needsRouter = argv.router,
5614
5790
  needsPinia = argv.pinia,
5615
- needsTests = argv.tests
5791
+ needsCypress = argv.cypress || argv.tests,
5792
+ needsVitest = argv.vitest || argv.tests,
5793
+ needsEslint = argv.eslint || argv["eslint-with-prettier"],
5794
+ needsPrettier = argv["eslint-with-prettier"]
5616
5795
  } = result;
5617
- const root = import_path3.default.join(cwd, targetDir);
5618
- if (shouldOverwrite) {
5796
+ const needsCypressCT = needsCypress && !needsVitest;
5797
+ const root = path4.join(cwd, targetDir);
5798
+ if (fs4.existsSync(root) && shouldOverwrite) {
5619
5799
  emptyDir(root);
5620
- } else if (!import_fs3.default.existsSync(root)) {
5621
- import_fs3.default.mkdirSync(root);
5800
+ } else if (!fs4.existsSync(root)) {
5801
+ fs4.mkdirSync(root);
5622
5802
  }
5623
5803
  console.log(`
5624
5804
  Scaffolding project in ${root}...`);
5625
5805
  const pkg = { name: packageName, version: "0.0.0" };
5626
- import_fs3.default.writeFileSync(import_path3.default.resolve(root, "package.json"), JSON.stringify(pkg, null, 2));
5627
- const templateRoot = import_path3.default.resolve(__dirname, "template");
5806
+ fs4.writeFileSync(path4.resolve(root, "package.json"), JSON.stringify(pkg, null, 2));
5807
+ const templateRoot = path4.resolve(__dirname, "template");
5628
5808
  const render = function render2(templateName) {
5629
- const templateDir = import_path3.default.resolve(templateRoot, templateName);
5809
+ const templateDir = path4.resolve(templateRoot, templateName);
5630
5810
  renderTemplate_default(templateDir, root);
5631
5811
  };
5632
5812
  render("base");
5813
+ if (needsJsx) {
5814
+ render("config/jsx");
5815
+ }
5633
5816
  if (needsRouter) {
5634
5817
  render("config/router");
5635
5818
  }
5636
5819
  if (needsPinia) {
5637
5820
  render("config/pinia");
5638
5821
  }
5639
- if (needsTests) {
5822
+ if (needsVitest) {
5823
+ render("config/vitest");
5824
+ }
5825
+ if (needsCypress) {
5640
5826
  render("config/cypress");
5641
5827
  }
5828
+ if (needsCypressCT) {
5829
+ render("config/cypress-ct");
5830
+ }
5642
5831
  if (needsTypeScript) {
5643
5832
  render("config/typescript");
5833
+ render("tsconfig/base");
5834
+ if (needsCypress) {
5835
+ render("tsconfig/cypress");
5836
+ }
5837
+ if (needsCypressCT) {
5838
+ render("tsconfig/cypress-ct");
5839
+ }
5840
+ if (needsVitest) {
5841
+ render("tsconfig/vitest");
5842
+ }
5843
+ }
5844
+ if (needsEslint) {
5845
+ renderEslint(root, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier });
5644
5846
  }
5645
5847
  const codeTemplate = (needsTypeScript ? "typescript-" : "") + (needsRouter ? "router" : "default");
5646
5848
  render(`code/${codeTemplate}`);
@@ -5657,39 +5859,48 @@ Scaffolding project in ${root}...`);
5657
5859
  preOrderDirectoryTraverse(root, () => {
5658
5860
  }, (filepath) => {
5659
5861
  if (filepath.endsWith(".js")) {
5660
- import_fs3.default.renameSync(filepath, filepath.replace(/\.js$/, ".ts"));
5661
- } else if (import_path3.default.basename(filepath) === "jsconfig.json") {
5662
- import_fs3.default.renameSync(filepath, filepath.replace(/jsconfig\.json$/, "tsconfig.json"));
5862
+ const tsFilePath = filepath.replace(/\.js$/, ".ts");
5863
+ if (fs4.existsSync(tsFilePath)) {
5864
+ fs4.unlinkSync(filepath);
5865
+ } else {
5866
+ fs4.renameSync(filepath, tsFilePath);
5867
+ }
5868
+ } else if (path4.basename(filepath) === "jsconfig.json") {
5869
+ fs4.unlinkSync(filepath);
5663
5870
  }
5664
5871
  });
5665
- const indexHtmlPath = import_path3.default.resolve(root, "index.html");
5666
- const indexHtmlContent = import_fs3.default.readFileSync(indexHtmlPath, "utf8");
5667
- import_fs3.default.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
5668
- }
5669
- if (!needsTests) {
5670
- preOrderDirectoryTraverse(root, (dirpath) => {
5671
- const dirname = import_path3.default.basename(dirpath);
5672
- if (dirname === "cypress" || dirname === "__tests__") {
5673
- emptyDir(dirpath);
5674
- import_fs3.default.rmdirSync(dirpath);
5675
- }
5676
- }, () => {
5872
+ const indexHtmlPath = path4.resolve(root, "index.html");
5873
+ const indexHtmlContent = fs4.readFileSync(indexHtmlPath, "utf8");
5874
+ fs4.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
5875
+ } else {
5876
+ preOrderDirectoryTraverse(root, () => {
5877
+ }, (filepath) => {
5878
+ if (filepath.endsWith(".ts")) {
5879
+ fs4.unlinkSync(filepath);
5880
+ }
5677
5881
  });
5678
5882
  }
5679
- const packageManager = /pnpm/.test(process.env.npm_execpath) ? "pnpm" : /yarn/.test(process.env.npm_execpath) ? "yarn" : "npm";
5680
- import_fs3.default.writeFileSync(import_path3.default.resolve(root, "README.md"), generateReadme({
5681
- projectName: result.projectName || defaultProjectName,
5883
+ const userAgent = process.env.npm_config_user_agent ?? "";
5884
+ const packageManager = /pnpm/.test(userAgent) ? "pnpm" : /yarn/.test(userAgent) ? "yarn" : "npm";
5885
+ fs4.writeFileSync(path4.resolve(root, "README.md"), generateReadme({
5886
+ projectName: result.projectName ?? defaultProjectName,
5682
5887
  packageManager,
5683
5888
  needsTypeScript,
5684
- needsTests
5889
+ needsVitest,
5890
+ needsCypress,
5891
+ needsCypressCT,
5892
+ needsEslint
5685
5893
  }));
5686
5894
  console.log(`
5687
5895
  Done. Now run:
5688
5896
  `);
5689
5897
  if (root !== cwd) {
5690
- console.log(` ${bold(green(`cd ${import_path3.default.relative(cwd, root)}`))}`);
5898
+ console.log(` ${bold(green(`cd ${path4.relative(cwd, root)}`))}`);
5691
5899
  }
5692
5900
  console.log(` ${bold(green(getCommand(packageManager, "install")))}`);
5901
+ if (needsPrettier) {
5902
+ console.log(` ${bold(green(getCommand(packageManager, "lint")))}`);
5903
+ }
5693
5904
  console.log(` ${bold(green(getCommand(packageManager, "dev")))}`);
5694
5905
  console.log();
5695
5906
  }