@jujulego/jill 1.1.16 → 1.2.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 (71) hide show
  1. package/dist/commands/each.command.d.ts +16 -0
  2. package/dist/commands/each.command.d.ts.map +1 -0
  3. package/dist/commands/each.command.js +203 -0
  4. package/dist/commands/each.command.js.map +1 -0
  5. package/dist/commands/info.command.d.ts +8 -0
  6. package/dist/commands/info.command.d.ts.map +1 -0
  7. package/dist/commands/info.command.js +178 -0
  8. package/dist/commands/info.command.js.map +1 -0
  9. package/dist/commands/list.command.d.ts +21 -0
  10. package/dist/commands/list.command.d.ts.map +1 -0
  11. package/dist/commands/list.command.js +251 -0
  12. package/dist/commands/list.command.js.map +1 -0
  13. package/dist/commands/run.command.d.ts +12 -0
  14. package/dist/commands/run.command.d.ts.map +1 -0
  15. package/dist/commands/run.command.js +111 -0
  16. package/dist/commands/run.command.js.map +1 -0
  17. package/dist/core.plugin.d.ts +2 -0
  18. package/dist/core.plugin.d.ts.map +1 -0
  19. package/dist/core.plugin.js +22 -0
  20. package/dist/core.plugin.js.map +1 -0
  21. package/dist/index.d.ts +4 -9
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +13 -26
  24. package/dist/index.js.map +1 -0
  25. package/dist/main.d.ts.map +1 -0
  26. package/dist/main.js +45 -141
  27. package/dist/main.js.map +1 -0
  28. package/dist/task-logger.d.ts.map +1 -0
  29. package/dist/task-logger.js +28 -17
  30. package/dist/task-logger.js.map +1 -0
  31. package/package.json +38 -25
  32. package/dist/commands/each.d.ts +0 -12
  33. package/dist/commands/each.js +0 -74
  34. package/dist/commands/info.d.ts +0 -5
  35. package/dist/commands/info.js +0 -42
  36. package/dist/commands/list.d.ts +0 -15
  37. package/dist/commands/list.js +0 -119
  38. package/dist/commands/run.d.ts +0 -9
  39. package/dist/commands/run.js +0 -43
  40. package/dist/filters/affected.d.ts +0 -10
  41. package/dist/filters/affected.js +0 -81
  42. package/dist/filters/filter.d.ts +0 -8
  43. package/dist/filters/filter.js +0 -35
  44. package/dist/filters/index.d.ts +0 -2
  45. package/dist/filters/index.js +0 -21
  46. package/dist/logger.d.ts +0 -32
  47. package/dist/logger.js +0 -189
  48. package/dist/myr/command.d.ts +0 -2
  49. package/dist/myr/command.js +0 -52
  50. package/dist/myr/commands/kill.d.ts +0 -5
  51. package/dist/myr/commands/kill.js +0 -34
  52. package/dist/myr/commands/list.d.ts +0 -10
  53. package/dist/myr/commands/list.js +0 -91
  54. package/dist/myr/commands/spawn.d.ts +0 -7
  55. package/dist/myr/commands/spawn.js +0 -39
  56. package/dist/myr/commands/stop.d.ts +0 -2
  57. package/dist/myr/commands/stop.js +0 -31
  58. package/dist/myr/myr-client.d.ts +0 -16
  59. package/dist/myr/myr-client.js +0 -455
  60. package/dist/myr/myr.process.d.ts +0 -1
  61. package/dist/myr/myr.process.js +0 -42
  62. package/dist/myr/watch.d.ts +0 -8
  63. package/dist/myr/watch.js +0 -79
  64. package/dist/pipeline.d.ts +0 -9
  65. package/dist/pipeline.js +0 -52
  66. package/dist/utils/cli-list.d.ts +0 -15
  67. package/dist/utils/cli-list.js +0 -86
  68. package/dist/utils/deps-tree.d.ts +0 -2
  69. package/dist/utils/deps-tree.js +0 -51
  70. package/dist/wrapper.d.ts +0 -9
  71. package/dist/wrapper.js +0 -38
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stopCommand = void 0;
7
-
8
- var _logger = require("../../logger");
9
-
10
- var _myrClient = require("../myr-client");
11
-
12
- // Command
13
- const stopCommand = async prj => {
14
- // Spawn task
15
- _logger.logger.spin('Stopping myr');
16
-
17
- const client = new _myrClient.MyrClient(prj);
18
- const ok = await client.stop();
19
-
20
- if (ok) {
21
- _logger.logger.succeed('myr stopped');
22
- } else {
23
- _logger.logger.stop();
24
-
25
- _logger.logger.warn('myr was not running');
26
- }
27
-
28
- return 0;
29
- };
30
-
31
- exports.stopCommand = stopCommand;
@@ -1,16 +0,0 @@
1
- import { Project, Workspace } from '@jujulego/jill-core';
2
- import { ITask } from '@jujulego/jill-myr';
3
- export declare class MyrClient {
4
- readonly project: Project;
5
- private readonly _logger;
6
- private readonly _endpoint;
7
- private readonly _qclient;
8
- constructor(project: Project);
9
- protected _autoStart<T>(fn: () => Promise<T>): Promise<T>;
10
- start(): Promise<void>;
11
- stop(): Promise<boolean>;
12
- tasks(): Promise<ITask[]>;
13
- spawn(cwd: string, cmd: string, args?: string[]): Promise<ITask>;
14
- spawnScript(wks: Workspace, script: string, args?: string[]): Promise<ITask>;
15
- kill(id: string): Promise<ITask | undefined>;
16
- }
@@ -1,455 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MyrClient = void 0;
7
-
8
- var _jillMyr = require("@jujulego/jill-myr");
9
-
10
- var _child_process = require("child_process");
11
-
12
- var _graphqlRequest = require("graphql-request");
13
-
14
- var _path = _interopRequireDefault(require("path"));
15
-
16
- var _logger = require("../logger");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
- // Class
23
- class MyrClient {
24
- // Attributes
25
- // Constructor
26
- constructor(project) {
27
- this.project = project;
28
-
29
- _defineProperty(this, "_logger", _logger.logger.child({
30
- context: MyrClient.name
31
- }));
32
-
33
- _defineProperty(this, "_endpoint", 'http://localhost:5001/');
34
-
35
- _defineProperty(this, "_qclient", new _graphqlRequest.GraphQLClient(this._endpoint));
36
- } // Methods
37
-
38
-
39
- async _autoStart(fn) {
40
- try {
41
- return await fn();
42
- } catch (error) {
43
- if (error.code !== 'ECONNREFUSED') throw error; // Start myr if connection impossible
44
-
45
- this._logger.verbose('Unable to connect to myr server, trying to start it');
46
-
47
- await this.start(); // Retry
48
-
49
- return await fn();
50
- }
51
- }
52
-
53
- start() {
54
- const child = (0, _child_process.fork)(_path.default.resolve(__dirname, './myr.process'), [], {
55
- cwd: this.project.root,
56
- detached: true,
57
- stdio: ['ignore', 'pipe', 'pipe', 'ipc']
58
- }); // Transmit logs to logger
59
-
60
- child.stdout?.on('data', msg => {
61
- for (const line of msg.toString('utf-8').split('\n')) {
62
- if (!line) continue;
63
- const {
64
- level,
65
- message,
66
- ...meta
67
- } = JSON.parse(line);
68
-
69
- _logger.logger.log(level, message, meta);
70
- }
71
- });
72
- child.stderr?.on('data', msg => {
73
- _logger.logger.error(msg.toString('utf-8'));
74
- }); // Start server
75
-
76
- return new Promise((resolve, reject) => {
77
- child.on('message', msg => {
78
- if (msg === 'started') {
79
- resolve();
80
- } else {
81
- reject(msg);
82
- }
83
- });
84
- child.on('close', (code, signal) => {
85
- reject(new Error(`Myr process ended with code ${code} by signal ${signal}`));
86
- });
87
- child.send('start');
88
- });
89
- }
90
-
91
- async stop() {
92
- try {
93
- await this._qclient.request({
94
- "kind": "Document",
95
- "definitions": [{
96
- "kind": "OperationDefinition",
97
- "operation": "mutation",
98
- "name": {
99
- "kind": "Name",
100
- "value": "Shutdown"
101
- },
102
- "variableDefinitions": [],
103
- "directives": [],
104
- "selectionSet": {
105
- "kind": "SelectionSet",
106
- "selections": [{
107
- "kind": "Field",
108
- "name": {
109
- "kind": "Name",
110
- "value": "shutdown"
111
- },
112
- "arguments": [],
113
- "directives": []
114
- }]
115
- }
116
- }],
117
- "loc": {
118
- "start": 0,
119
- "end": 64,
120
- "source": {
121
- "body": "\n mutation Shutdown {\n shutdown\n }\n ",
122
- "name": "GraphQL request",
123
- "locationOffset": {
124
- "line": 1,
125
- "column": 1
126
- }
127
- }
128
- }
129
- });
130
- return true;
131
- } catch (error) {
132
- if (error.code !== 'ECONNREFUSED') throw error;
133
- return false;
134
- }
135
- }
136
-
137
- async tasks() {
138
- return await this._autoStart(async () => {
139
- const {
140
- tasks
141
- } = await this._qclient.request({
142
- "kind": "Document",
143
- "definitions": [{
144
- "kind": "OperationDefinition",
145
- "operation": "query",
146
- "name": {
147
- "kind": "Name",
148
- "value": "Tasks"
149
- },
150
- "variableDefinitions": [],
151
- "directives": [],
152
- "selectionSet": {
153
- "kind": "SelectionSet",
154
- "selections": [{
155
- "kind": "Field",
156
- "name": {
157
- "kind": "Name",
158
- "value": "tasks"
159
- },
160
- "arguments": [],
161
- "directives": [],
162
- "selectionSet": {
163
- "kind": "SelectionSet",
164
- "selections": [{
165
- "kind": "FragmentSpread",
166
- "name": {
167
- "kind": "Name",
168
- "value": "Task"
169
- },
170
- "directives": []
171
- }]
172
- }
173
- }]
174
- }
175
- }].concat(_jillMyr.TaskFragment.definitions).reduce((acc, definition) => definition.kind === 'FragmentDefinition' && acc.find(curDef => curDef.kind === 'FragmentDefinition' && curDef.name.value === definition.name.value) ? acc : acc.concat(definition), []),
176
- "loc": {
177
- "start": 0,
178
- "end": 119,
179
- "source": {
180
- "body": "\n query Tasks {\n tasks {\n ...Task\n }\n }\n\n \n ",
181
- "name": "GraphQL request",
182
- "locationOffset": {
183
- "line": 1,
184
- "column": 1
185
- }
186
- }
187
- }
188
- });
189
- return tasks;
190
- });
191
- }
192
-
193
- async spawn(cwd, cmd, args = []) {
194
- return await this._autoStart(async () => {
195
- const {
196
- spawn
197
- } = await this._qclient.request({
198
- "kind": "Document",
199
- "definitions": [{
200
- "kind": "OperationDefinition",
201
- "operation": "mutation",
202
- "name": {
203
- "kind": "Name",
204
- "value": "Spawn"
205
- },
206
- "variableDefinitions": [{
207
- "kind": "VariableDefinition",
208
- "variable": {
209
- "kind": "Variable",
210
- "name": {
211
- "kind": "Name",
212
- "value": "cwd"
213
- }
214
- },
215
- "type": {
216
- "kind": "NonNullType",
217
- "type": {
218
- "kind": "NamedType",
219
- "name": {
220
- "kind": "Name",
221
- "value": "String"
222
- }
223
- }
224
- },
225
- "directives": []
226
- }, {
227
- "kind": "VariableDefinition",
228
- "variable": {
229
- "kind": "Variable",
230
- "name": {
231
- "kind": "Name",
232
- "value": "cmd"
233
- }
234
- },
235
- "type": {
236
- "kind": "NonNullType",
237
- "type": {
238
- "kind": "NamedType",
239
- "name": {
240
- "kind": "Name",
241
- "value": "String"
242
- }
243
- }
244
- },
245
- "directives": []
246
- }, {
247
- "kind": "VariableDefinition",
248
- "variable": {
249
- "kind": "Variable",
250
- "name": {
251
- "kind": "Name",
252
- "value": "args"
253
- }
254
- },
255
- "type": {
256
- "kind": "NonNullType",
257
- "type": {
258
- "kind": "ListType",
259
- "type": {
260
- "kind": "NonNullType",
261
- "type": {
262
- "kind": "NamedType",
263
- "name": {
264
- "kind": "Name",
265
- "value": "String"
266
- }
267
- }
268
- }
269
- }
270
- },
271
- "directives": []
272
- }],
273
- "directives": [],
274
- "selectionSet": {
275
- "kind": "SelectionSet",
276
- "selections": [{
277
- "kind": "Field",
278
- "name": {
279
- "kind": "Name",
280
- "value": "spawn"
281
- },
282
- "arguments": [{
283
- "kind": "Argument",
284
- "name": {
285
- "kind": "Name",
286
- "value": "cwd"
287
- },
288
- "value": {
289
- "kind": "Variable",
290
- "name": {
291
- "kind": "Name",
292
- "value": "cwd"
293
- }
294
- }
295
- }, {
296
- "kind": "Argument",
297
- "name": {
298
- "kind": "Name",
299
- "value": "cmd"
300
- },
301
- "value": {
302
- "kind": "Variable",
303
- "name": {
304
- "kind": "Name",
305
- "value": "cmd"
306
- }
307
- }
308
- }, {
309
- "kind": "Argument",
310
- "name": {
311
- "kind": "Name",
312
- "value": "args"
313
- },
314
- "value": {
315
- "kind": "Variable",
316
- "name": {
317
- "kind": "Name",
318
- "value": "args"
319
- }
320
- }
321
- }],
322
- "directives": [],
323
- "selectionSet": {
324
- "kind": "SelectionSet",
325
- "selections": [{
326
- "kind": "FragmentSpread",
327
- "name": {
328
- "kind": "Name",
329
- "value": "Task"
330
- },
331
- "directives": []
332
- }]
333
- }
334
- }]
335
- }
336
- }].concat(_jillMyr.TaskFragment.definitions).reduce((acc, definition) => definition.kind === 'FragmentDefinition' && acc.find(curDef => curDef.kind === 'FragmentDefinition' && curDef.name.value === definition.name.value) ? acc : acc.concat(definition), []),
337
- "loc": {
338
- "start": 0,
339
- "end": 206,
340
- "source": {
341
- "body": "\n mutation Spawn($cwd: String!, $cmd: String!, $args: [String!]!) {\n spawn(cwd: $cwd, cmd: $cmd, args: $args) {\n ...Task\n }\n }\n\n \n ",
342
- "name": "GraphQL request",
343
- "locationOffset": {
344
- "line": 1,
345
- "column": 1
346
- }
347
- }
348
- }
349
- }, {
350
- cwd,
351
- cmd,
352
- args
353
- });
354
- return spawn;
355
- });
356
- }
357
-
358
- async spawnScript(wks, script, args = []) {
359
- return await this.spawn(wks.cwd, await wks.project.packageManager(), [script, ...args]);
360
- }
361
-
362
- async kill(id) {
363
- return await this._autoStart(async () => {
364
- const {
365
- kill
366
- } = await this._qclient.request({
367
- "kind": "Document",
368
- "definitions": [{
369
- "kind": "OperationDefinition",
370
- "operation": "mutation",
371
- "name": {
372
- "kind": "Name",
373
- "value": "Kill"
374
- },
375
- "variableDefinitions": [{
376
- "kind": "VariableDefinition",
377
- "variable": {
378
- "kind": "Variable",
379
- "name": {
380
- "kind": "Name",
381
- "value": "id"
382
- }
383
- },
384
- "type": {
385
- "kind": "NonNullType",
386
- "type": {
387
- "kind": "NamedType",
388
- "name": {
389
- "kind": "Name",
390
- "value": "ID"
391
- }
392
- }
393
- },
394
- "directives": []
395
- }],
396
- "directives": [],
397
- "selectionSet": {
398
- "kind": "SelectionSet",
399
- "selections": [{
400
- "kind": "Field",
401
- "name": {
402
- "kind": "Name",
403
- "value": "kill"
404
- },
405
- "arguments": [{
406
- "kind": "Argument",
407
- "name": {
408
- "kind": "Name",
409
- "value": "id"
410
- },
411
- "value": {
412
- "kind": "Variable",
413
- "name": {
414
- "kind": "Name",
415
- "value": "id"
416
- }
417
- }
418
- }],
419
- "directives": [],
420
- "selectionSet": {
421
- "kind": "SelectionSet",
422
- "selections": [{
423
- "kind": "FragmentSpread",
424
- "name": {
425
- "kind": "Name",
426
- "value": "Task"
427
- },
428
- "directives": []
429
- }]
430
- }
431
- }]
432
- }
433
- }].concat(_jillMyr.TaskFragment.definitions).reduce((acc, definition) => definition.kind === 'FragmentDefinition' && acc.find(curDef => curDef.kind === 'FragmentDefinition' && curDef.name.value === definition.name.value) ? acc : acc.concat(definition), []),
434
- "loc": {
435
- "start": 0,
436
- "end": 139,
437
- "source": {
438
- "body": "\n mutation Kill($id: ID!) {\n kill(id: $id) {\n ...Task\n }\n }\n\n \n ",
439
- "name": "GraphQL request",
440
- "locationOffset": {
441
- "line": 1,
442
- "column": 1
443
- }
444
- }
445
- }
446
- }, {
447
- id
448
- });
449
- return kill;
450
- });
451
- }
452
-
453
- }
454
-
455
- exports.MyrClient = MyrClient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _jillCore = require("@jujulego/jill-core");
4
-
5
- var _jillMyr = require("@jujulego/jill-myr");
6
-
7
- var _winston = _interopRequireWildcard(require("winston"));
8
-
9
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
-
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
-
13
- // Setup logger
14
- const trans = new _winston.default.transports.Console({
15
- level: 'debug',
16
- format: _winston.format.combine(_winston.format.timestamp({
17
- format: () => new Date().toLocaleString()
18
- }), _winston.format.errors(), _winston.format.json()),
19
- consoleWarnLevels: [],
20
- stderrLevels: []
21
- });
22
-
23
- _jillCore.logger.add(trans); // Start server when parent is ready
24
-
25
-
26
- process.once('message', async () => {
27
- try {
28
- // Start server
29
- const server = new _jillMyr.MyrServer();
30
- await server.start();
31
-
32
- _jillCore.logger.remove(trans);
33
-
34
- process.send?.('started');
35
- } catch (error) {
36
- process.send?.({
37
- name: error.name,
38
- message: error.message
39
- });
40
- process.exit(1);
41
- }
42
- });
@@ -1,8 +0,0 @@
1
- import { CommandHandler } from '../wrapper';
2
- export interface WatchArgs {
3
- script: string;
4
- workspace: string | undefined;
5
- daemon: boolean;
6
- '--'?: (string | number)[] | undefined;
7
- }
8
- export declare const watchCommand: CommandHandler<WatchArgs>;
package/dist/myr/watch.js DELETED
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.watchCommand = void 0;
7
-
8
- var _jillCore = require("@jujulego/jill-core");
9
-
10
- var _logger = require("../logger");
11
-
12
- var _myrClient = require("./myr-client");
13
-
14
- // Utils
15
- async function spawnDepsTree(myr, wks, set) {
16
- let count = 0;
17
-
18
- for await (const ws of (0, _jillCore.combine)(wks.dependencies(), wks.devDependencies())) {
19
- if (set.has(ws.cwd)) continue;
20
- set.add(ws.cwd); // Spawn dependencies
21
-
22
- count += await spawnDepsTree(myr, ws, set); // Spawn task
23
-
24
- const tsk = await myr.spawnScript(ws, 'watch');
25
-
26
- _logger.logger.log('info', `Task ${tsk.id} spawned`, {
27
- label: ws.name
28
- });
29
-
30
- count++;
31
- }
32
-
33
- return count;
34
- } // Command
35
-
36
-
37
- const watchCommand = async (prj, argv) => {
38
- // Get workspace
39
- _logger.logger.spin('Loading project');
40
-
41
- const wks = await (argv.workspace ? prj.workspace(argv.workspace) : prj.currentWorkspace());
42
-
43
- if (!wks) {
44
- _logger.logger.fail(`Workspace ${argv.workspace || '.'} not found`);
45
-
46
- return 1;
47
- } // Spawn watch
48
-
49
-
50
- _logger.logger.spin('Spawning dependencies watch tasks');
51
-
52
- const myr = new _myrClient.MyrClient(prj);
53
- const count = await spawnDepsTree(myr, wks, new Set()); // Spawn task
54
-
55
- if (argv.daemon) {
56
- _logger.logger.spin(`Spawning ${argv.script} task`);
57
-
58
- const tsk = await myr.spawnScript(wks, argv.script, argv['--']?.map(arg => arg.toString()));
59
-
60
- _logger.logger.log('info', `Task ${tsk.id} spawned`, {
61
- label: wks.name
62
- });
63
-
64
- _logger.logger.succeed(`${count + 1} watch tasks spawned`);
65
-
66
- return 0;
67
- } else {
68
- _logger.logger.succeed(`${count} watch tasks spawned`);
69
-
70
- const tsk = await wks.run(argv.script, argv['--']?.map(arg => arg.toString()), {
71
- buildDeps: 'none'
72
- });
73
- tsk.start();
74
- await tsk.waitFor('done', 'failed');
75
- return tsk.exitCode === 0 ? 0 : 1;
76
- }
77
- };
78
-
79
- exports.watchCommand = watchCommand;
@@ -1,9 +0,0 @@
1
- import { Workspace } from '@jujulego/jill-core';
2
- import { Repeater } from '@repeaterjs/repeater';
3
- import { Filter } from './filters';
4
- export declare class Pipeline {
5
- private _filters;
6
- add(filter: Filter): void;
7
- private _test;
8
- filter(workspaces: AsyncGenerator<Workspace>): Repeater<Workspace>;
9
- }
package/dist/pipeline.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Pipeline = void 0;
7
-
8
- var _repeater = require("@repeaterjs/repeater");
9
-
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
-
12
- // Class
13
- class Pipeline {
14
- constructor() {
15
- _defineProperty(this, "_filters", []);
16
- }
17
-
18
- // Methods
19
- add(filter) {
20
- this._filters.push(filter);
21
- }
22
-
23
- async _test(workspace) {
24
- for (const filter of this._filters) {
25
- const res = await filter.test(workspace);
26
-
27
- if (!res) {
28
- return false;
29
- }
30
- }
31
-
32
- return true;
33
- }
34
-
35
- filter(workspaces) {
36
- return new _repeater.Repeater(async (push, stop) => {
37
- const proms = [];
38
-
39
- for await (const wks of workspaces) {
40
- proms.push(this._test(wks).then(res => {
41
- if (res) push(wks);
42
- }));
43
- }
44
-
45
- await Promise.all(proms);
46
- stop();
47
- });
48
- }
49
-
50
- }
51
-
52
- exports.Pipeline = Pipeline;