@mainset/cli 0.2.0-rc.2 → 0.2.1-rc.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.
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
// import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { runtimePathById } from './path.mjs';
|
|
5
5
|
function resolveHostPackageNodeModulesPath(hostPackageName, dependencyPackageName) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/*
|
|
7
|
+
* ========== V1 implementation using pnpm node_modules structure ==========
|
|
8
|
+
|
|
9
|
+
const hostPackageNodeModulesPath = path.resolve(
|
|
10
|
+
runtimePathById.root,
|
|
11
|
+
`node_modules/${hostPackageName}/node_modules`,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const hostPackageDependencyPackagePath = path.join(
|
|
15
|
+
hostPackageNodeModulesPath,
|
|
16
|
+
dependencyPackageName,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const isNodeModulesLinkedOrWorkspace = fs.existsSync(
|
|
20
|
+
hostPackageDependencyPackagePath,
|
|
21
|
+
);
|
|
22
|
+
|
|
9
23
|
// If the package is linked or part of a workspace, return the full path
|
|
10
24
|
// Otherwise, return just the package name (for packages installed from the registry)
|
|
11
25
|
return isNodeModulesLinkedOrWorkspace
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
? hostPackageDependencyPackagePath
|
|
27
|
+
: dependencyPackageName;
|
|
28
|
+
*/
|
|
29
|
+
const hostPackageDependencyPackagePath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/${dependencyPackageName}`);
|
|
30
|
+
return fileURLToPath(import.meta.resolve(hostPackageDependencyPackagePath));
|
|
14
31
|
}
|
|
15
32
|
function resolveHostPackageBinForCLICommandPath(hostPackageName,
|
|
16
33
|
// dependencyPackageName: string,
|
|
17
34
|
cliCommandName) {
|
|
18
|
-
/*
|
|
19
|
-
|
|
35
|
+
/*
|
|
36
|
+
* ========== V1 implementation using pnpm node_modules structure ==========
|
|
20
37
|
const dependencyPackageNodeModulesPath = resolveHostPackageNodeModulesPath(
|
|
21
38
|
hostPackageName,
|
|
22
39
|
dependencyPackageName,
|
|
@@ -33,12 +50,25 @@ cliCommandName) {
|
|
|
33
50
|
|
|
34
51
|
return path.join(dependencyPackageNodeModulesPath, binPath);
|
|
35
52
|
*/
|
|
53
|
+
/*
|
|
54
|
+
* ========== V2 implementation using pnpm node_modules structure ==========
|
|
36
55
|
// installed from the registry
|
|
37
|
-
const dependencyPackageNodeModulesPath = path.resolve(
|
|
56
|
+
const dependencyPackageNodeModulesPath = path.resolve(
|
|
57
|
+
runtimePathById.root,
|
|
58
|
+
`node_modules/.bin/${cliCommandName}`,
|
|
59
|
+
);
|
|
60
|
+
|
|
38
61
|
// linked / workspace:^ package
|
|
39
|
-
const dependencyWorkspacePackageNodeModulesPath = path.resolve(
|
|
62
|
+
const dependencyWorkspacePackageNodeModulesPath = path.resolve(
|
|
63
|
+
runtimePathById.root,
|
|
64
|
+
`node_modules/${hostPackageName}/node_modules/.bin/${cliCommandName}`,
|
|
65
|
+
);
|
|
66
|
+
|
|
40
67
|
return fs.existsSync(dependencyPackageNodeModulesPath)
|
|
41
|
-
|
|
42
|
-
|
|
68
|
+
? dependencyPackageNodeModulesPath
|
|
69
|
+
: dependencyWorkspacePackageNodeModulesPath;
|
|
70
|
+
*/
|
|
71
|
+
const hostPackageDependencyBinCLICommandPath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/.bin/${cliCommandName}`);
|
|
72
|
+
return fileURLToPath(import.meta.resolve(hostPackageDependencyBinCLICommandPath));
|
|
43
73
|
}
|
|
44
74
|
export { resolveHostPackageBinForCLICommandPath, resolveHostPackageNodeModulesPath, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mainset/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-rc.1",
|
|
4
4
|
"description": "A unified CLI tool for accelerating development, based on mainset vision of front-end infrastructure",
|
|
5
5
|
"homepage": "https://github.com/mainset/dev-stack-fe/tree/main/packages/cli",
|
|
6
6
|
"bugs": {
|