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
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.testCommandDefinition = 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");
8
- exports.testCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
9
- commandName: 'test',
10
- subCommandDescriptions: {},
11
- }, ({ commandName }) => {
12
- return {
13
- sections: [
14
- {
15
- title: '',
16
- content: `Test all .test.ts files with Mocha and Chai. By default this command tests all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "spec" property in .mocharc.js.`,
17
- },
18
- {
19
- title: '',
20
- content: `This command is meant to run Node.js tests. For running web-based testing, see the test-web command.`,
21
- },
22
- {
23
- title: '',
24
- content: `Note that the below single file examples only work because the base Mocha config from ${package_name_1.packageName} is setup to handle them. (So if you don't use that config, the examples may not work properly.)`,
25
- },
26
- ],
27
- examples: [
28
- {
29
- title: 'Test all .test.ts and .test.tsx files',
30
- content: `${package_name_1.packageName} ${commandName}`,
31
- },
32
- {
33
- title: 'Test a single file',
34
- content: `${package_name_1.packageName} ${commandName} ./path/to/single/file.js`,
35
- },
36
- {
37
- title: 'Test multiple files',
38
- content: `${package_name_1.packageName} ${commandName} "./**/single-file.js"`,
39
- },
40
- ],
41
- };
42
- }, async (inputs) => {
43
- const mochaPath = (0, virmator_package_paths_1.getNpmBinPath)('mocha');
44
- const joinedArgs = inputs.filteredInputArgs.join(' ');
45
- const useDefaultConfigArgs = !joinedArgs.includes('--config');
46
- const configString = useDefaultConfigArgs ? '--config .mocharc.js ' : '';
47
- const testCommand = `${mochaPath} ${configString} ${joinedArgs}`;
48
- const results = await (0, run_shell_command_1.runVirmatorShellCommand)(testCommand, inputs);
49
- return {
50
- fullExecutedCommand: testCommand,
51
- success: !results.exitCode,
52
- };
53
- });
@@ -1,4 +0,0 @@
1
- export declare enum CliFlagName {
2
- Help = "--help",
3
- Silent = "--silent"
4
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CliFlagName = void 0;
4
- var CliFlagName;
5
- (function (CliFlagName) {
6
- CliFlagName["Help"] = "--help";
7
- CliFlagName["Silent"] = "--silent";
8
- })(CliFlagName = exports.CliFlagName || (exports.CliFlagName = {}));
@@ -1,4 +0,0 @@
1
- import { CliFlagName } from './cli-flag-name';
2
- export declare type CliFlagValues = Readonly<Record<CliFlagName, boolean>>;
3
- export declare function fillInCliFlagValues(inputFlags?: Readonly<Partial<CliFlagValues>> | undefined): Readonly<Required<CliFlagValues>>;
4
- export declare const cliFlagDescriptions: Record<CliFlagName, string>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cliFlagDescriptions = exports.fillInCliFlagValues = void 0;
4
- const cli_flag_name_1 = require("./cli-flag-name");
5
- const defaultCliFlagValues = {
6
- [cli_flag_name_1.CliFlagName.Help]: false,
7
- [cli_flag_name_1.CliFlagName.Silent]: false,
8
- };
9
- function fillInCliFlagValues(inputFlags = {}) {
10
- return {
11
- ...defaultCliFlagValues,
12
- ...inputFlags,
13
- };
14
- }
15
- exports.fillInCliFlagValues = fillInCliFlagValues;
16
- exports.cliFlagDescriptions = {
17
- [cli_flag_name_1.CliFlagName.Silent]: 'Turns off most logging.',
18
- [cli_flag_name_1.CliFlagName.Help]: 'Prints this help message.',
19
- };
@@ -1,6 +0,0 @@
1
- export declare const cliErrorMessages: {
2
- missingCliCommand: string;
3
- commandNotFound(commandName: string): string;
4
- missingConfigFile(commandName: string, configFileNames: string[]): string;
5
- };
6
- export declare function getResultMessage(commandName: string, success: boolean): string;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getResultMessage = exports.cliErrorMessages = void 0;
4
- const cli_color_1 = require("./cli-color");
5
- exports.cliErrorMessages = {
6
- missingCliCommand: `Missing a command for virmator. Run "virmator help" for details.`,
7
- commandNotFound(commandName) {
8
- return `No command found by the name of "${commandName}"`;
9
- },
10
- missingConfigFile(commandName, configFileNames) {
11
- return `Failed to run "${commandName}". Missing the following config file(s): ${configFileNames.join(', ')}`;
12
- },
13
- };
14
- function getResultMessage(commandName, success) {
15
- const specificColor = success ? cli_color_1.Color.Success : cli_color_1.Color.Fail;
16
- const specificPhrase = success ? 'succeeded' : 'failed';
17
- return `${cli_color_1.Color.Bold}${specificColor}${commandName} ${specificPhrase}.${cli_color_1.Color.Reset}`;
18
- }
19
- exports.getResultMessage = getResultMessage;
package/dist/cli/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare function cli(rawArgs: string[]): Promise<void>;
package/dist/cli/cli.js DELETED
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.cli = void 0;
5
- const augment_vir_1 = require("augment-vir");
6
- const virmator_invalid_command_error_1 = require("../errors/virmator-invalid-command.error");
7
- const virmator_invalid_flags_error_1 = require("../errors/virmator-invalid-flags.error");
8
- const all_cli_command_definitions_1 = require("./all-cli-command-definitions");
9
- const cli_flag_name_1 = require("./cli-flags/cli-flag-name");
10
- const cli_messages_1 = require("./cli-messages");
11
- const parse_arguments_1 = require("./parse-arguments");
12
- const run_cli_command_1 = require("./run-cli-command");
13
- async function cli(rawArgs) {
14
- try {
15
- const { flags, invalidFlags, args, commandName } = (0, parse_arguments_1.parseArguments)(rawArgs);
16
- const cliCommandName = flags[cli_flag_name_1.CliFlagName.Help] ? all_cli_command_definitions_1.builtInCommandNames.help : commandName;
17
- if (!cliCommandName) {
18
- throw new virmator_invalid_command_error_1.VirmatorInvalidCommandError(cli_messages_1.cliErrorMessages.missingCliCommand, Object.values(all_cli_command_definitions_1.builtInCommandNames));
19
- }
20
- if (invalidFlags.length) {
21
- throw new virmator_invalid_flags_error_1.VirmatorInvalidFlagsError(invalidFlags);
22
- }
23
- const shouldLogStatus = cliCommandName !== all_cli_command_definitions_1.builtInCommandNames.help && !flags[cli_flag_name_1.CliFlagName.Silent];
24
- if (shouldLogStatus) {
25
- console.info(`running ${cliCommandName}...`);
26
- }
27
- const commandDefinition = all_cli_command_definitions_1.allCliCommandDefinitions[cliCommandName];
28
- if (!commandDefinition) {
29
- throw new Error(cli_messages_1.cliErrorMessages.commandNotFound(cliCommandName));
30
- }
31
- const commandResult = await (0, run_cli_command_1.runCommand)(commandDefinition, {
32
- otherArgs: args,
33
- cliFlags: flags,
34
- repoDir: process.cwd(),
35
- });
36
- if (shouldLogStatus) {
37
- console.info((0, cli_messages_1.getResultMessage)(cliCommandName, commandResult.success));
38
- }
39
- process.exit(commandResult.success ? 0 : 1);
40
- }
41
- catch (error) {
42
- console.error((0, augment_vir_1.extractErrorMessage)(error));
43
- process.exit(1);
44
- }
45
- }
46
- exports.cli = cli;
47
- // To run the cli from within this repo itself, use the following bash command:
48
- // node dist/cli/cli.js
49
- if (require.main === module) {
50
- cli(process.argv.slice(2));
51
- }
52
- else {
53
- throw new Error(`${__filename} should not be imported directly. To run the cli from within the Virmator repo itself, use the following bash command: node dist/cli/cli.js`);
54
- }
@@ -1,2 +0,0 @@
1
- import { ConfigFileCopyCallback } from './config-files';
2
- export declare const combineTextConfig: ConfigFileCopyCallback;
@@ -1,133 +0,0 @@
1
- import { createDefaultPackageJson } from './create-default-package-json';
2
- export declare type ConfigFileCopyCallback = (copyFromContents: string, existingConfigContents: string, repoDir: string) => string | Promise<string>;
3
- export declare type ConfigFileDefinition = {
4
- path: string;
5
- copyToPath?: string;
6
- /**
7
- * Name to rename the config file to when copying it to a repo.
8
- *
9
- * Example: this is needed for the .npmignore config file because npm won't publish .npmignore,
10
- * so it's saved in virmator configs as npmignore.txt. Upon copying, we must then rename it.
11
- */
12
- copyName?: string;
13
- /**
14
- * Used to modify the file contents before copying it over to a repo. The returned string should
15
- * be the new file contents.
16
- */
17
- updateCallback?: ConfigFileCopyCallback;
18
- canBeUpdated?: boolean;
19
- };
20
- export declare function doesCopyToConfigPathExist(configFileDefinition: ConfigFileDefinition, repoDir: string): boolean;
21
- export declare function getCopyToPath(configFileDefinition: ConfigFileDefinition, repoDir: string): string;
22
- export declare const configFiles: {
23
- /** Base config for spellchecking, contains a huge list of preset words defined within virmator. */
24
- cSpellBase: {
25
- path: string;
26
- canBeUpdated: true;
27
- };
28
- /**
29
- * Config for spellchecking. Extends the base config. Allows individual repos to add custom
30
- * words while still using the virmator defined list of words.
31
- */
32
- cSpell: {
33
- path: string;
34
- };
35
- /** Primarily fixes line ending issues on Windows machines. */
36
- gitAttributes: {
37
- path: string;
38
- updateCallback: ConfigFileCopyCallback;
39
- };
40
- gitIgnore: {
41
- path: string;
42
- copyName: string;
43
- updateCallback: ConfigFileCopyCallback;
44
- };
45
- /** Provides a GitHub Actions workflow for building deploying to GitHub Pages */
46
- gitHubActionsGhPagesBuild: {
47
- path: string;
48
- copyToPath: string;
49
- canBeUpdated: true;
50
- };
51
- /** Provides a GitHub Actions workflow for bundling releases for each version tag. */
52
- gitHubActionsTaggedRelease: {
53
- path: string;
54
- copyToPath: string;
55
- canBeUpdated: true;
56
- };
57
- /** Provides a GitHub Actions workflow to run all tests. */
58
- gitHubActionsTest: {
59
- path: string;
60
- copyToPath: string;
61
- canBeUpdated: true;
62
- };
63
- /** Ignores files for npm publish. */
64
- npmIgnore: {
65
- path: string;
66
- copyName: string;
67
- updateCallback: ConfigFileCopyCallback;
68
- };
69
- /** Provides some defaults for package.json properties. */
70
- packageJson: {
71
- path: string;
72
- updateCallback: typeof createDefaultPackageJson;
73
- };
74
- /** All the base configs for prettier. */
75
- prettierBase: {
76
- path: string;
77
- canBeUpdated: true;
78
- };
79
- /** Prettier config that inherits the base config and can be changed on a per-repo basis. */
80
- prettier: {
81
- path: string;
82
- };
83
- /** Ignore certain files in the formatting process. */
84
- prettierIgnore: {
85
- path: string;
86
- updateCallback: ConfigFileCopyCallback;
87
- };
88
- /** Provides base configuration for ts config. */
89
- tsConfigBase: {
90
- path: string;
91
- canBeUpdated: true;
92
- };
93
- /**
94
- * Configuration for the TypeScript compiler. Based on the base configuration above and can be
95
- * configured on a per-repo basis without interfering with the virmator config.
96
- */
97
- tsConfig: {
98
- path: string;
99
- };
100
- /** VS Code settings. */
101
- vsCodeSettings: {
102
- path: string;
103
- };
104
- /** Global types. Specifically used at the moment to block un-imported test functions. */
105
- globalTypes: {
106
- path: string;
107
- };
108
- mochaBase: {
109
- path: string;
110
- canBeUpdated: true;
111
- };
112
- mocha: {
113
- path: string;
114
- };
115
- viteBase: {
116
- path: string;
117
- canBeUpdated: true;
118
- };
119
- viteReloadPlugin: {
120
- path: string;
121
- canBeUpdated: true;
122
- };
123
- vite: {
124
- path: string;
125
- };
126
- webTestRunnerBase: {
127
- path: string;
128
- canBeUpdated: true;
129
- };
130
- webTestRunner: {
131
- path: string;
132
- };
133
- };
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configFiles = exports.getCopyToPath = exports.doesCopyToConfigPathExist = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const regexp_1 = require("../../augments/regexp");
7
- const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
8
- const combine_text_config_1 = require("./combine-text-config");
9
- const create_default_package_json_1 = require("./create-default-package-json");
10
- function doesCopyToConfigPathExist(configFileDefinition, repoDir) {
11
- return (0, fs_1.existsSync)(getCopyToPath(configFileDefinition, repoDir));
12
- }
13
- exports.doesCopyToConfigPathExist = doesCopyToConfigPathExist;
14
- function getCopyToPath(configFileDefinition, repoDir) {
15
- const replacedDir = configFileDefinition.copyToPath
16
- ? (0, path_1.join)(repoDir, configFileDefinition.copyToPath, (0, path_1.basename)(configFileDefinition.path))
17
- : configFileDefinition.path.replace(virmator_package_paths_1.virmatorConfigsDir, repoDir);
18
- if (configFileDefinition.copyName) {
19
- const replacedFileName = replacedDir.replace(new RegExp(`${(0, regexp_1.sanitizeStringForRegExpCreation)((0, path_1.basename)(replacedDir))}$`), configFileDefinition.copyName);
20
- return replacedFileName;
21
- }
22
- else {
23
- return replacedDir;
24
- }
25
- }
26
- exports.getCopyToPath = getCopyToPath;
27
- exports.configFiles = ((input) => input)({
28
- /** Base config for spellchecking, contains a huge list of preset words defined within virmator. */
29
- cSpellBase: {
30
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, '.cspell-base.json'),
31
- canBeUpdated: true,
32
- },
33
- /**
34
- * Config for spellchecking. Extends the base config. Allows individual repos to add custom
35
- * words while still using the virmator defined list of words.
36
- */
37
- cSpell: {
38
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, '.cspell.json'),
39
- },
40
- /** Primarily fixes line ending issues on Windows machines. */
41
- gitAttributes: {
42
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, '.gitattributes'),
43
- updateCallback: combine_text_config_1.combineTextConfig,
44
- },
45
- gitIgnore: {
46
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, 'gitignore.txt'),
47
- copyName: '.gitignore',
48
- updateCallback: combine_text_config_1.combineTextConfig,
49
- },
50
- /** Provides a GitHub Actions workflow for building deploying to GitHub Pages */
51
- gitHubActionsGhPagesBuild: {
52
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.gitHubWorkflows, 'virmator-build-for-gh-pages.yml'),
53
- copyToPath: (0, path_1.join)('.github', 'workflows'),
54
- canBeUpdated: true,
55
- },
56
- /** Provides a GitHub Actions workflow for bundling releases for each version tag. */
57
- gitHubActionsTaggedRelease: {
58
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.gitHubWorkflows, 'virmator-tagged-release.yml'),
59
- copyToPath: (0, path_1.join)('.github', 'workflows'),
60
- canBeUpdated: true,
61
- },
62
- /** Provides a GitHub Actions workflow to run all tests. */
63
- gitHubActionsTest: {
64
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.gitHubWorkflows, 'virmator-tests.yml'),
65
- copyToPath: (0, path_1.join)('.github', 'workflows'),
66
- canBeUpdated: true,
67
- },
68
- /** Ignores files for npm publish. */
69
- npmIgnore: {
70
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, 'npmignore.txt'),
71
- copyName: '.npmignore',
72
- updateCallback: combine_text_config_1.combineTextConfig,
73
- },
74
- /** Provides some defaults for package.json properties. */
75
- packageJson: {
76
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, 'package.json'),
77
- updateCallback: create_default_package_json_1.createDefaultPackageJson,
78
- },
79
- /** All the base configs for prettier. */
80
- prettierBase: {
81
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'prettierrc-base.js'),
82
- canBeUpdated: true,
83
- },
84
- /** Prettier config that inherits the base config and can be changed on a per-repo basis. */
85
- prettier: {
86
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, '.prettierrc.js'),
87
- },
88
- /** Ignore certain files in the formatting process. */
89
- prettierIgnore: {
90
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, '.prettierignore'),
91
- updateCallback: combine_text_config_1.combineTextConfig,
92
- },
93
- /** Provides base configuration for ts config. */
94
- tsConfigBase: {
95
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'tsconfig-base.json'),
96
- canBeUpdated: true,
97
- },
98
- /**
99
- * Configuration for the TypeScript compiler. Based on the base configuration above and can be
100
- * configured on a per-repo basis without interfering with the virmator config.
101
- */
102
- tsConfig: {
103
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, 'tsconfig.json'),
104
- },
105
- /** VS Code settings. */
106
- vsCodeSettings: {
107
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.vsCode, 'settings.json'),
108
- },
109
- /** Global types. Specifically used at the moment to block un-imported test functions. */
110
- globalTypes: {
111
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.src, 'global.d.ts'),
112
- },
113
- mochaBase: {
114
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'mocharc-base.js'),
115
- canBeUpdated: true,
116
- },
117
- mocha: {
118
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigsDir, '.mocharc.js'),
119
- },
120
- viteBase: {
121
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'vite-base.ts'),
122
- canBeUpdated: true,
123
- },
124
- viteReloadPlugin: {
125
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'vite-always-reload-plugin.ts'),
126
- canBeUpdated: true,
127
- },
128
- vite: {
129
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'vite.config.ts'),
130
- },
131
- webTestRunnerBase: {
132
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'web-test-runner-base.mjs'),
133
- canBeUpdated: true,
134
- },
135
- webTestRunner: {
136
- path: (0, path_1.join)(virmator_package_paths_1.virmatorConfigs.dotVirmator, 'web-test-runner.config.mjs'),
137
- },
138
- });
@@ -1 +0,0 @@
1
- export declare function isRunningFromGlobalInstallation(): Promise<boolean>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRunningFromGlobalInstallation = void 0;
4
- const node_only_1 = require("augment-vir/dist/cjs/node-only");
5
- const virmator_package_paths_1 = require("../file-paths/virmator-package-paths");
6
- async function isRunningFromGlobalInstallation() {
7
- const npmGlobalPath = (await (0, node_only_1.runShellCommand)(`npm root -g`)).stdout;
8
- return virmator_package_paths_1.virmatorPackageDir.startsWith(npmGlobalPath);
9
- }
10
- exports.isRunningFromGlobalInstallation = isRunningFromGlobalInstallation;
@@ -1,8 +0,0 @@
1
- import { CliFlagValues } from './cli-flags/cli-flag-values';
2
- export declare type ParsedArguments = {
3
- flags: CliFlagValues;
4
- invalidFlags: string[];
5
- args: string[];
6
- commandName: string | undefined;
7
- };
8
- export declare function parseArguments(args: string[]): Required<ParsedArguments>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseArguments = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const all_cli_command_definitions_1 = require("./all-cli-command-definitions");
6
- const cli_flag_name_1 = require("./cli-flags/cli-flag-name");
7
- const cli_flag_values_1 = require("./cli-flags/cli-flag-values");
8
- function parseArguments(args) {
9
- const { inputFlags, invalidFlags, otherArgs, commandName } = args.reduce((accum, currentArg) => {
10
- if (currentArg in all_cli_command_definitions_1.allCliCommandDefinitions && !accum.commandName) {
11
- accum.commandName = currentArg;
12
- }
13
- else if (currentArg.startsWith('--')) {
14
- if ((0, augment_vir_1.isEnumValue)(currentArg, cli_flag_name_1.CliFlagName)) {
15
- accum.inputFlags[currentArg] = true;
16
- }
17
- else if (!accum.commandName) {
18
- accum.invalidFlags.push(currentArg);
19
- }
20
- else {
21
- accum.otherArgs.push(currentArg);
22
- }
23
- }
24
- else {
25
- accum.otherArgs.push(currentArg);
26
- }
27
- return accum;
28
- }, {
29
- inputFlags: {},
30
- invalidFlags: [],
31
- otherArgs: [],
32
- commandName: undefined,
33
- });
34
- const cliFlags = (0, cli_flag_values_1.fillInCliFlagValues)(inputFlags);
35
- return {
36
- flags: cliFlags,
37
- invalidFlags,
38
- args: otherArgs,
39
- commandName,
40
- };
41
- }
42
- exports.parseArguments = parseArguments;
@@ -1,13 +0,0 @@
1
- import { CliCommandDefinition, CliCommandExecutorOutput } from './cli-command/define-cli-command';
2
- import { CliFlagValues } from './cli-flags/cli-flag-values';
3
- export declare type RunCommandInputs = {
4
- cliFlags: CliFlagValues;
5
- otherArgs: string[];
6
- repoDir: string;
7
- };
8
- export declare function runCommand(commandDefinition: CliCommandDefinition, runCommandInputs: RunCommandInputs): Promise<CliCommandExecutorOutput>;
9
- export declare type ExtractSubCommandsOutput<T> = {
10
- subCommands: T[];
11
- filteredArgs: string[];
12
- };
13
- export declare function extractSubCommands<T>(allArgs: string[], availableSubCommands: T[]): ExtractSubCommandsOutput<T>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractSubCommands = exports.runCommand = void 0;
4
- const array_1 = require("../augments/array");
5
- const logging_1 = require("../logging");
6
- const all_cli_command_definitions_1 = require("./all-cli-command-definitions");
7
- const cli_flag_name_1 = require("./cli-flags/cli-flag-name");
8
- async function runCommand(commandDefinition, runCommandInputs) {
9
- if (runCommandInputs.cliFlags[cli_flag_name_1.CliFlagName.Help]) {
10
- commandDefinition = all_cli_command_definitions_1.builtInCliCommandDefinitions.help;
11
- }
12
- const logging = runCommandInputs.cliFlags[cli_flag_name_1.CliFlagName.Silent] &&
13
- commandDefinition.commandName !== all_cli_command_definitions_1.builtInCommandNames.help
14
- ? logging_1.noCliLogging
15
- : {
16
- stdout: (input) => {
17
- console.info(input.replace(/\n$/, ''));
18
- },
19
- stderr: (input) => {
20
- console.error(input.replace(/\n$/, ''));
21
- },
22
- };
23
- const { subCommands: inputSubCommands, filteredArgs: filteredInputArgs } = extractSubCommands(runCommandInputs.otherArgs, commandDefinition.allAvailableSubCommands);
24
- const commandInputs = {
25
- logging,
26
- repoDir: process.cwd(),
27
- inputSubCommands,
28
- filteredInputArgs,
29
- };
30
- const commandResult = await commandDefinition.executor(commandInputs);
31
- return commandResult;
32
- }
33
- exports.runCommand = runCommand;
34
- function extractSubCommands(allArgs, availableSubCommands) {
35
- let stillInSubCommands = true;
36
- return allArgs.reduce((accum, currentArg) => {
37
- if (stillInSubCommands) {
38
- if ((0, array_1.isInTypedArray)(currentArg, availableSubCommands)) {
39
- accum.subCommands.push(currentArg);
40
- }
41
- else {
42
- stillInSubCommands = false;
43
- accum.filteredArgs.push(currentArg);
44
- }
45
- }
46
- else {
47
- accum.filteredArgs.push(currentArg);
48
- }
49
- return accum;
50
- }, { subCommands: [], filteredArgs: [] });
51
- }
52
- exports.extractSubCommands = extractSubCommands;
@@ -1,28 +0,0 @@
1
- import { ArrayElement, Overwrite } from 'augment-vir';
2
- import { ShellOutput } from 'augment-vir/dist/cjs/node-only';
3
- import { CliCommandDefinition } from './cli-command/define-cli-command';
4
- declare type RunCliCommandInputs<T extends CliCommandDefinition> = {
5
- commandDefinition: T;
6
- subCommand?: ArrayElement<T['allAvailableSubCommands']> | undefined;
7
- extraArgs?: string[];
8
- cwd: string;
9
- debug?: boolean;
10
- filesShouldNotChange?: boolean;
11
- recursiveFileReading?: boolean;
12
- };
13
- export declare function runCliCommandForTest<T extends CliCommandDefinition>(inputs: RunCliCommandInputs<T>, expectations?: Omit<Overwrite<ShellOutput, {
14
- stderr: string | RegExp;
15
- stdout: string | RegExp;
16
- }>, 'error'>, message?: string): Promise<{
17
- results: ShellOutput;
18
- dirFileNamesBefore: string[];
19
- dirFileNamesAfter: string[];
20
- dirFileContentsBefore: import("../augments/fs").DirContents;
21
- dirFileContentsAfter: import("../augments/fs").DirContents;
22
- changedFiles: Partial<{
23
- [x: string]: any;
24
- }>;
25
- newFiles: string[];
26
- durationMs: number;
27
- }>;
28
- export {};