1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+ const { execSync } = require ( 'child_process' ) ;
4+
5+ // Read package.json to compute VSIX file name as <name>-<version>.vsix
6+ const pkg = require ( '../package.json' ) ;
7+ const vsixName = `${ pkg . name } -${ pkg . version } .vsix` ;
8+
9+ // VSIX output path (saved at repo root)
10+ const vsixSource = path . resolve ( __dirname , '..' , vsixName ) ;
11+
12+ // Target directory for smoke tests (Windows/macOS friendly)
13+ const targetDir = path . resolve (
14+ process . env . USERPROFILE || process . env . HOME || '' ,
15+ 'vscode-extensions' ,
16+ 'vscode-react-native' ,
17+ 'test' ,
18+ 'smoke' ,
19+ 'resources' ,
20+ 'extension'
21+ ) ;
22+
23+ function buildVsix ( ) {
24+ console . log ( '📦 Packaging VSIX...' ) ;
25+ execSync ( `npx vsce package -o "${ vsixSource } "` , { stdio : 'inherit' } ) ;
26+ if ( ! fs . existsSync ( vsixSource ) ) {
27+ throw new Error ( '❌ VSIX not found. Ensure `vsce package` succeeded and entry file is not ignored.' ) ;
28+ }
29+ console . log ( `✅ VSIX packaged: ${ vsixSource } ` ) ;
30+ }
31+
32+ function copyVsix ( ) {
33+ console . log ( '📂 Copying VSIX to smoke resources...' ) ;
34+ if ( ! fs . existsSync ( targetDir ) ) fs . mkdirSync ( targetDir , { recursive : true } ) ;
35+ const targetPath = path . join ( targetDir , path . basename ( vsixSource ) ) ;
36+ fs . copyFileSync ( vsixSource , targetPath ) ;
37+ console . log ( `✅ Copied to: ${ targetPath } ` ) ;
38+ }
39+
40+ function runSmokeTests ( ) {
41+ console . log ( '🚀 Running smoke tests...' ) ;
42+ execSync ( 'npm run smoke-tests' , { stdio : 'inherit' } ) ;
43+ console . log ( '✅ Smoke tests completed' ) ;
44+ }
45+
46+ try {
47+ buildVsix ( ) ;
48+ copyVsix ( ) ;
49+ if ( process . argv . includes ( '--test' ) ) {
50+ runSmokeTests ( ) ;
51+ }
52+ } catch ( err ) {
53+ console . error ( err . message || err ) ;
54+ process . exit ( 1 ) ;
55+ }
0 commit comments