@virmator/core 13.3.11 → 13.3.13
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/dist/api/copy-configs.d.ts +3 -4
- package/dist/api/execute-command.d.ts +3 -4
- package/dist/api/execute-command.js +10 -11
- package/dist/api/install-deps.d.ts +3 -3
- package/dist/api/install-deps.js +4 -3
- package/dist/api/parse-args.d.ts +2 -2
- package/dist/api/parse-args.js +8 -8
- package/dist/api/typescript-config-file.js +1 -1
- package/dist/augments/fs/search.d.ts +0 -5
- package/dist/augments/fs/search.js +10 -21
- package/dist/augments/object/access.d.ts +1 -1
- package/dist/augments/object/access.js +2 -2
- package/dist/augments/stream/callback-writable.d.ts +2 -2
- package/dist/augments/tsconfig/parse-tsconfig.js +1 -1
- package/dist/plugin/index.d.ts +0 -1
- package/dist/plugin/index.js +0 -1
- package/dist/plugin/plugin-configs.d.ts +3 -2
- package/dist/plugin/plugin-env.d.ts +0 -7
- package/dist/plugin/plugin-env.js +0 -8
- package/dist/plugin/plugin-executor.d.ts +4 -5
- package/dist/plugin/plugin-init.d.ts +3 -2
- package/dist/plugin/plugin.js +4 -2
- package/package.json +7 -7
- package/dist/plugin/plugin-logger.d.ts +0 -15
- package/dist/plugin/plugin-logger.js +0 -97
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { MaybePromise } from '@augment-vir/common';
|
|
1
|
+
import { MaybePromise, type Logger } from '@augment-vir/common';
|
|
2
2
|
import { VirmatorPluginResolvedConfigFile } from '../plugin/plugin-configs.js';
|
|
3
3
|
import { PackageType } from '../plugin/plugin-env.js';
|
|
4
4
|
import { MonoRepoPackage, UsedVirmatorPluginCommands, VirmatorPluginResolvedConfigs } from '../plugin/plugin-executor.js';
|
|
5
|
-
import { PluginLogger } from '../plugin/plugin-logger.js';
|
|
6
5
|
/**
|
|
7
6
|
* Extracts a 1d array of virmator plugin config files from previously calculated used commands and
|
|
8
7
|
* resolved configs.
|
|
9
8
|
*/
|
|
10
9
|
export declare function flattenConfigs(usedCommands: Readonly<UsedVirmatorPluginCommands<any>>, resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>): VirmatorPluginResolvedConfigFile[];
|
|
11
10
|
/** Copies a plugin's entire set of configs based on the used command. */
|
|
12
|
-
export declare function copyPluginConfigs(usedCommands: Readonly<UsedVirmatorPluginCommands>, resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>, packageType: PackageType, monoRepoPackages: MonoRepoPackage[], log:
|
|
11
|
+
export declare function copyPluginConfigs(usedCommands: Readonly<UsedVirmatorPluginCommands>, resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>, packageType: PackageType, monoRepoPackages: MonoRepoPackage[], log: Logger, filteredArgs: string[]): Promise<void>;
|
|
13
12
|
/** Copies a single virmator plugin config file. */
|
|
14
|
-
export declare function copyConfigFile(config: Readonly<Pick<VirmatorPluginResolvedConfigFile, 'fullCopyFromPath' | 'fullCopyToPath'>>, log:
|
|
13
|
+
export declare function copyConfigFile(config: Readonly<Pick<VirmatorPluginResolvedConfigFile, 'fullCopyFromPath' | 'fullCopyToPath'>>, log: Logger,
|
|
15
14
|
/**
|
|
16
15
|
* If `true`, the config will be copied even if the copy destination already exists.
|
|
17
16
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PluginLogger } from '../plugin/plugin-logger.js';
|
|
1
|
+
import { PartialWithUndefined, type Logger } from '@augment-vir/common';
|
|
3
2
|
import { VirmatorPlugin } from '../plugin/plugin.js';
|
|
4
3
|
/** Params for executing a plugin command. */
|
|
5
4
|
export type ExecuteCommandParams = {
|
|
@@ -32,7 +31,7 @@ export type ExecuteCommandParams = {
|
|
|
32
31
|
* ];
|
|
33
32
|
*/
|
|
34
33
|
cliCommand: string | ReadonlyArray<string>;
|
|
35
|
-
} &
|
|
34
|
+
} & PartialWithUndefined<{
|
|
36
35
|
/**
|
|
37
36
|
* The current working directory. In most cases, this can be left unset.
|
|
38
37
|
*
|
|
@@ -47,7 +46,7 @@ export type ExecuteCommandParams = {
|
|
|
47
46
|
*/
|
|
48
47
|
entryPointFilePath: string;
|
|
49
48
|
/** Set the logger for use with this execution. */
|
|
50
|
-
log:
|
|
49
|
+
log: Logger;
|
|
51
50
|
/**
|
|
52
51
|
* The maximum number of concurrent processes that can run at the same time when running a
|
|
53
52
|
* command per mono-repo sub package.
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { log, logColors, LogOutputType,
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { awaitedBlockingMap, extractErrorMessage, filterMap, log, logColors, log as logImport, LogOutputType, mapObjectValues, wrapInTry, } from '@augment-vir/common';
|
|
3
|
+
import { readPackageJson, runShellCommand } from '@augment-vir/node';
|
|
3
4
|
import chalk from 'chalk';
|
|
4
5
|
import concurrently from 'concurrently';
|
|
5
6
|
import { getRelativePosixPackagePathsInDependencyOrder } from 'mono-vir';
|
|
6
7
|
import { cpus } from 'node:os';
|
|
7
8
|
import { join, resolve } from 'node:path';
|
|
8
|
-
import { isRunTimeType } from 'run-time-assertions';
|
|
9
9
|
import { findClosestPackageDir } from '../augments/index.js';
|
|
10
10
|
import { CallbackWritable } from '../augments/stream/callback-writable.js';
|
|
11
11
|
import { getTerminalColor } from '../colors.js';
|
|
12
12
|
import { hideNoTraceTraces, VirmatorNoTraceError } from '../errors/virmator-no-trace.error.js';
|
|
13
13
|
import { PackageType } from '../plugin/plugin-env.js';
|
|
14
|
-
import { createPluginLogger } from '../plugin/plugin-logger.js';
|
|
15
14
|
import { copyPluginConfigs } from './copy-configs.js';
|
|
16
15
|
import { installNpmDeps, installPluginNpmDeps } from './install-deps.js';
|
|
17
16
|
import { parseCliArgs } from './parse-args.js';
|
|
@@ -32,7 +31,7 @@ function resolveConfigs({ cwdPackagePath, pluginPackagePath }, cliCommands) {
|
|
|
32
31
|
async function determinePackageType(cwdPackagePath, monoRepoRootPath, cwdPackageJson) {
|
|
33
32
|
try {
|
|
34
33
|
if (cwdPackageJson.workspaces &&
|
|
35
|
-
(
|
|
34
|
+
(check.isArray(cwdPackageJson.workspaces)
|
|
36
35
|
? cwdPackageJson.workspaces.length
|
|
37
36
|
: cwdPackageJson.workspaces.packages?.length)) {
|
|
38
37
|
return PackageType.MonoRoot;
|
|
@@ -98,7 +97,7 @@ function writeLog(arg, log, logType, extraOptions) {
|
|
|
98
97
|
extraOptions?.logPrefix || '',
|
|
99
98
|
transformed.replace(/\n$/, ''),
|
|
100
99
|
].join('');
|
|
101
|
-
if (logType === LogOutputType.
|
|
100
|
+
if (logType === LogOutputType.Error) {
|
|
102
101
|
log.error(finalLog);
|
|
103
102
|
}
|
|
104
103
|
else {
|
|
@@ -107,7 +106,7 @@ function writeLog(arg, log, logType, extraOptions) {
|
|
|
107
106
|
}
|
|
108
107
|
/** The entry point to virmator. Runs a virmator plugin command. */
|
|
109
108
|
export async function executeVirmatorCommand({ log: logParam, entryPointFilePath = '', cwd = process.cwd(), ...params }) {
|
|
110
|
-
const log = logParam ||
|
|
109
|
+
const log = logParam || logImport;
|
|
111
110
|
const args = parseCliArgs({
|
|
112
111
|
...params,
|
|
113
112
|
log,
|
|
@@ -125,7 +124,7 @@ export async function executeVirmatorCommand({ log: logParam, entryPointFilePath
|
|
|
125
124
|
const packageType = await determinePackageType(cwdPackagePath, monoRepoRootPath, cwdPackageJson);
|
|
126
125
|
const monoRepoPackages = packageType === PackageType.MonoRoot ? await getMonoRepoPackages(cwdPackagePath) : [];
|
|
127
126
|
const outerMaxProcesses = params.concurrency || cpus().length - 1 || 1;
|
|
128
|
-
const filteredArgs = args.filteredCommandArgs.filter(isTruthy);
|
|
127
|
+
const filteredArgs = args.filteredCommandArgs.filter(check.isTruthy);
|
|
129
128
|
const executorParams = {
|
|
130
129
|
cliInputs: {
|
|
131
130
|
filteredArgs,
|
|
@@ -155,10 +154,10 @@ export async function executeVirmatorCommand({ log: logParam, entryPointFilePath
|
|
|
155
154
|
cwd,
|
|
156
155
|
shell: 'bash',
|
|
157
156
|
stderrCallback(stderr) {
|
|
158
|
-
writeLog(stderr, log, LogOutputType.
|
|
157
|
+
writeLog(stderr, log, LogOutputType.Error, extraOptions);
|
|
159
158
|
},
|
|
160
159
|
stdoutCallback(stdout) {
|
|
161
|
-
writeLog(stdout, log, LogOutputType.
|
|
160
|
+
writeLog(stdout, log, LogOutputType.Standard, extraOptions);
|
|
162
161
|
},
|
|
163
162
|
...options,
|
|
164
163
|
});
|
|
@@ -205,7 +204,7 @@ export async function executeVirmatorCommand({ log: logParam, entryPointFilePath
|
|
|
205
204
|
name: monoRepoPackage.packageName,
|
|
206
205
|
prefixColor: colorString,
|
|
207
206
|
};
|
|
208
|
-
})).filter(isTruthy);
|
|
207
|
+
})).filter(check.isTruthy);
|
|
209
208
|
const writeStream = new CallbackWritable(log);
|
|
210
209
|
/** Force concurrently to use color even though it's being run as a subscript. */
|
|
211
210
|
process.env.FORCE_COLOR = '2';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type Logger } from '@augment-vir/common';
|
|
1
2
|
import { PackageJson } from 'type-fest';
|
|
2
3
|
import { PackageType } from '../plugin/plugin-env.js';
|
|
3
4
|
import { UsedVirmatorPluginCommands } from '../plugin/plugin-executor.js';
|
|
4
5
|
import { PluginNpmDeps } from '../plugin/plugin-init.js';
|
|
5
|
-
import { PluginLogger } from '../plugin/plugin-logger.js';
|
|
6
6
|
/** Install's a virmator plugin's listed npm deps depending on which command is being run. */
|
|
7
7
|
export declare function installPluginNpmDeps({ usedCommands, ...params }: {
|
|
8
8
|
cwdPackagePath: string;
|
|
@@ -10,7 +10,7 @@ export declare function installPluginNpmDeps({ usedCommands, ...params }: {
|
|
|
10
10
|
pluginPackagePath: string;
|
|
11
11
|
pluginName: string;
|
|
12
12
|
packageType: PackageType;
|
|
13
|
-
log:
|
|
13
|
+
log: Logger;
|
|
14
14
|
usedCommands: Readonly<UsedVirmatorPluginCommands>;
|
|
15
15
|
}): Promise<void>;
|
|
16
16
|
/** Installs a set of virmator plugin npm deps. */
|
|
@@ -20,6 +20,6 @@ export declare function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginP
|
|
|
20
20
|
pluginPackagePath: string;
|
|
21
21
|
pluginName: string;
|
|
22
22
|
packageType: PackageType;
|
|
23
|
-
log:
|
|
23
|
+
log: Logger;
|
|
24
24
|
deps: Partial<PluginNpmDeps>;
|
|
25
25
|
}): Promise<void>;
|
package/dist/api/install-deps.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { awaitedBlockingMap, getObjectTypedEntries } from '@augment-vir/common';
|
|
3
|
+
import { readPackageJson, runShellCommand } from '@augment-vir/node';
|
|
3
4
|
import * as semver from 'semver';
|
|
4
5
|
import { VirmatorNoTraceError } from '../errors/virmator-no-trace.error.js';
|
|
5
6
|
import { NpmDepType } from '../plugin/plugin-init.js';
|
|
@@ -47,7 +48,7 @@ export async function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginPac
|
|
|
47
48
|
depType === NpmDepType.Dev ? '-D' : '',
|
|
48
49
|
installDeps,
|
|
49
50
|
]
|
|
50
|
-
.filter(isTruthy)
|
|
51
|
+
.filter(check.isTruthy)
|
|
51
52
|
.join(' ');
|
|
52
53
|
log.faint(`Installing ${installDeps}...`);
|
|
53
54
|
await runShellCommand(installCommand, {
|
package/dist/api/parse-args.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type Logger } from '@augment-vir/common';
|
|
1
2
|
import { UsedVirmatorPluginCommands } from '../plugin/plugin-executor.js';
|
|
2
3
|
import { VirmatorPluginCliCommands } from '../plugin/plugin-init.js';
|
|
3
|
-
import { PluginLogger } from '../plugin/plugin-logger.js';
|
|
4
4
|
import { VirmatorPlugin } from '../plugin/plugin.js';
|
|
5
5
|
import { SetVirmatorFlags } from './virmator-flags.js';
|
|
6
6
|
/** All supported sets of args for virmator. */
|
|
@@ -31,5 +31,5 @@ export declare function parseCliArgs({ cliCommand, entryPointFilePath, plugins,
|
|
|
31
31
|
plugins: ReadonlyArray<Readonly<VirmatorPlugin>>;
|
|
32
32
|
cliCommand: string | ReadonlyArray<string>;
|
|
33
33
|
entryPointFilePath: string;
|
|
34
|
-
log:
|
|
34
|
+
log: Logger;
|
|
35
35
|
}): ParsedArgs;
|
package/dist/api/parse-args.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { getObjectTypedEntries, mapObjectValues, wrapInTry } from '@augment-vir/common';
|
|
2
3
|
import { extractRelevantArgs } from 'cli-args-vir';
|
|
3
|
-
import { isRunTimeType } from 'run-time-assertions';
|
|
4
4
|
import { accessAtKeys } from '../augments/object/access.js';
|
|
5
5
|
import { virmatorFlags } from './virmator-flags.js';
|
|
6
6
|
function extractNestedCommands(cliCommands) {
|
|
@@ -18,8 +18,8 @@ export function mapPluginsByCommand(plugins) {
|
|
|
18
18
|
const mappedPlugins = {};
|
|
19
19
|
plugins.forEach((plugin) => {
|
|
20
20
|
getObjectTypedEntries(plugin.cliCommands).forEach(([commandName, command,]) => {
|
|
21
|
-
if (!
|
|
22
|
-
throw new
|
|
21
|
+
if (!check.isString(commandName)) {
|
|
22
|
+
throw new TypeError(`Command '${String(commandName)}' in plugin '${plugin.name}' must be string.`);
|
|
23
23
|
}
|
|
24
24
|
const existingPlugin = mappedPlugins[commandName]?.plugin;
|
|
25
25
|
if (existingPlugin) {
|
|
@@ -35,7 +35,7 @@ export function mapPluginsByCommand(plugins) {
|
|
|
35
35
|
}
|
|
36
36
|
/** Determine the path of used commands from a plugin's nested cli command definition. */
|
|
37
37
|
export function calculateUsedCommands(pluginCliCommands, commands) {
|
|
38
|
-
if (!isLengthAtLeast(commands, 1)) {
|
|
38
|
+
if (!check.isLengthAtLeast(commands, 1)) {
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
41
|
const pluginCommand = pluginCliCommands[commands[0]];
|
|
@@ -53,7 +53,7 @@ export function calculateUsedCommands(pluginCliCommands, commands) {
|
|
|
53
53
|
}
|
|
54
54
|
/** Parses a raw cli command into supported virmator args. */
|
|
55
55
|
export function parseCliArgs({ cliCommand, entryPointFilePath, plugins, log, }) {
|
|
56
|
-
const rawArgs =
|
|
56
|
+
const rawArgs = check.isArray(cliCommand)
|
|
57
57
|
? cliCommand
|
|
58
58
|
: cliCommand.split(' ');
|
|
59
59
|
const relevantArgs = wrapInTry(() => extractRelevantArgs({
|
|
@@ -66,13 +66,13 @@ export function parseCliArgs({ cliCommand, entryPointFilePath, plugins, log, })
|
|
|
66
66
|
});
|
|
67
67
|
const mappedPlugins = mapPluginsByCommand(plugins);
|
|
68
68
|
const parsedArgs = relevantArgs.reduce((parsedArgs, arg) => {
|
|
69
|
-
if (
|
|
69
|
+
if (check.isKeyOf(arg, virmatorFlags)) {
|
|
70
70
|
parsedArgs.virmatorFlags[arg] = true;
|
|
71
71
|
}
|
|
72
72
|
else if (parsedArgs.filteredCommandArgs.length) {
|
|
73
73
|
parsedArgs.filteredCommandArgs.push(arg);
|
|
74
74
|
}
|
|
75
|
-
else if (isLengthAtLeast(parsedArgs.commands, 1)) {
|
|
75
|
+
else if (check.isLengthAtLeast(parsedArgs.commands, 1)) {
|
|
76
76
|
const mainCommand = parsedArgs.commands[0];
|
|
77
77
|
const subCommands = mappedPlugins[mainCommand]?.subCommands || {};
|
|
78
78
|
const availableSubCommands = accessAtKeys(subCommands, parsedArgs.commands.slice(1));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { wrapInTry } from '@augment-vir/common';
|
|
2
|
-
import { toPosixPath } from '@augment-vir/node
|
|
2
|
+
import { toPosixPath } from '@augment-vir/node';
|
|
3
3
|
import { rm } from 'node:fs/promises';
|
|
4
4
|
import { basename, join, relative } from 'node:path';
|
|
5
5
|
import { findClosestNodeModulesDir } from '../augments/index.js';
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively calls the `check` callback on ancestor directories until there are no more ancestor
|
|
3
|
-
* directories to check.
|
|
4
|
-
*/
|
|
5
|
-
export declare function searchUpwardsForDir(startDirPath: string, check: (dirPath: string) => boolean): string;
|
|
6
1
|
/** Finds the closest ancestor directory with a `package.json` file. */
|
|
7
2
|
export declare function findClosestPackageDir(startDirPath: string): string;
|
|
8
3
|
/** Finds the closest ancestor `node_modules` directory. */
|
|
@@ -1,31 +1,20 @@
|
|
|
1
|
+
import { assert } from '@augment-vir/assert';
|
|
2
|
+
import { findAncestor } from '@augment-vir/node';
|
|
1
3
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* Recursively calls the `check` callback on ancestor directories until there are no more ancestor
|
|
5
|
-
* directories to check.
|
|
6
|
-
*/
|
|
7
|
-
export function searchUpwardsForDir(startDirPath, check) {
|
|
8
|
-
if (!existsSync(startDirPath) || !startDirPath) {
|
|
9
|
-
throw new Error(`Could not search in '${startDirPath}': it does not exist.`);
|
|
10
|
-
}
|
|
11
|
-
if (check(startDirPath)) {
|
|
12
|
-
return startDirPath;
|
|
13
|
-
}
|
|
14
|
-
const parent = dirname(startDirPath);
|
|
15
|
-
if (parent === startDirPath) {
|
|
16
|
-
throw new Error(`Cannot recurse any higher, already at '${parent}'`);
|
|
17
|
-
}
|
|
18
|
-
return searchUpwardsForDir(parent, check);
|
|
19
|
-
}
|
|
4
|
+
import { join } from 'node:path';
|
|
20
5
|
/** Finds the closest ancestor directory with a `package.json` file. */
|
|
21
6
|
export function findClosestPackageDir(startDirPath) {
|
|
22
|
-
|
|
7
|
+
const ancestor = findAncestor(startDirPath, (dir) => {
|
|
23
8
|
return existsSync(join(dir, 'package.json'));
|
|
24
9
|
});
|
|
10
|
+
assert.isDefined(ancestor, 'Failed to find ancestor package root.');
|
|
11
|
+
return ancestor;
|
|
25
12
|
}
|
|
26
13
|
/** Finds the closest ancestor `node_modules` directory. */
|
|
27
14
|
export function findClosestNodeModulesDir(startDirPath) {
|
|
28
|
-
|
|
15
|
+
const ancestor = findAncestor(startDirPath, (dir) => {
|
|
29
16
|
return existsSync(join(dir, 'node_modules'));
|
|
30
|
-
})
|
|
17
|
+
});
|
|
18
|
+
assert.isDefined(ancestor, 'Failed to find ancestor node_modules root.');
|
|
19
|
+
return join(ancestor, 'node_modules');
|
|
31
20
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { AnyObject } from '@augment-vir/common';
|
|
2
2
|
/** Gets the nested value within an object with the provided chain of keys. */
|
|
3
|
-
export declare function accessAtKeys<T
|
|
3
|
+
export declare function accessAtKeys<T>(parent: Readonly<AnyObject> | undefined, keys: ReadonlyArray<PropertyKey>): T | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
2
|
/** Gets the nested value within an object with the provided chain of keys. */
|
|
3
3
|
export function accessAtKeys(parent, keys) {
|
|
4
4
|
if (!parent) {
|
|
5
5
|
return undefined;
|
|
6
6
|
}
|
|
7
|
-
else if (isLengthAtLeast(keys, 1)) {
|
|
7
|
+
else if (check.isLengthAtLeast(keys, 1)) {
|
|
8
8
|
return accessAtKeys(parent[keys[0]], keys.slice(1));
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Logger } from '@augment-vir/common';
|
|
1
2
|
import { Writable } from 'node:stream';
|
|
2
|
-
import { PluginLogger } from '../../plugin/plugin-logger.js';
|
|
3
3
|
/**
|
|
4
4
|
* A [Writable](https://nodejs.org/api/stream.html#class-streamwritable) implementation that writes
|
|
5
5
|
* to the provided plugin logger.
|
|
@@ -9,5 +9,5 @@ export declare class CallbackWritable extends Writable {
|
|
|
9
9
|
private chunks;
|
|
10
10
|
/** Special write implementation that writs to the given logger. */
|
|
11
11
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
12
|
-
constructor(logger:
|
|
12
|
+
constructor(logger: Logger);
|
|
13
13
|
}
|
package/dist/plugin/index.d.ts
CHANGED
package/dist/plugin/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RuntimeEnv } from '@augment-vir/common';
|
|
2
|
+
import { PackageType } from './plugin-env.js';
|
|
2
3
|
/** Definition for a plugin's config file. */
|
|
3
4
|
export type VirmatorPluginConfigFile = {
|
|
4
5
|
/**
|
|
@@ -12,7 +13,7 @@ export type VirmatorPluginConfigFile = {
|
|
|
12
13
|
*/
|
|
13
14
|
copyToPath: string;
|
|
14
15
|
/** The environments in which this config should be used. */
|
|
15
|
-
env:
|
|
16
|
+
env: RuntimeEnv[];
|
|
16
17
|
/** The package type for which this config should be used. */
|
|
17
18
|
packageType: PackageType[];
|
|
18
19
|
/**
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/** The different execution environments that virmator supports. */
|
|
2
|
-
export declare enum VirmatorEnv {
|
|
3
|
-
/** Node.js */
|
|
4
|
-
Node = "node",
|
|
5
|
-
/** Any code that will run in a browser. */
|
|
6
|
-
Web = "web"
|
|
7
|
-
}
|
|
8
1
|
/** The different npm package types that virmator supports. */
|
|
9
2
|
export declare enum PackageType {
|
|
10
3
|
/** The root of an npm mono repo package. */
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/** The different execution environments that virmator supports. */
|
|
2
|
-
export var VirmatorEnv;
|
|
3
|
-
(function (VirmatorEnv) {
|
|
4
|
-
/** Node.js */
|
|
5
|
-
VirmatorEnv["Node"] = "node";
|
|
6
|
-
/** Any code that will run in a browser. */
|
|
7
|
-
VirmatorEnv["Web"] = "web";
|
|
8
|
-
})(VirmatorEnv || (VirmatorEnv = {}));
|
|
9
1
|
/** The different npm package types that virmator supports. */
|
|
10
2
|
export var PackageType;
|
|
11
3
|
(function (PackageType) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AnyObject, MaybePromise,
|
|
2
|
-
import type {
|
|
1
|
+
import type { AnyObject, Logger, LogOutputType, MaybePromise, PartialWithUndefined, TypedFunction } from '@augment-vir/common';
|
|
2
|
+
import type { runShellCommand } from '@augment-vir/node';
|
|
3
3
|
import { ChalkInstance } from 'chalk';
|
|
4
4
|
import { EmptyObject, PackageJson, SetRequired } from 'type-fest';
|
|
5
5
|
import { VirmatorPluginResolvedConfigFile } from './plugin-configs.js';
|
|
6
6
|
import { PackageType } from './plugin-env.js';
|
|
7
7
|
import { IndividualPluginCommand, PluginNpmDeps, VirmatorPluginCliCommands, VirmatorPluginInit } from './plugin-init.js';
|
|
8
|
-
import { PluginLogger } from './plugin-logger.js';
|
|
9
8
|
/** A picked nesting of commands based on which commands are currently in use. */
|
|
10
9
|
export type UsedVirmatorPluginCommands<Commands extends VirmatorPluginCliCommands = VirmatorPluginCliCommands> = Partial<Readonly<{
|
|
11
10
|
[CliCommand in keyof Commands]: Readonly<Omit<IndividualPluginCommand, 'subCommands'> & {
|
|
@@ -83,13 +82,13 @@ export type VirmatorPluginExecutorParams<Commands extends VirmatorPluginCliComma
|
|
|
83
82
|
/** Run a shell command with sensible defaults. */
|
|
84
83
|
runShellCommand: TypedFunction<[
|
|
85
84
|
...Parameters<typeof runShellCommand>,
|
|
86
|
-
|
|
85
|
+
PartialWithUndefined<ExtraRunShellCommandOptions>?
|
|
87
86
|
], ReturnType<typeof runShellCommand>>;
|
|
88
87
|
/** Runs the given command for each package within a mono repo, if it has any. */
|
|
89
88
|
runPerPackage: RunPerPackage;
|
|
90
89
|
/** Installs the given list of deps within the current package directory. */
|
|
91
90
|
runInstallDeps: (deps: Readonly<Partial<PluginNpmDeps>>) => Promise<void>;
|
|
92
|
-
log:
|
|
91
|
+
log: Logger;
|
|
93
92
|
configs: VirmatorPluginResolvedConfigs<Commands>;
|
|
94
93
|
virmator: Readonly<{
|
|
95
94
|
/** All plugins currently installed on the currently executing virmator instance. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { RuntimeEnv } from '@augment-vir/common';
|
|
1
2
|
import { VirmatorPluginConfigFile } from './plugin-configs.js';
|
|
2
|
-
import { PackageType
|
|
3
|
+
import { PackageType } from './plugin-env.js';
|
|
3
4
|
/** A single doc entry for {@link PluginCommandDocs}. */
|
|
4
5
|
export type PluginDocEntry = Readonly<{
|
|
5
6
|
title?: string;
|
|
@@ -14,7 +15,7 @@ export type PluginCommandDocs = {
|
|
|
14
15
|
export type PluginNpmDeps = Record<string, {
|
|
15
16
|
type: NpmDepType;
|
|
16
17
|
packageType: ReadonlyArray<PackageType>;
|
|
17
|
-
env: ReadonlyArray<
|
|
18
|
+
env: ReadonlyArray<RuntimeEnv>;
|
|
18
19
|
}>;
|
|
19
20
|
/** An individual virmator plugin cli command definition. Can nest recursive commands. */
|
|
20
21
|
export type IndividualPluginCommand = {
|
package/dist/plugin/plugin.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { assert } from '@augment-vir/assert';
|
|
2
|
+
import { findAncestor } from '@augment-vir/node';
|
|
1
3
|
import { existsSync } from 'node:fs';
|
|
2
4
|
import { join } from 'node:path';
|
|
3
|
-
import { searchUpwardsForDir } from '../augments/fs/search.js';
|
|
4
5
|
/** Define a virmator plugin. */
|
|
5
6
|
export function defineVirmatorPlugin(
|
|
6
7
|
/** Should be `import.meta.dirname`. Used to determine the directory of the plugin's package. */
|
|
7
8
|
currentDir, init, executor) {
|
|
8
|
-
const pluginPackageRootPath =
|
|
9
|
+
const pluginPackageRootPath = findAncestor(currentDir, (path) => {
|
|
9
10
|
return existsSync(join(path, 'package.json'));
|
|
10
11
|
});
|
|
12
|
+
assert.isDefined(pluginPackageRootPath, 'Failed to find plugin package root.');
|
|
11
13
|
return {
|
|
12
14
|
...init,
|
|
13
15
|
executor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/core",
|
|
3
|
-
"version": "13.3.
|
|
3
|
+
"version": "13.3.13",
|
|
4
4
|
"description": "Shared core functionality for all virmator plugins and the virmator CLI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
"test:update": "npm test update"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@augment-vir/
|
|
35
|
-
"@augment-vir/
|
|
34
|
+
"@augment-vir/assert": "^30.0.4",
|
|
35
|
+
"@augment-vir/common": "^30.0.4",
|
|
36
|
+
"@augment-vir/node": "^30.0.4",
|
|
36
37
|
"chalk": "^5.3.0",
|
|
37
38
|
"cli-args-vir": "^0.0.3",
|
|
38
|
-
"concurrently": "^9.0.
|
|
39
|
+
"concurrently": "^9.0.1",
|
|
39
40
|
"mono-vir": "^1.0.1",
|
|
40
|
-
"run-time-assertions": "^1.5.2",
|
|
41
41
|
"semver": "^7.6.3",
|
|
42
42
|
"type-fest": "^4.26.1",
|
|
43
43
|
"typescript": "^5.6.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@augment-vir/
|
|
47
|
-
"@types/node": "^22.5.
|
|
46
|
+
"@augment-vir/test": "^30.0.4",
|
|
47
|
+
"@types/node": "^22.5.5",
|
|
48
48
|
"@types/semver": "^7.5.8",
|
|
49
49
|
"esbuild": "^0.23.1"
|
|
50
50
|
},
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Logger, LogOutputType } from '@augment-vir/node-js';
|
|
2
|
-
import { Socket } from 'node:net';
|
|
3
|
-
/** An extensions of `@augment-vir/node-js`'s logger with a `plain` log command. */
|
|
4
|
-
export type PluginLogger = Logger & {
|
|
5
|
-
plain: Logger['faint'];
|
|
6
|
-
};
|
|
7
|
-
/** Creates a plugin logger based on the provided stderr and stdout writers. */
|
|
8
|
-
export declare function createPluginLogger(logWriters: Record<LogOutputType, Pick<Socket, 'write'>>, omitNewLines?: boolean | undefined): PluginLogger;
|
|
9
|
-
/** A {@link PluginLogger} implementation that does nothing. */
|
|
10
|
-
export declare const emptyLog: PluginLogger;
|
|
11
|
-
/**
|
|
12
|
-
* The default implementation of a {@link PluginLogger} which simply logs to the running process
|
|
13
|
-
* pipelines.
|
|
14
|
-
*/
|
|
15
|
-
export declare const defaultPluginLogger: PluginLogger;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { ColorKey, LogOutputType, toLogString } from '@augment-vir/node-js';
|
|
2
|
-
/** Creates a plugin logger based on the provided stderr and stdout writers. */
|
|
3
|
-
export function createPluginLogger(logWriters, omitNewLines) {
|
|
4
|
-
function writeLog(params) {
|
|
5
|
-
const logString = toLogString(params);
|
|
6
|
-
const fixedLogString = omitNewLines ? logString.replace(/\n$/, '') : logString;
|
|
7
|
-
logWriters[params.logType].write(fixedLogString);
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
info(...args) {
|
|
11
|
-
writeLog({
|
|
12
|
-
logType: LogOutputType.standard,
|
|
13
|
-
colors: ColorKey.info,
|
|
14
|
-
args,
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
|
-
plain(...args) {
|
|
18
|
-
writeLog({
|
|
19
|
-
logType: LogOutputType.standard,
|
|
20
|
-
colors: [],
|
|
21
|
-
args,
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
error(...args) {
|
|
25
|
-
writeLog({
|
|
26
|
-
logType: LogOutputType.error,
|
|
27
|
-
colors: [
|
|
28
|
-
ColorKey.error,
|
|
29
|
-
ColorKey.bold,
|
|
30
|
-
],
|
|
31
|
-
args,
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
bold(...args) {
|
|
35
|
-
writeLog({
|
|
36
|
-
logType: LogOutputType.standard,
|
|
37
|
-
colors: ColorKey.bold,
|
|
38
|
-
args,
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
mutate(...args) {
|
|
42
|
-
writeLog({
|
|
43
|
-
logType: LogOutputType.standard,
|
|
44
|
-
colors: [
|
|
45
|
-
ColorKey.bold,
|
|
46
|
-
ColorKey.mutate,
|
|
47
|
-
],
|
|
48
|
-
args,
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
faint(...args) {
|
|
52
|
-
writeLog({
|
|
53
|
-
logType: LogOutputType.standard,
|
|
54
|
-
colors: ColorKey.faint,
|
|
55
|
-
args,
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
warning(...args) {
|
|
59
|
-
writeLog({
|
|
60
|
-
logType: LogOutputType.standard,
|
|
61
|
-
colors: ColorKey.warning,
|
|
62
|
-
args,
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
success(...args) {
|
|
66
|
-
writeLog({
|
|
67
|
-
logType: LogOutputType.standard,
|
|
68
|
-
colors: [
|
|
69
|
-
ColorKey.bold,
|
|
70
|
-
ColorKey.success,
|
|
71
|
-
],
|
|
72
|
-
args,
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/** A {@link PluginLogger} implementation that does nothing. */
|
|
78
|
-
export const emptyLog = createPluginLogger({
|
|
79
|
-
stderr: {
|
|
80
|
-
write() {
|
|
81
|
-
return true;
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
stdout: {
|
|
85
|
-
write() {
|
|
86
|
-
return true;
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
/**
|
|
91
|
-
* The default implementation of a {@link PluginLogger} which simply logs to the running process
|
|
92
|
-
* pipelines.
|
|
93
|
-
*/
|
|
94
|
-
export const defaultPluginLogger = createPluginLogger({
|
|
95
|
-
stderr: process.stderr,
|
|
96
|
-
stdout: process.stdout,
|
|
97
|
-
});
|