virmator 4.3.3 → 5.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 (57) hide show
  1. package/README.md +4 -3
  2. package/base-configs/base-mocharc.js +2 -1
  3. package/base-configs/base-nyc.js +8 -4
  4. package/base-configs/base-tsconfig.json +0 -5
  5. package/configs/gitignore.txt +1 -1
  6. package/configs/npmignore.txt +1 -1
  7. package/dist/api/command/command-configs.js +3 -3
  8. package/dist/api/command/command-description.d.ts +2 -2
  9. package/dist/api/command/command-executor.d.ts +8 -8
  10. package/dist/api/command/command-help.d.ts +2 -2
  11. package/dist/api/command/command-logging.d.ts +5 -5
  12. package/dist/api/command/command-mapping.d.ts +3 -3
  13. package/dist/api/command/command-messages.js +3 -3
  14. package/dist/api/command/command-to-help-message.js +11 -10
  15. package/dist/api/command/define-command-inputs.d.ts +3 -3
  16. package/dist/api/command/define-command.d.ts +1 -1
  17. package/dist/api/command/define-command.js +3 -3
  18. package/dist/api/config/config-file-definition.d.ts +2 -2
  19. package/dist/api/config/config-paths.d.ts +1 -1
  20. package/dist/api/config/copy-config.d.ts +3 -3
  21. package/dist/api/config/copy-config.js +5 -5
  22. package/dist/api/create-virmator.js +2 -2
  23. package/dist/api/run-command/check-npm-deps.d.ts +1 -1
  24. package/dist/api/run-command/check-npm-deps.js +12 -10
  25. package/dist/api/run-command/extract-arguments.d.ts +1 -1
  26. package/dist/api/run-command/run-command-executor.js +6 -7
  27. package/dist/api/run-command/run-extended-virmator.js +3 -3
  28. package/dist/api/run-command/run-shell-command.d.ts +2 -2
  29. package/dist/api/run-command/run-shell-command.js +2 -2
  30. package/dist/api/virmator-types.d.ts +2 -2
  31. package/dist/augments/fs.js +2 -2
  32. package/dist/augments/git.js +2 -2
  33. package/dist/augments/npm.d.ts +3 -3
  34. package/dist/augments/npm.js +2 -2
  35. package/dist/augments/object.d.ts +1 -1
  36. package/dist/augments/object.js +7 -7
  37. package/dist/augments/prettier.js +2 -1
  38. package/dist/augments/string.d.ts +1 -1
  39. package/dist/augments/type.d.ts +1 -1
  40. package/dist/commands/compile.command.js +1 -2
  41. package/dist/commands/extra-configs/combine-json-config.js +2 -2
  42. package/dist/commands/extra-configs/combine-text-config.js +2 -2
  43. package/dist/commands/extra-configs/create-default-package-json.js +4 -4
  44. package/dist/commands/format.command.js +3 -3
  45. package/dist/commands/frontend.command.d.ts +1 -1
  46. package/dist/commands/frontend.command.js +1 -1
  47. package/dist/commands/publish.command.js +13 -13
  48. package/dist/commands/test.command.d.ts +1 -1
  49. package/dist/commands/test.command.js +1 -1
  50. package/dist/compiled-base-configs/vite-always-reload-plugin.js +2 -2
  51. package/dist/file-paths/package-paths.js +4 -4
  52. package/dist/index.d.ts +2 -3
  53. package/dist/index.js +0 -1
  54. package/dist/scripts/save-help-message.js +2 -2
  55. package/package.json +25 -24
  56. package/dist/api/cli-color.d.ts +0 -9
  57. package/dist/api/cli-color.js +0 -13
package/README.md CHANGED
@@ -82,14 +82,15 @@ Any other arguments encountered between the operation command (if provided) and
82
82
 
83
83
  ```
84
84
  virmator format
85
- virmator format
85
+ virmator format
86
86
  ```
87
87
 
88
88
  - examples with extra Prettier flags:
89
+
89
90
  ```
90
91
  virmator format --ignore-path .prettierignore
91
- virmator format --ignore-path .prettierignore
92
- virmator format --ignore-path .prettierignore --file-types md json
92
+ virmator format --ignore-path .prettierignore
93
+ virmator format --ignore-path .prettierignore --file-types md json
93
94
  ```
94
95
 
95
96
  ### check
