From a94651dc7548ed2d7e3212aa436dfae44e502c55 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Sat, 13 May 2017 22:53:04 -0400 Subject: [PATCH] chore(): update templates --- gulpfile.js | 12 +++++++----- scripts/templates/wrap-min.tmpl | 10 +++++----- scripts/templates/wrap.tmpl | 12 ++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c2e6c1168..1bf2f98a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,14 +34,16 @@ gulp.task('plugin:create', () => { const src = flags.m ? './scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl', pluginName = flags.n, - pluginNameSpaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1'); + spaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1'), + kebabCase = _.kebabCase(pluginName); return gulp.src(src) - .pipe(replace('$PluginName', pluginName)) - .pipe(replace('$Plugin_Name', pluginNameSpaced)) - .pipe(replace('$pluginName', _.lowerFirst(pluginName))) + .pipe(replace('{{ PluginName }}', pluginName)) + .pipe(replace('{{ Plugin_Name }}', spaced)) + .pipe(replace('{{ pluginName }}', _.lowerFirst(pluginName))) + .pipe(replace('{{ plugin-name }}', kebabCase)) .pipe(rename('index.ts')) - .pipe(gulp.dest('./src/@ionic-native/plugins/' + _.kebabCase(pluginName))); + .pipe(gulp.dest('./src/@ionic-native/plugins/' + kebabCase)); } else { console.log("Usage is: gulp plugin:create -n PluginName"); diff --git a/scripts/templates/wrap-min.tmpl b/scripts/templates/wrap-min.tmpl index 83aa48ff2..68a6bba1d 100644 --- a/scripts/templates/wrap-min.tmpl +++ b/scripts/templates/wrap-min.tmpl @@ -2,15 +2,15 @@ import { Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Injectable } from '@angular/core'; /** - * @name $Plugin_Name + * @name {{ Plugin_Name }} * @description * * @usage * ``` - * import { $PluginName } from 'ionic-native'; + * import { {{ PluginName }} } from '@ionic-native/{{ plugin-name }}'; * * - * constructor(private $pluginName: $PluginName) { } + * constructor(private {{ pluginName }}: {{ PluginName }}) { } * * ... * @@ -18,13 +18,13 @@ import { Injectable } from '@angular/core'; * ``` */ @Plugin({ - pluginName: '$PluginName', + pluginName: '{{ PluginName }}', plugin: '', pluginRef: '', repo: '', platforms: [] }) @Injectable() -export class $PluginName extends IonicNativePlugin { +export class {{ PluginName }} extends IonicNativePlugin { } diff --git a/scripts/templates/wrap.tmpl b/scripts/templates/wrap.tmpl index f6e872d6e..8f5228e1a 100644 --- a/scripts/templates/wrap.tmpl +++ b/scripts/templates/wrap.tmpl @@ -15,28 +15,28 @@ import { Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty, Io import { Observable } from 'rxjs/Observable'; /** - * @name $Plugin_Name + * @name {{ Plugin_Name }} * @description * This plugin does something * * @usage * ``` - * import { $PluginName } from '@ionic-native/'; + * import { {{ PluginName }} } from '@ionic-native/{{ plugin-name }}'; * * - * constructor(private $pluginName: $PluginName) { } + * constructor(private {{ pluginName }}: {{ PluginName }}) { } * * ... * * - * this.$pluginName.functionName('Hello', 123) + * this.{{ pluginName }}.functionName('Hello', 123) * .then((res: any) => console.log(res)) * .catch((error: any) => console.error(error)); * * ``` */ @Plugin({ - pluginName: '$PluginName', + pluginName: '{{ PluginName }}', plugin: '', // npm package name, example: cordova-plugin-camera pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation repo: '', // the github repository URL for the plugin @@ -44,7 +44,7 @@ import { Observable } from 'rxjs/Observable'; install: '', // OPTIONAL install command, in case the plugin requires variables }) @Injectable() -export class $PluginName extends IonicNativePlugin { +export class {{ PluginName }} extends IonicNativePlugin { /** * This function does something