virmator 12.0.3 → 13.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.
Files changed (158) hide show
  1. package/README.md +224 -129
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.js +21 -5
  4. package/dist/index.d.ts +1416 -1310
  5. package/dist/index.js +25 -63
  6. package/dist/tests/test-virmator.mock.d.ts +3 -0
  7. package/dist/tests/test-virmator.mock.js +5 -0
  8. package/package.json +25 -69
  9. package/src/cli.ts +29 -0
  10. package/src/index.ts +26 -0
  11. package/src/tests/test-virmator.mock.ts +13 -0
  12. package/base-configs/base-cspell.js +0 -272
  13. package/base-configs/base-mocharc.cjs +0 -20
  14. package/base-configs/base-nyc.js +0 -40
  15. package/base-configs/base-prettierrc.js +0 -32
  16. package/base-configs/base-web-test-runner.mjs +0 -137
  17. package/base-configs/test-files-glob.js +0 -13
  18. package/base-configs/tsconfig.base.json +0 -32
  19. package/configs/.gitattributes +0 -2
  20. package/configs/.github/workflows/build-for-gh-pages.yml +0 -24
  21. package/configs/.github/workflows/tagged-release.yml +0 -41
  22. package/configs/.github/workflows/tests.yml +0 -25
  23. package/configs/.nvmrc +0 -1
  24. package/configs/.prettierignore +0 -11
  25. package/configs/.prettierrc.js +0 -13
  26. package/configs/.vscode/settings.json +0 -50
  27. package/configs/LICENSE-CC0 +0 -121
  28. package/configs/LICENSE-MIT +0 -21
  29. package/configs/configs/dep-cruiser.config.ts +0 -22
  30. package/configs/configs/mocha.config.cjs +0 -8
  31. package/configs/configs/ncu.config.ts +0 -12
  32. package/configs/configs/nyc.config.js +0 -7
  33. package/configs/configs/typedoc.config.ts +0 -20
  34. package/configs/configs/vite.config.ts +0 -14
  35. package/configs/configs/web-test-runner.config.mjs +0 -21
  36. package/configs/cspell.config.cjs +0 -11
  37. package/configs/dep-cruiser.config.ts +0 -22
  38. package/configs/gitignore.txt +0 -13
  39. package/configs/ncu.config.ts +0 -13
  40. package/configs/npmignore.txt +0 -26
  41. package/configs/package.json +0 -23
  42. package/configs/src/index.html +0 -12
  43. package/configs/src/ui/elements/vir-app.element.ts +0 -10
  44. package/configs/tsconfig.json +0 -16
  45. package/configs/www-static/_redirects +0 -1
  46. package/configs/www-static/index.css +0 -7
  47. package/cspell.config.cjs +0 -13
  48. package/dist/api/command/command-configs.d.ts +0 -3
  49. package/dist/api/command/command-configs.js +0 -10
  50. package/dist/api/command/command-description.d.ts +0 -8
  51. package/dist/api/command/command-description.js +0 -2
  52. package/dist/api/command/command-executor.d.ts +0 -30
  53. package/dist/api/command/command-executor.js +0 -6
  54. package/dist/api/command/command-help.d.ts +0 -8
  55. package/dist/api/command/command-help.js +0 -2
  56. package/dist/api/command/command-logging.d.ts +0 -11
  57. package/dist/api/command/command-logging.js +0 -17
  58. package/dist/api/command/command-mapping.d.ts +0 -7
  59. package/dist/api/command/command-mapping.js +0 -9
  60. package/dist/api/command/command-messages.d.ts +0 -1
  61. package/dist/api/command/command-messages.js +0 -9
  62. package/dist/api/command/command-to-help-message.d.ts +0 -9
  63. package/dist/api/command/command-to-help-message.js +0 -175
  64. package/dist/api/command/define-command-inputs.d.ts +0 -22
  65. package/dist/api/command/define-command-inputs.js +0 -8
  66. package/dist/api/command/define-command.d.ts +0 -22
  67. package/dist/api/command/define-command.js +0 -41
  68. package/dist/api/config/config-file-definition.d.ts +0 -15
  69. package/dist/api/config/config-file-definition.js +0 -2
  70. package/dist/api/config/config-paths.d.ts +0 -7
  71. package/dist/api/config/config-paths.js +0 -7
  72. package/dist/api/config/copy-config.d.ts +0 -27
  73. package/dist/api/config/copy-config.js +0 -98
  74. package/dist/api/create-virmator.d.ts +0 -8
  75. package/dist/api/create-virmator.js +0 -67
  76. package/dist/api/run-command/check-npm-deps.d.ts +0 -8
  77. package/dist/api/run-command/check-npm-deps.js +0 -111
  78. package/dist/api/run-command/extract-arguments.d.ts +0 -6
  79. package/dist/api/run-command/extract-arguments.js +0 -36
  80. package/dist/api/run-command/run-command-executor.d.ts +0 -5
  81. package/dist/api/run-command/run-command-executor.js +0 -50
  82. package/dist/api/run-command/run-extended-virmator.d.ts +0 -10
  83. package/dist/api/run-command/run-extended-virmator.js +0 -53
  84. package/dist/api/run-command/run-shell-command.d.ts +0 -8
  85. package/dist/api/run-command/run-shell-command.js +0 -21
  86. package/dist/api/virmator-types.d.ts +0 -18
  87. package/dist/api/virmator-types.js +0 -2
  88. package/dist/augments/array.d.ts +0 -1
  89. package/dist/augments/array.js +0 -6
  90. package/dist/augments/console.d.ts +0 -9
  91. package/dist/augments/console.js +0 -43
  92. package/dist/augments/fs.d.ts +0 -11
  93. package/dist/augments/fs.js +0 -71
  94. package/dist/augments/git.d.ts +0 -1
  95. package/dist/augments/git.js +0 -12
  96. package/dist/augments/json.d.ts +0 -1
  97. package/dist/augments/json.js +0 -11
  98. package/dist/augments/npm.d.ts +0 -11
  99. package/dist/augments/npm.js +0 -52
  100. package/dist/augments/object.d.ts +0 -4
  101. package/dist/augments/object.js +0 -44
  102. package/dist/augments/path.d.ts +0 -1
  103. package/dist/augments/path.js +0 -12
  104. package/dist/augments/prettier.d.ts +0 -1
  105. package/dist/augments/prettier.js +0 -52
  106. package/dist/augments/regexp.d.ts +0 -1
  107. package/dist/augments/regexp.js +0 -6
  108. package/dist/augments/string.d.ts +0 -2
  109. package/dist/augments/string.js +0 -9
  110. package/dist/augments/type.d.ts +0 -1
  111. package/dist/augments/type.js +0 -2
  112. package/dist/augments/typescript-config-file.d.ts +0 -5
  113. package/dist/augments/typescript-config-file.js +0 -62
  114. package/dist/commands/compile.command.d.ts +0 -84
  115. package/dist/commands/compile.command.js +0 -58
  116. package/dist/commands/deps.command.d.ts +0 -144
  117. package/dist/commands/deps.command.js +0 -208
  118. package/dist/commands/docs.command.d.ts +0 -99
  119. package/dist/commands/docs.command.js +0 -192
  120. package/dist/commands/extra-configs/all-extra-configs.d.ts +0 -2
  121. package/dist/commands/extra-configs/all-extra-configs.js +0 -71
  122. package/dist/commands/extra-configs/combine-json-config.d.ts +0 -2
  123. package/dist/commands/extra-configs/combine-json-config.js +0 -21
  124. package/dist/commands/extra-configs/combine-text-config.d.ts +0 -2
  125. package/dist/commands/extra-configs/combine-text-config.js +0 -26
  126. package/dist/commands/extra-configs/create-default-package-json.d.ts +0 -1
  127. package/dist/commands/extra-configs/create-default-package-json.js +0 -86
  128. package/dist/commands/format.command.d.ts +0 -215
  129. package/dist/commands/format.command.js +0 -157
  130. package/dist/commands/frontend.command.d.ts +0 -149
  131. package/dist/commands/frontend.command.js +0 -140
  132. package/dist/commands/init.command.d.ts +0 -163
  133. package/dist/commands/init.command.js +0 -53
  134. package/dist/commands/publish.command.d.ts +0 -33
  135. package/dist/commands/publish.command.js +0 -193
  136. package/dist/commands/spellcheck.command.d.ts +0 -74
  137. package/dist/commands/spellcheck.command.js +0 -60
  138. package/dist/commands/test-web.command.d.ts +0 -189
  139. package/dist/commands/test-web.command.js +0 -125
  140. package/dist/commands/test.command.d.ts +0 -224
  141. package/dist/commands/test.command.js +0 -100
  142. package/dist/commands/update-configs.command.d.ts +0 -33
  143. package/dist/commands/update-configs.command.js +0 -35
  144. package/dist/compiled-base-configs/base-dep-cruiser.config.d.ts +0 -195
  145. package/dist/compiled-base-configs/base-dep-cruiser.config.js +0 -206
  146. package/dist/compiled-base-configs/base-ncu.d.ts +0 -6
  147. package/dist/compiled-base-configs/base-ncu.js +0 -16
  148. package/dist/compiled-base-configs/base-typedoc.d.ts +0 -3
  149. package/dist/compiled-base-configs/base-typedoc.js +0 -36
  150. package/dist/compiled-base-configs/base-vite.d.ts +0 -27
  151. package/dist/compiled-base-configs/base-vite.js +0 -74
  152. package/dist/compiled-base-configs/vite-always-reload-plugin.d.ts +0 -10
  153. package/dist/compiled-base-configs/vite-always-reload-plugin.js +0 -99
  154. package/dist/file-paths/package-paths.d.ts +0 -12
  155. package/dist/file-paths/package-paths.js +0 -46
  156. package/dist/scripts/save-help-message.d.ts +0 -1
  157. package/dist/scripts/save-help-message.js +0 -33
  158. package/mocha.config.cjs +0 -16
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.systemRootPath = void 0;
4
- exports.removeDirectory = removeDirectory;
5
- exports.readAllDirContents = readAllDirContents;
6
- exports.writeFiles = writeFiles;
7
- exports.recursivelyUpwardsSearchForDir = recursivelyUpwardsSearchForDir;
8
- const common_1 = require("@augment-vir/common");
9
- const fs_1 = require("fs");
10
- const fs_extra_1 = require("fs-extra");
11
- const promises_1 = require("fs/promises");
12
- const path_1 = require("path");
13
- async function removeDirectory(dirPath) {
14
- await (0, promises_1.rm)(dirPath, {
15
- force: true,
16
- recursive: true,
17
- maxRetries: 3,
18
- retryDelay: 100,
19
- });
20
- if ((0, fs_1.existsSync)(dirPath)) {
21
- // try... again? Cause Windows sucks.
22
- await (0, fs_extra_1.remove)(dirPath);
23
- }
24
- }
25
- exports.systemRootPath = (0, path_1.parse)(process.cwd()).root;
26
- async function readAllDirContents({ dir, recursive = false, }) {
27
- const fileNames = await (0, promises_1.readdir)(dir);
28
- const allFileContents = await Promise.all(fileNames.map(async (fileName) => {
29
- const filePath = (0, path_1.join)(dir, fileName);
30
- const isFile = (await (0, promises_1.stat)(filePath)).isFile();
31
- return isFile
32
- ? (await (0, promises_1.readFile)(filePath)).toString()
33
- : recursive
34
- ? await readAllDirContents({ dir: filePath, recursive })
35
- : '';
36
- }));
37
- const mappedFileContents = fileNames.reduce((accum, fileName, index) => {
38
- const fileContents = allFileContents[index] ?? '';
39
- accum[fileName] = fileContents;
40
- return accum;
41
- }, {});
42
- return mappedFileContents;
43
- }
44
- async function writeFiles(dir, allFileContents) {
45
- await (0, common_1.awaitedForEach)(Object.keys(allFileContents), async (fileOrDirName) => {
46
- const value = allFileContents[fileOrDirName];
47
- const currentPath = (0, path_1.join)(dir, fileOrDirName);
48
- if (typeof value === 'string') {
49
- await (0, promises_1.writeFile)(currentPath, value);
50
- }
51
- else if (!value) {
52
- throw new Error(`Failed to find file file under "${fileOrDirName}"`);
53
- }
54
- else {
55
- await writeFiles(currentPath, value);
56
- }
57
- });
58
- }
59
- async function recursivelyUpwardsSearchForDir(startDirPath, check) {
60
- if (!(0, fs_1.existsSync)(startDirPath) || !startDirPath) {
61
- throw new Error(`Could not search in "${startDirPath}": it does not exist.`);
62
- }
63
- if (check(startDirPath)) {
64
- return startDirPath;
65
- }
66
- const parent = (0, path_1.dirname)(startDirPath);
67
- if (parent === startDirPath) {
68
- throw new Error(`Cannot recurse any higher, already at "${parent}"`);
69
- }
70
- return recursivelyUpwardsSearchForDir(parent, check);
71
- }
@@ -1 +0,0 @@
1
- export declare function doChangesExist(repoDirPath: string): Promise<boolean>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.doChangesExist = doChangesExist;
4
- const node_js_1 = require("@augment-vir/node-js");
5
- async function doChangesExist(repoDirPath) {
6
- const getChangesCommand = `git status --porcelain=v1 2>/dev/null`;
7
- const getChangesOutput = await (0, node_js_1.runShellCommand)(getChangesCommand, {
8
- cwd: repoDirPath,
9
- rejectOnError: true,
10
- });
11
- return !!getChangesOutput.stdout;
12
- }
@@ -1 +0,0 @@
1
- export declare function jsonParseOrUndefined(input: string): any | undefined;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonParseOrUndefined = jsonParseOrUndefined;
4
- function jsonParseOrUndefined(input) {
5
- try {
6
- return JSON.parse(input);
7
- }
8
- catch (error) {
9
- return undefined;
10
- }
11
- }
@@ -1,11 +0,0 @@
1
- import { RequiredAndNotNullBy } from '@augment-vir/common';
2
- import type { PackageJson } from 'type-fest';
3
- export type CleanPackageJson = Readonly<RequiredAndNotNullBy<PackageJson.PackageJsonStandard, 'name' | 'version'> & {
4
- workspaces?: ReadonlyArray<string>;
5
- }>;
6
- export declare function findTopLevelPackageJsonFile(startDir: string): string | undefined;
7
- export declare function readPackageJson(packageJsonPath: string): Promise<CleanPackageJson>;
8
- export declare function readTopLevelPackageJson(startDir: string): Promise<Readonly<{
9
- packageJson: CleanPackageJson;
10
- path: string;
11
- }>>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findTopLevelPackageJsonFile = findTopLevelPackageJsonFile;
4
- exports.readPackageJson = readPackageJson;
5
- exports.readTopLevelPackageJson = readTopLevelPackageJson;
6
- const common_1 = require("@augment-vir/common");
7
- const fs_1 = require("fs");
8
- const promises_1 = require("fs/promises");
9
- const path_1 = require("path");
10
- const fs_2 = require("./fs");
11
- function findTopLevelPackageJsonFile(startDir) {
12
- if (startDir === fs_2.systemRootPath) {
13
- return undefined;
14
- }
15
- const topLevelPath = findTopLevelPackageJsonFile((0, path_1.dirname)(startDir));
16
- const currentLevelPath = (0, path_1.join)(startDir, 'package.json');
17
- if (topLevelPath) {
18
- return topLevelPath;
19
- }
20
- else if ((0, fs_1.existsSync)(currentLevelPath)) {
21
- return currentLevelPath;
22
- }
23
- else {
24
- return undefined;
25
- }
26
- }
27
- async function readPackageJson(packageJsonPath) {
28
- let parsed;
29
- try {
30
- parsed = JSON.parse((await (0, promises_1.readFile)(packageJsonPath)).toString());
31
- }
32
- catch (error) {
33
- throw new Error(`Failed to read package json file "${packageJsonPath}": ${(0, common_1.extractErrorMessage)(error)}`);
34
- }
35
- if (!parsed.name) {
36
- throw new Error(`Missing package name from "${packageJsonPath}"`);
37
- }
38
- if (!parsed.version) {
39
- throw new Error(`Missing package version from "${packageJsonPath}"`);
40
- }
41
- return parsed;
42
- }
43
- async function readTopLevelPackageJson(startDir) {
44
- const topLevelPackageJsonPath = findTopLevelPackageJsonFile(startDir);
45
- if (!topLevelPackageJsonPath) {
46
- throw new Error(`Failed to find package.json path in any ancestor directories from "${startDir}"`);
47
- }
48
- return {
49
- packageJson: await readPackageJson(topLevelPackageJsonPath),
50
- path: topLevelPackageJsonPath,
51
- };
52
- }
@@ -1,4 +0,0 @@
1
- import { Overwrite } from '@augment-vir/common';
2
- export declare function filterObject<T extends object>(fullObject: Readonly<T>, callback: (value: T[keyof T], key: keyof T, fullObject: Readonly<T>) => boolean): Partial<T>;
3
- export declare function deeplyCombineObjects<OriginalObjectGeneric extends object, OverwriteObjectGeneric extends object>(originalObject: OriginalObjectGeneric, overwriteObject: OverwriteObjectGeneric): Overwrite<OriginalObjectGeneric, OverwriteObjectGeneric>;
4
- export declare function filterToDifferentValues<T extends object>(baseObject: T, changedObject: T): Partial<T>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterObject = filterObject;
4
- exports.deeplyCombineObjects = deeplyCombineObjects;
5
- exports.filterToDifferentValues = filterToDifferentValues;
6
- const common_1 = require("@augment-vir/common");
7
- function filterObject(fullObject, callback) {
8
- return (0, common_1.getObjectTypedKeys)(fullObject).reduce((accum, key) => {
9
- const value = fullObject[key];
10
- if (callback(value, key, fullObject)) {
11
- accum[key] = value;
12
- }
13
- return accum;
14
- }, {});
15
- }
16
- function deeplyCombineObjects(originalObject, overwriteObject) {
17
- return (0, common_1.getObjectTypedKeys)(overwriteObject).reduce((accum, currentKey) => {
18
- const currentNewValue = overwriteObject[currentKey];
19
- const currentOldValue = (0, common_1.typedHasProperty)(originalObject, currentKey) && originalObject[currentKey];
20
- if ((0, common_1.isObject)(currentOldValue) && (0, common_1.isObject)(currentNewValue)) {
21
- accum[currentKey] = deeplyCombineObjects(currentOldValue, currentNewValue);
22
- }
23
- else {
24
- accum[currentKey] = currentNewValue;
25
- }
26
- return accum;
27
- }, originalObject);
28
- }
29
- function filterToDifferentValues(baseObject, changedObject) {
30
- return (0, common_1.getObjectTypedKeys)(baseObject).reduce((accum, key) => {
31
- const beforeValue = baseObject[key];
32
- const afterValue = changedObject[key];
33
- if ((0, common_1.isObject)(beforeValue) && (0, common_1.isObject)(afterValue)) {
34
- const innerDiff = filterToDifferentValues(beforeValue, afterValue);
35
- if (Object.keys(innerDiff).length) {
36
- accum[key] = filterToDifferentValues(beforeValue, afterValue);
37
- }
38
- }
39
- else if (beforeValue !== afterValue) {
40
- accum[key] = afterValue;
41
- }
42
- return accum;
43
- }, {});
44
- }
@@ -1 +0,0 @@
1
- export declare function getFirstPartOfPath(inputPath: string): string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFirstPartOfPath = getFirstPartOfPath;
4
- const path_1 = require("path");
5
- function getFirstPartOfPath(inputPath) {
6
- const split = inputPath.split(path_1.sep);
7
- const firstPart = split[0];
8
- if (!firstPart) {
9
- throw new Error(`First path of path was empty from "${inputPath}"`);
10
- }
11
- return firstPart;
12
- }
@@ -1 +0,0 @@
1
- export declare function formatCode(text: string, filePath: string): Promise<string>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.formatCode = formatCode;
27
- const fs_1 = require("fs");
28
- const path_1 = require("path");
29
- async function formatCode(text, filePath) {
30
- try {
31
- // if prettier isn't installed yet this will fail
32
- const { format: prettierFormat } = await Promise.resolve().then(() => __importStar(require('prettier')));
33
- const repoPrettierRc = (await Promise.resolve(`${findNearestConfig(process.cwd())}`).then(s => __importStar(require(s)))).default;
34
- const repoConfig = repoPrettierRc;
35
- return prettierFormat(text, {
36
- ...repoConfig,
37
- filepath: filePath,
38
- });
39
- }
40
- catch (error) {
41
- return text;
42
- }
43
- }
44
- function findNearestConfig(dir) {
45
- const currentDirConfig = (0, path_1.join)(dir, '.prettierrc.js');
46
- if ((0, fs_1.existsSync)(currentDirConfig)) {
47
- return currentDirConfig;
48
- }
49
- else {
50
- return findNearestConfig((0, path_1.dirname)(dir));
51
- }
52
- }
@@ -1 +0,0 @@
1
- export declare function sanitizeStringForRegExpCreation(inputString: string): string;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeStringForRegExpCreation = sanitizeStringForRegExpCreation;
4
- function sanitizeStringForRegExpCreation(inputString) {
5
- return inputString.replace(/\//g, '\\/').replace(/(\(|\)|\[|\]|\.|\}|\{|\||\+)/g, '\\$1');
6
- }
@@ -1,2 +0,0 @@
1
- export type NonEmptyString<ExactStringGeneric extends string> = ExactStringGeneric extends '' ? never : ExactStringGeneric;
2
- export declare function ensureNonEmptyString<StringGeneric extends string>(inputString: NonEmptyString<StringGeneric>): StringGeneric;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureNonEmptyString = ensureNonEmptyString;
4
- function ensureNonEmptyString(inputString) {
5
- if (!inputString) {
6
- throw new Error(`Expected a non-empty string.`);
7
- }
8
- return inputString;
9
- }
@@ -1 +0,0 @@
1
- export type Constructor<T> = new (...args: any[]) => T;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export declare function withTypescriptConfigFile<T>(configPath: string, callback: (config: any) => Promise<T>): Promise<T>;
2
- export declare function compileTs({ inputPath, outputPath, }: {
3
- inputPath: string;
4
- outputPath?: string | undefined;
5
- }): Promise<string>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.withTypescriptConfigFile = withTypescriptConfigFile;
27
- exports.compileTs = compileTs;
28
- const promises_1 = require("fs/promises");
29
- const path_1 = require("path");
30
- async function withTypescriptConfigFile(configPath, callback) {
31
- const tempFilePath = createOutfilePath(configPath);
32
- try {
33
- await compileTs({ inputPath: configPath, outputPath: tempFilePath });
34
- const loadedConfig = require(tempFilePath);
35
- return callback(loadedConfig);
36
- }
37
- finally {
38
- try {
39
- await (0, promises_1.unlink)(tempFilePath);
40
- }
41
- catch (error) { }
42
- }
43
- }
44
- function createOutfilePath(inputFilePath) {
45
- return (0, path_1.join)((0, path_1.dirname)(inputFilePath), [
46
- 'generated-config',
47
- (0, path_1.basename)(inputFilePath).replace(/\.ts$/, '.cjs'),
48
- ].join('-'));
49
- }
50
- async function compileTs({ inputPath, outputPath, }) {
51
- const outfile = outputPath || createOutfilePath(inputPath);
52
- await (await Promise.resolve().then(() => __importStar(require('esbuild')))).build({
53
- entryPoints: [inputPath],
54
- outfile,
55
- write: true,
56
- target: ['node20'],
57
- platform: 'node',
58
- bundle: false,
59
- format: 'cjs',
60
- });
61
- return outfile;
62
- }
@@ -1,84 +0,0 @@
1
- import { NpmDepTypeEnum } from '../api/command/define-command-inputs';
2
- export declare const compileCommandDefinition: {
3
- commandName: "compile";
4
- subCommandDescriptions: {
5
- readonly check: "Run type checking without emitting compiled files.";
6
- };
7
- configFiles: {
8
- readonly tsConfig: {
9
- readonly copyFromInternalPath: string;
10
- readonly copyToPathRelativeToRepoDir: "tsconfig.json";
11
- };
12
- };
13
- npmDeps: readonly [{
14
- readonly name: "typescript";
15
- readonly type: NpmDepTypeEnum.Dev;
16
- }];
17
- } & {
18
- allAvailableSubCommands: readonly "check"[];
19
- subCommands: import("../api/command/define-command-inputs").SubCommandsMap<{
20
- commandName: "compile";
21
- subCommandDescriptions: {
22
- readonly check: "Run type checking without emitting compiled files.";
23
- };
24
- configFiles: {
25
- readonly tsConfig: {
26
- readonly copyFromInternalPath: string;
27
- readonly copyToPathRelativeToRepoDir: "tsconfig.json";
28
- };
29
- };
30
- npmDeps: readonly [{
31
- readonly name: "typescript";
32
- readonly type: NpmDepTypeEnum.Dev;
33
- }];
34
- }>;
35
- } & {
36
- executor: import("..").CommandExecutor<{
37
- commandName: "compile";
38
- subCommandDescriptions: {
39
- readonly check: "Run type checking without emitting compiled files.";
40
- };
41
- configFiles: {
42
- readonly tsConfig: {
43
- readonly copyFromInternalPath: string;
44
- readonly copyToPathRelativeToRepoDir: "tsconfig.json";
45
- };
46
- };
47
- npmDeps: readonly [{
48
- readonly name: "typescript";
49
- readonly type: NpmDepTypeEnum.Dev;
50
- }];
51
- }>;
52
- createDescription: import("..").CreateDescriptionsCallback<{
53
- commandName: "compile";
54
- subCommandDescriptions: {
55
- readonly check: "Run type checking without emitting compiled files.";
56
- };
57
- configFiles: {
58
- readonly tsConfig: {
59
- readonly copyFromInternalPath: string;
60
- readonly copyToPathRelativeToRepoDir: "tsconfig.json";
61
- };
62
- };
63
- npmDeps: readonly [{
64
- readonly name: "typescript";
65
- readonly type: NpmDepTypeEnum.Dev;
66
- }];
67
- }>;
68
- extend: import("../api/command/define-command").ExtendCallback<{
69
- commandName: "compile";
70
- subCommandDescriptions: {
71
- readonly check: "Run type checking without emitting compiled files.";
72
- };
73
- configFiles: {
74
- readonly tsConfig: {
75
- readonly copyFromInternalPath: string;
76
- readonly copyToPathRelativeToRepoDir: "tsconfig.json";
77
- };
78
- };
79
- npmDeps: readonly [{
80
- readonly name: "typescript";
81
- readonly type: NpmDepTypeEnum.Dev;
82
- }];
83
- }>;
84
- };
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileCommandDefinition = 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
- exports.compileCommandDefinition = (0, define_command_1.defineCommand)({
9
- commandName: 'compile',
10
- subCommandDescriptions: {
11
- check: 'Run type checking without emitting compiled files.',
12
- },
13
- configFiles: {
14
- tsConfig: {
15
- copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'tsconfig.json'),
16
- copyToPathRelativeToRepoDir: 'tsconfig.json',
17
- },
18
- },
19
- npmDeps: [
20
- { name: 'typescript', type: define_command_inputs_1.NpmDepTypeEnum.Dev },
21
- ],
22
- }, ({ commandName, packageBinName }) => {
23
- return {
24
- sections: [
25
- {
26
- title: '',
27
- content: `compile typescript files
28
- Pass any extra tsc flags to this command.`,
29
- },
30
- ],
31
- examples: [
32
- {
33
- title: `no extra flags`,
34
- content: `${packageBinName} ${commandName}`,
35
- },
36
- {
37
- title: `one extra flag`,
38
- content: `${packageBinName} ${commandName} --noEmit`,
39
- },
40
- ],
41
- };
42
- }, async (inputs) => {
43
- const shouldNotEmit = inputs.filteredInputArgs.join(' ').includes('--noEmit') ||
44
- inputs.inputSubCommands.includes(inputs.subCommands.check);
45
- const noEmit = shouldNotEmit ? '--noEmit' : '';
46
- const mainCommand = await (0, package_paths_1.getNpmBinPath)({
47
- repoDir: inputs.repoDir,
48
- command: 'tsc',
49
- packageDirPath: inputs.packageDir,
50
- });
51
- return {
52
- args: [
53
- `rm -rf dist && ${mainCommand}`,
54
- noEmit,
55
- ...inputs.filteredInputArgs.map((arg) => `"${arg}"`),
56
- ],
57
- };
58
- });