@@ -31,8 +31,7 @@ module.exports = class extends BaseGenerator {
31
31
this . srcFiles = [
32
32
'plugin-test.js' ,
33
33
'plugin.js' ,
34
- 'plugin.md' ,
35
- 'test.js'
34
+ 'plugin.md'
36
35
] ;
37
36
}
38
37
@@ -50,6 +49,15 @@ module.exports = class extends BaseGenerator {
50
49
message : 'Project name' ,
51
50
when : ! this . pkg . name ,
52
51
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
+ }
53
61
} , {
54
62
name : 'folder' ,
55
63
message : 'Project main folder' ,
@@ -93,7 +101,22 @@ module.exports = class extends BaseGenerator {
93
101
94
102
this . prompt ( prompts ) . then ( function ( props ) {
95
103
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 ;
97
120
done ( ) ;
98
121
} . bind ( this ) ) ;
99
122
} . bind ( this ) ) ;
@@ -105,7 +128,7 @@ module.exports = class extends BaseGenerator {
105
128
' ./' + this . props . folder + '/' : '' ;
106
129
var keywords = getKeywords ( 'plugin' , this . props . keywords ) ;
107
130
var pkgJsonFields = {
108
- name : this . props . name ,
131
+ name : this . props . pkgName ,
109
132
version : '0.0.0' ,
110
133
description : this . props . description ,
111
134
homepage : this . props . homepage ,
@@ -125,9 +148,9 @@ module.exports = class extends BaseGenerator {
125
148
testee : "testee test.html --browsers firefox" ,
126
149
test : "npm run jshint && npm run testee" ,
127
150
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" : "" ) ,
131
154
build : "node build.js" ,
132
155
develop : "done-serve --static --develop --port 8080"
133
156
} ,
0 commit comments