virmator 1.1.14 → 1.3.1

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 (35) hide show
  1. package/.cspell.json +16 -2
  2. package/.github/workflows/virmator-tagged-release.yml +27 -0
  3. package/dist/cli/cli-util/cli-flags.js +3 -3
  4. package/dist/cli/cli-util/update-configs.js +3 -3
  5. package/dist/cli/commands/all-cli-commands.js +4 -4
  6. package/dist/cli/commands/implementations/compile.command.js +2 -2
  7. package/dist/cli/commands/implementations/format.command.js +4 -5
  8. package/dist/cli/commands/implementations/spellcheck.command.js +2 -2
  9. package/dist/cli/commands/implementations/test.command.js +3 -4
  10. package/dist/cli/commands/implementations/update-all-configs.command.js +3 -4
  11. package/dist/cli/commands/implementations/update-bare-configs.command.js +3 -4
  12. package/dist/cli/config/copy-config.js +3 -3
  13. package/dist/cli/config/extendable-config.js +3 -3
  14. package/dist/errors/cli-command-error.js +2 -2
  15. package/dist/errors/cli-flag-error.js +2 -2
  16. package/dist/file-paths/virmator-repo-paths.js +2 -2
  17. package/dist/file-paths/virmator-test-repos-paths.js +2 -2
  18. package/extender-configs/tsconfig.json +1 -1
  19. package/package.json +15 -14
  20. package/separate-configs/npmignore.txt +9 -5
  21. package/separate-configs/package.json +2 -2
  22. package/dist/augments/bash.d.ts +0 -44
  23. package/dist/augments/bash.js +0 -134
  24. package/dist/augments/error.d.ts +0 -4
  25. package/dist/augments/error.js +0 -14
  26. package/dist/augments/file-system.d.ts +0 -10
  27. package/dist/augments/file-system.js +0 -31
  28. package/dist/augments/fs-extra.d.ts +0 -1
  29. package/dist/augments/fs-extra.js +0 -13
  30. package/dist/augments/object.d.ts +0 -6
  31. package/dist/augments/object.js +0 -44
  32. package/dist/augments/string.d.ts +0 -3
  33. package/dist/augments/string.js +0 -31
  34. package/dist/augments/type.d.ts +0 -7
  35. package/dist/augments/type.js +0 -2
