Improved build-release open args
Summary: Improved `flipper:build-release` command with several options as suggested in earlier reviews. Flags added: * `--npx` install using npx and start * `--start` run directly from the build folder * `--open` icmw previous two, spawn a browser This should generally benefit developing from for example an on-demand server (although current socket access is currently only open to local host, so a port forward or remote entry point needs to be set up) Reviewed By: antonk52 Differential Revision: D33308198 fbshipit-source-id: fb905647c8d9fbda9d3efc2bfdcbd4d03be84938
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cbda298b9d
commit
bc98a77cf7
@@ -41,8 +41,21 @@ const argv = yargs
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
start: {
|
||||
describe:
|
||||
'Start flipper-server from the build folder after compiling it.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
npx: {
|
||||
describe:
|
||||
'Install flipper-server to the local system using NPX and start it',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
open: {
|
||||
describe: 'Open Flipper in the default browser after starting',
|
||||
describe:
|
||||
'Open Flipper in the default browser after starting. Should be combined with --start or --npx',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
@@ -188,6 +201,9 @@ async function modifyPackageManifest(
|
||||
manifest.revision = hgRevision;
|
||||
}
|
||||
manifest.releaseChannel = channel;
|
||||
// not needed in public builds
|
||||
delete manifest.scripts;
|
||||
delete manifest.devDependencies;
|
||||
await fs.writeFile(
|
||||
path.join(buildFolder, 'package.json'),
|
||||
JSON.stringify(manifest, null, ' '),
|
||||
@@ -231,12 +247,21 @@ async function modifyPackageManifest(
|
||||
`✅ flipper-release-build completed, version ${versionNumber} in ${dir}`,
|
||||
);
|
||||
|
||||
if (argv.open) {
|
||||
if (argv.npx) {
|
||||
// This is a hack, as npx cached very aggressively if package.version
|
||||
// didn't change
|
||||
console.log(`⚙️ Installing flipper-server.tgz using npx`);
|
||||
await fs.remove(path.join(homedir(), '.npm', '_npx'));
|
||||
await spawn('npx', [archive], {
|
||||
await spawn('npx', [archive, argv.open ? '--open' : '--no-open'], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
} else if (argv.start) {
|
||||
console.log(`⚙️ Starting flipper-server from build dir`);
|
||||
await spawn('yarn', ['install', '--production', '--no-lockfile'], {
|
||||
cwd: dir,
|
||||
});
|
||||
await spawn('./server.js', [argv.open ? '--open' : '--no-open'], {
|
||||
cwd: dir,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user