virmator 1.4.4 → 2.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/.cspell.json +1 -0
- package/.github/workflows/virmator-tests.yml +1 -1
- package/.prettierignore +3 -2
- package/README.md +159 -1
- package/dist/cli/cli-util/cli-color.js +5 -1
- package/dist/cli/cli-util/cli-flags.js +7 -10
- package/dist/cli/cli-util/get-all-command-output.d.ts +4 -3
- package/dist/cli/cli-util/shell-command-wrapper.d.ts +1 -1
- package/dist/cli/cli-util/shell-command-wrapper.js +2 -2
- package/dist/cli/cli-util/update-configs.js +6 -5
- package/dist/cli/cli.js +1 -1
- package/dist/cli/commands/all-cli-commands.d.ts +2 -0
- package/dist/cli/commands/all-cli-commands.js +31 -27
- package/dist/cli/commands/cli-command.d.ts +10 -1
- package/dist/cli/commands/cli-command.js +1 -1
- package/dist/cli/commands/description-printing.d.ts +10 -0
- package/dist/cli/commands/description-printing.js +149 -0
- package/dist/cli/commands/implementations/code-in-markdown.command.js +29 -22
- package/dist/cli/commands/implementations/compile.command.js +20 -8
- package/dist/cli/commands/implementations/format.command.js +54 -40
- package/dist/cli/commands/implementations/init.command.js +13 -4
- package/dist/cli/commands/implementations/spellcheck.command.js +10 -1
- package/dist/cli/commands/implementations/test.command.js +23 -26
- package/dist/cli/commands/implementations/update-all-configs.command.js +23 -14
- package/dist/cli/commands/implementations/update-bare-configs.command.js +23 -15
- package/dist/cli/commands/run-command.js +2 -3
- package/dist/cli/config/config-key.d.ts +9 -9
- package/dist/cli/config/config-key.js +4 -4
- package/dist/cli/config/config-paths.js +1 -1
- package/dist/cli/config/config-read.js +1 -2
- package/dist/cli/config/copy-config.js +3 -3
- package/dist/cli/config/create-default-package-json.js +2 -2
- package/dist/cli/config/extendable-config.js +3 -3
- package/dist/errors/cli-command-error.js +3 -3
- package/dist/errors/cli-flag-error.js +3 -3
- package/dist/errors/config-file-error.js +1 -4
- package/dist/exportable-jest-config/jest-config-path.d.ts +1 -0
- package/dist/exportable-jest-config/jest-config-path.js +6 -0
- package/dist/exportable-jest-config/separate-jest-configs/jest-config.d.ts +3 -0
- package/dist/exportable-jest-config/separate-jest-configs/jest-config.js +25 -0
- package/dist/exportable-jest-config/separate-jest-configs/jest-setup.d.ts +1 -0
- package/dist/exportable-jest-config/separate-jest-configs/jest-setup.js +11 -0
- package/dist/file-paths/virmator-repo-paths.js +4 -4
- package/dist/file-paths/{virmator-test-repos-paths.d.ts → virmator-test-file-paths.d.ts} +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/jest/jest-config.d.ts +3 -0
- package/dist/jest/jest-config.js +12 -0
- package/package.json +29 -23
- package/separate-configs/gitignore.txt +2 -0
- package/separate-configs/jest/jest-config.ts +26 -0
- package/separate-configs/jest/jest-setup.ts +12 -0
- package/separate-configs/npmignore.txt +7 -4
- package/tsconfig.json +13 -6
- package/dist/file-paths/virmator-test-repos-paths.js +0 -56
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCodeInMarkdownCommand = exports.codeInMarkdownCommandImplementation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_only_1 = require("augment-vir/dist/node-only");
|
|
5
5
|
const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
|
|
6
6
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
7
7
|
const cli_flags_1 = require("../../cli-util/cli-flags");
|
|
8
8
|
const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
|
|
9
9
|
exports.codeInMarkdownCommandImplementation = {
|
|
10
10
|
commandName: cli_command_name_1.CliCommandName.CodeInMarkdown,
|
|
11
|
-
description:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
virmator ${cli_command_name_1.CliCommandName.CodeInMarkdown}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
virmator ${cli_command_name_1.CliCommandName.CodeInMarkdown}
|
|
30
|
-
|
|
11
|
+
description: {
|
|
12
|
+
sections: [
|
|
13
|
+
{
|
|
14
|
+
title: '',
|
|
15
|
+
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 -->\``,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: '',
|
|
19
|
+
content: `By default this command parses all markdown files in the repo (ignoring node_modules). Specific markdown files can be parsed by giving virmator extra parameters.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
{
|
|
24
|
+
title: 'default experience (usually all you need)',
|
|
25
|
+
content: `virmator ${cli_command_name_1.CliCommandName.CodeInMarkdown}`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: 'override files to check to a single file',
|
|
29
|
+
content: `virmator ${cli_command_name_1.CliCommandName.CodeInMarkdown} only/this/one/file.md`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'override files to check to a group of files',
|
|
33
|
+
content: `virmator ${cli_command_name_1.CliCommandName.CodeInMarkdown} "only/this/dir/*.md"`,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
31
37
|
implementation: runCodeInMarkdownCommand,
|
|
32
38
|
configFlagSupport: {
|
|
33
39
|
[cli_flags_1.CliFlagName.NoWriteConfig]: false,
|
|
@@ -36,11 +42,12 @@ exports.codeInMarkdownCommandImplementation = {
|
|
|
36
42
|
const mdCodePath = (0, virmator_repo_paths_1.getNpmBinPath)('md-code');
|
|
37
43
|
async function runCodeInMarkdownCommand(inputs) {
|
|
38
44
|
const args = inputs.rawArgs.length
|
|
39
|
-
? (0,
|
|
45
|
+
? (0, node_only_1.interpolationSafeWindowsPath)(inputs.rawArgs.join(' '))
|
|
40
46
|
: `\"./**/*.md\"`;
|
|
41
47
|
const mdCodeCommand = `${mdCodePath} ${args}`;
|
|
42
48
|
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(mdCodeCommand, inputs);
|
|
43
49
|
return {
|
|
50
|
+
command: mdCodeCommand,
|
|
44
51
|
success: !results.error,
|
|
45
52
|
};
|
|
46
53
|
}
|
|
@@ -9,14 +9,25 @@ const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
|
|
|
9
9
|
const config_key_1 = require("../../config/config-key");
|
|
10
10
|
exports.compileImplementation = {
|
|
11
11
|
commandName: cli_command_name_1.CliCommandName.Compile,
|
|
12
|
-
description:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
description: {
|
|
13
|
+
sections: [
|
|
14
|
+
{
|
|
15
|
+
title: '',
|
|
16
|
+
content: `compile typescript files
|
|
17
|
+
Pass any extra tsc flags to this command.`,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
examples: [
|
|
21
|
+
{
|
|
22
|
+
title: `no extra flags`,
|
|
23
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile}`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: `one extra flag`,
|
|
27
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Compile} --noEmit`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
20
31
|
implementation: runCompileCommand,
|
|
21
32
|
configKeys: [config_key_1.ConfigKey.TsConfig],
|
|
22
33
|
configFlagSupport: {
|
|
@@ -31,6 +42,7 @@ async function runCompileCommand(inputs) {
|
|
|
31
42
|
.join(' ')}`;
|
|
32
43
|
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(compileCommand, inputs);
|
|
33
44
|
return {
|
|
45
|
+
command: compileCommand,
|
|
34
46
|
success: !results.error,
|
|
35
47
|
};
|
|
36
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractFormatArgs = exports.runFormatCommand = exports.formatImplementation = exports.filesMarkerArg = exports.defaultFormatArgs = exports.FormatOperation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const augment_vir_1 = require("augment-vir");
|
|
5
5
|
const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
|
|
6
6
|
const package_name_1 = require("../../../package-name");
|
|
7
7
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
@@ -31,42 +31,53 @@ exports.defaultFormatArgs = {
|
|
|
31
31
|
exports.filesMarkerArg = '--format-files';
|
|
32
32
|
exports.formatImplementation = {
|
|
33
33
|
commandName: cli_command_name_1.CliCommandName.Format,
|
|
34
|
-
description:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
and the "${exports.filesMarkerArg}" marker are treated as extra arguments to Prettier and
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
34
|
+
description: {
|
|
35
|
+
sections: [
|
|
36
|
+
{
|
|
37
|
+
title: '',
|
|
38
|
+
content: 'Formats source files with Prettier.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'operation commands',
|
|
42
|
+
content: `This is optional but if provided it must come first. ${FormatOperation.Write} is the default.
|
|
43
|
+
${FormatOperation.Write}: overwrites files to fix formatting.
|
|
44
|
+
${FormatOperation.Check}: checks the formatting, does not write to files`,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'file extensions',
|
|
48
|
+
content: `If only specific file extensions should be formatted, add the "${exports.filesMarkerArg}" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will overwrite files (because ${FormatOperation.Write} is the default operation) only if they have the extension ".md" or ".json": ${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${exports.filesMarkerArg} md json`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: 'Prettier flags',
|
|
52
|
+
content: `Any other arguments encountered between the operation command (if provided) and the "${exports.filesMarkerArg}" marker are treated as extra arguments to Prettier and will be passed along.`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
examples: [
|
|
56
|
+
{
|
|
57
|
+
title: 'checks formatting for files',
|
|
58
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check}`,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: 'checks formatting only for .md files',
|
|
62
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md`,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: 'checks formatting only for .md and .json files',
|
|
66
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Check} ${exports.filesMarkerArg} md json`,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: 'fixes formatting for files',
|
|
70
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format}
|
|
71
|
+
${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write}`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: `examples with extra Prettier flags`,
|
|
75
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} --ignore-path .prettierignore
|
|
76
|
+
${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore
|
|
77
|
+
${package_name_1.packageName} ${cli_command_name_1.CliCommandName.Format} ${FormatOperation.Write} --ignore-path .prettierignore ${exports.filesMarkerArg} md json`,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
70
81
|
configKeys: [
|
|
71
82
|
config_key_1.ConfigKey.Prettier,
|
|
72
83
|
config_key_1.ConfigKey.PrettierIgnore,
|
|
@@ -80,7 +91,9 @@ const prettierPath = (0, virmator_repo_paths_1.getNpmBinPath)('prettier');
|
|
|
80
91
|
async function runFormatCommand(inputs) {
|
|
81
92
|
const args = extractFormatArgs(inputs.rawArgs);
|
|
82
93
|
const operationFlag = args.operation === FormatOperation.Check ? '--check' : '--write';
|
|
83
|
-
const
|
|
94
|
+
const fileExtensions = `\"./**/*.+(${args.fileExtensions.join('|')})\"`;
|
|
95
|
+
const hasNonFlags = args.prettierFlags.some((flag) => !flag.startsWith('-'));
|
|
96
|
+
const prettierCommand = `${prettierPath} --color ${args.prettierFlags.join(' ')} ${hasNonFlags ? '' : fileExtensions} ${operationFlag}`;
|
|
84
97
|
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(prettierCommand, inputs, {
|
|
85
98
|
stdoutFilter: (stdout) => stdout
|
|
86
99
|
// only relevant when running the check command
|
|
@@ -89,17 +102,18 @@ async function runFormatCommand(inputs) {
|
|
|
89
102
|
.replace('All matched files use Prettier code style!\n', ''),
|
|
90
103
|
});
|
|
91
104
|
return {
|
|
105
|
+
command: prettierCommand,
|
|
92
106
|
success: !results.error,
|
|
93
107
|
};
|
|
94
108
|
}
|
|
95
109
|
exports.runFormatCommand = runFormatCommand;
|
|
96
110
|
function extractFormatArgs(rawArgs) {
|
|
97
111
|
let addingFileExtensions = false;
|
|
98
|
-
const operation = (0,
|
|
112
|
+
const operation = (0, augment_vir_1.isEnumValue)(rawArgs[0], FormatOperation)
|
|
99
113
|
? rawArgs[0]
|
|
100
114
|
: FormatOperation.Write;
|
|
101
115
|
const extractedArgs = rawArgs.reduce((accum, currentRawArg, index) => {
|
|
102
|
-
if (index === 0 && (0,
|
|
116
|
+
if (index === 0 && (0, augment_vir_1.isEnumValue)(rawArgs[index], FormatOperation)) {
|
|
103
117
|
return accum;
|
|
104
118
|
}
|
|
105
119
|
else if (currentRawArg === exports.filesMarkerArg) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runInitCommand = exports.initCommandImplementation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
5
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
6
6
|
const cli_flags_1 = require("../../cli-util/cli-flags");
|
|
7
7
|
const config_key_1 = require("../../config/config-key");
|
|
@@ -11,9 +11,17 @@ const format_command_1 = require("./format.command");
|
|
|
11
11
|
const update_all_configs_command_1 = require("./update-all-configs.command");
|
|
12
12
|
exports.initCommandImplementation = {
|
|
13
13
|
commandName: cli_command_name_1.CliCommandName.Test,
|
|
14
|
-
description:
|
|
14
|
+
description: {
|
|
15
|
+
sections: [
|
|
16
|
+
{
|
|
17
|
+
title: '',
|
|
18
|
+
content: `Init everything, including package.json scripts.
|
|
15
19
|
If no package.json file is found, one is created and initialized.
|
|
16
20
|
Pass --force to this command to overwrite current package.json scripts.`,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
examples: [],
|
|
24
|
+
},
|
|
17
25
|
implementation: runInitCommand,
|
|
18
26
|
configFlagSupport: {
|
|
19
27
|
[cli_flags_1.CliFlagName.NoWriteConfig]: true,
|
|
@@ -35,12 +43,13 @@ async function runInitCommand(inputs) {
|
|
|
35
43
|
error = catchError;
|
|
36
44
|
}
|
|
37
45
|
return {
|
|
46
|
+
command: undefined,
|
|
38
47
|
success: !error,
|
|
39
48
|
};
|
|
40
49
|
}
|
|
41
50
|
exports.runInitCommand = runInitCommand;
|
|
42
51
|
async function updatePackageJson(repoDir) {
|
|
43
52
|
const repoPackageJsonPath = (0, config_paths_1.getRepoConfigFilePath)(config_key_1.ConfigKey.PackageJson, false);
|
|
44
|
-
const finalPackageJsonContents = (0, config_read_1.readUpdatedVirmatorConfigFile)(config_key_1.ConfigKey.PackageJson, repoDir, false);
|
|
45
|
-
await (0,
|
|
53
|
+
const finalPackageJsonContents = await (0, config_read_1.readUpdatedVirmatorConfigFile)(config_key_1.ConfigKey.PackageJson, repoDir, false);
|
|
54
|
+
await (0, promises_1.writeFile)(repoPackageJsonPath, finalPackageJsonContents);
|
|
46
55
|
}
|
|
@@ -8,7 +8,15 @@ const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
|
|
|
8
8
|
const config_key_1 = require("../../config/config-key");
|
|
9
9
|
exports.spellcheckCommandImplementation = {
|
|
10
10
|
commandName: cli_command_name_1.CliCommandName.SpellCheck,
|
|
11
|
-
description:
|
|
11
|
+
description: {
|
|
12
|
+
sections: [
|
|
13
|
+
{
|
|
14
|
+
title: '',
|
|
15
|
+
content: `Spellcheck code with cspell. Any extra arguments are passed directly to cspell.`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
examples: [],
|
|
19
|
+
},
|
|
12
20
|
implementation: runSpellcheckCommand,
|
|
13
21
|
configKeys: [config_key_1.ConfigKey.Cspell],
|
|
14
22
|
configFlagSupport: {
|
|
@@ -20,6 +28,7 @@ async function runSpellcheckCommand(inputs) {
|
|
|
20
28
|
const spellcheckCommand = `${cSpellPath} --color "{*,.*,**/{.*,*}/**/{.*,*}}" ${inputs.rawArgs.join(' ')}`;
|
|
21
29
|
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(spellcheckCommand, inputs);
|
|
22
30
|
return {
|
|
31
|
+
command: spellcheckCommand,
|
|
23
32
|
success: !results.error,
|
|
24
33
|
};
|
|
25
34
|
}
|
|
@@ -1,45 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTestCommand = exports.testCommandImplementation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_only_1 = require("augment-vir/dist/node-only");
|
|
5
|
+
const jest_config_path_1 = require("../../../exportable-jest-config/jest-config-path");
|
|
5
6
|
const virmator_repo_paths_1 = require("../../../file-paths/virmator-repo-paths");
|
|
6
7
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
7
8
|
const cli_flags_1 = require("../../cli-util/cli-flags");
|
|
8
9
|
const shell_command_wrapper_1 = require("../../cli-util/shell-command-wrapper");
|
|
9
|
-
const compile_command_1 = require("./compile.command");
|
|
10
10
|
exports.testCommandImplementation = {
|
|
11
11
|
commandName: cli_command_name_1.CliCommandName.Test,
|
|
12
|
-
description:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
description: {
|
|
13
|
+
sections: [
|
|
14
|
+
{
|
|
15
|
+
title: '',
|
|
16
|
+
content: `Test all .test.ts files with jest. By default this command tests all .test.ts files in the current directory that are not .type.test.ts files. To override this behavior, pass in a custom config file with Jest's --config argument. The default Jest config file can be extended by importing it with "import {virmatorJestConfig} from 'virmator'". All other Jest inputs are also valid.`,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
examples: [
|
|
20
|
+
{ title: '', content: `virmator test ./path/to/single/file.js` },
|
|
21
|
+
{ title: '', content: `virmator test "./**/single-file.js"` },
|
|
22
|
+
{ title: '', content: `virmator test "./dist/**/!(*.type).test.js"` },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
22
25
|
implementation: runTestCommand,
|
|
23
26
|
configFlagSupport: {
|
|
24
27
|
[cli_flags_1.CliFlagName.NoWriteConfig]: false,
|
|
25
28
|
},
|
|
26
29
|
};
|
|
27
|
-
const
|
|
30
|
+
const jestPath = (0, virmator_repo_paths_1.getNpmBinPath)('jest');
|
|
28
31
|
async function runTestCommand(inputs) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
: `\"./dist/**/!(*.type).test.js\"`;
|
|
36
|
-
const testCommand = `${testVirPath} ${args}`;
|
|
37
|
-
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(testCommand, inputs, {
|
|
38
|
-
stdoutFilter: (logString) =>
|
|
39
|
-
// weird looking hex codes here are for color codes from test-vir
|
|
40
|
-
logString.replace('\x1B[1m\x1B[32mAll tests passed.\x1B[0m\n', ''),
|
|
41
|
-
});
|
|
32
|
+
const args = inputs.rawArgs.length ? inputs.rawArgs.join(' ') : '';
|
|
33
|
+
const configPath = args.includes('--config ') || args.includes('-c ')
|
|
34
|
+
? ''
|
|
35
|
+
: `--config ${(0, node_only_1.interpolationSafeWindowsPath)(jest_config_path_1.virmatorJestConfigFilePath)}`;
|
|
36
|
+
const testCommand = `${jestPath} ${configPath} ${args}`;
|
|
37
|
+
const results = await (0, shell_command_wrapper_1.runVirmatorShellCommand)(testCommand, inputs);
|
|
42
38
|
return {
|
|
39
|
+
command: testCommand,
|
|
43
40
|
success: !results.error,
|
|
44
41
|
};
|
|
45
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runUpdateAllConfigsCommand = exports.updateAllConfigsCommandImplementation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const augment_vir_1 = require("augment-vir");
|
|
5
5
|
const package_name_1 = require("../../../package-name");
|
|
6
6
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
7
7
|
const cli_flags_1 = require("../../cli-util/cli-flags");
|
|
@@ -13,19 +13,28 @@ const exampleFlags = [
|
|
|
13
13
|
];
|
|
14
14
|
exports.updateAllConfigsCommandImplementation = {
|
|
15
15
|
commandName: cli_command_name_1.CliCommandName.UpdateAllConfigs,
|
|
16
|
-
description:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
description: {
|
|
17
|
+
sections: [
|
|
18
|
+
{
|
|
19
|
+
title: '',
|
|
20
|
+
content: `Update all config files. This command accepts a list of config file keys as arguments. If no arguments are given, this command copies all config files.`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'list of possible arguments',
|
|
24
|
+
content: (0, augment_vir_1.getEnumTypedValues)(config_key_1.ConfigKey).join('\n'),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
title: `update all config files`,
|
|
30
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs}`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: `update only ${(0, augment_vir_1.joinWithFinalConjunction)(exampleFlags)} files`,
|
|
34
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateAllConfigs} ${exampleFlags.join(' ')}`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
29
38
|
implementation: runUpdateAllConfigsCommand,
|
|
30
39
|
configFlagSupport: {
|
|
31
40
|
[cli_flags_1.CliFlagName.NoWriteConfig]: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runUpdateBareConfigsCommand = exports.updateBareConfigsCommandImplementation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const augment_vir_1 = require("augment-vir");
|
|
5
5
|
const package_name_1 = require("../../../package-name");
|
|
6
6
|
const cli_command_name_1 = require("../../cli-util/cli-command-name");
|
|
7
7
|
const cli_flags_1 = require("../../cli-util/cli-flags");
|
|
@@ -13,20 +13,28 @@ const exampleFlags = [
|
|
|
13
13
|
];
|
|
14
14
|
exports.updateBareConfigsCommandImplementation = {
|
|
15
15
|
commandName: cli_command_name_1.CliCommandName.UpdateBareConfigs,
|
|
16
|
-
description:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
description: {
|
|
17
|
+
sections: [
|
|
18
|
+
{
|
|
19
|
+
title: '',
|
|
20
|
+
content: `Update config files that aren't used in any ${package_name_1.packageName} commands, like GitHub actions tests or VS Code Settings. This command accepts a list of bare config file keys as arguments. If no arguments are given, this command copies all the bare config files.`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'list of possible arguments',
|
|
24
|
+
content: (0, augment_vir_1.getEnumTypedValues)(config_key_1.BareConfigKey).join('\n'),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
title: `update all bare config files`,
|
|
30
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs}`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: `update only ${(0, augment_vir_1.joinWithFinalConjunction)(exampleFlags)} files`,
|
|
34
|
+
content: `${package_name_1.packageName} ${cli_command_name_1.CliCommandName.UpdateBareConfigs} ${exampleFlags.join(' ')},`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
30
38
|
implementation: runUpdateBareConfigsCommand,
|
|
31
39
|
configFlagSupport: {
|
|
32
40
|
[cli_flags_1.CliFlagName.NoWriteConfig]: false,
|
|
@@ -11,13 +11,12 @@ const extendable_config_1 = require("../config/extendable-config");
|
|
|
11
11
|
const all_cli_commands_1 = require("./all-cli-commands");
|
|
12
12
|
const cli_command_1 = require("./cli-command");
|
|
13
13
|
async function runCommand(command, commandInput) {
|
|
14
|
-
var _a, _b;
|
|
15
14
|
const commandImplementation = all_cli_commands_1.allCliCommands[command];
|
|
16
15
|
const cliFlags = (0, cli_flags_1.fillInCliFlags)(commandInput.rawCliFlags);
|
|
17
16
|
const defaultFlagSupport = {
|
|
18
17
|
[cli_flags_1.CliFlagName.Silent]: true,
|
|
19
18
|
[cli_flags_1.CliFlagName.Help]: true,
|
|
20
|
-
[cli_flags_1.CliFlagName.ExtendableConfig]: !!
|
|
19
|
+
[cli_flags_1.CliFlagName.ExtendableConfig]: !!commandImplementation.configKeys?.some((configKey) => (0, extendable_config_1.isExtendableConfig)(configKey)),
|
|
21
20
|
};
|
|
22
21
|
const unsupportedFlagsInUse = (0, all_cli_commands_1.getUnsupportedFlags)(cliFlags, {
|
|
23
22
|
...defaultFlagSupport,
|
|
@@ -26,7 +25,7 @@ async function runCommand(command, commandInput) {
|
|
|
26
25
|
if (command !== cli_command_name_1.CliCommandName.Help && unsupportedFlagsInUse.length) {
|
|
27
26
|
throw new cli_command_error_1.VirmatorCliCommandError(cli_messages_1.cliErrorMessages.unsupportedCliFlag(command, unsupportedFlagsInUse));
|
|
28
27
|
}
|
|
29
|
-
if (
|
|
28
|
+
if (commandImplementation.configKeys?.length && !cliFlags[cli_flags_1.CliFlagName.NoWriteConfig]) {
|
|
30
29
|
await Promise.all(commandImplementation.configKeys.map(async (configKey) => {
|
|
31
30
|
const copyOutput = await (0, copy_config_1.copyConfig)({
|
|
32
31
|
configKey: configKey,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** These config files are not used by any virmator commands but they are still helpful. */
|
|
2
2
|
export declare enum BareConfigKey {
|
|
3
3
|
GitAttributes = "GitAttributes",
|
|
4
|
-
GitHubActionsTest = "GitHubActionsTest",
|
|
5
|
-
GitHubActionsTaggedRelease = "GitHubActionsTaggedRelease",
|
|
6
4
|
GitHubActionsPrerelease = "GitHubActionsPrerelease",
|
|
5
|
+
GitHubActionsTaggedRelease = "GitHubActionsTaggedRelease",
|
|
6
|
+
GitHubActionsTest = "GitHubActionsTest",
|
|
7
7
|
GitIgnore = "GitIgnore",
|
|
8
8
|
NpmIgnore = "NpmIgnore",
|
|
9
9
|
VsCodeSettings = "VsCodeSettings"
|
|
@@ -11,23 +11,23 @@ export declare enum BareConfigKey {
|
|
|
11
11
|
/** These are config files used by virmator commands. */
|
|
12
12
|
export declare enum CommandConfigKey {
|
|
13
13
|
Cspell = "Cspell",
|
|
14
|
-
Prettier = "Prettier",
|
|
15
|
-
TsConfig = "TsConfig",
|
|
16
14
|
PackageJson = "PackageJson",
|
|
17
|
-
|
|
15
|
+
Prettier = "Prettier",
|
|
16
|
+
PrettierIgnore = "PrettierIgnore",
|
|
17
|
+
TsConfig = "TsConfig"
|
|
18
18
|
}
|
|
19
19
|
export declare const ConfigKey: {
|
|
20
20
|
GitAttributes: BareConfigKey.GitAttributes;
|
|
21
|
-
GitHubActionsTest: BareConfigKey.GitHubActionsTest;
|
|
22
|
-
GitHubActionsTaggedRelease: BareConfigKey.GitHubActionsTaggedRelease;
|
|
23
21
|
GitHubActionsPrerelease: BareConfigKey.GitHubActionsPrerelease;
|
|
22
|
+
GitHubActionsTaggedRelease: BareConfigKey.GitHubActionsTaggedRelease;
|
|
23
|
+
GitHubActionsTest: BareConfigKey.GitHubActionsTest;
|
|
24
24
|
GitIgnore: BareConfigKey.GitIgnore;
|
|
25
25
|
NpmIgnore: BareConfigKey.NpmIgnore;
|
|
26
26
|
VsCodeSettings: BareConfigKey.VsCodeSettings;
|
|
27
27
|
Cspell: CommandConfigKey.Cspell;
|
|
28
|
-
Prettier: CommandConfigKey.Prettier;
|
|
29
|
-
TsConfig: CommandConfigKey.TsConfig;
|
|
30
28
|
PackageJson: CommandConfigKey.PackageJson;
|
|
29
|
+
Prettier: CommandConfigKey.Prettier;
|
|
31
30
|
PrettierIgnore: CommandConfigKey.PrettierIgnore;
|
|
31
|
+
TsConfig: CommandConfigKey.TsConfig;
|
|
32
32
|
};
|
|
33
33
|
export declare type ConfigKey = CommandConfigKey | BareConfigKey;
|
|
@@ -5,9 +5,9 @@ exports.ConfigKey = exports.CommandConfigKey = exports.BareConfigKey = void 0;
|
|
|
5
5
|
var BareConfigKey;
|
|
6
6
|
(function (BareConfigKey) {
|
|
7
7
|
BareConfigKey["GitAttributes"] = "GitAttributes";
|
|
8
|
-
BareConfigKey["GitHubActionsTest"] = "GitHubActionsTest";
|
|
9
|
-
BareConfigKey["GitHubActionsTaggedRelease"] = "GitHubActionsTaggedRelease";
|
|
10
8
|
BareConfigKey["GitHubActionsPrerelease"] = "GitHubActionsPrerelease";
|
|
9
|
+
BareConfigKey["GitHubActionsTaggedRelease"] = "GitHubActionsTaggedRelease";
|
|
10
|
+
BareConfigKey["GitHubActionsTest"] = "GitHubActionsTest";
|
|
11
11
|
BareConfigKey["GitIgnore"] = "GitIgnore";
|
|
12
12
|
BareConfigKey["NpmIgnore"] = "NpmIgnore";
|
|
13
13
|
BareConfigKey["VsCodeSettings"] = "VsCodeSettings";
|
|
@@ -16,9 +16,9 @@ var BareConfigKey;
|
|
|
16
16
|
var CommandConfigKey;
|
|
17
17
|
(function (CommandConfigKey) {
|
|
18
18
|
CommandConfigKey["Cspell"] = "Cspell";
|
|
19
|
-
CommandConfigKey["Prettier"] = "Prettier";
|
|
20
|
-
CommandConfigKey["TsConfig"] = "TsConfig";
|
|
21
19
|
CommandConfigKey["PackageJson"] = "PackageJson";
|
|
20
|
+
CommandConfigKey["Prettier"] = "Prettier";
|
|
22
21
|
CommandConfigKey["PrettierIgnore"] = "PrettierIgnore";
|
|
22
|
+
CommandConfigKey["TsConfig"] = "TsConfig";
|
|
23
23
|
})(CommandConfigKey = exports.CommandConfigKey || (exports.CommandConfigKey = {}));
|
|
24
24
|
exports.ConfigKey = { ...CommandConfigKey, ...BareConfigKey };
|
|
@@ -15,9 +15,9 @@ var DifferentConfigPathTypes;
|
|
|
15
15
|
const configFileMap = {
|
|
16
16
|
[config_key_1.ConfigKey.Cspell]: '.cspell.json',
|
|
17
17
|
[config_key_1.ConfigKey.GitAttributes]: '.gitattributes',
|
|
18
|
-
[config_key_1.ConfigKey.GitHubActionsTest]: (0, path_1.join)('.github', 'workflows', 'virmator-tests.yml'),
|
|
19
18
|
[config_key_1.ConfigKey.GitHubActionsPrerelease]: (0, path_1.join)('.github', 'workflows', 'virmator-prerelease.yml'),
|
|
20
19
|
[config_key_1.ConfigKey.GitHubActionsTaggedRelease]: (0, path_1.join)('.github', 'workflows', 'virmator-tagged-release.yml'),
|
|
20
|
+
[config_key_1.ConfigKey.GitHubActionsTest]: (0, path_1.join)('.github', 'workflows', 'virmator-tests.yml'),
|
|
21
21
|
[config_key_1.ConfigKey.GitIgnore]: {
|
|
22
22
|
virmator: (0, path_1.join)(virmator_repo_paths_1.relativeSeparateConfigsDir, 'gitignore.txt'),
|
|
23
23
|
repo: '.gitignore',
|
|
@@ -44,7 +44,6 @@ async function readUpdatedVirmatorConfigFile(configKey, repoDir, extendable) {
|
|
|
44
44
|
}
|
|
45
45
|
exports.readUpdatedVirmatorConfigFile = readUpdatedVirmatorConfigFile;
|
|
46
46
|
async function updateVirmatorConfig(configKey, repoDir, extendable) {
|
|
47
|
-
var _a;
|
|
48
47
|
const virmatorConfigContents = await readVirmatorConfigFile(configKey, extendable);
|
|
49
48
|
switch (configKey) {
|
|
50
49
|
// in these special cases we want to merge the config files with what's already in the repo
|
|
@@ -77,7 +76,7 @@ async function updateVirmatorConfig(configKey, repoDir, extendable) {
|
|
|
77
76
|
...repoPackageJson,
|
|
78
77
|
scripts: {
|
|
79
78
|
...defaultPackageJson.scripts,
|
|
80
|
-
...(
|
|
79
|
+
...(repoPackageJson.scripts ?? {}),
|
|
81
80
|
},
|
|
82
81
|
});
|
|
83
82
|
}
|