package/.cspell.json CHANGED
@@ -1,5 +1,13 @@
1
1
  {
2
- "ignorePaths": [".DS_Store", ".git/", "dist/", "node_modules/", "package-lock.json"],
2
+ "ignorePaths": [
3
+ ".DS_Store",
4
+ ".git/",
5
+ "dist/",
6
+ "node_modules/",
7
+ "package-lock.json",
8
+ ".cspell-base.json",
9
+ ".cspell.json"
10
+ ],
3
11
  "version": "0.2",
4
12
  "words": [
5
13
  "accum",
@@ -15,16 +23,21 @@
15
23
  "derp",
16
24
  "derpy",
17
25
  "electrovir",
26
+ "entrypoints",
18
27
  "esbenp",
19
28
  "gitattributes",
20
29
  "globstar",
21
- "globstar",
30
+ "locationchange",
31
+ "marvinpinto",
32
+ "nojekyll",
22
33
  "npmignore",
23
34
  "packagejson",
24
35
  "parens",
25
36
  "pdfs",
26
37
  "prettierignore",
27
38
  "prettierrc",
39
+ "pushstate",
40
+ "replacestate",
28
41
  "repo's",
29
42
  "repos",
30
43
  "rgba",
@@ -32,6 +45,7 @@
32
45
  "stylelintrc",
33
46
  "subcommand",
34
47
  "thingie",
48
+ "threejs",
35
49
  "transpiled",
36
50
  "transpiling",
37
51
  "typeof",
@@ -0,0 +1,27 @@
1
+ name: 'tagged-release'
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ tagged-release:
10
+ name: 'Tagged Release'
11
+ runs-on: 'ubuntu-latest'
12
+
13
+ steps:
14
+ - uses: actions/checkout@v1
15
+ - name: Use Node.js 14.x
16
+ uses: actions/setup-node@v1
17
+ with:
18
+ node-version: 14.x
19
+ - name: run test
20
+ run: |
21
+ npm ci
22
+ npm run test:full
23
+
24
+ - uses: 'marvinpinto/action-automatic-releases@latest'
25
+ with:
26
+ repo_token: '${{ secrets.GITHUB_TOKEN }}'
27
+ prerelease: false
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractArguments = exports.fillInCliFlags = exports.flagDescriptions = exports.defaultCliFlags = exports.CliFlagName = void 0;
4
- const object_1 = require("../../augments/object");
4
+ const node_1 = require("augment-vir/dist/node");
5
5
  const cli_command_name_1 = require("./cli-command-name");
6
6
  var CliFlagName;
7
7
  (function (CliFlagName) {
@@ -31,11 +31,11 @@ function fillInCliFlags(inputFlags) {
31
31
  exports.fillInCliFlags = fillInCliFlags;
32
32
  function extractArguments(args) {
33
33
  const { inputFlags, invalidFlags, otherArgs, command } = args.reduce((accum, currentArg) => {
34
- if ((0, object_1.isEnumValue)(currentArg, cli_command_name_1.CliCommandName) && !accum.command) {
34
+ if ((0, node_1.isEnumValue)(currentArg, cli_command_name_1.CliCommandName) && !accum.command) {
35
35
  accum.command = currentArg;
36
36
  }
37
37
  else if (currentArg.startsWith('--')) {
38
- if ((0, object_1.isEnumValue)(currentArg, CliFlagName)) {
38
+ if ((0, node_1.isEnumValue)(currentArg, CliFlagName)) {
39
39
  accum.inputFlags[currentArg] = true;
40
40
  }
41
41
  else if (!accum.command) {
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateConfigs = void 0;
4
+ const node_1 = require("augment-vir/dist/node");
4
5
  const fs_extra_1 = require("fs-extra");
5
- const object_1 = require("../../augments/object");
6
6
  const format_command_1 = require("../commands/implementations/format.command");
7
7
  const copy_config_1 = require("../config/copy-config");
8
8
  const extendable_config_1 = require("../config/extendable-config");
9
9
  const cli_flags_1 = require("./cli-flags");
10
10
  async function updateConfigs(rawArgs, cliFlags, configKeysEnum, repoDir) {
11
- const inputConfigFiles = (0, object_1.filterToEnumValues)(rawArgs, configKeysEnum);
11
+ const inputConfigFiles = (0, node_1.filterToEnumValues)(rawArgs, configKeysEnum);
12
12
  const configFilesToCopy = inputConfigFiles.length
13
13
  ? inputConfigFiles
14
- : (0, object_1.getEnumTypedValues)(configKeysEnum);
14
+ : (0, node_1.getEnumTypedValues)(configKeysEnum);
15
15
  const errors = [];
16
16
  const writtenFiles = [];
17
17
  const failedFiles = [];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.allCliCommands = exports.runHelpCommand = exports.helpImplementation = exports.getUnsupportedFlags = void 0;
4
- const object_1 = require("../../augments/object");
4
+ const node_1 = require("augment-vir/dist/node");
5
5
  const package_name_1 = require("../../package-name");
6
6
  const cli_color_1 = require("../cli-util/cli-color");
7
7
  const cli_command_name_1 = require("../cli-util/cli-command-name");
@@ -26,7 +26,7 @@ function createUnImplementedCommand(commandName) {
26
26
  };
27
27
  }
28
28
  function getUnsupportedFlags(currentFlags, flagSupport) {
29
- return (0, object_1.getObjectTypedKeys)(currentFlags).filter((currentFlag) => {
29
+ return (0, node_1.getObjectTypedKeys)(currentFlags).filter((currentFlag) => {
30
30
  if (currentFlags[currentFlag]) {
31
31
  return !flagSupport[currentFlag];
32
32
  }
@@ -50,13 +50,13 @@ exports.helpImplementation = {
50
50
  },
51
51
  };
52
52
  function runHelpCommand() {
53
- const flagsMessage = (0, object_1.getEnumTypedValues)(cli_flags_1.CliFlagName)
53
+ const flagsMessage = (0, node_1.getEnumTypedValues)(cli_flags_1.CliFlagName)
54
54
  .sort()
55
55
  .map((flagName) => {
56
56
  return `${cli_color_1.Color.Bold}${cli_color_1.Color.Info} ${flagName}${cli_color_1.Color.Reset}: ${cli_flags_1.flagDescriptions[flagName].trim()}`;
57
57
  })
58
58
  .join('\n ');
59
- const commandsMessage = (0, object_1.getEnumTypedValues)(cli_command_name_1.CliCommandName)
59
+ const commandsMessage = (0, node_1.getEnumTypedValues)(cli_command_name_1.CliCommandName)
60
60
  .sort()
61
61
  .map((commandName) => {
62
62
  return `${cli_color_1.Color.Bold}${cli_color_1.Color.Info} ${commandName}${cli_color_1.Color.Reset}: ${exports.allCliCommands[commandName].description.trim()}`;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCompileCommand = exports.compileImplementation = void 0;
4
- const bash_1 = require("../../../augments/bash");
4
+ const node_1 = require("augment-vir/dist/node");
5
5
  const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
6
6
  const package_name_1 = require("../../../package-name");
7
7
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
@@ -30,7 +30,7 @@ async function runCompileCommand({ rawArgs, repoDir, }) {
30
30
  const compileCommand = `${resetCommand}${tscPath} --pretty ${rawArgs
31
31
  .map((arg) => `"${arg}"`)
32
32
  .join(' ')}`;
33
- const results = await (0, bash_1.runBashCommand)(compileCommand, repoDir);
33
+ const results = await (0, node_1.runBashCommand)(compileCommand, repoDir);
34
34
  const keepError = !(((_a = results.error) === null || _a === void 0 ? void 0 : _a.message.trim().startsWith('Command failed:')) &&
35
35
  ((_b = results.error) === null || _b === void 0 ? void 0 : _b.message.trim().split('\n').length) <= 1);
36
36
  return {
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractFormatArgs = exports.runFormatCommand = exports.formatImplementation = exports.filesMarkerArg = exports.defaultFormatArgs = exports.FormatOperation = void 0;
4
- const bash_1 = require("../../../augments/bash");
5
- const object_1 = require("../../../augments/object");
4
+ const node_1 = require("augment-vir/dist/node");
6
5
  const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
7
6
  const package_name_1 = require("../../../package-name");
8
7
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
@@ -69,7 +68,7 @@ async function runFormatCommand({ rawArgs, repoDir, }) {
69
68
  const args = extractFormatArgs(rawArgs);
70
69
  const operationFlag = args.operation === FormatOperation.Check ? '--check' : '--write';
71
70
  const prettierCommand = `${prettierPath} --color ${args.prettierFlags.join(' ')} \"./**/*.+(${args.fileExtensions.join('|')})\" ${operationFlag}`;
72
- const results = await (0, bash_1.runBashCommand)(prettierCommand, repoDir);
71
+ const results = await (0, node_1.runBashCommand)(prettierCommand, repoDir);
73
72
  const keepError = !((_a = results.error) === null || _a === void 0 ? void 0 : _a.message.includes('Forgot to run Prettier?'));
74
73
  return {
75
74
  success: !results.error,
@@ -82,11 +81,11 @@ async function runFormatCommand({ rawArgs, repoDir, }) {
82
81
  exports.runFormatCommand = runFormatCommand;
83
82
  function extractFormatArgs(rawArgs) {
84
83
  let addingFileExtensions = false;
85
- const operation = (0, object_1.isEnumValue)(rawArgs[0], FormatOperation)
84
+ const operation = (0, node_1.isEnumValue)(rawArgs[0], FormatOperation)
86
85
  ? rawArgs[0]
87
86
  : FormatOperation.Write;
88
87
  const extractedArgs = rawArgs.reduce((accum, currentRawArg, index) => {
89
- if (index === 0 && (0, object_1.isEnumValue)(rawArgs[index], FormatOperation)) {
88
+ if (index === 0 && (0, node_1.isEnumValue)(rawArgs[index], FormatOperation)) {
90
89
  return accum;
91
90
  }
92
91
  else if (currentRawArg === exports.filesMarkerArg) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runSpellcheckCommand = exports.spellcheckCommandImplementation = void 0;
4
- const bash_1 = require("../../../augments/bash");
4
+ const node_1 = require("augment-vir/dist/node");
5
5
  const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
6
6
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
7
7
  const cli_flags_1 = require("../../cli-util/cli-flags");
@@ -19,7 +19,7 @@ const cSpellPath = (0, virmator_repo_paths_1.getNpmBinPath)('cspell');
19
19
  async function runSpellcheckCommand({ rawArgs, repoDir, }) {
20
20
  var _a;
21
21
  const spellcheckCommand = `${cSpellPath} --color "{*,.*,**/{.*,*}/**/{.*,*}}" ${rawArgs.join(' ')}`;
22
- const results = await (0, bash_1.runBashCommand)(spellcheckCommand, repoDir);
22
+ const results = await (0, node_1.runBashCommand)(spellcheckCommand, repoDir);
23
23
  const keepError = !((_a = results.error) === null || _a === void 0 ? void 0 : _a.message.includes('CSpell: Files checked'));
24
24
  return {
25
25
  /** Stdout for cspell is always an explanation of the unknown words, when they exist. */
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runTestCommand = exports.testCommandImplementation = void 0;
4
- const bash_1 = require("../../../augments/bash");
5
- const string_1 = require("../../../augments/string");
4
+ const node_1 = require("augment-vir/dist/node");
6
5
  const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
7
6
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
8
7
  const cli_flags_1 = require("../../cli-util/cli-flags");
@@ -32,10 +31,10 @@ async function runTestCommand({ rawArgs, repoDir, cliFlags, }) {
32
31
  return compileResult;
33
32
  }
34
33
  const args = rawArgs.length
35
- ? (0, string_1.interpolationSafeWindowsPath)(rawArgs.join(' '))
34
+ ? (0, node_1.interpolationSafeWindowsPath)(rawArgs.join(' '))
36
35
  : `\"./dist/**/!(*.type).test.js\"`;
37
36
  const testCommand = `${testVirPath} ${args}`;
38
- const results = await (0, bash_1.runBashCommand)(testCommand, repoDir);
37
+ const results = await (0, node_1.runBashCommand)(testCommand, repoDir);
39
38
  const keepError = !(((_a = results.error) === null || _a === void 0 ? void 0 : _a.message.match(/\d+\s+tests?\s+failed/)) &&
40
39
  ((_b = results.error) === null || _b === void 0 ? void 0 : _b.message.trim().split('\n').length) <= 2);
41
40
  return {
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runUpdateAllConfigsCommand = exports.updateAllConfigsCommandImplementation = void 0;
4
- const object_1 = require("../../../augments/object");
5
- const string_1 = require("../../../augments/string");
4
+ const node_1 = require("augment-vir/dist/node");
6
5
  const package_name_1 = require("../../../package-name");
7
6
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
8
7
  const cli_flags_1 = require("../../cli-util/cli-flags");
@@ -17,12 +16,12 @@ exports.updateAllConfigsCommandImplementation = {
17
16
  If no arguments are given, this command copies all config files.
18
17
 
19
18
  list of possible arguments:
20
- ${(0, object_1.getEnumTypedValues)(config_key_1.ConfigKey).join('\n ')}
19
+ ${(0, node_1.getEnumTypedValues)(config_key_1.ConfigKey).join('\n ')}
21
20
 
22
21
  examples:
23
22
  update all config files:
24
23
  ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs}
25
- update only ${(0, string_1.joinWithFinalConjunction)(exampleFlags)} files:
24
+ update only ${(0, node_1.joinWithFinalConjunction)(exampleFlags)} files:
26
25
  ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs} ${exampleFlags.join(' ')}`,
27
26
  implementation: runUpdateAllConfigsCommand,
28
27
  configFlagSupport: {
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runUpdateBareConfigsCommand = exports.updateBareConfigsCommandImplementation = void 0;
4
- const object_1 = require("../../../augments/object");
5
- const string_1 = require("../../../augments/string");
4
+ const node_1 = require("augment-vir/dist/node");
6
5
  const package_name_1 = require("../../../package-name");
7
6
  const cli_command_name_1 = require("../../cli-util/cli-command-name");
8
7
  const cli_flags_1 = require("../../cli-util/cli-flags");
@@ -18,12 +17,12 @@ exports.updateBareConfigsCommandImplementation = {
18
17
  If no arguments are given, this command copies all the bare config files.
19
18
 
20
19
  list of possible arguments:
21
- ${(0, object_1.getEnumTypedValues)(config_key_1.BareConfigKey).join('\n ')}
20
+ ${(0, node_1.getEnumTypedValues)(config_key_1.BareConfigKey).join('\n ')}
22
21
 
23
22
  examples:
24
23
  update all bare config files:
25
24
  ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs}
26
- update only ${(0, string_1.joinWithFinalConjunction)(exampleFlags)} files:
25
+ update only ${(0, node_1.joinWithFinalConjunction)(exampleFlags)} files:
27
26
  ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs} ${exampleFlags.join(' ')}`,
28
27
  implementation: runUpdateBareConfigsCommand,
29
28
  configFlagSupport: {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyConfig = void 0;
4
+ const node_1 = require("augment-vir/dist/node");
4
5
  const fs_extra_1 = require("fs-extra");
5
6
  const path_1 = require("path");
6
- const file_system_1 = require("../../augments/file-system");
7
7
  const config_file_error_1 = require("../../errors/config-file-error");
8
8
  const cli_flags_1 = require("../cli-util/cli-flags");
9
9
  const config_paths_1 = require("./config-paths");
@@ -39,7 +39,7 @@ async function copyConfig({ configKey, forceExtendableConfig, repoDir, }) {
39
39
  if (!repoConfigExists) {
40
40
  // if extender config file does not exist, create it
41
41
  const extenderContents = await (0, config_read_1.readUpdatedVirmatorConfigFile)(configKey, repoDir, true);
42
- await (0, file_system_1.writeFileAndDir)(repoConfigPath, extenderContents);
42
+ await (0, node_1.writeFileAndDir)(repoConfigPath, extenderContents);
43
43
  }
44
44
  const repoExtendableConfigPath = (0, path_1.join)(repoDir, (0, extendable_config_1.getExtendableBaseConfigName)(configKey));
45
45
  const repoExtendableConfigExists = (0, fs_extra_1.existsSync)(repoExtendableConfigPath);
@@ -89,7 +89,7 @@ async function copyConfig({ configKey, forceExtendableConfig, repoDir, }) {
89
89
  outputFilePath = repoConfigPath;
90
90
  }
91
91
  if (shouldWriteConfig) {
92
- await (0, file_system_1.writeFileAndDir)(outputFilePath, virmatorConfigContents);
92
+ await (0, node_1.writeFileAndDir)(outputFilePath, virmatorConfigContents);
93
93
  }
94
94
  return {
95
95
  logs,
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isConfigExtending = exports.isExtendableConfig = exports.getExtendableBaseConfigName = exports.ExtendableConfig = void 0;
4
- const object_1 = require("../../augments/object");
4
+ const node_1 = require("augment-vir/dist/node");
5
5
  const config_key_1 = require("./config-key");
6
6
  const extendableConfigFileMap = {
7
7
  [config_key_1.ConfigKey.Prettier]: '.prettierrc-base.js',
8
8
  [config_key_1.ConfigKey.Cspell]: '.cspell-base.json',
9
9
  [config_key_1.ConfigKey.TsConfig]: 'tsconfig-base.json',
10
10
  };
11
- exports.ExtendableConfig = (0, object_1.getObjectTypedKeys)(extendableConfigFileMap).reduce((accum, key) => {
11
+ exports.ExtendableConfig = (0, node_1.getObjectTypedKeys)(extendableConfigFileMap).reduce((accum, key) => {
12
12
  accum[key] = key;
13
13
  return accum;
14
14
  }, {});
@@ -23,7 +23,7 @@ function isExtendableConfig(ConfigKey) {
23
23
  if (!ConfigKey) {
24
24
  return false;
25
25
  }
26
- return (0, object_1.isEnumValue)(ConfigKey, exports.ExtendableConfig);
26
+ return (0, node_1.isEnumValue)(ConfigKey, exports.ExtendableConfig);
27
27
  }
28
28
  exports.isExtendableConfig = isExtendableConfig;
29
29
  function isConfigExtending(key, contents) {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VirmatorCliCommandError = void 0;
4
- const object_1 = require("../augments/object");
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
7
  constructor(message) {
8
- super(`${message}\nExpected one of the following: ${(0, object_1.getEnumTypedValues)(cli_command_name_1.CliCommandName).join(', ')}`);
8
+ super(`${message}\nExpected one of the following: ${(0, node_1.getEnumTypedValues)(cli_command_name_1.CliCommandName).join(', ')}`);
9
9
  this.name = 'VirmatorCliCommandError';
10
10
  }
11
11
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CliFlagError = void 0;
4
- const object_1 = require("../augments/object");
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
7
  constructor(invalidFlags) {
8
- super(`Invalid flags given: ${invalidFlags.join(',')}\nValid flags: ${(0, object_1.getObjectTypedKeys)(cli_flags_1.defaultCliFlags).join(',')}`);
8
+ super(`Invalid flags given: ${invalidFlags.join(',')}\nValid flags: ${(0, node_1.getObjectTypedKeys)(cli_flags_1.defaultCliFlags).join(',')}`);
9
9
  this.name = 'CliFlagError';
10
10
  }
11
11
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNpmBinPath = exports.relativeSeparateConfigsDir = exports.extenderConfigsDir = exports.virmatorDistDir = exports.virmatorRootDir = void 0;
4
+ const node_1 = require("augment-vir/dist/node");
4
5
  const fs_extra_1 = require("fs-extra");
5
6
  const path_1 = require("path");
6
- const string_1 = require("../augments/string");
7
7
  exports.virmatorRootDir = __dirname.replace(/(?:src|node_modules\/dist|dist).*/, '');
8
8
  exports.virmatorDistDir = (0, path_1.join)(exports.virmatorRootDir, 'dist');
9
9
  exports.extenderConfigsDir = (0, path_1.join)(exports.virmatorRootDir, 'extender-configs');
@@ -14,6 +14,6 @@ function getNpmBinPath(command) {
14
14
  const actualBinPath = (0, fs_extra_1.existsSync)(virmatorBinPath)
15
15
  ? virmatorBinPath
16
16
  : (0, path_1.join)(exports.virmatorRootDir, '..', '.bin', command);
17
- return (0, string_1.interpolationSafeWindowsPath)(actualBinPath);
17
+ return (0, node_1.interpolationSafeWindowsPath)(actualBinPath);
18
18
  }
19
19
  exports.getNpmBinPath = getNpmBinPath;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateAllConfigsTestPaths = exports.updateBareConfigsTestPaths = exports.spellcheckTestPaths = exports.testTestPaths = exports.testCompilePaths = exports.testFormatPaths = exports.getCommandTestRepoDir = exports.createNodeModulesSymLinkForTests = void 0;
4
+ const node_1 = require("augment-vir/dist/node");
4
5
  const path_1 = require("path");
5
- const file_system_1 = require("../augments/file-system");
6
6
  const cli_command_name_1 = require("../cli/cli-util/cli-command-name");
7
7
  const virmator_repo_paths_1 = require("./virmator-repo-paths");
8
8
  async function createNodeModulesSymLinkForTests(dir) {
9
9
  const symlinkPath = (0, path_1.join)(dir, 'node_modules');
10
- await (0, file_system_1.createSymLink)((0, path_1.join)(virmator_repo_paths_1.virmatorRootDir, 'node_modules'), symlinkPath);
10
+ await (0, node_1.createSymLink)((0, path_1.join)(virmator_repo_paths_1.virmatorRootDir, 'node_modules'), symlinkPath);
11
11
  return symlinkPath;
12
12
  }
13
13
  exports.createNodeModulesSymLinkForTests = createNodeModulesSymLinkForTests;
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "tsconfig-base.json"
2
+ "extends": "./tsconfig-base.json"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virmator",
3
- "version": "1.1.14",
3
+ "version": "1.3.1",
4
4
  "description": "Handle all the stuffs in one package.",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/electrovir/virmator",
@@ -19,36 +19,37 @@
19
19
  "bin": "dist/cli/cli.js",
20
20
  "scripts": {
21
21
  "compile": "rm -rf dist && tsc && chmod +x dist/cli/cli.js",
22
+ "format": "npm run format:base -- --write",
22
23
  "format:base": "prettier \"./**/*.+(ts|json|html|css|md|js)\"",
23
24
  "format:check": "npm run format:base -- --check",
24
- "format": "npm run format:base -- --write",
25
25
  "prepublishOnly": "npm install && npm run test:full",
26
+ "sanitize": "npm run compile && node dist/sanitizer/sanitize-for-test-file-cli.js",
26
27
  "sanitize:all": "./bulk-sanitize.sh files/downloads",
27
28
  "sanitize:no-compile": "node dist/sanitizer/sanitize-for-test-file-cli.js",
28
- "sanitize": "npm run compile && node dist/sanitizer/sanitize-for-test-file-cli.js",
29
29
  "spellcheck": "cspell \"{*,.*,**/{.*,*}/**/{.*,*}}\" --exclude \"test-repos/spellcheck/invalid-spellcheck-repo/**/*\" --exclude \"extender-configs\"",
30
+ "test": "npm run compile && test-vir \"./dist/**/!(*.type).test.js\"",
30
31
  "test:file": "ts-node ./scripts/test-specific-file.ts",
31
32
  "test:full": "npm run test && npm run spellcheck -- --no-progress && npm run format:check",
32
- "test:help": "npm run compile && node dist/cli/cli.js --help",
33
- "test": "npm run compile && test-vir \"./dist/**/!(*.type).test.js\""
33
+ "test:help": "npm run compile && node dist/cli/cli.js --help"
34
34
  },
35
35
  "dependencies": {
36
36
  "ansi-styles": "5.2.0",
37
- "cspell": "^5.9.0",
37
+ "augment-vir": "^1.1.0",
38
+ "cspell": "^5.12.3",
38
39
  "fs-extra": "^10.0.0",
39
- "prettier": "^2.4.0",
40
+ "prettier": "^2.4.1",
40
41
  "prettier-plugin-jsdoc": "^0.3.24",
41
- "prettier-plugin-organize-imports": "^2.3.3",
42
- "prettier-plugin-packagejson": "^2.2.11",
42
+ "prettier-plugin-organize-imports": "^2.3.4",
43
+ "prettier-plugin-packagejson": "^2.2.13",
43
44
  "prettier-plugin-sort-json": "^0.0.2",
44
- "simple-git": "^2.45.1",
45
+ "simple-git": "^2.46.0",
45
46
  "test-vir": "^0.2.1",
46
- "typescript": "^4.4.2"
47
+ "typescript": "^4.4.4"
47
48
  },
48
49
  "devDependencies": {
49
- "@types/fs-extra": "^9.0.12",
50
- "@types/node": "^16.9.1",
51
- "ts-node": "^10.2.1"
50
+ "@types/fs-extra": "^9.0.13",
51
+ "@types/node": "^16.10.4",
52
+ "ts-node": "^10.3.0"
52
53
  },
53
54
  "engines": {
54
55
  "node": ">=12",
@@ -1,15 +1,19 @@
1
1
  .cspell-base.json
2
2
  .cspell.json
3
3
  .gitattributes
4
- .github
4
+ .github/
5
5
  .gitignore
6
6
  .prettierignore
7
7
  .prettierrc.js
8
- .vscode
8
+ .vscode/
9
9
  *.test.d.ts
10
10
  *.test.js
11
- scripts
12
- src
13
- test-repos
11
+ dist/test/
12
+ scripts/
13
+ snowpack.config.js
14
+ snowpack.config.mjs
15
+ src/
16
+ static/
17
+ test-repos/
14
18
  tsconfig-base.json
15
19
  tsconfig.json
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "scripts": {
3
+ "format": "virmator format write",
3
4
  "prepublishOnly": "npm run test:full",
4
5
  "spellcheck": "virmator spellcheck",
5
6
  "test": "virmator test",
6
- "test:full": "npm test && npm run spellcheck && virmator format check",
7
- "format": "virmator format write"
7
+ "test:full": "npm test && npm run spellcheck && virmator format check"
8
8
  }
9
9
  }
@@ -1,44 +0,0 @@
1
- /// <reference types="node" />
2
- import { ChildProcess } from 'child_process';
3
- import { EventEmitter } from 'stream';
4
- export declare type BashOutput = {
5
- error: undefined | Error;
6
- stderr: string;
7
- stdout: string;
8
- exitCode: number | undefined;
9
- exitSignal: NodeJS.Signals | undefined;
10
- };
11
- export declare const BashEmitterEvent: {
12
- readonly stdout: "stdout";
13
- readonly stderr: "stderr";
14
- readonly done: "done";
15
- readonly error: "error";
16
- };
17
- export declare type BashEmitterEventKey = typeof BashEmitterEvent[keyof typeof BashEmitterEvent];
18
- export declare type BashEmitterListenerMap = {
19
- [BashEmitterEvent.stdout]: [string];
20
- [BashEmitterEvent.stderr]: [string];
21
- /**
22
- * Exit code and exit signal. Based on the Node.js documentation, either one or the other is
23
- * defined, never both at the same time.
24
- */
25
- [BashEmitterEvent.done]: [exitCode: number | undefined, exitSignal: NodeJS.Signals | undefined];
26
- [BashEmitterEvent.error]: [Error];
27
- };
28
- export interface BashEmitter extends EventEmitter {
29
- emit<T extends BashEmitterEventKey>(type: T, ...args: BashEmitterListenerMap[T]): boolean;
30
- on<T extends BashEmitterEventKey>(type: T, listener: (...args: BashEmitterListenerMap[T]) => void): this;
31
- addListener<T extends BashEmitterEventKey>(type: T, listener: (...args: BashEmitterListenerMap[T]) => void): this;
32
- once<T extends BashEmitterEventKey>(type: T, listener: (...args: BashEmitterListenerMap[T]) => void): this;
33
- removeListener<T extends BashEmitterEventKey>(type: T, listener: (...args: BashEmitterListenerMap[T]) => void): this;
34
- off<T extends BashEmitterEventKey>(type: T, listener: (...args: BashEmitterListenerMap[T]) => void): this;
35
- childProcess: ChildProcess;
36
- }
37
- export declare function streamBashCommand(command: string, cwd?: string): BashEmitter;
38
- export declare function runBashCommand(command: string, cwd?: string, rejectError?: boolean): Promise<BashOutput>;
39
- export declare function printCommandOutput(bashOutput: {
40
- error?: unknown;
41
- stderr?: unknown;
42
- stdout?: unknown;
43
- exitCode?: unknown;
44
- }, withLabels?: boolean): void;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printCommandOutput = exports.runBashCommand = exports.streamBashCommand = exports.BashEmitterEvent = void 0;
4
- const child_process_1 = require("child_process");
5
- const stream_1 = require("stream");
6
- const error_1 = require("./error");
7
- exports.BashEmitterEvent = {
8
- stdout: 'stdout',
9
- stderr: 'stderr',
10
- done: 'done',
11
- error: 'error',
12
- };
13
- function streamBashCommand(command, cwd) {
14
- const bashEmitter = new stream_1.EventEmitter();
15
- /**
16
- * Using exec because I don't want to split up the command into an arguments array, which would
17
- * require making very general assumptions, nor do I want to require this function be passed an
18
- * array of arguments.
19
- *
20
- * Interestingly, most of the example code writers online seem to think that you NEED to use
21
- * spawn to access these event emitters, but that is simply not the case.
22
- *
23
- * Adding a callback here makes exec vulnerable to buffer overflows. However, not adding one
24
- * prevents errors being thrown when a command fails. Also however, failed command errors are
25
- * simply thrown whenever the command's exit code is not 0. Thus, this is easily accounted for elsewhere.
26
- */
27
- const childProcess = (0, child_process_1.spawn)(command, { shell: 'bash', cwd });
28
- bashEmitter.childProcess = childProcess;
29
- if (!childProcess.stdout) {
30
- throw new Error(`stdout emitter was not created by exec for some reason.`);
31
- }
32
- if (!childProcess.stderr) {
33
- throw new Error(`stderr emitter was not created by exec for some reason.`);
34
- }
35
- childProcess.stdout.on('data', (chunk) => {
36
- bashEmitter.emit(exports.BashEmitterEvent.stdout, chunk);
37
- });
38
- childProcess.stderr.on('data', (chunk) => {
39
- bashEmitter.emit(exports.BashEmitterEvent.stderr, chunk);
40
- });
41
- childProcess.on('error', (processError) => {
42
- bashEmitter.emit(exports.BashEmitterEvent.error, processError);
43
- });
44
- /**
45
- * Based on the Node.js documentation, we should listen to "close" instead of "exit" because the
46
- * io streams will be finished when "close" emits. Also "close" always emits after "exit" anyway.
47
- */
48
- childProcess.on('close', (inputExitCode, inputExitSignal) => {
49
- const exitCode = inputExitCode !== null && inputExitCode !== void 0 ? inputExitCode : undefined;
50
- const exitSignal = inputExitSignal !== null && inputExitSignal !== void 0 ? inputExitSignal : undefined;
51
- if ((exitCode !== undefined && exitCode !== 0) || exitSignal !== undefined) {
52
- const execException = new Error(`Command failed: ${command}`);
53
- execException.code = exitCode;
54
- execException.signal = exitSignal;
55
- execException.cmd = command;
56
- execException.killed = childProcess.killed;
57
- execException.cwd = cwd;
58
- bashEmitter.emit(exports.BashEmitterEvent.error, execException);
59
- }
60
- bashEmitter.emit(exports.BashEmitterEvent.done, exitCode, exitSignal);
61
- });
62
- // Might need to add a "disconnect" listener here as well. I'm not sure what it should do yet.
63
- // Like, should it emit "done"? idk.
64
- return bashEmitter;
65
- }
66
- exports.streamBashCommand = streamBashCommand;
67
- /** Helper function just to help with generics. */
68
- function processListener(eventType, eventListener) {
69
- return { eventType, eventListener };
70
- }
71
- async function runBashCommand(command, cwd = process.cwd(), rejectError = false) {
72
- return new Promise((resolve, reject) => {
73
- let stdout = '';
74
- let stderr = '';
75
- const errors = [];
76
- const bashStream = streamBashCommand(command, cwd);
77
- const listeners = [
78
- processListener(exports.BashEmitterEvent.stdout, (chunk) => {
79
- stdout += chunk;
80
- }),
81
- processListener(exports.BashEmitterEvent.stderr, (chunk) => {
82
- stderr += chunk;
83
- }),
84
- processListener(exports.BashEmitterEvent.error, (executionError) => {
85
- errors.push(executionError);
86
- if (rejectError) {
87
- listeners.forEach((listener) => bashStream.removeListener(listener.eventType, listener.eventListener));
88
- if (bashStream.childProcess.connected) {
89
- bashStream.childProcess.disconnect();
90
- }
91
- if (bashStream.childProcess.exitCode == null &&
92
- bashStream.childProcess.signalCode == null &&
93
- !bashStream.childProcess.killed) {
94
- bashStream.childProcess.kill();
95
- }
96
- // reject now cause the "done" listener won't get fired after killing the process
97
- reject((0, error_1.combineErrors)(errors));
98
- }
99
- }),
100
- processListener(exports.BashEmitterEvent.done, (exitCode, exitSignal) => {
101
- resolve({
102
- error: (0, error_1.combineErrors)(errors),
103
- stdout,
104
- stderr,
105
- exitCode,
106
- exitSignal,
107
- });
108
- }),
109
- ];
110
- listeners.forEach((listener) => {
111
- bashStream.addListener(listener.eventType, listener.eventListener);
112
- });
113
- });
114
- }
115
- exports.runBashCommand = runBashCommand;
116
- function printCommandOutput(bashOutput, withLabels = false) {
117
- if ('exitCode' in bashOutput) {
118
- withLabels && console.info('exit code');
119
- console.info(bashOutput.exitCode);
120
- }
121
- if ('stdout' in bashOutput) {
122
- withLabels && console.info('stdout');
123
- console.info(bashOutput.stdout);
124
- }
125
- if ('stderr' in bashOutput) {
126
- withLabels && console.info('stderr');
127
- console.error(bashOutput.stderr);
128
- }
129
- if ('error' in bashOutput) {
130
- withLabels && console.info('error');
131
- throw bashOutput.error;
132
- }
133
- }
134
- exports.printCommandOutput = printCommandOutput;
@@ -1,4 +0,0 @@
1
- export declare function combineErrors(errors: [Error, ...Error[]]): Error;
2
- export declare function combineErrors(errors: never[]): undefined;
3
- export declare function combineErrors(errors: Error[]): Error | undefined;
4
- export declare function combineErrors(errors?: undefined): undefined;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.combineErrors = void 0;
4
- function combineErrors(errors) {
5
- if (!errors || errors.length === 0) {
6
- return undefined;
7
- }
8
- const firstError = errors[0];
9
- if (errors.length === 1 && firstError) {
10
- return firstError;
11
- }
12
- return new Error(errors.map((error) => error.message.trim()).join('\n'));
13
- }
14
- exports.combineErrors = combineErrors;
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function createSymLink(
3
- /**
4
- * Path that the symlink will link to. If relative, it will be linked relative to the symlink
5
- * location itself.
6
- */
7
- linkPath: string,
8
- /** The location and name the symlink file itself. */
9
- symlinkLocationPath: string): Promise<void>;
10
- export declare function writeFileAndDir(path: string, contents: string | NodeJS.ArrayBufferView): Promise<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeFileAndDir = exports.createSymLink = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const path_1 = require("path");
6
- async function createSymLink(
7
- /**
8
- * Path that the symlink will link to. If relative, it will be linked relative to the symlink
9
- * location itself.
10
- */
11
- linkPath,
12
- /** The location and name the symlink file itself. */
13
- symlinkLocationPath) {
14
- if ((0, fs_extra_1.existsSync)(symlinkLocationPath)) {
15
- if (!(await (0, fs_extra_1.lstat)(symlinkLocationPath)).isSymbolicLink()) {
16
- throw new Error(`Tried to create symlink at ${symlinkLocationPath} but a non-symlink file already existed in that location.`);
17
- }
18
- if ((await (0, fs_extra_1.readlink)(symlinkLocationPath)) !== linkPath) {
19
- throw new Error(`Symlink already exists at ${symlinkLocationPath} but has a differently link path.`);
20
- }
21
- }
22
- else {
23
- await (0, fs_extra_1.symlink)(linkPath, symlinkLocationPath);
24
- }
25
- }
26
- exports.createSymLink = createSymLink;
27
- async function writeFileAndDir(path, contents) {
28
- await (0, fs_extra_1.ensureDir)((0, path_1.dirname)(path));
29
- await (0, fs_extra_1.writeFile)(path, contents);
30
- }
31
- exports.writeFileAndDir = writeFileAndDir;
@@ -1 +0,0 @@
1
- export * from 'fs-extra';
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("fs-extra"), exports);
@@ -1,6 +0,0 @@
1
- export declare function getEnumTypedKeys<T>(input: T): (keyof T)[];
2
- export declare function getEnumTypedValues<T>(input: T): T[keyof T][];
3
- export declare function isEnumValue<T extends object>(input: unknown, checkEnum: T): input is T[keyof T];
4
- export declare function filterToEnumValues<T extends object>(inputs: unknown[], checkEnum: T, caseInsensitive?: boolean): T[keyof T][];
5
- export declare function getObjectTypedKeys<T>(input: T): (keyof T)[];
6
- export declare function getObjectTypedValues<T>(input: T): T[keyof T][];
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getObjectTypedValues = exports.getObjectTypedKeys = exports.filterToEnumValues = exports.isEnumValue = exports.getEnumTypedValues = exports.getEnumTypedKeys = void 0;
4
- function getEnumTypedKeys(input) {
5
- // keys are always strings
6
- return getObjectTypedKeys(input).filter((key) => isNaN(Number(key)));
7
- }
8
- exports.getEnumTypedKeys = getEnumTypedKeys;
9
- function getEnumTypedValues(input) {
10
- const keys = getEnumTypedKeys(input);
11
- return keys.map((key) => input[key]);
12
- }
13
- exports.getEnumTypedValues = getEnumTypedValues;
14
- function isEnumValue(input, checkEnum) {
15
- return getEnumTypedValues(checkEnum).includes(input);
16
- }
17
- exports.isEnumValue = isEnumValue;
18
- function filterToEnumValues(inputs, checkEnum, caseInsensitive = false) {
19
- if (caseInsensitive) {
20
- return inputs.reduce((accum, currentInput) => {
21
- const matchedEnumValue = getEnumTypedValues(checkEnum).find((actualEnumValue) => {
22
- return String(actualEnumValue).toUpperCase() === String(currentInput).toUpperCase();
23
- });
24
- if (matchedEnumValue) {
25
- return accum.concat(matchedEnumValue);
26
- }
27
- else {
28
- return accum;
29
- }
30
- }, []);
31
- }
32
- else {
33
- return inputs.filter((input) => isEnumValue(input, checkEnum));
34
- }
35
- }
36
- exports.filterToEnumValues = filterToEnumValues;
37
- function getObjectTypedKeys(input) {
38
- return Object.keys(input);
39
- }
40
- exports.getObjectTypedKeys = getObjectTypedKeys;
41
- function getObjectTypedValues(input) {
42
- return Object.values(input);
43
- }
44
- exports.getObjectTypedValues = getObjectTypedValues;
@@ -1,3 +0,0 @@
1
- export declare function toPosixPath(maybeWindowsPath: string): string;
2
- export declare function interpolationSafeWindowsPath(input: string): string;
3
- export declare function joinWithFinalConjunction<T>(list: T[], word?: string): string;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinWithFinalConjunction = exports.interpolationSafeWindowsPath = exports.toPosixPath = void 0;
4
- function toPosixPath(maybeWindowsPath) {
5
- return maybeWindowsPath
6
- .replace(/^(.+?)\:\\+/, (match, captureGroup) => {
7
- return `/${captureGroup.toLowerCase()}/`;
8
- })
9
- .replace(/\\+/g, '/');
10
- }
11
- exports.toPosixPath = toPosixPath;
12
- function interpolationSafeWindowsPath(input) {
13
- return input.replace(/\\/g, '\\\\\\\\');
14
- }
15
- exports.interpolationSafeWindowsPath = interpolationSafeWindowsPath;
16
- function joinWithFinalConjunction(list, word = 'and ') {
17
- if (list.length < 2) {
18
- /**
19
- * If there are not multiple things in the list to join, just turn the list into a string
20
- * for an empty list, this will be '', for a single item list, this will just be the first
21
- * item as a string.
22
- */
23
- return list.join('');
24
- }
25
- /** When there are only two items in the list, we don't want any commas. */
26
- const commaSep = list.length > 2 ? ', ' : ' ';
27
- const commaJoined = list.slice(0, -1).join(commaSep);
28
- const fullyJoined = `${commaJoined}${commaSep}${word}${list[list.length - 1]}`;
29
- return fullyJoined;
30
- }
31
- exports.joinWithFinalConjunction = joinWithFinalConjunction;
@@ -1,7 +0,0 @@
1
- export declare type Writeable<T> = {
2
- -readonly [P in keyof T]: T[P];
3
- };
4
- export declare type DeepWriteable<T> = {
5
- -readonly [P in keyof T]: DeepWriteable<T[P]>;
6
- };
7
- export declare type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });