@@ -9,13 +9,18 @@ var bower = require('bower'),
99 JsonWriter = require ( '../JsonWriter' ) ,
1010 Project = require ( '../Project' ) ,
1111 Plugin = require ( '../Plugin' ) ;
12+ semver = require ( 'semver' ) ;
1213
1314module . exports = {
1415 register : function ( renderer ) {
1516 var done = arguments [ arguments . length - 1 ] || function ( ) { } ;
1617
1718 renderer . log ( chalk . yellow ( 'This will publish this plugin to' , Constants . Registry ) ) ;
1819
20+ var c = semver . coerce ( '>=2.2' )
21+ console . log ( c ) ;
22+ console . log ( semver . valid ( c ) ) ;
23+
1924 loadPluginProperties ( './bower.json' , {
2025 name : undefined ,
2126 repository : undefined ,
@@ -110,16 +115,29 @@ function confirm(properties) {
110115 default : plugin . toString ( ) || 'not specified' ,
111116 required : true
112117 } ,
113- repository : {
114- description : chalk . cyan ( 'repository' ) ,
115- pattern : / ( [ A - Z a - z 0 - 9 ] + @ | h t t p ( | s ) | g i t \: \/ \/ ) ( [ A - Z a - z 0 - 9 . ] + ) ( : | \/ ) ( [ A - Z a - z 0 - 9 \- \. \/ ] + ) ( \. g i t ) ? / ,
118+ repositoryType : {
119+ description : chalk . cyan ( 'repository type (e.g. git)' ) ,
120+ message : 'Please provide a repository type' ,
121+ pattern : / .+ / ,
122+ type : 'string' ,
123+ default : properties . repository ? properties . repository . type : undefined ,
124+ required : true
125+ } ,
126+ repositoryUrl : {
127+ description : chalk . cyan ( 'repository URL' ) ,
128+ message : 'Please provide a repository URL of the form [git@][<protocol>]<domain><path>.git' ,
129+ pattern : / ( ( g i t | s s h | h t t p ( s ) ? ) | ( g i t @ [ \w \. ] + ) ) ( : ( \/ \/ ) ? ) ( [ \w \. @ \: / \- ~ ] + ) ( \. g i t ) ( \/ ) ? / ,
116130 type : 'string' ,
117- default : properties . repository || 'not specified' ,
131+ default : properties . repository ? properties . repository . url : undefined ,
118132 required : true
119133 } ,
120134 framework : {
121135 description : chalk . cyan ( 'framework' ) ,
122- pattern : / \b v ? (?: 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \. (?: 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \. (?: 0 | [ 1 - 9 ] [ 0 - 9 ] * ) (?: - [ \d a - z \- ] + (?: \. [ \d a - z \- ] + ) * ) ? (?: \+ [ \d a - z \- ] + (?: \. [ \d a - z \- ] + ) * ) ? \b / ig,
136+ message : 'Please provide a valid semver (see https://semver.org/)' ,
137+ conform :function ( v ) {
138+ return semver . valid ( semver . coerce ( v ) ) ;
139+ } ,
140+ errors :[ 'fooble' ] ,
123141 type : 'string' ,
124142 default : properties . framework || '~2.0.0' ,
125143 required : false
@@ -143,8 +161,13 @@ function confirm(properties) {
143161 if ( ! confirmation . ready ) deferred . reject ( new Error ( 'Aborted. Nothing has been registered.' ) ) ;
144162
145163 properties . name = confirmation . name ;
146- properties . repository = confirmation . repository ;
164+
165+ if ( confirmation . repositoryType && confirmation . repositoryUrl ) {
166+ properties . repository = { type :confirmation . repositoryType , url :confirmation . repositoryUrl } ;
167+ }
168+
147169 properties . framework = confirmation . framework ;
170+
148171 deferred . resolve ( properties ) ;
149172 } ) ;
150173 return deferred . promise ;
0 commit comments