@automattic/vip 3.25.0 → 3.25.2-dev.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/AGENTS.md +6 -0
- package/CLAUDE.md +1 -0
- package/assets/dev-env.lando.template.yml.ejs +5 -0
- package/dist/bin/vip-dev-env-exec.js +18 -1
- package/dist/bin/vip-import.js +1 -1
- package/dist/bin/vip-sea.js +19 -0
- package/dist/bin/vip.js +111 -69
- package/dist/commands/dev-env-import-sql.js +1 -1
- package/dist/lib/cli/command.js +224 -53
- package/dist/lib/cli/config.js +13 -5
- package/dist/lib/cli/exit.js +2 -1
- package/dist/lib/cli/internal-bin-loader.js +81 -0
- package/dist/lib/cli/runtime-mode.js +21 -0
- package/dist/lib/cli/sea-dispatch.js +88 -0
- package/dist/lib/cli/sea-runtime.js +75 -0
- package/dist/lib/constants/dev-environment.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +9 -2
- package/dist/lib/dev-environment/dev-environment-core.js +62 -4
- package/dist/lib/dev-environment/dev-environment-lando.js +47 -10
- package/dist/lib/dev-environment/lando-loader.js +48 -0
- package/docs/COMMANDER-MIGRATION.md +55 -0
- package/docs/SEA-BUILD-SIGNING.md +171 -0
- package/helpers/build-sea.js +167 -0
- package/npm-shrinkwrap.json +877 -627
- package/package.json +9 -6
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { buildSync } = require( 'esbuild' );
|
|
4
|
+
const { spawnSync } = require( 'node:child_process' );
|
|
5
|
+
const { chmodSync, copyFileSync, mkdirSync, readFileSync, writeFileSync } = require( 'node:fs' );
|
|
6
|
+
const path = require( 'node:path' );
|
|
7
|
+
const tar = require( 'tar' );
|
|
8
|
+
|
|
9
|
+
const SEA_FUSE = 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2';
|
|
10
|
+
|
|
11
|
+
const projectRoot = path.resolve( __dirname, '..' );
|
|
12
|
+
const seaDir = path.join( projectRoot, 'dist', 'sea' );
|
|
13
|
+
const bundlePath = path.join( seaDir, 'vip.bundle.cjs' );
|
|
14
|
+
const blobPath = path.join( seaDir, 'vip.blob' );
|
|
15
|
+
const seaConfigPath = path.join( seaDir, 'sea-config.json' );
|
|
16
|
+
const executablePath = path.join( seaDir, process.platform === 'win32' ? 'vip.exe' : 'vip' );
|
|
17
|
+
const nodeModulesArchivePath = path.join( seaDir, 'node_modules.tgz' );
|
|
18
|
+
|
|
19
|
+
function run( command, args, options = {} ) {
|
|
20
|
+
const result = spawnSync( command, args, {
|
|
21
|
+
cwd: projectRoot,
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
...options,
|
|
24
|
+
} );
|
|
25
|
+
|
|
26
|
+
if ( result.status !== 0 ) {
|
|
27
|
+
process.exit( result.status || 1 );
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ensureNode22() {
|
|
32
|
+
const major = Number( process.versions.node.split( '.' )[ 0 ] );
|
|
33
|
+
if ( major !== 22 ) {
|
|
34
|
+
console.error(
|
|
35
|
+
`Error: SEA build requires Node 22.x. Current version is ${ process.versions.node }.`
|
|
36
|
+
);
|
|
37
|
+
process.exit( 1 );
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function createRuntimeArchive() {
|
|
42
|
+
await tar.c(
|
|
43
|
+
{
|
|
44
|
+
cwd: projectRoot,
|
|
45
|
+
file: nodeModulesArchivePath,
|
|
46
|
+
gzip: true,
|
|
47
|
+
portable: true,
|
|
48
|
+
noMtime: true,
|
|
49
|
+
},
|
|
50
|
+
[ 'node_modules' ]
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function writeSeaConfig() {
|
|
55
|
+
const config = {
|
|
56
|
+
main: bundlePath,
|
|
57
|
+
output: blobPath,
|
|
58
|
+
disableExperimentalSEAWarning: true,
|
|
59
|
+
assets: {
|
|
60
|
+
'dev-env.lando.template.yml.ejs': path.join(
|
|
61
|
+
projectRoot,
|
|
62
|
+
'assets',
|
|
63
|
+
'dev-env.lando.template.yml.ejs'
|
|
64
|
+
),
|
|
65
|
+
'dev-env.nginx.template.conf.ejs': path.join(
|
|
66
|
+
projectRoot,
|
|
67
|
+
'assets',
|
|
68
|
+
'dev-env.nginx.template.conf.ejs'
|
|
69
|
+
),
|
|
70
|
+
'sea.node_modules.tgz': nodeModulesArchivePath,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
writeFileSync( seaConfigPath, `${ JSON.stringify( config, null, 2 ) }\n`, 'utf8' );
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function buildBundle() {
|
|
78
|
+
buildSync( {
|
|
79
|
+
entryPoints: [ path.join( projectRoot, 'src', 'bin', 'vip-sea.js' ) ],
|
|
80
|
+
bundle: true,
|
|
81
|
+
platform: 'node',
|
|
82
|
+
target: 'node22',
|
|
83
|
+
format: 'cjs',
|
|
84
|
+
outfile: bundlePath,
|
|
85
|
+
external: [
|
|
86
|
+
'@postman/node-keytar',
|
|
87
|
+
'@postman/node-keytar/*',
|
|
88
|
+
'cpu-features',
|
|
89
|
+
'cpu-features/*',
|
|
90
|
+
'lando',
|
|
91
|
+
'lando/*',
|
|
92
|
+
'ssh2',
|
|
93
|
+
'ssh2/*',
|
|
94
|
+
'*.node',
|
|
95
|
+
],
|
|
96
|
+
} );
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function stripBundleShebang() {
|
|
100
|
+
const bundleContent = readFileSync( bundlePath, 'utf8' );
|
|
101
|
+
if ( ! bundleContent.startsWith( '#!' ) ) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
writeFileSync( bundlePath, bundleContent.replace( /^#![^\n]*\n/, '' ), 'utf8' );
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function buildBlob() {
|
|
109
|
+
run( process.execPath, [ '--experimental-sea-config', seaConfigPath ] );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function prepareExecutable() {
|
|
113
|
+
copyFileSync( process.execPath, executablePath );
|
|
114
|
+
|
|
115
|
+
if ( process.platform === 'darwin' ) {
|
|
116
|
+
run( 'codesign', [ '--remove-signature', executablePath ] );
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function injectBlob() {
|
|
121
|
+
const postjectCli = require.resolve( 'postject/dist/cli.js' );
|
|
122
|
+
const args = [
|
|
123
|
+
postjectCli,
|
|
124
|
+
executablePath,
|
|
125
|
+
'NODE_SEA_BLOB',
|
|
126
|
+
blobPath,
|
|
127
|
+
'--sentinel-fuse',
|
|
128
|
+
SEA_FUSE,
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
if ( process.platform === 'darwin' ) {
|
|
132
|
+
args.push( '--macho-segment-name', 'NODE_SEA' );
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ( process.platform === 'win32' ) {
|
|
136
|
+
args.push( '--overwrite' );
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
run( process.execPath, args );
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function finalizeExecutable() {
|
|
143
|
+
if ( process.platform === 'darwin' ) {
|
|
144
|
+
run( 'codesign', [ '--sign', '-', '--force', executablePath ] );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if ( process.platform !== 'win32' ) {
|
|
148
|
+
chmodSync( executablePath, 0o755 );
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function main() {
|
|
153
|
+
ensureNode22();
|
|
154
|
+
mkdirSync( seaDir, { recursive: true } );
|
|
155
|
+
await createRuntimeArchive();
|
|
156
|
+
writeSeaConfig();
|
|
157
|
+
buildBundle();
|
|
158
|
+
stripBundleShebang();
|
|
159
|
+
buildBlob();
|
|
160
|
+
prepareExecutable();
|
|
161
|
+
injectBlob();
|
|
162
|
+
finalizeExecutable();
|
|
163
|
+
|
|
164
|
+
console.log( `SEA executable written to ${ executablePath }` );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void main();
|