@codevector/cli 0.5.0 → 0.5.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.
- package/dist/index.js +254 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +14 -4
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 1. Migrate legacy single-profile credentials.json to the multi-profile
|
|
7
7
|
* format introduced in v0.4.0.
|
|
8
|
-
* 2.
|
|
9
|
-
* parsed out of `process.env.npm_config_user_agent`,
|
|
10
|
-
* `~/.config/codevector/install.json` so
|
|
11
|
-
* the same manager without prompting.
|
|
8
|
+
* 2. On a *global* install, detect which package manager invoked it
|
|
9
|
+
* (npm / pnpm / yarn), parsed out of `process.env.npm_config_user_agent`,
|
|
10
|
+
* and persist it to `~/.config/codevector/install.json` so
|
|
11
|
+
* `codevector update` can use the same manager without prompting.
|
|
12
|
+
* Non-global installs are skipped so a monorepo dev install can't
|
|
13
|
+
* clobber the record.
|
|
12
14
|
*
|
|
13
15
|
* Runs automatically after `npm install` / `pnpm install` / `yarn add`.
|
|
14
16
|
* Zero external dependencies — only Node built-ins. Any error is silently
|
|
@@ -83,6 +85,14 @@ function migrateCredentialsIfNeeded() {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
function capturePackageManagerIfPossible() {
|
|
88
|
+
// Only record on a genuine global install. Otherwise a non-global install
|
|
89
|
+
// that runs this script — most commonly the monorepo's own `pnpm install`,
|
|
90
|
+
// where this CLI is a workspace package — would clobber install.json with
|
|
91
|
+
// the wrong manager. npm, pnpm, and yarn all set npm_config_global=true for
|
|
92
|
+
// `-g` installs. When the binary isn't global, `codevector update` infers
|
|
93
|
+
// the manager from the install path instead.
|
|
94
|
+
if (process.env.npm_config_global !== "true") return;
|
|
95
|
+
|
|
86
96
|
const pm = detectPackageManager();
|
|
87
97
|
if (!pm) return;
|
|
88
98
|
|