File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ program
6767 . catch ( err => log . error ( 'clean' , 'clean break' , err ) )
6868 } )
6969
70+ program
71+ . command ( 'outdated' )
72+ . description ( 'Check template is outdated' )
73+ . action ( ( ) => {
74+ mili . outdated ( )
75+ } )
76+
7077
7178// error on unknown commands
7279program . on ( 'command:*' , function ( ) {
Original file line number Diff line number Diff line change 1+ const loadMiliConfig = require ( '../loadMiliConfig' )
2+ const semver = require ( 'semver' )
3+ const log = require ( '../log' )
4+ const throwError = require ( '../throwError' )
5+ const getTemplateVersions = require ( '../getTemplateVersions' )
6+
7+
8+ module . exports = async ( ) => {
9+ const miliConfig = await loadMiliConfig ( )
10+ const repository = miliConfig . repository
11+
12+ const versions = await getTemplateVersions ( repository )
13+
14+ if ( semver . valid ( miliConfig . version ) && semver . lt ( miliConfig . version , versions [ 0 ] . version ) ) {
15+ log . warn ( [
16+ '' ,
17+ '' ,
18+ 'Project Mili Template Is Outdated' ,
19+ 'run `npx mili upgrade` to upgrade template' ,
20+ '' ,
21+ '' ,
22+ ] . join ( '\n' ) )
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ const git = require ( 'simple-git/promise' )
2+ const semver = require ( 'semver' )
3+
4+
5+
6+ module . exports = async ( repository ) => {
7+ const result = await git ( ) . listRemote ( [ '--tags' , repository ] )
8+ const arr = result . split ( '\n' )
9+ return arr
10+ . filter ( item => item . length && ! / \^ { } $ / . test ( item ) )
11+ . map ( item => {
12+ const [ commit , ref ] = item . split ( / \s + / )
13+ const version = ref . substring ( 'refs/tags/v' . length )
14+ return { commit, ref, version }
15+ } )
16+ . filter ( item => semver . valid ( item . version ) )
17+ . sort ( ( a , b ) => semver . lt ( a . version , b . version ) ? 1 : - 1 )
18+ }
Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ const init = require('./commands/init')
22const upgrade = require ( './commands/upgrade' )
33const update = require ( './commands/update' )
44const clean = require ( './commands/clean' )
5+ const outdated = require ( './commands/outdated' )
56
67module . exports = {
78 init,
89 upgrade,
910 update,
1011 clean,
12+ outdated,
1113}
You can’t perform that action at this time.
0 commit comments