cap-copilot-sdk 0.2.4 → 0.2.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +15 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cap-copilot-sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "CDS plugin: auto-extracts entity schemas, relationships, project structure and registers with BTP Copilot backend",
5
5
  "main": "cds-plugin.js",
6
6
  "exports": {
package/postinstall.js CHANGED
@@ -18,15 +18,24 @@ const path = require("path");
18
18
  // Useful in CI/CD pipelines where package.json is read-only or managed by tooling.
19
19
  if (process.env.BTP_COPILOT_SKIP_POSTINSTALL === "1") process.exit(0);
20
20
 
21
- // INIT_CWD = directory from which `npm install` was run (the consuming app root)
22
- const appRoot = process.env.INIT_CWD;
23
-
24
-
25
21
  const isInstalledPackage = __dirname.includes("node_modules");
26
- if (!appRoot || !isInstalledPackage) {
27
- process.exit(0);
22
+ if (!isInstalledPackage) process.exit(0);
23
+
24
+ function findAppRoot() {
25
+ const fromEnv =
26
+ process.env.INIT_CWD ||
27
+ process.env.npm_config_local_prefix;
28
+ if (fromEnv) return fromEnv;
29
+ const parts = __dirname.split(path.sep);
30
+ const nmIdx = parts.lastIndexOf("node_modules");
31
+ if (nmIdx > 0) return parts.slice(0, nmIdx).join(path.sep);
32
+
33
+ return null;
28
34
  }
29
35
 
36
+ const appRoot = findAppRoot();
37
+ if (!appRoot) process.exit(0);
38
+
30
39
  const pkgPath = path.join(appRoot, "package.json");
31
40
  if (!fs.existsSync(pkgPath)) process.exit(0);
32
41