virmator 12.0.4 → 13.0.2
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 +224 -129
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +21 -5
- package/dist/index.d.ts +1416 -1310
- package/dist/index.js +25 -63
- package/dist/tests/test-virmator.mock.d.ts +3 -0
- package/dist/tests/test-virmator.mock.js +5 -0
- package/package.json +25 -69
- package/src/cli.ts +29 -0
- package/src/index.ts +26 -0
- package/src/tests/test-virmator.mock.ts +13 -0
- package/base-configs/base-cspell.js +0 -272
- package/base-configs/base-mocharc.cjs +0 -20
- package/base-configs/base-nyc.js +0 -40
- package/base-configs/base-prettierrc.js +0 -32
- package/base-configs/base-web-test-runner.mjs +0 -137
- package/base-configs/test-files-glob.js +0 -13
- package/base-configs/tsconfig.base.json +0 -32
- package/configs/.gitattributes +0 -2
- package/configs/.github/workflows/build-for-gh-pages.yml +0 -24
- package/configs/.github/workflows/tagged-release.yml +0 -41
- package/configs/.github/workflows/tests.yml +0 -25
- package/configs/.nvmrc +0 -1
- package/configs/.prettierignore +0 -11
- package/configs/.prettierrc.js +0 -13
- package/configs/.vscode/settings.json +0 -50
- package/configs/LICENSE-CC0 +0 -121
- package/configs/LICENSE-MIT +0 -21
- package/configs/configs/dep-cruiser.config.ts +0 -22
- package/configs/configs/mocha.config.cjs +0 -8
- package/configs/configs/ncu.config.ts +0 -12
- package/configs/configs/nyc.config.js +0 -7
- package/configs/configs/typedoc.config.ts +0 -20
- package/configs/configs/vite.config.ts +0 -14
- package/configs/configs/web-test-runner.config.mjs +0 -21
- package/configs/cspell.config.cjs +0 -11
- package/configs/dep-cruiser.config.ts +0 -22
- package/configs/gitignore.txt +0 -13
- package/configs/ncu.config.ts +0 -13
- package/configs/npmignore.txt +0 -26
- package/configs/package.json +0 -23
- package/configs/src/index.html +0 -12
- package/configs/src/ui/elements/vir-app.element.ts +0 -10
- package/configs/tsconfig.json +0 -16
- package/configs/www-static/_redirects +0 -1
- package/configs/www-static/index.css +0 -7
- package/cspell.config.cjs +0 -13
- package/dist/api/command/command-configs.d.ts +0 -3
- package/dist/api/command/command-configs.js +0 -10
- package/dist/api/command/command-description.d.ts +0 -8
- package/dist/api/command/command-description.js +0 -2
- package/dist/api/command/command-executor.d.ts +0 -30
- package/dist/api/command/command-executor.js +0 -6
- package/dist/api/command/command-help.d.ts +0 -8
- package/dist/api/command/command-help.js +0 -2
- package/dist/api/command/command-logging.d.ts +0 -11
- package/dist/api/command/command-logging.js +0 -17
- package/dist/api/command/command-mapping.d.ts +0 -7
- package/dist/api/command/command-mapping.js +0 -9
- package/dist/api/command/command-messages.d.ts +0 -1
- package/dist/api/command/command-messages.js +0 -9
- package/dist/api/command/command-to-help-message.d.ts +0 -9
- package/dist/api/command/command-to-help-message.js +0 -175
- package/dist/api/command/define-command-inputs.d.ts +0 -22
- package/dist/api/command/define-command-inputs.js +0 -8
- package/dist/api/command/define-command.d.ts +0 -22
- package/dist/api/command/define-command.js +0 -41
- package/dist/api/config/config-file-definition.d.ts +0 -15
- package/dist/api/config/config-file-definition.js +0 -2
- package/dist/api/config/config-paths.d.ts +0 -7
- package/dist/api/config/config-paths.js +0 -7
- package/dist/api/config/copy-config.d.ts +0 -27
- package/dist/api/config/copy-config.js +0 -98
- package/dist/api/create-virmator.d.ts +0 -8
- package/dist/api/create-virmator.js +0 -67
- package/dist/api/run-command/check-npm-deps.d.ts +0 -8
- package/dist/api/run-command/check-npm-deps.js +0 -111
- package/dist/api/run-command/extract-arguments.d.ts +0 -6
- package/dist/api/run-command/extract-arguments.js +0 -36
- package/dist/api/run-command/run-command-executor.d.ts +0 -5
- package/dist/api/run-command/run-command-executor.js +0 -50
- package/dist/api/run-command/run-extended-virmator.d.ts +0 -10
- package/dist/api/run-command/run-extended-virmator.js +0 -53
- package/dist/api/run-command/run-shell-command.d.ts +0 -8
- package/dist/api/run-command/run-shell-command.js +0 -21
- package/dist/api/virmator-types.d.ts +0 -18
- package/dist/api/virmator-types.js +0 -2
- package/dist/augments/array.d.ts +0 -1
- package/dist/augments/array.js +0 -6
- package/dist/augments/console.d.ts +0 -9
- package/dist/augments/console.js +0 -43
- package/dist/augments/fs.d.ts +0 -11
- package/dist/augments/fs.js +0 -71
- package/dist/augments/git.d.ts +0 -1
- package/dist/augments/git.js +0 -12
- package/dist/augments/json.d.ts +0 -1
- package/dist/augments/json.js +0 -11
- package/dist/augments/npm.d.ts +0 -11
- package/dist/augments/npm.js +0 -52
- package/dist/augments/object.d.ts +0 -4
- package/dist/augments/object.js +0 -44
- package/dist/augments/path.d.ts +0 -1
- package/dist/augments/path.js +0 -12
- package/dist/augments/prettier.d.ts +0 -1
- package/dist/augments/prettier.js +0 -52
- package/dist/augments/regexp.d.ts +0 -1
- package/dist/augments/regexp.js +0 -6
- package/dist/augments/string.d.ts +0 -2
- package/dist/augments/string.js +0 -9
- package/dist/augments/type.d.ts +0 -1
- package/dist/augments/type.js +0 -2
- package/dist/augments/typescript-config-file.d.ts +0 -5
- package/dist/augments/typescript-config-file.js +0 -62
- package/dist/commands/compile.command.d.ts +0 -84
- package/dist/commands/compile.command.js +0 -58
- package/dist/commands/deps.command.d.ts +0 -144
- package/dist/commands/deps.command.js +0 -208
- package/dist/commands/docs.command.d.ts +0 -99
- package/dist/commands/docs.command.js +0 -192
- package/dist/commands/extra-configs/all-extra-configs.d.ts +0 -2
- package/dist/commands/extra-configs/all-extra-configs.js +0 -71
- package/dist/commands/extra-configs/combine-json-config.d.ts +0 -2
- package/dist/commands/extra-configs/combine-json-config.js +0 -21
- package/dist/commands/extra-configs/combine-text-config.d.ts +0 -2
- package/dist/commands/extra-configs/combine-text-config.js +0 -26
- package/dist/commands/extra-configs/create-default-package-json.d.ts +0 -1
- package/dist/commands/extra-configs/create-default-package-json.js +0 -86
- package/dist/commands/format.command.d.ts +0 -215
- package/dist/commands/format.command.js +0 -157
- package/dist/commands/frontend.command.d.ts +0 -149
- package/dist/commands/frontend.command.js +0 -140
- package/dist/commands/init.command.d.ts +0 -163
- package/dist/commands/init.command.js +0 -53
- package/dist/commands/publish.command.d.ts +0 -33
- package/dist/commands/publish.command.js +0 -193
- package/dist/commands/spellcheck.command.d.ts +0 -74
- package/dist/commands/spellcheck.command.js +0 -60
- package/dist/commands/test-web.command.d.ts +0 -189
- package/dist/commands/test-web.command.js +0 -125
- package/dist/commands/test.command.d.ts +0 -224
- package/dist/commands/test.command.js +0 -100
- package/dist/commands/update-configs.command.d.ts +0 -33
- package/dist/commands/update-configs.command.js +0 -35
- package/dist/compiled-base-configs/base-dep-cruiser.config.d.ts +0 -195
- package/dist/compiled-base-configs/base-dep-cruiser.config.js +0 -206
- package/dist/compiled-base-configs/base-ncu.d.ts +0 -6
- package/dist/compiled-base-configs/base-ncu.js +0 -16
- package/dist/compiled-base-configs/base-typedoc.d.ts +0 -3
- package/dist/compiled-base-configs/base-typedoc.js +0 -36
- package/dist/compiled-base-configs/base-vite.d.ts +0 -27
- package/dist/compiled-base-configs/base-vite.js +0 -74
- package/dist/compiled-base-configs/vite-always-reload-plugin.d.ts +0 -10
- package/dist/compiled-base-configs/vite-always-reload-plugin.js +0 -99
- package/dist/file-paths/package-paths.d.ts +0 -12
- package/dist/file-paths/package-paths.js +0 -46
- package/dist/scripts/save-help-message.d.ts +0 -1
- package/dist/scripts/save-help-message.js +0 -33
- package/mocha.config.cjs +0 -16
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CopyConfigOperation = void 0;
|
|
4
|
-
exports.copyConfig = copyConfig;
|
|
5
|
-
exports.copyAllConfigFiles = copyAllConfigFiles;
|
|
6
|
-
const common_1 = require("@augment-vir/common");
|
|
7
|
-
const node_js_1 = require("@augment-vir/node-js");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const promises_1 = require("fs/promises");
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
const config_paths_1 = require("./config-paths");
|
|
12
|
-
var CopyConfigOperation;
|
|
13
|
-
(function (CopyConfigOperation) {
|
|
14
|
-
/** Only update the config file if it exists and is marked as being able to be updated. */
|
|
15
|
-
CopyConfigOperation["Update"] = "update";
|
|
16
|
-
/** Overwrite config file, even if it already exists in the repo. */
|
|
17
|
-
CopyConfigOperation["Overwrite"] = "overwrite";
|
|
18
|
-
/** Only write the config file if it doesn't exist already or if it can be updated. */
|
|
19
|
-
CopyConfigOperation["Init"] = "init";
|
|
20
|
-
})(CopyConfigOperation || (exports.CopyConfigOperation = CopyConfigOperation = {}));
|
|
21
|
-
function checkIfShouldWrite({ configFileDefinition, operation, copyToPath, }) {
|
|
22
|
-
const fileExists = (0, fs_1.existsSync)(copyToPath);
|
|
23
|
-
switch (operation) {
|
|
24
|
-
case CopyConfigOperation.Init: {
|
|
25
|
-
return !fileExists || !!configFileDefinition.updateExistingConfigFileCallback;
|
|
26
|
-
}
|
|
27
|
-
case CopyConfigOperation.Overwrite: {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
case CopyConfigOperation.Update: {
|
|
31
|
-
return fileExists && !!configFileDefinition.updateExistingConfigFileCallback;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async function copyConfig(inputs) {
|
|
36
|
-
const copyFromPath = inputs.configFileDefinition.copyFromInternalPath;
|
|
37
|
-
const copyToPath = (0, config_paths_1.getCopyToPath)(inputs);
|
|
38
|
-
const shouldWriteBasedOnOperation = checkIfShouldWrite({
|
|
39
|
-
configFileDefinition: inputs.configFileDefinition,
|
|
40
|
-
operation: inputs.operation,
|
|
41
|
-
copyToPath,
|
|
42
|
-
});
|
|
43
|
-
const currentRepoFileContents = (0, fs_1.existsSync)(copyToPath)
|
|
44
|
-
? (await (0, promises_1.readFile)(copyToPath)).toString()
|
|
45
|
-
: '';
|
|
46
|
-
const virmatorFileContents = (await (0, promises_1.readFile)(copyFromPath)).toString();
|
|
47
|
-
const writeContents = inputs.configFileDefinition.updateExistingConfigFileCallback
|
|
48
|
-
? await inputs.configFileDefinition.updateExistingConfigFileCallback(virmatorFileContents, currentRepoFileContents, inputs.repoDir)
|
|
49
|
-
: virmatorFileContents;
|
|
50
|
-
const shouldWrite = shouldWriteBasedOnOperation && currentRepoFileContents !== writeContents;
|
|
51
|
-
if (shouldWrite) {
|
|
52
|
-
await (0, promises_1.mkdir)((0, path_1.dirname)(copyToPath), { recursive: true });
|
|
53
|
-
await (0, promises_1.writeFile)(copyToPath, writeContents);
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
copiedToPath: copyToPath,
|
|
57
|
-
shouldWrite,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const successfulOperation = {
|
|
61
|
-
[CopyConfigOperation.Init]: 'copied',
|
|
62
|
-
[CopyConfigOperation.Overwrite]: 'overwrote',
|
|
63
|
-
[CopyConfigOperation.Update]: 'updated',
|
|
64
|
-
};
|
|
65
|
-
const failedOperation = {
|
|
66
|
-
[CopyConfigOperation.Init]: 'copy',
|
|
67
|
-
[CopyConfigOperation.Overwrite]: 'overwrite',
|
|
68
|
-
[CopyConfigOperation.Update]: 'update',
|
|
69
|
-
};
|
|
70
|
-
/** Returns success state. True if success, false is errors were encountered. */
|
|
71
|
-
async function copyAllConfigFiles(inputs) {
|
|
72
|
-
const errors = [];
|
|
73
|
-
await (0, common_1.awaitedForEach)(inputs.configFiles.sort((a, b) => {
|
|
74
|
-
const aName = (0, path_1.basename)(a.copyToPathRelativeToRepoDir || a.copyFromInternalPath);
|
|
75
|
-
const bName = (0, path_1.basename)(b.copyToPathRelativeToRepoDir || b.copyFromInternalPath);
|
|
76
|
-
return aName.localeCompare(bName);
|
|
77
|
-
}), async (configFile) => {
|
|
78
|
-
try {
|
|
79
|
-
const result = await copyConfig({
|
|
80
|
-
configFileDefinition: configFile,
|
|
81
|
-
operation: inputs.operation,
|
|
82
|
-
repoDir: inputs.repoDir,
|
|
83
|
-
packageDir: inputs.packageDir,
|
|
84
|
-
});
|
|
85
|
-
if (result.shouldWrite) {
|
|
86
|
-
inputs.logging.stdout(`${node_js_1.logColors.info}Successfully ${successfulOperation[inputs.operation]}${node_js_1.logColors.reset} ${(0, path_1.basename)(result.copiedToPath)}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
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)}`);
|
|
91
|
-
errors.push(copyError);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
errors.forEach((error) => {
|
|
95
|
-
inputs.logging.stderr(error.message);
|
|
96
|
-
});
|
|
97
|
-
return !errors.length;
|
|
98
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CommandDefinitionArrayToMapping } from './command/command-mapping';
|
|
2
|
-
import { CommandDefinition } from './command/define-command';
|
|
3
|
-
import { ExtendVirmatorInputs, ExtendedVirmator } from './virmator-types';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a wrapped instance of virmator from which all its CLI commands can be called. Arguments
|
|
6
|
-
* can be passed in to add to virmator default configs or overwrite them.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createVirmator<CommandDefinitionsGeneric extends ReadonlyArray<CommandDefinition>>(inputs: ExtendVirmatorInputs<CommandDefinitionsGeneric>): ExtendedVirmator<CommandDefinitionArrayToMapping<CommandDefinitionsGeneric>>;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVirmator = createVirmator;
|
|
4
|
-
const common_1 = require("@augment-vir/common");
|
|
5
|
-
const command_configs_1 = require("./command/command-configs");
|
|
6
|
-
const command_mapping_1 = require("./command/command-mapping");
|
|
7
|
-
const command_to_help_message_1 = require("./command/command-to-help-message");
|
|
8
|
-
const run_extended_virmator_1 = require("./run-command/run-extended-virmator");
|
|
9
|
-
/**
|
|
10
|
-
* Creates a wrapped instance of virmator from which all its CLI commands can be called. Arguments
|
|
11
|
-
* can be passed in to add to virmator default configs or overwrite them.
|
|
12
|
-
*/
|
|
13
|
-
function createVirmator(inputs) {
|
|
14
|
-
const commandDefinitions = inputs.commandDefinitions ?? [];
|
|
15
|
-
const commandMapping = (0, command_mapping_1.commandsToMapping)(commandDefinitions);
|
|
16
|
-
const allCommands = {
|
|
17
|
-
...{}, // todo: put the default commands here
|
|
18
|
-
...commandMapping,
|
|
19
|
-
};
|
|
20
|
-
const cliHelpMessage = (0, command_to_help_message_1.generateHelpMessage)(inputs.packageBinName, allCommands ?? {}, command_to_help_message_1.HelpMessageSyntax.Cli);
|
|
21
|
-
const markdownHelpMessage = (0, command_to_help_message_1.generateHelpMessage)(inputs.packageBinName, allCommands, command_to_help_message_1.HelpMessageSyntax.Markdown);
|
|
22
|
-
const allConfigs = (0, command_configs_1.extractAllConfigs)(commandMapping);
|
|
23
|
-
async function run(allArgs, repoDir) {
|
|
24
|
-
return await (0, run_extended_virmator_1.runExtendedVirmator)({
|
|
25
|
-
allArgs,
|
|
26
|
-
repoDir,
|
|
27
|
-
packageBinName: inputs.packageBinName,
|
|
28
|
-
packageDir: inputs.packageRootDir,
|
|
29
|
-
commandMapping: allCommands,
|
|
30
|
-
allConfigs,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async function runInCli() {
|
|
34
|
-
try {
|
|
35
|
-
await run(process.argv, process.cwd());
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
if (process.env.INCLUDE_VIRMATOR_STACK_TRACE) {
|
|
39
|
-
console.error(error);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.error((0, common_1.extractErrorMessage)(error));
|
|
43
|
-
}
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function extendVirmator(innerInputs) {
|
|
48
|
-
const allCommandDefinitions = [
|
|
49
|
-
...commandDefinitions,
|
|
50
|
-
...(innerInputs.commandDefinitions ?? []),
|
|
51
|
-
];
|
|
52
|
-
return createVirmator({
|
|
53
|
-
...innerInputs,
|
|
54
|
-
commandDefinitions: allCommandDefinitions,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
packageBinName: inputs.packageBinName,
|
|
59
|
-
cliHelpMessage,
|
|
60
|
-
extend: extendVirmator,
|
|
61
|
-
markdownHelpMessage,
|
|
62
|
-
commandMapping: allCommands,
|
|
63
|
-
allConfigs,
|
|
64
|
-
runInCli,
|
|
65
|
-
run,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DefineCommandInputs } from '../command/define-command-inputs';
|
|
2
|
-
export type UpdateDepsInput = Readonly<{
|
|
3
|
-
repoDir: string;
|
|
4
|
-
packageDir: string;
|
|
5
|
-
npmDeps: DefineCommandInputs['npmDeps'];
|
|
6
|
-
packageBinName: string;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function updateDepsAsNeeded(inputs: UpdateDepsInput): Promise<void>;
|
|
@@ -1,111 +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
|
-
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.updateDepsAsNeeded = updateDepsAsNeeded;
|
|
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 semver = __importStar(require("semver"));
|
|
33
|
-
const fs_2 = require("../../augments/fs");
|
|
34
|
-
const define_command_inputs_1 = require("../command/define-command-inputs");
|
|
35
|
-
async function updateDepsAsNeeded(inputs) {
|
|
36
|
-
try {
|
|
37
|
-
const upgradeVersions = await getVersionsToUpgradeTo(inputs);
|
|
38
|
-
const depsToUpdate = upgradeVersions.filter(common_1.isTruthy);
|
|
39
|
-
await (0, common_1.awaitedForEach)(depsToUpdate, async (depDetails) => {
|
|
40
|
-
const depToInstall = `${depDetails.name}@${depDetails.exactVersion}`;
|
|
41
|
-
node_js_1.log.info(`Installing ${depToInstall}...`);
|
|
42
|
-
await (0, node_js_1.runShellCommand)(`npm i ${depDetails.type === define_command_inputs_1.NpmDepTypeEnum.Dev ? '-D' : ''} ${depToInstall}`, {
|
|
43
|
-
cwd: inputs.repoDir,
|
|
44
|
-
rejectOnError: true,
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
throw new Error(`Failed to update deps: ${(0, common_1.extractErrorMessage)(error)}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function cleanDepVersion(input) {
|
|
53
|
-
if (input === '*') {
|
|
54
|
-
return '*';
|
|
55
|
-
}
|
|
56
|
-
return input ? (semver.clean(input) ?? semver.minVersion(input)?.raw ?? undefined) : undefined;
|
|
57
|
-
}
|
|
58
|
-
async function getVersionsToUpgradeTo({ repoDir, packageDir, npmDeps, packageBinName, }) {
|
|
59
|
-
const packageName = (await (0, node_js_1.runShellCommand)(`cut -d "=" -f 2 <<< $(npm run env | grep "npm_package_name")`, {
|
|
60
|
-
cwd: repoDir,
|
|
61
|
-
rejectOnError: true,
|
|
62
|
-
})).stdout.trim();
|
|
63
|
-
const currentRepoDepVersions = await getDeps(repoDir, packageName);
|
|
64
|
-
const virmatorPackageJson = JSON.parse((await (0, promises_1.readFile)((0, path_1.join)(packageDir, 'package.json'))).toString());
|
|
65
|
-
const packageDepVersions = {
|
|
66
|
-
...virmatorPackageJson.devDependencies,
|
|
67
|
-
...virmatorPackageJson.dependencies,
|
|
68
|
-
};
|
|
69
|
-
return npmDeps.map((npmDep) => {
|
|
70
|
-
try {
|
|
71
|
-
const currentRepoVersion = cleanDepVersion(currentRepoDepVersions[npmDep.name]);
|
|
72
|
-
const virmatorDepVersion = packageDepVersions[npmDep.name];
|
|
73
|
-
const cleanVirmatorDepVersion = cleanDepVersion(virmatorDepVersion);
|
|
74
|
-
if (!cleanVirmatorDepVersion || !virmatorDepVersion) {
|
|
75
|
-
throw new Error(`No npm dep version listed for "${npmDep.name}" in ${packageBinName}'s dependencies.`);
|
|
76
|
-
}
|
|
77
|
-
if (currentRepoVersion !== '*' &&
|
|
78
|
-
(!currentRepoVersion ||
|
|
79
|
-
semver.gt(cleanVirmatorDepVersion, currentRepoVersion) ||
|
|
80
|
-
(virmatorDepVersion.match(/^\d/) &&
|
|
81
|
-
cleanVirmatorDepVersion !== currentRepoVersion))) {
|
|
82
|
-
return {
|
|
83
|
-
...npmDep,
|
|
84
|
-
cleanVersion: cleanVirmatorDepVersion,
|
|
85
|
-
exactVersion: virmatorDepVersion,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
async function getDeps(repoDir, packageName) {
|
|
98
|
-
if (repoDir === fs_2.systemRootPath) {
|
|
99
|
-
return {};
|
|
100
|
-
}
|
|
101
|
-
const packageJsonPath = (0, path_1.join)(repoDir, 'package.json');
|
|
102
|
-
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
103
|
-
return getDeps((0, path_1.dirname)(repoDir), packageName);
|
|
104
|
-
}
|
|
105
|
-
const packageJson = await (0, node_js_1.readJson)(packageJsonPath);
|
|
106
|
-
const allDeps = {
|
|
107
|
-
...(packageJson?.dependencies ?? {}),
|
|
108
|
-
...(packageJson?.devDependencies ?? {}),
|
|
109
|
-
};
|
|
110
|
-
return allDeps;
|
|
111
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function getRelevantArgs(allArgs: string[], binName: string): string[];
|
|
2
|
-
export type ExtractSubCommandsOutput<T extends string> = {
|
|
3
|
-
subCommands: T[];
|
|
4
|
-
filteredArgs: string[];
|
|
5
|
-
};
|
|
6
|
-
export declare function extractSubCommands<T extends string = string>(allArgs: ReadonlyArray<string>, availableSubCommands: ReadonlyArray<T>): ExtractSubCommandsOutput<T>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRelevantArgs = getRelevantArgs;
|
|
4
|
-
exports.extractSubCommands = extractSubCommands;
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const array_1 = require("../../augments/array");
|
|
7
|
-
function getRelevantArgs(allArgs, binName) {
|
|
8
|
-
const binIndex = allArgs.findIndex((arg) => {
|
|
9
|
-
return arg.includes((0, path_1.join)('', 'node_modules', '.bin', binName));
|
|
10
|
-
});
|
|
11
|
-
const firstJsOrTsIndex = allArgs.findIndex((arg) => {
|
|
12
|
-
return arg.match(/\.[tj]sx?$/);
|
|
13
|
-
});
|
|
14
|
-
const binWasFound = binIndex > -1;
|
|
15
|
-
const firstJsOrTsWasFound = firstJsOrTsIndex > -1;
|
|
16
|
-
const sliceIndexStart = binWasFound ? binIndex : firstJsOrTsWasFound ? firstJsOrTsIndex : 0;
|
|
17
|
-
return allArgs.slice(sliceIndexStart + 1);
|
|
18
|
-
}
|
|
19
|
-
function extractSubCommands(allArgs, availableSubCommands) {
|
|
20
|
-
let stillInSubCommands = true;
|
|
21
|
-
return allArgs.reduce((accum, currentArg) => {
|
|
22
|
-
if (stillInSubCommands) {
|
|
23
|
-
if ((0, array_1.isInTypedArray)(currentArg, availableSubCommands)) {
|
|
24
|
-
accum.subCommands.push(currentArg);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
stillInSubCommands = false;
|
|
28
|
-
accum.filteredArgs.push(currentArg);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
accum.filteredArgs.push(currentArg);
|
|
33
|
-
}
|
|
34
|
-
return accum;
|
|
35
|
-
}, { subCommands: [], filteredArgs: [] });
|
|
36
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BashCommandExecutorOutput, CommandExecutorInputs } from '../command/command-executor';
|
|
2
|
-
import { CommandDefinition } from '../command/define-command';
|
|
3
|
-
import { DefineCommandInputs } from '../command/define-command-inputs';
|
|
4
|
-
export declare function createCommandString(executorOutput: BashCommandExecutorOutput): string;
|
|
5
|
-
export declare function runCommandExecutor<DefineCommandInputsGeneric extends DefineCommandInputs>(commandDefinition: CommandDefinition<DefineCommandInputsGeneric>, commandInputs: CommandExecutorInputs<DefineCommandInputsGeneric>): Promise<boolean>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommandString = createCommandString;
|
|
4
|
-
exports.runCommandExecutor = runCommandExecutor;
|
|
5
|
-
const common_1 = require("@augment-vir/common");
|
|
6
|
-
const node_js_1 = require("@augment-vir/node-js");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const command_executor_1 = require("../command/command-executor");
|
|
9
|
-
const copy_config_1 = require("../config/copy-config");
|
|
10
|
-
const run_shell_command_1 = require("./run-shell-command");
|
|
11
|
-
function createCommandString(executorOutput) {
|
|
12
|
-
const args = executorOutput.args.map((arg) => {
|
|
13
|
-
if (typeof arg !== 'string') {
|
|
14
|
-
if (arg.skipWindowsInterpolation) {
|
|
15
|
-
return arg;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
arg = arg.arg;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return (0, node_js_1.interpolationSafeWindowsPath)(arg);
|
|
22
|
-
});
|
|
23
|
-
const commandString = `${args.filter(common_1.isTruthy).join(' ')}`;
|
|
24
|
-
return commandString;
|
|
25
|
-
}
|
|
26
|
-
async function runCommandExecutor(commandDefinition, commandInputs) {
|
|
27
|
-
console.info(`${node_js_1.logColors.info}running ${commandDefinition.commandName}...${node_js_1.logColors.reset}`);
|
|
28
|
-
await (0, copy_config_1.copyAllConfigFiles)({
|
|
29
|
-
logging: commandInputs.logging,
|
|
30
|
-
configFiles: Object.values(commandDefinition.configFiles),
|
|
31
|
-
operation: copy_config_1.CopyConfigOperation.Init,
|
|
32
|
-
packageDir: commandInputs.packageDir,
|
|
33
|
-
repoDir: commandInputs.repoDir,
|
|
34
|
-
});
|
|
35
|
-
const executorOutput = await commandDefinition.executor(commandInputs);
|
|
36
|
-
if ((0, command_executor_1.isCompletedExecutor)(executorOutput)) {
|
|
37
|
-
return executorOutput.success;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const commandString = createCommandString(executorOutput);
|
|
41
|
-
console.info(`${node_js_1.logColors.faint}${(0, node_js_1.toPosixPath)((0, path_1.relative)(process.cwd(), commandString))}${node_js_1.logColors.reset}`);
|
|
42
|
-
const commandResult = await (0, run_shell_command_1.runVirmatorShellCommand)(commandString, {
|
|
43
|
-
repoDir: commandInputs.repoDir,
|
|
44
|
-
logging: commandInputs.logging,
|
|
45
|
-
logTransforms: executorOutput.logTransforms,
|
|
46
|
-
});
|
|
47
|
-
await executorOutput.postExecute?.();
|
|
48
|
-
return commandResult.exitCode === 0;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CommandMapping } from '../command/command-mapping';
|
|
2
|
-
import { ConfigFileDefinition } from '../config/config-file-definition';
|
|
3
|
-
export declare function runExtendedVirmator({ allArgs, allConfigs, commandMapping, packageBinName, packageDir, repoDir, }: {
|
|
4
|
-
allArgs: string[];
|
|
5
|
-
allConfigs: readonly ConfigFileDefinition[];
|
|
6
|
-
commandMapping: CommandMapping;
|
|
7
|
-
packageBinName: string;
|
|
8
|
-
packageDir: string;
|
|
9
|
-
repoDir: string;
|
|
10
|
-
}): Promise<void>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runExtendedVirmator = runExtendedVirmator;
|
|
4
|
-
const common_1 = require("@augment-vir/common");
|
|
5
|
-
const command_logging_1 = require("../command/command-logging");
|
|
6
|
-
const command_messages_1 = require("../command/command-messages");
|
|
7
|
-
const check_npm_deps_1 = require("./check-npm-deps");
|
|
8
|
-
const extract_arguments_1 = require("./extract-arguments");
|
|
9
|
-
const run_command_executor_1 = require("./run-command-executor");
|
|
10
|
-
function availableCommandsString(commandMapping) {
|
|
11
|
-
return `\nAvailable commands:\n ${(0, common_1.getObjectTypedKeys)(commandMapping).join(', ')}\n`;
|
|
12
|
-
}
|
|
13
|
-
function getValidCommandDefinition(binName, commandMapping, givenCommandName) {
|
|
14
|
-
if (!givenCommandName) {
|
|
15
|
-
throw new Error(`Missing command name as first input to ${binName}.${availableCommandsString(commandMapping)}`);
|
|
16
|
-
}
|
|
17
|
-
const commandDefinition = commandMapping[givenCommandName];
|
|
18
|
-
if (!(0, common_1.typedHasProperty)(commandMapping, givenCommandName) || !commandDefinition) {
|
|
19
|
-
throw new Error(`Invalid command "${givenCommandName} for ${binName}.${availableCommandsString(commandMapping)}"`);
|
|
20
|
-
}
|
|
21
|
-
return commandDefinition;
|
|
22
|
-
}
|
|
23
|
-
async function runExtendedVirmator({ allArgs, allConfigs, commandMapping, packageBinName, packageDir, repoDir, }) {
|
|
24
|
-
const args = (0, extract_arguments_1.getRelevantArgs)(allArgs, packageBinName);
|
|
25
|
-
const commandName = args[0];
|
|
26
|
-
const commandArgs = args.slice(1);
|
|
27
|
-
const commandDefinition = getValidCommandDefinition(packageBinName, commandMapping, commandName);
|
|
28
|
-
const logging = command_logging_1.defaultConsoleLogging;
|
|
29
|
-
const { subCommands: inputSubCommands, filteredArgs: filteredInputArgs } = (0, extract_arguments_1.extractSubCommands)(commandArgs, commandDefinition.allAvailableSubCommands);
|
|
30
|
-
await (0, check_npm_deps_1.updateDepsAsNeeded)({
|
|
31
|
-
npmDeps: commandDefinition.npmDeps,
|
|
32
|
-
packageBinName,
|
|
33
|
-
packageDir,
|
|
34
|
-
repoDir,
|
|
35
|
-
});
|
|
36
|
-
const commandInputs = {
|
|
37
|
-
logging,
|
|
38
|
-
repoDir,
|
|
39
|
-
inputSubCommands,
|
|
40
|
-
filteredInputArgs,
|
|
41
|
-
allConfigs,
|
|
42
|
-
packageDir,
|
|
43
|
-
packageBinName,
|
|
44
|
-
};
|
|
45
|
-
const success = await (0, run_command_executor_1.runCommandExecutor)(commandDefinition, commandInputs);
|
|
46
|
-
const resultMessage = (0, command_messages_1.getCommandResultMessage)(commandName ?? '', success);
|
|
47
|
-
if (success) {
|
|
48
|
-
console.info(resultMessage);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
throw new Error(resultMessage);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ShellOutput } from '@augment-vir/node-js';
|
|
2
|
-
import { CommandLogging, CommandLogTransforms } from '../command/command-logging';
|
|
3
|
-
export type RunVirmatorShellCommandOptions = {
|
|
4
|
-
repoDir: string;
|
|
5
|
-
logging: CommandLogging;
|
|
6
|
-
logTransforms?: CommandLogTransforms | undefined;
|
|
7
|
-
};
|
|
8
|
-
export declare function runVirmatorShellCommand(command: string, { repoDir: cwd, logging, logTransforms }: RunVirmatorShellCommandOptions): Promise<ShellOutput>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runVirmatorShellCommand = runVirmatorShellCommand;
|
|
4
|
-
const node_js_1 = require("@augment-vir/node-js");
|
|
5
|
-
const command_logging_1 = require("../command/command-logging");
|
|
6
|
-
function logWrapper(handleLog, logTransformer) {
|
|
7
|
-
return (input) => {
|
|
8
|
-
const callbackString = logTransformer(input.toString());
|
|
9
|
-
if (callbackString) {
|
|
10
|
-
handleLog(callbackString);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
async function runVirmatorShellCommand(command, { repoDir: cwd, logging, logTransforms }) {
|
|
15
|
-
const shellResults = await (0, node_js_1.runShellCommand)(command, {
|
|
16
|
-
cwd,
|
|
17
|
-
stdoutCallback: logWrapper(logging.stdout, logTransforms?.stdout ?? command_logging_1.identityCommandLogTransform),
|
|
18
|
-
stderrCallback: logWrapper(logging.stderr, logTransforms?.stderr ?? command_logging_1.identityCommandLogTransform),
|
|
19
|
-
});
|
|
20
|
-
return shellResults;
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CommandDefinitionArrayToMapping, CommandMapping } from './command/command-mapping';
|
|
2
|
-
import { CommandDefinition } from './command/define-command';
|
|
3
|
-
import { ConfigFileDefinition } from './config/config-file-definition';
|
|
4
|
-
export type ExtendVirmatorInputs<CommandDefinitionsGeneric extends ReadonlyArray<CommandDefinition>> = Readonly<{
|
|
5
|
-
packageBinName: string;
|
|
6
|
-
packageRootDir: string;
|
|
7
|
-
commandDefinitions?: CommandDefinitionsGeneric;
|
|
8
|
-
}>;
|
|
9
|
-
export type ExtendedVirmator<CommandMappingGeneric extends Readonly<CommandMapping>> = Readonly<{
|
|
10
|
-
packageBinName: string;
|
|
11
|
-
cliHelpMessage: string;
|
|
12
|
-
markdownHelpMessage: string;
|
|
13
|
-
commandMapping: CommandMappingGeneric;
|
|
14
|
-
extend: <CommandDefinitionsGeneric extends ReadonlyArray<CommandDefinition>>(inputs: ExtendVirmatorInputs<CommandDefinitionsGeneric>) => ExtendedVirmator<CommandDefinitionArrayToMapping<CommandDefinitionsGeneric>>;
|
|
15
|
-
allConfigs: ReadonlyArray<ConfigFileDefinition>;
|
|
16
|
-
runInCli: () => Promise<void>;
|
|
17
|
-
run: (allArgs: string[], repoDir: string) => Promise<void>;
|
|
18
|
-
}>;
|
package/dist/augments/array.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isInTypedArray<T>(input: any, array: ReadonlyArray<T>): input is T;
|
package/dist/augments/array.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function askQuestion(questionToAsk: string, timeoutMs?: number): Promise<string>;
|
|
2
|
-
export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, timeoutMs, }: {
|
|
3
|
-
questionToAsk: string;
|
|
4
|
-
conditionCallback: (response: string) => boolean | Promise<boolean>;
|
|
5
|
-
invalidInputMessage: string;
|
|
6
|
-
tryCountMax?: number;
|
|
7
|
-
/** Set to 0 to disable the timeout */
|
|
8
|
-
timeoutMs?: number;
|
|
9
|
-
}): Promise<string>;
|
package/dist/augments/console.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.askQuestion = askQuestion;
|
|
4
|
-
exports.askQuestionUntilConditionMet = askQuestionUntilConditionMet;
|
|
5
|
-
const readline_1 = require("readline");
|
|
6
|
-
async function askQuestion(questionToAsk, timeoutMs = 60_000) {
|
|
7
|
-
const cliInterface = (0, readline_1.createInterface)({
|
|
8
|
-
input: process.stdin,
|
|
9
|
-
output: process.stdout,
|
|
10
|
-
});
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
const timeoutId = timeoutMs
|
|
13
|
-
? setTimeout(() => {
|
|
14
|
-
cliInterface.close();
|
|
15
|
-
reject(`Took too long to response (over "${timeoutMs / 1_000}" seconds)`);
|
|
16
|
-
}, timeoutMs)
|
|
17
|
-
: undefined;
|
|
18
|
-
cliInterface.question(questionToAsk + ' ', (response) => {
|
|
19
|
-
if (timeoutId != undefined) {
|
|
20
|
-
clearTimeout(timeoutId);
|
|
21
|
-
}
|
|
22
|
-
cliInterface.close();
|
|
23
|
-
resolve(response);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax = 5, timeoutMs = 60_000, }) {
|
|
28
|
-
let wasConditionMet = false;
|
|
29
|
-
let retryCount = 0;
|
|
30
|
-
let response = '';
|
|
31
|
-
while (!wasConditionMet && retryCount <= tryCountMax) {
|
|
32
|
-
response = (await askQuestion(questionToAsk, timeoutMs)).trim();
|
|
33
|
-
wasConditionMet = await conditionCallback(response);
|
|
34
|
-
if (!wasConditionMet) {
|
|
35
|
-
console.error(invalidInputMessage);
|
|
36
|
-
}
|
|
37
|
-
retryCount++;
|
|
38
|
-
}
|
|
39
|
-
if (retryCount > tryCountMax) {
|
|
40
|
-
throw new Error(`Max input attempts (${tryCountMax}) exceeded.`);
|
|
41
|
-
}
|
|
42
|
-
return response;
|
|
43
|
-
}
|
package/dist/augments/fs.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function removeDirectory(dirPath: string): Promise<void>;
|
|
2
|
-
export interface DirContents {
|
|
3
|
-
[key: string]: string | DirContents;
|
|
4
|
-
}
|
|
5
|
-
export declare const systemRootPath: string;
|
|
6
|
-
export declare function readAllDirContents({ dir, recursive, }: {
|
|
7
|
-
dir: string;
|
|
8
|
-
recursive?: boolean;
|
|
9
|
-
}): Promise<DirContents>;
|
|
10
|
-
export declare function writeFiles(dir: string, allFileContents: DirContents): Promise<void>;
|
|
11
|
-
export declare function recursivelyUpwardsSearchForDir(startDirPath: string, check: (dirPath: string) => boolean): Promise<string>;
|