build headless
Summary: - create a zip-file when building the headless version of Flipper - restore pkg cache in Sandcastle from pantri - run build script in sandcastle. Changes need to go together with D13942919 Reviewed By: passy Differential Revision: D13942701 fbshipit-source-id: caac7d6cda99fec2a6836c652957ff609a0bf8bb
This commit is contained in:
committed by
Facebook Github Bot
parent
dc9160d05c
commit
e78bd57514
@@ -101,7 +101,8 @@
|
|||||||
"which": "^1.3.1",
|
"which": "^1.3.1",
|
||||||
"ws": "^6.1.2",
|
"ws": "^6.1.2",
|
||||||
"xml2js": "^0.4.19",
|
"xml2js": "^0.4.19",
|
||||||
"yargs": "^11.0.0"
|
"yargs": "^11.0.0",
|
||||||
|
"yazl": "^2.5.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "node scripts/yarn-install.js",
|
"postinstall": "node scripts/yarn-install.js",
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const lineReplace = require('line-replace');
|
const lineReplace = require('line-replace');
|
||||||
|
const yazl = require('yazl');
|
||||||
const {exec: createBinary} = require('pkg');
|
const {exec: createBinary} = require('pkg');
|
||||||
const {
|
const {
|
||||||
buildFolder,
|
buildFolder,
|
||||||
@@ -15,6 +17,8 @@ const {
|
|||||||
getVersionNumber,
|
getVersionNumber,
|
||||||
} = require('./build-utils.js');
|
} = require('./build-utils.js');
|
||||||
|
|
||||||
|
const PLUGINS_FOLDER_NAME = 'plugins';
|
||||||
|
|
||||||
function preludeBundle(dir, versionNumber) {
|
function preludeBundle(dir, versionNumber) {
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
lineReplace({
|
lineReplace({
|
||||||
@@ -27,25 +31,53 @@ function preludeBundle(dir, versionNumber) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createZip(buildDir, distDir, targets) {
|
||||||
|
return Promise.all(
|
||||||
|
targets.map(
|
||||||
|
target =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const zip = new yazl.ZipFile();
|
||||||
|
const binary = `flipper-${target === 'mac' ? 'macos' : target}`;
|
||||||
|
zip.addFile(path.join(buildDir, binary), binary);
|
||||||
|
const pluginDir = path.join(buildDir, PLUGINS_FOLDER_NAME);
|
||||||
|
fs.readdirSync(pluginDir).forEach(file => {
|
||||||
|
zip.addFile(
|
||||||
|
path.join(pluginDir, file),
|
||||||
|
path.join(PLUGINS_FOLDER_NAME, file),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
zip.outputStream
|
||||||
|
.pipe(
|
||||||
|
fs.createWriteStream(
|
||||||
|
path.join(distDir, `Flipper-headless-${target}.zip`),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.on('close', resolve);
|
||||||
|
zip.end();
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const targets = [];
|
const targets = {};
|
||||||
let platformPostfix;
|
let platformPostfix;
|
||||||
|
|
||||||
if (process.argv.indexOf('--mac') > -1) {
|
if (process.argv.indexOf('--mac') > -1) {
|
||||||
targets.push('node10-macos-x64');
|
targets.mac = 'node10-macos-x64';
|
||||||
platformPostfix = '-macos';
|
platformPostfix = '-macos';
|
||||||
}
|
}
|
||||||
if (process.argv.indexOf('--linux') > -1) {
|
if (process.argv.indexOf('--linux') > -1) {
|
||||||
targets.push('node10-linux-x64');
|
targets.linux = 'node10-linux-x64';
|
||||||
platformPostfix = '-linux';
|
platformPostfix = '-linux';
|
||||||
}
|
}
|
||||||
if (process.argv.indexOf('--win') > -1) {
|
if (process.argv.indexOf('--win') > -1) {
|
||||||
targets.push('node10-win-x64');
|
targets.win = 'node10-win-x64';
|
||||||
platformPostfix = '-win';
|
platformPostfix = '-win';
|
||||||
}
|
}
|
||||||
if (targets.length === 0) {
|
if (targets.length === 0) {
|
||||||
throw new Error('No targets specified. eg. --mac, --win, or --linux');
|
throw new Error('No targets specified. eg. --mac, --win, or --linux');
|
||||||
} else if (targets.length > 1) {
|
} else if (Object.keys(targets).length > 1) {
|
||||||
// platformPostfix is automatically added by pkg
|
// platformPostfix is automatically added by pkg
|
||||||
platformPostfix = '';
|
platformPostfix = '';
|
||||||
}
|
}
|
||||||
@@ -58,14 +90,16 @@ function preludeBundle(dir, versionNumber) {
|
|||||||
await compile(buildDir, path.join(__dirname, '..', 'headless', 'index.js'));
|
await compile(buildDir, path.join(__dirname, '..', 'headless', 'index.js'));
|
||||||
const versionNumber = getVersionNumber();
|
const versionNumber = getVersionNumber();
|
||||||
await preludeBundle(buildDir, versionNumber);
|
await preludeBundle(buildDir, versionNumber);
|
||||||
await compileDefaultPlugins(path.join(distDir, 'plugins'));
|
await compileDefaultPlugins(path.join(buildDir, PLUGINS_FOLDER_NAME));
|
||||||
await createBinary([
|
await createBinary([
|
||||||
path.join(buildDir, 'bundle.js'),
|
path.join(buildDir, 'bundle.js'),
|
||||||
'--output',
|
'--output',
|
||||||
path.join(distDir, `flipper${platformPostfix}`),
|
path.join(buildDir, `flipper${platformPostfix}`),
|
||||||
'--targets',
|
'--targets',
|
||||||
targets.join(','),
|
Object.values(targets).join(','),
|
||||||
|
'--debug',
|
||||||
]);
|
]);
|
||||||
|
await createZip(buildDir, distDir, Object.keys(targets));
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('✨ Done');
|
console.log('✨ Done');
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ function compile(buildFolder, entry) {
|
|||||||
'index.js',
|
'index.js',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
resolver: {
|
||||||
|
blacklistRE: /\/sonar\/dist\//,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dev: false,
|
dev: false,
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ async function compilePlugin(
|
|||||||
'index.js',
|
'index.js',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
resolver: {
|
||||||
|
blacklistRE: /\/sonar\/dist\//,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
entry: entry.replace(rootDir, '.'),
|
entry: entry.replace(rootDir, '.'),
|
||||||
|
|||||||
12
yarn.lock
12
yarn.lock
@@ -1455,6 +1455,11 @@ bser@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
node-int64 "^0.4.0"
|
node-int64 "^0.4.0"
|
||||||
|
|
||||||
|
buffer-crc32@~0.2.3:
|
||||||
|
version "0.2.13"
|
||||||
|
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
|
||||||
|
integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=
|
||||||
|
|
||||||
buffer-from@^1.0.0:
|
buffer-from@^1.0.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
|
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
|
||||||
@@ -7409,6 +7414,13 @@ yauzl@2.4.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fd-slicer "~1.0.1"
|
fd-slicer "~1.0.1"
|
||||||
|
|
||||||
|
yazl@^2.5.1:
|
||||||
|
version "2.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.5.1.tgz#a3d65d3dd659a5b0937850e8609f22fffa2b5c35"
|
||||||
|
integrity sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==
|
||||||
|
dependencies:
|
||||||
|
buffer-crc32 "~0.2.3"
|
||||||
|
|
||||||
yeast@0.1.2:
|
yeast@0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
||||||
|
|||||||
Reference in New Issue
Block a user