virmator 8.0.5 → 9.0.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.
package/README.md CHANGED
@@ -42,6 +42,41 @@ Pass any extra tsc flags to this command.
42
42
 
43
43
  Run type checking without emitting compiled files.
44
44
 
45
+ ## deps
46
+
47
+ Either upgrade or check dependencies
48
+
49
+ ### check:
50
+
51
+ Check that dependencies are all good via a default set of rules in configs/dep-cruiser.config.ts and dependency-cruiser.
52
+
53
+ ### upgrade:
54
+
55
+ Upgrade all packages using npm-check-updates and configs/ncu.config.ts.
56
+
57
+ ### regen:
58
+
59
+ Regenerate all npm deps and package-lock.json
60
+
61
+ ### Examples
62
+
63
+ - Upgrade deps: `virmator deps upgrade`
64
+ - Check deps: `virmator deps check`
65
+ - Check deps for a specific file: `virmator deps check ./src/my-file.ts`
66
+ - Regen deps: `virmator deps regen`
67
+
68
+ ### check
69
+
70
+ validate dependencies
71
+
72
+ ### upgrade
73
+
74
+ upgrade npm dependencies
75
+
76
+ ### regen
77
+
78
+ regenerate npm dependencies
79
+
45
80
  ## docs
46
81
 
47
82
  This also inserts code snippets into markdown files. This uses the markdown-code-example-inserter package to expand code link comments inside of markdown files to actual markdown code blocks. See that package's README for more details but the basics are that you need a comment that looks like the following in your markdown file for this to do anything: `<!-- example-link: path/to/file.ts -->`
@@ -131,10 +166,6 @@ Publish an npm package. Includes workspace support. Add test commands to run bef
131
166
  - publish a package: `virmator publish`
132
167
  - publish a package and run tests beforehand: `virmator publish npm test`
133
168
 
134
- ## regen-deps
135
-
136
- Regenerates all npm deps.
137
-
138
169
  ## spellcheck
139
170
 
140
171
  Spellcheck code with cspell. By default this spellchecks every file in the entire repo (except for those ignored in the config file), including .dot files. If any arguments are passed to this command, the default cspell args that this command applies are ignored, you'll have to supply them via your args.
@@ -175,11 +206,3 @@ run web tests with code coverage calculations
175
206
  ## update-configs
176
207
 
177
208
  Update all existing configuration files that virmator is able to update. (Like base config files.)
