@mbc-cqrs-serverless/cli 0.1.50-beta.0 → 0.1.51-beta.0

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.
Files changed (108) hide show
  1. package/dist/actions/generate.action.js +44 -0
  2. package/dist/actions/new.action.get-package-version.spec.js +29 -0
  3. package/dist/actions/new.action.is-latest-version.spec.js +36 -0
  4. package/dist/actions/new.action.js +12 -6
  5. package/dist/actions/new.action.spec.js +84 -0
  6. package/dist/actions/new.action.update-env-local.spec.js +35 -0
  7. package/dist/actions/new.action.use-package-version.spec.js +46 -0
  8. package/dist/actions/ui.action.js +7 -5
  9. package/dist/commands/command.input.js +2 -0
  10. package/dist/commands/generate.command.js +24 -0
  11. package/dist/commands/index.js +2 -0
  12. package/dist/index.js +13 -2
  13. package/dist/runners/abstract.runner.js +44 -0
  14. package/dist/runners/schematic.runner.js +21 -0
  15. package/dist/schematics/collection.json +34 -0
  16. package/dist/schematics/index.js +17 -0
  17. package/dist/schematics/lib/controller/controller.factory.js +40 -0
  18. package/dist/schematics/lib/controller/controller.factory.spec.js +79 -0
  19. package/dist/schematics/lib/controller/files/__name@dasherize__.controller.ts +11 -0
  20. package/dist/schematics/lib/controller/schema.json +18 -0
  21. package/dist/schematics/lib/controller/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
  22. package/dist/schematics/lib/dto/dto.factory.js +32 -0
  23. package/dist/schematics/lib/dto/dto.factory.spec.js +128 -0
  24. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-attributes.dto.ts +6 -0
  25. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-command.dto.ts +16 -0
  26. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-create.dto.ts +18 -0
  27. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-search.dto.ts +2 -0
  28. package/dist/schematics/lib/dto/files/dto/__name@dasherize__-update.dto.ts +34 -0
  29. package/dist/schematics/lib/dto/schema.json +18 -0
  30. package/dist/schematics/lib/entity/entity.factory.js +30 -0
  31. package/dist/schematics/lib/entity/entity.factory.spec.js +86 -0
  32. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-command.entity.ts +12 -0
  33. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data-list.entity.ts +12 -0
  34. package/dist/schematics/lib/entity/files/entity/__name@dasherize__-data.entity.ts +12 -0
  35. package/dist/schematics/lib/entity/schema.json +18 -0
  36. package/dist/schematics/lib/module/files/async/__name@dasherize__.controller.ts +74 -0
  37. package/dist/schematics/lib/module/files/async/__name@dasherize__.module.ts +19 -0
  38. package/dist/schematics/lib/module/files/async/__name@dasherize__.service.ts +164 -0
  39. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-attributes.dto.ts +6 -0
  40. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-command.dto.ts +16 -0
  41. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-create.dto.ts +18 -0
  42. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-search.dto.ts +2 -0
  43. package/dist/schematics/lib/module/files/async/dto/__name@dasherize__-update.dto.ts +34 -0
  44. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-command.entity.ts +12 -0
  45. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data-list.entity.ts +12 -0
  46. package/dist/schematics/lib/module/files/async/entity/__name@dasherize__-data.entity.ts +12 -0
  47. package/dist/schematics/lib/module/files/async/handler/__name@dasherize__-rds.handler.ts +62 -0
  48. package/dist/schematics/lib/module/files/sync/__name@dasherize__.controller.ts +74 -0
  49. package/dist/schematics/lib/module/files/sync/__name@dasherize__.module.ts +19 -0
  50. package/dist/schematics/lib/module/files/sync/__name@dasherize__.service.ts +164 -0
  51. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-attributes.dto.ts +6 -0
  52. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-command.dto.ts +16 -0
  53. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-create.dto.ts +18 -0
  54. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-search.dto.ts +2 -0
  55. package/dist/schematics/lib/module/files/sync/dto/__name@dasherize__-update.dto.ts +34 -0
  56. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-command.entity.ts +12 -0
  57. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data-list.entity.ts +12 -0
  58. package/dist/schematics/lib/module/files/sync/entity/__name@dasherize__-data.entity.ts +12 -0
  59. package/dist/schematics/lib/module/files/sync/handler/__name@dasherize__-rds.handler.ts +62 -0
  60. package/dist/schematics/lib/module/module.factory.js +204 -0
  61. package/dist/schematics/lib/module/module.factory.spec.js +188 -0
  62. package/dist/schematics/lib/module/schema.json +28 -0
  63. package/dist/schematics/lib/module/units/__name@dasherize__.controller.__specFileSuffix__.ts +19 -0
  64. package/dist/schematics/lib/module/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
  65. package/dist/schematics/lib/service/files/__name@dasherize__.service.ts +12 -0
  66. package/dist/schematics/lib/service/schema.json +18 -0
  67. package/dist/schematics/lib/service/service.factory.js +40 -0
  68. package/dist/schematics/lib/service/service.factory.spec.js +81 -0
  69. package/dist/schematics/lib/service/units/__name@dasherize__.service.__specFileSuffix__.ts +19 -0
  70. package/dist/schematics/schematic.colection.js +60 -0
  71. package/dist/schematics/schematic.option.js +44 -0
  72. package/dist/schematics/utils/check-files-exist.js +13 -0
  73. package/dist/schematics/utils/index.js +17 -0
  74. package/dist/ui/index.js +18 -0
  75. package/dist/ui/logger.js +54 -0
  76. package/dist/ui/message.js +6 -0
  77. package/dist/utils/formatting.js +18 -0
  78. package/dist/utils/index.js +18 -0
  79. package/dist/utils/local-binaries.js +20 -0
  80. package/package.json +13 -4
  81. package/templates/.env.local +1 -1
  82. package/templates/README.md +1 -1
  83. package/templates/infra/README.md +6 -1
  84. package/templates/infra/libs/infra-stack.ts +1 -1
  85. package/templates/infra-local/docker-compose.yml +1 -1
  86. package/templates/infra-local/serverless.yml +19 -21
  87. package/templates/infra-local/swagger.json +396 -0
  88. package/templates/package.json +1 -0
  89. package/templates/prisma/dynamodbs/cqrs.json +1 -1
  90. package/templates/prisma/schema.prisma +4 -7
  91. package/templates/src/helpers/id.ts +12 -0
  92. package/templates/src/helpers/index.ts +1 -0
  93. package/templates/src/main.module.ts +2 -2
  94. package/templates/src/{master/dto/master-attributes.dto.ts → sample/dto/sample-attributes.dto.ts} +2 -2
  95. package/templates/src/{master/dto/master-command.dto.ts → sample/dto/sample-command.dto.ts} +4 -4
  96. package/templates/src/sample/entity/sample-command.entity.ts +13 -0
  97. package/templates/src/sample/entity/sample-data-list.entity.ts +13 -0
  98. package/templates/src/sample/entity/sample-data.entity.ts +13 -0
  99. package/templates/src/{master/handler/master-rds.handler.ts → sample/handler/sample-rds.handler.ts} +5 -7
  100. package/templates/src/{master/master.controller.ts → sample/sample.controller.ts} +22 -22
  101. package/templates/src/sample/sample.module.ts +19 -0
  102. package/templates/src/{master/master.service.ts → sample/sample.service.ts} +12 -12
  103. package/templates/test/api.http +25 -0
  104. package/templates/tsconfig.json +1 -1
  105. package/templates/src/master/entity/master-command.entity.ts +0 -13
  106. package/templates/src/master/entity/master-data-list.entity.ts +0 -13
  107. package/templates/src/master/entity/master-data.entity.ts +0 -13
  108. package/templates/src/master/master.module.ts +0 -19
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = main;
4
+ const core_1 = require("@angular-devkit/core");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ function createService(options) {
7
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
8
+ (0, schematics_1.template)({
9
+ ...core_1.strings,
10
+ ...options,
11
+ }),
12
+ (0, schematics_1.move)((0, core_1.normalize)(`/src/${core_1.strings.dasherize(options.name)}`)),
13
+ ]));
14
+ }
15
+ function createUnitTest(options) {
16
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./units'), [
17
+ (0, schematics_1.template)({
18
+ ...core_1.strings,
19
+ ...options,
20
+ specFileSuffix: 'spec',
21
+ }),
22
+ (0, schematics_1.move)((0, core_1.normalize)(`/test/unit/${core_1.strings.dasherize(options.name)}`)),
23
+ ]));
24
+ }
25
+ function main(options) {
26
+ return (tree, _context) => {
27
+ const filePath = (0, core_1.normalize)(`/src/${core_1.strings.dasherize(options.name)}/${core_1.strings.dasherize(options.name)}.service.ts`);
28
+ const unitPath = (0, core_1.normalize)(`/test/unit/${core_1.strings.dasherize(options.name)}/${core_1.strings.dasherize(options.name)}.service.spec.ts`);
29
+ const isFileExists = tree.exists(filePath);
30
+ const isUnitExists = tree.exists(unitPath);
31
+ if (isFileExists || isUnitExists) {
32
+ if (isFileExists)
33
+ _context.logger.info(`Service file already exists at: ${filePath}`);
34
+ if (isUnitExists)
35
+ _context.logger.info(`Unit test file already exists at: ${unitPath}`);
36
+ return;
37
+ }
38
+ return (0, schematics_1.chain)([createService(options), createUnitTest(options)]);
39
+ };
40
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const testing_1 = require("@angular-devkit/schematics/testing");
37
+ const path = __importStar(require("path"));
38
+ describe('Service Factory', () => {
39
+ const runner = new testing_1.SchematicTestRunner('.', path.join(__dirname, '../../collection.json'));
40
+ it('should generate correct template', async () => {
41
+ const options = {
42
+ name: 'foo',
43
+ };
44
+ const tree = await runner.runSchematic('service', options);
45
+ const files = tree.files;
46
+ expect(files.find((filename) => filename === '/src/foo/foo.service.ts')).toBeDefined();
47
+ expect(files.find((filename) => filename === '/test/unit/foo/foo.service.spec.ts')).toBeDefined();
48
+ expect(tree.readContent('/src/foo/foo.service.ts')).toEqual("import { CommandService, DataService } from '@mbc-cqrs-serverless/core'\n" +
49
+ "import { Injectable, Logger } from '@nestjs/common'\n" +
50
+ '\n' +
51
+ '@Injectable()\n' +
52
+ 'export class FooService {\n' +
53
+ ' private readonly logger = new Logger(FooService.name)\n' +
54
+ '\n' +
55
+ ' constructor(\n' +
56
+ ' private readonly commandService: CommandService,\n' +
57
+ ' private readonly dataService: DataService,\n' +
58
+ ' ) {}\n' +
59
+ '}\n');
60
+ console.log(tree.readContent('/test/unit/foo/foo.service.spec.ts'));
61
+ expect(tree.readContent('/test/unit/foo/foo.service.spec.ts')).toEqual("import { createMock } from '@golevelup/ts-jest'\n" +
62
+ "import { Test, TestingModule } from '@nestjs/testing'\n" +
63
+ "import { FooService } from 'src/foo/foo.service'\n" +
64
+ '\n' +
65
+ "describe('FooService', () => {\n" +
66
+ ' let service: FooService\n' +
67
+ '\n' +
68
+ ' beforeEach(async () => {\n' +
69
+ ' const module: TestingModule = await Test.createTestingModule({\n' +
70
+ ' controllers: [FooService],\n' +
71
+ ' }).useMocker(createMock).compile()\n' +
72
+ '\n' +
73
+ ' service = module.get<FooService>(FooService)\n' +
74
+ ' })\n' +
75
+ '\n' +
76
+ " it('should be defined', () => {\n" +
77
+ ' expect(service).toBeDefined()\n' +
78
+ ' })\n' +
79
+ '})\n');
80
+ });
81
+ });
@@ -0,0 +1,19 @@
1
+ import { createMock } from '@golevelup/ts-jest'
2
+ import { Test, TestingModule } from '@nestjs/testing'
3
+ import { <%= classify(name) %>Service } from 'src/<%= dasherize(name) %>/<%= dasherize(name) %>.service'
4
+
5
+ describe('<%= classify(name) %>Service', () => {
6
+ let service: <%= classify(name) %>Service
7
+
8
+ beforeEach(async () => {
9
+ const module: TestingModule = await Test.createTestingModule({
10
+ controllers: [<%= classify(name) %>Service],
11
+ }).useMocker(createMock).compile()
12
+
13
+ service = module.get<<%= classify(name) %>Service>(<%= classify(name) %>Service)
14
+ })
15
+
16
+ it('should be defined', () => {
17
+ expect(service).toBeDefined()
18
+ })
19
+ })
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.schematics = void 0;
7
+ exports.buildSchematicsListAsTable = buildSchematicsListAsTable;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const cli_table3_1 = __importDefault(require("cli-table3"));
10
+ exports.schematics = [
11
+ {
12
+ name: 'module',
13
+ alias: 'mo',
14
+ description: 'Create a module.',
15
+ },
16
+ {
17
+ name: 'controller',
18
+ alias: 'co',
19
+ description: 'Create a controller.',
20
+ },
21
+ {
22
+ name: 'service',
23
+ alias: 'se',
24
+ description: 'Create a service.',
25
+ },
26
+ {
27
+ name: 'entity',
28
+ alias: 'en',
29
+ description: 'Create a entity.',
30
+ },
31
+ {
32
+ name: 'dto',
33
+ alias: 'dto',
34
+ description: 'Create a dto.',
35
+ },
36
+ ];
37
+ function buildSchematicsListAsTable() {
38
+ const leftMargin = ' ';
39
+ const tableConfig = {
40
+ head: ['name', 'alias', 'description'],
41
+ chars: {
42
+ left: leftMargin.concat('│'),
43
+ 'top-left': leftMargin.concat('┌'),
44
+ 'bottom-left': leftMargin.concat('└'),
45
+ mid: '',
46
+ 'left-mid': '',
47
+ 'mid-mid': '',
48
+ 'right-mid': '',
49
+ },
50
+ };
51
+ const table = new cli_table3_1.default(tableConfig);
52
+ for (const schematic of exports.schematics) {
53
+ table.push([
54
+ chalk_1.default.green(schematic.name),
55
+ chalk_1.default.cyan(schematic.alias),
56
+ schematic.description,
57
+ ]);
58
+ }
59
+ return table.toString();
60
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchematicOption = void 0;
4
+ const formatting_1 = require("../utils/formatting");
5
+ class SchematicOption {
6
+ constructor(name, value) {
7
+ this.name = name;
8
+ this.value = value;
9
+ }
10
+ get normalizedName() {
11
+ return (0, formatting_1.normalizeToKebabOrSnakeCase)(this.name);
12
+ }
13
+ toCommandString() {
14
+ if (typeof this.value === 'string') {
15
+ if (this.name === 'name') {
16
+ return `--${this.normalizedName}=${this.format()}`;
17
+ }
18
+ else if (this.name === 'version' || this.name === 'path') {
19
+ return `--${this.normalizedName}=${this.value}`;
20
+ }
21
+ else {
22
+ return `--${this.normalizedName}="${this.value}"`;
23
+ }
24
+ }
25
+ else if (typeof this.value === 'boolean') {
26
+ const str = this.normalizedName;
27
+ return this.value ? `--${str}` : `--no-${str}`;
28
+ }
29
+ else {
30
+ return `--${this.normalizedName}=${this.value}`;
31
+ }
32
+ }
33
+ format() {
34
+ return (0, formatting_1.normalizeToKebabOrSnakeCase)(this.value)
35
+ .split('')
36
+ .reduce((content, char) => {
37
+ if (char === '(' || char === ')' || char === '[' || char === ']') {
38
+ return `${content}\\${char}`;
39
+ }
40
+ return `${content}${char}`;
41
+ }, '');
42
+ }
43
+ }
44
+ exports.SchematicOption = SchematicOption;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkFilesExist = checkFilesExist;
4
+ const core_1 = require("@angular-devkit/core");
5
+ function checkFilesExist(tree, paths) {
6
+ for (const path of paths) {
7
+ const filePath = (0, core_1.normalize)(path);
8
+ if (tree.exists(filePath)) {
9
+ return true;
10
+ }
11
+ }
12
+ return false;
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./check-files-exist"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./logger"), exports);
18
+ __exportStar(require("./message"), exports);
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logger = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const MAX_PREFIX_LENGTH = 8;
9
+ const badge = (text, bgColor, textColor = chalk_1.default.black) => {
10
+ const wrappedText = ` ${text} `;
11
+ const repeat = Math.max(0, MAX_PREFIX_LENGTH - wrappedText.length);
12
+ return ' '.repeat(repeat) + bgColor(textColor(wrappedText));
13
+ };
14
+ const textIndent = (text, indentFirst = true, indent = MAX_PREFIX_LENGTH + 2) => {
15
+ const parts = Array.isArray(text) ? text : [text];
16
+ return parts
17
+ .map((part, i) => {
18
+ if (i === 0 && !indentFirst) {
19
+ return part;
20
+ }
21
+ return ' '.repeat(indent) + part;
22
+ })
23
+ .join('\n');
24
+ };
25
+ exports.logger = {
26
+ log(message) {
27
+ console.log(textIndent(message));
28
+ },
29
+ title(title, message) {
30
+ const prefix = badge(title, chalk_1.default.bgBlueBright);
31
+ console.log(`\n${prefix} ${message}`);
32
+ },
33
+ info(message) {
34
+ console.log(`${' '.repeat(7)}${chalk_1.default.cyan('●')} ${message}`);
35
+ },
36
+ success(message) {
37
+ console.log(`\n${' '.repeat(7)}${chalk_1.default.green('✓')} ${chalk_1.default.green(message)}`);
38
+ },
39
+ fatal(message) {
40
+ const prefix = badge('Error', chalk_1.default.bgRed);
41
+ if (message) {
42
+ console.error(`\n${prefix} ${textIndent(message, false)}\n`);
43
+ }
44
+ process.exit(1);
45
+ },
46
+ error(message) {
47
+ const prefix = badge('Error', chalk_1.default.bgRed);
48
+ console.error(`\n${prefix} ${textIndent(message, false)}\n`);
49
+ },
50
+ warn(message) {
51
+ const prefix = badge('Warn', chalk_1.default.bgYellow);
52
+ console.warn(`\n${prefix} ${textIndent(message, false)}\n`);
53
+ },
54
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MESSAGES = void 0;
4
+ exports.MESSAGES = {
5
+ RUNNER_EXECUTION_ERROR: (command) => `\nFailed to execute command: ${command}`,
6
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeToKebabOrSnakeCase = normalizeToKebabOrSnakeCase;
4
+ /**
5
+ *
6
+ * @param str
7
+ * @returns formated string
8
+ * @description normalizes input to supported path and file name format.
9
+ * Changes camelCase strings to kebab-case, replaces spaces with dash and keeps underscores.
10
+ */
11
+ function normalizeToKebabOrSnakeCase(str) {
12
+ const STRING_DASHERIZE_REGEXP = /\s/g;
13
+ const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
14
+ return str
15
+ .replace(STRING_DECAMELIZE_REGEXP, '$1-$2')
16
+ .toLowerCase()
17
+ .replace(STRING_DASHERIZE_REGEXP, '-');
18
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./formatting"), exports);
18
+ __exportStar(require("./local-binaries"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localBinExists = localBinExists;
4
+ exports.loadLocalBinCommandLoader = loadLocalBinCommandLoader;
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const localBinPathSegments = [
8
+ process.cwd(),
9
+ 'node_modules',
10
+ '@mbc-cqrs-serverless',
11
+ 'cli',
12
+ ];
13
+ function localBinExists() {
14
+ return (0, fs_1.existsSync)((0, path_1.join)(...localBinPathSegments));
15
+ }
16
+ function loadLocalBinCommandLoader() {
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
18
+ const commandLoader = require(path_1.posix.join(...localBinPathSegments, 'dist', 'commands'));
19
+ return commandLoader;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbc-cqrs-serverless/cli",
3
- "version": "0.1.50-beta.0",
3
+ "version": "0.1.51-beta.0",
4
4
  "description": "a CLI to get started with MBC CQRS serverless framework",
5
5
  "keywords": [
6
6
  "mbc",
@@ -17,6 +17,7 @@
17
17
  "sqs",
18
18
  "typescript"
19
19
  ],
20
+ "schematics": "./dist/schematics/collection.json",
20
21
  "bin": {
21
22
  "mbc": "./dist/index.js"
22
23
  },
@@ -27,7 +28,7 @@
27
28
  ],
28
29
  "scripts": {
29
30
  "build": "rm -rf dist && tsc",
30
- "test": "echo \"Error: no test specified\" && exit 1"
31
+ "postbuild": "copyfiles ./schematics/collection.json ./schematics/**/schema.json ./schematics/**/files/** ./schematics/**/units/** dist && copyfiles -u 2 -a dist/src/**/* dist && copyfiles -u 2 -a dist/src/index.js dist && rm -rf dist/src"
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
@@ -43,11 +44,19 @@
43
44
  "access": "public"
44
45
  },
45
46
  "dependencies": {
47
+ "@angular-devkit/core": "^17.3.11",
48
+ "@angular-devkit/schematics": "^17.3.11",
49
+ "@angular-devkit/schematics-cli": "^17.3.11",
50
+ "@schematics/angular": "^17.3.11",
51
+ "chalk": "^4.1.2",
52
+ "cli-table3": "^0.6.5",
46
53
  "commander": "^11.1.0",
54
+ "js-yaml": "^4.1.0",
47
55
  "rimraf": "^5.0.5"
48
56
  },
49
57
  "devDependencies": {
50
- "@faker-js/faker": "^8.3.1"
58
+ "@faker-js/faker": "^8.3.1",
59
+ "copyfiles": "^2.4.1"
51
60
  },
52
- "gitHead": "d61475400eb1b00a1c427769875d2f056e48c73c"
61
+ "gitHead": "6935a6c2f929944e111d953a06929dcc26321624"
53
62
  }
@@ -54,4 +54,4 @@ SES_FROM_EMAIL=email@example.com
54
54
  DATABASE_URL="mysql://root:RootCqrs@localhost:3306/cqrs?schema=public&connection_limit=1"
55
55
 
56
56
  # serverless dynamodb local stream
57
- LOCAL_DDB_MASTER_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-demo-master-command/stream/2024-01-02T02:49:43.692
57
+ LOCAL_DDB_SAMPLE_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-test-cli-sample-command/stream/2025-01-14T12:05:57.881
@@ -46,7 +46,7 @@ $ npm run offline:docker
46
46
  $ npm run migrate
47
47
 
48
48
  # copy dynamodb stream arn to `.env` file
49
- # LOCAL_DDB_MASTER_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-demo-master-command/stream/2024-01-02T03:07:49.349
49
+ #LOCAL_DDB_SAMPLE_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-test-cli-sample-command/stream/2025-01-14T12:05:57.881
50
50
 
51
51
  # serverless, open in other terminal session
52
52
  $ npm run offline:sls
@@ -1,9 +1,14 @@
1
1
  # Welcome to your CDK TypeScript project
2
2
 
3
- This is a blank project for CDK development with TypeScript.
3
+ This is a project for CDK development with TypeScript.
4
4
 
5
5
  The `cdk.json` file tells the CDK Toolkit how to execute your app.
6
6
 
7
+ ## Instruction
8
+
9
+ - Install requirement package by using command `pnpm install`
10
+ - Update test snapshot by using command `npm run test -- --updateSnapshot`
11
+
7
12
  ## Use SSO profile
8
13
 
9
14
  ```bash
@@ -779,7 +779,7 @@ export class InfraStack extends cdk.Stack {
779
779
  }),
780
780
  )
781
781
  // dynamodb event source
782
- const tableNames = ['tasks', 'master-command']
782
+ const tableNames = ['tasks', 'sample-command']
783
783
  for (const tableName of tableNames) {
784
784
  const tableDesc = new cdk.custom_resources.AwsCustomResource(
785
785
  this,
@@ -38,7 +38,7 @@ services:
38
38
  dynamodb-admin:
39
39
  image: aaronshaf/dynamodb-admin
40
40
  environment:
41
- - DYNAMO_ENDPOINT=dynamodb-local:8000
41
+ - DYNAMO_ENDPOINT=http://dynamodb-local:8000
42
42
  - AWS_REGION=ap-northeast-1
43
43
  - AWS_ACCESS_KEY_ID=local
44
44
  - AWS_SECRET_ACCESS_KEY=local
@@ -29,16 +29,12 @@ custom:
29
29
  - topic:
30
30
  topicName: CqrsSnsTopic
31
31
  rawMessageDelivery: 'true'
32
- filterPolicy: { 'action': ['task-execute'] }
32
+ filterPolicy: { 'action': [ 'task-execute' ] }
33
33
  queue: http://localhost:9324/101010101010/task-action-queue
34
34
  - topic:
35
35
  topicName: CqrsSnsTopic
36
36
  rawMessageDelivery: 'true'
37
- filterPolicy:
38
- {
39
- 'action':
40
- ['notification-action', 'command-status', 'task-status'],
41
- }
37
+ filterPolicy: { 'action': [ 'notification-action', 'command-status', 'task-status' ] }
42
38
  queue: http://localhost:9324/101010101010/notification-queue
43
39
  - topic:
44
40
  topicName: AlarmSnsTopic
@@ -106,35 +102,37 @@ provider:
106
102
  issuerUrl: http://localhost:9229/local_2G7noHgW
107
103
  audience:
108
104
  - dnk8y7ii3wled35p3lw0l2cd7
109
- keycloakAuthorizer:
110
- type: jwt
111
- identitySource: $request.header.Authorization
112
- issuerUrl: http://localhost:8180/realms/master
113
- # issuerUrl: http://localhost:8180/auth/realms/master # old version
114
- audience:
115
- - cqrs-demo
105
+ # keycloakAuthorizer:
106
+ # type: jwt
107
+ # identitySource: $request.header.Authorization
108
+ # issuerUrl: http://localhost:8180/realms/master
109
+ # # issuerUrl: http://localhost:8180/auth/realms/master # old version
110
+ # audience:
111
+ # - cqrs-demo
116
112
 
117
113
  functions:
118
114
  main:
119
115
  handler: ../dist/main.handler
120
116
  events:
121
- - httpApi: # public api
117
+ - httpApi:
118
+ # public api
122
119
  method: GET
123
120
  path: /
124
121
  - httpApi:
125
122
  method: ANY
126
123
  path: '/swagger-ui/{proxy+}'
127
- - httpApi: # protected api
124
+ - httpApi:
125
+ # protected api
128
126
  method: ANY
129
127
  path: '/{proxy+}'
130
128
  authorizer:
131
129
  name: localAuthorizer
132
130
  # authorizer:
133
131
  # name: keycloakAuthorizer
134
- # - eventBridge:
135
- # eventBus: marketing
136
- # # run every 5 minutes
137
- # schedule: "cron(0/5 * * * ? *)"
132
+ # - eventBridge:
133
+ # eventBus: marketing
134
+ # # run every 5 minutes
135
+ # schedule: "cron(0/5 * * * ? *)"
138
136
  - sqs:
139
137
  arn:
140
138
  Fn::GetAtt:
@@ -148,9 +146,9 @@ functions:
148
146
  - stream:
149
147
  type: dynamodb
150
148
  maximumRetryAttempts: 10
151
- arn: ${env:LOCAL_DDB_MASTER_STREAM}
149
+ arn: ${env:LOCAL_DDB_SAMPLE_STREAM}
152
150
  filterPatterns:
153
- - eventName: [INSERT]
151
+ - eventName: [ INSERT ]
154
152
 
155
153
  stepFunctions:
156
154
  # https://goessner.net/articles/JsonPath/index.html