virmator 1.4.5 → 2.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 (50) hide show
  1. package/.cspell.json +1 -0
  2. package/.github/workflows/virmator-tests.yml +1 -1
  3. package/.prettierignore +3 -2
  4. package/README.md +159 -1
  5. package/dist/cli/cli-util/cli-flags.js +4 -7
  6. package/dist/cli/cli-util/get-all-command-output.d.ts +4 -3
  7. package/dist/cli/cli-util/update-configs.js +3 -2
  8. package/dist/cli/cli.js +1 -1
  9. package/dist/cli/commands/all-cli-commands.d.ts +2 -0
  10. package/dist/cli/commands/all-cli-commands.js +27 -23
  11. package/dist/cli/commands/cli-command.d.ts +10 -1
  12. package/dist/cli/commands/cli-command.js +1 -1
  13. package/dist/cli/commands/description-printing.d.ts +10 -0
  14. package/dist/cli/commands/description-printing.js +149 -0
  15. package/dist/cli/commands/implementations/code-in-markdown.command.js +27 -20
  16. package/dist/cli/commands/implementations/compile.command.js +20 -8
  17. package/dist/cli/commands/implementations/format.command.js +51 -37
  18. package/dist/cli/commands/implementations/init.command.js +13 -4
  19. package/dist/cli/commands/implementations/spellcheck.command.js +10 -1
  20. package/dist/cli/commands/implementations/test.command.js +22 -25
  21. package/dist/cli/commands/implementations/update-all-configs.command.js +22 -13
  22. package/dist/cli/commands/implementations/update-bare-configs.command.js +22 -14
  23. package/dist/cli/commands/run-command.js +2 -3
  24. package/dist/cli/config/config-key.d.ts +9 -9
  25. package/dist/cli/config/config-key.js +4 -4
  26. package/dist/cli/config/config-paths.js +1 -1
  27. package/dist/cli/config/config-read.js +1 -2
  28. package/dist/cli/config/create-default-package-json.js +2 -2
  29. package/dist/errors/cli-command-error.js +1 -1
  30. package/dist/errors/cli-flag-error.js +1 -1
  31. package/dist/errors/config-file-error.js +1 -4
  32. package/dist/exportable-jest-config/jest-config-path.d.ts +1 -0
  33. package/dist/exportable-jest-config/jest-config-path.js +6 -0
  34. package/dist/exportable-jest-config/separate-jest-configs/jest-config.d.ts +3 -0
  35. package/dist/exportable-jest-config/separate-jest-configs/jest-config.js +25 -0
  36. package/dist/exportable-jest-config/separate-jest-configs/jest-setup.d.ts +1 -0
  37. package/dist/exportable-jest-config/separate-jest-configs/jest-setup.js +11 -0
  38. package/dist/file-paths/virmator-repo-paths.js +2 -2
  39. package/dist/file-paths/{virmator-test-repos-paths.d.ts → virmator-test-file-paths.d.ts} +2 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +6 -0
  42. package/dist/jest/jest-config.d.ts +3 -0
  43. package/dist/jest/jest-config.js +12 -0
  44. package/package.json +16 -10
  45. package/separate-configs/gitignore.txt +2 -0
  46. package/separate-configs/jest/jest-config.ts +26 -0
  47. package/separate-configs/jest/jest-setup.ts +12 -0
  48. package/separate-configs/npmignore.txt +7 -4
  49. package/tsconfig.json +13 -6
  50. package/dist/file-paths/virmator-test-repos-paths.js +0 -56
@@ -9,14 +9,25 @@ const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
9
9
  const config_key_1 = require("../../config/config-key");
10
10
  exports.compileImplementation = {
11
11
  commandName: cli_command_name_1.CliCommandName.Compile,
12
- description: `compile typescript files
13
- Pass any extra tsc flags to this command.
14
-
15
- examples:
16
- no extra flags:
17
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile}
18
- one extra flag:
19
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile} --noEmit`,
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
+ },
20
31
  implementation: runCompileCommand,
