@virmator/core 13.8.0 → 13.8.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.
|
@@ -13,7 +13,11 @@ export declare function installPluginNpmDeps({ usedCommands, ...params }: {
|
|
|
13
13
|
log: Logger;
|
|
14
14
|
usedCommands: Readonly<UsedVirmatorPluginCommands>;
|
|
15
15
|
}): Promise<void>;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Installs a set of virmator plugin npm deps.
|
|
18
|
+
*
|
|
19
|
+
* @returns `true` if new deps were installed, otherwise `false`.
|
|
20
|
+
*/
|
|
17
21
|
export declare function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginPackagePath, pluginName, packageType, log, deps, }: {
|
|
18
22
|
cwdPackagePath: string;
|
|
19
23
|
cwdPackageJson: PackageJson;
|
|
@@ -22,4 +26,4 @@ export declare function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginP
|
|
|
22
26
|
packageType: PackageType;
|
|
23
27
|
log: Logger;
|
|
24
28
|
deps: Partial<PluginNpmDeps>;
|
|
25
|
-
}): Promise<
|
|
29
|
+
}): Promise<boolean>;
|
package/dist/api/install-deps.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { awaitedBlockingMap, getObjectTypedEntries } from '@augment-vir/common';
|
|
2
|
+
import { awaitedBlockingMap, awaitedForEach, getObjectTypedEntries, } from '@augment-vir/common';
|
|
3
3
|
import { readPackageJson, runShellCommand } from '@augment-vir/node';
|
|
4
4
|
import * as semver from 'semver';
|
|
5
5
|
import { VirmatorNoTraceError } from '../errors/virmator-no-trace.error.js';
|
|
@@ -7,13 +7,27 @@ import { NpmDepType } from '../plugin/plugin-init.js';
|
|
|
7
7
|
/** Install's a virmator plugin's listed npm deps depending on which command is being run. */
|
|
8
8
|
export async function installPluginNpmDeps({ usedCommands, ...params }) {
|
|
9
9
|
const deps = flattenDeps(usedCommands);
|
|
10
|
-
|
|
10
|
+
const installCommands = flattenExtraInstallCommands(usedCommands);
|
|
11
|
+
if (await installNpmDeps({ ...params, deps })) {
|
|
12
|
+
await awaitedForEach(installCommands, async (command) => {
|
|
13
|
+
params.log.faint(`> ${command}`);
|
|
14
|
+
await runShellCommand(command, {
|
|
15
|
+
cwd: params.cwdPackagePath,
|
|
16
|
+
rejectOnError: true,
|
|
17
|
+
hookUpToConsole: true,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
11
21
|
}
|
|
12
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Installs a set of virmator plugin npm deps.
|
|
24
|
+
*
|
|
25
|
+
* @returns `true` if new deps were installed, otherwise `false`.
|
|
26
|
+
*/
|
|
13
27
|
export async function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginPackagePath, pluginName, packageType, log, deps, }) {
|
|
14
28
|
const neededDeps = getObjectTypedEntries(deps);
|
|
15
29
|
if (!neededDeps.length) {
|
|
16
|
-
return;
|
|
30
|
+
return false;
|
|
17
31
|
}
|
|
18
32
|
const cwdPackageDeps = combineDeps(cwdPackageJson);
|
|
19
33
|
const pluginPackageJson = await readPackageJson(pluginPackagePath);
|
|
@@ -37,7 +51,8 @@ export async function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginPac
|
|
|
37
51
|
[NpmDepType.Dev]: [],
|
|
38
52
|
[NpmDepType.Regular]: [],
|
|
39
53
|
});
|
|
40
|
-
|
|
54
|
+
const depsToInstallEntries = Object.entries(depsThatNeedInstalling);
|
|
55
|
+
await awaitedBlockingMap(depsToInstallEntries, async ([depType, deps,]) => {
|
|
41
56
|
if (!deps.length) {
|
|
42
57
|
return;
|
|
43
58
|
}
|
|
@@ -57,6 +72,7 @@ export async function installNpmDeps({ cwdPackagePath, cwdPackageJson, pluginPac
|
|
|
57
72
|
rejectOnError: true,
|
|
58
73
|
});
|
|
59
74
|
});
|
|
75
|
+
return !!depsToInstallEntries.length;
|
|
60
76
|
}
|
|
61
77
|
function combineDeps(packageJson) {
|
|
62
78
|
return {
|
|
@@ -78,3 +94,18 @@ function flattenDeps(usedCommands) {
|
|
|
78
94
|
return accum;
|
|
79
95
|
}, {});
|
|
80
96
|
}
|
|
97
|
+
function flattenExtraInstallCommands(usedCommands) {
|
|
98
|
+
return Object.values(usedCommands).reduce((accum, usedCommand) => {
|
|
99
|
+
if (!usedCommand) {
|
|
100
|
+
return accum;
|
|
101
|
+
}
|
|
102
|
+
if (usedCommand.extraInstallCommand) {
|
|
103
|
+
accum.push(usedCommand.extraInstallCommand);
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(usedCommand.subCommands).length) {
|
|
106
|
+
const subCommands = flattenExtraInstallCommands(usedCommand.subCommands);
|
|
107
|
+
accum.push(...subCommands);
|
|
108
|
+
}
|
|
109
|
+
return accum;
|
|
110
|
+
}, []);
|
|
111
|
+
}
|
|
@@ -26,6 +26,8 @@ export type IndividualPluginCommand = {
|
|
|
26
26
|
doc: PluginCommandDocs;
|
|
27
27
|
configFiles?: Readonly<Record<string, VirmatorPluginConfigFile>>;
|
|
28
28
|
subCommands?: VirmatorPluginCliCommands;
|
|
29
|
+
/** An extra shell command that will be run after deps have been installed. */
|
|
30
|
+
extraInstallCommand?: string;
|
|
29
31
|
/** Dependencies that this command needs to be installed in the host repo. */
|
|
30
32
|
npmDeps?: Readonly<PluginNpmDeps>;
|
|
31
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/core",
|
|
3
|
-
"version": "13.8.
|
|
3
|
+
"version": "13.8.2",
|
|
4
4
|
"description": "Shared core functionality for all virmator plugins and the virmator CLI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
"test:update": "npm test update"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@augment-vir/assert": "^30.
|
|
35
|
-
"@augment-vir/common": "^30.
|
|
36
|
-
"@augment-vir/node": "^30.
|
|
34
|
+
"@augment-vir/assert": "^30.8.2",
|
|
35
|
+
"@augment-vir/common": "^30.8.2",
|
|
36
|
+
"@augment-vir/node": "^30.8.2",
|
|
37
37
|
"chalk": "^5.3.0",
|
|
38
38
|
"cli-args-vir": "^1.0.0",
|
|
39
39
|
"concurrently": "^9.1.0",
|
|
40
|
-
"mono-vir": "^2.0.
|
|
40
|
+
"mono-vir": "^2.0.4",
|
|
41
41
|
"semver": "^7.6.3",
|
|
42
|
-
"type-fest": "^4.
|
|
42
|
+
"type-fest": "^4.27.0",
|
|
43
43
|
"typescript": "^5.6.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@augment-vir/test": "^30.
|
|
46
|
+
"@augment-vir/test": "^30.8.2",
|
|
47
47
|
"@types/node": "^22.9.0",
|
|
48
48
|
"@types/semver": "^7.5.8",
|
|
49
49
|
"esbuild": "^0.24.0"
|