virmator 2.0.5 → 3.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.
- package/.github/workflows/virmator-build-for-gh-pages.yml +24 -0
- package/.github/workflows/virmator-tagged-release.yml +6 -4
- package/.github/workflows/virmator-tests.yml +4 -3
- package/.mocharc.js +9 -0
- package/.prettierignore +2 -3
- package/README.md +67 -82
- package/configs/.cspell.json +4 -0
- package/configs/.gitattributes +1 -0
- package/configs/.mocharc.js +8 -0
- package/configs/.prettierignore +6 -0
- package/configs/.prettierrc.js +13 -0
- package/{.cspell.json → configs/.virmator/.cspell-base.json} +5 -0
- package/configs/.virmator/mocharc-base.js +15 -0
- package/configs/.virmator/prettierrc-base.js +62 -0
- package/{tsconfig.json → configs/.virmator/tsconfig-base.json} +12 -8
- package/configs/.virmator/vite-always-reload-plugin.ts +90 -0
- package/configs/.virmator/vite-base.ts +11 -0
- package/configs/.virmator/vite.config.ts +8 -0
- package/configs/.virmator/web-test-runner-base.mjs +29 -0
- package/configs/.virmator/web-test-runner.config.mjs +8 -0
- package/{.vscode → configs/.vscode}/settings.json +13 -0
- package/configs/gitignore.txt +6 -0
- package/configs/npmignore.txt +13 -0
- package/configs/package.json +16 -0
- package/configs/src/global.d.ts +5 -0
- package/configs/tsconfig.json +3 -0
- package/dist/api/virmator-wrapper.d.ts +5 -0
- package/dist/api/virmator-wrapper.js +9 -0
- package/dist/augments/array.d.ts +1 -0
- package/dist/augments/array.js +7 -0
- package/dist/augments/fs.d.ts +5 -0
- package/dist/augments/fs.js +30 -0
- package/dist/augments/json.d.ts +1 -0
- package/dist/augments/json.js +12 -0
- package/dist/augments/object.d.ts +1 -0
- package/dist/augments/object.js +14 -0
- package/dist/augments/regexp.d.ts +1 -0
- package/dist/augments/regexp.js +7 -0
- package/dist/augments/test.d.ts +2 -0
- package/dist/augments/test.js +8 -0
- package/dist/augments/type.d.ts +1 -0
- package/dist/augments/type.js +2 -0
- package/dist/cli/all-cli-command-definitions.d.ts +54 -0
- package/dist/cli/all-cli-command-definitions.js +76 -0
- package/dist/cli/cli-color.d.ts +8 -0
- package/dist/cli/cli-color.js +12 -0
- package/dist/cli/cli-command/cli-command-help.d.ts +8 -0
- package/dist/cli/cli-command/cli-command-help.js +2 -0
- package/dist/cli/{commands/description-printing.d.ts → cli-command/cli-command-to-help-message.d.ts} +3 -2
- package/dist/cli/{commands/description-printing.js → cli-command/cli-command-to-help-message.js} +55 -21
- package/dist/cli/cli-command/define-cli-command.d.ts +41 -0
- package/dist/cli/cli-command/define-cli-command.js +29 -0
- package/dist/cli/cli-command/run-shell-command.d.ts +8 -0
- package/dist/cli/cli-command/run-shell-command.js +23 -0
- package/dist/cli/cli-command-implementations/code-in-markdown.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/code-in-markdown.command.js +67 -0
- package/dist/cli/cli-command-implementations/compile.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/compile.command.js +44 -0
- package/dist/cli/cli-command-implementations/format.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/format.command.js +116 -0
- package/dist/cli/cli-command-implementations/frontend.command.d.ts +7 -0
- package/dist/cli/cli-command-implementations/frontend.command.js +45 -0
- package/dist/cli/cli-command-implementations/init.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/init.command.js +31 -0
- package/dist/cli/cli-command-implementations/spellcheck.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/spellcheck.command.js +40 -0
- package/dist/cli/cli-command-implementations/test-web.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/test-web.command.js +50 -0
- package/dist/cli/cli-command-implementations/test.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/test.command.js +53 -0
- package/dist/cli/cli-command-implementations/update-configs.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/update-configs.command.js +31 -0
- package/dist/cli/cli-flags/cli-flag-name.d.ts +4 -0
- package/dist/cli/cli-flags/cli-flag-name.js +8 -0
- package/dist/cli/cli-flags/cli-flag-values.d.ts +4 -0
- package/dist/cli/cli-flags/cli-flag-values.js +19 -0
- package/dist/cli/cli-messages.d.ts +6 -0
- package/dist/cli/cli-messages.js +19 -0
- package/dist/cli/cli.js +27 -20
- package/dist/cli/config/combine-text-config.d.ts +2 -0
- package/dist/cli/config/combine-text-config.js +27 -0
- package/dist/cli/config/config-files.d.ts +133 -0
- package/dist/cli/config/config-files.js +138 -0
- package/dist/cli/config/copy-config.d.ts +25 -13
- package/dist/cli/config/copy-config.js +86 -86
- package/dist/cli/config/create-default-package-json.d.ts +1 -16
- package/dist/cli/config/create-default-package-json.js +37 -12
- package/dist/cli/is-global.d.ts +1 -0
- package/dist/cli/is-global.js +10 -0
- package/dist/cli/parse-arguments.d.ts +8 -0
- package/dist/cli/parse-arguments.js +42 -0
- package/dist/cli/run-cli-command.d.ts +13 -0
- package/dist/cli/run-cli-command.js +52 -0
- package/dist/cli/run-command.test-helper.d.ts +28 -0
- package/dist/cli/run-command.test-helper.js +87 -0
- package/dist/errors/virmator-cli.error.d.ts +3 -0
- package/dist/errors/virmator-cli.error.js +10 -0
- package/dist/errors/virmator-config-file.error.d.ts +4 -0
- package/dist/errors/virmator-config-file.error.js +11 -0
- package/dist/errors/virmator-invalid-command.error.d.ts +5 -0
- package/dist/errors/virmator-invalid-command.error.js +11 -0
- package/dist/errors/virmator-invalid-flags.error.d.ts +5 -0
- package/dist/errors/virmator-invalid-flags.error.js +13 -0
- package/dist/file-paths/virmator-package-paths.d.ts +11 -0
- package/dist/file-paths/virmator-package-paths.js +31 -0
- package/dist/file-paths/virmator-test-file-paths.d.ts +17 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -4
- package/dist/logging.d.ts +10 -0
- package/dist/logging.js +9 -0
- package/package.json +28 -22
- package/.prettierrc.js +0 -40
- package/dist/augments/ansi-regex.d.ts +0 -1
- package/dist/augments/ansi-regex.js +0 -27
- package/dist/augments/string.d.ts +0 -1
- package/dist/augments/string.js +0 -8
- package/dist/cli/cli-util/cli-color.d.ts +0 -8
- package/dist/cli/cli-util/cli-color.js +0 -35
- package/dist/cli/cli-util/cli-command-name.d.ts +0 -11
- package/dist/cli/cli-util/cli-command-name.js +0 -15
- package/dist/cli/cli-util/cli-flags.d.ts +0 -18
- package/dist/cli/cli-util/cli-flags.js +0 -63
- package/dist/cli/cli-util/cli-messages.d.ts +0 -7
- package/dist/cli/cli-util/cli-messages.js +0 -19
- package/dist/cli/cli-util/get-all-command-output.d.ts +0 -7
- package/dist/cli/cli-util/get-all-command-output.js +0 -21
- package/dist/cli/cli-util/shell-command-wrapper.d.ts +0 -8
- package/dist/cli/cli-util/shell-command-wrapper.js +0 -25
- package/dist/cli/cli-util/update-configs.d.ts +0 -3
- package/dist/cli/cli-util/update-configs.js +0 -54
- package/dist/cli/commands/all-cli-commands.d.ts +0 -13
- package/dist/cli/commands/all-cli-commands.js +0 -99
- package/dist/cli/commands/cli-command.d.ts +0 -35
- package/dist/cli/commands/cli-command.js +0 -40
- package/dist/cli/commands/implementations/code-in-markdown.command.d.ts +0 -3
- package/dist/cli/commands/implementations/code-in-markdown.command.js +0 -54
- package/dist/cli/commands/implementations/compile.command.d.ts +0 -3
- package/dist/cli/commands/implementations/compile.command.js +0 -49
- package/dist/cli/commands/implementations/format.command.d.ts +0 -16
- package/dist/cli/commands/implementations/format.command.js +0 -143
- package/dist/cli/commands/implementations/init.command.d.ts +0 -3
- package/dist/cli/commands/implementations/init.command.js +0 -55
- package/dist/cli/commands/implementations/spellcheck.command.d.ts +0 -3
- package/dist/cli/commands/implementations/spellcheck.command.js +0 -35
- package/dist/cli/commands/implementations/test.command.d.ts +0 -3
- package/dist/cli/commands/implementations/test.command.js +0 -49
- package/dist/cli/commands/implementations/update-all-configs.command.d.ts +0 -3
- package/dist/cli/commands/implementations/update-all-configs.command.js +0 -46
- package/dist/cli/commands/implementations/update-bare-configs.command.d.ts +0 -3
- package/dist/cli/commands/implementations/update-bare-configs.command.js +0 -46
- package/dist/cli/commands/run-command.d.ts +0 -3
- package/dist/cli/commands/run-command.js +0 -65
- package/dist/cli/config/config-key.d.ts +0 -35
- package/dist/cli/config/config-key.js +0 -25
- package/dist/cli/config/config-paths.d.ts +0 -3
- package/dist/cli/config/config-paths.js +0 -69
- package/dist/cli/config/config-read.d.ts +0 -7
- package/dist/cli/config/config-read.js +0 -91
- package/dist/cli/config/extendable-config.d.ts +0 -12
- package/dist/cli/config/extendable-config.js +0 -45
- package/dist/errors/cli-command-error.d.ts +0 -4
- package/dist/errors/cli-command-error.js +0 -12
- package/dist/errors/cli-flag-error.d.ts +0 -4
- package/dist/errors/cli-flag-error.js +0 -12
- package/dist/errors/config-file-error.d.ts +0 -3
- package/dist/errors/config-file-error.js +0 -7
- package/dist/exportable-jest-config/jest-config.d.ts +0 -3
- package/dist/exportable-jest-config/jest-config.js +0 -23
- package/dist/exportable-jest-config/jest-setup.d.ts +0 -1
- package/dist/exportable-jest-config/jest-setup.js +0 -11
- package/dist/file-paths/virmator-repo-paths.d.ts +0 -5
- package/dist/file-paths/virmator-repo-paths.js +0 -19
- package/dist/jest/jest-config.d.ts +0 -3
- package/dist/jest/jest-config.js +0 -13
- package/extender-configs/.cspell.json +0 -3
- package/extender-configs/.prettierrc.js +0 -3
- package/extender-configs/tsconfig.json +0 -3
- package/separate-configs/.prettierignore +0 -3
- package/separate-configs/gitignore.txt +0 -4
- package/separate-configs/jest/jest-config.ts +0 -24
- package/separate-configs/jest/jest-setup.ts +0 -12
- package/separate-configs/npmignore.txt +0 -20
- package/separate-configs/package.json +0 -9
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineCliCommand = void 0;
|
|
4
|
+
const augment_vir_1 = require("augment-vir");
|
|
5
|
+
function defineCliCommand(inputs, createDescription, inputExecutor) {
|
|
6
|
+
const allAvailableSubCommands = (0, augment_vir_1.getObjectTypedKeys)(inputs.subCommandDescriptions);
|
|
7
|
+
const subCommands = (0, augment_vir_1.mapObject)(inputs.subCommandDescriptions, (key) => key);
|
|
8
|
+
const init = {
|
|
9
|
+
...inputs,
|
|
10
|
+
allAvailableSubCommands,
|
|
11
|
+
subCommands,
|
|
12
|
+
};
|
|
13
|
+
const executor = (executorInputs) => {
|
|
14
|
+
return inputExecutor({
|
|
15
|
+
...executorInputs,
|
|
16
|
+
...init,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const commandDescription = createDescription({
|
|
20
|
+
commandName: init.commandName,
|
|
21
|
+
subCommands: init.subCommands,
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
...init,
|
|
25
|
+
commandDescription,
|
|
26
|
+
executor,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.defineCliCommand = defineCliCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShellOutput } from 'augment-vir/dist/cjs/node-only';
|
|
2
|
+
import { CliLogging, LogTransforms } from '../../logging';
|
|
3
|
+
export declare type RunVirmatorShellCommandOptions = {
|
|
4
|
+
repoDir: string;
|
|
5
|
+
logging: CliLogging;
|
|
6
|
+
logTransforms?: LogTransforms | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare function runVirmatorShellCommand(command: string, { repoDir: cwd, logging, logTransforms }: RunVirmatorShellCommandOptions): Promise<ShellOutput>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runVirmatorShellCommand = void 0;
|
|
4
|
+
const node_only_1 = require("augment-vir/dist/cjs/node-only");
|
|
5
|
+
const logging_1 = require("../../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
|
+
var _a, _b;
|
|
16
|
+
const shellResults = await (0, node_only_1.runShellCommand)(command, {
|
|
17
|
+
cwd,
|
|
18
|
+
stdoutCallback: logWrapper(logging.stdout, (_a = logTransforms === null || logTransforms === void 0 ? void 0 : logTransforms.stdout) !== null && _a !== void 0 ? _a : logging_1.noLogTransforms),
|
|
19
|
+
stderrCallback: logWrapper(logging.stderr, (_b = logTransforms === null || logTransforms === void 0 ? void 0 : logTransforms.stderr) !== null && _b !== void 0 ? _b : logging_1.noLogTransforms),
|
|
20
|
+
});
|
|
21
|
+
return shellResults;
|
|
22
|
+
}
|
|
23
|
+
exports.runVirmatorShellCommand = runVirmatorShellCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const codeInMarkdownCommandDefinition: import("../cli-command/define-cli-command").CliCommandDefinition<{
|
|
2
|
+
commandName: "code-in-markdown";
|
|
3
|
+
subCommandDescriptions: {
|
|
4
|
+
readonly check: "Check that markdown files have their examples inserted and are up-to-date.";
|
|
5
|
+
};
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeInMarkdownCommandDefinition = void 0;
|
|
4
|
+
const node_only_1 = require("augment-vir/dist/cjs/node-only");
|
|
5
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
6
|
+
const package_name_1 = require("../../package-name");
|
|
7
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
8
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
9
|
+
exports.codeInMarkdownCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
10
|
+
commandName: 'code-in-markdown',
|
|
11
|
+
subCommandDescriptions: {
|
|
12
|
+
check: 'Check that markdown files have their examples inserted and are up-to-date.',
|
|
13
|
+
},
|
|
14
|
+
}, ({ commandName }) => {
|
|
15
|
+
return {
|
|
16
|
+
sections: [
|
|
17
|
+
{
|
|
18
|
+
title: '',
|
|
19
|
+
content: `Insert 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 -->\``,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '',
|
|
23
|
+
content: `By default this command parses all markdown files in the repo (ignoring node_modules). Specific markdown files can be parsed by giving ${package_name_1.packageName} extra parameters.`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: '',
|
|
27
|
+
content: `To check if files are up-to-date (rather than actually updating them), use the "check" sub-command.`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
examples: [
|
|
31
|
+
{
|
|
32
|
+
title: 'default experience (usually all you need)',
|
|
33
|
+
content: `${package_name_1.packageName} ${commandName}`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'checking if files are up-to-date',
|
|
37
|
+
content: `${package_name_1.packageName} ${commandName} check`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'override files to check to a single file',
|
|
41
|
+
content: `${package_name_1.packageName} ${commandName} only/this/one/file.md`,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'override files to check to a group of files',
|
|
45
|
+
content: `${package_name_1.packageName} ${commandName} "only/this/dir/*.md"`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}, async (inputs) => {
|
|
50
|
+
const args = inputs.filteredInputArgs.length
|
|
51
|
+
? (0, node_only_1.interpolationSafeWindowsPath)(inputs.filteredInputArgs.join(' '))
|
|
52
|
+
: `\"./**/*.md\"`;
|
|
53
|
+
const subCommand = inputs.inputSubCommands.includes(inputs.subCommands.check)
|
|
54
|
+
? '--check'
|
|
55
|
+
: '';
|
|
56
|
+
const mdCodeCommand = `${(0, virmator_package_paths_1.getNpmBinPath)('md-code')} ${subCommand} ${args}`;
|
|
57
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(mdCodeCommand, {
|
|
58
|
+
...inputs,
|
|
59
|
+
logTransforms: {
|
|
60
|
+
stderr: (stderrInput) => stderrInput.replace('Run without --check to update.', 'Run without the "check" sub-command in order to update.'),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
fullExecutedCommand: mdCodeCommand,
|
|
65
|
+
success: !results.exitCode,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileCommandDefinition = void 0;
|
|
4
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
5
|
+
const package_name_1 = require("../../package-name");
|
|
6
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
7
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
8
|
+
exports.compileCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
9
|
+
commandName: 'compile',
|
|
10
|
+
subCommandDescriptions: {
|
|
11
|
+
check: 'Run type checking without emitting compiled files.',
|
|
12
|
+
},
|
|
13
|
+
}, ({ commandName }) => {
|
|
14
|
+
return {
|
|
15
|
+
sections: [
|
|
16
|
+
{
|
|
17
|
+
title: '',
|
|
18
|
+
content: `compile typescript files
|
|
19
|
+
Pass any extra tsc flags to this command.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
{
|
|
24
|
+
title: `no extra flags`,
|
|
25
|
+
content: `${package_name_1.packageName} ${commandName}`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: `one extra flag`,
|
|
29
|
+
content: `${package_name_1.packageName} ${commandName} --noEmit`,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}, async (inputs) => {
|
|
34
|
+
const shouldNotEmit = inputs.filteredInputArgs.join(' ').includes('--noEmit') ||
|
|
35
|
+
inputs.inputSubCommands.includes(inputs.subCommands.check);
|
|
36
|
+
const resetCommand = shouldNotEmit ? '' : 'rm -rf dist && ';
|
|
37
|
+
const noEmit = shouldNotEmit ? ' --noEmit' : '';
|
|
38
|
+
const compileCommand = `${resetCommand}${(0, virmator_package_paths_1.getNpmBinPath)('tsc')} --pretty ${noEmit}${inputs.filteredInputArgs.map((arg) => `"${arg}"`).join(' ')}`;
|
|
39
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(compileCommand, inputs);
|
|
40
|
+
return {
|
|
41
|
+
fullExecutedCommand: compileCommand,
|
|
42
|
+
success: !results.exitCode,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCommandDefinition = void 0;
|
|
4
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
5
|
+
const package_name_1 = require("../../package-name");
|
|
6
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
7
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
8
|
+
const defaultFormatExtensions = [
|
|
9
|
+
'css',
|
|
10
|
+
'html',
|
|
11
|
+
'js',
|
|
12
|
+
'json',
|
|
13
|
+
'jsx',
|
|
14
|
+
'md',
|
|
15
|
+
'toml',
|
|
16
|
+
'ts',
|
|
17
|
+
'tsx',
|
|
18
|
+
'yaml',
|
|
19
|
+
'yml',
|
|
20
|
+
];
|
|
21
|
+
const filesMarkerArg = '--file-types';
|
|
22
|
+
exports.formatCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
23
|
+
commandName: 'format',
|
|
24
|
+
subCommandDescriptions: {
|
|
25
|
+
check: 'check formatting without overwriting files.',
|
|
26
|
+
},
|
|
27
|
+
}, ({ commandName, subCommands }) => {
|
|
28
|
+
return {
|
|
29
|
+
sections: [
|
|
30
|
+
{
|
|
31
|
+
title: '',
|
|
32
|
+
content: 'Formats source files with Prettier.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'file extensions',
|
|
36
|
+
content: `If only specific file extensions should be formatted, add the "${filesMarkerArg}" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will format files only if they have the extension ".md" or ".json": ${package_name_1.packageName} ${commandName} ${filesMarkerArg} md json`,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: 'Prettier flags',
|
|
40
|
+
content: `Any other arguments encountered between the operation command (if provided) and the "${filesMarkerArg}" marker are treated as extra arguments to Prettier and will be passed along.`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
examples: [
|
|
44
|
+
{
|
|
45
|
+
title: 'checks formatting for files',
|
|
46
|
+
content: `${package_name_1.packageName} ${commandName} ${subCommands.check}`,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: 'checks formatting only for .md files',
|
|
50
|
+
content: `${package_name_1.packageName} ${commandName} ${subCommands.check} ${filesMarkerArg} md`,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: 'checks formatting only for .md and .json files',
|
|
54
|
+
content: `${package_name_1.packageName} ${commandName} ${subCommands.check} ${filesMarkerArg} md json`,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: 'fixes formatting for files',
|
|
58
|
+
content: `${package_name_1.packageName} ${commandName}
|
|
59
|
+
${package_name_1.packageName} ${commandName}`,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: `examples with extra Prettier flags`,
|
|
63
|
+
content: `${package_name_1.packageName} ${commandName} --ignore-path .prettierignore
|
|
64
|
+
${package_name_1.packageName} ${commandName} --ignore-path .prettierignore
|
|
65
|
+
${package_name_1.packageName} ${commandName} --ignore-path .prettierignore ${filesMarkerArg} md json`,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}, async (inputs) => {
|
|
70
|
+
const formatArgs = extractFormatArgs(inputs.filteredInputArgs);
|
|
71
|
+
const shouldCheckOnly = inputs.inputSubCommands.includes(inputs.subCommands.check) ||
|
|
72
|
+
formatArgs.prettierFlags.includes('--check');
|
|
73
|
+
const operationString = shouldCheckOnly ? '--check ' : '--write';
|
|
74
|
+
const fileExtensions = formatArgs.fileExtensions.length
|
|
75
|
+
? formatArgs.fileExtensions
|
|
76
|
+
: defaultFormatExtensions;
|
|
77
|
+
const fileExtensionsString = `\"./**/*.+(${fileExtensions.join('|')})\"`;
|
|
78
|
+
const extraPrettierFlags = formatArgs.prettierFlags.length
|
|
79
|
+
? `${formatArgs.prettierFlags.join(' ')} `
|
|
80
|
+
: '';
|
|
81
|
+
const prettier = (0, virmator_package_paths_1.getNpmBinPath)('prettier');
|
|
82
|
+
const formatCommand = `${prettier} --color ${extraPrettierFlags}${fileExtensionsString} ${operationString}`;
|
|
83
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(formatCommand, {
|
|
84
|
+
...inputs,
|
|
85
|
+
logTransforms: {
|
|
86
|
+
stdout: (stdout) => stdout
|
|
87
|
+
// only relevant when running the check command
|
|
88
|
+
.replace('Checking formatting...\n', '')
|
|
89
|
+
// only relevant when running the check command
|
|
90
|
+
.replace('All matched files use Prettier code style!\n', ''),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
fullExecutedCommand: formatCommand,
|
|
95
|
+
success: !results.exitCode,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
function extractFormatArgs(args) {
|
|
99
|
+
let foundFileTypesFlag = false;
|
|
100
|
+
const formatArgs = {
|
|
101
|
+
prettierFlags: [],
|
|
102
|
+
fileExtensions: [],
|
|
103
|
+
};
|
|
104
|
+
args.forEach((arg) => {
|
|
105
|
+
if (foundFileTypesFlag) {
|
|
106
|
+
formatArgs.fileExtensions.push(arg);
|
|
107
|
+
}
|
|
108
|
+
else if (arg === filesMarkerArg) {
|
|
109
|
+
foundFileTypesFlag = true;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
formatArgs.prettierFlags.push(arg);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return formatArgs;
|
|
116
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const frontendCommandDefinition: import("../cli-command/define-cli-command").CliCommandDefinition<{
|
|
2
|
+
commandName: "frontend";
|
|
3
|
+
subCommandDescriptions: {
|
|
4
|
+
readonly build: "Builds and bundles the frontend for deployment.";
|
|
5
|
+
readonly preview: "Builds and previews the built output.";
|
|
6
|
+
};
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.frontendCommandDefinition = void 0;
|
|
4
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
5
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
6
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
7
|
+
const config_files_1 = require("../config/config-files");
|
|
8
|
+
exports.frontendCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
9
|
+
commandName: 'frontend',
|
|
10
|
+
subCommandDescriptions: {
|
|
11
|
+
build: 'Builds and bundles the frontend for deployment.',
|
|
12
|
+
preview: 'Builds and previews the built output.',
|
|
13
|
+
},
|
|
14
|
+
}, () => {
|
|
15
|
+
return {
|
|
16
|
+
sections: [
|
|
17
|
+
{
|
|
18
|
+
title: '',
|
|
19
|
+
content: `Runs a frontend. Currently uses vite.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
examples: [],
|
|
23
|
+
};
|
|
24
|
+
}, async (inputs) => {
|
|
25
|
+
const vitePath = (0, virmator_package_paths_1.getNpmBinPath)('vite');
|
|
26
|
+
const joinedArgs = inputs.filteredInputArgs.join(' ');
|
|
27
|
+
const useDefaultConfigArgs = !joinedArgs.includes('--config');
|
|
28
|
+
const configString = useDefaultConfigArgs
|
|
29
|
+
? `--config ${(0, config_files_1.getCopyToPath)(config_files_1.configFiles.vite, inputs.repoDir)}`
|
|
30
|
+
: '';
|
|
31
|
+
let viteCommand = `${vitePath} --force ${configString} ${joinedArgs}`;
|
|
32
|
+
// insert the build command in either sub command
|
|
33
|
+
if (inputs.inputSubCommands.length) {
|
|
34
|
+
viteCommand = `rm -rf dist && ${vitePath} --colors build ${configString} ${joinedArgs} && cp dist/index.html dist/404.html`;
|
|
35
|
+
}
|
|
36
|
+
if (inputs.inputSubCommands.includes('preview')) {
|
|
37
|
+
const hostString = joinedArgs.includes('--host') ? '' : `--host`;
|
|
38
|
+
viteCommand += ` && ${vitePath} preview ${configString} ${joinedArgs} ${hostString}`;
|
|
39
|
+
}
|
|
40
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(viteCommand, inputs);
|
|
41
|
+
return {
|
|
42
|
+
fullExecutedCommand: viteCommand,
|
|
43
|
+
success: !results.error,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initCommandDefinition = void 0;
|
|
4
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
5
|
+
const config_files_1 = require("../config/config-files");
|
|
6
|
+
const copy_config_1 = require("../config/copy-config");
|
|
7
|
+
exports.initCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
8
|
+
commandName: 'init',
|
|
9
|
+
subCommandDescriptions: {},
|
|
10
|
+
}, () => {
|
|
11
|
+
return {
|
|
12
|
+
sections: [
|
|
13
|
+
{
|
|
14
|
+
title: '',
|
|
15
|
+
content: `Initialize a repo with all virmator config files.`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
examples: [],
|
|
19
|
+
};
|
|
20
|
+
}, async (inputs) => {
|
|
21
|
+
const success = await (0, copy_config_1.copyAllConfigFiles)({
|
|
22
|
+
configFiles: config_files_1.configFiles,
|
|
23
|
+
logging: inputs.logging,
|
|
24
|
+
operation: copy_config_1.CopyConfigOperation.Init,
|
|
25
|
+
repoDir: inputs.repoDir,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
fullExecutedCommand: '',
|
|
29
|
+
success: success,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spellcheckCommandDefinition = void 0;
|
|
4
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
5
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
6
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
7
|
+
function spellcheckLogTransform(log) {
|
|
8
|
+
return log.replace(/\r/g, '\n').replace(/\n$/, '');
|
|
9
|
+
}
|
|
10
|
+
exports.spellcheckCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
11
|
+
commandName: 'spellcheck',
|
|
12
|
+
subCommandDescriptions: {},
|
|
13
|
+
}, () => {
|
|
14
|
+
return {
|
|
15
|
+
sections: [
|
|
16
|
+
{
|
|
17
|
+
title: '',
|
|
18
|
+
content: `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.`,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
examples: [],
|
|
22
|
+
};
|
|
23
|
+
}, async (inputs) => {
|
|
24
|
+
const cSpellPath = (0, virmator_package_paths_1.getNpmBinPath)('cspell');
|
|
25
|
+
const extraArgs = inputs.filteredInputArgs.join(' ');
|
|
26
|
+
const containsNonFlagArgs = inputs.filteredInputArgs.some((arg) => !arg.startsWith('-'));
|
|
27
|
+
const args = containsNonFlagArgs ? '' : '"**/*"';
|
|
28
|
+
const spellcheckCommand = `${cSpellPath} --color --unique --no-progress --relative --dot ${extraArgs} ${args}`;
|
|
29
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(spellcheckCommand, {
|
|
30
|
+
...inputs,
|
|
31
|
+
logTransforms: {
|
|
32
|
+
stderr: spellcheckLogTransform,
|
|
33
|
+
stdout: spellcheckLogTransform,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
fullExecutedCommand: spellcheckCommand,
|
|
38
|
+
success: !results.exitCode,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testWebCommandDefinition = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
6
|
+
const package_name_1 = require("../../package-name");
|
|
7
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
8
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
9
|
+
const config_files_1 = require("../config/config-files");
|
|
10
|
+
const test_command_1 = require("./test.command");
|
|
11
|
+
exports.testWebCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
12
|
+
commandName: 'test-web',
|
|
13
|
+
subCommandDescriptions: {},
|
|
14
|
+
}, ({ commandName }) => {
|
|
15
|
+
return {
|
|
16
|
+
sections: [
|
|
17
|
+
{
|
|
18
|
+
title: '',
|
|
19
|
+
content: `Runs tests within browsers rather than inside of Node.js. Test files fed into this command cannot be mixed with test files run by the "${package_name_1.packageName} ${test_command_1.testCommandDefinition.commandName}" command, as the run-time environment is quite different (Node.js vs browser). However, just like the ${test_command_1.testCommandDefinition.commandName} command, this command will all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "files" property in ${(0, path_1.basename)(config_files_1.configFiles.webTestRunner.path)}.`,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '',
|
|
23
|
+
content: `By default this command runs all tests three times: in Chromium (Chrome), Firefox, and Webkit (Safari) using playwright.`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
examples: [
|
|
27
|
+
{
|
|
28
|
+
title: 'Test all .test.ts and .test.tsx files',
|
|
29
|
+
content: `${package_name_1.packageName} ${commandName}`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Test a specific file',
|
|
33
|
+
content: `${package_name_1.packageName} ${commandName} path/to/file.test.ts`,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}, async (inputs) => {
|
|
38
|
+
const webTestRunnerPath = (0, virmator_package_paths_1.getNpmBinPath)('web-test-runner');
|
|
39
|
+
const joinedArgs = inputs.filteredInputArgs.join(' ');
|
|
40
|
+
const shouldUseConfig = !joinedArgs.includes('--config');
|
|
41
|
+
const configString = shouldUseConfig
|
|
42
|
+
? `--config ./.virmator/web-test-runner.config.mjs`
|
|
43
|
+
: '';
|
|
44
|
+
const testCommand = `${webTestRunnerPath} --color ${configString} ${joinedArgs}`;
|
|
45
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(testCommand, inputs);
|
|
46
|
+
return {
|
|
47
|
+
fullExecutedCommand: testCommand,
|
|
48
|
+
success: !results.exitCode,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testCommandDefinition = void 0;
|
|
4
|
+
const virmator_package_paths_1 = require("../../file-paths/virmator-package-paths");
|
|
5
|
+
const package_name_1 = require("../../package-name");
|
|
6
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
7
|
+
const run_shell_command_1 = require("../cli-command/run-shell-command");
|
|
8
|
+
exports.testCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
9
|
+
commandName: 'test',
|
|
10
|
+
subCommandDescriptions: {},
|
|
11
|
+
}, ({ commandName }) => {
|
|
12
|
+
return {
|
|
13
|
+
sections: [
|
|
14
|
+
{
|
|
15
|
+
title: '',
|
|
16
|
+
content: `Test all .test.ts files with Mocha and Chai. By default this command tests all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "spec" property in .mocharc.js.`,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: '',
|
|
20
|
+
content: `This command is meant to run Node.js tests. For running web-based testing, see the test-web command.`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: '',
|
|
24
|
+
content: `Note that the below single file examples only work because the base Mocha config from ${package_name_1.packageName} is setup to handle them. (So if you don't use that config, the examples may not work properly.)`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
title: 'Test all .test.ts and .test.tsx files',
|
|
30
|
+
content: `${package_name_1.packageName} ${commandName}`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: 'Test a single file',
|
|
34
|
+
content: `${package_name_1.packageName} ${commandName} ./path/to/single/file.js`,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: 'Test multiple files',
|
|
38
|
+
content: `${package_name_1.packageName} ${commandName} "./**/single-file.js"`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}, async (inputs) => {
|
|
43
|
+
const mochaPath = (0, virmator_package_paths_1.getNpmBinPath)('mocha');
|
|
44
|
+
const joinedArgs = inputs.filteredInputArgs.join(' ');
|
|
45
|
+
const useDefaultConfigArgs = !joinedArgs.includes('--config');
|
|
46
|
+
const configString = useDefaultConfigArgs ? '--config .mocharc.js ' : '';
|
|
47
|
+
const testCommand = `${mochaPath} ${configString} ${joinedArgs}`;
|
|
48
|
+
const results = await (0, run_shell_command_1.runVirmatorShellCommand)(testCommand, inputs);
|
|
49
|
+
return {
|
|
50
|
+
fullExecutedCommand: testCommand,
|
|
51
|
+
success: !results.exitCode,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateConfigsCommandDefinition = void 0;
|
|
4
|
+
const define_cli_command_1 = require("../cli-command/define-cli-command");
|
|
5
|
+
const config_files_1 = require("../config/config-files");
|
|
6
|
+
const copy_config_1 = require("../config/copy-config");
|
|
7
|
+
exports.updateConfigsCommandDefinition = (0, define_cli_command_1.defineCliCommand)({
|
|
8
|
+
commandName: 'update-configs',
|
|
9
|
+
subCommandDescriptions: {},
|
|
10
|
+
}, () => {
|
|
11
|
+
return {
|
|
12
|
+
sections: [
|
|
13
|
+
{
|
|
14
|
+
title: '',
|
|
15
|
+
content: `Update all existing configuration files that virmator is able to update. (Like base config files.)`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
examples: [],
|
|
19
|
+
};
|
|
20
|
+
}, async (inputs) => {
|
|
21
|
+
const success = await (0, copy_config_1.copyAllConfigFiles)({
|
|
22
|
+
configFiles: config_files_1.configFiles,
|
|
23
|
+
logging: inputs.logging,
|
|
24
|
+
operation: copy_config_1.CopyConfigOperation.Update,
|
|
25
|
+
repoDir: inputs.repoDir,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
fullExecutedCommand: '',
|
|
29
|
+
success: success,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliFlagName = void 0;
|
|
4
|
+
var CliFlagName;
|
|
5
|
+
(function (CliFlagName) {
|
|
6
|
+
CliFlagName["Help"] = "--help";
|
|
7
|
+
CliFlagName["Silent"] = "--silent";
|
|
8
|
+
})(CliFlagName = exports.CliFlagName || (exports.CliFlagName = {}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CliFlagName } from './cli-flag-name';
|
|
2
|
+
export declare type CliFlagValues = Readonly<Record<CliFlagName, boolean>>;
|
|
3
|
+
export declare function fillInCliFlagValues(inputFlags?: Readonly<Partial<CliFlagValues>> | undefined): Readonly<Required<CliFlagValues>>;
|
|
4
|
+
export declare const cliFlagDescriptions: Record<CliFlagName, string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cliFlagDescriptions = exports.fillInCliFlagValues = void 0;
|
|
4
|
+
const cli_flag_name_1 = require("./cli-flag-name");
|
|
5
|
+
const defaultCliFlagValues = {
|
|
6
|
+
[cli_flag_name_1.CliFlagName.Help]: false,
|
|
7
|
+
[cli_flag_name_1.CliFlagName.Silent]: false,
|
|
8
|
+
};
|
|
9
|
+
function fillInCliFlagValues(inputFlags = {}) {
|
|
10
|
+
return {
|
|
11
|
+
...defaultCliFlagValues,
|
|
12
|
+
...inputFlags,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.fillInCliFlagValues = fillInCliFlagValues;
|
|
16
|
+
exports.cliFlagDescriptions = {
|
|
17
|
+
[cli_flag_name_1.CliFlagName.Silent]: 'Turns off most logging.',
|
|
18
|
+
[cli_flag_name_1.CliFlagName.Help]: 'Prints this help message.',
|
|
19
|
+
};
|