@virmator/core 14.26.1 → 14.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { type Logger, type MaybePromise } from '@augment-vir/common';
1
+ import { type Logger, type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
2
2
  import { type VirmatorPluginResolvedConfigFile } from '../plugin/plugin-configs.js';
3
3
  import { PackageType } from '../plugin/plugin-env.js';
4
4
  import { type MonoRepoPackage, type UsedVirmatorPluginCommands, type VirmatorPluginResolvedConfigs } from '../plugin/plugin-executor.js';
@@ -8,14 +8,29 @@ import { type MonoRepoPackage, type UsedVirmatorPluginCommands, type VirmatorPlu
8
8
  */
9
9
  export declare function flattenConfigs(usedCommands: Readonly<UsedVirmatorPluginCommands<any>>, resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>): VirmatorPluginResolvedConfigFile[];
10
10
  /** Copies a plugin's entire set of configs based on the used command. */
11
- export declare function copyPluginConfigs(usedCommands: Readonly<UsedVirmatorPluginCommands>, resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>, packageType: PackageType, monoRepoPackages: MonoRepoPackage[], log: Logger, filteredArgs: string[]): Promise<void>;
11
+ export declare function copyPluginConfigs({ usedCommands, resolvedConfigs, packageType, monoRepoPackages, log, filteredArgs, }: Readonly<{
12
+ usedCommands: Readonly<UsedVirmatorPluginCommands>;
13
+ resolvedConfigs: Readonly<VirmatorPluginResolvedConfigs<any>>;
14
+ packageType: PackageType;
15
+ monoRepoPackages: MonoRepoPackage[];
16
+ log: Logger;
17
+ filteredArgs: string[];
18
+ }>): Promise<void>;
19
+ /** Inputs for {@link copyConfigFile}. */
20
+ export type CopyConfigFileParams = {
21
+ config: Readonly<Pick<VirmatorPluginResolvedConfigFile, 'fullCopyFromPath' | 'fullCopyToPath'>>;
22
+ log: Logger;
23
+ } & PartialWithUndefined<{
24
+ /**
25
+ * If `true`, the config will be copied even if the copy destination already exists.
26
+ *
27
+ * @default false
28
+ */
29
+ force: boolean;
30
+ /** Optional transform callback. */
31
+ transform: (currentContents: string) => MaybePromise<string>;
32
+ /** Package name when this is being run within a sub-package. */
33
+ packageName: string;
34
+ }>;
12
35
  /** Copies a single virmator plugin config file. */
13
- export declare function copyConfigFile(config: Readonly<Pick<VirmatorPluginResolvedConfigFile, 'fullCopyFromPath' | 'fullCopyToPath'>>, log: Logger,
14
- /**
15
- * If `true`, the config will be copied even if the copy destination already exists.
16
- *
17
- * @default false
18
- */
19
- force?: boolean, transform?: ((currentContents: string) => MaybePromise<string>) | undefined,
20
- /** Package name when this is being run within a sub-package. */
21
- packageName?: string | undefined): Promise<void>;
36
+ export declare function copyConfigFile({ config, log, force, transform, packageName, }: Readonly<CopyConfigFileParams>): Promise<void>;
@@ -21,7 +21,7 @@ export function flattenConfigs(usedCommands, resolvedConfigs) {
21
21
  });
22
22
  }
23
23
  /** Copies a plugin's entire set of configs based on the used command. */
24
- export async function copyPluginConfigs(usedCommands, resolvedConfigs, packageType, monoRepoPackages, log, filteredArgs) {
24
+ export async function copyPluginConfigs({ usedCommands, resolvedConfigs, packageType, monoRepoPackages, log, filteredArgs, }) {
25
25
  const configs = flattenConfigs(usedCommands, resolvedConfigs).sort((a, b) => basename(a.copyToPath).localeCompare(basename(b.copyToPath)));
26
26
  await awaitedForEach(Object.values(configs), async (config) => {
27
27
  if ((config.configFlags || []).some((configFlag) => filteredArgs.includes(configFlag))) {
@@ -32,29 +32,27 @@ export async function copyPluginConfigs(usedCommands, resolvedConfigs, packageTy
32
32
  config.packageType[PackageType.MonoPackage]) {
33
33
  await Promise.all(monoRepoPackages.map(async (repoPackage) => {
34
34
  await copyConfigFile({
35
- ...config,
36
- fullCopyToPath: join(repoPackage.fullPath, config.copyToPath),
37
- }, log);
35
+ config: {
36
+ ...config,
37
+ fullCopyToPath: join(repoPackage.fullPath, config.copyToPath),
38
+ },
39
+ log,
40
+ });
38
41
  }));
39
42
  }
40
43
  else if (!config.required || !config.packageType[packageType]) {
41
44
  return;
42
45
  }
43
46
  else {
44
- await copyConfigFile(config, log);
47
+ await copyConfigFile({
48
+ config,
49
+ log,
50
+ });
45
51
  }
46
52
  });
47
53
  }
