@@ -8,7 +8,8 @@ var bower = require('bower'),
88 JsonLoader = require ( '../JsonLoader' ) ,
99 JsonWriter = require ( '../JsonWriter' ) ,
1010 Project = require ( '../Project' ) ,
11- Plugin = require ( '../Plugin' ) ;
11+ Plugin = require ( '../Plugin' ) ,
12+ semver = require ( 'semver' ) ;
1213
1314module . exports = {
1415 register : function ( renderer ) {
@@ -110,16 +111,20 @@ function confirm(properties) {
110111 default : plugin . toString ( ) || 'not specified' ,
111112 required : true
112113 } ,
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 ) ? / ,
114+ repositoryUrl : {
115+ description : chalk . cyan ( 'repository URL' ) ,
116+ message : 'Please provide a repository URL of the form git://<domain><path>.git' ,
117+ pattern : / g i t : \/ \/ ( [ \w \. @ \: / \- ~ ] + ) ( \. g i t ) ( \/ ) ? / ,
116118 type : 'string' ,
117- default : properties . repository || 'not specified' ,
119+ default : properties . repository ? properties . repository . url : undefined ,
118120 required : true
119121 } ,
120122 framework : {
121123 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,
124+ message : 'Please provide a valid semver (see https://semver.org/)' ,
125+ conform :function ( v ) {
126+ return semver . valid ( semver . coerce ( v ) ) ;
127+ } ,
123128 type : 'string' ,
124129 default : properties . framework || '~2.0.0' ,
125130 required : false
@@ -143,8 +148,9 @@ function confirm(properties) {
143148 if ( ! confirmation . ready ) deferred . reject ( new Error ( 'Aborted. Nothing has been registered.' ) ) ;
144149
145150 properties . name = confirmation . name ;
146- properties . repository = confirmation . repository ;
151+ properties . repository = { type : 'git' , url : confirmation . repositoryUrl } ;
147152 properties . framework = confirmation . framework ;
153+
148154 deferred . resolve ( properties ) ;
149155 } ) ;
150156 return deferred . promise ;
0 commit comments