@magek/cli 0.0.5 → 0.0.7
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/dist/commands/add/projection.js +21 -21
- package/dist/commands/add/reducer.js +21 -21
- package/dist/commands/clean.js +8 -8
- package/dist/commands/new/command.js +18 -15
- package/dist/commands/new/entity.js +22 -18
- package/dist/commands/new/event-handler.js +12 -12
- package/dist/commands/new/event.js +19 -15
- package/dist/commands/new/query.js +18 -15
- package/dist/commands/new/read-model.js +27 -21
- package/dist/commands/new/scheduled-command.js +7 -7
- package/dist/commands/new/type.js +33 -13
- package/dist/commands/stub/publish.js +9 -9
- package/dist/common/script.js +62 -59
- package/dist/hooks/command_not_found/custom-parse.js +2 -3
- package/dist/services/file-system/index.js +2 -1
- package/dist/services/package-manager/index.js +4 -2
- package/dist/services/process/index.js +2 -1
- package/dist/services/project-checker.js +6 -0
- package/dist/services/semver.js +1 -0
- package/dist/templates/command.stub +1 -1
- package/dist/templates/entity.stub +3 -3
- package/dist/templates/event.stub +11 -2
- package/dist/templates/query.stub +1 -1
- package/dist/templates/read-model.stub +3 -3
- package/dist/templates/type.stub +9 -5
- package/package.json +7 -7
|
@@ -9,6 +9,27 @@ const brand_js_1 = tslib_1.__importDefault(require("../../common/brand.js"));
|
|
|
9
9
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
10
10
|
const method_generator_js_1 = require("../../services/method-generator.js");
|
|
11
11
|
class Projection extends base_command_js_1.default {
|
|
12
|
+
static description = 'add new projection to read model';
|
|
13
|
+
static usage = 'projection --read-model ReadModel --entity Entity:id';
|
|
14
|
+
static examples = [
|
|
15
|
+
'$ magek add:projection --read-model PostReadModel --entity Post:id',
|
|
16
|
+
'$ magek add:projection --read-model CommentReadModel --entity Comment:id',
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
20
|
+
'read-model': core_1.Flags.string({
|
|
21
|
+
description: 'read-model name',
|
|
22
|
+
required: true,
|
|
23
|
+
multiple: false,
|
|
24
|
+
dependsOn: ['entity'],
|
|
25
|
+
}),
|
|
26
|
+
entity: core_1.Flags.string({
|
|
27
|
+
description: 'an entity name',
|
|
28
|
+
required: true,
|
|
29
|
+
multiple: false,
|
|
30
|
+
dependsOn: ['read-model'],
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
12
33
|
async run() {
|
|
13
34
|
const { flags } = await this.parse(Projection);
|
|
14
35
|
const readModel = flags['read-model'];
|
|
@@ -16,27 +37,6 @@ class Projection extends base_command_js_1.default {
|
|
|
16
37
|
return run(readModel, entity);
|
|
17
38
|
}
|
|
18
39
|
}
|
|
19
|
-
Projection.description = 'add new projection to read model';
|
|
20
|
-
Projection.usage = 'projection --read-model ReadModel --entity Entity:id';
|
|
21
|
-
Projection.examples = [
|
|
22
|
-
'$ magek add:projection --read-model PostReadModel --entity Post:id',
|
|
23
|
-
'$ magek add:projection --read-model CommentReadModel --entity Comment:id',
|
|
24
|
-
];
|
|
25
|
-
Projection.flags = {
|
|
26
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
27
|
-
'read-model': core_1.Flags.string({
|
|
28
|
-
description: 'read-model name',
|
|
29
|
-
required: true,
|
|
30
|
-
multiple: false,
|
|
31
|
-
dependsOn: ['entity'],
|
|
32
|
-
}),
|
|
33
|
-
entity: core_1.Flags.string({
|
|
34
|
-
description: 'an entity name',
|
|
35
|
-
required: true,
|
|
36
|
-
multiple: false,
|
|
37
|
-
dependsOn: ['read-model'],
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
40
|
exports.default = Projection;
|
|
41
41
|
const run = async (rawReadModel, rawProjection) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('add:projection')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(rawReadModel), (0, index_js_1.parseProjectionField)(rawProjection)))
|
|
42
42
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -9,6 +9,27 @@ const brand_js_1 = tslib_1.__importDefault(require("../../common/brand.js"));
|
|
|
9
9
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
10
10
|
const method_generator_js_1 = require("../../services/method-generator.js");
|
|
11
11
|
class Reducer extends base_command_js_1.default {
|
|
12
|
+
static description = 'add new reducer to entity';
|
|
13
|
+
static usage = 'reducer --entity Entity --event Event';
|
|
14
|
+
static examples = [
|
|
15
|
+
'$ magek add:reducer --entity Post --event PostCreated',
|
|
16
|
+
'$ magek add:reducer --entity Comment --event CommentUpdated CommentVoted',
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
20
|
+
entity: core_1.Flags.string({
|
|
21
|
+
description: 'an entity name',
|
|
22
|
+
required: true,
|
|
23
|
+
multiple: false,
|
|
24
|
+
dependsOn: ['event'],
|
|
25
|
+
}),
|
|
26
|
+
event: core_1.Flags.string({
|
|
27
|
+
description: 'an event name',
|
|
28
|
+
required: true,
|
|
29
|
+
multiple: true,
|
|
30
|
+
dependsOn: ['entity'],
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
12
33
|
async run() {
|
|
13
34
|
const { flags } = await this.parse(Reducer);
|
|
14
35
|
const entity = flags.entity;
|
|
@@ -16,27 +37,6 @@ class Reducer extends base_command_js_1.default {
|
|
|
16
37
|
return run(entity, events);
|
|
17
38
|
}
|
|
18
39
|
}
|
|
19
|
-
Reducer.description = 'add new reducer to entity';
|
|
20
|
-
Reducer.usage = 'reducer --entity Entity --event Event';
|
|
21
|
-
Reducer.examples = [
|
|
22
|
-
'$ magek add:reducer --entity Post --event PostCreated',
|
|
23
|
-
'$ magek add:reducer --entity Comment --event CommentUpdated CommentVoted',
|
|
24
|
-
];
|
|
25
|
-
Reducer.flags = {
|
|
26
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
27
|
-
entity: core_1.Flags.string({
|
|
28
|
-
description: 'an entity name',
|
|
29
|
-
required: true,
|
|
30
|
-
multiple: false,
|
|
31
|
-
dependsOn: ['event'],
|
|
32
|
-
}),
|
|
33
|
-
event: core_1.Flags.string({
|
|
34
|
-
description: 'an event name',
|
|
35
|
-
required: true,
|
|
36
|
-
multiple: true,
|
|
37
|
-
dependsOn: ['entity'],
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
40
|
exports.default = Reducer;
|
|
41
41
|
const pluralize = (word, count) => (count === 1 ? word : `${word}s`);
|
|
42
42
|
const run = async (rawEntity, rawEvents) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('add:reducer')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(rawEntity), (0, index_js_1.parseReaction)(rawEvents)))
|
package/dist/commands/clean.js
CHANGED
|
@@ -13,6 +13,14 @@ const runTasks = async (clean) => script_js_1.Script.init(`magek ${brand_js_1.de
|
|
|
13
13
|
.info('Clean complete!')
|
|
14
14
|
.done();
|
|
15
15
|
class Clean extends base_command_js_1.default {
|
|
16
|
+
static description = 'Clean the current application as configured in your `index.ts` file.';
|
|
17
|
+
static flags = {
|
|
18
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
19
|
+
verbose: core_1.Flags.boolean({
|
|
20
|
+
description: 'display full error messages',
|
|
21
|
+
default: false,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
16
24
|
async run() {
|
|
17
25
|
await runTasks((ctx) => (0, config_service_js_1.cleanProject)(process.cwd()));
|
|
18
26
|
}
|
|
@@ -24,12 +32,4 @@ class Clean extends base_command_js_1.default {
|
|
|
24
32
|
return super.catch(fullError);
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
|
-
Clean.description = 'Clean the current application as configured in your `index.ts` file.';
|
|
28
|
-
Clean.flags = {
|
|
29
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
30
|
-
verbose: core_1.Flags.boolean({
|
|
31
|
-
description: 'display full error messages',
|
|
32
|
-
default: false,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
35
|
exports.default = Clean;
|
|
@@ -10,6 +10,18 @@ const index_js_1 = require("../../services/generator/target/index.js");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
class Command extends base_command_js_1.default {
|
|
13
|
+
static description = "Generate new resource, write 'magek new' to see options";
|
|
14
|
+
static flags = {
|
|
15
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
16
|
+
fields: core_1.Flags.string({
|
|
17
|
+
char: 'f',
|
|
18
|
+
description: 'Field that this command will contain',
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
commandName: core_1.Args.string(),
|
|
24
|
+
};
|
|
13
25
|
async run() {
|
|
14
26
|
const { args, flags } = await this.parse(Command);
|
|
15
27
|
try {
|
|
@@ -23,18 +35,6 @@ class Command extends base_command_js_1.default {
|
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
Command.description = "Generate new resource, write 'magek new' to see options";
|
|
27
|
-
Command.flags = {
|
|
28
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
29
|
-
fields: core_1.Flags.string({
|
|
30
|
-
char: 'f',
|
|
31
|
-
description: 'Field that this command will contain',
|
|
32
|
-
multiple: true,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
Command.args = {
|
|
36
|
-
commandName: core_1.Args.string(),
|
|
37
|
-
};
|
|
38
38
|
exports.default = Command;
|
|
39
39
|
const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:command')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields)))
|
|
40
40
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -44,9 +44,12 @@ const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js
|
|
|
44
44
|
function generateImports(info) {
|
|
45
45
|
const commandFieldTypes = info.fields.map((f) => f.type);
|
|
46
46
|
const commandUsesUUID = commandFieldTypes.some((type) => type == 'UUID');
|
|
47
|
-
const
|
|
47
|
+
const componentsFromMagekCommon = ['Register'];
|
|
48
|
+
if (info.fields.length > 0) {
|
|
49
|
+
componentsFromMagekCommon.unshift('Field');
|
|
50
|
+
}
|
|
48
51
|
if (commandUsesUUID) {
|
|
49
|
-
|
|
52
|
+
componentsFromMagekCommon.push('UUID');
|
|
50
53
|
}
|
|
51
54
|
return [
|
|
52
55
|
{
|
|
@@ -55,7 +58,7 @@ function generateImports(info) {
|
|
|
55
58
|
},
|
|
56
59
|
{
|
|
57
60
|
packagePath: '@magek/common',
|
|
58
|
-
commaSeparatedComponents:
|
|
61
|
+
commaSeparatedComponents: componentsFromMagekCommon.join(', '),
|
|
59
62
|
},
|
|
60
63
|
];
|
|
61
64
|
}
|
|
@@ -11,6 +11,23 @@ const generator_js_1 = require("../../services/generator.js");
|
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
const filenames_js_1 = require("../../common/filenames.js");
|
|
13
13
|
class Entity extends base_command_js_1.default {
|
|
14
|
+
static description = 'create a new entity';
|
|
15
|
+
static flags = {
|
|
16
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
17
|
+
fields: core_1.Flags.string({
|
|
18
|
+
char: 'f',
|
|
19
|
+
description: 'fields that this entity will contain',
|
|
20
|
+
multiple: true,
|
|
21
|
+
}),
|
|
22
|
+
reduces: core_1.Flags.string({
|
|
23
|
+
char: 'r',
|
|
24
|
+
description: 'events that this entity will reduce to build its state',
|
|
25
|
+
multiple: true,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
static args = {
|
|
29
|
+
entityName: core_1.Args.string(),
|
|
30
|
+
};
|
|
14
31
|
async run() {
|
|
15
32
|
const { args, flags } = await this.parse(Entity);
|
|
16
33
|
try {
|
|
@@ -25,23 +42,6 @@ class Entity extends base_command_js_1.default {
|
|
|
25
42
|
}
|
|
26
43
|
}
|
|
27
44
|
}
|
|
28
|
-
Entity.description = 'create a new entity';
|
|
29
|
-
Entity.flags = {
|
|
30
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
31
|
-
fields: core_1.Flags.string({
|
|
32
|
-
char: 'f',
|
|
33
|
-
description: 'fields that this entity will contain',
|
|
34
|
-
multiple: true,
|
|
35
|
-
}),
|
|
36
|
-
reduces: core_1.Flags.string({
|
|
37
|
-
char: 'r',
|
|
38
|
-
description: 'events that this entity will reduce to build its state',
|
|
39
|
-
multiple: true,
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
Entity.args = {
|
|
43
|
-
entityName: core_1.Args.string(),
|
|
44
|
-
};
|
|
45
45
|
exports.default = Entity;
|
|
46
46
|
const run = async (name, rawFields, rawEvents) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:entity')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields), (0, index_js_1.parseReaction)(rawEvents)))
|
|
47
47
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -60,6 +60,10 @@ function generateImports(info) {
|
|
|
60
60
|
if (info.events.length > 0) {
|
|
61
61
|
coreComponents.push('Reduces');
|
|
62
62
|
}
|
|
63
|
+
const commonComponents = ['UUID'];
|
|
64
|
+
if (info.fields.length > 0) {
|
|
65
|
+
commonComponents.unshift('Field');
|
|
66
|
+
}
|
|
63
67
|
return [
|
|
64
68
|
{
|
|
65
69
|
packagePath: '@magek/core',
|
|
@@ -67,7 +71,7 @@ function generateImports(info) {
|
|
|
67
71
|
},
|
|
68
72
|
{
|
|
69
73
|
packagePath: '@magek/common',
|
|
70
|
-
commaSeparatedComponents: '
|
|
74
|
+
commaSeparatedComponents: commonComponents.join(', '),
|
|
71
75
|
},
|
|
72
76
|
...eventsImports,
|
|
73
77
|
];
|
|
@@ -11,6 +11,18 @@ const generator_js_1 = require("../../services/generator.js");
|
|
|
11
11
|
const path = tslib_1.__importStar(require("path"));
|
|
12
12
|
const filenames_js_1 = require("../../common/filenames.js");
|
|
13
13
|
class EventHandler extends base_command_js_1.default {
|
|
14
|
+
static description = 'create a new event handler';
|
|
15
|
+
static flags = {
|
|
16
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
17
|
+
event: core_1.Flags.string({
|
|
18
|
+
char: 'e',
|
|
19
|
+
description: 'event that this event handler with handle',
|
|
20
|
+
multiple: false,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static args = {
|
|
24
|
+
eventHandlerName: core_1.Args.string(),
|
|
25
|
+
};
|
|
14
26
|
async run() {
|
|
15
27
|
const { args, flags } = await this.parse(EventHandler);
|
|
16
28
|
try {
|
|
@@ -26,18 +38,6 @@ class EventHandler extends base_command_js_1.default {
|
|
|
26
38
|
}
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
|
-
EventHandler.description = 'create a new event handler';
|
|
30
|
-
EventHandler.flags = {
|
|
31
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
32
|
-
event: core_1.Flags.string({
|
|
33
|
-
char: 'e',
|
|
34
|
-
description: 'event that this event handler with handle',
|
|
35
|
-
multiple: false,
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
EventHandler.args = {
|
|
39
|
-
eventHandlerName: core_1.Args.string(),
|
|
40
|
-
};
|
|
41
41
|
exports.default = EventHandler;
|
|
42
42
|
const run = async (name, eventName) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:event-handler')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseEvent)(eventName)))
|
|
43
43
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -10,6 +10,18 @@ const generator_js_1 = require("../../services/generator.js");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
class Event extends base_command_js_1.default {
|
|
13
|
+
static description = 'create a new event';
|
|
14
|
+
static flags = {
|
|
15
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
16
|
+
fields: core_1.Flags.string({
|
|
17
|
+
char: 'f',
|
|
18
|
+
description: 'field that this event will contain',
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
eventName: core_1.Args.string(),
|
|
24
|
+
};
|
|
13
25
|
async run() {
|
|
14
26
|
const { args, flags } = await this.parse(Event);
|
|
15
27
|
try {
|
|
@@ -23,25 +35,17 @@ class Event extends base_command_js_1.default {
|
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
Event.description = 'create a new event';
|
|
27
|
-
Event.flags = {
|
|
28
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
29
|
-
fields: core_1.Flags.string({
|
|
30
|
-
char: 'f',
|
|
31
|
-
description: 'field that this event will contain',
|
|
32
|
-
multiple: true,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
Event.args = {
|
|
36
|
-
eventName: core_1.Args.string(),
|
|
37
|
-
};
|
|
38
38
|
exports.default = Event;
|
|
39
39
|
const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:event')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields)))
|
|
40
40
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
41
41
|
.step('Creating new event', generateEvent)
|
|
42
42
|
.info('Event generated!')
|
|
43
43
|
.done();
|
|
44
|
-
function generateImports() {
|
|
44
|
+
function generateImports(info) {
|
|
45
|
+
const commonComponents = ['UUID'];
|
|
46
|
+
if (info.fields.length > 0) {
|
|
47
|
+
commonComponents.unshift('Field');
|
|
48
|
+
}
|
|
45
49
|
return [
|
|
46
50
|
{
|
|
47
51
|
packagePath: '@magek/core',
|
|
@@ -49,7 +53,7 @@ function generateImports() {
|
|
|
49
53
|
},
|
|
50
54
|
{
|
|
51
55
|
packagePath: '@magek/common',
|
|
52
|
-
commaSeparatedComponents: '
|
|
56
|
+
commaSeparatedComponents: commonComponents.join(', '),
|
|
53
57
|
},
|
|
54
58
|
];
|
|
55
59
|
}
|
|
@@ -59,7 +63,7 @@ const generateEvent = (info) => (0, generator_js_1.generate)({
|
|
|
59
63
|
placementDir: path.join('src', 'events'),
|
|
60
64
|
template: (0, generator_js_1.template)('event'),
|
|
61
65
|
info: {
|
|
62
|
-
imports: generateImports(),
|
|
66
|
+
imports: generateImports(info),
|
|
63
67
|
...info,
|
|
64
68
|
},
|
|
65
69
|
});
|
|
@@ -10,6 +10,18 @@ const index_js_1 = require("../../services/generator/target/index.js");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
class Query extends base_command_js_1.default {
|
|
13
|
+
static description = "generate new query resource, write 'magek new' to see options";
|
|
14
|
+
static flags = {
|
|
15
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
16
|
+
fields: core_1.Flags.string({
|
|
17
|
+
char: 'f',
|
|
18
|
+
description: 'field list that this query will contain',
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
queryName: core_1.Args.string(),
|
|
24
|
+
};
|
|
13
25
|
async run() {
|
|
14
26
|
const { args, flags } = await this.parse(Query);
|
|
15
27
|
try {
|
|
@@ -23,18 +35,6 @@ class Query extends base_command_js_1.default {
|
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
Query.description = "generate new query resource, write 'magek new' to see options";
|
|
27
|
-
Query.flags = {
|
|
28
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
29
|
-
fields: core_1.Flags.string({
|
|
30
|
-
char: 'f',
|
|
31
|
-
description: 'field list that this query will contain',
|
|
32
|
-
multiple: true,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
Query.args = {
|
|
36
|
-
queryName: core_1.Args.string(),
|
|
37
|
-
};
|
|
38
38
|
exports.default = Query;
|
|
39
39
|
const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:query')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields)))
|
|
40
40
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -44,9 +44,12 @@ const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js
|
|
|
44
44
|
function generateImports(info) {
|
|
45
45
|
const queryFieldTypes = info.fields.map((f) => f.type);
|
|
46
46
|
const queryUsesUUID = queryFieldTypes.some((type) => type == 'UUID');
|
|
47
|
-
const
|
|
47
|
+
const componentsFromMagekCommon = ['QueryInfo'];
|
|
48
|
+
if (info.fields.length > 0) {
|
|
49
|
+
componentsFromMagekCommon.unshift('Field');
|
|
50
|
+
}
|
|
48
51
|
if (queryUsesUUID) {
|
|
49
|
-
|
|
52
|
+
componentsFromMagekCommon.push('UUID');
|
|
50
53
|
}
|
|
51
54
|
return [
|
|
52
55
|
{
|
|
@@ -55,7 +58,7 @@ function generateImports(info) {
|
|
|
55
58
|
},
|
|
56
59
|
{
|
|
57
60
|
packagePath: '@magek/common',
|
|
58
|
-
commaSeparatedComponents:
|
|
61
|
+
commaSeparatedComponents: componentsFromMagekCommon.join(', '),
|
|
59
62
|
},
|
|
60
63
|
];
|
|
61
64
|
}
|
|
@@ -11,12 +11,28 @@ const generator_js_1 = require("../../services/generator.js");
|
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
const filenames_js_1 = require("../../common/filenames.js");
|
|
13
13
|
class ReadModel extends base_command_js_1.default {
|
|
14
|
+
static description = 'create a new read model';
|
|
15
|
+
static flags = {
|
|
16
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
17
|
+
fields: core_1.Flags.string({
|
|
18
|
+
char: 'f',
|
|
19
|
+
description: 'fields that this read model will contain',
|
|
20
|
+
multiple: true,
|
|
21
|
+
}),
|
|
22
|
+
projects: core_1.Flags.string({
|
|
23
|
+
char: 'p',
|
|
24
|
+
description: 'entities that this read model will project to build its state',
|
|
25
|
+
multiple: true,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
static args = {
|
|
29
|
+
readModelName: core_1.Args.string(),
|
|
30
|
+
};
|
|
14
31
|
async run() {
|
|
15
|
-
var _a, _b;
|
|
16
32
|
const { args, flags } = await this.parse(ReadModel);
|
|
17
33
|
try {
|
|
18
|
-
const fields =
|
|
19
|
-
const projections =
|
|
34
|
+
const fields = flags.fields ?? [];
|
|
35
|
+
const projections = flags.projects ?? [];
|
|
20
36
|
if (!args.readModelName)
|
|
21
37
|
throw "You haven't provided a read model name, but it is required, run with --help for usage";
|
|
22
38
|
return run(args.readModelName, fields, projections);
|
|
@@ -26,23 +42,6 @@ class ReadModel extends base_command_js_1.default {
|
|
|
26
42
|
}
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
|
-
ReadModel.description = 'create a new read model';
|
|
30
|
-
ReadModel.flags = {
|
|
31
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
32
|
-
fields: core_1.Flags.string({
|
|
33
|
-
char: 'f',
|
|
34
|
-
description: 'fields that this read model will contain',
|
|
35
|
-
multiple: true,
|
|
36
|
-
}),
|
|
37
|
-
projects: core_1.Flags.string({
|
|
38
|
-
char: 'p',
|
|
39
|
-
description: 'entities that this read model will project to build its state',
|
|
40
|
-
multiple: true,
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
ReadModel.args = {
|
|
44
|
-
readModelName: core_1.Args.string(),
|
|
45
|
-
};
|
|
46
45
|
exports.default = ReadModel;
|
|
47
46
|
const run = async (name, rawFields, rawProjections) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:read-model')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields), (0, index_js_1.parseProjections)(rawProjections)))
|
|
48
47
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -61,6 +60,13 @@ function generateImports(info) {
|
|
|
61
60
|
if (info.projections.length > 0) {
|
|
62
61
|
coreComponents.push('Projects');
|
|
63
62
|
}
|
|
63
|
+
const commonComponents = ['UUID'];
|
|
64
|
+
if (info.fields.length > 0) {
|
|
65
|
+
commonComponents.unshift('Field');
|
|
66
|
+
}
|
|
67
|
+
if (info.projections.length > 0) {
|
|
68
|
+
commonComponents.push('ProjectionResult');
|
|
69
|
+
}
|
|
64
70
|
return [
|
|
65
71
|
{
|
|
66
72
|
packagePath: '@magek/core',
|
|
@@ -68,7 +74,7 @@ function generateImports(info) {
|
|
|
68
74
|
},
|
|
69
75
|
{
|
|
70
76
|
packagePath: '@magek/common',
|
|
71
|
-
commaSeparatedComponents:
|
|
77
|
+
commaSeparatedComponents: commonComponents.join(', '),
|
|
72
78
|
},
|
|
73
79
|
...eventsImports,
|
|
74
80
|
];
|
|
@@ -10,6 +10,13 @@ const index_js_1 = require("../../services/generator/target/index.js");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
class ScheduledCommand extends base_command_js_1.default {
|
|
13
|
+
static description = "generate new scheduled command, write 'magek new:scheduled-command -h' to see options";
|
|
14
|
+
static flags = {
|
|
15
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
16
|
+
};
|
|
17
|
+
static args = {
|
|
18
|
+
scheduledCommandName: core_1.Args.string(),
|
|
19
|
+
};
|
|
13
20
|
async run() {
|
|
14
21
|
const { args } = await this.parse(ScheduledCommand);
|
|
15
22
|
try {
|
|
@@ -22,13 +29,6 @@ class ScheduledCommand extends base_command_js_1.default {
|
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
ScheduledCommand.description = "generate new scheduled command, write 'magek new:scheduled-command -h' to see options";
|
|
26
|
-
ScheduledCommand.flags = {
|
|
27
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
28
|
-
};
|
|
29
|
-
ScheduledCommand.args = {
|
|
30
|
-
scheduledCommandName: core_1.Args.string(),
|
|
31
|
-
};
|
|
32
32
|
exports.default = ScheduledCommand;
|
|
33
33
|
const run = async (name) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:scheduled-command')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name)))
|
|
34
34
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
@@ -10,6 +10,18 @@ const generator_js_1 = require("../../services/generator.js");
|
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
11
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
12
12
|
class Type extends base_command_js_1.default {
|
|
13
|
+
static description = 'create a new type';
|
|
14
|
+
static flags = {
|
|
15
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
16
|
+
fields: core_1.Flags.string({
|
|
17
|
+
char: 'f',
|
|
18
|
+
description: 'field that this type will contain',
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
typeName: core_1.Args.string(),
|
|
24
|
+
};
|
|
13
25
|
async run() {
|
|
14
26
|
const { args, flags } = await this.parse(Type);
|
|
15
27
|
try {
|
|
@@ -23,31 +35,39 @@ class Type extends base_command_js_1.default {
|
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
Type.description = 'create a new type';
|
|
27
|
-
Type.flags = {
|
|
28
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
29
|
-
fields: core_1.Flags.string({
|
|
30
|
-
char: 'f',
|
|
31
|
-
description: 'field that this type will contain',
|
|
32
|
-
multiple: true,
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
Type.args = {
|
|
36
|
-
typeName: core_1.Args.string(),
|
|
37
|
-
};
|
|
38
38
|
exports.default = Type;
|
|
39
39
|
const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js_1.default.energize('new:type')} 🚧`, (0, index_js_1.joinParsers)((0, index_js_1.parseName)(name), (0, index_js_1.parseFields)(rawFields)))
|
|
40
40
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
|
41
41
|
.step('Creating new type', generateType)
|
|
42
42
|
.info('Type generated!')
|
|
43
43
|
.done();
|
|
44
|
+
function generateImports(info) {
|
|
45
|
+
const typeFieldTypes = info.fields.map((f) => f.type);
|
|
46
|
+
const typeUsesUUID = typeFieldTypes.some((type) => type == 'UUID');
|
|
47
|
+
const componentsFromMagekCommon = [];
|
|
48
|
+
if (info.fields.length > 0) {
|
|
49
|
+
componentsFromMagekCommon.push('Field');
|
|
50
|
+
}
|
|
51
|
+
if (typeUsesUUID) {
|
|
52
|
+
componentsFromMagekCommon.push('UUID');
|
|
53
|
+
}
|
|
54
|
+
if (componentsFromMagekCommon.length === 0) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
packagePath: '@magek/common',
|
|
60
|
+
commaSeparatedComponents: componentsFromMagekCommon.join(', '),
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
44
64
|
const generateType = (info) => (0, generator_js_1.generate)({
|
|
45
65
|
name: info.name,
|
|
46
66
|
extension: '.ts',
|
|
47
67
|
placementDir: path.join('src', 'common'),
|
|
48
68
|
template: (0, generator_js_1.template)('type'),
|
|
49
69
|
info: {
|
|
50
|
-
imports:
|
|
70
|
+
imports: generateImports(info),
|
|
51
71
|
...info,
|
|
52
72
|
},
|
|
53
73
|
});
|
|
@@ -9,6 +9,15 @@ const stub_publisher_js_1 = require("../../services/stub-publisher.js");
|
|
|
9
9
|
const project_checker_js_1 = require("../../services/project-checker.js");
|
|
10
10
|
const user_prompt_js_1 = tslib_1.__importDefault(require("../../services/user-prompt.js"));
|
|
11
11
|
class Publish extends base_command_js_1.default {
|
|
12
|
+
static description = 'publish all resource template stubs that are available for customization';
|
|
13
|
+
static usage = 'magek stub:publish --force';
|
|
14
|
+
static examples = ['$ magek stub:publish --force', '$ magek stub:publish'];
|
|
15
|
+
static flags = {
|
|
16
|
+
force: core_1.Flags.boolean({
|
|
17
|
+
char: 'f',
|
|
18
|
+
description: 'Overwrite any existing stub files',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
12
21
|
async run() {
|
|
13
22
|
const { flags } = await this.parse(Publish);
|
|
14
23
|
const stubFolderExists = (0, stub_publisher_js_1.checkStubsFolderExists)();
|
|
@@ -27,15 +36,6 @@ class Publish extends base_command_js_1.default {
|
|
|
27
36
|
await run();
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
|
-
Publish.description = 'publish all resource template stubs that are available for customization';
|
|
31
|
-
Publish.usage = 'magek stub:publish --force';
|
|
32
|
-
Publish.examples = ['$ magek stub:publish --force', '$ magek stub:publish'];
|
|
33
|
-
Publish.flags = {
|
|
34
|
-
force: core_1.Flags.boolean({
|
|
35
|
-
char: 'f',
|
|
36
|
-
description: 'Overwrite any existing stub files',
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
39
|
exports.default = Publish;
|
|
40
40
|
const run = async () => script_js_1.Script.init(`magek ${brand_js_1.default.energize('stub:publish')} 🗄`, Promise.resolve(process.cwd()))
|
|
41
41
|
.step('Verifying project', project_checker_js_1.checkCurrentDirIsAMagekProject)
|
package/dist/common/script.js
CHANGED
|
@@ -14,60 +14,72 @@ const brand_js_1 = tslib_1.__importDefault(require("./brand.js"));
|
|
|
14
14
|
* implicitly, and makes it available for all of the steps that define this process.
|
|
15
15
|
*/
|
|
16
16
|
class Script {
|
|
17
|
+
contextResolver;
|
|
18
|
+
errorHandlers;
|
|
19
|
+
action;
|
|
17
20
|
constructor(contextResolver, errorHandlers, action) {
|
|
18
|
-
/**
|
|
19
|
-
* Method that eases the creation of steps. It accepts a message to be shown in the spinner and a
|
|
20
|
-
* function that receives the context and the input from the previous step.
|
|
21
|
-
* From this function you must return a Promise that resolves with the value that you want to pass to the next step (if any)
|
|
22
|
-
*
|
|
23
|
-
* @param message Message to initialize the spinner
|
|
24
|
-
* @param action Function that receives the config object and performs an action
|
|
25
|
-
*/
|
|
26
|
-
this.step = (message, action) => new Script(this.contextResolver, this.errorHandlers, (0, pipeable_js_1.pipe)(this.action, (0, ReaderTaskEither_js_1.chain)(() => (0, ReaderTaskEither_js_1.ask)()), (0, ReaderTaskEither_js_1.chain)((ctx) => (0, ReaderTaskEither_js_1.fromTaskEither)((0, TaskEither_js_1.tryCatch)(async () => {
|
|
27
|
-
Script.logger.start(message);
|
|
28
|
-
await action(ctx);
|
|
29
|
-
Script.logger.succeed(message);
|
|
30
|
-
}, (err) => {
|
|
31
|
-
Script.logger.fail(message);
|
|
32
|
-
return err;
|
|
33
|
-
})))));
|
|
34
|
-
/**
|
|
35
|
-
* Function to determine next action depending on passed boolean condition
|
|
36
|
-
* If condition is true, step will be skipped and info action will be called.
|
|
37
|
-
* Otherwise, step method will be called as usual.
|
|
38
|
-
*
|
|
39
|
-
* @param skipCondition When true, the action is skipped
|
|
40
|
-
* @param message Message to initialize the spinner
|
|
41
|
-
* @param action Function that receives the config object and performs an action
|
|
42
|
-
*/
|
|
43
|
-
this.optionalStep = (skipCondition, message, action) => {
|
|
44
|
-
if (skipCondition)
|
|
45
|
-
return this.info(brand_js_1.default.mellancholize(`Skipping: ${message}`));
|
|
46
|
-
return this.step(message, action);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Convenience method to generate a step that just prints a message with a small blue `i` character in front of it.
|
|
50
|
-
*
|
|
51
|
-
* @param message Message to be shown in the CLI
|
|
52
|
-
*/
|
|
53
|
-
this.info = (message) => new Script(this.contextResolver, this.errorHandlers, (0, pipeable_js_1.pipe)(this.action, (0, ReaderTaskEither_js_1.chain)(() => (0, ReaderTaskEither_js_1.rightIO)(() => {
|
|
54
|
-
Script.logger.info(message);
|
|
55
|
-
}))));
|
|
56
|
-
/**
|
|
57
|
-
* Add a handler to catch a specific type of errors
|
|
58
|
-
*
|
|
59
|
-
* @param errorType the kind of errors that the handler will catch
|
|
60
|
-
* @param handler handler for the errors
|
|
61
|
-
*/
|
|
62
|
-
this.catch = (errorType, handler) => {
|
|
63
|
-
const newHandlers = { ...this.errorHandlers };
|
|
64
|
-
newHandlers[errorType] = handler;
|
|
65
|
-
return new Script(this.contextResolver, newHandlers, this.action);
|
|
66
|
-
};
|
|
67
21
|
this.contextResolver = contextResolver;
|
|
68
22
|
this.errorHandlers = errorHandlers;
|
|
69
23
|
this.action = action;
|
|
70
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Convenience function to print a welcome message and initialize the context of the script
|
|
27
|
+
*
|
|
28
|
+
* @param initialMessage The message to show in the console
|
|
29
|
+
* @param contextResolver A promise that fulfills into a valid context object
|
|
30
|
+
*/
|
|
31
|
+
static init = (initialMessage, contextResolver) => new Script(contextResolver, {}, (0, ReaderTaskEither_js_1.rightIO)(() => {
|
|
32
|
+
Script.logger.info(initialMessage);
|
|
33
|
+
}));
|
|
34
|
+
/**
|
|
35
|
+
* Method that eases the creation of steps. It accepts a message to be shown in the spinner and a
|
|
36
|
+
* function that receives the context and the input from the previous step.
|
|
37
|
+
* From this function you must return a Promise that resolves with the value that you want to pass to the next step (if any)
|
|
38
|
+
*
|
|
39
|
+
* @param message Message to initialize the spinner
|
|
40
|
+
* @param action Function that receives the config object and performs an action
|
|
41
|
+
*/
|
|
42
|
+
step = (message, action) => new Script(this.contextResolver, this.errorHandlers, (0, pipeable_js_1.pipe)(this.action, (0, ReaderTaskEither_js_1.chain)(() => (0, ReaderTaskEither_js_1.ask)()), (0, ReaderTaskEither_js_1.chain)((ctx) => (0, ReaderTaskEither_js_1.fromTaskEither)((0, TaskEither_js_1.tryCatch)(async () => {
|
|
43
|
+
Script.logger.start(message);
|
|
44
|
+
await action(ctx);
|
|
45
|
+
Script.logger.succeed(message);
|
|
46
|
+
}, (err) => {
|
|
47
|
+
Script.logger.fail(message);
|
|
48
|
+
return err;
|
|
49
|
+
})))));
|
|
50
|
+
/**
|
|
51
|
+
* Function to determine next action depending on passed boolean condition
|
|
52
|
+
* If condition is true, step will be skipped and info action will be called.
|
|
53
|
+
* Otherwise, step method will be called as usual.
|
|
54
|
+
*
|
|
55
|
+
* @param skipCondition When true, the action is skipped
|
|
56
|
+
* @param message Message to initialize the spinner
|
|
57
|
+
* @param action Function that receives the config object and performs an action
|
|
58
|
+
*/
|
|
59
|
+
optionalStep = (skipCondition, message, action) => {
|
|
60
|
+
if (skipCondition)
|
|
61
|
+
return this.info(brand_js_1.default.mellancholize(`Skipping: ${message}`));
|
|
62
|
+
return this.step(message, action);
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Convenience method to generate a step that just prints a message with a small blue `i` character in front of it.
|
|
66
|
+
*
|
|
67
|
+
* @param message Message to be shown in the CLI
|
|
68
|
+
*/
|
|
69
|
+
info = (message) => new Script(this.contextResolver, this.errorHandlers, (0, pipeable_js_1.pipe)(this.action, (0, ReaderTaskEither_js_1.chain)(() => (0, ReaderTaskEither_js_1.rightIO)(() => {
|
|
70
|
+
Script.logger.info(message);
|
|
71
|
+
}))));
|
|
72
|
+
/**
|
|
73
|
+
* Add a handler to catch a specific type of errors
|
|
74
|
+
*
|
|
75
|
+
* @param errorType the kind of errors that the handler will catch
|
|
76
|
+
* @param handler handler for the errors
|
|
77
|
+
*/
|
|
78
|
+
catch = (errorType, handler) => {
|
|
79
|
+
const newHandlers = { ...this.errorHandlers };
|
|
80
|
+
newHandlers[errorType] = handler;
|
|
81
|
+
return new Script(this.contextResolver, newHandlers, this.action);
|
|
82
|
+
};
|
|
71
83
|
/**
|
|
72
84
|
* Function to finish the script,
|
|
73
85
|
* it will handle any error in between that might happen in
|
|
@@ -88,15 +100,6 @@ class Script {
|
|
|
88
100
|
throw new Error(handler(error));
|
|
89
101
|
}
|
|
90
102
|
}
|
|
103
|
+
static logger = logger_js_1.oraLogger;
|
|
91
104
|
}
|
|
92
105
|
exports.Script = Script;
|
|
93
|
-
/**
|
|
94
|
-
* Convenience function to print a welcome message and initialize the context of the script
|
|
95
|
-
*
|
|
96
|
-
* @param initialMessage The message to show in the console
|
|
97
|
-
* @param contextResolver A promise that fulfills into a valid context object
|
|
98
|
-
*/
|
|
99
|
-
Script.init = (initialMessage, contextResolver) => new Script(contextResolver, {}, (0, ReaderTaskEither_js_1.rightIO)(() => {
|
|
100
|
-
Script.logger.info(initialMessage);
|
|
101
|
-
}));
|
|
102
|
-
Script.logger = logger_js_1.oraLogger;
|
|
@@ -17,14 +17,13 @@ const extractEnvironmentArg = () => {
|
|
|
17
17
|
return environment;
|
|
18
18
|
};
|
|
19
19
|
const hook = async function (opts) {
|
|
20
|
-
var _a;
|
|
21
20
|
// ensure opts.argv is argv without the environment
|
|
22
21
|
process.env['MAGEK_CLI_HOOK'] = 'true';
|
|
23
22
|
if (opts.id === '-e') {
|
|
24
23
|
opts.id = '';
|
|
25
|
-
opts.argv = ['-e', ...(
|
|
24
|
+
opts.argv = ['-e', ...(opts.argv ?? [])];
|
|
26
25
|
}
|
|
27
|
-
const firstArgs = process.argv.filter((arg) =>
|
|
26
|
+
const firstArgs = process.argv.filter((arg) => !opts.argv?.includes(arg));
|
|
28
27
|
const environment = extractEnvironmentArg();
|
|
29
28
|
opts.argv = process.argv.filter((arg) => !firstArgs.includes(arg));
|
|
30
29
|
const cwd = process.cwd();
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileSystemError = void 0;
|
|
4
4
|
class FileSystemError extends Error {
|
|
5
|
+
cause;
|
|
6
|
+
_tag = 'FileSystemError';
|
|
5
7
|
constructor(message, cause) {
|
|
6
8
|
super(message);
|
|
7
9
|
this.cause = cause;
|
|
8
|
-
this._tag = 'FileSystemError';
|
|
9
10
|
this.name = 'FileSystemError';
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RunScriptError = exports.InstallDependenciesError = void 0;
|
|
4
4
|
class InstallDependenciesError extends Error {
|
|
5
|
+
cause;
|
|
6
|
+
_tag = 'InstallDependenciesError';
|
|
5
7
|
constructor(message, cause) {
|
|
6
8
|
super(message);
|
|
7
9
|
this.cause = cause;
|
|
8
|
-
this._tag = 'InstallDependenciesError';
|
|
9
10
|
this.name = 'InstallDependenciesError';
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
exports.InstallDependenciesError = InstallDependenciesError;
|
|
13
14
|
class RunScriptError extends Error {
|
|
15
|
+
cause;
|
|
16
|
+
_tag = 'RunScriptError';
|
|
14
17
|
constructor(message, cause) {
|
|
15
18
|
super(message);
|
|
16
19
|
this.cause = cause;
|
|
17
|
-
this._tag = 'RunScriptError';
|
|
18
20
|
this.name = 'RunScriptError';
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessError = void 0;
|
|
4
4
|
class ProcessError extends Error {
|
|
5
|
+
cause;
|
|
6
|
+
_tag = 'ProcessError';
|
|
5
7
|
constructor(message, cause) {
|
|
6
8
|
super(message);
|
|
7
9
|
this.cause = cause;
|
|
8
|
-
this._tag = 'ProcessError';
|
|
9
10
|
this.name = 'ProcessError';
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -87,6 +87,9 @@ async function getMagekVersion(projectPath) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
class HigherCliVersionError extends Error {
|
|
90
|
+
cliVersion;
|
|
91
|
+
projectVersion;
|
|
92
|
+
section;
|
|
90
93
|
constructor(cliVersion, projectVersion, section) {
|
|
91
94
|
super(`CLI version ${cliVersion} is higher than your project Magek version ${projectVersion} in the '${section}' section. Please upgrade your project Magek dependencies.`);
|
|
92
95
|
this.cliVersion = cliVersion;
|
|
@@ -95,6 +98,9 @@ class HigherCliVersionError extends Error {
|
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
class LowerCliVersionError extends Error {
|
|
101
|
+
cliVersion;
|
|
102
|
+
projectVersion;
|
|
103
|
+
section;
|
|
98
104
|
constructor(cliVersion, projectVersion, section) {
|
|
99
105
|
super(`CLI version ${cliVersion} is lower than your project Magek version ${projectVersion}. Please upgrade your @magek/cli to the same version with "npm install -g @magek/cli@${projectVersion}"`);
|
|
100
106
|
this.cliVersion = cliVersion;
|
package/dist/services/semver.js
CHANGED
|
@@ -4,16 +4,16 @@ import { {{commaSeparatedComponents}} } from '{{{packagePath}}}'
|
|
|
4
4
|
|
|
5
5
|
@Entity
|
|
6
6
|
export class {{{name}}} {
|
|
7
|
-
@
|
|
7
|
+
@field(type => UUID)
|
|
8
8
|
public id!: UUID
|
|
9
9
|
|
|
10
10
|
{{#fields}}
|
|
11
|
-
@
|
|
11
|
+
@field()
|
|
12
12
|
readonly {{{name}}}!: {{{type}}}
|
|
13
13
|
|
|
14
14
|
{{/fields}}
|
|
15
15
|
{{#events}}
|
|
16
|
-
@
|
|
16
|
+
@reduces({{{eventName}}})
|
|
17
17
|
public static reduce{{{eventName}}}(event: {{{eventName}}}, current{{{name}}}?: {{{name}}}): {{{name}}} {
|
|
18
18
|
return /* NEW {{name}} HERE */
|
|
19
19
|
}
|
|
@@ -4,11 +4,20 @@ import { {{commaSeparatedComponents}} } from '{{{packagePath}}}'
|
|
|
4
4
|
|
|
5
5
|
@Event
|
|
6
6
|
export class {{{ name }}} {
|
|
7
|
+
{{#fields}}
|
|
8
|
+
@field()
|
|
9
|
+
public readonly {{{name}}}!: {{{type}}}
|
|
10
|
+
|
|
11
|
+
{{/fields}}
|
|
7
12
|
public constructor(
|
|
8
13
|
{{#fields}}
|
|
9
|
-
|
|
14
|
+
{{{name}}}: {{{type}}},
|
|
15
|
+
{{/fields}}
|
|
16
|
+
) {
|
|
17
|
+
{{#fields}}
|
|
18
|
+
this.{{{name}}} = {{{name}}}
|
|
10
19
|
{{/fields}}
|
|
11
|
-
|
|
20
|
+
}
|
|
12
21
|
|
|
13
22
|
public entityID(): UUID {
|
|
14
23
|
return /* the associated entity ID */
|
|
@@ -6,16 +6,16 @@ import { {{commaSeparatedComponents}} } from '{{{packagePath}}}'
|
|
|
6
6
|
authorize: // Specify authorized roles here. Use 'all' to authorize anyone
|
|
7
7
|
})
|
|
8
8
|
export class {{{name}}} {
|
|
9
|
-
@
|
|
9
|
+
@field(type => UUID)
|
|
10
10
|
public id!: UUID
|
|
11
11
|
|
|
12
12
|
{{#fields}}
|
|
13
|
-
@
|
|
13
|
+
@field()
|
|
14
14
|
readonly {{{name}}}!: {{{type}}}
|
|
15
15
|
|
|
16
16
|
{{/fields}}
|
|
17
17
|
{{#projections}}
|
|
18
|
-
@
|
|
18
|
+
@projects({{{entityName}}}, "{{{entityId}}}")
|
|
19
19
|
public static project{{{entityName}}}(entity: {{{entityName}}}, current{{{name}}}?: {{{name}}}): ProjectionResult<{{{name}}}> {
|
|
20
20
|
return /* NEW {{name}} HERE */
|
|
21
21
|
}
|
package/dist/templates/type.stub
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
{{#imports}}
|
|
2
|
+
import { {{commaSeparatedComponents}} } from '{{{packagePath}}}'
|
|
3
|
+
{{/imports}}
|
|
4
|
+
|
|
1
5
|
export class {{{ name }}} {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
{{#fields}}
|
|
7
|
+
@field()
|
|
8
|
+
public {{{name}}}!: {{{type}}}
|
|
9
|
+
|
|
10
|
+
{{/fields}}
|
|
7
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magek/cli",
|
|
3
3
|
"description": "CLI of the Magek Framework, the next level of abstraction for cloud-native applications",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"author": "Boosterin Labs SLU",
|
|
6
6
|
"homepage": "https://magek.ai",
|
|
7
7
|
"publishConfig": {
|
|
@@ -12,24 +12,24 @@
|
|
|
12
12
|
},
|
|
13
13
|
"bugs": "https://github.com/theam/magek/issues",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@magek/common": "^0.0.
|
|
15
|
+
"@magek/common": "^0.0.7",
|
|
16
16
|
"@oclif/core": "4.8.0",
|
|
17
|
-
"@oclif/plugin-help": "6.2.
|
|
18
|
-
"@oclif/plugin-plugins": "5.4.
|
|
17
|
+
"@oclif/plugin-help": "6.2.37",
|
|
18
|
+
"@oclif/plugin-plugins": "5.4.55",
|
|
19
19
|
"chalk": "5.6.2",
|
|
20
20
|
"execa": "9.6.1",
|
|
21
21
|
"fp-ts": "2.16.11",
|
|
22
22
|
"fs-extra": "11.3.3",
|
|
23
23
|
"inflected": "2.1.0",
|
|
24
|
-
"inquirer": "13.2.
|
|
24
|
+
"inquirer": "13.2.2",
|
|
25
25
|
"mustache": "4.2.0",
|
|
26
26
|
"ora": "9.1.0",
|
|
27
27
|
"ts-morph": "27.0.2",
|
|
28
28
|
"tslib": "2.8.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@magek/eslint-config": "^0.0.
|
|
32
|
-
"@oclif/test": "4.1.
|
|
31
|
+
"@magek/eslint-config": "^0.0.7",
|
|
32
|
+
"@oclif/test": "4.1.16",
|
|
33
33
|
"@types/chai": "5.2.3",
|
|
34
34
|
"@types/chai-as-promised": "8.0.2",
|
|
35
35
|
"@types/fs-extra": "11.0.4",
|