Skip to content

Commit 82b2f2f

Browse files
committed
refactor CLI without IIFEs, add bcryptjs instead for user model
1 parent 3d71acb commit 82b2f2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1861
-2038
lines changed

cli/cli.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const CommandLineInterface = require('cmnd').CommandLineInterface;
4+
const CLI = new CommandLineInterface();
45

5-
const CommandLineInterface = require('cmnd').CommandLineInterface;
6-
const CLI = new CommandLineInterface();
6+
CLI.load(__dirname, './commands');
77

8-
CLI.load(__dirname, './commands');
9-
10-
return CLI;
11-
12-
})();
8+
return CLI;

cli/commands/db/bootstrap.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const Command = require('cmnd').Command;
44

5-
const Command = require('cmnd').Command;
5+
class DBBootstrapCommand extends Command {
66

7-
class DBBootstrapCommand extends Command {
7+
constructor() {
88

9-
constructor() {
9+
super('db', 'bootstrap');
1010

11-
super('db', 'bootstrap');
12-
13-
}
14-
15-
help() {
11+
}
1612

17-
return {
18-
description: 'Runs db:drop, db:create, db:prepare, db:migrate, db:seed',
19-
};
13+
help() {
2014

21-
}
15+
return {
16+
description: 'Runs db:drop, db:create, db:prepare, db:migrate, db:seed',
17+
};
2218

23-
run(args, flags, vflags, callback) {
19+
}
2420

25-
const bootstrapper = require('../../../core/my/bootstrapper.js');
26-
bootstrapper.bootstrap(callback);
21+
run(args, flags, vflags, callback) {
2722

28-
}
23+
const bootstrapper = require('../../../core/my/bootstrapper.js');
24+
bootstrapper.bootstrap(callback);
2925

3026
}
3127

32-
return DBBootstrapCommand;
28+
}
3329

34-
})();
30+
module.exports = DBBootstrapCommand;

cli/commands/db/compose.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const Command = require('cmnd').Command;
44

5-
const Command = require('cmnd').Command;
5+
class DBBootstrapCommand extends Command {
66

7-
class DBBootstrapCommand extends Command {
7+
constructor() {
88

9-
constructor() {
9+
super('db', 'compose');
1010

11-
super('db', 'compose');
12-
13-
}
14-
15-
help() {
11+
}
1612

17-
return {
18-
description: 'Runs db:prepare, db:migrate, db:seed',
19-
};
13+
help() {
2014

21-
}
15+
return {
16+
description: 'Runs db:prepare, db:migrate, db:seed',
17+
};
2218

23-
run(args, flags, vflags, callback) {
19+
}
2420

25-
const bootstrapper = require('../../../core/my/bootstrapper.js');
26-
bootstrapper.compose(callback);
21+
run(args, flags, vflags, callback) {
2722

28-
}
23+
const bootstrapper = require('../../../core/my/bootstrapper.js');
24+
bootstrapper.compose(callback);
2925

3026
}
3127

32-
return DBBootstrapCommand;
28+
}
3329

34-
})();
30+
module.exports = DBBootstrapCommand;

