@mainset/cli 0.2.0 → 0.2.1-rc.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.
|
@@ -3,20 +3,18 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { runtimePathById } from './path.mjs';
|
|
5
5
|
function resolveHostPackageNodeModulesPath(hostPackageName, dependencyPackageName) {
|
|
6
|
-
const
|
|
7
|
-
const hostPackageDependencyPackagePath = path.join(hostPackageNodeModulesPath, dependencyPackageName);
|
|
8
|
-
const isNodeModulesLinkedOrWorkspace = fs.existsSync(hostPackageDependencyPackagePath);
|
|
6
|
+
const hostPackageDependencyPackagePath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/${dependencyPackageName}`);
|
|
9
7
|
// If the package is linked or part of a workspace, return the full path
|
|
10
8
|
// Otherwise, return just the package name (for packages installed from the registry)
|
|
11
|
-
return
|
|
9
|
+
return fs.existsSync(hostPackageDependencyPackagePath)
|
|
12
10
|
? hostPackageDependencyPackagePath
|
|
13
11
|
: fileURLToPath(import.meta.resolve(dependencyPackageName));
|
|
14
12
|
}
|
|
15
13
|
function resolveHostPackageBinForCLICommandPath(hostPackageName,
|
|
16
14
|
// dependencyPackageName: string,
|
|
17
15
|
cliCommandName) {
|
|
18
|
-
/*
|
|
19
|
-
|
|
16
|
+
/*
|
|
17
|
+
* ========== V1 implementation using pnpm node_modules structure ==========
|
|
20
18
|
const dependencyPackageNodeModulesPath = resolveHostPackageNodeModulesPath(
|
|
21
19
|
hostPackageName,
|
|
22
20
|
dependencyPackageName,
|
|
@@ -33,12 +31,13 @@ cliCommandName) {
|
|
|
33
31
|
|
|
34
32
|
return path.join(dependencyPackageNodeModulesPath, binPath);
|
|
35
33
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
const hostPackageDependencyBinCLICommandPath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/.bin/${cliCommandName}`);
|
|
35
|
+
// Return the full path if the dependency is linked or part of a workspace (nested under the host package)
|
|
36
|
+
if (fs.existsSync(hostPackageDependencyBinCLICommandPath)) {
|
|
37
|
+
return fileURLToPath(import.meta.resolve(hostPackageDependencyBinCLICommandPath));
|
|
38
|
+
}
|
|
39
|
+
// Otherwise, return the path to the dependency in the root node_modules (for registry-installed packages)
|
|
40
|
+
const dependencyBinCLICommandPath = path.resolve(runtimePathById.root, `node_modules/.bin/${cliCommandName}`);
|
|
41
|
+
return fileURLToPath(import.meta.resolve(dependencyBinCLICommandPath));
|
|
43
42
|
}
|
|
44
43
|
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.2",
|
|
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": {
|