Extend IonicNativePlugin

This commit is contained in:
Ibby Hadeed 2017-12-28 22:12:48 -05:00
parent 2f5f34c2c5
commit 542e7d24f0
No known key found for this signature in database
GPG Key ID: 1CA08EB11DAAA786
5 changed files with 66 additions and 23 deletions

21
package-lock.json generated
View File

@ -507,6 +507,27 @@
"integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=",
"dev": true
},
"async-promise-queue": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/async-promise-queue/-/async-promise-queue-1.0.4.tgz",
"integrity": "sha512-GQ5X3DT+TefYuFPHdvIPXFTlKnh39U7dwtl+aUBGeKjMea9nBpv3c91DXgeyBQmY07vQ97f3Sr9XHqkamEameQ==",
"dev": true,
"requires": {
"async": "2.6.0",
"debug": "2.6.9"
},
"dependencies": {
"async": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
"dev": true,
"requires": {
"lodash": "4.17.4"
}
}
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",

View File

@ -18,7 +18,8 @@
"lint": "gulp lint",
"readmes": "gulp readmes",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"postchangelog": "git commit -am \"chore(): update changelog\""
"postchangelog": "git commit -am \"chore(): update changelog\"",
"shipit": "npm run build && npm run readmes && npm run npmpub"
},
"devDependencies": {
"@angular/common": "latest",
@ -32,6 +33,7 @@
"@types/node": "8.0.47",
"@types/rimraf": "^2.0.2",
"@types/webpack": "^3.8.1",
"async-promise-queue": "^1.0.4",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babelify": "^8.0.0",

View File

@ -25,7 +25,7 @@ const webpackConfig: webpack.Configuration = {
modules: ['node_modules'],
extensions: ['.js'],
alias: {
'@ionic-native/core': path.resolve(DIST, 'core/index.js')
'@ionic-native/core': path.resolve(DIST, '@ionic-native/core/index.js')
}
},
module: {
@ -44,7 +44,8 @@ const webpackConfig: webpack.Configuration = {
}),
new uglifyJsPlugin({
sourceMap: true
})
}),
]
};

View File

@ -3,20 +3,22 @@ import * as path from 'path';
import { merge } from 'lodash';
import { exec } from 'child_process';
import { PLUGIN_PATHS, ROOT } from '../build/helpers';
import { cpus } from 'os';
import * as Queue from 'async-promise-queue';
const MAIN_PACKAGE_JSON = require('../../package.json');
const VERSION = MAIN_PACKAGE_JSON.version;
const FLAGS = '--access public --tag beta';
const PACKAGE_JSON_BASE = {
"description": "Ionic Native - Native plugins for ionic apps",
"module": "index.js",
"typings": "index.d.ts",
"author": "ionic",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-native.git"
'description': 'Ionic Native - Native plugins for ionic apps',
'module': 'index.js',
'typings': 'index.d.ts',
'author': 'ionic',
'license': 'MIT',
'repository': {
'type': 'git',
'url': 'https://github.com/ionic-team/ionic-native.git'
}
};
@ -63,17 +65,34 @@ function prepare() {
});
}
async function publish() {
// TODO apply queue system to process them concurrently
for (let pkg of PACKAGES) {
// console.log('Going to run the following command: ', `npm publish ${ pkg } ${ FLAGS }`);
await new Promise<any>((resolve, reject) => {
exec(`npm publish ${ pkg } ${ FLAGS }`, (err, stdout, stderr) => {
if (err) reject(err);
if (stderr) reject(stderr);
if (stdout) resolve(stdout);
async function publish(ignoreErrors: boolean = false) {
// upload 1 package per CPU thread at a time
const worker = Queue.async.asyncify((pkg: any) => {
new Promise<any>((resolve, reject) => {
exec(`npm publish ${ pkg } ${ FLAGS }`, (err, stdout) => {
if (stdout) {
console.log(stdout);
resolve(stdout);
}
if (err) {
if (!ignoreErrors) {
if (err.message.includes('You cannot publish over the previously published version')) {
console.log('Ignoring duplicate version error.');
return resolve();
}
reject(err);
}
}
});
});
});
try {
await Queue(worker, PACKAGES, cpus().length);
console.log('Done publishing!');
} catch (e) {
console.log('Error publishing!');
console.log(e);
}
}

View File

@ -72,7 +72,7 @@ export interface AdMobFreeRewardVideoConfig {
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.banner',
})
export class AdMobFreeBanner {
export class AdMobFreeBanner extends IonicNativePlugin {
/**
* Update config.
@ -130,7 +130,7 @@ export class AdMobFreeBanner {
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.interstitial',
})
export class AdMobFreeInterstitial {
export class AdMobFreeInterstitial extends IonicNativePlugin {
/**
* Update config.
@ -179,7 +179,7 @@ export class AdMobFreeInterstitial {
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.rewardvideo',
})
export class AdMobFreeRewardVideo {
export class AdMobFreeRewardVideo extends IonicNativePlugin {
/**
* Update config.