mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-10 15:21:03 +00:00
Exposes buildApp as a programmatic api for npm, and also shifted the main
function from cli.js to within buildApp
Merge branch 'zweicoder-expose-main'
This commit is contained in:
commit
3fa34dead5
@ -9,7 +9,7 @@
|
||||
"native",
|
||||
"wrapper"
|
||||
],
|
||||
"main": "lib/buildApp.js",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"dev-up": "npm install && (cd app && npm install) && npm run build",
|
||||
"test": "gulp test",
|
||||
|
@ -2,6 +2,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import crypto from 'crypto';
|
||||
|
||||
import optionsFactory from './options';
|
||||
import packager from 'electron-packager';
|
||||
import tmp from 'tmp';
|
||||
import ncp from 'ncp';
|
||||
@ -31,10 +32,30 @@ function buildApp(options, callback) {
|
||||
|
||||
async.waterfall([
|
||||
callback => {
|
||||
copyPlaceholderApp(options.dir, tmpPath, options.name, options.targetUrl, options.counter, options.width, options.height, options.showMenuBar, options.userAgent, callback);
|
||||
optionsFactory(
|
||||
options.appName,
|
||||
options.targetUrl,
|
||||
options.platform,
|
||||
options.arch,
|
||||
options.electronVersion,
|
||||
options.outDir,
|
||||
options.overwrite,
|
||||
options.conceal,
|
||||
options.icon,
|
||||
options.counter,
|
||||
options.width,
|
||||
options.height,
|
||||
options.showMenuBar,
|
||||
options.userAgent,
|
||||
options.honest,
|
||||
callback);
|
||||
},
|
||||
|
||||
(tempDir, callback) => {
|
||||
(options, callback) => {
|
||||
copyPlaceholderApp(options.dir, tmpPath, options.name, options.targetUrl, options.counter, options.width, options.height, options.showMenuBar, options.userAgent, (error, tempDirPath) => {
|
||||
callback(error, tempDirPath, options);
|
||||
});
|
||||
},
|
||||
(tempDir, options, callback) => {
|
||||
options.dir = tempDir;
|
||||
packager(options, callback);
|
||||
},
|
||||
|
46
src/cli.js
46
src/cli.js
@ -2,47 +2,9 @@
|
||||
|
||||
import path from 'path';
|
||||
import program from 'commander';
|
||||
import async from 'async';
|
||||
|
||||
import optionsFactory from './options';
|
||||
import buildApp from './buildApp';
|
||||
|
||||
const packageJson = require(path.join('..', 'package'));
|
||||
|
||||
function main(program) {
|
||||
async.waterfall([
|
||||
callback => {
|
||||
optionsFactory(
|
||||
program.appName,
|
||||
program.targetUrl,
|
||||
program.platform,
|
||||
program.arch,
|
||||
program.electronVersion,
|
||||
program.outDir,
|
||||
program.overwrite,
|
||||
program.conceal,
|
||||
program.icon,
|
||||
program.counter,
|
||||
program.width,
|
||||
program.height,
|
||||
program.showMenuBar,
|
||||
program.userAgent,
|
||||
program.honest,
|
||||
callback);
|
||||
},
|
||||
|
||||
(options, callback) => {
|
||||
buildApp(options, callback);
|
||||
}
|
||||
], (error, appPath) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
console.log(`App built to ${appPath}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
program
|
||||
.version(packageJson.version)
|
||||
@ -70,5 +32,11 @@ if (require.main === module) {
|
||||
program.help();
|
||||
}
|
||||
|
||||
main(program);
|
||||
buildApp(program, (error, appPath) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
console.log(`App built to ${appPath}`);
|
||||
});
|
||||
}
|
||||
|
3
src/index.js
Normal file
3
src/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import buildApp from './buildApp';
|
||||
|
||||
export default buildApp;
|
Loading…
Reference in New Issue
Block a user