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,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nonCommandConfigs = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const package_paths_1 = require("../../file-paths/package-paths");
|
|
6
|
-
const combine_json_config_1 = require("./combine-json-config");
|
|
7
|
-
const combine_text_config_1 = require("./combine-text-config");
|
|
8
|
-
const create_default_package_json_1 = require("./create-default-package-json");
|
|
9
|
-
exports.nonCommandConfigs = [
|
|
10
|
-
{
|
|
11
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.gitattributes'),
|
|
12
|
-
copyToPathRelativeToRepoDir: '.gitattributes',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.nvmrc'),
|
|
16
|
-
copyToPathRelativeToRepoDir: '.nvmrc',
|
|
17
|
-
updateExistingConfigFileCallback: (newContents) => newContents,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'LICENSE-MIT'),
|
|
21
|
-
copyToPathRelativeToRepoDir: 'LICENSE-MIT',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'LICENSE-CC0'),
|
|
25
|
-
copyToPathRelativeToRepoDir: 'LICENSE-CC0',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'gitignore.txt'),
|
|
29
|
-
updateExistingConfigFileCallback: combine_text_config_1.combineTextConfig,
|
|
30
|
-
copyToPathRelativeToRepoDir: '.gitignore',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'npmignore.txt'),
|
|
34
|
-
updateExistingConfigFileCallback: combine_text_config_1.combineTextConfig,
|
|
35
|
-
copyToPathRelativeToRepoDir: '.npmignore',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'package.json'),
|
|
39
|
-
copyToPathRelativeToRepoDir: 'package.json',
|
|
40
|
-
updateExistingConfigFileCallback: create_default_package_json_1.createDefaultPackageJson,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.vscode', 'settings.json'),
|
|
44
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('.vscode', 'settings.json'),
|
|
45
|
-
updateExistingConfigFileCallback: combine_json_config_1.combineJsonConfig,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.github', 'workflows', 'build-for-gh-pages.yml'),
|
|
49
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('.github', 'workflows', 'build-for-gh-pages.yml'),
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.github', 'workflows', 'tagged-release.yml'),
|
|
53
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('.github', 'workflows', 'tagged-release.yml'),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.github', 'workflows', 'tests.yml'),
|
|
57
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('.github', 'workflows', 'tests.yml'),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'www-static', 'index.css'),
|
|
61
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('www-static', 'index.css'),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'src', 'index.html'),
|
|
65
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('src', 'index.html'),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'src', 'ui', 'elements', 'vir-app.element.ts'),
|
|
69
|
-
copyToPathRelativeToRepoDir: (0, path_1.join)('src', 'ui', 'elements', 'vir-app.element.ts'),
|
|
70
|
-
},
|
|
71
|
-
];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineJsonConfig = combineJsonConfig;
|
|
4
|
-
const common_1 = require("@augment-vir/common");
|
|
5
|
-
const object_1 = require("../../augments/object");
|
|
6
|
-
const prettier_1 = require("../../augments/prettier");
|
|
7
|
-
async function combineJsonConfig(...[newConfigContents, existingConfigContents,]) {
|
|
8
|
-
let oldJson;
|
|
9
|
-
try {
|
|
10
|
-
oldJson = JSON.parse(existingConfigContents);
|
|
11
|
-
}
|
|
12
|
-
catch (error) { }
|
|
13
|
-
const newJson = JSON.parse(newConfigContents);
|
|
14
|
-
if (!oldJson || !(0, common_1.isObject)(oldJson)) {
|
|
15
|
-
return stringify(newJson);
|
|
16
|
-
}
|
|
17
|
-
return stringify((0, object_1.deeplyCombineObjects)(oldJson, newJson));
|
|
18
|
-
}
|
|
19
|
-
async function stringify(input) {
|
|
20
|
-
return await (0, prettier_1.formatCode)(JSON.stringify(input, null, 4), 'a.json');
|
|
21
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineTextConfig = combineTextConfig;
|
|
4
|
-
const common_1 = require("@augment-vir/common");
|
|
5
|
-
function splitContentsIntoArrayOfLines(input) {
|
|
6
|
-
return input
|
|
7
|
-
.split('\n')
|
|
8
|
-
.map((line) => line.trim())
|
|
9
|
-
.filter(common_1.isTruthy)
|
|
10
|
-
.sort();
|
|
11
|
-
}
|
|
12
|
-
function combineTextConfig(...[newConfigContents, existingConfigContents,]) {
|
|
13
|
-
const sortedNew = splitContentsIntoArrayOfLines(newConfigContents);
|
|
14
|
-
const sortedExisting = splitContentsIntoArrayOfLines(existingConfigContents);
|
|
15
|
-
let existingLinesAppended = false;
|
|
16
|
-
sortedExisting.forEach((existingLine) => {
|
|
17
|
-
if (!sortedNew.includes(existingLine) && !sortedNew.includes(`${existingLine}/`)) {
|
|
18
|
-
if (!existingLinesAppended) {
|
|
19
|
-
sortedNew.push('');
|
|
20
|
-
existingLinesAppended = true;
|
|
21
|
-
}
|
|
22
|
-
sortedNew.push(existingLine);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return sortedNew.join('\n');
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createDefaultPackageJson(copyFromContents: string, existingConfigContents: string, repoDir: string): Promise<string>;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createDefaultPackageJson = createDefaultPackageJson;
|
|
7
|
-
const common_1 = require("@augment-vir/common");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const simple_git_1 = __importDefault(require("simple-git"));
|
|
10
|
-
const json_1 = require("../../augments/json");
|
|
11
|
-
const prettier_1 = require("../../augments/prettier");
|
|
12
|
-
async function createDefaultPackageJson(copyFromContents, existingConfigContents, repoDir) {
|
|
13
|
-
const baseVirmatorPackageJson = JSON.parse(copyFromContents);
|
|
14
|
-
if (!(0, common_1.isObject)(baseVirmatorPackageJson)) {
|
|
15
|
-
throw new Error(`Failed to parse virmator's config version of package json file.`);
|
|
16
|
-
}
|
|
17
|
-
const currentRepoPackageJson = (0, json_1.jsonParseOrUndefined)(existingConfigContents) ?? {};
|
|
18
|
-
if (!(0, common_1.isObject)(currentRepoPackageJson)) {
|
|
19
|
-
throw new Error(`Failed to parse current repo's package json file.`);
|
|
20
|
-
}
|
|
21
|
-
const combinedScripts = combineScripts(baseVirmatorPackageJson, currentRepoPackageJson);
|
|
22
|
-
const gitProperties = await getGitProperties(repoDir);
|
|
23
|
-
const newPackageJson = {
|
|
24
|
-
name: (0, path_1.basename)(repoDir),
|
|
25
|
-
...currentRepoPackageJson,
|
|
26
|
-
...baseVirmatorPackageJson,
|
|
27
|
-
...gitProperties,
|
|
28
|
-
scripts: combinedScripts,
|
|
29
|
-
};
|
|
30
|
-
return await (0, prettier_1.formatCode)(JSON.stringify(newPackageJson), 'package.json');
|
|
31
|
-
}
|
|
32
|
-
function combineScripts(virmatorPackageJson, currentRepoPackageJson) {
|
|
33
|
-
const scripts = {
|
|
34
|
-
...currentRepoPackageJson.scripts,
|
|
35
|
-
};
|
|
36
|
-
(0, common_1.getObjectTypedKeys)(virmatorPackageJson.scripts).forEach((key) => {
|
|
37
|
-
const virmatorValue = virmatorPackageJson.scripts[key];
|
|
38
|
-
const currentRepoValue = scripts[key];
|
|
39
|
-
if (virmatorValue &&
|
|
40
|
-
(!scripts.hasOwnProperty(key) ||
|
|
41
|
-
(key === 'test' &&
|
|
42
|
-
currentRepoValue &&
|
|
43
|
-
currentRepoValue.includes('Error: no test specified')))) {
|
|
44
|
-
scripts[key] = virmatorValue;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return scripts;
|
|
48
|
-
}
|
|
49
|
-
async function getGitProperties(repoDir) {
|
|
50
|
-
const git = (0, simple_git_1.default)(repoDir);
|
|
51
|
-
const remotes = await git.getRemotes(true);
|
|
52
|
-
const originRemote = remotes.find((remote) => remote.name === 'origin') || remotes[0];
|
|
53
|
-
if (originRemote) {
|
|
54
|
-
return createGitUrls(originRemote.refs.fetch);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function createGitUrls(ref) {
|
|
61
|
-
const repoPath = ref
|
|
62
|
-
.replace(/(\w):(\w)/g, '$1/$2')
|
|
63
|
-
.replace(/\.git$/, '')
|
|
64
|
-
.replace(/^git@/g, 'https://');
|
|
65
|
-
const isGitHub = repoPath.includes('github.com');
|
|
66
|
-
const issuesUrl = isGitHub ? `${repoPath}/issues` : '';
|
|
67
|
-
const username = repoPath.replace(/^.+\.com\//, '').replace(/\/.+$/, '');
|
|
68
|
-
const bugsObject = issuesUrl ? { bugs: { url: issuesUrl } } : {};
|
|
69
|
-
const userUrlObject = isGitHub
|
|
70
|
-
? {
|
|
71
|
-
url: `https://github.com/${username}`,
|
|
72
|
-
}
|
|
73
|
-
: {};
|
|
74
|
-
return {
|
|
75
|
-
homepage: repoPath,
|
|
76
|
-
...bugsObject,
|
|
77
|
-
repository: {
|
|
78
|
-
type: 'git',
|
|
79
|
-
url: `git+${repoPath}.git`,
|
|
80
|
-
},
|
|
81
|
-
author: {
|
|
82
|
-
name: username,
|
|
83
|
-
...userUrlObject,
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { NpmDepTypeEnum } from '../api/command/define-command-inputs';
|
|
2
|
-
import { combineTextConfig } from './extra-configs/combine-text-config';
|
|
3
|
-
export declare const formatCommandDefinition: {
|
|
4
|
-
commandName: "format";
|
|
5
|
-
subCommandDescriptions: {
|
|
6
|
-
readonly check: "check formatting without overwriting files.";
|
|
7
|
-
};
|
|
8
|
-
configFiles: {
|
|
9
|
-
readonly prettierrc: {
|
|
10
|
-
readonly copyFromInternalPath: string;
|
|
11
|
-
readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
|
|
12
|
-
};
|
|
13
|
-
readonly prettierIgnore: {
|
|
14
|
-
readonly copyFromInternalPath: string;
|
|
15
|
-
readonly copyToPathRelativeToRepoDir: ".prettierignore";
|
|
16
|
-
readonly updateExistingConfigFileCallback: typeof combineTextConfig;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
npmDeps: readonly [{
|
|
20
|
-
readonly name: "prettier";
|
|
21
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
22
|
-
}, {
|
|
23
|
-
readonly name: "prettier-plugin-jsdoc";
|
|
24
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
25
|
-
}, {
|
|
26
|
-
readonly name: "prettier-plugin-multiline-arrays";
|
|
27
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
28
|
-
}, {
|
|
29
|
-
readonly name: "prettier-plugin-organize-imports";
|
|
30
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
31
|
-
}, {
|
|
32
|
-
readonly name: "prettier-plugin-packagejson";
|
|
33
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
34
|
-
}, {
|
|
35
|
-
readonly name: "prettier-plugin-sort-json";
|
|
36
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
37
|
-
}, {
|
|
38
|
-
readonly name: "prettier-plugin-toml";
|
|
39
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
40
|
-
}, {
|
|
41
|
-
readonly name: "prettier-plugin-interpolated-html-tags";
|
|
42
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
43
|
-
}];
|
|
44
|
-
} & {
|
|
45
|
-
allAvailableSubCommands: readonly "check"[];
|
|
46
|
-
subCommands: import("../api/command/define-command-inputs").SubCommandsMap<{
|
|
47
|
-
commandName: "format";
|
|
48
|
-
subCommandDescriptions: {
|
|
49
|
-
readonly check: "check formatting without overwriting files.";
|
|
50
|
-
};
|
|
51
|
-
configFiles: {
|
|
52
|
-
readonly prettierrc: {
|
|
53
|
-
readonly copyFromInternalPath: string;
|
|
54
|
-
readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
|
|
55
|
-
};
|
|
56
|
-
readonly prettierIgnore: {
|
|
57
|
-
readonly copyFromInternalPath: string;
|
|
58
|
-
readonly copyToPathRelativeToRepoDir: ".prettierignore";
|
|
59
|
-
readonly updateExistingConfigFileCallback: typeof combineTextConfig;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
npmDeps: readonly [{
|
|
63
|
-
readonly name: "prettier";
|
|
64
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
65
|
-
}, {
|
|
66
|
-
readonly name: "prettier-plugin-jsdoc";
|
|
67
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
68
|
-
}, {
|
|
69
|
-
readonly name: "prettier-plugin-multiline-arrays";
|
|
70
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
71
|
-
}, {
|
|
72
|
-
readonly name: "prettier-plugin-organize-imports";
|
|
73
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
74
|
-
}, {
|
|
75
|
-
readonly name: "prettier-plugin-packagejson";
|
|
76
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
77
|
-
}, {
|
|
78
|
-
readonly name: "prettier-plugin-sort-json";
|
|
79
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
80
|
-
}, {
|
|
81
|
-
readonly name: "prettier-plugin-toml";
|
|
82
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
83
|
-
}, {
|
|
84
|
-
readonly name: "prettier-plugin-interpolated-html-tags";
|
|
85
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
86
|
-
}];
|
|
87
|
-
}>;
|
|
88
|
-
} & {
|
|
89
|
-
executor: import("..").CommandExecutor<{
|
|
90
|
-
commandName: "format";
|
|
91
|
-
subCommandDescriptions: {
|
|
92
|
-
readonly check: "check formatting without overwriting files.";
|
|
93
|
-
};
|
|
94
|
-
configFiles: {
|
|
95
|
-
readonly prettierrc: {
|
|
96
|
-
readonly copyFromInternalPath: string;
|
|
97
|
-
readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
|
|
98
|
-
};
|
|
99
|
-
readonly prettierIgnore: {
|
|
100
|
-
readonly copyFromInternalPath: string;
|
|
101
|
-
readonly copyToPathRelativeToRepoDir: ".prettierignore";
|
|
102
|
-
readonly updateExistingConfigFileCallback: typeof combineTextConfig;
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
npmDeps: readonly [{
|
|
106
|
-
readonly name: "prettier";
|
|
107
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
108
|
-
}, {
|
|
109
|
-
readonly name: "prettier-plugin-jsdoc";
|
|
110
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
111
|
-
}, {
|
|
112
|
-
readonly name: "prettier-plugin-multiline-arrays";
|
|
113
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
114
|
-
}, {
|
|
115
|
-
readonly name: "prettier-plugin-organize-imports";
|
|
116
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
117
|
-
}, {
|
|
118
|
-
readonly name: "prettier-plugin-packagejson";
|
|
119
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
120
|
-
}, {
|
|
121
|
-
readonly name: "prettier-plugin-sort-json";
|
|
122
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
123
|
-
}, {
|
|
124
|
-
readonly name: "prettier-plugin-toml";
|
|
125
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
126
|
-
}, {
|
|
127
|
-
readonly name: "prettier-plugin-interpolated-html-tags";
|
|
128
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
129
|
-
}];
|
|
130
|
-
}>;
|
|
131
|
-
createDescription: import("..").CreateDescriptionsCallback<{
|
|
132
|
-
commandName: "format";
|
|
133
|
-
subCommandDescriptions: {
|
|
134
|
-
readonly check: "check formatting without overwriting files.";
|
|
135
|
-
};
|
|
136
|
-
configFiles: {
|
|
137
|
-
readonly prettierrc: {
|
|
138
|
-
readonly copyFromInternalPath: string;
|
|
139
|
-
readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
|
|
140
|
-
};
|
|
141
|
-
readonly prettierIgnore: {
|
|
142
|
-
readonly copyFromInternalPath: string;
|
|
143
|
-
readonly copyToPathRelativeToRepoDir: ".prettierignore";
|
|
144
|
-
readonly updateExistingConfigFileCallback: typeof combineTextConfig;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
npmDeps: readonly [{
|
|
148
|
-
readonly name: "prettier";
|
|
149
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
150
|
-
}, {
|
|
151
|
-
readonly name: "prettier-plugin-jsdoc";
|
|
152
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
153
|
-
}, {
|
|
154
|
-
readonly name: "prettier-plugin-multiline-arrays";
|
|
155
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
156
|
-
}, {
|
|
157
|
-
readonly name: "prettier-plugin-organize-imports";
|
|
158
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
159
|
-
}, {
|
|
160
|
-
readonly name: "prettier-plugin-packagejson";
|
|
161
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
162
|
-
}, {
|
|
163
|
-
readonly name: "prettier-plugin-sort-json";
|
|
164
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
165
|
-
}, {
|
|
166
|
-
readonly name: "prettier-plugin-toml";
|
|
167
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
168
|
-
}, {
|
|
169
|
-
readonly name: "prettier-plugin-interpolated-html-tags";
|
|
170
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
171
|
-
}];
|
|
172
|
-
}>;
|
|
173
|
-
extend: import("../api/command/define-command").ExtendCallback<{
|
|
174
|
-
commandName: "format";
|
|
175
|
-
subCommandDescriptions: {
|
|
176
|
-
readonly check: "check formatting without overwriting files.";
|
|
177
|
-
};
|
|
178
|
-
configFiles: {
|
|
179
|
-
readonly prettierrc: {
|
|
180
|
-
readonly copyFromInternalPath: string;
|
|
181
|
-
readonly copyToPathRelativeToRepoDir: ".prettierrc.js";
|
|
182
|
-
};
|
|
183
|
-
readonly prettierIgnore: {
|
|
184
|
-
readonly copyFromInternalPath: string;
|
|
185
|
-
readonly copyToPathRelativeToRepoDir: ".prettierignore";
|
|
186
|
-
readonly updateExistingConfigFileCallback: typeof combineTextConfig;
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
npmDeps: readonly [{
|
|
190
|
-
readonly name: "prettier";
|
|
191
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
192
|
-
}, {
|
|
193
|
-
readonly name: "prettier-plugin-jsdoc";
|
|
194
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
195
|
-
}, {
|
|
196
|
-
readonly name: "prettier-plugin-multiline-arrays";
|
|
197
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
198
|
-
}, {
|
|
199
|
-
readonly name: "prettier-plugin-organize-imports";
|
|
200
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
201
|
-
}, {
|
|
202
|
-
readonly name: "prettier-plugin-packagejson";
|
|
203
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
204
|
-
}, {
|
|
205
|
-
readonly name: "prettier-plugin-sort-json";
|
|
206
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
207
|
-
}, {
|
|
208
|
-
readonly name: "prettier-plugin-toml";
|
|
209
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
210
|
-
}, {
|
|
211
|
-
readonly name: "prettier-plugin-interpolated-html-tags";
|
|
212
|
-
readonly type: NpmDepTypeEnum.Dev;
|
|
213
|
-
}];
|
|
214
|
-
}>;
|
|
215
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatCommandDefinition = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const define_command_1 = require("../api/command/define-command");
|
|
6
|
-
const define_command_inputs_1 = require("../api/command/define-command-inputs");
|
|
7
|
-
const package_paths_1 = require("../file-paths/package-paths");
|
|
8
|
-
const combine_text_config_1 = require("./extra-configs/combine-text-config");
|
|
9
|
-
const defaultFormatExtensions = [
|
|
10
|
-
'cjs',
|
|
11
|
-
'css',
|
|
12
|
-
'graphql',
|
|
13
|
-
'html',
|
|
14
|
-
'js',
|
|
15
|
-
'json',
|
|
16
|
-
'jsx',
|
|
17
|
-
'less',
|
|
18
|
-
'md',
|
|
19
|
-
'mjs',
|
|
20
|
-
'scss',
|
|
21
|
-
'toml',
|
|
22
|
-
'ts',
|
|
23
|
-
'tsx',
|
|
24
|
-
'yaml',
|
|
25
|
-
'yml',
|
|
26
|
-
];
|
|
27
|
-
const filesMarkerArg = '--file-types';
|
|
28
|
-
exports.formatCommandDefinition = (0, define_command_1.defineCommand)({
|
|
29
|
-
commandName: 'format',
|
|
30
|
-
subCommandDescriptions: {
|
|
31
|
-
check: 'check formatting without overwriting files.',
|
|
32
|
-
},
|
|
33
|
-
configFiles: {
|
|
34
|
-
prettierrc: {
|
|
35
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.prettierrc.js'),
|
|
36
|
-
copyToPathRelativeToRepoDir: '.prettierrc.js',
|
|
37
|
-
},
|
|
38
|
-
prettierIgnore: {
|
|
39
|
-
copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.prettierignore'),
|
|
40
|
-
copyToPathRelativeToRepoDir: '.prettierignore',
|
|
41
|
-
updateExistingConfigFileCallback: combine_text_config_1.combineTextConfig,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
npmDeps: [
|
|
45
|
-
{ name: 'prettier', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
46
|
-
{ name: 'prettier-plugin-jsdoc', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
47
|
-
{ name: 'prettier-plugin-multiline-arrays', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
48
|
-
{ name: 'prettier-plugin-organize-imports', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
49
|
-
{ name: 'prettier-plugin-packagejson', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
50
|
-
{ name: 'prettier-plugin-sort-json', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
51
|
-
{ name: 'prettier-plugin-toml', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
52
|
-
{ name: 'prettier-plugin-interpolated-html-tags', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
|
|
53
|
-
],
|
|
54
|
-
}, ({ commandName, subCommands, packageBinName }) => {
|
|
55
|
-
return {
|
|
56
|
-
sections: [
|
|
57
|
-
{
|
|
58
|
-
title: '',
|
|
59
|
-
content: 'Formats source files with Prettier.',
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
title: 'file extensions',
|
|
63
|
-
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": ${packageBinName} ${commandName} ${filesMarkerArg} md json`,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
title: 'Prettier flags',
|
|
67
|
-
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.`,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
examples: [
|
|
71
|
-
{
|
|
72
|
-
title: 'checks formatting for files',
|
|
73
|
-
content: `${packageBinName} ${commandName} ${subCommands.check}`,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
title: 'checks formatting only for .md files',
|
|
77
|
-
content: `${packageBinName} ${commandName} ${subCommands.check} ${filesMarkerArg} md`,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
title: 'checks formatting only for .md and .json files',
|
|
81
|
-
content: `${packageBinName} ${commandName} ${subCommands.check} ${filesMarkerArg} md json`,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
title: 'fixes formatting for files',
|
|
85
|
-
content: `${packageBinName} ${commandName}
|
|
86
|
-
${packageBinName} ${commandName}`,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
title: `examples with extra Prettier flags`,
|
|
90
|
-
content: `${packageBinName} ${commandName} --ignore-path .prettierignore
|
|
91
|
-
${packageBinName} ${commandName} --ignore-path .prettierignore
|
|
92
|
-
${packageBinName} ${commandName} --ignore-path .prettierignore ${filesMarkerArg} md json`,
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
}, async (inputs) => {
|
|
97
|
-
const formatArgs = extractFormatArgs(inputs.filteredInputArgs);
|
|
98
|
-
const shouldCheckOnly = inputs.inputSubCommands.includes(inputs.subCommands.check) ||
|
|
99
|
-
formatArgs.prettierFlags.includes('--check');
|
|
100
|
-
const operationString = shouldCheckOnly ? '--check ' : '--write';
|
|
101
|
-
const fileExtensions = formatArgs.fileExtensions.length
|
|
102
|
-
? formatArgs.fileExtensions
|
|
103
|
-
: defaultFormatExtensions;
|
|
104
|
-
const filesToFormat = formatArgs.specificFilesToFormat.length
|
|
105
|
-
? formatArgs.specificFilesToFormat.join(' ')
|
|
106
|
-
: `\"./**/*.+(${fileExtensions.join('|')})\"`;
|
|
107
|
-
const listDifferentFlag = shouldCheckOnly ? '' : '--list-different';
|
|
108
|
-
const extraPrettierFlags = formatArgs.prettierFlags.length ? formatArgs.prettierFlags : '';
|
|
109
|
-
const logTransforms = {
|
|
110
|
-
stdout: (stdout) => stdout
|
|
111
|
-
// only relevant when running the check command
|
|
112
|
-
.replace('Checking formatting...\n', '')
|
|
113
|
-
// only relevant when running the check command
|
|
114
|
-
.replace('All matched files use Prettier code style!\n', ''),
|
|
115
|
-
};
|
|
116
|
-
return {
|
|
117
|
-
args: [
|
|
118
|
-
await (0, package_paths_1.getNpmBinPath)({
|
|
119
|
-
repoDir: inputs.repoDir,
|
|
120
|
-
command: 'prettier',
|
|
121
|
-
packageDirPath: inputs.packageDir,
|
|
122
|
-
}),
|
|
123
|
-
'--color',
|
|
124
|
-
'--cache',
|
|
125
|
-
'--cache-strategy',
|
|
126
|
-
'content',
|
|
127
|
-
listDifferentFlag,
|
|
128
|
-
...extraPrettierFlags,
|
|
129
|
-
filesToFormat,
|
|
130
|
-
operationString,
|
|
131
|
-
],
|
|
132
|
-
logTransforms,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
function extractFormatArgs(args) {
|
|
136
|
-
let foundFileTypesFlag = false;
|
|
137
|
-
const formatArgs = {
|
|
138
|
-
prettierFlags: [],
|
|
139
|
-
fileExtensions: [],
|
|
140
|
-
specificFilesToFormat: [],
|
|
141
|
-
};
|
|
142
|
-
args.forEach((arg) => {
|
|
143
|
-
if (foundFileTypesFlag) {
|
|
144
|
-
formatArgs.fileExtensions.push(arg);
|
|
145
|
-
}
|
|
146
|
-
else if (arg === filesMarkerArg) {
|
|
147
|
-
foundFileTypesFlag = true;
|
|
148
|
-
}
|
|
149
|
-
else if (arg.startsWith('-')) {
|
|
150
|
-
formatArgs.prettierFlags.push(arg);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
formatArgs.specificFilesToFormat.push(arg);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return formatArgs;
|
|
157
|
-
}
|