virmator 3.0.5 → 4.0.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 (175) hide show
  1. package/README.md +1 -14
  2. package/base-configs/base-cspell.js +83 -0
  3. package/base-configs/base-mocharc.js +14 -0
  4. package/{configs/.virmator/prettierrc-base.js → base-configs/base-prettierrc.js} +0 -0
  5. package/{configs/.virmator/tsconfig-base.json → base-configs/base-tsconfig.json} +0 -6
  6. package/{configs/.virmator/vite-base.ts → base-configs/base-vite.ts} +0 -0
  7. package/base-configs/test-files-glob.js +5 -0
  8. package/{configs/.virmator → base-configs}/vite-always-reload-plugin.ts +5 -3
  9. package/{configs/.virmator → base-configs}/web-test-runner-base.mjs +4 -5
  10. package/configs/.gitattributes +1 -0
  11. package/configs/.nvmrc +1 -0
  12. package/configs/.prettierignore +1 -1
  13. package/configs/.prettierrc.js +1 -1
  14. package/configs/{.mocharc.js → configs/.mocharc.js} +1 -1
  15. package/configs/{.virmator → configs}/vite.config.ts +1 -1
  16. package/configs/{.virmator → configs}/web-test-runner.config.mjs +1 -1
  17. package/configs/cspell.config.js +9 -0
  18. package/configs/gitignore.txt +1 -0
  19. package/configs/npmignore.txt +1 -0
  20. package/configs/package.json +9 -5
  21. package/configs/tsconfig.json +1 -1
  22. package/cspell.config.js +11 -0
  23. package/dist/{cli → api}/cli-color.d.ts +1 -0
  24. package/dist/{cli → api}/cli-color.js +1 -0
  25. package/dist/api/command/command-configs.d.ts +3 -0
  26. package/dist/api/command/command-configs.js +11 -0
  27. package/dist/api/command/command-description.d.ts +8 -0
  28. package/dist/{cli/cli-command/cli-command-help.js → api/command/command-description.js} +0 -0
  29. package/dist/api/command/command-executor.d.ts +28 -0
  30. package/dist/api/command/command-executor.js +7 -0
  31. package/dist/api/command/command-help.d.ts +8 -0
  32. package/dist/{package-name.js → api/command/command-help.js} +0 -2
  33. package/dist/api/command/command-logging.d.ts +11 -0
  34. package/dist/api/command/command-logging.js +17 -0
  35. package/dist/api/command/command-mapping.d.ts +7 -0
  36. package/dist/api/command/command-mapping.js +10 -0
  37. package/dist/api/command/command-messages.d.ts +1 -0
  38. package/dist/api/command/command-messages.js +10 -0
  39. package/dist/api/command/command-to-help-message.d.ts +9 -0
  40. package/dist/{cli/cli-command/cli-command-to-help-message.js → api/command/command-to-help-message.js} +41 -48
  41. package/dist/api/command/define-command-inputs.d.ts +14 -0
  42. package/dist/api/command/define-command-inputs.js +2 -0
  43. package/dist/api/command/define-command.d.ts +8 -0
  44. package/dist/api/command/define-command.js +25 -0
  45. package/dist/api/config/config-file-definition.d.ts +16 -0
  46. package/dist/api/config/config-file-definition.js +2 -0
  47. package/dist/api/config/config-paths.d.ts +7 -0
  48. package/dist/api/config/config-paths.js +8 -0
  49. package/dist/{cli → api}/config/copy-config.d.ts +5 -4
  50. package/dist/{cli → api}/config/copy-config.js +26 -28
  51. package/dist/api/create-virmator.d.ts +8 -0
  52. package/dist/api/create-virmator.js +65 -0
  53. package/dist/api/run-command/check-npm-deps.d.ts +7 -0
  54. package/dist/api/run-command/check-npm-deps.js +107 -0
  55. package/dist/api/run-command/extract-arguments.d.ts +6 -0
  56. package/dist/api/run-command/extract-arguments.js +37 -0
  57. package/dist/api/run-command/run-command-executor.d.ts +5 -0
  58. package/dist/api/run-command/run-command-executor.js +51 -0
  59. package/dist/api/run-command/run-extended-virmator.d.ts +10 -0
  60. package/dist/api/run-command/run-extended-virmator.js +53 -0
  61. package/dist/{cli/cli-command → api/run-command}/run-shell-command.d.ts +3 -3
  62. package/dist/{cli/cli-command → api/run-command}/run-shell-command.js +3 -3
  63. package/dist/api/virmator-types.d.ts +18 -0
  64. package/dist/api/virmator-types.js +2 -0
  65. package/dist/augments/fs.d.ts +5 -2
  66. package/dist/augments/fs.js +20 -8
  67. package/dist/augments/object.d.ts +3 -0
  68. package/dist/augments/object.js +33 -2
  69. package/dist/augments/path.d.ts +1 -0
  70. package/dist/augments/path.js +14 -0
  71. package/dist/augments/prettier.d.ts +1 -0
  72. package/dist/augments/prettier.js +47 -0
  73. package/dist/augments/string.d.ts +2 -0
  74. package/dist/augments/string.js +10 -0
  75. package/dist/augments/test.d.ts +2 -1
  76. package/dist/augments/test.js +7 -3
  77. package/dist/cli.d.ts +2 -0
  78. package/dist/cli.js +5 -0
  79. package/dist/{cli/cli-command-implementations → commands}/code-in-markdown.command.d.ts +3 -1
  80. package/dist/{cli/cli-command-implementations → commands}/code-in-markdown.command.js +23 -24
  81. package/dist/commands/compile.command.d.ts +14 -0
  82. package/dist/commands/compile.command.js +54 -0
  83. package/dist/commands/extra-configs/all-extra-configs.d.ts +2 -0
  84. package/dist/commands/extra-configs/all-extra-configs.js +44 -0
  85. package/dist/commands/extra-configs/combine-json-config.d.ts +2 -0
  86. package/dist/commands/extra-configs/combine-json-config.js +22 -0
  87. package/dist/commands/extra-configs/combine-text-config.d.ts +2 -0
  88. package/dist/{cli/config → commands/extra-configs}/combine-text-config.js +5 -5
  89. package/dist/{cli/config → commands/extra-configs}/create-default-package-json.d.ts +0 -0
  90. package/dist/{cli/config → commands/extra-configs}/create-default-package-json.js +30 -18
  91. package/dist/commands/format.command.d.ts +19 -0
  92. package/dist/{cli/cli-command-implementations → commands}/format.command.js +59 -33
  93. package/dist/commands/frontend.command.d.ts +15 -0
  94. package/dist/commands/frontend.command.js +78 -0
  95. package/dist/commands/init.command.d.ts +8 -0
  96. package/dist/commands/init.command.js +53 -0
  97. package/dist/commands/spellcheck.command.d.ts +12 -0
  98. package/dist/commands/spellcheck.command.js +54 -0
  99. package/dist/commands/test-web.command.d.ts +12 -0
  100. package/dist/commands/test-web.command.js +68 -0
  101. package/dist/commands/test.command.d.ts +12 -0
  102. package/dist/commands/test.command.js +67 -0
  103. package/dist/{cli/cli-command-implementations → commands}/update-configs.command.d.ts +3 -1
  104. package/dist/{cli/cli-command-implementations → commands}/update-configs.command.js +14 -10
  105. package/dist/file-paths/{virmator-package-paths.d.ts → package-paths.d.ts} +1 -1
  106. package/dist/file-paths/{virmator-package-paths.js → package-paths.js} +3 -4
  107. package/dist/index.d.ts +134 -1
  108. package/dist/index.js +55 -0
  109. package/dist/scripts/save-help-message.d.ts +1 -0
  110. package/dist/scripts/save-help-message.js +33 -0
  111. package/package.json +33 -28
  112. package/.gitattributes +0 -1
  113. package/.github/workflows/virmator-build-for-gh-pages.yml +0 -24
  114. package/.github/workflows/virmator-tagged-release.yml +0 -42
  115. package/.github/workflows/virmator-tests.yml +0 -26
  116. package/.mocharc.js +0 -9
  117. package/.prettierignore +0 -5
  118. package/configs/.cspell.json +0 -4
  119. package/configs/.virmator/.cspell-base.json +0 -81
  120. package/configs/.virmator/mocharc-base.js +0 -15
  121. package/configs/src/global.d.ts +0 -5
  122. package/dist/api/virmator-wrapper.d.ts +0 -5
  123. package/dist/api/virmator-wrapper.js +0 -9
  124. package/dist/cli/all-cli-command-definitions.d.ts +0 -56
  125. package/dist/cli/all-cli-command-definitions.js +0 -76
  126. package/dist/cli/cli-command/cli-command-help.d.ts +0 -8
  127. package/dist/cli/cli-command/cli-command-to-help-message.d.ts +0 -11
  128. package/dist/cli/cli-command/define-cli-command.d.ts +0 -41
  129. package/dist/cli/cli-command/define-cli-command.js +0 -29
  130. package/dist/cli/cli-command-implementations/compile.command.d.ts +0 -6
  131. package/dist/cli/cli-command-implementations/compile.command.js +0 -44
  132. package/dist/cli/cli-command-implementations/format.command.d.ts +0 -6
  133. package/dist/cli/cli-command-implementations/frontend.command.d.ts +0 -7
  134. package/dist/cli/cli-command-implementations/frontend.command.js +0 -45
  135. package/dist/cli/cli-command-implementations/init.command.d.ts +0 -6
  136. package/dist/cli/cli-command-implementations/init.command.js +0 -42
  137. package/dist/cli/cli-command-implementations/spellcheck.command.d.ts +0 -4
  138. package/dist/cli/cli-command-implementations/spellcheck.command.js +0 -40
  139. package/dist/cli/cli-command-implementations/test-web.command.d.ts +0 -4
  140. package/dist/cli/cli-command-implementations/test-web.command.js +0 -50
  141. package/dist/cli/cli-command-implementations/test.command.d.ts +0 -4
  142. package/dist/cli/cli-command-implementations/test.command.js +0 -53
  143. package/dist/cli/cli-flags/cli-flag-name.d.ts +0 -4
  144. package/dist/cli/cli-flags/cli-flag-name.js +0 -8
  145. package/dist/cli/cli-flags/cli-flag-values.d.ts +0 -4
  146. package/dist/cli/cli-flags/cli-flag-values.js +0 -19
  147. package/dist/cli/cli-messages.d.ts +0 -6
  148. package/dist/cli/cli-messages.js +0 -19
  149. package/dist/cli/cli.d.ts +0 -2
  150. package/dist/cli/cli.js +0 -54
  151. package/dist/cli/config/combine-text-config.d.ts +0 -2
  152. package/dist/cli/config/config-files.d.ts +0 -133
  153. package/dist/cli/config/config-files.js +0 -138
  154. package/dist/cli/is-global.d.ts +0 -1
  155. package/dist/cli/is-global.js +0 -10
  156. package/dist/cli/parse-arguments.d.ts +0 -8
  157. package/dist/cli/parse-arguments.js +0 -42
  158. package/dist/cli/run-cli-command.d.ts +0 -13
  159. package/dist/cli/run-cli-command.js +0 -52
  160. package/dist/cli/run-command.test-helper.d.ts +0 -28
  161. package/dist/cli/run-command.test-helper.js +0 -87
  162. package/dist/errors/virmator-cli.error.d.ts +0 -3
  163. package/dist/errors/virmator-cli.error.js +0 -10
  164. package/dist/errors/virmator-config-file.error.d.ts +0 -4
  165. package/dist/errors/virmator-config-file.error.js +0 -11
  166. package/dist/errors/virmator-invalid-command.error.d.ts +0 -5
  167. package/dist/errors/virmator-invalid-command.error.js +0 -11
  168. package/dist/errors/virmator-invalid-flags.error.d.ts +0 -5
  169. package/dist/errors/virmator-invalid-flags.error.js +0 -13
  170. package/dist/file-paths/repo-paths.d.ts +0 -2
  171. package/dist/file-paths/repo-paths.js +0 -6
  172. package/dist/file-paths/virmator-test-file-paths.d.ts +0 -44
  173. package/dist/logging.d.ts +0 -10
  174. package/dist/logging.js +0 -9
  175. package/dist/package-name.d.ts +0 -1
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combineJsonConfig = void 0;
4
+ const augment_vir_1 = require("augment-vir");
5
+ const object_1 = require("../../augments/object");
6
+ const prettier_1 = require("../../augments/prettier");
7
+ async function combineJsonConfig(...[newConfigContents, existingConfigContents,]) {
8
+ let oldJson;
9
+ try {
10
+ oldJson = JSON.parse(existingConfigContents);
11
+ }
12
+ catch (error) { }
13
+ const newJson = JSON.parse(newConfigContents);
14
+ if (!oldJson || !(0, augment_vir_1.isObject)(oldJson)) {
15
+ return stringify(newJson);
16
+ }
17
+ return stringify((0, object_1.deeplyCombineObjects)(oldJson, newJson));
18
+ }
19
+ exports.combineJsonConfig = combineJsonConfig;
20
+ async function stringify(input) {
21
+ return await (0, prettier_1.formatCode)(JSON.stringify(input, null, 4), 'a.json');
22
+ }
@@ -0,0 +1,2 @@
1
+ import { UpdateConfigCallback } from '../../api/config/config-file-definition';
2
+ export declare function combineTextConfig(...[newConfigContents, existingConfigContents,]: Parameters<UpdateConfigCallback>): ReturnType<UpdateConfigCallback>;
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.combineTextConfig = void 0;
4
4
  const augment_vir_1 = require("augment-vir");