48
54
  /** Copies a single virmator plugin config file. */
49
- export async function copyConfigFile(config, log,
50
- /**
51
- * If `true`, the config will be copied even if the copy destination already exists.
52
- *
53
- * @default false
54
- */
55
- force = false, transform,
56
- /** Package name when this is being run within a sub-package. */
57
- packageName) {
55
+ export async function copyConfigFile({ config, log, force = false, transform, packageName, }) {
58
56
  if (existsSync(config.fullCopyToPath) && !force) {
59
57
  return;
60
58
  }
@@ -28,7 +28,7 @@ function resolveConfigs({ cwdPackagePath, pluginPackagePath }, cliCommands) {
28
28
  };
29
29
  });
30
30
  }
31
- async function determinePackageType(cwdPackagePath, monoRepoRootPath, cwdPackageJson) {
31
+ async function determinePackageType({ cwdPackagePath, monoRepoRootPath, cwdPackageJson, }) {
32
32
  try {
33
33
  if (cwdPackageJson.workspaces &&
34
34
  (check.isArray(cwdPackageJson.workspaces)
@@ -89,7 +89,11 @@ async function getMonoRepoPackages(cwdPackagePath) {
89
89
  }
90
90
  async function getMonoRepoDetails(cwdPackagePath, cwdPackageJson) {
91
91
  const monoRepoRootPath = await findMonoRepoDir(cwdPackagePath);
92
- const { packageType, monoRepoPackages } = await determinePackageType(cwdPackagePath, monoRepoRootPath, cwdPackageJson);
92
+ const { packageType, monoRepoPackages } = await determinePackageType({
93
+ cwdPackagePath,
94
+ monoRepoRootPath,
95
+ cwdPackageJson,
96
+ });
93
97
  const isPartOfMonoRepo = packageType === PackageType.MonoPackage &&
94
98
  monoRepoPackages.flat().some(({ fullPath }) => fullPath === cwdPackagePath);
95
99
  if (isPartOfMonoRepo || packageType === PackageType.MonoRoot) {
@@ -116,7 +120,7 @@ async function findMonoRepoDir(cwdPackagePath) {
116
120
  });
117
121
  return parentPackageDir || cwdPackagePath;
118
122
  }
119
- function writeLog(arg, log, logType, extraOptions) {
123
+ function writeLog({ arg, log, logType, extraOptions, }) {
120
124
  const transformed = extraOptions?.logTransform?.[logType]
121
125
  ? extraOptions.logTransform[logType](arg)
122
126
  : arg;
@@ -194,10 +198,20 @@ export async function executeVirmatorCommand({ log: logParam, entryPointFilePath
194
198
  cwd,
195
199
  shell: 'bash',
196
200
  stderrCallback(stderr) {
197
- writeLog(stderr, log, LogOutputType.Error, outputExtraOptions);
201
+ writeLog({
202
+ arg: stderr,
203
+ log,
204
+ logType: LogOutputType.Error,
205
+ extraOptions: outputExtraOptions,
206
+ });
198
207
  },
199
208
  stdoutCallback(stdout) {
200
- writeLog(stdout, log, LogOutputType.Standard, outputExtraOptions);
209
+ writeLog({
210
+ arg: stdout,
211
+ log,
212
+ logType: LogOutputType.Standard,
213
+ extraOptions: outputExtraOptions,
214
+ });
201
215
  },
202
216
  ...options,
203
217
  });
@@ -308,7 +322,14 @@ export async function executeVirmatorCommand({ log: logParam, entryPointFilePath
308
322
  },
309
323
  };
310
324
  if (!args.virmatorFlags['--no-configs']) {
311
- await copyPluginConfigs(args.usedCommands, resolvedConfigs, packageType, monoRepoPackages.flat(), log, filteredArgs);
325
+ await copyPluginConfigs({
326
+ usedCommands: args.usedCommands,
327
+ resolvedConfigs,
328
+ packageType,
329
+ monoRepoPackages: monoRepoPackages.flat(),
330
+ log,
331
+ filteredArgs,
332
+ });
312
333
  }
313
334
  if (!args.virmatorFlags['--no-deps']) {
314
335
  await installPluginNpmDeps({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/core",
3
- "version": "14.26.1",
3
+ "version": "14.27.0",
4
4
  "description": "Shared core functionality for all virmator plugins and the virmator CLI.",
5
5
  "keywords": [
6
6
  "automation",