@mainset/cli 0.2.1-rc.1 → 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.
@@ -1,33 +1,14 @@
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
- * ========== 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
-
6
+ const hostPackageDependencyPackagePath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/${dependencyPackageName}`);
23
7
  // If the package is linked or part of a workspace, return the full path
24
8
  // Otherwise, return just the package name (for packages installed from the registry)
25
- return isNodeModulesLinkedOrWorkspace
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));
9
+ return fs.existsSync(hostPackageDependencyPackagePath)
10
+ ? hostPackageDependencyPackagePath
11
+ : fileURLToPath(import.meta.resolve(dependencyPackageName));
31
12
  }
32
13
  function resolveHostPackageBinForCLICommandPath(hostPackageName,
33
14
  // dependencyPackageName: string,
@@ -50,25 +31,13 @@ cliCommandName) {
50
31
 
51
32
  return path.join(dependencyPackageNodeModulesPath, binPath);
52
33
  */
53
- /*
54
- * ========== V2 implementation using pnpm node_modules structure ==========
55
- // installed from the registry
56
- const dependencyPackageNodeModulesPath = path.resolve(
57
- runtimePathById.root,
58
- `node_modules/.bin/${cliCommandName}`,
59
- );
60
-
61
- // linked / workspace:^ package
62
- const dependencyWorkspacePackageNodeModulesPath = path.resolve(
63
- runtimePathById.root,
64
- `node_modules/${hostPackageName}/node_modules/.bin/${cliCommandName}`,
65
- );
66
-
67
- return fs.existsSync(dependencyPackageNodeModulesPath)
68
- ? dependencyPackageNodeModulesPath
69
- : dependencyWorkspacePackageNodeModulesPath;
70
- */
71
34
  const hostPackageDependencyBinCLICommandPath = path.resolve(runtimePathById.root, `node_modules/${hostPackageName}/node_modules/.bin/${cliCommandName}`);
72
- return fileURLToPath(import.meta.resolve(hostPackageDependencyBinCLICommandPath));
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));
73
42
  }
74
43
  export { resolveHostPackageBinForCLICommandPath, resolveHostPackageNodeModulesPath, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mainset/cli",
3
- "version": "0.2.1-rc.1",
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": {