5
- function formatContents(input) {
5
+ function splitContentsIntoArrayOfLines(input) {
6
6
  return input
7
7
  .split('\n')
8
8
  .map((line) => line.trim())
9
9
  .filter(augment_vir_1.isTruthy)
10
10
  .sort();
11
11
  }
12
- const combineTextConfig = (newConfigContents, existingConfigContents) => {
13
- const sortedNew = formatContents(newConfigContents);
14
- const sortedExisting = formatContents(existingConfigContents);
12
+ function combineTextConfig(...[newConfigContents, existingConfigContents,]) {
13
+ const sortedNew = splitContentsIntoArrayOfLines(newConfigContents);
14
+ const sortedExisting = splitContentsIntoArrayOfLines(existingConfigContents);
15
15
  let existingLinesAppended = false;
16
16
  sortedExisting.forEach((existingLine) => {
17
17
  if (!sortedNew.includes(existingLine) && !sortedNew.includes(`${existingLine}/`)) {
@@ -23,5 +23,5 @@ const combineTextConfig = (newConfigContents, existingConfigContents) => {
23
23
  }
24
24
  });
25
25
  return sortedNew.join('\n');
26
- };
26
+ }
27
27
  exports.combineTextConfig = combineTextConfig;
@@ -8,6 +8,7 @@ const augment_vir_1 = require("augment-vir");
8
8
  const path_1 = require("path");
9
9
  const simple_git_1 = __importDefault(require("simple-git"));
10
10
  const json_1 = require("../../augments/json");
11
+ const prettier_1 = require("../../augments/prettier");
11
12
  async function createDefaultPackageJson(copyFromContents, existingConfigContents, repoDir) {
12
13
  var _a;
13
14
  const baseVirmatorPackageJson = JSON.parse(copyFromContents);
@@ -27,7 +28,7 @@ async function createDefaultPackageJson(copyFromContents, existingConfigContents
27
28
  ...gitProperties,
28
29
  scripts: combinedScripts,
29
30
  };
30
- return await JSON.stringify(newPackageJson);
31
+ return await (0, prettier_1.formatCode)(JSON.stringify(newPackageJson), 'package.json');
31
32
  }
32
33
  exports.createDefaultPackageJson = createDefaultPackageJson;
33
34
  function combineScripts(virmatorPackageJson, currentRepoPackageJson) {
@@ -35,10 +36,13 @@ function combineScripts(virmatorPackageJson, currentRepoPackageJson) {
35
36
  ...currentRepoPackageJson.scripts,
36
37
  };
37
38
  (0, augment_vir_1.getObjectTypedKeys)(virmatorPackageJson.scripts).forEach((key) => {
38
- const virmatorValue = virmatorPackageJson[key];
39
- const currentRepoValue = currentRepoPackageJson[key];
40
- if (!scripts.hasOwnProperty(key) ||
41
- (key === 'test' && currentRepoValue === `echo \"Error: no test specified\" && exit 1`)) {
39
+ const virmatorValue = virmatorPackageJson.scripts[key];
40
+ const currentRepoValue = scripts[key];
41
+ if (virmatorValue &&
42
+ (!scripts.hasOwnProperty(key) ||
43
+ (key === 'test' &&
44
+ currentRepoValue &&
45
+ currentRepoValue.includes('Error: no test specified')))) {
42
46
  scripts[key] = virmatorValue;
43
47
  }
44
48
  });
@@ -48,29 +52,37 @@ async function getGitProperties(repoDir) {
48
52
  const git = (0, simple_git_1.default)(repoDir);
49
53
  const remotes = await git.getRemotes(true);
50
54
  const originRemote = remotes.find((remote) => remote.name === 'origin') || remotes[0];
51
- if (originRemote && originRemote.refs.fetch.includes('github.com')) {
52
- return createGitHubUrls(originRemote.refs.fetch);
55
+ if (originRemote) {
56
+ return createGitUrls(originRemote.refs.fetch);
53
57
  }
54
58
  else {
55
59
  return {};
56
60
  }
57
61
  }
58
- function createGitHubUrls(ref) {
59
- const repoPath = ref.replace(/^.*github.com:/, '').replace(/\.git$/, '');
60
- const gitHubUrl = `https://github.com/${repoPath}`;
61
- const user = repoPath.replace(/\/[^\/]+$/, '');
62
+ function createGitUrls(ref) {
63
+ const repoPath = ref
64
+ .replace(/(\w):(\w)/g, '$1/$2')
65
+ .replace(/\.git$/, '')
66
+ .replace(/^git@/g, 'https://');
67
+ const isGitHub = repoPath.includes('github.com');
68
+ const issuesUrl = isGitHub ? `${repoPath}/issues` : '';
69
+ const username = repoPath.replace(/^.+\.com\//, '').replace(/\/.+$/, '');
70
+ const bugsObject = issuesUrl ? { bugs: { url: issuesUrl } } : {};
71
+ const userUrlObject = isGitHub
72
+ ? {
73
+ url: `https://github.com/${username}`,
74
+ }
75
+ : {};
62
76
  return {
63
- homepage: gitHubUrl,
64
- bugs: {
65
- url: `${gitHubUrl}/issues`,
66
- },
77
+ homepage: repoPath,
78
+ ...bugsObject,
67
79
  repository: {
68
80
  type: 'git',
69
- url: gitHubUrl,
81
+ url: repoPath,
70
82
  },
71
83
  author: {
72
- name: user,
73
- url: `https://github.com/${user}`,
84
+ name: username,
85
+ ...userUrlObject,
74
86
  },
75
87
  };
76
88
  }
@@ -0,0 +1,19 @@
1
+ export declare const formatCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "format";
3
+ subCommandDescriptions: {
4
+ readonly check: "check formatting without overwriting files.";
5
+ };
6
+ configFiles: {
7
+ readonly prettierrc: {
8
+ readonly copyFromInternalPath: string;
9
+ readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
10
+ readonly required: true;
11
+ };
12
+ readonly prettierIgnore: {
13
+ readonly copyFromInternalPath: string;
14
+ readonly copyToPathRelativeToRepoDir: ".prettierignore";
15
+ readonly required: true;
16
+ };
17
+ };
18
+ npmDeps: readonly ["prettier", "prettier-plugin-jsdoc", "prettier-plugin-multiline-arrays", "prettier-plugin-organize-imports", "prettier-plugin-packagejson", "prettier-plugin-sort-json", "prettier-plugin-toml"];
19
+ }>;
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatCommandDefinition = void 0;
4
- const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
5
- const package_name_1 = require("../../package-name");
6
- const define_cli_command_1 = require("../cli-command/define-cli-command");
7
- const run_shell_command_1 = require("../cli-command/run-shell-command");
4
+ const path_1 = require("path");
5
+ const define_command_1 = require("../api/command/define-command");
6
+ const package_paths_1 = require("../file-paths/package-paths");
8
7
  const defaultFormatExtensions = [
8
+ 'cjs',
9
9
  'css',
10
+ 'graphql',
10
11
  'html',
11
12
  'js',
12
13
  'json',
13
14
  'jsx',
15
+ 'less',
14
16
  'md',
17
+ 'mjs',
18
+ 'scss',
15
19
  'toml',
16
20
  'ts',
17
21
  'tsx',
@@ -19,12 +23,33 @@ const defaultFormatExtensions = [
19
23
  'yml',
20
24
  ];
21
25
  const filesMarkerArg = '--file-types';
22
- exports.formatCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
26
+ exports.formatCommandDefinition = (0, define_command_1.defineCommand)({
23
27
  commandName: 'format',
24
28
  subCommandDescriptions: {
25
29
  check: 'check formatting without overwriting files.',
26
30
  },
27
- }, ({ commandName, subCommands }) => {
31
+ configFiles: {
32
+ prettierrc: {
33
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.prettierrc.js'),
34
+ copyToPathRelativeToRepoDir: '.prettierrc.js',
35
+ required: true,
36
+ },
37
+ prettierIgnore: {
38
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.prettierignore'),
39
+ copyToPathRelativeToRepoDir: '.prettierignore',
40
+ required: true,
41
+ },
42
+ },
43
+ npmDeps: [
44
+ 'prettier',
45
+ 'prettier-plugin-jsdoc',
46
+ 'prettier-plugin-multiline-arrays',
47
+ 'prettier-plugin-organize-imports',
48
+ 'prettier-plugin-packagejson',
49
+ 'prettier-plugin-sort-json',
50
+ 'prettier-plugin-toml',
51
+ ],
52
+ }, ({ commandName, subCommands, packageBinName }) => {
28
53
  return {
29
54
  sections: [
30
55
  {
@@ -33,7 +58,7 @@ exports.formatCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
33
58
  },
34
59
  {
35
60
  title: 'file extensions',
36
- content: `If only specific file extensions should be formatted, add the "${filesMarkerArg}" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will format files only if they have the extension ".md" or ".json": ${package_name_1.packageName} ${commandName} ${filesMarkerArg} md json`,
61
+ content: `If only specific file extensions should be formatted, add the "${filesMarkerArg}" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will format files only if they have the extension ".md" or ".json": ${packageBinName} ${commandName} ${filesMarkerArg} md json`,
37
62
  },
38
63
  {
39
64
  title: 'Prettier flags',
@@ -43,30 +68,30 @@ exports.formatCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
43
68
  examples: [
44
69
  {
45
70
  title: 'checks formatting for files',
46
- content: `${package_name_1.packageName} ${commandName} ${subCommands.check}`,
71
+ content: `${packageBinName} ${commandName} ${subCommands.check}`,
47
72
  },
48
73
  {
49
74
  title: 'checks formatting only for .md files',
50
- content: `${package_name_1.packageName} ${commandName} ${subCommands.check} ${filesMarkerArg} md`,
75
+ content: `${packageBinName} ${commandName} ${subCommands.check} ${filesMarkerArg} md`,
51
76
  },
52
77
  {
53
78
  title: 'checks formatting only for .md and .json files',
54
- content: `${package_name_1.packageName} ${commandName} ${subCommands.check} ${filesMarkerArg} md json`,
79
+ content: `${packageBinName} ${commandName} ${subCommands.check} ${filesMarkerArg} md json`,
55
80
  },
56
81
  {
57
82
  title: 'fixes formatting for files',
58
- content: `${package_name_1.packageName} ${commandName}
59
- ${package_name_1.packageName} ${commandName}`,
83
+ content: `${packageBinName} ${commandName}
84
+ ${packageBinName} ${commandName}`,
60
85
  },
61
86
  {
62
87
  title: `examples with extra Prettier flags`,
63
- content: `${package_name_1.packageName} ${commandName} --ignore-path .prettierignore
64
- ${package_name_1.packageName} ${commandName} --ignore-path .prettierignore
65
- ${package_name_1.packageName} ${commandName} --ignore-path .prettierignore ${filesMarkerArg} md json`,
88
+ content: `${packageBinName} ${commandName} --ignore-path .prettierignore
89
+ ${packageBinName} ${commandName} --ignore-path .prettierignore
90
+ ${packageBinName} ${commandName} --ignore-path .prettierignore ${filesMarkerArg} md json`,
66
91
  },
67
92
  ],
68
93
  };
69
- }, async (inputs) => {
94
+ }, (inputs) => {
70
95
  const formatArgs = extractFormatArgs(inputs.filteredInputArgs);
71
96
  const shouldCheckOnly = inputs.inputSubCommands.includes(inputs.subCommands.check) ||
72
97
  formatArgs.prettierFlags.includes('--check');
@@ -75,24 +100,25 @@ exports.formatCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
75
100
  ? formatArgs.fileExtensions
76
101
  : defaultFormatExtensions;
77
102
  const fileExtensionsString = `\"./**/*.+(${fileExtensions.join('|')})\"`;
78
- const extraPrettierFlags = formatArgs.prettierFlags.length
79
- ? `${formatArgs.prettierFlags.join(' ')} `
80
- : '';
81
- const prettier = (0, virmator_package_paths_1.getNpmBinPath)('prettier');
82
- const formatCommand = `${prettier} --color ${extraPrettierFlags}${fileExtensionsString} ${operationString}`;
83
- const results = await (0, run_shell_command_1.runVirmatorShellCommand)(formatCommand, {
84
- ...inputs,
85
- logTransforms: {
86
- stdout: (stdout) => stdout
87
- // only relevant when running the check command
88
- .replace('Checking formatting...\n', '')
89
- // only relevant when running the check command
90
- .replace('All matched files use Prettier code style!\n', ''),
91
- },
92
- });
103
+ const listDifferentFlag = shouldCheckOnly ? '' : '--list-different';
104
+ const extraPrettierFlags = formatArgs.prettierFlags.length ? formatArgs.prettierFlags : '';
105
+ const logTransforms = {
106
+ stdout: (stdout) => stdout
107
+ // only relevant when running the check command
108
+ .replace('Checking formatting...\n', '')
109
+ // only relevant when running the check command
110
+ .replace('All matched files use Prettier code style!\n', ''),
111
+ };
93
112
  return {
94
- fullExecutedCommand: formatCommand,
95
- success: !results.exitCode,
113
+ mainCommand: (0, package_paths_1.getNpmBinPath)('prettier'),
114
+ args: [
115
+ '--color',
116
+ listDifferentFlag,
117
+ ...extraPrettierFlags,
118
+ fileExtensionsString,
119
+ operationString,
120
+ ],
121
+ logTransforms,
96
122
  };
97
123
  });
98
124
  function extractFormatArgs(args) {
@@ -0,0 +1,15 @@
1
+ export declare const frontendCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "frontend";
3
+ subCommandDescriptions: {
4
+ readonly build: "Builds and bundles the frontend for deployment.";
5
+ readonly preview: "Builds and previews the built output.";
6
+ };
7
+ configFiles: {
8
+ readonly vite: {
9
+ readonly copyFromInternalPath: string;
10
+ readonly copyToPathRelativeToRepoDir: string;
11
+ readonly required: true;
12
+ };
13
+ };
14
+ npmDeps: readonly ["vite", "ansi-colors"];
15
+ }>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.frontendCommandDefinition = void 0;
4
+ const path_1 = require("path");
5
+ const define_command_1 = require("../api/command/define-command");
6
+ const config_paths_1 = require("../api/config/config-paths");
7
+ const package_paths_1 = require("../file-paths/package-paths");
8
+ exports.frontendCommandDefinition = (0, define_command_1.defineCommand)({
9
+ commandName: 'frontend',
10
+ subCommandDescriptions: {
11
+ build: 'Builds and bundles the frontend for deployment.',
12
+ preview: 'Builds and previews the built output.',
13
+ },
14
+ configFiles: {
15
+ vite: {
16
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'configs', 'vite.config.ts'),
17
+ copyToPathRelativeToRepoDir: (0, path_1.join)('configs', 'vite.config.ts'),
18
+ required: true,
19
+ },
20
+ },
21
+ npmDeps: [
22
+ 'vite',
23
+ 'ansi-colors',
24
+ ],
25
+ }, () => {
26
+ return {
27
+ sections: [
28
+ {
29
+ title: '',
30
+ content: `Runs a frontend. Currently uses vite.`,
31
+ },
32
+ ],
33
+ examples: [],
34
+ };
35
+ }, (inputs) => {
36
+ const needToBuild = !!inputs.inputSubCommands.length;
37
+ const useDefaultConfigArgs = !inputs.filteredInputArgs.includes('--config');
38
+ const configString = useDefaultConfigArgs
39
+ ? `--config ${(0, config_paths_1.getCopyToPath)({
40
+ repoDir: inputs.repoDir,
41
+ configFileDefinition: inputs.configFiles.vite,
42
+ packageDir: package_paths_1.virmatorPackageDir,
43
+ })}`
44
+ : '';
45
+ const viteBinPath = (0, package_paths_1.getNpmBinPath)('vite');
46
+ const removeOutput = needToBuild ? 'rm -rf dist' : '';
47
+ const mainCommand = `${removeOutput}${viteBinPath}`;
48
+ const subCommandArgs = needToBuild
49
+ ? [
50
+ '--colors',
51
+ 'build',
52
+ configString,
53
+ ...inputs.filteredInputArgs,
54
+ '&&',
55
+ 'cp dist/index.html dist/404.html',
56
+ ]
57
+ : [];
58
+ const hostString = inputs.filteredInputArgs.includes('--host') ? '' : `--host`;
59
+ const previewCommandArgs = inputs.inputSubCommands.includes('preview')
60
+ ? [
61
+ '&&',
62
+ viteBinPath,
63
+ 'preview',
64
+ configString,
65
+ ...inputs.filteredInputArgs,
66
+ hostString,
67
+ ]
68
+ : [];
69
+ return {
70
+ mainCommand,
71
+ args: [
72
+ '--force',
73
+ configString,
74
+ ...subCommandArgs,
75
+ ...previewCommandArgs,
76
+ ],
77
+ };
78
+ });
@@ -0,0 +1,8 @@
1
+ export declare const initCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "init";
3
+ subCommandDescriptions: {
4
+ readonly force: "force overwrite files even if they already exist.";
5
+ };
6
+ configFiles: {};
7
+ npmDeps: readonly ["prettier", "prettier-plugin-jsdoc", "prettier-plugin-multiline-arrays", "prettier-plugin-organize-imports", "prettier-plugin-packagejson", "prettier-plugin-sort-json", "prettier-plugin-toml"];
8
+ }>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initCommandDefinition = void 0;
4
+ const command_logging_1 = require("../api/command/command-logging");
5
+ const define_command_1 = require("../api/command/define-command");
6
+ const copy_config_1 = require("../api/config/copy-config");
7
+ const all_extra_configs_1 = require("./extra-configs/all-extra-configs");
8
+ const format_command_1 = require("./format.command");
9
+ exports.initCommandDefinition = (0, define_command_1.defineCommand)({
10
+ commandName: 'init',
11
+ subCommandDescriptions: {
12
+ force: 'force overwrite files even if they already exist.',
13
+ },
14
+ configFiles: {},
15
+ npmDeps: [...format_command_1.formatCommandDefinition.npmDeps],
16
+ }, ({ commandName, subCommands, packageBinName }) => {
17
+ return {
18
+ sections: [
19
+ {
20
+ title: '',
21
+ content: `Initialize a repo with all virmator config files.`,
22
+ },
23
+ ],
24
+ examples: [
25
+ {
26
+ title: 'run init',
27
+ content: `${packageBinName} ${commandName}`,
28
+ },
29
+ {
30
+ title: 'run init and force all configs to be written',
31
+ content: `${packageBinName} ${commandName} ${subCommands.force}`,
32
+ },
33
+ ],
34
+ };
35
+ }, async (inputs) => {
36
+ const copyStyle = inputs.inputSubCommands.includes(inputs.subCommands.force)
37
+ ? copy_config_1.CopyConfigOperation.Overwrite
38
+ : copy_config_1.CopyConfigOperation.Init;
39
+ const allConfigs = [
40
+ ...all_extra_configs_1.nonCommandConfigs,
41
+ ...inputs.allConfigs,
42
+ ];
43
+ const success = await (0, copy_config_1.copyAllConfigFiles)({
44
+ configFiles: allConfigs,
45
+ logging: command_logging_1.defaultConsoleLogging,
46
+ operation: copyStyle,
47
+ repoDir: inputs.repoDir,
48
+ packageDir: inputs.packageDir,
49
+ });
50
+ return {
51
+ success,
52
+ };
53
+ });
@@ -0,0 +1,12 @@
1
+ export declare const spellcheckCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "spellcheck";
3
+ subCommandDescriptions: {};
4
+ configFiles: {
5
+ readonly cspell: {
6
+ readonly copyFromInternalPath: string;
7
+ readonly copyToPathRelativeToRepoDir: "cspell.config.js";
8
+ readonly required: true;
9
+ };
10
+ };
11
+ npmDeps: readonly ["cspell"];
12
+ }>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spellcheckCommandDefinition = void 0;
4
+ const path_1 = require("path");
5
+ const define_command_1 = require("../api/command/define-command");
6
+ const package_paths_1 = require("../file-paths/package-paths");
7
+ function spellcheckLogTransform(log) {
8
+ return log.replace(/\r/g, '\n').replace(/\n$/, '');
9
+ }
10
+ exports.spellcheckCommandDefinition = (0, define_command_1.defineCommand)({
11
+ commandName: 'spellcheck',
12
+ subCommandDescriptions: {},
13
+ configFiles: {
14
+ cspell: {
15
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'cspell.config.js'),
16
+ copyToPathRelativeToRepoDir: 'cspell.config.js',
17
+ required: true,
18
+ },
19
+ },
20
+ npmDeps: ['cspell'],
21
+ }, () => {
22
+ return {
23
+ sections: [
24
+ {
25
+ title: '',
26
+ content: `Spellcheck code with cspell. By default this spellchecks every file in the entire repo (except for those ignored in the config file), including .dot files. If any arguments are passed to this command, the default cspell args that this command applies are ignored, you'll have to supply them via your args.`,
27
+ },
28
+ ],
29
+ examples: [],
30
+ };
31
+ }, (inputs) => {
32
+ const containsNonFlagArgs = inputs.filteredInputArgs.some((arg) => !arg.startsWith('-'));
33
+ const fileArg = containsNonFlagArgs ? '' : '"**/*"';
34
+ const configArg = inputs.filteredInputArgs.includes('--config')
35
+ ? ''
36
+ : `--config ${inputs.configFiles.cspell.copyToPathRelativeToRepoDir}`;
37
+ return {
38
+ mainCommand: (0, package_paths_1.getNpmBinPath)('cspell'),
39
+ args: [
40
+ configArg,
41
+ '--color',
42
+ '--unique',
43
+ '--no-progress',
44
+ '--relative',
45
+ '--dot',
46
+ ...inputs.filteredInputArgs,
47
+ fileArg,
48
+ ],
49
+ logTransforms: {
50
+ stderr: spellcheckLogTransform,
51
+ stdout: spellcheckLogTransform,
52
+ },
53
+ };
54
+ });
@@ -0,0 +1,12 @@
1
+ export declare const testWebCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "test-web";
3
+ subCommandDescriptions: {};
4
+ configFiles: {
5
+ readonly webTestRunner: {
6
+ readonly copyFromInternalPath: string;
7
+ readonly copyToPathRelativeToRepoDir: string;
8
+ readonly required: true;
9
+ };
10
+ };
11
+ npmDeps: readonly ["@open-wc/testing", "@web/dev-server-esbuild", "@web/test-runner", "@web/test-runner-commands", "@web/test-runner-playwright"];
12
+ }>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.testWebCommandDefinition = void 0;
4
+ const path_1 = require("path");
5
+ const define_command_1 = require("../api/command/define-command");
6
+ const package_paths_1 = require("../file-paths/package-paths");
7
+ const test_command_1 = require("./test.command");
8
+ exports.testWebCommandDefinition = (0, define_command_1.defineCommand)({
9
+ commandName: 'test-web',
10
+ subCommandDescriptions: {},
11
+ configFiles: {
12
+ webTestRunner: {
13
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'configs', 'web-test-runner.config.mjs'),
14
+ copyToPathRelativeToRepoDir: (0, path_1.join)('configs', 'web-test-runner.config.mjs'),
15
+ required: true,
16
+ },
17
+ },
18
+ npmDeps: [
19
+ '@open-wc/testing',
20
+ '@web/dev-server-esbuild',
21
+ '@web/test-runner',
22
+ '@web/test-runner-commands',
23
+ '@web/test-runner-playwright',
24
+ ],
25
+ }, ({ commandName, packageBinName, configFiles }) => {
26
+ return {
27
+ sections: [
28
+ {
29
+ title: '',
30
+ content: `Runs tests within browsers rather than inside of Node.js. Test files fed into this command cannot be mixed with test files run by the "${packageBinName} ${test_command_1.testCommandDefinition.commandName}" command, as the run-time environment is quite different (Node.js vs browser). However, just like the ${test_command_1.testCommandDefinition.commandName} command, this command will all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "files" property in ${(0, path_1.basename)(configFiles.webTestRunner.copyFromInternalPath)}.`,
31
+ },
32
+ {
33
+ title: '',
34
+ content: `By default this command runs all tests three times: in Chromium (Chrome), Firefox, and Webkit (Safari) using playwright.`,
35
+ },
36
+ ],
37
+ examples: [
38
+ {
39
+ title: 'Test all .test.ts and .test.tsx files',
40
+ content: `${packageBinName} ${commandName}`,
41
+ },
42
+ {
43
+ title: 'Test a specific file',
44
+ content: `${packageBinName} ${commandName} path/to/file.test.ts`,
45
+ },
46
+ ],
47
+ };
48
+ }, (inputs) => {
49
+ const shouldUseConfig = !inputs.filteredInputArgs.includes('--config');
50
+ const configString = shouldUseConfig
51
+ ? `--config ${inputs.configFiles.webTestRunner.copyToPathRelativeToRepoDir}`
52
+ : '';
53
+ return {
54
+ mainCommand: (0, package_paths_1.getNpmBinPath)('web-test-runner'),
55
+ logTransforms: {
56
+ stdout: testWebTransform,
57
+ },
58
+ args: [
59
+ '--color',
60
+ configString,
61
+ ...inputs.filteredInputArgs,
62
+ ],
63
+ };
64
+ });
65
+ function testWebTransform(input) {
66
+ // remove annoying progress messages
67
+ return input.replace(/[^\n]+█[^\n]+\n/g, '').replace(/Running tests\.\.\./g, '');
68
+ }
@@ -0,0 +1,12 @@
1
+ export declare const testCommandDefinition: import("../api/command/define-command").CommandDefinition<{
2
+ commandName: "test";
3
+ subCommandDescriptions: {};
4
+ configFiles: {
5
+ readonly mocharc: {
6
+ readonly copyFromInternalPath: string;
7
+ readonly copyToPathRelativeToRepoDir: string;
8
+ readonly required: true;
9
+ };
10
+ };
11
+ npmDeps: readonly ["@types/chai", "@types/mocha", "chai", "mocha", "ts-node"];
12
+ }>;