Auto stash before revert of "4.12.0"

This commit is contained in:
Daniel 2018-08-16 22:18:20 +02:00
parent 0764e28408
commit ff784a4377

View File

@ -1,4 +1,4 @@
"use strict"; 'use strict';
// Node module dependencies // Node module dependencies
const fs = require('fs-extra-promise').useFs(require('fs-extra')), const fs = require('fs-extra-promise').useFs(require('fs-extra')),
queue = require('queue'), queue = require('queue'),
@ -15,22 +15,21 @@ const ROOT = path.resolve(path.join(__dirname, '../../')), // root ionic-native
BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/@ionic-native'), // dist directory root path BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/@ionic-native'), // dist directory root path
BUILD_CORE_DIST = path.resolve(BUILD_DIST_ROOT, 'core'); // core dist directory path BUILD_CORE_DIST = path.resolve(BUILD_DIST_ROOT, 'core'); // core dist directory path
// dependency versions // dependency versions
const ANGULAR_VERSION = '*', const ANGULAR_VERSION = '*',
RXJS_VERSION = '^5.0.1', RXJS_VERSION = '^5.5.11',
MIN_CORE_VERSION = '^4.2.0', MIN_CORE_VERSION = '^4.11.0',
IONIC_NATIVE_VERSION = require(path.resolve(ROOT, 'package.json')).version; IONIC_NATIVE_VERSION = require(path.resolve(ROOT, 'package.json')).version;
// package dependencies // package dependencies
const CORE_PEER_DEPS = { const CORE_PEER_DEPS = {
'rxjs': RXJS_VERSION rxjs: RXJS_VERSION
}; };
const PLUGIN_PEER_DEPS = { const PLUGIN_PEER_DEPS = {
'@ionic-native/core': MIN_CORE_VERSION, '@ionic-native/core': MIN_CORE_VERSION,
'@angular/core': ANGULAR_VERSION, '@angular/core': ANGULAR_VERSION,
'rxjs': RXJS_VERSION rxjs: RXJS_VERSION
}; };
// set peer dependencies for all plugins // set peer dependencies for all plugins
@ -44,8 +43,10 @@ fs.mkdirpSync(BUILD_TMP);
console.log('Preparing core module package.json'); console.log('Preparing core module package.json');
CORE_PACKAGE_JSON.version = IONIC_NATIVE_VERSION; CORE_PACKAGE_JSON.version = IONIC_NATIVE_VERSION;
CORE_PACKAGE_JSON.peerDependencies = CORE_PEER_DEPS; CORE_PACKAGE_JSON.peerDependencies = CORE_PEER_DEPS;
fs.writeJsonSync(path.resolve(BUILD_CORE_DIST, 'package.json'), CORE_PACKAGE_JSON); fs.writeJsonSync(
path.resolve(BUILD_CORE_DIST, 'package.json'),
CORE_PACKAGE_JSON
);
// Fetch a list of the plugins // Fetch a list of the plugins
const PLUGINS = fs.readdirSync(PLUGINS_PATH); const PLUGINS = fs.readdirSync(PLUGINS_PATH);
@ -59,7 +60,9 @@ const index = pluginsToBuild.indexOf('ignore-errors');
if (index > -1) { if (index > -1) {
ignoreErrors = true; ignoreErrors = true;
pluginsToBuild.splice(index, 1); pluginsToBuild.splice(index, 1);
console.log('Build will continue even if errors were thrown. Errors will be printed when build finishes.'); console.log(
'Build will continue even if errors were thrown. Errors will be printed when build finishes.'
);
} }
if (!pluginsToBuild.length) { if (!pluginsToBuild.length) {
@ -71,12 +74,9 @@ const QUEUE = queue({
concurrency: require('os').cpus().length concurrency: require('os').cpus().length
}); });
// Function to process a single plugin // Function to process a single plugin
const addPluginToQueue = pluginName => { const addPluginToQueue = pluginName => {
QUEUE.push(callback => {
QUEUE.push((callback) => {
console.log(`Building plugin: ${pluginName}`); console.log(`Building plugin: ${pluginName}`);
const PLUGIN_BUILD_DIR = path.resolve(BUILD_TMP, 'plugins', pluginName), const PLUGIN_BUILD_DIR = path.resolve(BUILD_TMP, 'plugins', pluginName),
@ -87,7 +87,6 @@ const addPluginToQueue = pluginName => {
fs.mkdirpAsync(PLUGIN_BUILD_DIR) // create tmp build dir fs.mkdirpAsync(PLUGIN_BUILD_DIR) // create tmp build dir
.then(() => fs.mkdirpAsync(path.resolve(BUILD_DIST_ROOT, pluginName))) // create dist dir .then(() => fs.mkdirpAsync(path.resolve(BUILD_DIST_ROOT, pluginName))) // create dist dir
.then(() => { .then(() => {
// Write tsconfig.json // Write tsconfig.json
const tsConfig = JSON.parse(JSON.stringify(PLUGIN_TS_CONFIG)); const tsConfig = JSON.parse(JSON.stringify(PLUGIN_TS_CONFIG));
tsConfig.files = [PLUGIN_SRC_PATH]; tsConfig.files = [PLUGIN_SRC_PATH];
@ -104,42 +103,39 @@ const addPluginToQueue = pluginName => {
packageJson.name = `@ionic-native/${pluginName}`; packageJson.name = `@ionic-native/${pluginName}`;
packageJson.version = IONIC_NATIVE_VERSION; packageJson.version = IONIC_NATIVE_VERSION;
return fs.writeJsonAsync(path.resolve(BUILD_DIST_ROOT, pluginName, 'package.json'), packageJson); return fs.writeJsonAsync(
path.resolve(BUILD_DIST_ROOT, pluginName, 'package.json'),
packageJson
);
}) })
.then(() => { .then(() => {
// compile the plugin // compile the plugin
exec(`${ROOT}/node_modules/.bin/ngc -p ${tsConfigPath}`, (err, stdout, stderr) => { exec(
`${ROOT}/node_modules/.bin/ngc -p ${tsConfigPath}`,
if (err) { (err, stdout, stderr) => {
if (err) {
if (!ignoreErrors) { if (!ignoreErrors) {
// oops! something went wrong. // oops! something went wrong.
console.log(err); console.log(err);
callback(`\n\nBuilding ${pluginName} failed.`); callback(`\n\nBuilding ${pluginName} failed.`);
return; return;
} else { } else {
errors.push(err); errors.push(err);
}
} }
// we're done with this plugin!
callback();
} }
);
// we're done with this plugin!
callback();
});
}) })
.catch(callback); .catch(callback);
}); // QUEUE.push end }); // QUEUE.push end
}; };
pluginsToBuild.forEach(addPluginToQueue); pluginsToBuild.forEach(addPluginToQueue);
QUEUE.start((err) => { QUEUE.start(err => {
if (err) { if (err) {
console.log('Error building plugins.'); console.log('Error building plugins.');
console.log(err); console.log(err);
@ -155,5 +151,4 @@ QUEUE.start((err) => {
} else { } else {
console.log('Done processing plugins!'); console.log('Done processing plugins!');
} }
}); });