@vercel/vc-native 54.6.1 → 54.7.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/bin/vercel.exe +6 -0
- package/package.json +13 -9
- package/postinstall.mjs +121 -0
- package/bin/vercel +0 -85
package/bin/vercel.exe
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/vc-native",
|
|
3
|
-
"version": "54.
|
|
3
|
+
"version": "54.7.0",
|
|
4
4
|
"description": "Native Vercel CLI installer for npm",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -10,18 +10,22 @@
|
|
|
10
10
|
"directory": "packages/vc-native"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
|
-
"vercel": "./bin/vercel",
|
|
14
|
-
"vc": "./bin/vercel"
|
|
13
|
+
"vercel": "./bin/vercel.exe",
|
|
14
|
+
"vc": "./bin/vercel.exe"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"postinstall": "node ./postinstall.mjs"
|
|
15
18
|
},
|
|
16
19
|
"optionalDependencies": {
|
|
17
|
-
"@vercel/vc-native-darwin-arm64": "54.
|
|
18
|
-
"@vercel/vc-native-darwin-x64": "54.
|
|
19
|
-
"@vercel/vc-native-linux-arm64": "54.
|
|
20
|
-
"@vercel/vc-native-linux-x64": "54.
|
|
21
|
-
"@vercel/vc-native-win32-x64": "54.
|
|
20
|
+
"@vercel/vc-native-darwin-arm64": "54.7.0",
|
|
21
|
+
"@vercel/vc-native-darwin-x64": "54.7.0",
|
|
22
|
+
"@vercel/vc-native-linux-arm64": "54.7.0",
|
|
23
|
+
"@vercel/vc-native-linux-x64": "54.7.0",
|
|
24
|
+
"@vercel/vc-native-win32-x64": "54.7.0"
|
|
22
25
|
},
|
|
23
26
|
"files": [
|
|
24
|
-
"bin"
|
|
27
|
+
"bin",
|
|
28
|
+
"postinstall.mjs"
|
|
25
29
|
],
|
|
26
30
|
"publishConfig": {
|
|
27
31
|
"access": "public"
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import childProcess from 'child_process';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { createRequire } from 'module';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const packageJson = JSON.parse(
|
|
13
|
+
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8')
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const platformMap = {
|
|
17
|
+
darwin: 'darwin',
|
|
18
|
+
linux: 'linux',
|
|
19
|
+
win32: 'win32',
|
|
20
|
+
};
|
|
21
|
+
const archMap = {
|
|
22
|
+
x64: 'x64',
|
|
23
|
+
arm64: 'arm64',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const platform = platformMap[os.platform()] ?? os.platform();
|
|
27
|
+
const arch = archMap[os.arch()] ?? os.arch();
|
|
28
|
+
const packageName = `@vercel/vc-native-${platform}-${arch}`;
|
|
29
|
+
const sourceBinary = platform === 'win32' ? 'vercel.exe' : 'vercel';
|
|
30
|
+
const targetBinary = path.join(__dirname, 'bin', 'vercel.exe');
|
|
31
|
+
|
|
32
|
+
function packageNames() {
|
|
33
|
+
return [packageName];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolveBinary(name) {
|
|
37
|
+
const packageJsonPath = require.resolve(`${name}/package.json`);
|
|
38
|
+
const binaryPath = path.join(
|
|
39
|
+
path.dirname(packageJsonPath),
|
|
40
|
+
'bin',
|
|
41
|
+
sourceBinary
|
|
42
|
+
);
|
|
43
|
+
if (!fs.existsSync(binaryPath)) {
|
|
44
|
+
throw new Error(`Binary not found at ${binaryPath}`);
|
|
45
|
+
}
|
|
46
|
+
return binaryPath;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function installPackage(name) {
|
|
50
|
+
const version = packageJson.optionalDependencies?.[name];
|
|
51
|
+
if (!version) return;
|
|
52
|
+
|
|
53
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'vc-native-install-'));
|
|
54
|
+
try {
|
|
55
|
+
const result = childProcess.spawnSync(
|
|
56
|
+
'npm',
|
|
57
|
+
[
|
|
58
|
+
'install',
|
|
59
|
+
'--ignore-scripts',
|
|
60
|
+
'--no-save',
|
|
61
|
+
'--loglevel=error',
|
|
62
|
+
'--prefix',
|
|
63
|
+
temp,
|
|
64
|
+
`${name}@${version}`,
|
|
65
|
+
],
|
|
66
|
+
{ stdio: 'inherit', windowsHide: true }
|
|
67
|
+
);
|
|
68
|
+
if (result.status !== 0) return;
|
|
69
|
+
const packageDir = path.join(temp, 'node_modules', ...name.split('/'));
|
|
70
|
+
copyBinary(path.join(packageDir, 'bin', sourceBinary), targetBinary);
|
|
71
|
+
return true;
|
|
72
|
+
} finally {
|
|
73
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function copyBinary(source, target) {
|
|
78
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`);
|
|
79
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
80
|
+
if (fs.existsSync(target)) fs.unlinkSync(target);
|
|
81
|
+
try {
|
|
82
|
+
fs.linkSync(source, target);
|
|
83
|
+
} catch {
|
|
84
|
+
fs.copyFileSync(source, target);
|
|
85
|
+
}
|
|
86
|
+
fs.chmodSync(target, 0o755);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function verifyBinary() {
|
|
90
|
+
const result = childProcess.spawnSync(targetBinary, ['--version'], {
|
|
91
|
+
encoding: 'utf8',
|
|
92
|
+
stdio: 'ignore',
|
|
93
|
+
windowsHide: true,
|
|
94
|
+
});
|
|
95
|
+
return result.status === 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function main() {
|
|
99
|
+
for (const name of packageNames()) {
|
|
100
|
+
try {
|
|
101
|
+
copyBinary(resolveBinary(name), targetBinary);
|
|
102
|
+
if (verifyBinary()) return;
|
|
103
|
+
} catch {
|
|
104
|
+
if (installPackage(name) && verifyBinary()) return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
throw new Error(
|
|
109
|
+
`It seems your package manager failed to install the right Vercel CLI package. Try manually installing ${packageNames()
|
|
110
|
+
.map(name => JSON.stringify(name))
|
|
111
|
+
.join(' or ')}.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
main();
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// Do not fail package installation. If setup cannot install a native
|
|
119
|
+
// binary, the fallback bin shim will print a user-facing reinstall message.
|
|
120
|
+
console.warn(error.message);
|
|
121
|
+
}
|
package/bin/vercel
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess = require('node:child_process');
|
|
4
|
-
const fs = require('node:fs');
|
|
5
|
-
const os = require('node:os');
|
|
6
|
-
const path = require('node:path');
|
|
7
|
-
|
|
8
|
-
const platformPackages = {
|
|
9
|
-
darwin: {
|
|
10
|
-
arm64: '@vercel/vc-native-darwin-arm64',
|
|
11
|
-
x64: '@vercel/vc-native-darwin-x64',
|
|
12
|
-
},
|
|
13
|
-
linux: {
|
|
14
|
-
arm64: '@vercel/vc-native-linux-arm64',
|
|
15
|
-
x64: '@vercel/vc-native-linux-x64',
|
|
16
|
-
},
|
|
17
|
-
win32: {
|
|
18
|
-
x64: '@vercel/vc-native-win32-x64',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const platform = os.platform();
|
|
23
|
-
const arch = os.arch();
|
|
24
|
-
const packageName = platformPackages[platform]?.[arch];
|
|
25
|
-
|
|
26
|
-
if (!packageName) {
|
|
27
|
-
console.error(
|
|
28
|
-
`The native Vercel CLI does not support ${platform}-${arch}. Use \`npm i -g vercel\` for the Node.js-based CLI.`
|
|
29
|
-
);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const binaryName = platform === 'win32' ? 'vercel.exe' : 'vercel';
|
|
34
|
-
const binaryPath = findBinary(path.dirname(fs.realpathSync(__filename)));
|
|
35
|
-
|
|
36
|
-
if (!binaryPath) {
|
|
37
|
-
console.error(
|
|
38
|
-
`Could not find ${packageName}. Your package manager may have skipped optional dependencies. Try reinstalling with \`npm i -g @vercel/vc-native --force\`.`
|
|
39
|
-
);
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const result = childProcess.spawnSync(binaryPath, process.argv.slice(2), {
|
|
44
|
-
stdio: 'inherit',
|
|
45
|
-
env: {
|
|
46
|
-
...process.env,
|
|
47
|
-
VERCEL_VC_NATIVE: '1',
|
|
48
|
-
},
|
|
49
|
-
windowsHide: false,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (result.error) {
|
|
53
|
-
console.error(result.error.message);
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (result.signal) {
|
|
58
|
-
process.kill(process.pid, result.signal);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
process.exit(typeof result.status === 'number' ? result.status : 1);
|
|
62
|
-
|
|
63
|
-
function findBinary(startDir) {
|
|
64
|
-
let current = startDir;
|
|
65
|
-
|
|
66
|
-
for (;;) {
|
|
67
|
-
const candidate = path.join(
|
|
68
|
-
current,
|
|
69
|
-
'node_modules',
|
|
70
|
-
...packageName.split('/'),
|
|
71
|
-
'bin',
|
|
72
|
-
binaryName
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
if (fs.existsSync(candidate)) {
|
|
76
|
-
return candidate;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const parent = path.dirname(current);
|
|
80
|
-
if (parent === current) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
current = parent;
|
|
84
|
-
}
|
|
85
|
-
}
|