21
32
  configKeys: [config_key_1.ConfigKey.TsConfig],
22
33
  configFlagSupport: {
@@ -31,6 +42,7 @@ async function runCompileCommand(inputs) {
31
42
  .join(' ')}`;
32
43
  const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(compileCommand, inputs);
33
44
  return {
45
+ command: compileCommand,
34
46
  success: !results.error,
35
47
  };
36
48
  }
@@ -31,42 +31,53 @@ exports.defaultFormatArgs = {
31
31
  exports.filesMarkerArg = '--format-files';
32
32
  exports.formatImplementation = {
33
33
  commandName: cli_command_name_1.CliCommandName.Format,
34
- description: `formats source files with Prettier
35
- operation commands:
36
- This is optional but if provided it must come first. ${FormatOperation.Write} is the default.
37
-
38
- ${FormatOperation.Write}: overwrites files to fix formatting.
39
- ${FormatOperation.Check}: checks the formatting, does not write to files
40
-
41
- file extensions:
42
- If only specific file extensions should be formatted, add the "${exports.filesMarkerArg}"
43
- argument to this command. All following arguments will be treated
44
- as file extensions to be formatted.
45
- For example, the following command will overwrite files
46
- (because ${FormatOperation.Write} is the default operation) only if they have the
47
- extension ".md" or ".json":
48
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${exports.filesMarkerArg} md json
49
-
50
- Prettier flags:
51
- Any other arguments encountered between the operation command (if provided)
52
- and the "${exports.filesMarkerArg}" marker are treated as extra arguments to Prettier and
53
- will be passed along.
54
-
55
- examples:
56
- checks formatting for files:
57
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check}
58
- checks formatting only for .md files:
59
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md
60
- checks formatting only for .md and .json files:
61
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md json
62
- fixes formatting for files:
63
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format}
64
- or
65
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write}
66
- examples with extra Prettier flags:
67
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} --ignore-path .prettierignore
68
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore
69
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore ${exports.filesMarkerArg} md json`,
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
+ },
70
81
  configKeys: [
71
82
  config_key_1.ConfigKey.Prettier,
72
83
  config_key_1.ConfigKey.PrettierIgnore,
@@ -80,7 +91,9 @@ const prettierPath = (0, virmator_repo_paths_1.getNpmBinPath)('prettier');
80
91
  async function runFormatCommand(inputs) {
81
92
  const args = extractFormatArgs(inputs.rawArgs);
82
93
  const operationFlag = args.operation === FormatOperation.Check ? '--check' : '--write';
83
- const prettierCommand = `${prettierPath} --color ${args.prettierFlags.join(' ')} \"./**/*.+(${args.fileExtensions.join('|')})\" ${operationFlag}`;
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}`;
84
97
  const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(prettierCommand, inputs, {
85
98
  stdoutFilter: (stdout) => stdout
86
99
  // only relevant when running the check command
@@ -89,6 +102,7 @@ async function runFormatCommand(inputs) {
89
102
  .replace('All matched files use Prettier code style!\n', ''),
90
103
  });
91
104
  return {
105
+ command: prettierCommand,
92
106
  success: !results.error,
93
107
  };
94
108
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runInitCommand = exports.initCommandImplementation = void 0;
4
- const fs_extra_1 = require("fs-extra");
4
+ const promises_1 = require("fs/promises");
5
5
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
6
6
  const cli_flags_1 = require("../../cli-util/cli-flags");
7
7
  const config_key_1 = require("../../config/config-key");
@@ -11,9 +11,17 @@ const format_command_1 = require("./format.command");
11
11
  const update_all_configs_command_1 = require("./update-all-configs.command");
12
12
  exports.initCommandImplementation = {
13
13
  commandName: cli_command_name_1.CliCommandName.Test,
14
- description: `Init everything, including package.json scripts.
14
+ description: {
15
+ sections: [
16
+ {
17
+ title: '',
18
+ content: `Init everything, including package.json scripts.
15
19
  If no package.json file is found, one is created and initialized.
16
20
  Pass --force to this command to overwrite current package.json scripts.`,
21
+ },
22
+ ],
23
+ examples: [],
24
+ },
17
25
  implementation: runInitCommand,
