mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
chore(): fix plugin create command and templtes
This commit is contained in:
parent
1eebea9df5
commit
c52bb832b4
13
gulpfile.js
13
gulpfile.js
@ -5,7 +5,8 @@ const gulp = require('gulp'),
|
|||||||
rename = require("gulp-rename"),
|
rename = require("gulp-rename"),
|
||||||
tslint = require('gulp-tslint'),
|
tslint = require('gulp-tslint'),
|
||||||
decamelize = require('decamelize'),
|
decamelize = require('decamelize'),
|
||||||
replace = require('gulp-replace');
|
replace = require('gulp-replace'),
|
||||||
|
_ = require('lodash');
|
||||||
|
|
||||||
const flagConfig = {
|
const flagConfig = {
|
||||||
string: ['port', 'version', 'ngVersion', 'animations'],
|
string: ['port', 'version', 'ngVersion', 'animations'],
|
||||||
@ -31,16 +32,16 @@ gulp.task('lint', () => {
|
|||||||
gulp.task('plugin:create', () => {
|
gulp.task('plugin:create', () => {
|
||||||
if (flags.n && flags.n !== ''){
|
if (flags.n && flags.n !== ''){
|
||||||
|
|
||||||
const src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl',
|
const src = flags.m ? './scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl',
|
||||||
pluginName = flags.n,
|
pluginName = flags.n,
|
||||||
pluginPackageName = decamelize(pluginName, '-'),
|
|
||||||
pluginNameSpaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1');
|
pluginNameSpaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1');
|
||||||
|
|
||||||
return gulp.src(src)
|
return gulp.src(src)
|
||||||
.pipe(replace('PluginName', pluginName))
|
.pipe(replace('$PluginName', pluginName))
|
||||||
.pipe(replace('Plugin Name', pluginNameSpaced))
|
.pipe(replace('$Plugin_Name', pluginNameSpaced))
|
||||||
|
.pipe(replace('$pluginName', _.lowerFirst(pluginName)))
|
||||||
.pipe(rename('index.ts'))
|
.pipe(rename('index.ts'))
|
||||||
.pipe(gulp.dest('./src/@ionic-native/plugins/' + pluginPackageName));
|
.pipe(gulp.dest('./src/@ionic-native/plugins/' + _.kebabCase(pluginName)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("Usage is: gulp plugin:create -n PluginName");
|
console.log("Usage is: gulp plugin:create -n PluginName");
|
||||||
|
@ -7,18 +7,23 @@ import { Injectable } from '@angular/core';
|
|||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* ```
|
* ```
|
||||||
* import { PluginName } from 'ionic-native';
|
* import { $PluginName } from 'ionic-native';
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* constructor(private $pluginName: $PluginName) { }
|
||||||
|
*
|
||||||
|
* ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
pluginName: 'PluginName',
|
pluginName: '$PluginName',
|
||||||
plugin: '',
|
plugin: '',
|
||||||
pluginRef: '',
|
pluginRef: '',
|
||||||
repo: ''
|
repo: ''
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PluginName {
|
export class $PluginName {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,29 +15,35 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Plugin Name
|
* @name $Plugin_Name
|
||||||
* @description
|
* @description
|
||||||
* This plugin does something
|
* This plugin does something
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* ```
|
* ```
|
||||||
* import { PluginName } from 'ionic-native';
|
* import { $PluginName } from 'ionic-native';
|
||||||
*
|
*
|
||||||
* PluginName.functionName('Hello', 123)
|
*
|
||||||
* .then((something: any) => doSomething(something))
|
* constructor(private $pluginName: $PluginName) { }
|
||||||
* .catch((error: any) => console.log(error));
|
*
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* this.$pluginName.functionName('Hello', 123)
|
||||||
|
* .then((res: any) => console.log(res))
|
||||||
|
* .catch((error: any) => console.error(error));
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
pluginName: 'PluginName',
|
pluginName: '$PluginName',
|
||||||
plugin: '', // npm package name, example: cordova-plugin-camera
|
plugin: '', // npm package name, example: cordova-plugin-camera
|
||||||
pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation
|
pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation
|
||||||
repo: '', // the github repository URL for the plugin
|
repo: '', // the github repository URL for the plugin
|
||||||
install: '' // OPTIONAL install command, in case the plugin requires variables
|
install: '' // OPTIONAL install command, in case the plugin requires variables
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PluginName {
|
export class $PluginName {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function does something
|
* This function does something
|
||||||
|
Loading…
Reference in New Issue
Block a user