millas 0.2.27 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/millas.js +12 -2
- package/package.json +2 -1
- package/src/cli.js +117 -20
- package/src/commands/call.js +1 -1
- package/src/commands/createsuperuser.js +137 -182
- package/src/commands/key.js +61 -83
- package/src/commands/lang.js +423 -515
- package/src/commands/make.js +88 -62
- package/src/commands/migrate.js +200 -279
- package/src/commands/new.js +55 -50
- package/src/commands/route.js +78 -80
- package/src/commands/schedule.js +52 -150
- package/src/commands/serve.js +158 -191
- package/src/console/AppCommand.js +106 -0
- package/src/console/BaseCommand.js +726 -0
- package/src/console/CommandContext.js +66 -0
- package/src/console/CommandRegistry.js +88 -0
- package/src/console/Style.js +123 -0
- package/src/console/index.js +12 -3
- package/src/container/AppInitializer.js +10 -0
- package/src/container/Application.js +2 -0
- package/src/facades/DB.js +195 -0
- package/src/index.js +2 -1
- package/src/scaffold/maker.js +102 -42
- package/src/schematics/Collection.js +28 -0
- package/src/schematics/SchematicEngine.js +122 -0
- package/src/schematics/Template.js +99 -0
- package/src/schematics/index.js +7 -0
- package/src/templates/command/default.template.js +14 -0
- package/src/templates/command/schema.json +19 -0
- package/src/templates/controller/default.template.js +10 -0
- package/src/templates/controller/resource.template.js +59 -0
- package/src/templates/controller/schema.json +30 -0
- package/src/templates/job/default.template.js +11 -0
- package/src/templates/job/schema.json +19 -0
- package/src/templates/middleware/default.template.js +11 -0
- package/src/templates/middleware/schema.json +19 -0
- package/src/templates/migration/default.template.js +14 -0
- package/src/templates/migration/schema.json +19 -0
- package/src/templates/model/default.template.js +14 -0
- package/src/templates/model/migration.template.js +17 -0
- package/src/templates/model/schema.json +30 -0
- package/src/templates/service/default.template.js +12 -0
- package/src/templates/service/schema.json +19 -0
- package/src/templates/shape/default.template.js +11 -0
- package/src/templates/shape/schema.json +19 -0
- package/src/validation/BaseValidator.js +3 -0
- package/src/validation/types.js +3 -3
package/src/commands/make.js
CHANGED
|
@@ -1,75 +1,101 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const BaseCommand = require('../console/BaseCommand');
|
|
5
|
+
const SchematicEngine = require('../schematics/SchematicEngine');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
class MakeCommand extends BaseCommand {
|
|
8
|
+
static description = 'Generate application scaffolding';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
.command('make:controller <name>')
|
|
10
|
-
.description('Generate a new controller')
|
|
11
|
-
.option('--resource', 'Generate a resource controller with CRUD methods')
|
|
12
|
-
.action(async (name, options) => {
|
|
13
|
-
await run('Controller', () => makeController(name, options));
|
|
14
|
-
});
|
|
10
|
+
#engine = new SchematicEngine(path.join(__dirname, '../templates'));
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
async onInit(register) {
|
|
13
|
+
register
|
|
14
|
+
.command(async (name, resource,model) => {
|
|
15
|
+
const result = await this.#generate('controller', name, {resource,model});
|
|
16
|
+
this.success(`Created: ${result.path}`);
|
|
17
|
+
})
|
|
18
|
+
.name('controller')
|
|
19
|
+
.arg('name')
|
|
20
|
+
.arg('--resource')
|
|
21
|
+
.arg('--model', v => v.string())
|
|
22
|
+
.description('Generate a new controller');
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
register
|
|
25
|
+
.command(async (name, migration) => {
|
|
26
|
+
console.log(name,migration)
|
|
27
|
+
const timestamp = Date.now();
|
|
28
|
+
const results = await this.#generate('model', name, { migration, timestamp });
|
|
29
|
+
if (Array.isArray(results)) {
|
|
30
|
+
results.forEach(r => this.success(`Created: ${r.path}`));
|
|
31
|
+
} else {
|
|
32
|
+
this.success(`Created: ${results.path}`);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.name('model')
|
|
36
|
+
.arg('name')
|
|
37
|
+
.arg('--migration')
|
|
38
|
+
.description('Generate a new model');
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
register
|
|
41
|
+
.command(async (name) => {
|
|
42
|
+
const result = await this.#generate('middleware', name);
|
|
43
|
+
this.success(`Created: ${result.path}`);
|
|
44
|
+
})
|
|
45
|
+
.name('middleware')
|
|
46
|
+
.arg('name')
|
|
47
|
+
.description('Generate a new middleware');
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
register
|
|
50
|
+
.command(async (name) => {
|
|
51
|
+
const result = await this.#generate('service', name);
|
|
52
|
+
this.success(`Created: ${result.path}`);
|
|
53
|
+
})
|
|
54
|
+
.name('service')
|
|
55
|
+
.arg('name')
|
|
56
|
+
.description('Generate a new service class');
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
register
|
|
59
|
+
.command(async (name) => {
|
|
60
|
+
const result = await this.#generate('job', name);
|
|
61
|
+
this.success(`Created: ${result.path}`);
|
|
62
|
+
})
|
|
63
|
+
.name('job')
|
|
64
|
+
.arg('name')
|
|
65
|
+
.description('Generate a new background job');
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.action(async (name) => {
|
|
62
|
-
await run('Command', () => makeCommand(name));
|
|
63
|
-
});
|
|
67
|
+
register
|
|
68
|
+
.command(async (name) => {
|
|
69
|
+
const timestamp = Date.now();
|
|
70
|
+
const result = await this.#generate('migration', name, {timestamp });
|
|
71
|
+
this.success(`Created: ${result.path}`);
|
|
72
|
+
})
|
|
73
|
+
.name('migration')
|
|
74
|
+
.arg('name')
|
|
75
|
+
.description('Generate a blank migration file');
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
register
|
|
78
|
+
.command(async (name) => {
|
|
79
|
+
const result = await this.#generate('shape', name);
|
|
80
|
+
this.success(`Created: ${result.path}`);
|
|
81
|
+
})
|
|
82
|
+
.name('shape')
|
|
83
|
+
.arg('name')
|
|
84
|
+
.description('Generate a shape file with Create/Update contracts (app/shapes/)');
|
|
66
85
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
register
|
|
87
|
+
.command(async (name) => {
|
|
88
|
+
const result = await this.#generate('command', name);
|
|
89
|
+
this.success(`Created: ${result.path}`);
|
|
90
|
+
})
|
|
91
|
+
.name('command')
|
|
92
|
+
.arg('name')
|
|
93
|
+
.description('Generate a new custom console command in app/commands/');
|
|
74
94
|
}
|
|
75
|
-
|
|
95
|
+
|
|
96
|
+
async #generate(type, name, options) {
|
|
97
|
+
return await this.#engine.generate(type, {name}, options);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = MakeCommand;
|