18
26
  configFlagSupport: {
19
27
  [cli_flags_1.CliFlagName.NoWriteConfig]: true,
@@ -35,12 +43,13 @@ async function runInitCommand(inputs) {
35
43
  error = catchError;
36
44
  }
37
45
  return {
46
+ command: undefined,
38
47
  success: !error,
39
48
  };
40
49
  }
41
50
  exports.runInitCommand = runInitCommand;
42
51
  async function updatePackageJson(repoDir) {
43
52
  const repoPackageJsonPath = (0, config_paths_1.getRepoConfigFilePath)(config_key_1.ConfigKey.PackageJson, false);
44
- const finalPackageJsonContents = (0, config_read_1.readUpdatedVirmatorConfigFile)(config_key_1.ConfigKey.PackageJson, repoDir, false);
45
- await (0, fs_extra_1.writeFile)(repoPackageJsonPath, finalPackageJsonContents);
53
+ const finalPackageJsonContents = await (0, config_read_1.readUpdatedVirmatorConfigFile)(config_key_1.ConfigKey.PackageJson, repoDir, false);
54
+ await (0, promises_1.writeFile)(repoPackageJsonPath, finalPackageJsonContents);
46
55
  }
@@ -8,7 +8,15 @@ const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
8
8
  const config_key_1 = require("../../config/config-key");
9
9
  exports.spellcheckCommandImplementation = {
10
10
  commandName: cli_command_name_1.CliCommandName.SpellCheck,
11
- description: `Spellcheck code with cspell. Any extra arguments are passed directly to cspell.`,
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
+ },
12
20
  implementation: runSpellcheckCommand,
13
21
  configKeys: [config_key_1.ConfigKey.Cspell],
