@@ -31,8 +31,7 @@ module.exports = class extends BaseGenerator {
3131 this . srcFiles = [
3232 'plugin-test.js' ,
3333 'plugin.js' ,
34- 'plugin.md' ,
35- 'test.js'
34+ 'plugin.md'
3635 ] ;
3736 }
3837
@@ -50,6 +49,15 @@ module.exports = class extends BaseGenerator {
5049 message : 'Project name' ,
5150 when : ! this . pkg . name ,
5251 default : process . cwd ( ) . split ( path . sep ) . pop ( )
52+ } , {
53+ name : 'public' ,
54+ type : 'confirm' ,
55+ message : 'Is this project public' ,
56+ default : true ,
57+ when : function ( response ) {
58+ // Only prompt if the name prop starts with "@" indicating a scoped package
59+ return response . name . indexOf ( '@' ) === 0
60+ }
5361 } , {
5462 name : 'folder' ,
5563 message : 'Project main folder' ,
@@ -93,7 +101,22 @@ module.exports = class extends BaseGenerator {
93101
94102 this . prompt ( prompts ) . then ( function ( props ) {
95103 this . props = _ . extend ( this . props , props ) ;
96- this . props . name = _ . kebabCase ( this . props . name ) ;
104+ var scopedPkgName = undefined ;
105+ var pkgName = _ . kebabCase ( this . props . name ) ;
106+
107+ // Parse out any scoping
108+ if ( this . props . name . indexOf ( '@' ) === 0 ) {
109+ // Get the scope of the package
110+ var scope = this . props . name . match ( / @ .+ \/ / ) [ 0 ] ;
111+ // kebabCase the package name minus the scope
112+ // this will be used in the repository url
113+ pkgName = _ . kebabCase ( this . props . name . replace ( scope , '' ) ) ;
114+ // Create the scoped name for use in the package.json
115+ scopedPkgName = scope + pkgName ;
116+ }
117+
118+ this . props . name = pkgName ;
119+ this . props . pkgName = scopedPkgName || pkgName ;
97120 done ( ) ;
98121 } . bind ( this ) ) ;
99122 } . bind ( this ) ) ;
@@ -105,7 +128,7 @@ module.exports = class extends BaseGenerator {
105128 ' ./' + this . props . folder + '/' : '' ;
106129 var keywords = getKeywords ( 'plugin' , this . props . keywords ) ;
107130 var pkgJsonFields = {
108- name : this . props . name ,
131+ name : this . props . pkgName ,
109132 version : '0.0.0' ,
110133 description : this . props . description ,
111134 homepage : this . props . homepage ,
@@ -125,9 +148,9 @@ module.exports = class extends BaseGenerator {
125148 testee : "testee test.html --browsers firefox" ,
126149 test : "npm run jshint && npm run testee" ,
127150 jshint : "jshint ./*.js" + jshintFolder + " --config" ,
128- "release:patch" : "npm version patch && npm publish" ,
129- "release:minor" : "npm version minor && npm publish" ,
130- "release:major" : "npm version major && npm publish" ,
151+ "release:patch" : "npm version patch && npm publish" . concat ( this . props . public ? " --access public" : "" ) ,
152+ "release:minor" : "npm version minor && npm publish" . concat ( this . props . public ? " --access public" : "" ) ,
153+ "release:major" : "npm version major && npm publish" . concat ( this . props . public ? " --access public" : "" ) ,
131154 build : "node build.js" ,
132155 develop : "done-serve --static --develop --port 8080"
133156 } ,
0 commit comments