@magek/cli 0.0.4 → 0.0.6

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.
@@ -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 componentsFromMagekTypes = ['Register'];
47
+ const componentsFromMagekCommon = ['Register'];
48
+ if (info.fields.length > 0) {
49
+ componentsFromMagekCommon.unshift('Field');
50
+ }
48
51
  if (commandUsesUUID) {
49
- componentsFromMagekTypes.push('UUID');
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: componentsFromMagekTypes.join(', '),
61
+ commaSeparatedComponents: componentsFromMagekCommon.join(', '),
59
62
  },
60
63
  ];
61
64
  }
@@ -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: 'UUID',
74
+ commaSeparatedComponents: commonComponents.join(', '),
71
75
  },
72
76
  ...eventsImports,
73
77
  ];
@@ -41,7 +41,11 @@ const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js
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: 'UUID',
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
  });
@@ -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 componentsFromMagekTypes = ['QueryInfo'];
47
+ const componentsFromMagekCommon = ['QueryInfo'];
48
+ if (info.fields.length > 0) {
49
+ componentsFromMagekCommon.unshift('Field');
50
+ }
48
51
  if (queryUsesUUID) {
49
- componentsFromMagekTypes.push('UUID');
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: componentsFromMagekTypes.join(', '),
61
+ commaSeparatedComponents: componentsFromMagekCommon.join(', '),
59
62
  },
60
63
  ];
61
64
  }
@@ -61,6 +61,13 @@ function generateImports(info) {
61
61
  if (info.projections.length > 0) {
62
62
  coreComponents.push('Projects');
63
63
  }
64
+ const commonComponents = ['UUID'];
65
+ if (info.fields.length > 0) {
66
+ commonComponents.unshift('Field');
67
+ }
68
+ if (info.projections.length > 0) {
69
+ commonComponents.push('ProjectionResult');
70
+ }
64
71
  return [
65
72
  {
66
73
  packagePath: '@magek/core',
@@ -68,7 +75,7 @@ function generateImports(info) {
68
75
  },
69
76
  {
70
77
  packagePath: '@magek/common',
71
- commaSeparatedComponents: info.projections.length > 0 ? 'UUID, ProjectionResult' : 'UUID',
78
+ commaSeparatedComponents: commonComponents.join(', '),
72
79
  },
73
80
  ...eventsImports,
74
81
  ];
@@ -41,13 +41,33 @@ const run = async (name, rawFields) => script_js_1.Script.init(`magek ${brand_js
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
  });
@@ -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
- readonly {{{name}}}: {{{type}}},
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 */
@@ -1,7 +1,11 @@
1
+ {{#imports}}
2
+ import { {{commaSeparatedComponents}} } from '{{{packagePath}}}'
3
+ {{/imports}}
4
+
1
5
  export class {{{ name }}} {
2
- public constructor(
3
- {{#fields}}
4
- public {{{name}}}: {{{type}}},
5
- {{/fields}}
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",
4
+ "version": "0.0.6",
5
5
  "author": "Boosterin Labs SLU",
6
6
  "homepage": "https://magek.ai",
7
7
  "publishConfig": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "bugs": "https://github.com/theam/magek/issues",
14
14
  "dependencies": {
15
- "@magek/common": "^0.0.4",
15
+ "@magek/common": "^0.0.6",
16
16
  "@oclif/core": "4.8.0",
17
17
  "@oclif/plugin-help": "6.2.36",
18
18
  "@oclif/plugin-plugins": "5.4.54",
@@ -23,12 +23,12 @@
23
23
  "inflected": "2.1.0",
24
24
  "inquirer": "13.2.0",
25
25
  "mustache": "4.2.0",
26
- "ora": "9.0.0",
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.4",
31
+ "@magek/eslint-config": "^0.0.6",
32
32
  "@oclif/test": "4.1.15",
33
33
  "@types/chai": "5.2.3",
34
34
  "@types/chai-as-promised": "8.0.2",