virmator 2.0.5 → 3.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 (183) hide show
  1. package/.github/workflows/virmator-build-for-gh-pages.yml +24 -0
  2. package/.github/workflows/virmator-tagged-release.yml +6 -4
  3. package/.github/workflows/virmator-tests.yml +4 -3
  4. package/.mocharc.js +9 -0
  5. package/.prettierignore +2 -3
  6. package/README.md +67 -82
  7. package/configs/.cspell.json +4 -0
  8. package/configs/.gitattributes +1 -0
  9. package/configs/.mocharc.js +8 -0
  10. package/configs/.prettierignore +6 -0
  11. package/configs/.prettierrc.js +13 -0
  12. package/{.cspell.json → configs/.virmator/.cspell-base.json} +5 -0
  13. package/configs/.virmator/mocharc-base.js +15 -0
  14. package/configs/.virmator/prettierrc-base.js +62 -0
  15. package/{tsconfig.json → configs/.virmator/tsconfig-base.json} +12 -8
  16. package/configs/.virmator/vite-always-reload-plugin.ts +90 -0
  17. package/configs/.virmator/vite-base.ts +11 -0
  18. package/configs/.virmator/vite.config.ts +8 -0
  19. package/configs/.virmator/web-test-runner-base.mjs +29 -0
  20. package/configs/.virmator/web-test-runner.config.mjs +8 -0
  21. package/{.vscode → configs/.vscode}/settings.json +13 -0
  22. package/configs/gitignore.txt +6 -0
  23. package/configs/npmignore.txt +13 -0
  24. package/configs/package.json +16 -0
  25. package/configs/src/global.d.ts +5 -0
  26. package/configs/tsconfig.json +3 -0
  27. package/dist/api/virmator-wrapper.d.ts +5 -0
  28. package/dist/api/virmator-wrapper.js +9 -0
  29. package/dist/augments/array.d.ts +1 -0
  30. package/dist/augments/array.js +7 -0
  31. package/dist/augments/fs.d.ts +5 -0
  32. package/dist/augments/fs.js +30 -0
  33. package/dist/augments/json.d.ts +1 -0
  34. package/dist/augments/json.js +12 -0
  35. package/dist/augments/object.d.ts +1 -0
  36. package/dist/augments/object.js +14 -0
  37. package/dist/augments/regexp.d.ts +1 -0
  38. package/dist/augments/regexp.js +7 -0
  39. package/dist/augments/test.d.ts +2 -0
  40. package/dist/augments/test.js +8 -0
  41. package/dist/augments/type.d.ts +1 -0
  42. package/dist/augments/type.js +2 -0
  43. package/dist/cli/all-cli-command-definitions.d.ts +54 -0
  44. package/dist/cli/all-cli-command-definitions.js +76 -0
  45. package/dist/cli/cli-color.d.ts +8 -0
  46. package/dist/cli/cli-color.js +12 -0
  47. package/dist/cli/cli-command/cli-command-help.d.ts +8 -0
  48. package/dist/cli/cli-command/cli-command-help.js +2 -0
  49. package/dist/cli/{commands/description-printing.d.ts → cli-command/cli-command-to-help-message.d.ts} +3 -2
  50. package/dist/cli/{commands/description-printing.js → cli-command/cli-command-to-help-message.js} +55 -21
  51. package/dist/cli/cli-command/define-cli-command.d.ts +41 -0
  52. package/dist/cli/cli-command/define-cli-command.js +29 -0
  53. package/dist/cli/cli-command/run-shell-command.d.ts +8 -0
  54. package/dist/cli/cli-command/run-shell-command.js +23 -0
  55. package/dist/cli/cli-command-implementations/code-in-markdown.command.d.ts +6 -0
  56. package/dist/cli/cli-command-implementations/code-in-markdown.command.js +67 -0
  57. package/dist/cli/cli-command-implementations/compile.command.d.ts +6 -0
  58. package/dist/cli/cli-command-implementations/compile.command.js +44 -0
  59. package/dist/cli/cli-command-implementations/format.command.d.ts +6 -0
  60. package/dist/cli/cli-command-implementations/format.command.js +116 -0
  61. package/dist/cli/cli-command-implementations/frontend.command.d.ts +7 -0
  62. package/dist/cli/cli-command-implementations/frontend.command.js +45 -0
  63. package/dist/cli/cli-command-implementations/init.command.d.ts +4 -0
  64. package/dist/cli/cli-command-implementations/init.command.js +31 -0
  65. package/dist/cli/cli-command-implementations/spellcheck.command.d.ts +4 -0
  66. package/dist/cli/cli-command-implementations/spellcheck.command.js +40 -0
  67. package/dist/cli/cli-command-implementations/test-web.command.d.ts +4 -0
  68. package/dist/cli/cli-command-implementations/test-web.command.js +50 -0
  69. package/dist/cli/cli-command-implementations/test.command.d.ts +4 -0
  70. package/dist/cli/cli-command-implementations/test.command.js +53 -0
  71. package/dist/cli/cli-command-implementations/update-configs.command.d.ts +4 -0
  72. package/dist/cli/cli-command-implementations/update-configs.command.js +31 -0
  73. package/dist/cli/cli-flags/cli-flag-name.d.ts +4 -0
  74. package/dist/cli/cli-flags/cli-flag-name.js +8 -0
  75. package/dist/cli/cli-flags/cli-flag-values.d.ts +4 -0
  76. package/dist/cli/cli-flags/cli-flag-values.js +19 -0
  77. package/dist/cli/cli-messages.d.ts +6 -0
  78. package/dist/cli/cli-messages.js +19 -0
  79. package/dist/cli/cli.js +27 -20
  80. package/dist/cli/config/combine-text-config.d.ts +2 -0
  81. package/dist/cli/config/combine-text-config.js +27 -0
  82. package/dist/cli/config/config-files.d.ts +133 -0
  83. package/dist/cli/config/config-files.js +138 -0
  84. package/dist/cli/config/copy-config.d.ts +25 -13
  85. package/dist/cli/config/copy-config.js +86 -86
  86. package/dist/cli/config/create-default-package-json.d.ts +1 -16
  87. package/dist/cli/config/create-default-package-json.js +37 -12
  88. package/dist/cli/is-global.d.ts +1 -0
  89. package/dist/cli/is-global.js +10 -0
  90. package/dist/cli/parse-arguments.d.ts +8 -0
  91. package/dist/cli/parse-arguments.js +42 -0
  92. package/dist/cli/run-cli-command.d.ts +13 -0
  93. package/dist/cli/run-cli-command.js +52 -0
  94. package/dist/cli/run-command.test-helper.d.ts +28 -0
  95. package/dist/cli/run-command.test-helper.js +87 -0
  96. package/dist/errors/virmator-cli.error.d.ts +3 -0
  97. package/dist/errors/virmator-cli.error.js +10 -0
  98. package/dist/errors/virmator-config-file.error.d.ts +4 -0
  99. package/dist/errors/virmator-config-file.error.js +11 -0
  100. package/dist/errors/virmator-invalid-command.error.d.ts +5 -0
  101. package/dist/errors/virmator-invalid-command.error.js +11 -0
  102. package/dist/errors/virmator-invalid-flags.error.d.ts +5 -0
  103. package/dist/errors/virmator-invalid-flags.error.js +13 -0
  104. package/dist/file-paths/virmator-package-paths.d.ts +11 -0
  105. package/dist/file-paths/virmator-package-paths.js +31 -0
  106. package/dist/file-paths/virmator-test-file-paths.d.ts +17 -7
  107. package/dist/index.d.ts +1 -2
  108. package/dist/index.js +0 -4
  109. package/dist/logging.d.ts +10 -0
  110. package/dist/logging.js +9 -0
  111. package/package.json +28 -22
  112. package/.prettierrc.js +0 -40
  113. package/dist/augments/ansi-regex.d.ts +0 -1
  114. package/dist/augments/ansi-regex.js +0 -27
  115. package/dist/augments/string.d.ts +0 -1
  116. package/dist/augments/string.js +0 -8
  117. package/dist/cli/cli-util/cli-color.d.ts +0 -8
  118. package/dist/cli/cli-util/cli-color.js +0 -35
  119. package/dist/cli/cli-util/cli-command-name.d.ts +0 -11
  120. package/dist/cli/cli-util/cli-command-name.js +0 -15
  121. package/dist/cli/cli-util/cli-flags.d.ts +0 -18
  122. package/dist/cli/cli-util/cli-flags.js +0 -63
  123. package/dist/cli/cli-util/cli-messages.d.ts +0 -7
  124. package/dist/cli/cli-util/cli-messages.js +0 -19
  125. package/dist/cli/cli-util/get-all-command-output.d.ts +0 -7
  126. package/dist/cli/cli-util/get-all-command-output.js +0 -21
  127. package/dist/cli/cli-util/shell-command-wrapper.d.ts +0 -8
  128. package/dist/cli/cli-util/shell-command-wrapper.js +0 -25
  129. package/dist/cli/cli-util/update-configs.d.ts +0 -3
  130. package/dist/cli/cli-util/update-configs.js +0 -54
  131. package/dist/cli/commands/all-cli-commands.d.ts +0 -13
  132. package/dist/cli/commands/all-cli-commands.js +0 -99
  133. package/dist/cli/commands/cli-command.d.ts +0 -35
  134. package/dist/cli/commands/cli-command.js +0 -40
  135. package/dist/cli/commands/implementations/code-in-markdown.command.d.ts +0 -3
  136. package/dist/cli/commands/implementations/code-in-markdown.command.js +0 -54
  137. package/dist/cli/commands/implementations/compile.command.d.ts +0 -3
  138. package/dist/cli/commands/implementations/compile.command.js +0 -49
  139. package/dist/cli/commands/implementations/format.command.d.ts +0 -16
  140. package/dist/cli/commands/implementations/format.command.js +0 -143
  141. package/dist/cli/commands/implementations/init.command.d.ts +0 -3
  142. package/dist/cli/commands/implementations/init.command.js +0 -55
  143. package/dist/cli/commands/implementations/spellcheck.command.d.ts +0 -3
  144. package/dist/cli/commands/implementations/spellcheck.command.js +0 -35
  145. package/dist/cli/commands/implementations/test.command.d.ts +0 -3
  146. package/dist/cli/commands/implementations/test.command.js +0 -49
  147. package/dist/cli/commands/implementations/update-all-configs.command.d.ts +0 -3
  148. package/dist/cli/commands/implementations/update-all-configs.command.js +0 -46
  149. package/dist/cli/commands/implementations/update-bare-configs.command.d.ts +0 -3
  150. package/dist/cli/commands/implementations/update-bare-configs.command.js +0 -46
  151. package/dist/cli/commands/run-command.d.ts +0 -3
  152. package/dist/cli/commands/run-command.js +0 -65
  153. package/dist/cli/config/config-key.d.ts +0 -35
  154. package/dist/cli/config/config-key.js +0 -25
  155. package/dist/cli/config/config-paths.d.ts +0 -3
  156. package/dist/cli/config/config-paths.js +0 -69
  157. package/dist/cli/config/config-read.d.ts +0 -7
  158. package/dist/cli/config/config-read.js +0 -91
  159. package/dist/cli/config/extendable-config.d.ts +0 -12
  160. package/dist/cli/config/extendable-config.js +0 -45
  161. package/dist/errors/cli-command-error.d.ts +0 -4
  162. package/dist/errors/cli-command-error.js +0 -12
  163. package/dist/errors/cli-flag-error.d.ts +0 -4
  164. package/dist/errors/cli-flag-error.js +0 -12
  165. package/dist/errors/config-file-error.d.ts +0 -3
  166. package/dist/errors/config-file-error.js +0 -7
  167. package/dist/exportable-jest-config/jest-config.d.ts +0 -3
  168. package/dist/exportable-jest-config/jest-config.js +0 -23
  169. package/dist/exportable-jest-config/jest-setup.d.ts +0 -1
  170. package/dist/exportable-jest-config/jest-setup.js +0 -11
  171. package/dist/file-paths/virmator-repo-paths.d.ts +0 -5
  172. package/dist/file-paths/virmator-repo-paths.js +0 -19
  173. package/dist/jest/jest-config.d.ts +0 -3
  174. package/dist/jest/jest-config.js +0 -13
  175. package/extender-configs/.cspell.json +0 -3
  176. package/extender-configs/.prettierrc.js +0 -3
  177. package/extender-configs/tsconfig.json +0 -3
  178. package/separate-configs/.prettierignore +0 -3
  179. package/separate-configs/gitignore.txt +0 -4
  180. package/separate-configs/jest/jest-config.ts +0 -24
  181. package/separate-configs/jest/jest-setup.ts +0 -12
  182. package/separate-configs/npmignore.txt +0 -20
  183. package/separate-configs/package.json +0 -9
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runCompileCommand = exports.compileImplementation = void 0;
4
- const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
5
- const package_name_1 = require("../../../package-name");
6
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
7
- const cli_flags_1 = require("../../cli-util/cli-flags");
8
- const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
9
- const config_key_1 = require("../../config/config-key");
10
- exports.compileImplementation = {
11
- commandName: cli_command_name_1.CliCommandName.Compile,
12
- description: {
13
- sections: [
14
- {
15
- title: '',
16
- content: `compile typescript files
17
- Pass any extra tsc flags to this command.`,
18
- },
19
- ],
20
- examples: [
21
- {
22
- title: `no extra flags`,
23
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile}`,
24
- },
25
- {
26
- title: `one extra flag`,
27
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile} --noEmit`,
28
- },
29
- ],
30
- },
31
- implementation: runCompileCommand,
32
- configKeys: [config_key_1.ConfigKey.TsConfig],
33
- configFlagSupport: {
34
- [cli_flags_1.CliFlagName.NoWriteConfig]: true,
35
- },
36
- };
37
- const tscPath = (0, virmator_repo_paths_1.getNpmBinPath)('tsc');
38
- async function runCompileCommand(inputs) {
39
- const resetCommand = inputs.rawArgs.join(' ').includes('--noEmit') ? '' : 'rm -rf dist && ';
40
- const compileCommand = `${resetCommand}${tscPath} --pretty ${inputs.rawArgs
41
- .map((arg) => `"${arg}"`)
42
- .join(' ')}`;
43
- const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(compileCommand, inputs);
44
- return {
45
- command: compileCommand,
46
- success: !results.error,
47
- };
48
- }
49
- exports.runCompileCommand = runCompileCommand;
@@ -1,16 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare enum FormatOperation {
3
- Check = "check",
4
- Write = "write"
5
- }
6
- declare type FormatArgs = Required<Readonly<{
7
- operation: FormatOperation;
8
- fileExtensions: Readonly<string[]>;
9
- prettierFlags: Readonly<string[]>;
10
- }>>;
11
- export declare const defaultFormatArgs: FormatArgs;
12
- export declare const filesMarkerArg: "--format-files";
13
- export declare const formatImplementation: CliCommandImplementation;
14
- export declare function runFormatCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
15
- export declare function extractFormatArgs(rawArgs: string[]): FormatArgs;
16
- export {};
@@ -1,143 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractFormatArgs = exports.runFormatCommand = exports.formatImplementation = exports.filesMarkerArg = exports.defaultFormatArgs = exports.FormatOperation = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
6
- const package_name_1 = require("../../../package-name");
7
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
8
- const cli_flags_1 = require("../../cli-util/cli-flags");
9
- const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
10
- const config_key_1 = require("../../config/config-key");
11
- var FormatOperation;
12
- (function (FormatOperation) {
13
- FormatOperation["Check"] = "check";
14
- FormatOperation["Write"] = "write";
15
- })(FormatOperation = exports.FormatOperation || (exports.FormatOperation = {}));
16
- exports.defaultFormatArgs = {
17
- operation: FormatOperation.Write,
18
- prettierFlags: [],
19
- fileExtensions: [
20
- 'ts',
21
- 'tsx',
22
- 'json',
23
- 'html',
24
- 'css',
25
- 'md',
26
- 'js',
27
- 'yml',
28
- 'yaml',
29
- ],
30
- };
31
- exports.filesMarkerArg = '--format-files';
32
- exports.formatImplementation = {
33
- commandName: cli_command_name_1.CliCommandName.Format,
34
- description: {
35
- sections: [
36
- {
37
- title: '',
38
- content: 'Formats source files with Prettier.',
39
- },
40
- {
41
- title: 'operation commands',
42
- content: `This is optional but if provided it must come first. ${FormatOperation.Write} is the default.
43
- ${FormatOperation.Write}: overwrites files to fix formatting.
44
- ${FormatOperation.Check}: checks the formatting, does not write to files`,
45
- },
46
- {
47
- title: 'file extensions',
48
- content: `If only specific file extensions should be formatted, add the "${exports.filesMarkerArg}" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will overwrite files (because ${FormatOperation.Write} is the default operation) only if they have the extension ".md" or ".json": ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${exports.filesMarkerArg} md json`,
49
- },
50
- {
51
- title: 'Prettier flags',
52
- content: `Any other arguments encountered between the operation command (if provided) and the "${exports.filesMarkerArg}" marker are treated as extra arguments to Prettier and will be passed along.`,
53
- },
54
- ],
55
- examples: [
56
- {
57
- title: 'checks formatting for files',
58
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check}`,
59
- },
60
- {
61
- title: 'checks formatting only for .md files',
62
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md`,
63
- },
64
- {
65
- title: 'checks formatting only for .md and .json files',
66
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md json`,
67
- },
68
- {
69
- title: 'fixes formatting for files',
70
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format}
71
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write}`,
72
- },
73
- {
74
- title: `examples with extra Prettier flags`,
75
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} --ignore-path .prettierignore
76
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore
77
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore ${exports.filesMarkerArg} md json`,
78
- },
79
- ],
80
- },
81
- configKeys: [
82
- config_key_1.ConfigKey.Prettier,
83
- config_key_1.ConfigKey.PrettierIgnore,
84
- ],
85
- implementation: runFormatCommand,
86
- configFlagSupport: {
87
- [cli_flags_1.CliFlagName.NoWriteConfig]: true,
88
- },
89
- };
90
- const prettierPath = (0, virmator_repo_paths_1.getNpmBinPath)('prettier');
91
- async function runFormatCommand(inputs) {
92
- const args = extractFormatArgs(inputs.rawArgs);
93
- const operationFlag = args.operation === FormatOperation.Check ? '--check' : '--write';
94
- const fileExtensions = `\"./**/*.+(${args.fileExtensions.join('|')})\"`;
95
- const hasNonFlags = args.prettierFlags.some((flag) => !flag.startsWith('-'));
96
- const prettierCommand = `${prettierPath} --color ${args.prettierFlags.join(' ')} ${hasNonFlags ? '' : fileExtensions} ${operationFlag}`;
97
- const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(prettierCommand, inputs, {
98
- stdoutFilter: (stdout) => stdout
99
- // only relevant when running the check command
100
- .replace('Checking formatting...\n', '')
101
- // only relevant when running the check command
102
- .replace('All matched files use Prettier code style!\n', ''),
103
- });
104
- return {
105
- command: prettierCommand,
106
- success: !results.error,
107
- };
108
- }
109
- exports.runFormatCommand = runFormatCommand;
110
- function extractFormatArgs(rawArgs) {
111
- let addingFileExtensions = false;
112
- const operation = (0, augment_vir_1.isEnumValue)(rawArgs[0], FormatOperation)
113
- ? rawArgs[0]
114
- : FormatOperation.Write;
115
- const extractedArgs = rawArgs.reduce((accum, currentRawArg, index) => {
116
- if (index === 0 && (0, augment_vir_1.isEnumValue)(rawArgs[index], FormatOperation)) {
117
- return accum;
118
- }
119
- else if (currentRawArg === exports.filesMarkerArg) {
120
- addingFileExtensions = true;
121
- }
122
- else if (addingFileExtensions) {
123
- if (!accum.fileExtensions) {
124
- accum.fileExtensions = [];
125
- }
126
- accum.fileExtensions.push(currentRawArg);
127
- }
128
- else {
129
- if (!accum.prettierFlags) {
130
- accum.prettierFlags = [];
131
- }
132
- accum.prettierFlags.push(currentRawArg);
133
- }
134
- return accum;
135
- }, { prettierFlags: [...exports.defaultFormatArgs.prettierFlags] });
136
- const finalArgs = {
137
- ...exports.defaultFormatArgs,
138
- ...extractedArgs,
139
- operation,
140
- };
141
- return finalArgs;
142
- }
143
- exports.extractFormatArgs = extractFormatArgs;
@@ -1,3 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare const initCommandImplementation: CliCommandImplementation;
3
- export declare function runInitCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runInitCommand = exports.initCommandImplementation = void 0;
4
- const promises_1 = require("fs/promises");
5
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
6
- const cli_flags_1 = require("../../cli-util/cli-flags");
7
- const config_key_1 = require("../../config/config-key");
8
- const config_paths_1 = require("../../config/config-paths");
9
- const config_read_1 = require("../../config/config-read");
10
- const format_command_1 = require("./format.command");
11
- const update_all_configs_command_1 = require("./update-all-configs.command");
12
- exports.initCommandImplementation = {
13
- commandName: cli_command_name_1.CliCommandName.Test,
14
- description: {
15
- sections: [
16
- {
17
- title: '',
18
- content: `Init everything, including package.json scripts.
19
- If no package.json file is found, one is created and initialized.
20
- Pass --force to this command to overwrite current package.json scripts.`,
21
- },
22
- ],
23
- examples: [],
24
- },
25
- implementation: runInitCommand,
26
- configFlagSupport: {
27
- [cli_flags_1.CliFlagName.NoWriteConfig]: true,
28
- },
29
- };
30
- async function runInitCommand(inputs) {
31
- let error;
32
- try {
33
- if (!inputs.cliFlags[cli_flags_1.CliFlagName.NoWriteConfig]) {
34
- await updatePackageJson(inputs.repoDir);
35
- await (0, update_all_configs_command_1.runUpdateAllConfigsCommand)({
36
- ...inputs,
37
- rawArgs: [],
38
- });
39
- }
40
- await (0, format_command_1.runFormatCommand)({ ...inputs, rawArgs: [] });
41
- }
42
- catch (catchError) {
43
- error = catchError;
44
- }
45
- return {
46
- command: undefined,
47
- success: !error,
48
- };
49
- }
50
- exports.runInitCommand = runInitCommand;
51
- async function updatePackageJson(repoDir) {
52
- const repoPackageJsonPath = (0, config_paths_1.getRepoConfigFilePath)(config_key_1.ConfigKey.PackageJson, false);
53
- const finalPackageJsonContents = await (0, config_read_1.readUpdatedVirmatorConfigFile)(config_key_1.ConfigKey.PackageJson, repoDir, false);
54
- await (0, promises_1.writeFile)(repoPackageJsonPath, finalPackageJsonContents);
55
- }
@@ -1,3 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare const spellcheckCommandImplementation: CliCommandImplementation;
3
- export declare function runSpellcheckCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runSpellcheckCommand = exports.spellcheckCommandImplementation = void 0;
4
- const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
5
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
6
- const cli_flags_1 = require("../../cli-util/cli-flags");
7
- const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
8
- const config_key_1 = require("../../config/config-key");
9
- exports.spellcheckCommandImplementation = {
10
- commandName: cli_command_name_1.CliCommandName.SpellCheck,
11
- description: {
12
- sections: [
13
- {
14
- title: '',
15
- content: `Spellcheck code with cspell. Any extra arguments are passed directly to cspell.`,
16
- },
17
- ],
18
- examples: [],
19
- },
20
- implementation: runSpellcheckCommand,
21
- configKeys: [config_key_1.ConfigKey.Cspell],
22
- configFlagSupport: {
23
- [cli_flags_1.CliFlagName.NoWriteConfig]: true,
24
- },
25
- };
26
- const cSpellPath = (0, virmator_repo_paths_1.getNpmBinPath)('cspell');
27
- async function runSpellcheckCommand(inputs) {
28
- const spellcheckCommand = `${cSpellPath} --color "{*,.*,**/{.*,*}/**/{.*,*}}" ${inputs.rawArgs.join(' ')}`;
29
- const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(spellcheckCommand, inputs);
30
- return {
31
- command: spellcheckCommand,
32
- success: !results.error,
33
- };
34
- }
35
- exports.runSpellcheckCommand = runSpellcheckCommand;
@@ -1,3 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare const testCommandImplementation: CliCommandImplementation;
3
- export declare function runTestCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runTestCommand = exports.testCommandImplementation = void 0;
4
- const node_only_1 = require("augment-vir/dist/node-only");
5
- const config_key_1 = require("../../../cli/config/config-key");
6
- const config_paths_1 = require("../../../cli/config/config-paths");
7
- const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
8
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
9
- const cli_flags_1 = require("../../cli-util/cli-flags");
10
- const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
11
- exports.testCommandImplementation = {
12
- commandName: cli_command_name_1.CliCommandName.Test,
13
- description: {
14
- sections: [
15
- {
16
- title: '',
17
- content: `Test all .test.ts files with jest. By default this command tests all .test.ts files in the current directory that are not .type.test.ts files. To override this behavior, pass in a custom config file with Jest's --config argument. The default Jest config file can be extended by importing it with "import {virmatorJestConfig} from 'virmator'". All other Jest inputs are also valid.`,
18
- },
19
- ],
20
- examples: [
21
- { title: '', content: `virmator test ./path/to/single/file.js` },
22
- { title: '', content: `virmator test "./**/single-file.js"` },
23
- { title: '', content: `virmator test "./dist/**/!(*.type).test.js"` },
24
- ],
25
- },
26
- implementation: runTestCommand,
27
- configKeys: [
28
- config_key_1.CommandConfigKey.JestSetup,
29
- config_key_1.CommandConfigKey.JestConfig,
30
- ],
31
- configFlagSupport: {
32
- [cli_flags_1.CliFlagName.NoWriteConfig]: true,
33
- },
34
- };
35
- const jestPath = (0, virmator_repo_paths_1.getNpmBinPath)('jest');
36
- async function runTestCommand(inputs) {
37
- const args = inputs.rawArgs.length ? inputs.rawArgs.join(' ') : '';
38
- const defaultConfigPath = (0, config_paths_1.getRepoConfigFilePath)(config_key_1.CommandConfigKey.JestConfig, false);
39
- const configPath = args.includes('--config ') || args.includes('-c ')
40
- ? ''
41
- : `--config ${(0, node_only_1.interpolationSafeWindowsPath)(defaultConfigPath)}`;
42
- const testCommand = `${jestPath} --colors ${configPath} ${args}`;
43
- const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(testCommand, inputs);
44
- return {
45
- command: testCommand,
46
- success: !results.error,
47
- };
48
- }
49
- exports.runTestCommand = runTestCommand;
@@ -1,3 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare const updateAllConfigsCommandImplementation: CliCommandImplementation;
3
- export declare function runUpdateAllConfigsCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runUpdateAllConfigsCommand = exports.updateAllConfigsCommandImplementation = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const package_name_1 = require("../../../package-name");
6
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
7
- const cli_flags_1 = require("../../cli-util/cli-flags");
8
- const update_configs_1 = require("../../cli-util/update-configs");
9
- const config_key_1 = require("../../config/config-key");
10
- const exampleFlags = [
11
- config_key_1.ConfigKey.Cspell,
12
- config_key_1.ConfigKey.GitIgnore,
13
- ];
14
- exports.updateAllConfigsCommandImplementation = {
15
- commandName: cli_command_name_1.CliCommandName.UpdateAllConfigs,
16
- description: {
17
- sections: [
18
- {
19
- title: '',
20
- content: `Update all config files. This command accepts a list of config file keys as arguments. If no arguments are given, this command copies all config files.`,
21
- },
22
- {
23
- title: 'list of possible arguments',
24
- content: (0, augment_vir_1.getEnumTypedValues)(config_key_1.ConfigKey).join('\n'),
25
- },
26
- ],
27
- examples: [
28
- {
29
- title: `update all config files`,
30
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs}`,
31
- },
32
- {
33
- title: `update only ${(0, augment_vir_1.joinWithFinalConjunction)(exampleFlags)} files`,
34
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs} ${exampleFlags.join(' ')}`,
35
- },
36
- ],
37
- },
38
- implementation: runUpdateAllConfigsCommand,
39
- configFlagSupport: {
40
- [cli_flags_1.CliFlagName.NoWriteConfig]: false,
41
- },
42
- };
43
- async function runUpdateAllConfigsCommand(inputs) {
44
- return await (0, update_configs_1.updateConfigs)(config_key_1.ConfigKey, inputs);
45
- }
46
- exports.runUpdateAllConfigsCommand = runUpdateAllConfigsCommand;
@@ -1,3 +0,0 @@
1
- import { CliCommandImplementation, CliCommandResult, CommandFunctionInput } from '../cli-command';
2
- export declare const updateBareConfigsCommandImplementation: CliCommandImplementation;
3
- export declare function runUpdateBareConfigsCommand(inputs: CommandFunctionInput): Promise<CliCommandResult>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runUpdateBareConfigsCommand = exports.updateBareConfigsCommandImplementation = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const package_name_1 = require("../../../package-name");
6
- const cli_command_name_1 = require("../../cli-util/cli-command-name");
7
- const cli_flags_1 = require("../../cli-util/cli-flags");
8
- const update_configs_1 = require("../../cli-util/update-configs");
9
- const config_key_1 = require("../../config/config-key");
10
- const exampleFlags = [
11
- config_key_1.BareConfigKey.GitIgnore,
12
- config_key_1.BareConfigKey.NpmIgnore,
13
- ];
14
- exports.updateBareConfigsCommandImplementation = {
15
- commandName: cli_command_name_1.CliCommandName.UpdateBareConfigs,
16
- description: {
17
- sections: [
18
- {
19
- title: '',
20
- content: `Update config files that aren't used in any ${package_name_1.packageName} commands, like GitHub actions tests or VS Code Settings. This command accepts a list of bare config file keys as arguments. If no arguments are given, this command copies all the bare config files.`,
21
- },
22
- {
23
- title: 'list of possible arguments',
24
- content: (0, augment_vir_1.getEnumTypedValues)(config_key_1.BareConfigKey).join('\n'),
25
- },
26
- ],
27
- examples: [
28
- {
29
- title: `update all bare config files`,
30
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs}`,
31
- },
32
- {
33
- title: `update only ${(0, augment_vir_1.joinWithFinalConjunction)(exampleFlags)} files`,
34
- content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs} ${exampleFlags.join(' ')},`,
35
- },
36
- ],
37
- },
38
- implementation: runUpdateBareConfigsCommand,
39
- configFlagSupport: {
40
- [cli_flags_1.CliFlagName.NoWriteConfig]: false,
41
- },
42
- };
43
- async function runUpdateBareConfigsCommand(inputs) {
44
- return await (0, update_configs_1.updateConfigs)(config_key_1.BareConfigKey, inputs);
45
- }
46
- exports.runUpdateBareConfigsCommand = runUpdateBareConfigsCommand;
@@ -1,3 +0,0 @@
1
- import { CliCommandName } from '../cli-util/cli-command-name';
2
- import { CliCommandResult, PartialCommandFunctionInput } from './cli-command';
3
- export declare function runCommand(command: CliCommandName, commandInput: PartialCommandFunctionInput): Promise<CliCommandResult>;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runCommand = void 0;
4
- const cli_command_error_1 = require("../../errors/cli-command-error");
5
- const repo_paths_1 = require("../../file-paths/repo-paths");
6
- const cli_command_name_1 = require("../cli-util/cli-command-name");
7
- const cli_flags_1 = require("../cli-util/cli-flags");
8
- const cli_messages_1 = require("../cli-util/cli-messages");
9
- const copy_config_1 = require("../config/copy-config");
10
- const extendable_config_1 = require("../config/extendable-config");
11
- const all_cli_commands_1 = require("./all-cli-commands");
12
- const cli_command_1 = require("./cli-command");
13
- async function runCommand(command, commandInput) {
14
- const commandImplementation = all_cli_commands_1.allCliCommands[command];
15
- const cliFlags = (0, cli_flags_1.fillInCliFlags)(commandInput.rawCliFlags);
16
- const defaultFlagSupport = {
17
- [cli_flags_1.CliFlagName.Silent]: true,
18
- [cli_flags_1.CliFlagName.Help]: true,
19
- [cli_flags_1.CliFlagName.ExtendableConfig]: !!commandImplementation.configKeys?.some((configKey) => (0, extendable_config_1.isExtendableConfig)(configKey)),
20
- };
21
- const unsupportedFlagsInUse = (0, all_cli_commands_1.getUnsupportedFlags)(cliFlags, {
22
- ...defaultFlagSupport,
23
- ...commandImplementation.configFlagSupport,
24
- });
25
- if (command !== cli_command_name_1.CliCommandName.Help && unsupportedFlagsInUse.length) {
26
- throw new cli_command_error_1.VirmatorCliCommandError(cli_messages_1.cliErrorMessages.unsupportedCliFlag(command, unsupportedFlagsInUse));
27
- }
28
- if (commandImplementation.configKeys?.length && !cliFlags[cli_flags_1.CliFlagName.NoWriteConfig]) {
29
- await Promise.all(commandImplementation.configKeys.map(async (configKey) => {
30
- const copyOutput = await (0, copy_config_1.copyConfig)({
31
- configKey: configKey,
32
- forceExtendableConfig: cliFlags[cli_flags_1.CliFlagName.ExtendableConfig],
33
- repoDir: repo_paths_1.repoRootDir,
34
- });
35
- copyOutput.logs.forEach((log) => {
36
- if (log.stderr) {
37
- console.error(log.log);
38
- }
39
- else {
40
- console.info(log.log);
41
- }
42
- });
43
- }));
44
- }
45
- const loggers = cliFlags[cli_flags_1.CliFlagName.Silent] && command !== cli_command_name_1.CliCommandName.Help
46
- ? cli_command_1.EmptyOutputCallbacks
47
- : {
48
- stdoutCallback: (input) => {
49
- console.info(input.replace(/\n$/, ''));
50
- },
51
- stderrCallback: (input) => {
52
- console.error(input.replace(/\n$/, ''));
53
- },
54
- };
55
- const commandResult = await commandImplementation.implementation({
56
- ...(0, cli_command_1.fillInCommandInput)({
57
- ...commandInput,
58
- cliFlags,
59
- rawArgs: commandInput.rawArgs || [],
60
- }),
61
- ...loggers,
62
- });
63
- return commandResult;
64
- }
65
- exports.runCommand = runCommand;
@@ -1,35 +0,0 @@
1
- /** These config files are not used by any virmator commands but they are still helpful. */
2
- export declare enum BareConfigKey {
3
- GitAttributes = "GitAttributes",
4
- GitHubActionsTaggedRelease = "GitHubActionsTaggedRelease",
5
- GitHubActionsTest = "GitHubActionsTest",
6
- GitIgnore = "GitIgnore",
7
- NpmIgnore = "NpmIgnore",
8
- VsCodeSettings = "VsCodeSettings"
9
- }
10
- /** These are config files used by virmator commands. */
11
- export declare enum CommandConfigKey {
12
- Cspell = "Cspell",
13
- JestConfig = "JestConfig",
14
- JestSetup = "JestSetup",
15
- PackageJson = "PackageJson",
16
- Prettier = "Prettier",
17
- PrettierIgnore = "PrettierIgnore",
18
- TsConfig = "TsConfig"
19
- }
20
- export declare const ConfigKey: {
21
- GitAttributes: BareConfigKey.GitAttributes;
22
- GitHubActionsTaggedRelease: BareConfigKey.GitHubActionsTaggedRelease;
23
- GitHubActionsTest: BareConfigKey.GitHubActionsTest;
24
- GitIgnore: BareConfigKey.GitIgnore;
25
- NpmIgnore: BareConfigKey.NpmIgnore;
26
- VsCodeSettings: BareConfigKey.VsCodeSettings;
27
- Cspell: CommandConfigKey.Cspell;
28
- JestConfig: CommandConfigKey.JestConfig;
29
- JestSetup: CommandConfigKey.JestSetup;
30
- PackageJson: CommandConfigKey.PackageJson;
31
- Prettier: CommandConfigKey.Prettier;
32
- PrettierIgnore: CommandConfigKey.PrettierIgnore;
33
- TsConfig: CommandConfigKey.TsConfig;
34
- };
35
- export declare type ConfigKey = CommandConfigKey | BareConfigKey;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigKey = exports.CommandConfigKey = exports.BareConfigKey = void 0;
4
- /** These config files are not used by any virmator commands but they are still helpful. */
5
- var BareConfigKey;
6
- (function (BareConfigKey) {
7
- BareConfigKey["GitAttributes"] = "GitAttributes";
8
- BareConfigKey["GitHubActionsTaggedRelease"] = "GitHubActionsTaggedRelease";
9
- BareConfigKey["GitHubActionsTest"] = "GitHubActionsTest";
10
- BareConfigKey["GitIgnore"] = "GitIgnore";
11
- BareConfigKey["NpmIgnore"] = "NpmIgnore";
12
- BareConfigKey["VsCodeSettings"] = "VsCodeSettings";
13
- })(BareConfigKey = exports.BareConfigKey || (exports.BareConfigKey = {}));
14
- /** These are config files used by virmator commands. */
15
- var CommandConfigKey;
16
- (function (CommandConfigKey) {
17
- CommandConfigKey["Cspell"] = "Cspell";
18
- CommandConfigKey["JestConfig"] = "JestConfig";
19
- CommandConfigKey["JestSetup"] = "JestSetup";
20
- CommandConfigKey["PackageJson"] = "PackageJson";
21
- CommandConfigKey["Prettier"] = "Prettier";
22
- CommandConfigKey["PrettierIgnore"] = "PrettierIgnore";
23
- CommandConfigKey["TsConfig"] = "TsConfig";
24
- })(CommandConfigKey = exports.CommandConfigKey || (exports.CommandConfigKey = {}));
25
- exports.ConfigKey = { ...CommandConfigKey, ...BareConfigKey };
@@ -1,3 +0,0 @@
1
- import { ConfigKey } from './config-key';
2
- export declare function getRepoConfigFilePath(configKey: ConfigKey, extendable: boolean): string;
3
- export declare function getVirmatorConfigFilePath(configKey: ConfigKey, extender: boolean): string;