cli/commands/db/create.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
module.exports = (() => {
21

3-
'use strict';
42

5-
const Command = require('cmnd').Command;
3+
'use strict';
64

7-
class DBCreateCommand extends Command {
5+
const Command = require('cmnd').Command;
86

9-
constructor() {
7+
class DBCreateCommand extends Command {
108

11-
super('db', 'create');
9+
constructor() {
1210

13-
}
14-
15-
help() {
11+
super('db', 'create');
1612

17-
return {
18-
description: 'Create a new PostgreSQL database for the current project'
19-
};
13+
}
2014

21-
}
15+
help() {
2216

23-
run(args, flags, vflags, callback) {
17+
return {
18+
description: 'Create a new PostgreSQL database for the current project'
19+
};
2420

25-
if (vflags.env) {
26-
process.env.NODE_ENV = vflags.env[0];
27-
}
21+
}
2822

29-
const bootstrapper = require('../../../core/my/bootstrapper.js');
30-
bootstrapper.create(callback);
23+
run(args, flags, vflags, callback) {
3124

25+
if (vflags.env) {
26+
process.env.NODE_ENV = vflags.env[0];
3227
}
3328

29+
const bootstrapper = require('../../../core/my/bootstrapper.js');
30+
bootstrapper.create(callback);
31+
3432
}
3533

36-
return DBCreateCommand;
34+
}
3735

38-
})();
36+
module.exports = DBCreateCommand;

cli/commands/db/drop.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const Command = require('cmnd').Command;
44

5-
const Command = require('cmnd').Command;
5+
class DBDropCommand extends Command {
66

7-
class DBDropCommand extends Command {
7+
constructor() {
88

9-
constructor() {
9+
super('db', 'drop');
1010

11-
super('db', 'drop');
12-
13-
}
14-
15-
help() {
16-
17-
return {
18-
description: 'drops the currently active database'
19-
};
11+
}
2012

21-
}
13+
help() {
2214

23-
run(args, flags, vflags, callback) {
15+
return {
16+
description: 'drops the currently active database'
17+
};
2418

25-
if (vflags.env) {
26-
process.env.NODE_ENV = vflags.env[0];
27-
}
19+
}
2820

29-
const bootstrapper = require('../../../core/my/bootstrapper.js');
30-
bootstrapper.drop(callback);
21+
run(args, flags, vflags, callback) {
3122

23+
if (vflags.env) {
24+
process.env.NODE_ENV = vflags.env[0];
3225
}
3326

27+
const bootstrapper = require('../../../core/my/bootstrapper.js');
28+
bootstrapper.drop(callback);
29+
3430
}
3531

36-
return DBDropCommand;
32+
}
3733

38-
})();
34+
module.exports = DBDropCommand;

cli/commands/db/migrate.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const Command = require('cmnd').Command;
44

5-
const Command = require('cmnd').Command;
5+
class DBMigrateCommand extends Command {
66

7-
class DBMigrateCommand extends Command {
7+
constructor() {
88

9-
constructor() {
9+
super('db', 'migrate');
1010

11-
super('db', 'migrate');
12-
13-
}
14-
15-
help() {
11+
}
1612

17-
return {
18-
description: 'An example command',
19-
vflags: {
20-
step: 'The number of steps to migrate (default: all)'
21-
}
22-
};
13+
help() {
2314

24-
}
15+
return {
16+
description: 'An example command',
17+
vflags: {
18+
step: 'The number of steps to migrate (default: all)'
19+
}
20+
};
2521

26-
run(args, flags, vflags, callback) {
22+
}
2723

28-
const bootstrapper = require('../../../core/my/bootstrapper.js');
29-
bootstrapper.migrate(vflags.step, callback);
24+
run(args, flags, vflags, callback) {
3025

31-
}
26+
const bootstrapper = require('../../../core/my/bootstrapper.js');
27+
bootstrapper.migrate(vflags.step, callback);
3228

3329
}
3430

35-
return DBMigrateCommand;
31+
}
3632

37-
})();
33+
module.exports = DBMigrateCommand;

cli/commands/db/prepare.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
module.exports = (() => {
1+
'use strict';
22

3-
'use strict';
3+
const Command = require('cmnd').Command;
44

5-
const Command = require('cmnd').Command;
5+
class DBPrepareCommand extends Command {
66

7-
class DBPrepareCommand extends Command {
7+
constructor() {
88

9-
constructor() {
9+
super('db', 'prepare');
1010

11-
super('db', 'prepare');
12-
13-
}
14-
15-
help() {
11+
}
1612

17-
return {
18-
description: 'Prepares your database for migrations (resets all data)'
19-
};
13+
help() {
2014

21-
}
15+
return {
16+
description: 'Prepares your database for migrations (resets all data)'
17+
};
2218

23-
run(args, flags, vflags, callback) {
19+
}
2420

25-
const bootstrapper = require('../../../core/my/bootstrapper.js');
26-
bootstrapper.prepare(callback);
21+
run(args, flags, vflags, callback) {
2722

28-
}
23+
const bootstrapper = require('../../../core/my/bootstrapper.js');
24+
bootstrapper.prepare(callback);
2925

3026
}
3127

32-
return DBPrepareCommand;
28+
}
3329

34-
})();
30+
module.exports = DBPrepareCommand;

0 commit comments

Comments
 (0)