@jujulego/jill 3.0.0-alpha.6 → 3.0.0-alpha.7
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/bin/jill.js +1 -4
- package/dist/TaskName.js +1 -1
- package/dist/inked.js +1 -1
- package/dist/instrument.js +3 -2
- package/dist/instrument.js.map +1 -1
- package/dist/list.ink.js +2 -1
- package/dist/list.ink.js.map +1 -1
- package/dist/main.js +120 -102
- package/dist/main.js.map +1 -1
- package/dist/planner.service.js +2 -1
- package/dist/planner.service.js.map +1 -1
- package/dist/task-exec.ink.js +3 -1
- package/dist/task-exec.ink.js.map +1 -1
- package/dist/task-plan.ink.js +2 -1
- package/dist/task-plan.ink.js.map +1 -1
- package/dist/tree.ink.js +2 -1
- package/dist/tree.ink.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +21 -21
package/bin/jill.js
CHANGED
package/dist/TaskName.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="17363c5b-8c12-425c-9bfc-b22bfcde7f09",e._sentryDebugIdIdentifier="sentry-dbid-17363c5b-8c12-425c-9bfc-b22bfcde7f09");})();}catch(e){}};!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"3.0.0-alpha.7"};}catch(e){}}();import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Text } from 'ink';
|
|
3
3
|
import { a as isScriptCtx } from './main.js';
|
|
4
4
|
|
package/dist/inked.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="92368bb9-8978-4811-a19e-8d31de9120d2",e._sentryDebugIdIdentifier="sentry-dbid-92368bb9-8978-4811-a19e-8d31de9120d2");})();}catch(e){}};!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"3.0.0-alpha.7"};}catch(e){}}();import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { startSpan } from '@sentry/node';
|
|
3
3
|
import { useStderr, render } from 'ink';
|
|
4
4
|
import { inject$ } from '@kyrielle/injector';
|
package/dist/instrument.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c983ba1b-dae6-4864-b164-e9932653ec2b",e._sentryDebugIdIdentifier="sentry-dbid-c983ba1b-dae6-4864-b164-e9932653ec2b");})();}catch(e){}};!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"3.0.0-alpha.7"};}catch(e){}}();import { init } from '@sentry/node';
|
|
2
2
|
|
|
3
3
|
init({
|
|
4
4
|
dsn: 'https://53e6d10c16975ebd025175d9836d039b@o4508229080055808.ingest.de.sentry.io/4509876546895952',
|
|
5
5
|
sendDefaultPii: false,
|
|
6
|
-
tracesSampleRate: 1.0
|
|
6
|
+
tracesSampleRate: 1.0,
|
|
7
|
+
enabled: process.env.DISABLE_TRACING !== 'true'
|
|
7
8
|
});
|
|
8
9
|
//# sourceMappingURL=instrument.js.map
|
package/dist/instrument.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.js","sources":["../src/instrument.ts"],"sourcesContent":["import { init } from '@sentry/node';\n\ninit({\n dsn: 'https://53e6d10c16975ebd025175d9836d039b@o4508229080055808.ingest.de.sentry.io/4509876546895952',\n sendDefaultPii: false,\n tracesSampleRate: 1.0,\n});\n"],"names":["init","dsn","sendDefaultPii","tracesSampleRate"],"mappings":";;AAEAA,IAAAA,CAAK,CAAA;IACHC,GAAAA,EAAK,CAAA,KAAA,CAAA,CAAA,CAAA,gCAAA,CAAA,iBAAA,CAAA,MAAA,CAAA,EAAA,CAAA,MAAA,CAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;IACLC,cAAAA,EAAgB,KAAA,CAAA;IAChBC,gBAAAA,CAAAA,
|
|
1
|
+
{"version":3,"file":"instrument.js","sources":["../src/instrument.ts"],"sourcesContent":["import { init } from '@sentry/node';\n\ninit({\n dsn: 'https://53e6d10c16975ebd025175d9836d039b@o4508229080055808.ingest.de.sentry.io/4509876546895952',\n sendDefaultPii: false,\n tracesSampleRate: 1.0,\n enabled: process.env.DISABLE_TRACING !== 'true',\n});\n"],"names":["init","dsn","sendDefaultPii","tracesSampleRate","enabled","process","env","DISABLE_TRACING"],"mappings":";;AAEAA,IAAAA,CAAK,CAAA;IACHC,GAAAA,EAAK,CAAA,KAAA,CAAA,CAAA,CAAA,gCAAA,CAAA,iBAAA,CAAA,MAAA,CAAA,EAAA,CAAA,MAAA,CAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;IACLC,cAAAA,EAAgB,KAAA,CAAA;IAChBC,gBAAAA,EAAkB,CAAA,CAAA,CAAA,CAAA;AAClBC,CAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAASC,OAAAA,CAAQC,GAAG,CAACC,eAAe,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,IAAA,CAAA;AAC3C,CAAA,CAAA"}
|
package/dist/list.ink.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="709f9f0c-2b27-4e12-a775-626dddf53de8",e._sentryDebugIdIdentifier="sentry-dbid-709f9f0c-2b27-4e12-a775-626dddf53de8");})();}catch(e){}};!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"3.0.0-alpha.7"};}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
3
|
import { c as capitalize } from './main.js';
|
|
4
4
|
import { i as inked } from './inked.js';
|
|
@@ -13,6 +13,7 @@ import '@kyrielle/logger';
|
|
|
13
13
|
import 'node:fs';
|
|
14
14
|
import 'path-scurry';
|
|
15
15
|
import '@swc/helpers/_/_apply_decs_2203_r';
|
|
16
|
+
import 'node:stream/consumers';
|
|
16
17
|
import 'node:path';
|
|
17
18
|
import 'glob';
|
|
18
19
|
import 'normalize-package-data';
|
package/dist/list.ink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.ink.js","sources":["../src/cli/commands/list.ink.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { capitalize } from '../../utils/string.js';\nimport { inked } from '../inked.jsx';\nimport type { ExtractedData, ListAttr } from './list.js';\n\nconst ListInk = inked(function* (props: ListInkProps) {\n const { attributes, headers, workspaces } = props;\n\n yield (\n <Box>\n { attributes.map((attr) => (\n <Box key={attr} flexDirection=\"column\" marginRight={2}>\n { headers && (\n <Text bold>{ capitalize(attr) }</Text>\n ) }\n { workspaces.map((wks, idx) => (\n <Text key={idx}>{ wks[attr] || ' ' }</Text>\n ))}\n </Box>\n )) }\n </Box>\n );\n});\n\nexport default ListInk;\n\n// Types\nexport interface ListInkProps {\n readonly attributes: readonly ListAttr[];\n readonly headers?: boolean;\n readonly workspaces: readonly ExtractedData[];\n}"],"names":["ListInk","inked","props","attributes","headers","workspaces","_jsx","Box","map","attr","_jsxs","flexDirection","marginRight","Text","bold","capitalize","wks","idx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.ink.js","sources":["../src/cli/commands/list.ink.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { capitalize } from '../../utils/string.js';\nimport { inked } from '../inked.jsx';\nimport type { ExtractedData, ListAttr } from './list.js';\n\nconst ListInk = inked(function* (props: ListInkProps) {\n const { attributes, headers, workspaces } = props;\n\n yield (\n <Box>\n { attributes.map((attr) => (\n <Box key={attr} flexDirection=\"column\" marginRight={2}>\n { headers && (\n <Text bold>{ capitalize(attr) }</Text>\n ) }\n { workspaces.map((wks, idx) => (\n <Text key={idx}>{ wks[attr] || ' ' }</Text>\n ))}\n </Box>\n )) }\n </Box>\n );\n});\n\nexport default ListInk;\n\n// Types\nexport interface ListInkProps {\n readonly attributes: readonly ListAttr[];\n readonly headers?: boolean;\n readonly workspaces: readonly ExtractedData[];\n}"],"names":["ListInk","inked","props","attributes","headers","workspaces","_jsx","Box","map","attr","_jsxs","flexDirection","marginRight","Text","bold","capitalize","wks","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,KAAA,CAAMA,OAAAA,CAAAA,CAAAA,CAAUC,KAAAA,CAAM,QAAA,CAAA,CAAWC,KAAmB,CAAA,CAAA,CAAA;AAClD,CAAA,CAAA,CAAA,CAAA,KAAA,CAAM,EAAEC,UAAU,CAAA,CAAEC,OAAO,CAAA,CAAEC,UAAU,CAAA,CAAE,CAAA,CAAA,CAAGH,KAAAA,CAAAA;AAE5C,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CACEI,GAAA,CAACC,GAAAA,CAAAA,CAAAA,CAAAA;AACGJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAAAA,UAAAA,CAAWK,GAAG,CAAC,CAACC,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAAAA,CAChBC,IAAA,CAACH,GAAAA,CAAAA,CAAAA,CAAAA;gBAAeI,aAAAA,EAAc,CAAA,MAAA,CAAA,CAAA;gBAASC,WAAAA,EAAa,CAAA,CAAA;;AAChDR,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAAAA,CACAE,GAAA,CAACO,IAAAA,CAAAA,CAAAA,CAAAA;wBAAKC,IAAI,EAAA,IAAA,CAAA;kCAAGC,UAAAA,CAAWN,IAAAA,CAAAA;;AAExBJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,UAAAA,CAAWG,GAAG,CAAC,CAACQ,GAAAA,CAAAA,CAAKC,oBACrBX,GAAA,CAACO,IAAAA,CAAAA,CAAAA,CAAAA;sCAAiBG,GAAG,CAACP,KAAK,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA;AAApBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA;;AALLR,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,IAAAA,CAAAA,CAAAA;;AAWlB,CAAA,CAAA,CAAA;;"}
|
package/dist/main.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
;{try{(function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="423e1769-82e8-4ede-89c9-d0cfbda3929d",e._sentryDebugIdIdentifier="sentry-dbid-423e1769-82e8-4ede-89c9-d0cfbda3929d");})();}catch(e){}};!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"3.0.0-alpha.7"};}catch(e){}}();import { token$, inject$, asyncScope$ } from '@kyrielle/injector';
|
|
2
2
|
import { startSpan, getActiveSpan, updateSpanName, getRootSpan, startInactiveSpan, captureException } from '@sentry/node';
|
|
3
3
|
import process$1 from 'node:process';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
|
-
import { pipe$, waitFor$, filter$,
|
|
5
|
+
import { pipe$, waitFor$, filter$, map$, collect$, asyncIterator$, var$, observable$, off$, once$, flow$ } from 'kyrielle';
|
|
6
6
|
import yargs from 'yargs';
|
|
7
|
-
import { TaskManager, plan, SpawnTask, GroupTask, TaskSet, ParallelGroup, FallbackGroup, SequenceGroup } from '@jujulego/tasks';
|
|
7
|
+
import { TaskManager, scheduler$, isWorkloadEnded, WorkloadState, plan, spawn$, SpawnTask, GroupTask, TaskSet, ParallelGroup, FallbackGroup, SequenceGroup } from '@jujulego/tasks';
|
|
8
8
|
import { logger$, withTimestamp, withLabel, qLogDelay, LogLevel, LogGateway, logDelay$, toStderr } from '@kyrielle/logger';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import { PathScurry } from 'path-scurry';
|
|
11
11
|
import { _ } from '@swc/helpers/_/_apply_decs_2203_r';
|
|
12
|
+
import { text } from 'node:stream/consumers';
|
|
12
13
|
import path from 'node:path';
|
|
13
14
|
import { Glob } from 'glob';
|
|
14
15
|
import normalize from 'normalize-package-data';
|
|
@@ -23,7 +24,7 @@ import os from 'node:os';
|
|
|
23
24
|
import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
|
|
24
25
|
import { chalkTemplateStderr } from 'chalk-template';
|
|
25
26
|
|
|
26
|
-
var version = "3.0.0-alpha.
|
|
27
|
+
var version = "3.0.0-alpha.7";
|
|
27
28
|
|
|
28
29
|
function trace(fun, opts) {
|
|
29
30
|
const name = typeof opts === 'string' ? opts : opts.name;
|
|
@@ -96,7 +97,7 @@ const LOGGER = token$('Logger', ()=>logger$(withTimestamp()));
|
|
|
96
97
|
const PATH_SCURRY = token$('PathScurry', ()=>new PathScurry('/', {
|
|
97
98
|
fs
|
|
98
99
|
}));
|
|
99
|
-
const TASK_MANAGER = token$('TaskManager', async ()=>{
|
|
100
|
+
/** @deprecated */ const TASK_MANAGER = token$('TaskManager', async ()=>{
|
|
100
101
|
const manager = new TaskManager({
|
|
101
102
|
jobs: (await inject$(CONFIG, asyncScope$())).jobs,
|
|
102
103
|
logger: inject$(LOGGER)
|
|
@@ -137,6 +138,51 @@ const TASK_MANAGER = token$('TaskManager', async ()=>{
|
|
|
137
138
|
});
|
|
138
139
|
return manager;
|
|
139
140
|
});
|
|
141
|
+
const SCHEDULER = token$('Scheduler', async ()=>{
|
|
142
|
+
const config = await inject$(CONFIG, asyncScope$());
|
|
143
|
+
const logger = inject$(LOGGER);
|
|
144
|
+
const scheduler = scheduler$({
|
|
145
|
+
strength: config.jobs
|
|
146
|
+
});
|
|
147
|
+
scheduler.events$.on('started', (job)=>{
|
|
148
|
+
logger.verbose(`job "${job.label}" started`);
|
|
149
|
+
});
|
|
150
|
+
scheduler.events$.on('ended', (job)=>{
|
|
151
|
+
logger.verbose(`job "${job.label}" ended in state ${job.state()}`);
|
|
152
|
+
});
|
|
153
|
+
// Task instrumentation
|
|
154
|
+
scheduler.events$.on('added', (job)=>{
|
|
155
|
+
const jobSpan = startInactiveSpan({
|
|
156
|
+
op: 'job',
|
|
157
|
+
name: job.label,
|
|
158
|
+
attributes: {
|
|
159
|
+
'job.id': job.id,
|
|
160
|
+
'job.type': job.type,
|
|
161
|
+
'job.weight': job.weight
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Status spans
|
|
165
|
+
let stateSpan;
|
|
166
|
+
const sub = job.state$.subscribe((state)=>{
|
|
167
|
+
stateSpan?.end();
|
|
168
|
+
if (isWorkloadEnded(state)) {
|
|
169
|
+
jobSpan.setAttribute('job.final_state', state);
|
|
170
|
+
jobSpan.setStatus({
|
|
171
|
+
code: state === WorkloadState.Succeeded ? 1 : 2
|
|
172
|
+
});
|
|
173
|
+
jobSpan.end();
|
|
174
|
+
sub.unsubscribe();
|
|
175
|
+
} else {
|
|
176
|
+
stateSpan = startInactiveSpan({
|
|
177
|
+
op: 'job.state',
|
|
178
|
+
name: state,
|
|
179
|
+
parentSpan: jobSpan
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
return scheduler;
|
|
185
|
+
});
|
|
140
186
|
|
|
141
187
|
// Utils
|
|
142
188
|
function printJson(data, stream = process.stdout) {
|
|
@@ -252,37 +298,12 @@ function hasEveryScript$(scripts) {
|
|
|
252
298
|
});
|
|
253
299
|
}
|
|
254
300
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
301
|
+
class ClientError extends Error {
|
|
302
|
+
name = 'ClientError';
|
|
303
|
+
constructor(message){
|
|
304
|
+
super(message);
|
|
259
305
|
}
|
|
260
306
|
}
|
|
261
|
-
function streamLines$(task, stream = 'stdout') {
|
|
262
|
-
return observable$((observer, signal)=>{
|
|
263
|
-
const off = off$();
|
|
264
|
-
let current = '';
|
|
265
|
-
// End
|
|
266
|
-
off.add(once$(task.events$, 'completed', ()=>{
|
|
267
|
-
if (current) observer.next(current);
|
|
268
|
-
observer.complete();
|
|
269
|
-
off.unsubscribe();
|
|
270
|
-
}));
|
|
271
|
-
// Abort
|
|
272
|
-
signal.addEventListener('abort', ()=>off.unsubscribe(), {
|
|
273
|
-
once: true
|
|
274
|
-
});
|
|
275
|
-
// Steam
|
|
276
|
-
off.add(task.events$.on(`stream.${stream}`, (chunk)=>{
|
|
277
|
-
const data = current + chunk.data.toString('utf-8');
|
|
278
|
-
const lines = data.split(/\r?\n/);
|
|
279
|
-
current = lines.pop() ?? '';
|
|
280
|
-
for (const line of lines){
|
|
281
|
-
observer.next(line);
|
|
282
|
-
}
|
|
283
|
-
}));
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
307
|
|
|
287
308
|
var _dec$4, _dec1$3, _dec2$1, _initProto$4;
|
|
288
309
|
_dec$4 = instrument('GitService.isAffected'), _dec1$3 = instrument('GitService.listBranches'), _dec2$1 = instrument('GitService.listTags');
|
|
@@ -307,103 +328,75 @@ class GitService {
|
|
|
307
328
|
], []));
|
|
308
329
|
}
|
|
309
330
|
// Attributes
|
|
310
|
-
|
|
331
|
+
_scheduler = (_initProto$4(this), inject$(SCHEDULER));
|
|
311
332
|
_logger = inject$(LOGGER);
|
|
312
333
|
// Methods
|
|
313
334
|
/**
|
|
314
|
-
* Runs a git command inside
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
*/ async command(cmd, args, options = {}) {
|
|
320
|
-
const opts = {
|
|
321
|
-
logger: this._logger,
|
|
322
|
-
...options
|
|
323
|
-
};
|
|
324
|
-
// Create task
|
|
325
|
-
const task = new SpawnTask('git', [
|
|
335
|
+
* Runs a git command inside
|
|
336
|
+
*/ async command(cmd, args, opts = {}) {
|
|
337
|
+
const { logger = this._logger, ...props } = opts;
|
|
338
|
+
// Create job
|
|
339
|
+
const job = spawn$('git', [
|
|
326
340
|
cmd,
|
|
327
341
|
...args
|
|
328
|
-
],
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
(await this._manager).add(task);
|
|
334
|
-
return task;
|
|
342
|
+
], props);
|
|
343
|
+
job.stdout.on('data', (data)=>logger.debug(data.toString('utf-8').trimEnd()));
|
|
344
|
+
job.stderr.on('data', (data)=>logger.warn(data.toString('utf-8').trimEnd()));
|
|
345
|
+
(await this._scheduler).register(job);
|
|
346
|
+
return job;
|
|
335
347
|
}
|
|
336
348
|
/**
|
|
337
349
|
* Runs git branch
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
* @param options
|
|
341
|
-
*/ branch(args, options) {
|
|
342
|
-
return this.command('branch', args, options);
|
|
350
|
+
*/ branch(args, opts) {
|
|
351
|
+
return this.command('branch', args, opts);
|
|
343
352
|
}
|
|
344
353
|
/**
|
|
345
354
|
* Runs git diff
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
* @param options
|
|
349
|
-
*/ diff(args, options) {
|
|
350
|
-
return this.command('diff', args, options);
|
|
355
|
+
*/ diff(args, opts) {
|
|
356
|
+
return this.command('diff', args, opts);
|
|
351
357
|
}
|
|
352
358
|
/**
|
|
353
359
|
* Runs git tag
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
* @param options
|
|
357
|
-
*/ tag(args, options) {
|
|
358
|
-
return this.command('tag', args, options);
|
|
360
|
+
*/ tag(args, opts) {
|
|
361
|
+
return this.command('tag', args, opts);
|
|
359
362
|
}
|
|
360
363
|
/**
|
|
361
364
|
* Uses git diff to detect if given files have been affected since given reference
|
|
362
|
-
*
|
|
363
|
-
* @param reference
|
|
364
|
-
* @param files
|
|
365
|
-
* @param opts
|
|
366
365
|
*/ async isAffected(reference, files = [], opts) {
|
|
367
|
-
const
|
|
366
|
+
const job = await this.diff([
|
|
368
367
|
'--quiet',
|
|
369
368
|
reference,
|
|
370
369
|
'--',
|
|
371
370
|
...files
|
|
372
371
|
], opts);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
});
|
|
382
|
-
});
|
|
372
|
+
await waitFor$(pipe$(job.state$, filter$(isWorkloadEnded)));
|
|
373
|
+
if (job.exitCode() === 0) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
if (job.exitCode() === 1) {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
throw new ClientError(`Error "git diff" command failed (exit code ${job.exitCode()})`);
|
|
383
380
|
}
|
|
384
381
|
/**
|
|
385
382
|
* List git branches
|
|
386
|
-
*
|
|
387
|
-
* @param args
|
|
388
|
-
* @param opts
|
|
389
383
|
*/ async listBranches(args = [], opts) {
|
|
390
|
-
const
|
|
384
|
+
const job = await this.branch([
|
|
391
385
|
'-l',
|
|
392
386
|
...args
|
|
393
387
|
], opts);
|
|
394
|
-
|
|
388
|
+
const output = await text(job.stdout);
|
|
389
|
+
return pipe$(output.split(/\r?\n/), map$((line)=>line.replace(/^[ *] /, '')), filter$((line)=>!!line), collect$());
|
|
395
390
|
}
|
|
396
391
|
/**
|
|
397
392
|
* List git tags
|
|
398
|
-
*
|
|
399
|
-
* @param args
|
|
400
|
-
* @param opts
|
|
401
393
|
*/ async listTags(args = [], opts) {
|
|
402
|
-
const
|
|
394
|
+
const job = await this.tag([
|
|
403
395
|
'-l',
|
|
404
396
|
...args
|
|
405
397
|
], opts);
|
|
406
|
-
|
|
398
|
+
const output = await text(job.stdout);
|
|
399
|
+
return output.split(/\r?\n/).filter((line)=>!!line);
|
|
407
400
|
}
|
|
408
401
|
}
|
|
409
402
|
|
|
@@ -500,6 +493,38 @@ async function with$(lock, fn) {
|
|
|
500
493
|
}
|
|
501
494
|
}
|
|
502
495
|
|
|
496
|
+
// Utils
|
|
497
|
+
async function* combine(...generators) {
|
|
498
|
+
for (const gen of generators){
|
|
499
|
+
yield* gen;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function streamLines$(task, stream = 'stdout') {
|
|
503
|
+
return observable$((observer, signal)=>{
|
|
504
|
+
const off = off$();
|
|
505
|
+
let current = '';
|
|
506
|
+
// End
|
|
507
|
+
off.add(once$(task.events$, 'completed', ()=>{
|
|
508
|
+
if (current) observer.next(current);
|
|
509
|
+
observer.complete();
|
|
510
|
+
off.unsubscribe();
|
|
511
|
+
}));
|
|
512
|
+
// Abort
|
|
513
|
+
signal.addEventListener('abort', ()=>off.unsubscribe(), {
|
|
514
|
+
once: true
|
|
515
|
+
});
|
|
516
|
+
// Steam
|
|
517
|
+
off.add(task.events$.on(`stream.${stream}`, (chunk)=>{
|
|
518
|
+
const data = current + chunk.data.toString('utf-8');
|
|
519
|
+
const lines = data.split(/\r?\n/);
|
|
520
|
+
current = lines.pop() ?? '';
|
|
521
|
+
for (const line of lines){
|
|
522
|
+
observer.next(line);
|
|
523
|
+
}
|
|
524
|
+
}));
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
503
528
|
// Class
|
|
504
529
|
class CommandTask extends SpawnTask {
|
|
505
530
|
workspace;
|
|
@@ -547,13 +572,6 @@ function isCommandCtx(ctx) {
|
|
|
547
572
|
return 'workspace' in ctx && 'command' in ctx;
|
|
548
573
|
}
|
|
549
574
|
|
|
550
|
-
class ClientError extends Error {
|
|
551
|
-
name = 'ClientError';
|
|
552
|
-
constructor(message){
|
|
553
|
-
super(message);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
575
|
// Utils
|
|
558
576
|
function capitalize(txt) {
|
|
559
577
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
@@ -2115,7 +2133,7 @@ void startSpan({
|
|
|
2115
2133
|
if (msg) {
|
|
2116
2134
|
logger.error(msg);
|
|
2117
2135
|
} else if (err instanceof ClientError) {
|
|
2118
|
-
logger.
|
|
2136
|
+
logger.error(err.message);
|
|
2119
2137
|
} else {
|
|
2120
2138
|
captureException(err, {
|
|
2121
2139
|
tags: {
|