178
-
179
- ## upgrade-deps
180
-
181
- Upgrade all packages using npm-check-updates and config/ncu.config.ts.
182
-
183
- ### Examples
184
-
185
- - Run command: `virmator upgrade-deps`
@@ -10,6 +10,7 @@ const baseConfig = {
10
10
  '**/build/',
11
11
  '**/coverage/',
12
12
  '**/dist/',
13
+ 'generated-config-*',
13
14
  '**/docs-dist/',
14
15
  '**/graphics/',
15
16
  '**/node_modules/',
@@ -55,6 +56,7 @@ const baseConfig = {
55
56
  'datamodel',
56
57
  'datasource',
57
58
  'deduped',
59
+ 'depcruise',
58
60
  'derp',
59
61
  'describedby',
60
62
  'devs',
@@ -196,7 +198,6 @@ const baseConfig = {
196
198
  'SIGINT',
197
199
  'SIGTERM',
198
200
  'sonarjs',
199
- 'sonarjs',
200
201
  'Srednekolymsk',
201
202
  'St_Kitts',
202
203
  'stackoverflow',
@@ -2,6 +2,7 @@
2
2
  coverage/
3
3
  dist/
4
4
  docs-dist/
5
+ generated-config-*
5
6
  graphics/
6
7
  node_modules/
7
8
  package-lock.json
@@ -0,0 +1,16 @@
1
+ import type {IConfiguration} from 'dependency-cruiser';
2
+ import {generateDepCruiserConfig} from 'virmator/dist/compiled-base-configs/base-dep-cruiser.config';
3
+
4
+ const depCruiserConfig: IConfiguration = generateDepCruiserConfig({
5
+ fileExceptions: {
6
+ // enter file exceptions by rule name here
7
+ 'no-orphans': [
8
+ 'src/index.ts',
9
+ ],
10
+ },
11
+ omitRules: [
12
+ // enter rule names here to omit
13
+ ],
14
+ });
15
+
16
+ module.exports = depCruiserConfig;
@@ -0,0 +1,16 @@
1
+ import type {IConfiguration} from 'dependency-cruiser';
2
+ import {generateDepCruiserConfig} from 'virmator/dist/compiled-base-configs/base-dep-cruiser.config';
3
+
4
+ const depCruiserConfig: IConfiguration = generateDepCruiserConfig({
5
+ fileExceptions: {
6
+ // enter file exceptions by rule name here
7
+ 'no-orphans': [
8
+ 'src/index.ts',
9
+ ],
10
+ },
11
+ omitRules: [
12
+ // enter rule names here to omit
13
+ ],
14
+ });
15
+
16
+ module.exports = depCruiserConfig;
@@ -4,6 +4,7 @@
4
4
  coverage/
5
5
  dist/
6
6
  docs-dist/
7
+ generated-config-*
7
8
  graphics/
8
9
  node_modules/
9
10
  src/all-files-for-code-coverage.test.ts
@@ -14,6 +14,7 @@
14
14
  /www-static/
15
15
  bash-scripts/
16
16
  docs-dist/
17
+ generated-config-*
17
18
  index.html
18
19
  test-files/
19
20
  tsconfig*.json
@@ -11,8 +11,9 @@
11
11
  "publish": "virmator publish \"npm run compile && npm run test:all\"",
12
12
  "start": "npm install && virmator frontend",
13
13
  "test": "virmator test",
14
- "test:all": "concurrently --colors --kill-others-on-fail -c auto --names types,tests,spelling,format,docs \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\"",
14
+ "test:all": "concurrently --colors --kill-others-on-fail -c auto --names types,tests,spelling,format,docs,deps \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\" \"npm run test:deps\"",
15
15
  "test:coverage": "npm run test coverage",
16
+ "test:deps": "virmator deps check",
16
17
  "test:docs": "virmator docs check",
17
18
  "test:format": "virmator format check",
18
19
  "test:spelling": "virmator spellcheck",
@@ -1,3 +1,4 @@
1
+ import { MaybePromise } from '@augment-vir/common';
1
2
  import { ConfigFileDefinition } from '../config/config-file-definition';
2
3
  import { CommandLogging, CommandLogTransforms } from './command-logging';
3
4
  import { DefineCommandInputs, SharedExecutorInputsAndCommandDefinition } from './define-command-inputs';
@@ -21,6 +22,7 @@ export type SuccessOnlyExecutorOutput = {
21
22
  export type BashCommandExecutorOutput = {
22
23
  logTransforms?: CommandLogTransforms;
23
24
  args: (string | DetailedArg)[];
25
+ postExecute?: () => MaybePromise<void>;
24
26
  };
25
27
  export declare function isCompletedExecutor(executorOutput: CommandExecutorOutput): executorOutput is SuccessOnlyExecutorOutput;
26
28
  export type CommandExecutorOutput = BashCommandExecutorOutput | SuccessOnlyExecutorOutput;
@@ -44,6 +44,7 @@ async function runCommandExecutor(commandDefinition, commandInputs) {
44
44
  logging: commandInputs.logging,
45
45
  logTransforms: executorOutput.logTransforms,
46
46
  });
47
+ await executorOutput.postExecute?.();
47
48
  return commandResult.exitCode === 0;
48
49
  }
49
50
  }
@@ -1 +1,5 @@
1
1
  export declare function withTypescriptConfigFile<T>(configPath: string, callback: (config: any) => Promise<T>): Promise<T>;
2
+ export declare function compileTs({ inputPath, outputPath, }: {
3
+ inputPath: string;
4
+ outputPath?: string | undefined;
5
+ }): Promise<string>;
@@ -23,22 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.withTypescriptConfigFile = void 0;
27
- const node_js_1 = require("@augment-vir/node-js");
26
+ exports.compileTs = exports.withTypescriptConfigFile = void 0;
28
27
  const promises_1 = require("fs/promises");
29
28
  const path_1 = require("path");
30
29
  async function withTypescriptConfigFile(configPath, callback) {
31
- const tempFilePath = (0, path_1.join)((0, path_1.dirname)(configPath), `config-output-${Date.now()}-${(0, node_js_1.randomString)()}.cjs`);
30
+ const tempFilePath = createOutfilePath(configPath);
32
31
  try {
33
- await (await Promise.resolve().then(() => __importStar(require('esbuild')))).build({
34
- entryPoints: [configPath],
35
- outfile: tempFilePath,
36
- write: true,
37
- target: ['node20'],
38
- platform: 'node',
39
- bundle: false,
40
- format: 'cjs',
41
- });
32
+ await compileTs({ inputPath: configPath, outputPath: tempFilePath });
42
33
  const loadedConfig = require(tempFilePath);
43
34
  return callback(loadedConfig);
44
35
  }
@@ -50,3 +41,23 @@ async function withTypescriptConfigFile(configPath, callback) {
50
41
  }
51
42
  }
52
43
  exports.withTypescriptConfigFile = withTypescriptConfigFile;
44
+ function createOutfilePath(inputFilePath) {
45
+ return (0, path_1.join)((0, path_1.dirname)(inputFilePath), [
46
+ 'generated-config',
47
+ (0, path_1.basename)(inputFilePath).replace(/\.ts$/, '.cjs'),
48
+ ].join('-'));
49
+ }
50
+ async function compileTs({ inputPath, outputPath, }) {
51
+ const outfile = outputPath || createOutfilePath(inputPath);
52
+ await (await Promise.resolve().then(() => __importStar(require('esbuild')))).build({
53
+ entryPoints: [inputPath],
54
+ outfile,
55
+ write: true,
56
+ target: ['node20'],
57
+ platform: 'node',
58
+ bundle: false,
59
+ format: 'cjs',
60
+ });
61
+ return outfile;
62
+ }
63
+ exports.compileTs = compileTs;
@@ -0,0 +1,144 @@
1
+ import { NpmDepTypeEnum } from '../api/command/define-command-inputs';
2
+ export declare const depsCommandDefinition: {
3
+ commandName: "deps";
4
+ subCommandDescriptions: {
5
+ readonly check: "validate dependencies";
6
+ readonly upgrade: "upgrade npm dependencies";
7
+ readonly regen: "regenerate npm dependencies";
8
+ };
9
+ configFiles: {
10
+ readonly depCruiserConfig: {
11
+ readonly copyFromInternalPath: string;
12
+ readonly copyToPathRelativeToRepoDir: string;
13
+ };
14
+ readonly ncuConfig: {
15
+ readonly copyFromInternalPath: string;
16
+ readonly copyToPathRelativeToRepoDir: string;
17
+ };
18
+ };
19
+ npmDeps: readonly [{
20
+ readonly name: "esbuild";
21
+ readonly type: NpmDepTypeEnum.Dev;
22
+ }, {
23
+ readonly name: "npm-check-updates";
24
+ readonly type: NpmDepTypeEnum.Dev;
25
+ }, {
26
+ readonly name: "dependency-cruiser";
27
+ readonly type: NpmDepTypeEnum.Dev;
28
+ }];
29
+ } & {
30
+ allAvailableSubCommands: readonly ("check" | "upgrade" | "regen")[];
31
+ subCommands: import("../api/command/define-command-inputs").SubCommandsMap<{
32
+ commandName: "deps";
33
+ subCommandDescriptions: {
34
+ readonly check: "validate dependencies";
35
+ readonly upgrade: "upgrade npm dependencies";
36
+ readonly regen: "regenerate npm dependencies";
37
+ };
38
+ configFiles: {
39
+ readonly depCruiserConfig: {
40
+ readonly copyFromInternalPath: string;
41
+ readonly copyToPathRelativeToRepoDir: string;
42
+ };
43
+ readonly ncuConfig: {
44
+ readonly copyFromInternalPath: string;
45
+ readonly copyToPathRelativeToRepoDir: string;
46
+ };
47
+ };
48
+ npmDeps: readonly [{
49
+ readonly name: "esbuild";
50
+ readonly type: NpmDepTypeEnum.Dev;
51
+ }, {
52
+ readonly name: "npm-check-updates";
53
+ readonly type: NpmDepTypeEnum.Dev;
54
+ }, {
55
+ readonly name: "dependency-cruiser";
56
+ readonly type: NpmDepTypeEnum.Dev;
57
+ }];
58
+ }>;
59
+ } & {
60
+ executor: import("..").CommandExecutor<{
61
+ commandName: "deps";
62
+ subCommandDescriptions: {
63
+ readonly check: "validate dependencies";
64
+ readonly upgrade: "upgrade npm dependencies";
65
+ readonly regen: "regenerate npm dependencies";
66
+ };
67
+ configFiles: {
68
+ readonly depCruiserConfig: {
69
+ readonly copyFromInternalPath: string;
70
+ readonly copyToPathRelativeToRepoDir: string;
71
+ };
72
+ readonly ncuConfig: {
73
+ readonly copyFromInternalPath: string;
74
+ readonly copyToPathRelativeToRepoDir: string;
75
+ };
76
+ };
77
+ npmDeps: readonly [{
78
+ readonly name: "esbuild";
79
+ readonly type: NpmDepTypeEnum.Dev;
80
+ }, {
81
+ readonly name: "npm-check-updates";
82
+ readonly type: NpmDepTypeEnum.Dev;
83
+ }, {
84
+ readonly name: "dependency-cruiser";
85
+ readonly type: NpmDepTypeEnum.Dev;
86
+ }];
87
+ }>;
88
+ createDescription: import("..").CreateDescriptionsCallback<{
89
+ commandName: "deps";
90
+ subCommandDescriptions: {
91
+ readonly check: "validate dependencies";
92
+ readonly upgrade: "upgrade npm dependencies";
93
+ readonly regen: "regenerate npm dependencies";
94
+ };
95
+ configFiles: {
96
+ readonly depCruiserConfig: {
97
+ readonly copyFromInternalPath: string;
98
+ readonly copyToPathRelativeToRepoDir: string;
99
+ };
100
+ readonly ncuConfig: {
101
+ readonly copyFromInternalPath: string;
102
+ readonly copyToPathRelativeToRepoDir: string;
103
+ };
104
+ };
105
+ npmDeps: readonly [{
106
+ readonly name: "esbuild";
107
+ readonly type: NpmDepTypeEnum.Dev;
108
+ }, {
109
+ readonly name: "npm-check-updates";
110
+ readonly type: NpmDepTypeEnum.Dev;
111
+ }, {
112
+ readonly name: "dependency-cruiser";
113
+ readonly type: NpmDepTypeEnum.Dev;
114
+ }];
115
+ }>;
116
+ extend: import("../api/command/define-command").ExtendCallback<{
117
+ commandName: "deps";
118
+ subCommandDescriptions: {
119
+ readonly check: "validate dependencies";
120
+ readonly upgrade: "upgrade npm dependencies";
121
+ readonly regen: "regenerate npm dependencies";
122
+ };
123
+ configFiles: {
124
+ readonly depCruiserConfig: {
125
+ readonly copyFromInternalPath: string;
126
+ readonly copyToPathRelativeToRepoDir: string;
127
+ };
128
+ readonly ncuConfig: {
129
+ readonly copyFromInternalPath: string;
130
+ readonly copyToPathRelativeToRepoDir: string;
131
+ };
132
+ };
133
+ npmDeps: readonly [{
134
+ readonly name: "esbuild";
135
+ readonly type: NpmDepTypeEnum.Dev;
136
+ }, {
137
+ readonly name: "npm-check-updates";
138
+ readonly type: NpmDepTypeEnum.Dev;
139
+ }, {
140
+ readonly name: "dependency-cruiser";
141
+ readonly type: NpmDepTypeEnum.Dev;
142
+ }];
143
+ }>;
144
+ };
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.depsCommandDefinition = void 0;
27
+ const common_1 = require("@augment-vir/common");
28
+ const node_js_1 = require("@augment-vir/node-js");
29
+ const fs_1 = require("fs");
30
+ const promises_1 = require("fs/promises");
31
+ const path_1 = require("path");
32
+ const define_command_1 = require("../api/command/define-command");
33
+ const define_command_inputs_1 = require("../api/command/define-command-inputs");
34
+ const fs_2 = require("../augments/fs");
35
+ const typescript_config_file_1 = require("../augments/typescript-config-file");
36
+ const package_paths_1 = require("../file-paths/package-paths");
37
+ exports.depsCommandDefinition = (0, define_command_1.defineCommand)({
38
+ commandName: 'deps',
39
+ subCommandDescriptions: {
40
+ check: 'validate dependencies',
41
+ upgrade: 'upgrade npm dependencies',
42
+ regen: 'regenerate npm dependencies',
43
+ },
44
+ configFiles: {
45
+ depCruiserConfig: {
46
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'configs', 'dep-cruiser.config.ts'),
47
+ copyToPathRelativeToRepoDir: (0, path_1.join)('configs', 'dep-cruiser.config.ts'),
48
+ },
49
+ ncuConfig: {
50
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'configs', 'ncu.config.ts'),
51
+ copyToPathRelativeToRepoDir: (0, path_1.join)('configs', 'ncu.config.ts'),
52
+ },
53
+ },
54
+ npmDeps: [
55
+ { name: 'esbuild', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
56
+ { name: 'npm-check-updates', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
57
+ { name: 'dependency-cruiser', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
58
+ ],
59
+ }, ({ commandName, packageBinName, configFiles, subCommands }) => {
60
+ return {
61
+ sections: [
62
+ {
63
+ title: '',
64
+ content: 'Either upgrade or check dependencies',
65
+ },
66
+ {
67
+ title: 'check',
68
+ content: `Check that dependencies are all good via a default set of rules in ${configFiles.depCruiserConfig.copyToPathRelativeToRepoDir} and dependency-cruiser.`,
69
+ },
70
+ {
71
+ title: 'upgrade',
72
+ content: `Upgrade all packages using npm-check-updates and ${configFiles.ncuConfig.copyToPathRelativeToRepoDir}.`,
73
+ },
74
+ {
75
+ title: 'regen',
76
+ content: 'Regenerate all npm deps and package-lock.json',
77
+ },
78
+ ],
79
+ examples: [
80
+ {
81
+ title: 'Upgrade deps',
82
+ content: `${packageBinName} ${commandName} ${subCommands.upgrade}`,
83
+ },
84
+ {
85
+ title: 'Check deps',
86
+ content: `${packageBinName} ${commandName} ${subCommands.check}`,
87
+ },
88
+ {
89
+ title: 'Check deps for a specific file',
90
+ content: `${packageBinName} ${commandName} ${subCommands.check} ./src/my-file.ts`,
91
+ },
92
+ {
93
+ title: 'Regen deps',
94
+ content: `${packageBinName} ${commandName} ${subCommands.regen}`,
95
+ },
96
+ ],
97
+ };
98
+ }, async ({ inputSubCommands, subCommands, allAvailableSubCommands, commandName, repoDir, packageDir, configFiles, filteredInputArgs, logging, }) => {
99
+ const subCommandsErrorString = allAvailableSubCommands.join(',');
100
+ if (!(0, common_1.isLengthAtLeast)(inputSubCommands, 1)) {
101
+ throw new Error(`Missing sub command for '${commandName}' command: expected one of ${subCommandsErrorString}`);
102
+ }
103
+ else if (inputSubCommands.length > 1) {
104
+ throw new Error(`Too many sub commands given to '${commandName}' command, only one is allowed from: ${subCommandsErrorString}`);
105
+ }
106
+ else if (inputSubCommands[0] === subCommands.check) {
107
+ const depCruiserConfigPath = (0, path_1.join)(repoDir, configFiles.depCruiserConfig.copyToPathRelativeToRepoDir);
108
+ const compiledConfigPath = await (0, typescript_config_file_1.compileTs)({ inputPath: depCruiserConfigPath });
109
+ const pathsToCheck = filteredInputArgs.length
110
+ ? filteredInputArgs
111
+ : [(0, path_1.join)(repoDir, 'src')];
112
+ const depCruiseCommand = await (0, package_paths_1.getNpmBinPath)({
113
+ repoDir: repoDir,
114
+ command: 'depcruise',
115
+ packageDirPath: packageDir,
116
+ });
117
+ return {
118
+ args: [
119
+ depCruiseCommand,
120
+ '--config',
121
+ compiledConfigPath,
122
+ ...pathsToCheck,
123
+ ],
124
+ async postExecute() {
125
+ await (0, promises_1.unlink)(compiledConfigPath);
126
+ },
127
+ };
128
+ }
129
+ else if (inputSubCommands[0] === subCommands.upgrade) {
130
+ const ncuConfigPath = (0, path_1.join)(repoDir, configFiles.ncuConfig.copyToPathRelativeToRepoDir);
131
+ return await (0, typescript_config_file_1.withTypescriptConfigFile)(ncuConfigPath, async (loadedConfig) => {
132
+ const repoPackageJson = await (0, node_js_1.readPackageJson)(repoDir);
133
+ const config = loadedConfig.ncuConfig;
134
+ await (await Promise.resolve().then(() => __importStar(require('npm-check-updates')))).run({
135
+ ...config,
136
+ cwd: repoDir,
137
+ json: false,
138
+ workspaces: !!repoPackageJson.workspaces,
139
+ format: [],
140
+ }, {
141
+ cli: true,
142
+ });
143
+ return { success: true };
144
+ });
145
+ }
146
+ else if (inputSubCommands[0] === subCommands.regen) {
147
+ const allChildNodeModules = await (0, node_js_1.readDirRecursive)(repoDir);
148
+ const nodeModulesPaths = Array.from(new Set(allChildNodeModules
149
+ .filter((path) => path.includes('node_modules'))
150
+ .map((path) => path.replace(/([\\\/]|^)node_modules[\\\/].+$/, '$1node_modules'))));
151
+ const packageLockPath = (0, path_1.join)(repoDir, 'package-lock.json');
152
+ const removePackageLock = (0, fs_1.existsSync)(packageLockPath);
153
+ const logLines = [
154
+ 'Removing node_modules:',
155
+ ...nodeModulesPaths.map((nodeModulesPath) => ` ${nodeModulesPath}`),
156
+ removePackageLock ? '\nRemoving package-lock.json' : '',
157
+ ].filter(common_1.isTruthy);
158
+ logging.stdout((0, node_js_1.toLogString)({
159
+ args: [
160
+ logLines.join('\n'),
161
+ ],
162
+ colors: node_js_1.ColorKey.faint,
163
+ }));
164
+ let errorsHappened = false;
165
+ if (removePackageLock) {
166
+ try {
167
+ await (0, promises_1.unlink)(packageLockPath);
168
+ }
169
+ catch (error) {
170
+ errorsHappened = true;
171
+ logging.stderr('Failed to remove package-lock.json.');
172
+ }
173
+ }
174
+ await Promise.all(nodeModulesPaths.map(async (nodeModulesPath) => {
175
+ try {
176
+ await (0, fs_2.removeDirectory)(nodeModulesPath);
177
+ }
178
+ catch (error) {
179
+ errorsHappened = true;
180
+ logging.stderr('Failed to remove package-lock.json.');
181
+ }
182
+ }));
183
+ if (errorsHappened) {
184
+ return {
185
+ success: false,
186
+ };
187
+ }
188
+ return {
189
+ args: [
190
+ 'npm',
191
+ 'i',
192
+ ],
193
+ };
194
+ }
195
+ else {
196
+ throw new Error(`Invalid sub command for '${commandName}' given: got '${inputSubCommands[0]}' but expected one of ${subCommandsErrorString}`);
197
+ }
198
+ });
@@ -127,15 +127,15 @@ async function runTypeDoc(options, packageBinName, typeDoc) {
127
127
  new typeDoc.TSConfigReader(),
128
128
  ]);
129
129
  if (app.options.getValue('version')) {
130
- console.log(app.toString());
130
+ console.info(app.toString());
131
131
  return true;
132
132
  }
133
133
  else if (app.options.getValue('help')) {
134
- console.log(app.options.getHelp());
134
+ console.info(app.options.getHelp());
135
135
  return true;
136
136
  }
137
137
  else if (app.options.getValue('showConfig')) {
138
- console.log(app.options.getRawValues());
138
+ console.info(app.options.getRawValues());
139
139
  return true;
140
140
  }
141
141
  else if (app.logger.hasErrors()) {
@@ -25,7 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.frontendCommandDefinition = void 0;
27
27
  const common_1 = require("@augment-vir/common");
28
- const node_js_1 = require("@augment-vir/node-js");
29
28
  const promises_1 = require("fs/promises");
30
29
  const path_1 = require("path");
31
30
  const define_command_1 = require("../api/command/define-command");
@@ -67,7 +66,7 @@ exports.frontendCommandDefinition = (0, define_command_1.defineCommand)({
67
66
  configFileDefinition: inputs.configFiles.vite,
68
67
  packageDir: package_paths_1.virmatorPackageDir,
69
68
  });
70
- const tempFilePath = (0, path_1.join)((0, path_1.dirname)(viteConfigPath), `config-output-${Date.now()}-${(0, node_js_1.randomString)()}.cjs`);
69
+ const tempFilePath = (0, path_1.join)((0, path_1.dirname)(viteConfigPath), `config-output-${Date.now()}-${(0, common_1.randomString)()}.cjs`);
71
70
  const oldWrite = process.stdout.write;
72
71
  try {
73
72
  const needToBuild = !!inputs.inputSubCommands.length;