14
22
  configFlagSupport: {
@@ -20,6 +28,7 @@ async function runSpellcheckCommand(inputs) {
20
28
  const spellcheckCommand = `${cSpellPath} --color "{*,.*,**/{.*,*}/**/{.*,*}}" ${inputs.rawArgs.join(' ')}`;
21
29
  const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(spellcheckCommand, inputs);
22
30
  return {
31
+ command: spellcheckCommand,
23
32
  success: !results.error,
24
33
  };
25
34
  }
@@ -2,44 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runTestCommand = exports.testCommandImplementation = void 0;
4
4
  const node_1 = require("augment-vir/dist/node");
5
+ const jest_config_path_1 = require("../../../exportable-jest-config/jest-config-path");
5
6
  const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
6
7
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
7
8
  const cli_flags_1 = require("../../cli-util/cli-flags");
8
9
  const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
9
- const compile_command_1 = require("./compile.command");
10
10
  exports.testCommandImplementation = {
11
11
  commandName: cli_command_name_1.CliCommandName.Test,
12
- description: `Test all .test.js files with test-vir.
13
- By default this command tests all .test.js files in dist that are not
14
- .type.test.js files. To override this behavior, pass in a list of files or a
15
- quoted glob which will be expanded by the package test-vir itself.
16
-
17
- examples:
18
- virmator test ./path/to/single/file.js
19
- virmator test "./**/single-file.js"
20
- virmator test "./dist/**/!(*.type).test.js"
21
- `,
12
+ description: {
13
+ sections: [
14
+ {
15
+ title: '',
16
+ 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.`,
17
+ },
18
+ ],
19
+ examples: [
20
+ { title: '', content: `virmator test ./path/to/single/file.js` },
21
+ { title: '', content: `virmator test "./**/single-file.js"` },
22
+ { title: '', content: `virmator test "./dist/**/!(*.type).test.js"` },
23
+ ],
24
+ },
22
25
  implementation: runTestCommand,
23
26
  configFlagSupport: {
24
27
  [cli_flags_1.CliFlagName.NoWriteConfig]: false,
25
28
  },
26
29
  };
27
- const testVirPath = (0, virmator_repo_paths_1.getNpmBinPath)('test-vir');
30
+ const jestPath = (0, virmator_repo_paths_1.getNpmBinPath)('jest');
28
31
  async function runTestCommand(inputs) {
29
- const compileResult = await (0, compile_command_1.runCompileCommand)({ ...inputs, rawArgs: [] });
30
- if (!compileResult.success) {
31
- return compileResult;
32
- }
33
- const args = inputs.rawArgs.length
34
- ? (0, node_1.interpolationSafeWindowsPath)(inputs.rawArgs.join(' '))
35
- : `\"./dist/**/!(*.type).test.js\"`;
36
- const testCommand = `${testVirPath} ${args}`;
37
- const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(testCommand, inputs, {
38
- stdoutFilter: (logString) =>
39
- // weird looking hex codes here are for color codes from test-vir
40
- logString.replace('\x1B[1m\x1B[32mAll tests passed.\x1B[0m\n', ''),
41
- });
32
+ const args = inputs.rawArgs.length ? inputs.rawArgs.join(' ') : '';
33
+ const configPath = args.includes('--config ') || args.includes('-c ')
34
+ ? ''
35
+ : `--config ${(0, node_1.interpolationSafeWindowsPath)(jest_config_path_1.virmatorJestConfigFilePath)}`;
36
+ const testCommand = `${jestPath} ${configPath} ${args}`;
37
+ const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(testCommand, inputs);
42
38
  return {
39
+ command: testCommand,
43
40
  success: !results.error,
44
41
  };
45
42
  }
@@ -13,19 +13,28 @@ const exampleFlags = [
13
13
  ];
14
14
  exports.updateAllConfigsCommandImplementation = {
15
15
  commandName: cli_command_name_1.CliCommandName.UpdateAllConfigs,
16
- description: `Update all config files.
17
-
18
- This command accepts a list of config file keys as arguments.
19
- If no arguments are given, this command copies all config files.
20
-
21
- list of possible arguments:
22
- ${(0, node_1.getEnumTypedValues)(config_key_1.ConfigKey).join('\n ')}
23
-
24
- examples:
25
- update all config files:
26
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs}
27
- update only ${(0, node_1.joinWithFinalConjunction)(exampleFlags)} files:
28
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs} ${exampleFlags.join(' ')}`,
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, node_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, node_1.joinWithFinalConjunction)(exampleFlags)} files`,
34
+ content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs} ${exampleFlags.join(' ')}`,
35
+ },
36
+ ],
37
+ },
29
38
  implementation: runUpdateAllConfigsCommand,
30
39
  configFlagSupport: {
31
40
  [cli_flags_1.CliFlagName.NoWriteConfig]: false,
@@ -13,20 +13,28 @@ const exampleFlags = [
13
13
  ];
14
14
  exports.updateBareConfigsCommandImplementation = {
15
15
  commandName: cli_command_name_1.CliCommandName.UpdateBareConfigs,
16
- description: `Update config files that aren't used in any ${package_name_1.packageName} commands,
17
- like GitHub actions tests or VS Code Settings.
18
-
19
- This command accepts a list of bare config file keys as arguments.
20
- If no arguments are given, this command copies all the bare config files.
21
-
22
- list of possible arguments:
23
- ${(0, node_1.getEnumTypedValues)(config_key_1.BareConfigKey).join('\n ')}
24
-
25
- examples:
26
- update all bare config files:
27
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs}
28
- update only ${(0, node_1.joinWithFinalConjunction)(exampleFlags)} files:
29
- ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs} ${exampleFlags.join(' ')}`,
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, node_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, node_1.joinWithFinalConjunction)(exampleFlags)} files`,
34
+ content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs} ${exampleFlags.join(' ')},`,
35
+ },
36
+ ],
37
+ },
30
38
  implementation: runUpdateBareConfigsCommand,
