@mbc-cqrs-serverless/cli 1.0.15 → 1.0.16
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.
|
@@ -1,26 +1,104 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
const generate_action_1 = __importDefault(require("./generate.action"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
7
42
|
describe('Generate Action', () => {
|
|
43
|
+
// Use dryRun: true by default to avoid creating actual files during tests
|
|
44
|
+
// テスト中に実際のファイルを作成しないように、デフォルトで dryRun: true を使用
|
|
8
45
|
const mockCommand = {
|
|
9
46
|
name: () => 'generate',
|
|
10
47
|
opts: () => ({
|
|
11
|
-
dryRun:
|
|
48
|
+
dryRun: true,
|
|
12
49
|
mode: 'async',
|
|
13
50
|
schema: true
|
|
14
51
|
})
|
|
15
52
|
};
|
|
16
53
|
const mockOptions = {
|
|
17
|
-
dryRun:
|
|
54
|
+
dryRun: true,
|
|
18
55
|
mode: 'async',
|
|
19
56
|
schema: true
|
|
20
57
|
};
|
|
58
|
+
// Directories that may be created by tests
|
|
59
|
+
// テストで作成される可能性があるディレクトリ
|
|
60
|
+
const testDirs = ['src', 'test'];
|
|
21
61
|
beforeEach(() => {
|
|
22
62
|
jest.clearAllMocks();
|
|
23
63
|
});
|
|
64
|
+
afterAll(() => {
|
|
65
|
+
// Clean up any directories created during tests
|
|
66
|
+
// テスト中に作成されたディレクトリを削除
|
|
67
|
+
// The monorepo root is determined by finding package.json with "workspaces"
|
|
68
|
+
let rootDir = process.cwd();
|
|
69
|
+
// Walk up to find monorepo root (has workspaces in package.json)
|
|
70
|
+
let current = rootDir;
|
|
71
|
+
for (let i = 0; i < 10; i++) {
|
|
72
|
+
const pkgPath = path.join(current, 'package.json');
|
|
73
|
+
if (fs.existsSync(pkgPath)) {
|
|
74
|
+
try {
|
|
75
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
76
|
+
if (pkg.workspaces) {
|
|
77
|
+
rootDir = current;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// ignore
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const parent = path.dirname(current);
|
|
86
|
+
if (parent === current)
|
|
87
|
+
break;
|
|
88
|
+
current = parent;
|
|
89
|
+
}
|
|
90
|
+
for (const dir of testDirs) {
|
|
91
|
+
const dirPath = path.join(rootDir, dir);
|
|
92
|
+
if (fs.existsSync(dirPath)) {
|
|
93
|
+
try {
|
|
94
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.warn(`Failed to clean up directory: ${dirPath}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
24
102
|
describe('Overview: Schematic generation functionality', () => {
|
|
25
103
|
describe('Purpose: Test basic generate action execution', () => {
|
|
26
104
|
it('should execute generate action without errors', async () => {
|
|
@@ -87,7 +165,7 @@ describe('Generate Action', () => {
|
|
|
87
165
|
const asyncCommand = {
|
|
88
166
|
...mockCommand,
|
|
89
167
|
opts: () => ({
|
|
90
|
-
dryRun:
|
|
168
|
+
dryRun: true,
|
|
91
169
|
mode: 'async',
|
|
92
170
|
schema: true
|
|
93
171
|
})
|
|
@@ -98,7 +176,7 @@ describe('Generate Action', () => {
|
|
|
98
176
|
const syncCommand = {
|
|
99
177
|
...mockCommand,
|
|
100
178
|
opts: () => ({
|
|
101
|
-
dryRun:
|
|
179
|
+
dryRun: true,
|
|
102
180
|
mode: 'sync',
|
|
103
181
|
schema: false
|
|
104
182
|
})
|
|
@@ -109,7 +187,7 @@ describe('Generate Action', () => {
|
|
|
109
187
|
const noSchemaCommand = {
|
|
110
188
|
...mockCommand,
|
|
111
189
|
opts: () => ({
|
|
112
|
-
dryRun:
|
|
190
|
+
dryRun: true,
|
|
113
191
|
mode: 'async',
|
|
114
192
|
noSchema: true
|
|
115
193
|
})
|
|
@@ -146,7 +146,7 @@ export class <%= classify(name) %>Service {
|
|
|
146
146
|
|
|
147
147
|
const data = (await this.dataService.getItem(key)) as <%= classify(name) %>DataEntity
|
|
148
148
|
if (!data) {
|
|
149
|
-
throw new NotFoundException()
|
|
149
|
+
throw new NotFoundException('<%= classify(name) %> not found')
|
|
150
150
|
}
|
|
151
151
|
const commandDto: CommandPartialInputModel = {
|
|
152
152
|
pk: data.pk,
|
|
@@ -146,7 +146,7 @@ export class <%= classify(name) %>Service {
|
|
|
146
146
|
|
|
147
147
|
const data = (await this.dataService.getItem(key)) as <%= classify(name) %>DataEntity
|
|
148
148
|
if (!data) {
|
|
149
|
-
throw new NotFoundException()
|
|
149
|
+
throw new NotFoundException('<%= classify(name) %> not found')
|
|
150
150
|
}
|
|
151
151
|
const commandDto: CommandPartialInputModel = {
|
|
152
152
|
pk: data.pk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "a CLI to get started with MBC CQRS serverless framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"@faker-js/faker": "^8.3.1",
|
|
59
59
|
"copyfiles": "^2.4.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "4ab967474160873735b8cb816272a7012b8940d5"
|
|
62
62
|
}
|
|
@@ -55,7 +55,7 @@ export class SampleController {
|
|
|
55
55
|
this.logger.debug('commandService:' + this.commandService.tableName)
|
|
56
56
|
const item = await this.commandService.getItem(detailDto)
|
|
57
57
|
if (!item) {
|
|
58
|
-
throw new NotFoundException()
|
|
58
|
+
throw new NotFoundException('Sample command not found')
|
|
59
59
|
}
|
|
60
60
|
this.logger.debug('item:', item)
|
|
61
61
|
return new SampleCommandEntity(item as SampleCommandEntity)
|
|
@@ -66,7 +66,7 @@ export class SampleController {
|
|
|
66
66
|
this.logger.debug('dataService:' + this.dataService.tableName)
|
|
67
67
|
const item = await this.dataService.getItem(detailDto)
|
|
68
68
|
if (!item) {
|
|
69
|
-
throw new NotFoundException()
|
|
69
|
+
throw new NotFoundException('Sample data not found')
|
|
70
70
|
}
|
|
71
71
|
this.logger.debug('item:', item)
|
|
72
72
|
return new SampleDataEntity(item as SampleDataEntity)
|