@volcano.dev/cli 0.2.2 → 0.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcano.dev/cli",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for Volcano's hosting platform.",
5
5
  "keywords": [
6
6
  "volcano",
@@ -57,6 +57,32 @@ function binaryPath() {
57
57
  return path.join(__dirname, '..', '..', 'bin', assetName());
58
58
  }
59
59
 
60
+ // Which JS package manager is driving this install. During a lifecycle script
61
+ // npm/pnpm/yarn/bun all set npm_config_user_agent (e.g. "pnpm/8.6.0 ...").
62
+ function detectManager(ua = process.env.npm_config_user_agent || '') {
63
+ const name = String(ua).split('/')[0].trim().toLowerCase();
64
+ return ['npm', 'pnpm', 'yarn', 'bun'].includes(name) ? name : 'npm';
65
+ }
66
+
67
+ // Record how the CLI was installed next to the binary so `volcano upgrade`
68
+ // delegates to the right package manager. Best effort: a missing marker just
69
+ // falls back to path-based detection in the Go binary.
70
+ function writeInstallMarker() {
71
+ const ua = process.env.npm_config_user_agent;
72
+ // Only a package-manager lifecycle script sets a user agent. At shim runtime
73
+ // (self-heal after --ignore-scripts / VOLCANO_SKIP_DOWNLOAD) there is none, so
74
+ // skip the marker rather than guess `npm` and mislabel a pnpm/yarn/bun install
75
+ // — the Go binary's path-based detection is accurate in that case.
76
+ if (!ua) return;
77
+ const marker = path.join(path.dirname(binaryPath()), '.volcano-install-method');
78
+ try {
79
+ fs.mkdirSync(path.dirname(marker), { recursive: true });
80
+ fs.writeFileSync(marker, `${detectManager(ua)}\n`);
81
+ } catch {
82
+ // best effort
83
+ }
84
+ }
85
+
60
86
  function releaseTag() {
61
87
  // The npm package version maps 1:1 to the GitHub release tag `v<version>`.
62
88
  return `v${pkg.version}`;
@@ -153,6 +179,7 @@ async function downloadToFile(url, dest) {
153
179
  // against the release's SHA256SUMS manifest. Idempotent: no-op if present.
154
180
  async function ensureBinary({ force = false } = {}) {
155
181
  const dest = binaryPath();
182
+ writeInstallMarker();
156
183
  if (!force && fs.existsSync(dest)) {
157
184
  return dest;
158
185
  }