31
39
  configFlagSupport: {
32
40
  [cli_flags_1.CliFlagName.NoWriteConfig]: false,
@@ -11,13 +11,12 @@ const extendable_config_1 = require("../config/extendable-config");
11
11
  const all_cli_commands_1 = require("./all-cli-commands");
12
12
  const cli_command_1 = require("./cli-command");
13
13
  async function runCommand(command, commandInput) {
14
- var _a, _b;
15
14
  const commandImplementation = all_cli_commands_1.allCliCommands[command];
16
15
  const cliFlags = (0, cli_flags_1.fillInCliFlags)(commandInput.rawCliFlags);
17
16
  const defaultFlagSupport = {
18
17
  [cli_flags_1.CliFlagName.Silent]: true,
19
18
  [cli_flags_1.CliFlagName.Help]: true,
20
- [cli_flags_1.CliFlagName.ExtendableConfig]: !!((_a = commandImplementation.configKeys) === null || _a === void 0 ? void 0 : _a.some((configKey) => (0, extendable_config_1.isExtendableConfig)(configKey))),
19
+ [cli_flags_1.CliFlagName.ExtendableConfig]: !!commandImplementation.configKeys?.some((configKey) => (0, extendable_config_1.isExtendableConfig)(configKey)),
21
20
  };
22
21
  const unsupportedFlagsInUse = (0, all_cli_commands_1.getUnsupportedFlags)(cliFlags, {
23
22
  ...defaultFlagSupport,
@@ -26,7 +25,7 @@ async function runCommand(command, commandInput) {
26
25
  if (command !== cli_command_name_1.CliCommandName.Help && unsupportedFlagsInUse.length) {
27
26
  throw new cli_command_error_1.VirmatorCliCommandError(cli_messages_1.cliErrorMessages.unsupportedCliFlag(command, unsupportedFlagsInUse));
28
27
  }
29
- if (((_b = commandImplementation.configKeys) === null || _b === void 0 ? void 0 : _b.length) && !cliFlags[cli_flags_1.CliFlagName.NoWriteConfig]) {
28
+ if (commandImplementation.configKeys?.length && !cliFlags[cli_flags_1.CliFlagName.NoWriteConfig]) {
30
29
  await Promise.all(commandImplementation.configKeys.map(async (configKey) => {
31
30
  const copyOutput = await (0, copy_config_1.copyConfig)({
32
31
  configKey: configKey,
@@ -1,9 +1,9 @@
1
1
  /** These config files are not used by any virmator commands but they are still helpful. */
2
2
  export declare enum BareConfigKey {
3
3
  GitAttributes = "GitAttributes",
4
- GitHubActionsTest = "GitHubActionsTest",
5
- GitHubActionsTaggedRelease = "GitHubActionsTaggedRelease",
6
4
  GitHubActionsPrerelease = "GitHubActionsPrerelease",
5
+ GitHubActionsTaggedRelease = "GitHubActionsTaggedRelease",
6
+ GitHubActionsTest = "GitHubActionsTest",
7
7
  GitIgnore = "GitIgnore",
8
8
  NpmIgnore = "NpmIgnore",
9
9
  VsCodeSettings = "VsCodeSettings"
@@ -11,23 +11,23 @@ export declare enum BareConfigKey {
11
11
  /** These are config files used by virmator commands. */
12
12
  export declare enum CommandConfigKey {
13
13
  Cspell = "Cspell",
14
- Prettier = "Prettier",
15
- TsConfig = "TsConfig",
16
14
  PackageJson = "PackageJson",
17
- PrettierIgnore = "PrettierIgnore"
15
+ Prettier = "Prettier",
16
+ PrettierIgnore = "PrettierIgnore",
17
+ TsConfig = "TsConfig"
18
18
  }
19
19
  export declare const ConfigKey: {
20
20
  GitAttributes: BareConfigKey.GitAttributes;
21
- GitHubActionsTest: BareConfigKey.GitHubActionsTest;
22
- GitHubActionsTaggedRelease: BareConfigKey.GitHubActionsTaggedRelease;
23
21
  GitHubActionsPrerelease: BareConfigKey.GitHubActionsPrerelease;
22
+ GitHubActionsTaggedRelease: BareConfigKey.GitHubActionsTaggedRelease;
23
+ GitHubActionsTest: BareConfigKey.GitHubActionsTest;
24
24
  GitIgnore: BareConfigKey.GitIgnore;
25
25
  NpmIgnore: BareConfigKey.NpmIgnore;
26
26
  VsCodeSettings: BareConfigKey.VsCodeSettings;
27
27
  Cspell: CommandConfigKey.Cspell;
28
- Prettier: CommandConfigKey.Prettier;
29
- TsConfig: CommandConfigKey.TsConfig;
30
28
  PackageJson: CommandConfigKey.PackageJson;
29
+ Prettier: CommandConfigKey.Prettier;
31
30
  PrettierIgnore: CommandConfigKey.PrettierIgnore;
31
+ TsConfig: CommandConfigKey.TsConfig;
32
32
  };
33
33
  export declare type ConfigKey = CommandConfigKey | BareConfigKey;
@@ -5,9 +5,9 @@ exports.ConfigKey = exports.CommandConfigKey = exports.BareConfigKey = void 0;
5
5
  var BareConfigKey;
6
6
  (function (BareConfigKey) {
7
7
  BareConfigKey["GitAttributes"] = "GitAttributes";
8
- BareConfigKey["GitHubActionsTest"] = "GitHubActionsTest";
9
- BareConfigKey["GitHubActionsTaggedRelease"] = "GitHubActionsTaggedRelease";
10
8
  BareConfigKey["GitHubActionsPrerelease"] = "GitHubActionsPrerelease";
9
+ BareConfigKey["GitHubActionsTaggedRelease"] = "GitHubActionsTaggedRelease";
10
+ BareConfigKey["GitHubActionsTest"] = "GitHubActionsTest";
11
11
  BareConfigKey["GitIgnore"] = "GitIgnore";
12
12
  BareConfigKey["NpmIgnore"] = "NpmIgnore";
13
13
  BareConfigKey["VsCodeSettings"] = "VsCodeSettings";
@@ -16,9 +16,9 @@ var BareConfigKey;
16
16
  var CommandConfigKey;
17
17
  (function (CommandConfigKey) {
18
18
  CommandConfigKey["Cspell"] = "Cspell";
19
- CommandConfigKey["Prettier"] = "Prettier";
20
- CommandConfigKey["TsConfig"] = "TsConfig";
21
19
  CommandConfigKey["PackageJson"] = "PackageJson";
20
+ CommandConfigKey["Prettier"] = "Prettier";
22
21
  CommandConfigKey["PrettierIgnore"] = "PrettierIgnore";
22
+ CommandConfigKey["TsConfig"] = "TsConfig";
23
23
  })(CommandConfigKey = exports.CommandConfigKey || (exports.CommandConfigKey = {}));
24
24
  exports.ConfigKey = { ...CommandConfigKey, ...BareConfigKey };
@@ -15,9 +15,9 @@ var DifferentConfigPathTypes;
15
15
  const configFileMap = {
16
16
  [config_key_1.ConfigKey.Cspell]: '.cspell.json',
17
17
  [config_key_1.ConfigKey.GitAttributes]: '.gitattributes',
18
- [config_key_1.ConfigKey.GitHubActionsTest]: (0, path_1.join)('.github', 'workflows', 'virmator-tests.yml'),
19
18
  [config_key_1.ConfigKey.GitHubActionsPrerelease]: (0, path_1.join)('.github', 'workflows', 'virmator-prerelease.yml'),
20
19
  [config_key_1.ConfigKey.GitHubActionsTaggedRelease]: (0, path_1.join)('.github', 'workflows', 'virmator-tagged-release.yml'),
20
+ [config_key_1.ConfigKey.GitHubActionsTest]: (0, path_1.join)('.github', 'workflows', 'virmator-tests.yml'),
21
21
  [config_key_1.ConfigKey.GitIgnore]: {
22
22
  virmator: (0, path_1.join)(virmator_repo_paths_1.relativeSeparateConfigsDir, 'gitignore.txt'),
23
23
  repo: '.gitignore',
@@ -44,7 +44,6 @@ async function readUpdatedVirmatorConfigFile(configKey, repoDir, extendable) {
44
44
  }
45
45
  exports.readUpdatedVirmatorConfigFile = readUpdatedVirmatorConfigFile;
46
46
  async function updateVirmatorConfig(configKey, repoDir, extendable) {
47
- var _a;
48
47
  const virmatorConfigContents = await readVirmatorConfigFile(configKey, extendable);
49
48
  switch (configKey) {
50
49
  // in these special cases we want to merge the config files with what's already in the repo
@@ -77,7 +76,7 @@ async function updateVirmatorConfig(configKey, repoDir, extendable) {
77
76
  ...repoPackageJson,
78
77
  scripts: {
79
78
  ...defaultPackageJson.scripts,
80
- ...((_a = repoPackageJson.scripts) !== null && _a !== void 0 ? _a : {}),
79
+ ...(repoPackageJson.scripts ?? {}),
81
80
  },
82
81
  });
83
82
  }
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createDefaultPackageJson = void 0;
7
- const fs_extra_1 = require("fs-extra");
7
+ const promises_1 = require("fs/promises");
8
8
  const path_1 = require("path");
9
9
  const simple_git_1 = __importDefault(require("simple-git"));
10
10
  const config_key_1 = require("./config-key");
11
11
  const config_paths_1 = require("./config-paths");
12
12
  async function createDefaultPackageJson(repoDir) {
13
- const virmatorPackageJson = JSON.parse((await (0, fs_extra_1.readFile)((0, config_paths_1.getVirmatorConfigFilePath)(config_key_1.ConfigKey.PackageJson, false))).toString());
13
+ const virmatorPackageJson = JSON.parse((await (0, promises_1.readFile)((0, config_paths_1.getVirmatorConfigFilePath)(config_key_1.ConfigKey.PackageJson, false))).toString());
14
14
  const gitProperties = await getGitProperties(repoDir);
15
15
  return {
16
16
  ...virmatorPackageJson,
@@ -4,9 +4,9 @@ exports.VirmatorCliCommandError = void 0;
4
4
  const node_1 = require("augment-vir/dist/node");
5
5
  const cli_command_name_1 = require("../cli/cli-util/cli-command-name");
6
6
  class VirmatorCliCommandError extends Error {
7
+ name = 'VirmatorCliCommandError';
7
8
  constructor(message) {
8
9
  super(`${message}\nExpected one of the following: ${(0, node_1.getEnumTypedValues)(cli_command_name_1.CliCommandName).join(', ')}`);
9
- this.name = 'VirmatorCliCommandError';
10
10
  }
11
11
  }
12
12
  exports.VirmatorCliCommandError = VirmatorCliCommandError;
@@ -4,9 +4,9 @@ exports.CliFlagError = void 0;
4
4
  const node_1 = require("augment-vir/dist/node");
5
5
  const cli_flags_1 = require("../cli/cli-util/cli-flags");
6
6
  class CliFlagError extends Error {
7
+ name = 'CliFlagError';
7
8
  constructor(invalidFlags) {
8
9
  super(`Invalid flags given: ${invalidFlags.join(',')}\nValid flags: ${(0, node_1.getObjectTypedKeys)(cli_flags_1.defaultCliFlags).join(',')}`);
9
- this.name = 'CliFlagError';
10
10
  }
11
11
  }
12
12
  exports.CliFlagError = CliFlagError;
@@ -2,9 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigFileError = void 0;
4
4
  class ConfigFileError extends Error {
5
- constructor() {
6
- super(...arguments);
7
- this.name = 'ConfigFileError';
8
- }
5
+ name = 'ConfigFileError';
9
6
  }
10
7
  exports.ConfigFileError = ConfigFileError;
@@ -0,0 +1 @@
1
+ export declare const virmatorJestConfigFilePath: string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.virmatorJestConfigFilePath = void 0;
4
+ const path_1 = require("path");
5
+ const virmator_repo_paths_1 = require("../file-paths/virmator-repo-paths");
6
+ exports.virmatorJestConfigFilePath = (0, path_1.join)(virmator_repo_paths_1.virmatorRootDir, virmator_repo_paths_1.relativeSeparateConfigsDir, 'jest', 'jest-config.ts');
@@ -0,0 +1,3 @@
1
+ import { InitialOptionsTsJest } from 'ts-jest';
2
+ export declare const virmatorJestConfig: InitialOptionsTsJest;
3
+ export default virmatorJestConfig;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.virmatorJestConfig = void 0;
4
+ const path_1 = require("path");
5
+ const cwd = process.cwd();
6
+ exports.virmatorJestConfig = {
7
+ preset: 'ts-jest',
8
+ testEnvironment: 'node',
9
+ verbose: false,
10
+ rootDir: cwd,
11
+ silent: false,
12
+ modulePathIgnorePatterns: ['.*.type.test.ts$'],
13
+ roots: [(0, path_1.join)(cwd, 'src')],
14
+ setupFilesAfterEnv: [(0, path_1.join)(__dirname, 'jest-setup.ts')],
15
+ globals: {
16
+ 'ts-jest': {
17
+ tsconfig: (0, path_1.join)(cwd, 'tsconfig.json'),
18
+ diagnostics: {
19
+ warnOnly: true,
20
+ ignoreCodes: ['TS151001'],
21
+ },
22
+ },
23
+ },
24
+ };
25
+ exports.default = exports.virmatorJestConfig;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const console_1 = require("@jest/console");
4
+ function simpleFormatter(type, message) {
5
+ const consoleIndent = ' ';
6
+ return message
7
+ .split(/\n/)
8
+ .map((line) => consoleIndent + line)
9
+ .join('\n');
10
+ }
11
+ global.console = new console_1.CustomConsole(process.stdout, process.stderr, simpleFormatter);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNpmBinPath = exports.relativeSeparateConfigsDir = exports.extenderConfigsDir = exports.virmatorDistDir = exports.virmatorRootDir = void 0;
4
4
  const node_1 = require("augment-vir/dist/node");
5
- const fs_extra_1 = require("fs-extra");
5
+ const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  exports.virmatorRootDir = __dirname.replace(/(?:src|node_modules\/dist|dist).*/, '');
8
8
  exports.virmatorDistDir = (0, path_1.join)(exports.virmatorRootDir, 'dist');
@@ -11,7 +11,7 @@ exports.relativeSeparateConfigsDir = 'separate-configs';
11
11
  const virmatorNodeBin = (0, path_1.join)(exports.virmatorRootDir, 'node_modules', '.bin');
12
12
  function getNpmBinPath(command) {
13
13
  const virmatorBinPath = (0, path_1.join)(virmatorNodeBin, command);
14
- const actualBinPath = (0, fs_extra_1.existsSync)(virmatorBinPath)
14
+ const actualBinPath = (0, fs_1.existsSync)(virmatorBinPath)
15
15
  ? virmatorBinPath
16
16
  : (0, path_1.join)(exports.virmatorRootDir, '..', '.bin', command);
17
17
  return (0, node_1.interpolationSafeWindowsPath)(actualBinPath);