File tree Expand file tree Collapse file tree 6 files changed +63
-17
lines changed Expand file tree Collapse file tree 6 files changed +63
-17
lines changed Original file line number Diff line number Diff line change 1
1
migrations /
2
2
node_modules /
3
+ lib /commands /generated.js
4
+ .tern-port
3
5
VCSeeder /
4
6
Seeder /
5
7
* .db
@@ -11,6 +13,7 @@ database.json
11
13
* .sublime-workspace
12
14
archive
13
15
.db-migraterc
16
+ coverage.html
14
17
15
18
# Vim swap files
16
19
. * .sw [a-z ]
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var load = require ( './lib/commands' ) ;
3
+ module . exports . version = require ( './package.json' ) . version ;
4
+
5
+ let load ;
4
6
var log = require ( 'db-migrate-shared' ) . log ;
5
- require ( 'pkginfo' ) ( module , 'version' ) ; // jshint ignore:line
6
7
var Promise ;
7
- var onComplete = load ( 'on-complete' ) ;
8
+ let onComplete ;
8
9
9
10
// constant hooks for this file
10
11
var APIHooks = {
@@ -17,12 +18,18 @@ var APIHooks = {
17
18
} ;
18
19
19
20
function dbmigrate ( plugins , isModule , options , callback ) {
21
+ if ( ! options . staticLoader ) load = require ( './lib/commands' ) ;
22
+ else load = require ( './lib/commands/generated.js' ) ;
23
+
24
+ onComplete = load ( 'on-complete' ) ;
25
+
20
26
var dotenv = require ( 'dotenv' ) ;
21
27
var setDefaultArgv = load ( 'set-default-argv' ) ;
22
28
23
29
this . internals = {
24
30
onComplete : onComplete ,
25
- migrationProtocol : 1
31
+ migrationProtocol : 1 ,
32
+ load
26
33
} ;
27
34
if ( typeof isModule !== 'function' ) {
28
35
this . internals . isModule = isModule ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const path = require ( 'path' ) ;
4
+ const recursive = require ( 'final-fs' ) . readdirRecursive ;
5
+ const start = path . join ( __dirname , 'lib/commands' ) ;
6
+ const Promise = require ( 'bluebird' ) ;
7
+ const fs = require ( 'fs' ) ;
8
+
9
+ ( async ( ) => {
10
+ const files = await recursive ( start , true ) ;
11
+ const template = `
12
+ 'use strict';
13
+
14
+ const path = require('path');
15
+
16
+ const files = {
17
+ ${ files
18
+ . map ( x => ` "${ x . substring ( 0 , x . indexOf ( '.js' ) ) } ": require('./${ x } ')` )
19
+ . join ( ',\n' ) }
20
+ }
21
+
22
+ function register (module) {
23
+ return files[module];
24
+ }
25
+
26
+ module.exports = register;
27
+ ` ;
28
+
29
+ fs . writeFile (
30
+ path . join ( __dirname , 'lib/commands/generated.js' ) ,
31
+ template ,
32
+ 'utf8' ,
33
+ err => {
34
+ if ( err ) throw err ;
35
+ }
36
+ ) ;
37
+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -63,15 +63,12 @@ function loadPlugins (options) {
63
63
return hooks ;
64
64
}
65
65
66
- module . exports . getInstance = function (
67
- isModule ,
68
- options = { cwd : process . cwd ( ) } ,
69
- callback
70
- ) {
66
+ module . exports . getInstance = function ( isModule , options = { } , callback ) {
71
67
delete require . cache [ require . resolve ( './api.js' ) ] ;
72
68
delete require . cache [ require . resolve ( 'optimist' ) ] ;
73
69
var Mod = require ( './api.js' ) ;
74
70
var plugins = { } ;
71
+ options . cwd = options . cwd || process . cwd ( ) ;
75
72
76
73
try {
77
74
if ( ! options || ! options . noPlugins ) plugins = loadPlugins ( options ) ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var log = require ( 'db-migrate-shared' ) . log ;
4
- var optimist = require ( 'optimist' ) ;
5
- var load = require ( './' ) ;
6
- var transition = load ( 'transition' ) ;
4
+ var yargs = require ( 'yargs' ) ;
5
+ var transition ;
7
6
8
7
function run ( internals , config ) {
8
+ const { load } = internals ;
9
+ const transition = load ( 'transition' ) ;
10
+ console . log ( load ) ;
9
11
var action = internals . argv . _ . shift ( ) ;
10
12
var folder = action . split ( ':' ) ;
11
13
@@ -117,7 +119,7 @@ function run (internals, config) {
117
119
'Invalid Action: Must be [up|down|check|create|reset|sync|' +
118
120
'db|transition].'
119
121
) ;
120
- optimist . showHelp ( ) ;
122
+ yargs . showHelp ( ) ;
121
123
process . exit ( 1 ) ;
122
124
}
123
125
break ;
Original file line number Diff line number Diff line change 33
33
],
34
34
"version" : " 0.11.6" ,
35
35
"engines" : {
36
- "node" : " >=0.6 .0"
36
+ "node" : " >=8.0 .0"
37
37
},
38
38
"bugs" : {
39
39
"url" : " https://github.com/db-migrate/node-db-migrate/issues"
52
52
"final-fs" : " ^1.6.0" ,
53
53
"inflection" : " ^1.10.0" ,
54
54
"mkdirp" : " ~0.5.0" ,
55
- "optimist" : " ~0.6.1" ,
56
55
"parse-database-url" : " ~0.3.0" ,
57
- "pkginfo" : " ^0.4.0" ,
58
56
"prompt" : " ^1.0.0" ,
59
57
"rc" : " ^1.2.8" ,
60
58
"resolve" : " ^1.1.6" ,
61
59
"semver" : " ^5.3.0" ,
62
- "tunnel-ssh" : " ^4.0.0"
60
+ "tunnel-ssh" : " ^4.0.0" ,
61
+ "yargs" : " ^15.3.1"
63
62
},
64
63
"devDependencies" : {
65
64
"code" : " ^4.1.0" ,
78
77
"sinon" : " ^4.1.2"
79
78
},
80
79
"scripts" : {
80
+ "prepublishOnly" : " node generateLoader.js" ,
81
81
"pretest" : " eslint *.js lib/*.js test/*.js bin/*" ,
82
82
"test" : " make test-cov"
83
83
}
You can’t perform that action at this time.
0 commit comments