Set up a script to automate builds, and support native extensions

This commit is contained in:
Tim Perry 2017-12-13 15:08:36 +01:00
parent 7681003512
commit e8c19df8c9
2 changed files with 39 additions and 1 deletions

34
automation/build-bin.ts Normal file
View File

@ -0,0 +1,34 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import * as FileHound from 'filehound';
import { exec as execPkg } from 'pkg';
const ROOT = path.join(__dirname, '..');
console.log('Building package...\n');
execPkg([
'--target', 'host',
'--output', 'build-bin/resin',
'package.json'
]).then(() => fs.copy(
path.join(ROOT, 'node_modules', 'opn', 'xdg-open'),
path.join(ROOT, 'build-bin', 'xdg-open')
)).then(() => {
return FileHound.create()
.paths(path.join(ROOT, 'node_modules'))
.ext(['node', 'dll'])
.find();
}).then((nativeExtensions: string[]) => {
console.log(`\nCopying to build-bin:\n${nativeExtensions.join('\n')}`);
return nativeExtensions.map((extPath) => {
return fs.copy(
extPath,
extPath.replace(
path.join(ROOT, 'node_modules'),
path.join(ROOT, 'build-bin')
)
);
});
});

View File

@ -31,7 +31,7 @@
"prebuild": "rimraf build/ build-bin/",
"build": "npm run build:src && npm run build:bin",
"build:src": "gulp build && tsc && npm run doc",
"build:bin": "pkg . -t host -o build-bin/resin && cp node_modules/opn/xdg-open build-bin/",
"build:bin": "ts-node automation/build-bin.ts",
"pretest": "npm run build",
"test": "gulp test",
"ci": "npm run test && catch-uncommitted",
@ -51,8 +51,11 @@
"node": ">=6.0"
},
"devDependencies": {
"@types/fs-extra": "^5.0.0",
"catch-uncommitted": "^1.0.0",
"ent": "^2.2.0",
"filehound": "^1.16.2",
"fs-extra": "^5.0.0",
"gulp": "^3.9.0",
"gulp-coffee": "^2.2.0",
"gulp-coffeelint": "^0.6.0",
@ -62,6 +65,7 @@
"mochainon": "^2.0.0",
"pkg": "^4.3.0-beta.1",
"require-npm4-to-publish": "^1.0.0",
"ts-node": "^4.0.1",
"typescript": "^2.6.1"
},
"dependencies": {