@@ -6,8 +6,9 @@ const mochaConfig = {
6
6
  checkLeaks: true,
7
7
  color: true,
8
8
  parallel: true,
9
- require: ['ts-node/register'],
9
+ require: ['tsx'],
10
10
  slow: 1_500, // ms
11
+ fullTrace: true,
11
12
  timeout: 60_000, // 1 minute in ms
12
13
  reporter: SpecReporterWithFileNames.pathToThisReporter,
13
14
  ...testFiles,
@@ -5,19 +5,23 @@ function getBaseConfigWithCoveragePercent(percent) {
5
5
  extends: '@istanbuljs/nyc-config-typescript',
6
6
  all: true,
7
7
  branches: percent,
8
+ clean: true,
8
9
  cache: false,
9
10
  instrument: true,
10
- checkCoverage: true,
11
+ // use the reporter (istanbul-smart-text-reporter) to fail instead of printing errors for
12
+ // every message
13
+ checkCoverage: false,
11
14
  exclude: [
12
15
  '**/*.test.ts',
13
- 'src/readme-examples',
16
+ '**/*.example.ts',
14
17
  '**/*.type.test.ts',
15
18
  '**/*.test-helper.ts',
16
19
  ],
17
20
  functions: percent,
18
- include: 'src/*',
21
+ include: ['src/**/*.ts'],
19
22
  lines: percent,
20
- perFile: true,
23
+ // so we don't get error messages printed for every file
24
+ perFile: false,
21
25
  reporter: [
22
26
  'html',
23
27
  'istanbul-smart-text-reporter',
@@ -23,10 +23,5 @@
23
23
  "strict": true,
24
24
  "target": "ES2019",
25
25
  "useUnknownInCatchVariables": true
26
- },
27
- "ts-node": {
28
- "compilerOptions": {
29
- "module": "CommonJS"
30
- }
31
26
  }
32
27
  }
@@ -1,5 +1,5 @@
1
1
  .DS_Store
2
- /*.tgz
2
+ *.tgz
3
3
  /Icon?
4
4
  coverage/
5
5
  dist/
@@ -1,10 +1,10 @@
1
1
  .*
2
2
  *.test-helper.*
3
3
  *.test.*
4
+ *.tgz
4
5
  *.tsbuildinfo
5
6
  **/*/readme-examples/
6
7
  **/*/test/
7
- /*.tgz
8
8
  /configs/
9
9
  /coverage/
10
10
  /cspell.config.js
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractAllConfigs = void 0;
4
- const augment_vir_1 = require("augment-vir");
4
+ const common_1 = require("@augment-vir/common");
5
5
  function extractAllConfigs(commandMapping) {
6
- const configFiles = (0, augment_vir_1.getObjectTypedValues)(commandMapping)
7
- .map((commandDefinition) => (0, augment_vir_1.getObjectTypedValues)(commandDefinition.configFiles))
6
+ const configFiles = (0, common_1.getObjectTypedValues)(commandMapping)
7
+ .map((commandDefinition) => (0, common_1.getObjectTypedValues)(commandDefinition.configFiles))
8
8
  .flat();
9
9
  return configFiles;
10
10
  }
@@ -1,8 +1,8 @@
1
1
  import { CommandDescription } from './command-help';
2
2
  import { DefineCommandInputs, SubCommandsMap } from './define-command-inputs';
3
- export declare type CreateDescriptionsInputs<DefineCommandInputsGeneric extends DefineCommandInputs> = Pick<DefineCommandInputsGeneric, 'commandName'> & {
3
+ export type CreateDescriptionsInputs<DefineCommandInputsGeneric extends DefineCommandInputs> = Pick<DefineCommandInputsGeneric, 'commandName'> & {
4
4
  packageBinName: string;
5
5
  subCommands: SubCommandsMap<DefineCommandInputsGeneric>;
6
6
  configFiles: DefineCommandInputsGeneric['configFiles'];
7
7
  };
8
- export declare type CreateDescriptionsCallback<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CreateDescriptionsInputs<DefineCommandInputsGeneric>) => CommandDescription;
8
+ export type CreateDescriptionsCallback<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CreateDescriptionsInputs<DefineCommandInputsGeneric>) => CommandDescription;
@@ -1,7 +1,7 @@
1
1
  import { ConfigFileDefinition } from '../config/config-file-definition';
2
2
  import { CommandLogging, CommandLogTransforms } from './command-logging';
3
3
  import { DefineCommandInputs, SharedExecutorInputsAndCommandDefinition } from './define-command-inputs';
4
- export declare type CommandExecutorInputs<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs> = {
4
+ export type CommandExecutorInputs<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs> = {
5
5
  filteredInputArgs: string[];
6
6
  inputSubCommands: (keyof DefineCommandInputsGeneric['subCommandDescriptions'])[];
7
7
  repoDir: string;
@@ -9,20 +9,20 @@ export declare type CommandExecutorInputs<DefineCommandInputsGeneric extends Def
9
9
  packageDir: string;
10
10
  logging: CommandLogging;
11
11
  };
12
- export declare type CommandExecutorDefinitionInputs<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs> = CommandExecutorInputs<DefineCommandInputsGeneric> & SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric>;
13
- export declare type DetailedArg = {
12
+ export type CommandExecutorDefinitionInputs<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs> = CommandExecutorInputs<DefineCommandInputsGeneric> & SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric>;
13
+ export type DetailedArg = {
14
14
  arg: string;
15
15
  skipWindowsInterpolation: true;
16
16
  };
17
- export declare type SuccessOnlyExecutorOutput = {
17
+ export type SuccessOnlyExecutorOutput = {
18
18
  success: boolean;
19
19
  };
20
- export declare type BashCommandExecutorOutput = {
20
+ export type BashCommandExecutorOutput = {
21
21
  mainCommand: string;
22
22
  logTransforms?: CommandLogTransforms;
23
23
  args: (string | DetailedArg)[];
24
24
  };
25
25
  export declare function isCompletedExecutor(executorOutput: CommandExecutorOutput): executorOutput is SuccessOnlyExecutorOutput;
26
- export declare type CommandExecutorOutput = BashCommandExecutorOutput | SuccessOnlyExecutorOutput;
27
- export declare type CommandExecutorDefinition<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CommandExecutorDefinitionInputs<DefineCommandInputsGeneric>) => Promise<CommandExecutorOutput> | CommandExecutorOutput;
28
- export declare type CommandExecutor<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CommandExecutorInputs<DefineCommandInputsGeneric>) => Promise<CommandExecutorOutput> | CommandExecutorOutput;
26
+ export type CommandExecutorOutput = BashCommandExecutorOutput | SuccessOnlyExecutorOutput;
27
+ export type CommandExecutorDefinition<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CommandExecutorDefinitionInputs<DefineCommandInputsGeneric>) => Promise<CommandExecutorOutput> | CommandExecutorOutput;
28
+ export type CommandExecutor<DefineCommandInputsGeneric extends DefineCommandInputs> = (inputs: CommandExecutorInputs<DefineCommandInputsGeneric>) => Promise<CommandExecutorOutput> | CommandExecutorOutput;
@@ -1,8 +1,8 @@
1
- export declare type HelpSection = Readonly<{
1
+ export type HelpSection = Readonly<{
2
2
  title: string;
3
3
  content: string;
4
4
  }>;
5
- export declare type CommandDescription = Readonly<{
5
+ export type CommandDescription = Readonly<{
6
6
  sections: Readonly<HelpSection[]>;
7
7
  examples: Readonly<HelpSection[]>;
8
8
  }>;
@@ -1,11 +1,11 @@
1
- export declare type CommandLogCallback = (thingToLog: string) => void;
2
- export declare type CommandLogging = {
1
+ export type CommandLogCallback = (thingToLog: string) => void;
2
+ export type CommandLogging = {
3
3
  stdout: CommandLogCallback;
4
4
  stderr: CommandLogCallback;
5
5
  };
6
6
  export declare const noCommandLogging: Readonly<Required<CommandLogging>>;
7
7
  export declare const defaultConsoleLogging: Readonly<Required<CommandLogging>>;
8
- export declare type CommandLogs = Record<keyof CommandLogging, string>;
8
+ export type CommandLogs = Record<keyof CommandLogging, string>;
9
9
  export declare const identityCommandLogTransform: CommandLogTransform;
10
- export declare type CommandLogTransform = (thingToTransform: string) => string;
11
- export declare type CommandLogTransforms = Partial<Record<keyof CommandLogging, CommandLogTransform>>;
10
+ export type CommandLogTransform = (thingToTransform: string) => string;
11
+ export type CommandLogTransforms = Partial<Record<keyof CommandLogging, CommandLogTransform>>;
@@ -1,7 +1,7 @@
1
- import { ArrayElement } from 'augment-vir';
1
+ import { ArrayElement } from '@augment-vir/common';
2
2
  import { CommandDefinition } from './define-command';
3
- export declare type CommandMapping = Record<string, CommandDefinition>;
3
+ export type CommandMapping = Record<string, CommandDefinition>;
4
4
  export declare function commandsToMapping(commands: ReadonlyArray<CommandDefinition>): Readonly<CommandMapping>;
5
- export declare type CommandDefinitionArrayToMapping<DefinitionArray extends ReadonlyArray<CommandDefinition>> = {
5
+ export type CommandDefinitionArrayToMapping<DefinitionArray extends ReadonlyArray<CommandDefinition>> = {
6
6
  [CommandName in ArrayElement<DefinitionArray>['commandName']]: CommandDefinition;
7
7
  };
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCommandResultMessage = void 0;
4
- const cli_color_1 = require("../cli-color");
4
+ const node_js_1 = require("@augment-vir/node-js");
5
5
  function getCommandResultMessage(commandName, success) {
6
- const specificColor = success ? cli_color_1.Color.Success : cli_color_1.Color.Fail;
6
+ const specificColor = success ? node_js_1.logColors.success : node_js_1.logColors.error;
7
7
  const specificPhrase = success ? 'succeeded' : 'failed';
8
- return `${cli_color_1.Color.Bold}${specificColor}${commandName} ${specificPhrase}.${cli_color_1.Color.Reset}`;
8
+ return `${node_js_1.logColors.bold}${specificColor}${commandName} ${specificPhrase}.${node_js_1.logColors.reset}`;
9
9
  }
10
10
  exports.getCommandResultMessage = getCommandResultMessage;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commandToHelpString = exports.flagToHelpString = exports.generateHelpMessage = exports.HelpMessageSyntax = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const cli_color_1 = require("../cli-color");
4
+ const common_1 = require("@augment-vir/common");
5
+ const node_js_1 = require("@augment-vir/node-js");
6
6
  var HelpMessageSyntax;
7
7
  (function (HelpMessageSyntax) {
8
8
  HelpMessageSyntax["Cli"] = "cli";
9
9
  HelpMessageSyntax["Markdown"] = "markdown";
10
10
  })(HelpMessageSyntax = exports.HelpMessageSyntax || (exports.HelpMessageSyntax = {}));
11
11
  function generateHelpMessage(packageBinName, commandDefinitions, syntax, cliWrapIfMoreThanThisManyColumns = 100) {
12
- const commandsMessage = [...(0, augment_vir_1.getObjectTypedKeys)(commandDefinitions)]
12
+ const commandsMessage = [...(0, common_1.getObjectTypedKeys)(commandDefinitions)]
13
13
  .sort()
14
14
  .map((commandName) => {
15
15
  const commandDefinition = commandDefinitions[commandName];
@@ -27,11 +27,11 @@ function generateHelpMessage(packageBinName, commandDefinitions, syntax, cliWrap
27
27
  exports.generateHelpMessage = generateHelpMessage;
28
28
  const formatting = ((input) => input)({
29
29
  h1: {
30
- [HelpMessageSyntax.Cli]: `${cli_color_1.Color.Info}`,
30
+ [HelpMessageSyntax.Cli]: `${node_js_1.logColors.info}`,
31
31
  [HelpMessageSyntax.Markdown]: '# ',
32
32
  },
33
33
  h2: {
34
- [HelpMessageSyntax.Cli]: `${cli_color_1.Color.Bold}${cli_color_1.Color.Info}`,
34
+ [HelpMessageSyntax.Cli]: `${node_js_1.logColors.bold}${node_js_1.logColors.info}`,
35
35
  [HelpMessageSyntax.Markdown]: '## ',
36
36
  },
37
37
  h3: {
@@ -39,7 +39,7 @@ const formatting = ((input) => input)({
39
39
  [HelpMessageSyntax.Markdown]: '### ',
40
40
  },
41
41
  reset: {
42
- [HelpMessageSyntax.Cli]: `${cli_color_1.Color.Reset}`,
42
+ [HelpMessageSyntax.Cli]: `${node_js_1.logColors.reset}`,
43
43
  [HelpMessageSyntax.Markdown]: '',
44
44
  },
45
45
  indent: {
@@ -93,7 +93,7 @@ function commandToHelpString(packageBinName, commandDefinition, syntax) {
93
93
  }
94
94
  exports.commandToHelpString = commandToHelpString;
95
95
  function subCommandDescriptionsToMessage(subCommandDescriptions, syntax) {
96
- return (0, augment_vir_1.getObjectTypedKeys)(subCommandDescriptions).reduce((accum, currentKey, index) => {
96
+ return (0, common_1.getObjectTypedKeys)(subCommandDescriptions).reduce((accum, currentKey, index) => {
97
97
  const keyDescription = subCommandDescriptions[currentKey];
98
98
  const leadingLine = index > 0 ? '\n\n' : '';
99
99
  const fullDescription = `${leadingLine}${formatWithSyntax('h3', syntax)}${currentKey}${formatWithSyntax('colon', syntax)}\n${indent(2, syntax)}${keyDescription}`;
@@ -110,7 +110,8 @@ function sectionToString(section, extraIndent, syntax, bullets) {
110
110
  const header = bullets ? '' : format('h3');
111
111
  const title = section.title ? `${sectionIndent}${header}${section.title}${separator}` : '';
112
112
  if (bullets && syntax === HelpMessageSyntax.Markdown) {
113
- return `${format('bullet')}${title}${code(section.content, section.content.includes('\n'), syntax === HelpMessageSyntax.Markdown && section.content.includes('\n') ? ' ' : '', syntax)}`;
113
+ const isBlock = section.content.includes('\n');
114
+ return `${format('bullet')}${title}${isBlock ? '\n' : ''}${code(section.content, isBlock, syntax === HelpMessageSyntax.Markdown && isBlock ? ' ' : '', syntax)}`;
114
115
  }
115
116
  else {
116
117
  const contentIndent = section.title ? indent(3 + extraIndent, syntax) : sectionIndent;
@@ -142,7 +143,7 @@ ${commandsText}`;
142
143
  }
143
144
  function getIndent(line) {
144
145
  var _a;
145
- return (_a = (0, augment_vir_1.safeMatch)(line, /^(\s*)/)[0]) !== null && _a !== void 0 ? _a : '';
146
+ return (_a = (0, common_1.safeMatch)(line, /^(\s*)/)[0]) !== null && _a !== void 0 ? _a : '';
146
147
  }
147
148
  function wrapLines(input, limit) {
148
149
  var _a, _b;
@@ -158,7 +159,7 @@ function wrapLines(input, limit) {
158
159
  let wrappedPart = line.slice(limit);
159
160
  // didn't wrap on a space, we need to shift a word down
160
161
  if (!newLine.endsWith(' ') && !wrappedPart.startsWith(' ')) {
161
- const lastWord = (_b = (0, augment_vir_1.safeMatch)(newLine, /(\s\S+$)/)[0]) !== null && _b !== void 0 ? _b : '';
162
+ const lastWord = (_b = (0, common_1.safeMatch)(newLine, /(\s\S+$)/)[0]) !== null && _b !== void 0 ? _b : '';
162
163
  lines[index] = newLine.slice(0, -1 * lastWord.length).trimEnd();
163
164
  wrappedPart = `${lastWord}${wrappedPart.trim()}`;
164
165
  }
@@ -1,14 +1,14 @@
1
1
  import { ConfigFileDefinition } from '../config/config-file-definition';
2
- export declare type DefineCommandInputs<CommandName extends string = string> = Readonly<{
2
+ export type DefineCommandInputs<CommandName extends string = string> = Readonly<{
3
3
  commandName: CommandName;
4
4
  subCommandDescriptions: Readonly<Record<string, string>>;
5
5
  configFiles: Readonly<Record<string, Readonly<ConfigFileDefinition>>>;
6
6
  npmDeps: ReadonlyArray<string>;
7
7
  }>;
8
- export declare type SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric extends DefineCommandInputs> = DefineCommandInputsGeneric & {
8
+ export type SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric extends DefineCommandInputs> = DefineCommandInputsGeneric & {
9
9
  allAvailableSubCommands: ReadonlyArray<keyof DefineCommandInputsGeneric['subCommandDescriptions']>;
10
10
  subCommands: SubCommandsMap<DefineCommandInputsGeneric>;
11
11
  };
12
- export declare type SubCommandsMap<DefineCommandInputsGeneric extends DefineCommandInputs> = {
12
+ export type SubCommandsMap<DefineCommandInputsGeneric extends DefineCommandInputs> = {
13
13
  [Prop in keyof DefineCommandInputsGeneric['subCommandDescriptions']]: Prop;
14
14
  };
@@ -1,7 +1,7 @@
1
1
  import { CreateDescriptionsCallback } from './command-description';
2
2
  import { CommandExecutor, CommandExecutorDefinition } from './command-executor';
3
3
  import { DefineCommandInputs, SharedExecutorInputsAndCommandDefinition } from './define-command-inputs';
4
- export declare type CommandDefinition<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs<string>> = SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric> & {
4
+ export type CommandDefinition<DefineCommandInputsGeneric extends DefineCommandInputs = DefineCommandInputs<string>> = SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric> & {
5
5
  executor: CommandExecutor<DefineCommandInputsGeneric>;
6
6
  createDescription: CreateDescriptionsCallback<DefineCommandInputsGeneric>;
7
7
  };
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineCommand = void 0;
4
- const augment_vir_1 = require("augment-vir");
4
+ const common_1 = require("@augment-vir/common");
5
5
  function defineCommand(defineCommandInputs, createDescription, inputExecutor) {
6
- const allAvailableSubCommands = (0, augment_vir_1.getObjectTypedKeys)(defineCommandInputs.subCommandDescriptions);
7
- const subCommands = (0, augment_vir_1.mapObjectValues)(defineCommandInputs.subCommandDescriptions, (key) => key);
6
+ const allAvailableSubCommands = (0, common_1.getObjectTypedKeys)(defineCommandInputs.subCommandDescriptions);
7
+ const subCommands = (0, common_1.mapObjectValues)(defineCommandInputs.subCommandDescriptions, (key) => key);
8
8
  const init = {
9
9
  ...defineCommandInputs,
10
10
  allAvailableSubCommands,
@@ -1,5 +1,5 @@
1
- export declare type UpdateConfigCallback = (copyFromContents: string, existingConfigContents: string, repoDir: string) => string | Promise<string>;
2
- export declare type ConfigFileDefinition = {
1
+ export type UpdateConfigCallback = (copyFromContents: string, existingConfigContents: string, repoDir: string) => string | Promise<string>;
2
+ export type ConfigFileDefinition = {
3
3
  /** Path to the config file to copy. */
4
4
  copyFromInternalPath: string;
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { ConfigFileDefinition } from './config-file-definition';
2
- export declare type GetCopyToPathInputs = {
2
+ export type GetCopyToPathInputs = {
3
3
  repoDir: string;
4
4
  packageDir: string;
5
5
  configFileDefinition: ConfigFileDefinition;
@@ -8,18 +8,18 @@ export declare enum CopyConfigOperation {
8
8
  /** Only write the config file if it doesn't exist already or if it can be updated. */
9
9
  Init = "init"
10
10
  }
11
- export declare type CopyConfigInputs = {
11
+ export type CopyConfigInputs = {
12
12
  configFileDefinition: ConfigFileDefinition;
13
13
  repoDir: string;
14
14
  packageDir: string;
15
15
  operation: CopyConfigOperation;
16
16
  };
17
- export declare type CopyConfigOutputs = {
17
+ export type CopyConfigOutputs = {
18
18
  copiedToPath: string;
19
19
  shouldWrite: boolean;
20
20
  };
21
21
  export declare function copyConfig(inputs: CopyConfigInputs): Promise<CopyConfigOutputs>;
22
- export declare type CopyAllConfigFilesInputs = Omit<CopyConfigInputs, 'configFileDefinition'> & {
22
+ export type CopyAllConfigFilesInputs = Omit<CopyConfigInputs, 'configFileDefinition'> & {
23
23
  logging: CommandLogging;
24
24
  configFiles: ReadonlyArray<ConfigFileDefinition>;
25
25
  };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyAllConfigFiles = exports.copyConfig = exports.CopyConfigOperation = void 0;
4
- const augment_vir_1 = require("augment-vir");
4
+ const common_1 = require("@augment-vir/common");
5
+ const node_js_1 = require("@augment-vir/node-js");
5
6
  const fs_1 = require("fs");
6
7
  const promises_1 = require("fs/promises");
7
8
  const path_1 = require("path");
8
- const cli_color_1 = require("../cli-color");
9
9
  const config_paths_1 = require("./config-paths");
10
10
  var CopyConfigOperation;
11
11
  (function (CopyConfigOperation) {
@@ -69,7 +69,7 @@ const failedOperation = {
69
69
  /** Returns success state. True if success, false is errors were encountered. */
70
70
  async function copyAllConfigFiles(inputs) {
71
71
  const errors = [];
72
- await (0, augment_vir_1.awaitedForEach)(inputs.configFiles.sort((a, b) => {
72
+ await (0, common_1.awaitedForEach)(inputs.configFiles.sort((a, b) => {
73
73
  const aName = (0, path_1.basename)(a.copyToPathRelativeToRepoDir || a.copyFromInternalPath);
74
74
  const bName = (0, path_1.basename)(b.copyToPathRelativeToRepoDir || b.copyFromInternalPath);
75
75
  return aName.localeCompare(bName);
@@ -82,11 +82,11 @@ async function copyAllConfigFiles(inputs) {
82
82
  packageDir: inputs.packageDir,
83
83
  });
84
84
  if (result.shouldWrite) {
85
- inputs.logging.stdout(`${cli_color_1.Color.Info}Successfully ${successfulOperation[inputs.operation]}${cli_color_1.Color.Reset} ${(0, path_1.basename)(result.copiedToPath)}`);
85
+ inputs.logging.stdout(`${node_js_1.logColors.info}Successfully ${successfulOperation[inputs.operation]}${node_js_1.logColors.reset} ${(0, path_1.basename)(result.copiedToPath)}`);
86
86
  }
87
87
  }
88
88
  catch (error) {
89
- const copyError = new Error(`${cli_color_1.Color.Fail}Failed to ${failedOperation[inputs.operation]}${cli_color_1.Color.Reset} ${(0, path_1.basename)(configFile.copyToPathRelativeToRepoDir || configFile.copyFromInternalPath)}: ${(0, augment_vir_1.extractErrorMessage)(error)}`);
89
+ const copyError = new Error(`${node_js_1.logColors.error}Failed to ${failedOperation[inputs.operation]}${node_js_1.logColors.reset} ${(0, path_1.basename)(configFile.copyToPathRelativeToRepoDir || configFile.copyFromInternalPath)}: ${(0, common_1.extractErrorMessage)(error)}`);
90
90
  errors.push(copyError);
91
91
  }
92
92
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createVirmator = void 0;
4
- const augment_vir_1 = require("augment-vir");
4
+ const common_1 = require("@augment-vir/common");
5
5
  const command_configs_1 = require("./command/command-configs");
6
6
  const command_mapping_1 = require("./command/command-mapping");
7
7
  const command_to_help_message_1 = require("./command/command-to-help-message");
@@ -36,7 +36,7 @@ function createVirmator(inputs) {
36
36
  await run(process.argv, process.cwd());
37
37
  }
38
38
  catch (error) {
39
- console.error((0, augment_vir_1.extractErrorMessage)(error));
39
+ console.error((0, common_1.extractErrorMessage)(error));
40
40
  process.exit(1);
41
41
  }
42
42
  }
@@ -1,4 +1,4 @@
1
- export declare type UpdateDepsInput = Readonly<{
1
+ export type UpdateDepsInput = Readonly<{
2
2
  repoDir: string;
3
3
  packageDir: string;
4
4
  npmDeps: ReadonlyArray<string>;
@@ -24,14 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.updateDepsAsNeeded = void 0;
27
- const augment_vir_1 = require("augment-vir");
28
- const node_only_1 = require("augment-vir/dist/cjs/node-only");
27
+ const common_1 = require("@augment-vir/common");
28
+ const node_js_1 = require("@augment-vir/node-js");
29
29
  const fs_1 = require("fs");
30
30
  const promises_1 = require("fs/promises");
31
31
  const path_1 = require("path");
32
32
  const semver = __importStar(require("semver"));
33
33
  const fs_2 = require("../../augments/fs");
34
- const cli_color_1 = require("../cli-color");
35
34
  async function updateDepsAsNeeded(inputs) {
36
35
  try {
37
36
  const upgradeVersions = await getVersionsToUpgradeTo(inputs);
@@ -48,23 +47,23 @@ async function updateDepsAsNeeded(inputs) {
48
47
  return undefined;
49
48
  }
50
49
  })
51
- .filter(augment_vir_1.isTruthy);
52
- await (0, augment_vir_1.awaitedForEach)(depsToUpdate, async (depDetails) => {
50
+ .filter(common_1.isTruthy);
51
+ await (0, common_1.awaitedForEach)(depsToUpdate, async (depDetails) => {
53
52
  const depToInstall = `${depDetails.npmDep}@${depDetails.version}`;
54
- console.info(`${cli_color_1.Color.Info}Installing ${depToInstall}...`);
55
- await (0, node_only_1.runShellCommand)(`npm i -D ${depToInstall}`, {
53
+ console.info(`${node_js_1.logColors.info}Installing ${depToInstall}...`);
54
+ await (0, node_js_1.runShellCommand)(`npm i -D ${depToInstall}`, {
56
55
  cwd: inputs.repoDir,
57
56
  rejectOnError: true,
58
57
  });
59
58
  });
60
59
  }
61
60
  catch (error) {
62
- throw new Error(`Failed to update deps: ${(0, augment_vir_1.extractErrorMessage)(error)}`);
61
+ throw new Error(`Failed to update deps: ${(0, common_1.extractErrorMessage)(error)}`);
63
62
  }
64
63
  }
65
64
  exports.updateDepsAsNeeded = updateDepsAsNeeded;
66
65
  async function getVersionsToUpgradeTo({ repoDir, packageDir, npmDeps, packageBinName, }) {
67
- const packageName = (await (0, node_only_1.runShellCommand)(`cut -d "=" -f 2 <<< $(npm run env | grep "npm_package_name")`, {
66
+ const packageName = (await (0, node_js_1.runShellCommand)(`cut -d "=" -f 2 <<< $(npm run env | grep "npm_package_name")`, {
68
67
  cwd: repoDir,
69
68
  rejectOnError: true,
70
69
  })).stdout.trim();
@@ -99,7 +98,7 @@ async function findDepsListWithPackageName(repoDir, packageName) {
99
98
  if (!(0, fs_1.existsSync)((0, path_1.join)(repoDir, 'package.json'))) {
100
99
  return findDepsListWithPackageName((0, path_1.dirname)(repoDir), packageName);
101
100
  }
102
- const listedDeps = await (0, node_only_1.runShellCommand)(`npm list --depth=0 -json`, {
101
+ const listedDeps = await (0, node_js_1.runShellCommand)(`npm list --depth=0 -json`, {
103
102
  cwd: repoDir,
104
103
  rejectOnError: true,
105
104
  });
@@ -118,6 +117,9 @@ function parseCurrentDeps(objectInput, packageName) {
118
117
  }
119
118
  function readDeps(rawDeps, packageName) {
120
119
  var _a;
120
+ if (!rawDeps) {
121
+ return {};
122
+ }
121
123
  const depsAndVersions = {};
122
124
  const nestedDeps = (_a = rawDeps[packageName]) === null || _a === void 0 ? void 0 : _a.dependencies;
123
125
  const deps = nestedDeps !== null && nestedDeps !== void 0 ? nestedDeps : rawDeps;
@@ -1,5 +1,5 @@
1
1
  export declare function getRelevantArgs(allArgs: string[], binName: string): string[];
2
- export declare type ExtractSubCommandsOutput<T> = {
2
+ export type ExtractSubCommandsOutput<T> = {
3
3
  subCommands: T[];
4
4
  filteredArgs: string[];
5
5
  };
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCommandExecutor = exports.createCommandString = void 0;
4
- const augment_vir_1 = require("augment-vir");
5
- const node_only_1 = require("augment-vir/dist/cjs/node-only");
4
+ const common_1 = require("@augment-vir/common");
5
+ const node_js_1 = require("@augment-vir/node-js");
6
6
  const path_1 = require("path");
7
- const cli_color_1 = require("../cli-color");
8
7
  const command_executor_1 = require("../command/command-executor");
9
8
  const copy_config_1 = require("../config/copy-config");
10
9
  const run_shell_command_1 = require("./run-shell-command");
@@ -18,14 +17,14 @@ function createCommandString(executorOutput) {
18
17
  arg = arg.arg;
19
18
  }
20
19
  }
21
- return (0, node_only_1.interpolationSafeWindowsPath)(arg);
20
+ return (0, node_js_1.interpolationSafeWindowsPath)(arg);
22
21
  });
23
- const commandString = `${executorOutput.mainCommand} ${args.filter(augment_vir_1.isTruthy).join(' ')}`;
22
+ const commandString = `${executorOutput.mainCommand} ${args.filter(common_1.isTruthy).join(' ')}`;
24
23
  return commandString;
25
24
  }
26
25
  exports.createCommandString = createCommandString;
27
26
  async function runCommandExecutor(commandDefinition, commandInputs) {
28
- console.info(`${cli_color_1.Color.Info}running ${commandDefinition.commandName}...${cli_color_1.Color.Reset}`);
27
+ console.info(`${node_js_1.logColors.info}running ${commandDefinition.commandName}...${node_js_1.logColors.reset}`);
29
28
  await (0, copy_config_1.copyAllConfigFiles)({
30
29
  logging: commandInputs.logging,
31
30
  configFiles: Object.values(commandDefinition.configFiles),
@@ -39,7 +38,7 @@ async function runCommandExecutor(commandDefinition, commandInputs) {
39
38
  }
40
39
  else {
41
40
  const commandString = createCommandString(executorOutput);
42
- console.log(`${cli_color_1.Color.Faint}${(0, node_only_1.toPosixPath)((0, path_1.relative)(process.cwd(), commandString))}${cli_color_1.Color.Reset}`);
41
+ console.log(`${node_js_1.logColors.faint}${(0, node_js_1.toPosixPath)((0, path_1.relative)(process.cwd(), commandString))}${node_js_1.logColors.reset}`);
43
42
  const commandResult = await (0, run_shell_command_1.runVirmatorShellCommand)(commandString, {
44
43
  repoDir: commandInputs.repoDir,
45
44
  logging: commandInputs.logging,
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runExtendedVirmator = void 0;
4
- const augment_vir_1 = require("augment-vir");
4
+ const common_1 = require("@augment-vir/common");
5
5
  const command_logging_1 = require("../command/command-logging");
6
6
  const command_messages_1 = require("../command/command-messages");
7
7
  const check_npm_deps_1 = require("./check-npm-deps");
8
8
  const extract_arguments_1 = require("./extract-arguments");
9
9
  const run_command_executor_1 = require("./run-command-executor");
10
10
  function availableCommandsString(commandMapping) {
11
- return `\nAvailable commands:\n ${(0, augment_vir_1.getObjectTypedKeys)(commandMapping).join(', ')}\n`;
11
+ return `\nAvailable commands:\n ${(0, common_1.getObjectTypedKeys)(commandMapping).join(', ')}\n`;
12
12
  }
13
13
  function getValidCommandDefinition(binName, commandMapping, givenCommandName) {
14
14
  if (!givenCommandName) {
15
15
  throw new Error(`Missing command name as first input to ${binName}.${availableCommandsString(commandMapping)}`);
16
16
  }
17
17
  const commandDefinition = commandMapping[givenCommandName];
18
- if (!(0, augment_vir_1.typedHasProperty)(commandMapping, givenCommandName) || !commandDefinition) {
18
+ if (!(0, common_1.typedHasProperty)(commandMapping, givenCommandName) || !commandDefinition) {
19
19
  throw new Error(`Invalid command "${givenCommandName} for ${binName}.${availableCommandsString(commandMapping)}"`);
20
20
  }
21
21
  return commandDefinition;
@@ -1,6 +1,6 @@
1
- import { ShellOutput } from 'augment-vir/dist/cjs/node-only';
1
+ import { ShellOutput } from '@augment-vir/node-js';
2
2
  import { CommandLogging, CommandLogTransforms } from '../command/command-logging';
3
- export declare type RunVirmatorShellCommandOptions = {
3
+ export type RunVirmatorShellCommandOptions = {
4
4
  repoDir: string;
5
5
  logging: CommandLogging;
6
6
  logTransforms?: CommandLogTransforms | undefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runVirmatorShellCommand = void 0;
4
- const node_only_1 = require("augment-vir/dist/cjs/node-only");
4
+ const node_js_1 = require("@augment-vir/node-js");
5
5
  const command_logging_1 = require("../command/command-logging");
6
6
  function logWrapper(handleLog, logTransformer) {
7
7
  return (input) => {
@@ -13,7 +13,7 @@ function logWrapper(handleLog, logTransformer) {
13
13
  }
14
14
  async function runVirmatorShellCommand(command, { repoDir: cwd, logging, logTransforms }) {
15
15
  var _a, _b;
16
- const shellResults = await (0, node_only_1.runShellCommand)(command, {
16
+ const shellResults = await (0, node_js_1.runShellCommand)(command, {
17
17
  cwd,
18
18
  stdoutCallback: logWrapper(logging.stdout, (_a = logTransforms === null || logTransforms === void 0 ? void 0 : logTransforms.stdout) !== null && _a !== void 0 ? _a : command_logging_1.identityCommandLogTransform),
19
19
  stderrCallback: logWrapper(logging.stderr, (_b = logTransforms === null || logTransforms === void 0 ? void 0 : logTransforms.stderr) !== null && _b !== void 0 ? _b : command_logging_1.identityCommandLogTransform),