npm-cli-gh-issue-preparator 1.4.0 → 1.5.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.
- package/.github/copilot-instructions.md +0 -0
- package/.github/instructions/code-review.instructions.md +43 -0
- package/.github/workflows/umino-project.yml +1 -1
- package/CHANGELOG.md +7 -0
- package/bin/adapter/entry-points/cli/index.js +13 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/domain/usecases/StartPreparationUseCase.js +2 -2
- package/bin/domain/usecases/StartPreparationUseCase.js.map +1 -1
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.test.ts +180 -2
- package/src/adapter/entry-points/cli/index.ts +22 -0
- package/src/domain/usecases/StartPreparationUseCase.test.ts +56 -0
- package/src/domain/usecases/StartPreparationUseCase.ts +3 -2
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/domain/usecases/StartPreparationUseCase.d.ts +1 -1
- package/types/domain/usecases/StartPreparationUseCase.d.ts.map +1 -1
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Code Review Instructions
|
|
6
|
+
|
|
7
|
+
## Scope Integrity
|
|
8
|
+
|
|
9
|
+
Flag pull requests that contain changes unrelated to the stated PR title or description.
|
|
10
|
+
Each PR must address a single topic or feature.
|
|
11
|
+
If unrelated modifications are detected, request that they be split into separate issues first.
|
|
12
|
+
|
|
13
|
+
## Lint and Static Analysis Bypass Detection
|
|
14
|
+
|
|
15
|
+
Flag any code that disables, ignores, or bypasses linting rules.
|
|
16
|
+
Report usage of eslint-disable, @ts-ignore, @ts-expect-error, noqa, or similar suppression comments.
|
|
17
|
+
Flag modifications to linter configuration files that weaken existing rules.
|
|
18
|
+
|
|
19
|
+
## Error Handling Violations
|
|
20
|
+
|
|
21
|
+
Flag code that catches exceptions but does nothing with them (empty catch blocks).
|
|
22
|
+
Flag API endpoints that return HTTP 200 status codes when errors have occurred.
|
|
23
|
+
Flag code that converts errors into success responses or hides error states.
|
|
24
|
+
Flag use of console.log for error handling instead of proper error propagation.
|
|
25
|
+
Flag code that swallows errors by returning default values without logging or reporting.
|
|
26
|
+
|
|
27
|
+
## Test Coverage Requirements
|
|
28
|
+
|
|
29
|
+
Flag new features or bug fixes that lack corresponding unit tests.
|
|
30
|
+
Flag modifications to existing code where related tests have not been updated.
|
|
31
|
+
Flag deletion or disabling of existing tests without justification.
|
|
32
|
+
Flag test files that use skip, only, or other mechanisms to bypass test execution.
|
|
33
|
+
Flag mock implementations that always return success without testing failure scenarios.
|
|
34
|
+
Report when test coverage for modified files appears insufficient.
|
|
35
|
+
Report when test assertion for modified files appears insufficient.
|
|
36
|
+
|
|
37
|
+
## Code Quality Red Flags
|
|
38
|
+
|
|
39
|
+
Flag hardcoded credentials, API keys, or secrets.
|
|
40
|
+
Flag commented-out code blocks.
|
|
41
|
+
Flag TODO or FIXME comments without associated issue references.
|
|
42
|
+
Flag any use of type assertions (as any, as unknown) that bypass type safety.
|
|
43
|
+
Flag functions with excessive cyclomatic complexity.
|
|
@@ -41,7 +41,7 @@ env:
|
|
|
41
41
|
|
|
42
42
|
jobs:
|
|
43
43
|
umino-job:
|
|
44
|
-
if: github.event_name != 'issue_comment' || github.event.comment.user.login != 'umino-bot'
|
|
44
|
+
if: (github.event_name != 'issue_comment' || github.event.comment.user.login != 'umino-bot') && github.event.action != 'labeled'
|
|
45
45
|
runs-on: ubuntu-latest
|
|
46
46
|
steps:
|
|
47
47
|
- name: Move issue to ${{ env.unread }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/compare/v1.4.0...v1.5.0) (2026-01-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **cli:** add maximumPreparingIssuesCount as cli parameter for startDaemon ([a3f1e98](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/commit/a3f1e985c65cdda426538abd5d1552344f33da0e))
|
|
7
|
+
|
|
1
8
|
# [1.4.0](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/compare/v1.3.0...v1.4.0) (2026-01-14)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -26,6 +26,7 @@ program
|
|
|
26
26
|
.requiredOption('--preparationStatus <status>', 'Status for issues in preparation')
|
|
27
27
|
.requiredOption('--defaultAgentName <name>', 'Default agent name')
|
|
28
28
|
.option('--logFilePath <path>', 'Path to log file')
|
|
29
|
+
.option('--maximumPreparingIssuesCount <count>', 'Maximum number of issues in preparation status (default: 6)')
|
|
29
30
|
.action(async (options) => {
|
|
30
31
|
const token = process.env.GH_TOKEN;
|
|
31
32
|
if (!token) {
|
|
@@ -36,12 +37,24 @@ program
|
|
|
36
37
|
const issueRepository = new GitHubIssueRepository_1.GitHubIssueRepository(token);
|
|
37
38
|
const localCommandRunner = new NodeLocalCommandRunner_1.NodeLocalCommandRunner();
|
|
38
39
|
const useCase = new StartPreparationUseCase_1.StartPreparationUseCase(projectRepository, issueRepository, localCommandRunner);
|
|
40
|
+
let maximumPreparingIssuesCount = null;
|
|
41
|
+
if (options.maximumPreparingIssuesCount !== undefined) {
|
|
42
|
+
const parsedCount = Number(options.maximumPreparingIssuesCount);
|
|
43
|
+
if (!Number.isFinite(parsedCount) ||
|
|
44
|
+
!Number.isInteger(parsedCount) ||
|
|
45
|
+
parsedCount <= 0) {
|
|
46
|
+
console.error('Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
maximumPreparingIssuesCount = parsedCount;
|
|
50
|
+
}
|
|
39
51
|
await useCase.run({
|
|
40
52
|
projectUrl: options.projectUrl,
|
|
41
53
|
awaitingWorkspaceStatus: options.awaitingWorkspaceStatus,
|
|
42
54
|
preparationStatus: options.preparationStatus,
|
|
43
55
|
defaultAgentName: options.defaultAgentName,
|
|
44
56
|
logFilePath: options.logFilePath,
|
|
57
|
+
maximumPreparingIssuesCount,
|
|
45
58
|
});
|
|
46
59
|
});
|
|
47
60
|
program
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";;;;;;;AACA,oDAA4B;AAC5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,yCAAoC;AACpC,8FAA2F;AAC3F,0HAAuH;AACvH,wFAAqF;AACrF,oFAAiF;AACjF,sFAAmF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";;;;;;;AACA,oDAA4B;AAC5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,yCAAoC;AACpC,8FAA2F;AAC3F,0HAAuH;AACvH,wFAAqF;AACrF,oFAAiF;AACjF,sFAAmF;AAkBnF,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AA2GrB,0BAAO;AA1GhB,OAAO;KACJ,IAAI,CAAC,6BAA6B,CAAC;KACnC,WAAW,CAAC,mCAAmC,CAAC,CAAC;AAEpD,OAAO;KACJ,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,uCAAuC,CAAC;KACpD,cAAc,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;KAC1D,cAAc,CACb,oCAAoC,EACpC,sCAAsC,CACvC;KACA,cAAc,CACb,8BAA8B,EAC9B,kCAAkC,CACnC;KACA,cAAc,CAAC,2BAA2B,EAAE,oBAAoB,CAAC;KACjE,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;KAClD,MAAM,CACL,uCAAuC,EACvC,6DAA6D,CAC9D;KACA,MAAM,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,GAA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ACzC,WAAW,CAAC,2CAA2C,CAAC;KACxD,cAAc,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;KAC1D,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;KACtD,cAAc,CACb,8BAA8B,EAC9B,kCAAkC,CACnC;KACA,cAAc,CACb,uCAAuC,EACvC,0CAA0C,CAC3C;KACA,MAAM,CAAC,KAAK,EAAE,OAA8B,EAAE,EAAE;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,iBAAiB,GAAG,IAAI,iDAAuB,CAAC,KAAK,CAAC,CAAC;IAC7D,MAAM,eAAe,GAAG,IAAI,6CAAqB,CAAC,KAAK,CAAC,CAAC;IAEzD,MAAM,OAAO,GAAG,IAAI,6EAAqC,CACvD,iBAAiB,EACjB,eAAe,CAChB,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;KAC/D,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,0BAA0B;AAC1B,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -6,14 +6,14 @@ class StartPreparationUseCase {
|
|
|
6
6
|
this.projectRepository = projectRepository;
|
|
7
7
|
this.issueRepository = issueRepository;
|
|
8
8
|
this.localCommandRunner = localCommandRunner;
|
|
9
|
-
this.maximumPreparingIssuesCount = 6;
|
|
10
9
|
this.run = async (params) => {
|
|
10
|
+
const maximumPreparingIssuesCount = params.maximumPreparingIssuesCount ?? 6;
|
|
11
11
|
const project = await this.projectRepository.getByUrl(params.projectUrl);
|
|
12
12
|
const allIssues = await this.issueRepository.getAllOpened(project);
|
|
13
13
|
const awaitingWorkspaceIssues = allIssues.filter((issue) => issue.status === params.awaitingWorkspaceStatus);
|
|
14
14
|
const currentPreparationIssueCount = allIssues.filter((issue) => issue.status === params.preparationStatus).length;
|
|
15
15
|
for (let i = currentPreparationIssueCount; i <
|
|
16
|
-
Math.min(
|
|
16
|
+
Math.min(maximumPreparingIssuesCount, awaitingWorkspaceIssues.length + currentPreparationIssueCount); i++) {
|
|
17
17
|
const issue = awaitingWorkspaceIssues.pop();
|
|
18
18
|
if (!issue) {
|
|
19
19
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartPreparationUseCase.js","sourceRoot":"","sources":["../../../src/domain/usecases/StartPreparationUseCase.ts"],"names":[],"mappings":";;;AAIA,MAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"StartPreparationUseCase.js","sourceRoot":"","sources":["../../../src/domain/usecases/StartPreparationUseCase.ts"],"names":[],"mappings":";;;AAIA,MAAa,uBAAuB;IAClC,YACmB,iBAAoC,EACpC,eAAgC,EAChC,kBAAsC;QAFtC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,oBAAe,GAAf,eAAe,CAAiB;QAChC,uBAAkB,GAAlB,kBAAkB,CAAoB;QAGzD,QAAG,GAAG,KAAK,EAAE,MAOZ,EAAiB,EAAE;YAClB,MAAM,2BAA2B,GAAG,MAAM,CAAC,2BAA2B,IAAI,CAAC,CAAC;YAC5E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEzE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAA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C,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACvF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;IAlDC,CAAC;CAmDL;AAxDD,0DAwDC"}
|
package/package.json
CHANGED
|
@@ -32,7 +32,6 @@ describe('CLI', () => {
|
|
|
32
32
|
this: StartPreparationUseCase,
|
|
33
33
|
) {
|
|
34
34
|
this.run = mockRun;
|
|
35
|
-
this.maximumPreparingIssuesCount = 6;
|
|
36
35
|
return this;
|
|
37
36
|
});
|
|
38
37
|
|
|
@@ -57,6 +56,7 @@ describe('CLI', () => {
|
|
|
57
56
|
preparationStatus: 'Preparing',
|
|
58
57
|
defaultAgentName: 'agent1',
|
|
59
58
|
logFilePath: undefined,
|
|
59
|
+
maximumPreparingIssuesCount: null,
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -68,7 +68,6 @@ describe('CLI', () => {
|
|
|
68
68
|
this: StartPreparationUseCase,
|
|
69
69
|
) {
|
|
70
70
|
this.run = mockRun;
|
|
71
|
-
this.maximumPreparingIssuesCount = 6;
|
|
72
71
|
return this;
|
|
73
72
|
});
|
|
74
73
|
|
|
@@ -95,9 +94,188 @@ describe('CLI', () => {
|
|
|
95
94
|
preparationStatus: 'Preparing',
|
|
96
95
|
defaultAgentName: 'agent1',
|
|
97
96
|
logFilePath: '/path/to/log.txt',
|
|
97
|
+
maximumPreparingIssuesCount: null,
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
it('should pass maximumPreparingIssuesCount to StartPreparationUseCase when provided', async () => {
|
|
102
|
+
const mockRun = jest.fn().mockResolvedValue(undefined);
|
|
103
|
+
const MockedStartPreparationUseCase = jest.mocked(StartPreparationUseCase);
|
|
104
|
+
|
|
105
|
+
MockedStartPreparationUseCase.mockImplementation(function (
|
|
106
|
+
this: StartPreparationUseCase,
|
|
107
|
+
) {
|
|
108
|
+
this.run = mockRun;
|
|
109
|
+
return this;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await program.parseAsync([
|
|
113
|
+
'node',
|
|
114
|
+
'test',
|
|
115
|
+
'startDaemon',
|
|
116
|
+
'--projectUrl',
|
|
117
|
+
'https://github.com/test/project',
|
|
118
|
+
'--awaitingWorkspaceStatus',
|
|
119
|
+
'Awaiting',
|
|
120
|
+
'--preparationStatus',
|
|
121
|
+
'Preparing',
|
|
122
|
+
'--defaultAgentName',
|
|
123
|
+
'agent1',
|
|
124
|
+
'--maximumPreparingIssuesCount',
|
|
125
|
+
'10',
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
expect(mockRun).toHaveBeenCalledTimes(1);
|
|
129
|
+
expect(mockRun).toHaveBeenCalledWith({
|
|
130
|
+
projectUrl: 'https://github.com/test/project',
|
|
131
|
+
awaitingWorkspaceStatus: 'Awaiting',
|
|
132
|
+
preparationStatus: 'Preparing',
|
|
133
|
+
defaultAgentName: 'agent1',
|
|
134
|
+
logFilePath: undefined,
|
|
135
|
+
maximumPreparingIssuesCount: 10,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should exit with error for non-numeric maximumPreparingIssuesCount', async () => {
|
|
140
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
141
|
+
const processExitSpy = jest
|
|
142
|
+
.spyOn(process, 'exit')
|
|
143
|
+
.mockImplementation(() => {
|
|
144
|
+
throw new Error('process.exit called');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await expect(
|
|
148
|
+
program.parseAsync([
|
|
149
|
+
'node',
|
|
150
|
+
'test',
|
|
151
|
+
'startDaemon',
|
|
152
|
+
'--projectUrl',
|
|
153
|
+
'https://github.com/test/project',
|
|
154
|
+
'--awaitingWorkspaceStatus',
|
|
155
|
+
'Awaiting',
|
|
156
|
+
'--preparationStatus',
|
|
157
|
+
'Preparing',
|
|
158
|
+
'--defaultAgentName',
|
|
159
|
+
'agent1',
|
|
160
|
+
'--maximumPreparingIssuesCount',
|
|
161
|
+
'abc',
|
|
162
|
+
]),
|
|
163
|
+
).rejects.toThrow('process.exit called');
|
|
164
|
+
|
|
165
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
166
|
+
'Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.',
|
|
167
|
+
);
|
|
168
|
+
expect(processExitSpy).toHaveBeenCalledWith(1);
|
|
169
|
+
|
|
170
|
+
consoleErrorSpy.mockRestore();
|
|
171
|
+
processExitSpy.mockRestore();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should exit with error for negative maximumPreparingIssuesCount', async () => {
|
|
175
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
176
|
+
const processExitSpy = jest
|
|
177
|
+
.spyOn(process, 'exit')
|
|
178
|
+
.mockImplementation(() => {
|
|
179
|
+
throw new Error('process.exit called');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await expect(
|
|
183
|
+
program.parseAsync([
|
|
184
|
+
'node',
|
|
185
|
+
'test',
|
|
186
|
+
'startDaemon',
|
|
187
|
+
'--projectUrl',
|
|
188
|
+
'https://github.com/test/project',
|
|
189
|
+
'--awaitingWorkspaceStatus',
|
|
190
|
+
'Awaiting',
|
|
191
|
+
'--preparationStatus',
|
|
192
|
+
'Preparing',
|
|
193
|
+
'--defaultAgentName',
|
|
194
|
+
'agent1',
|
|
195
|
+
'--maximumPreparingIssuesCount',
|
|
196
|
+
'-5',
|
|
197
|
+
]),
|
|
198
|
+
).rejects.toThrow('process.exit called');
|
|
199
|
+
|
|
200
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
201
|
+
'Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.',
|
|
202
|
+
);
|
|
203
|
+
expect(processExitSpy).toHaveBeenCalledWith(1);
|
|
204
|
+
|
|
205
|
+
consoleErrorSpy.mockRestore();
|
|
206
|
+
processExitSpy.mockRestore();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should exit with error for zero maximumPreparingIssuesCount', async () => {
|
|
210
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
211
|
+
const processExitSpy = jest
|
|
212
|
+
.spyOn(process, 'exit')
|
|
213
|
+
.mockImplementation(() => {
|
|
214
|
+
throw new Error('process.exit called');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
await expect(
|
|
218
|
+
program.parseAsync([
|
|
219
|
+
'node',
|
|
220
|
+
'test',
|
|
221
|
+
'startDaemon',
|
|
222
|
+
'--projectUrl',
|
|
223
|
+
'https://github.com/test/project',
|
|
224
|
+
'--awaitingWorkspaceStatus',
|
|
225
|
+
'Awaiting',
|
|
226
|
+
'--preparationStatus',
|
|
227
|
+
'Preparing',
|
|
228
|
+
'--defaultAgentName',
|
|
229
|
+
'agent1',
|
|
230
|
+
'--maximumPreparingIssuesCount',
|
|
231
|
+
'0',
|
|
232
|
+
]),
|
|
233
|
+
).rejects.toThrow('process.exit called');
|
|
234
|
+
|
|
235
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
236
|
+
'Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.',
|
|
237
|
+
);
|
|
238
|
+
expect(processExitSpy).toHaveBeenCalledWith(1);
|
|
239
|
+
|
|
240
|
+
consoleErrorSpy.mockRestore();
|
|
241
|
+
processExitSpy.mockRestore();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should exit with error for decimal maximumPreparingIssuesCount', async () => {
|
|
245
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
246
|
+
const processExitSpy = jest
|
|
247
|
+
.spyOn(process, 'exit')
|
|
248
|
+
.mockImplementation(() => {
|
|
249
|
+
throw new Error('process.exit called');
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
await expect(
|
|
253
|
+
program.parseAsync([
|
|
254
|
+
'node',
|
|
255
|
+
'test',
|
|
256
|
+
'startDaemon',
|
|
257
|
+
'--projectUrl',
|
|
258
|
+
'https://github.com/test/project',
|
|
259
|
+
'--awaitingWorkspaceStatus',
|
|
260
|
+
'Awaiting',
|
|
261
|
+
'--preparationStatus',
|
|
262
|
+
'Preparing',
|
|
263
|
+
'--defaultAgentName',
|
|
264
|
+
'agent1',
|
|
265
|
+
'--maximumPreparingIssuesCount',
|
|
266
|
+
'3.5',
|
|
267
|
+
]),
|
|
268
|
+
).rejects.toThrow('process.exit called');
|
|
269
|
+
|
|
270
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
271
|
+
'Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.',
|
|
272
|
+
);
|
|
273
|
+
expect(processExitSpy).toHaveBeenCalledWith(1);
|
|
274
|
+
|
|
275
|
+
consoleErrorSpy.mockRestore();
|
|
276
|
+
processExitSpy.mockRestore();
|
|
277
|
+
});
|
|
278
|
+
|
|
101
279
|
it('should pass correct parameters to NotifyFinishedIssuePreparationUseCase', async () => {
|
|
102
280
|
const mockRun = jest.fn().mockResolvedValue(undefined);
|
|
103
281
|
const MockedNotifyFinishedUseCase = jest.mocked(
|
|
@@ -15,6 +15,7 @@ type StartDaemonOptions = {
|
|
|
15
15
|
preparationStatus: string;
|
|
16
16
|
defaultAgentName: string;
|
|
17
17
|
logFilePath?: string;
|
|
18
|
+
maximumPreparingIssuesCount?: string;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
type NotifyFinishedOptions = {
|
|
@@ -43,6 +44,10 @@ program
|
|
|
43
44
|
)
|
|
44
45
|
.requiredOption('--defaultAgentName <name>', 'Default agent name')
|
|
45
46
|
.option('--logFilePath <path>', 'Path to log file')
|
|
47
|
+
.option(
|
|
48
|
+
'--maximumPreparingIssuesCount <count>',
|
|
49
|
+
'Maximum number of issues in preparation status (default: 6)',
|
|
50
|
+
)
|
|
46
51
|
.action(async (options: StartDaemonOptions) => {
|
|
47
52
|
const token = process.env.GH_TOKEN;
|
|
48
53
|
if (!token) {
|
|
@@ -60,12 +65,29 @@ program
|
|
|
60
65
|
localCommandRunner,
|
|
61
66
|
);
|
|
62
67
|
|
|
68
|
+
let maximumPreparingIssuesCount: number | null = null;
|
|
69
|
+
if (options.maximumPreparingIssuesCount !== undefined) {
|
|
70
|
+
const parsedCount = Number(options.maximumPreparingIssuesCount);
|
|
71
|
+
if (
|
|
72
|
+
!Number.isFinite(parsedCount) ||
|
|
73
|
+
!Number.isInteger(parsedCount) ||
|
|
74
|
+
parsedCount <= 0
|
|
75
|
+
) {
|
|
76
|
+
console.error(
|
|
77
|
+
'Invalid value for --maximumPreparingIssuesCount. It must be a positive integer.',
|
|
78
|
+
);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
maximumPreparingIssuesCount = parsedCount;
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
await useCase.run({
|
|
64
85
|
projectUrl: options.projectUrl,
|
|
65
86
|
awaitingWorkspaceStatus: options.awaitingWorkspaceStatus,
|
|
66
87
|
preparationStatus: options.preparationStatus,
|
|
67
88
|
defaultAgentName: options.defaultAgentName,
|
|
68
89
|
logFilePath: options.logFilePath,
|
|
90
|
+
maximumPreparingIssuesCount,
|
|
69
91
|
});
|
|
70
92
|
});
|
|
71
93
|
|
|
@@ -58,6 +58,7 @@ describe('StartPreparationUseCase', () => {
|
|
|
58
58
|
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
59
59
|
preparationStatus: 'Preparation',
|
|
60
60
|
defaultAgentName: 'agent1',
|
|
61
|
+
maximumPreparingIssuesCount: null,
|
|
61
62
|
});
|
|
62
63
|
expect(mockIssueRepository.update.mock.calls).toHaveLength(1);
|
|
63
64
|
expect(mockIssueRepository.update.mock.calls[0][0]).toMatchObject({
|
|
@@ -99,6 +100,7 @@ describe('StartPreparationUseCase', () => {
|
|
|
99
100
|
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
100
101
|
preparationStatus: 'Preparation',
|
|
101
102
|
defaultAgentName: 'agent1',
|
|
103
|
+
maximumPreparingIssuesCount: null,
|
|
102
104
|
});
|
|
103
105
|
expect(mockIssueRepository.update.mock.calls).toHaveLength(1);
|
|
104
106
|
expect(mockIssueRepository.update.mock.calls[0][0]).toMatchObject({
|
|
@@ -135,6 +137,7 @@ describe('StartPreparationUseCase', () => {
|
|
|
135
137
|
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
136
138
|
preparationStatus: 'Preparation',
|
|
137
139
|
defaultAgentName: 'agent1',
|
|
140
|
+
maximumPreparingIssuesCount: null,
|
|
138
141
|
});
|
|
139
142
|
const issue7UpdateCalls = mockIssueRepository.update.mock.calls.filter(
|
|
140
143
|
(call) => call[0].id === '7',
|
|
@@ -165,6 +168,7 @@ describe('StartPreparationUseCase', () => {
|
|
|
165
168
|
preparationStatus: 'Preparation',
|
|
166
169
|
defaultAgentName: 'agent1',
|
|
167
170
|
logFilePath: '/path/to/log.txt',
|
|
171
|
+
maximumPreparingIssuesCount: null,
|
|
168
172
|
});
|
|
169
173
|
expect(mockLocalCommandRunner.runCommand.mock.calls).toHaveLength(1);
|
|
170
174
|
expect(mockLocalCommandRunner.runCommand.mock.calls[0][0]).toBe(
|
|
@@ -193,6 +197,7 @@ describe('StartPreparationUseCase', () => {
|
|
|
193
197
|
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
194
198
|
preparationStatus: 'Preparation',
|
|
195
199
|
defaultAgentName: 'agent1',
|
|
200
|
+
maximumPreparingIssuesCount: null,
|
|
196
201
|
});
|
|
197
202
|
expect(mockLocalCommandRunner.runCommand.mock.calls).toHaveLength(1);
|
|
198
203
|
expect(mockLocalCommandRunner.runCommand.mock.calls[0][0]).toBe(
|
|
@@ -236,8 +241,59 @@ describe('StartPreparationUseCase', () => {
|
|
|
236
241
|
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
237
242
|
preparationStatus: 'Preparation',
|
|
238
243
|
defaultAgentName: 'agent1',
|
|
244
|
+
maximumPreparingIssuesCount: null,
|
|
239
245
|
});
|
|
240
246
|
expect(mockIssueRepository.update.mock.calls).toHaveLength(1);
|
|
241
247
|
expect(mockLocalCommandRunner.runCommand.mock.calls).toHaveLength(1);
|
|
242
248
|
});
|
|
249
|
+
it('should use custom maximumPreparingIssuesCount when provided', async () => {
|
|
250
|
+
const awaitingIssues: Issue[] = Array.from({ length: 10 }, (_, i) => ({
|
|
251
|
+
id: `${i + 1}`,
|
|
252
|
+
url: `url${i + 1}`,
|
|
253
|
+
title: `Issue ${i + 1}`,
|
|
254
|
+
labels: [],
|
|
255
|
+
status: 'Awaiting Workspace',
|
|
256
|
+
}));
|
|
257
|
+
mockProjectRepository.getByUrl.mockResolvedValue(mockProject);
|
|
258
|
+
mockIssueRepository.getAllOpened.mockResolvedValueOnce(awaitingIssues);
|
|
259
|
+
mockLocalCommandRunner.runCommand.mockResolvedValue({
|
|
260
|
+
stdout: '',
|
|
261
|
+
stderr: '',
|
|
262
|
+
exitCode: 0,
|
|
263
|
+
});
|
|
264
|
+
await useCase.run({
|
|
265
|
+
projectUrl: 'https://github.com/user/repo',
|
|
266
|
+
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
267
|
+
preparationStatus: 'Preparation',
|
|
268
|
+
defaultAgentName: 'agent1',
|
|
269
|
+
maximumPreparingIssuesCount: 3,
|
|
270
|
+
});
|
|
271
|
+
expect(mockIssueRepository.update.mock.calls).toHaveLength(3);
|
|
272
|
+
expect(mockLocalCommandRunner.runCommand.mock.calls).toHaveLength(3);
|
|
273
|
+
});
|
|
274
|
+
it('should use default maximumPreparingIssuesCount of 6 when null is provided', async () => {
|
|
275
|
+
const awaitingIssues: Issue[] = Array.from({ length: 12 }, (_, i) => ({
|
|
276
|
+
id: `${i + 1}`,
|
|
277
|
+
url: `url${i + 1}`,
|
|
278
|
+
title: `Issue ${i + 1}`,
|
|
279
|
+
labels: [],
|
|
280
|
+
status: 'Awaiting Workspace',
|
|
281
|
+
}));
|
|
282
|
+
mockProjectRepository.getByUrl.mockResolvedValue(mockProject);
|
|
283
|
+
mockIssueRepository.getAllOpened.mockResolvedValueOnce(awaitingIssues);
|
|
284
|
+
mockLocalCommandRunner.runCommand.mockResolvedValue({
|
|
285
|
+
stdout: '',
|
|
286
|
+
stderr: '',
|
|
287
|
+
exitCode: 0,
|
|
288
|
+
});
|
|
289
|
+
await useCase.run({
|
|
290
|
+
projectUrl: 'https://github.com/user/repo',
|
|
291
|
+
awaitingWorkspaceStatus: 'Awaiting Workspace',
|
|
292
|
+
preparationStatus: 'Preparation',
|
|
293
|
+
defaultAgentName: 'agent1',
|
|
294
|
+
maximumPreparingIssuesCount: null,
|
|
295
|
+
});
|
|
296
|
+
expect(mockIssueRepository.update.mock.calls).toHaveLength(6);
|
|
297
|
+
expect(mockLocalCommandRunner.runCommand.mock.calls).toHaveLength(6);
|
|
298
|
+
});
|
|
243
299
|
});
|
|
@@ -3,7 +3,6 @@ import { ProjectRepository } from './adapter-interfaces/ProjectRepository';
|
|
|
3
3
|
import { LocalCommandRunner } from './adapter-interfaces/LocalCommandRunner';
|
|
4
4
|
|
|
5
5
|
export class StartPreparationUseCase {
|
|
6
|
-
maximumPreparingIssuesCount = 6;
|
|
7
6
|
constructor(
|
|
8
7
|
private readonly projectRepository: ProjectRepository,
|
|
9
8
|
private readonly issueRepository: IssueRepository,
|
|
@@ -16,7 +15,9 @@ export class StartPreparationUseCase {
|
|
|
16
15
|
preparationStatus: string;
|
|
17
16
|
defaultAgentName: string;
|
|
18
17
|
logFilePath?: string;
|
|
18
|
+
maximumPreparingIssuesCount: number | null;
|
|
19
19
|
}): Promise<void> => {
|
|
20
|
+
const maximumPreparingIssuesCount = params.maximumPreparingIssuesCount ?? 6;
|
|
20
21
|
const project = await this.projectRepository.getByUrl(params.projectUrl);
|
|
21
22
|
|
|
22
23
|
const allIssues = await this.issueRepository.getAllOpened(project);
|
|
@@ -32,7 +33,7 @@ export class StartPreparationUseCase {
|
|
|
32
33
|
let i = currentPreparationIssueCount;
|
|
33
34
|
i <
|
|
34
35
|
Math.min(
|
|
35
|
-
|
|
36
|
+
maximumPreparingIssuesCount,
|
|
36
37
|
awaitingWorkspaceIssues.length + currentPreparationIssueCount,
|
|
37
38
|
);
|
|
38
39
|
i++
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AA2G9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -5,7 +5,6 @@ export declare class StartPreparationUseCase {
|
|
|
5
5
|
private readonly projectRepository;
|
|
6
6
|
private readonly issueRepository;
|
|
7
7
|
private readonly localCommandRunner;
|
|
8
|
-
maximumPreparingIssuesCount: number;
|
|
9
8
|
constructor(projectRepository: ProjectRepository, issueRepository: IssueRepository, localCommandRunner: LocalCommandRunner);
|
|
10
9
|
run: (params: {
|
|
11
10
|
projectUrl: string;
|
|
@@ -13,6 +12,7 @@ export declare class StartPreparationUseCase {
|
|
|
13
12
|
preparationStatus: string;
|
|
14
13
|
defaultAgentName: string;
|
|
15
14
|
logFilePath?: string;
|
|
15
|
+
maximumPreparingIssuesCount: number | null;
|
|
16
16
|
}) => Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=StartPreparationUseCase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartPreparationUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/StartPreparationUseCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,qBAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"StartPreparationUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/StartPreparationUseCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAFlB,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,kBAAkB;IAGzD,GAAG,GAAU,QAAQ;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,uBAAuB,EAAE,MAAM,CAAC;QAChC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5C,KAAG,OAAO,CAAC,IAAI,CAAC,CAyCf;CACH"}
|