@@ -46,19 +46,19 @@ export async function newPlugin(config: Config) {
4646 {
4747 type : 'input' ,
4848 name : 'name' ,
49- message : 'Plugin NPM name (kebab-case):' ,
49+ message : 'Plugin npm name (kebab-case. ex: capacitor-plugin-example ):' ,
5050 validate : requiredInput
5151 } ,
5252 {
5353 type : 'input' ,
5454 name : 'domain' ,
55- message : 'Plugin id (domain-style syntax. ex: com.example.plugin )' ,
55+ message : 'Plugin id (domain-style syntax. ex: com.mycompany.plugins.example )' ,
5656 validate : requiredInput
5757 } ,
5858 {
5959 type : 'input' ,
6060 name : 'className' ,
61- message : 'Plugin class name (ex: AwesomePlugin )' ,
61+ message : 'Plugin class name (ex: Example )' ,
6262 validate : requiredInput
6363 } ,
6464 {
@@ -167,24 +167,24 @@ async function createIosPlugin(config: Config, pluginPath: string, domain: strin
167167}
168168
169169function generatePodspec ( config : Config , answers : NewPluginAnswers ) {
170- return `
171- require 'json'
172-
173- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
174-
175- Pod::Spec.new do |s|
176- s.name = ' ${ fixName ( answers . name ) } '
177- s.version = package['version ']
178- s.summary = package['description ']
179- s.license = package['license ']
180- s.homepage = package['repository']['url ']
181- s.author = package['author']
182- s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
183- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp }'
184- s.ios.deployment_target = ' ${ config . ios . minVersion } '
185- s.dependency 'Capacitor '
186- s.swift_version = '5.0'
187- end `;
170+ return `require 'json'
171+
172+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
173+
174+ Pod::Spec.new do |s|
175+ s.name = ' ${ fixName ( answers . name ) } '
176+ s.version = package['version']
177+ s.summary = package['description ']
178+ s.license = package['license ']
179+ s.homepage = package['repository']['url ']
180+ s.author = package['author ']
181+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
182+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
183+ s.ios.deployment_target = '${ config . ios . minVersion } '
184+ s.dependency 'Capacitor '
185+ s.swift_version = '5.1 '
186+ end
187+ ` ;
188188}
189189
190190async function createAndroidPlugin ( config : Config , pluginPath : string , domain : string , className : string ) {
@@ -221,47 +221,61 @@ function generateAndroidManifest(domain: string, pluginPath: string) {
221221
222222function generatePackageJSON ( answers : NewPluginAnswers , cliVersion : string ) {
223223 return {
224- name : answers . name ,
225- version : '0.0.1' ,
226- description : answers . description ,
227- main : 'dist/esm/index.js' ,
228- types : 'dist/esm/index.d.ts' ,
229- scripts : {
230- 'build' : 'npm run clean && tsc' ,
224+ 'name' : answers . name ,
225+ 'version' : '0.0.1' ,
226+ 'description' : answers . description ,
227+ 'main' : 'dist/plugin.js' ,
228+ 'module' : 'dist/esm/index.js' ,
229+ 'types' : 'dist/esm/index.d.ts' ,
230+ 'scripts' : {
231+ 'lint' : 'npm run prettier -- --check && npm run swiftlint -- lint' ,
232+ 'prettier' : 'prettier "**/*.{css,html,ts,js,java}"' ,
233+ 'swiftlint' : 'node-swiftlint' ,
234+ 'build' : 'npm run clean && tsc && rollup -c rollup.config.js' ,
231235 'clean' : 'rimraf ./dist' ,
232236 'watch' : 'tsc --watch' ,
233237 'prepublishOnly' : 'npm run build'
234238 } ,
235- author : answers . author ,
236- license : answers . license ,
237- dependencies : {
238- '@capacitor/core' : `^${ cliVersion } `
239- } ,
240- devDependencies : {
241- 'rimraf' : '^3.0.0' ,
242- 'typescript' : '^3.2.4' ,
239+ 'author' : answers . author ,
240+ 'license' : answers . license ,
241+ 'devDependencies' : {
242+ '@capacitor/android' : `^${ cliVersion } ` ,
243+ '@capacitor/core' : `^${ cliVersion } ` ,
243244 '@capacitor/ios' : `^${ cliVersion } ` ,
244- '@capacitor/android' : `^${ cliVersion } `
245+ '@ionic/prettier-config' : '^1.0.0' ,
246+ '@ionic/swiftlint-config' : '^1.0.0' ,
247+ '@rollup/plugin-node-resolve' : '^8.1.0' ,
248+ 'prettier' : '^2.0.5' ,
249+ 'prettier-plugin-java' : '^0.8.0' ,
250+ 'rimraf' : '^3.0.0' ,
251+ 'rollup' : '^2.21.0' ,
252+ 'swiftlint' : '^1.0.1' ,
253+ 'typescript' : '~3.8.3'
254+ } ,
255+ 'peerDependencies' : {
256+ '@capacitor/core' : `^${ cliVersion } `
245257 } ,
246- files : [
258+ ' files' : [
247259 'dist/' ,
248260 'ios/' ,
249261 'android/' ,
250262 `${ fixName ( answers . name ) } .podspec`
251263 ] ,
252- keywords : [
264+ ' keywords' : [
253265 'capacitor' ,
254266 'plugin' ,
255267 'native'
256268 ] ,
257- capacitor : {
258- ios : {
259- src : 'ios' ,
269+ ' capacitor' : {
270+ ' ios' : {
271+ ' src' : 'ios' ,
260272 } ,
261- android : {
262- src : 'android'
273+ ' android' : {
274+ ' src' : 'android'
263275 }
264276 } ,
277+ 'prettier' : '@ionic/prettier-config' ,
278+ 'swiftlint' : '@ionic/swiftlint-config' ,
265279 'repository' : {
266280 'type' : 'git' ,
267281 'url' : answers . git
0 commit comments