@jujulego/jill 3.0.0-alpha.1 → 3.0.0-alpha.3
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/README.md +1 -2
- package/bin/jill.js +1 -0
- package/dist/TaskName.js +33 -0
- package/dist/TaskName.js.map +1 -0
- package/dist/inked.js +66 -0
- package/dist/inked.js.map +1 -0
- package/dist/instrument.js +8 -0
- package/dist/instrument.js.map +1 -0
- package/dist/list.ink.js +50 -0
- package/dist/list.ink.js.map +1 -0
- package/dist/main.js +44 -35
- package/dist/main.js.map +1 -1
- package/dist/parser.js +2104 -0
- package/dist/parser.js.map +1 -0
- package/dist/planner.service.js +58 -0
- package/dist/planner.service.js.map +1 -0
- package/dist/task-exec.ink.js +539 -0
- package/dist/task-exec.ink.js.map +1 -0
- package/dist/task-plan.ink.js +114 -0
- package/dist/task-plan.ink.js.map +1 -0
- package/dist/tree.ink.js +185 -0
- package/dist/tree.ink.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +46 -45
- package/dist/ajv.config.d.ts +0 -3
- package/dist/commands/each.d.ts +0 -25
- package/dist/commands/exec.d.ts +0 -26
- package/dist/commands/group.d.ts +0 -16
- package/dist/commands/list.d.ts +0 -30
- package/dist/commands/run.d.ts +0 -24
- package/dist/commands/tree.d.ts +0 -6
- package/dist/commons/context.service.d.ts +0 -23
- package/dist/commons/git.service.d.ts +0 -62
- package/dist/commons/logger/log.gateway.d.ts +0 -18
- package/dist/commons/logger/parameters.d.ts +0 -2
- package/dist/commons/logger/thread.gateway.d.ts +0 -12
- package/dist/commons/logger/types.d.ts +0 -2
- package/dist/commons/logger.service.d.ts +0 -1
- package/dist/config/config-loader.d.ts +0 -4
- package/dist/config/config-options.d.ts +0 -5
- package/dist/config/types.d.ts +0 -8
- package/dist/config/utils.d.ts +0 -5
- package/dist/constants.d.ts +0 -1
- package/dist/core.plugin-CxgfxFUI.js +0 -642
- package/dist/core.plugin-CxgfxFUI.js.map +0 -1
- package/dist/core.plugin.d.ts +0 -2
- package/dist/filters/affected.filter.d.ts +0 -12
- package/dist/filters/pipeline.d.ts +0 -11
- package/dist/filters/private.filter.d.ts +0 -7
- package/dist/filters/scripts.filter.d.ts +0 -8
- package/dist/index.d.ts +0 -45
- package/dist/index.js +0 -35
- package/dist/index.js.map +0 -1
- package/dist/ink-command-CsbkuRbm.js +0 -2071
- package/dist/ink-command-CsbkuRbm.js.map +0 -1
- package/dist/ink.config.d.ts +0 -3
- package/dist/inversify.config.d.ts +0 -4
- package/dist/jill.application-DNJpmnCF.js +0 -637
- package/dist/jill.application-DNJpmnCF.js.map +0 -1
- package/dist/jill.application.d.ts +0 -19
- package/dist/main.d.ts +0 -1
- package/dist/middlewares/load-project.d.ts +0 -21
- package/dist/middlewares/load-workspace.d.ts +0 -20
- package/dist/modules/command.d.ts +0 -20
- package/dist/modules/ink-command.d.ts +0 -11
- package/dist/modules/middleware.d.ts +0 -8
- package/dist/modules/module.d.ts +0 -7
- package/dist/modules/plugin-loader.service.d.ts +0 -10
- package/dist/modules/plugin.d.ts +0 -14
- package/dist/modules/service.d.ts +0 -8
- package/dist/modules/task-command.d.ts +0 -14
- package/dist/project/project.d.ts +0 -27
- package/dist/project/project.repository.d.ts +0 -15
- package/dist/project/types.d.ts +0 -1
- package/dist/project/workspace.d.ts +0 -41
- package/dist/tasks/command-task.d.ts +0 -15
- package/dist/tasks/errors.d.ts +0 -4
- package/dist/tasks/script-task.d.ts +0 -27
- package/dist/tasks/task-expression.service.d.ts +0 -25
- package/dist/tasks/task-manager.config.d.ts +0 -3
- package/dist/types.d.ts +0 -11
- package/dist/ui/hooks/useFlatTaskTree.d.ts +0 -14
- package/dist/ui/hooks/useIsVerbose.d.ts +0 -1
- package/dist/ui/hooks/useStdoutDimensions.d.ts +0 -4
- package/dist/ui/layout.d.ts +0 -5
- package/dist/ui/list.d.ts +0 -5
- package/dist/ui/static-logs.d.ts +0 -1
- package/dist/ui/task-name.d.ts +0 -5
- package/dist/ui/task-spinner.d.ts +0 -5
- package/dist/ui/task-tree-completed.d.ts +0 -5
- package/dist/ui/task-tree-full-spinner.d.ts +0 -5
- package/dist/ui/task-tree-scrollable-spinner.d.ts +0 -5
- package/dist/ui/task-tree-spinner.d.ts +0 -5
- package/dist/ui/task-tree-stats.d.ts +0 -5
- package/dist/ui/workspace-tree.d.ts +0 -8
- package/dist/utils/events.d.ts +0 -3
- package/dist/utils/exit.d.ts +0 -4
- package/dist/utils/import.d.ts +0 -4
- package/dist/utils/json.d.ts +0 -1
- package/dist/utils/streams.d.ts +0 -3
- package/dist/utils/string.d.ts +0 -2
- package/dist/utils/worker-cache.d.ts +0 -3
- package/dist/workspace-tree-VWKE0B6b.js +0 -1120
- package/dist/workspace-tree-VWKE0B6b.js.map +0 -1
|
@@ -1,642 +0,0 @@
|
|
|
1
|
-
import { _ } from '@swc/helpers/_/_ts_decorate';
|
|
2
|
-
import { _ as _$1 } from '@swc/helpers/_/_ts_param';
|
|
3
|
-
import { Logger, withLabel } from '@jujulego/logger';
|
|
4
|
-
import { inject } from 'inversify';
|
|
5
|
-
import symbols from 'log-symbols';
|
|
6
|
-
import { b as LazyCurrentProject, L as LoadProject, T as TaskExpressionService, k as TaskExpressionError, l as TaskSyntaxError, S as ScriptsFilter, a as PrivateFilter, A as AffectedFilter, P as Pipeline, d as LazyCurrentWorkspace, c as LoadWorkspace, W as WorkspaceTree, f as Plugin } from './workspace-tree-VWKE0B6b.js';
|
|
7
|
-
import { f as Command, E as ExitException, I as InkCommand, y as printJson, a as List } from './ink-command-CsbkuRbm.js';
|
|
8
|
-
import { T as TaskCommand } from './jill.application-DNJpmnCF.js';
|
|
9
|
-
import cp from 'node:child_process';
|
|
10
|
-
import process$1 from 'node:process';
|
|
11
|
-
import { jsx } from 'react/jsx-runtime';
|
|
12
|
-
import chalk from 'chalk';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
import { compare, parse } from 'semver';
|
|
15
|
-
import slugify from 'slugify';
|
|
16
|
-
import '@jujulego/event-tree';
|
|
17
|
-
import '@jujulego/tasks';
|
|
18
|
-
import '@jujulego/utils';
|
|
19
|
-
import 'glob';
|
|
20
|
-
import 'node:fs';
|
|
21
|
-
import 'normalize-package-data';
|
|
22
|
-
import 'path-scurry';
|
|
23
|
-
import 'node:fs/promises';
|
|
24
|
-
import 'moo';
|
|
25
|
-
import 'ink';
|
|
26
|
-
import 'react';
|
|
27
|
-
import 'node:async_hooks';
|
|
28
|
-
import 'node:os';
|
|
29
|
-
import 'ajv';
|
|
30
|
-
import 'node:worker_threads';
|
|
31
|
-
import 'yargs';
|
|
32
|
-
import 'yargs/helpers';
|
|
33
|
-
import 'cosmiconfig';
|
|
34
|
-
import 'ink-spinner';
|
|
35
|
-
import 'pretty-ms';
|
|
36
|
-
import 'inversify-inject-decorators';
|
|
37
|
-
import '@jujulego/aegis';
|
|
38
|
-
import '@jujulego/quick-tag';
|
|
39
|
-
import 'chalk-template';
|
|
40
|
-
|
|
41
|
-
class EachCommand extends TaskCommand {
|
|
42
|
-
// Constructor
|
|
43
|
-
constructor(logger, taskExpression){
|
|
44
|
-
super();
|
|
45
|
-
this.logger = logger;
|
|
46
|
-
this.taskExpression = taskExpression;
|
|
47
|
-
}
|
|
48
|
-
// Methods
|
|
49
|
-
builder(parser) {
|
|
50
|
-
return this.addTaskOptions(parser)// Run options
|
|
51
|
-
.positional('expr', {
|
|
52
|
-
type: 'string',
|
|
53
|
-
demandOption: true,
|
|
54
|
-
desc: 'Script or task expression'
|
|
55
|
-
}).option('build-script', {
|
|
56
|
-
default: 'build',
|
|
57
|
-
desc: 'Script to use to build dependencies'
|
|
58
|
-
}).option('deps-mode', {
|
|
59
|
-
alias: 'd',
|
|
60
|
-
choice: [
|
|
61
|
-
'all',
|
|
62
|
-
'prod',
|
|
63
|
-
'none'
|
|
64
|
-
],
|
|
65
|
-
default: 'all',
|
|
66
|
-
desc: 'Dependency selection mode:\n' + ' - all = dependencies AND devDependencies\n' + ' - prod = dependencies\n' + ' - none = nothing'
|
|
67
|
-
}).option('allow-no-workspaces', {
|
|
68
|
-
type: 'boolean',
|
|
69
|
-
default: false,
|
|
70
|
-
desc: 'Allow no matching workspaces. Without it jill will exit with code 1 if no workspace matches'
|
|
71
|
-
})// Filters
|
|
72
|
-
.option('private', {
|
|
73
|
-
type: 'boolean',
|
|
74
|
-
group: 'Filters:',
|
|
75
|
-
desc: 'Print only private workspaces'
|
|
76
|
-
}).option('affected', {
|
|
77
|
-
alias: 'a',
|
|
78
|
-
type: 'string',
|
|
79
|
-
coerce: (rev)=>rev === '' ? 'master' : rev,
|
|
80
|
-
group: 'Filters:',
|
|
81
|
-
desc: 'Print only affected workspaces towards given git revision. If no revision is given, it will check towards master. Replaces %name by workspace name.'
|
|
82
|
-
}).option('affected-rev-sort', {
|
|
83
|
-
type: 'string',
|
|
84
|
-
group: 'Filters:',
|
|
85
|
-
desc: 'Sort applied to git tag / git branch command'
|
|
86
|
-
}).option('affected-rev-fallback', {
|
|
87
|
-
type: 'string',
|
|
88
|
-
default: 'master',
|
|
89
|
-
group: 'Filters:',
|
|
90
|
-
desc: 'Fallback revision, used if no revision matching the given format is found'
|
|
91
|
-
})// Config
|
|
92
|
-
.strict(false).parserConfiguration({
|
|
93
|
-
'unknown-options-as-args': true
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
async *prepare(argv) {
|
|
97
|
-
let empty = true;
|
|
98
|
-
try {
|
|
99
|
-
// Extract expression
|
|
100
|
-
const expr = argv._.map((arg)=>arg.toString());
|
|
101
|
-
if (expr[0] === 'each') {
|
|
102
|
-
expr.splice(0, 1);
|
|
103
|
-
}
|
|
104
|
-
expr.unshift(argv.expr);
|
|
105
|
-
const tree = this.taskExpression.parse(expr.join(' '));
|
|
106
|
-
const scripts = Array.from(this.taskExpression.extractScripts(tree));
|
|
107
|
-
// Create script tasks
|
|
108
|
-
const pipeline = this._preparePipeline(argv, scripts);
|
|
109
|
-
for await (const wks of pipeline.filter(this.project.workspaces())){
|
|
110
|
-
const task = await this.taskExpression.buildTask(tree.roots[0], wks, {
|
|
111
|
-
buildScript: argv.buildScript,
|
|
112
|
-
buildDeps: argv.depsMode
|
|
113
|
-
});
|
|
114
|
-
if (task) {
|
|
115
|
-
yield task;
|
|
116
|
-
empty = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
if (err instanceof TaskExpressionError) {
|
|
121
|
-
this.logger.error(err.message);
|
|
122
|
-
throw new ExitException(1);
|
|
123
|
-
}
|
|
124
|
-
if (err instanceof TaskSyntaxError) {
|
|
125
|
-
this.logger.error(`Syntax error in task expression: ${err.message}`);
|
|
126
|
-
throw new ExitException(1);
|
|
127
|
-
}
|
|
128
|
-
throw err;
|
|
129
|
-
}
|
|
130
|
-
if (empty) {
|
|
131
|
-
this.logger.error(`${symbols.error} No matching workspace found !`);
|
|
132
|
-
if (argv.allowNoWorkspaces === false) {
|
|
133
|
-
throw new ExitException(1);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
_preparePipeline(argv, scripts) {
|
|
138
|
-
const pipeline = new Pipeline();
|
|
139
|
-
pipeline.add(new ScriptsFilter(scripts, true));
|
|
140
|
-
if (argv.private !== undefined) {
|
|
141
|
-
pipeline.add(new PrivateFilter(argv.private));
|
|
142
|
-
}
|
|
143
|
-
if (argv.affected !== undefined) {
|
|
144
|
-
pipeline.add(new AffectedFilter(argv.affected, argv.affectedRevFallback, argv.affectedRevSort));
|
|
145
|
-
}
|
|
146
|
-
return pipeline;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
_([
|
|
150
|
-
LazyCurrentProject()
|
|
151
|
-
], EachCommand.prototype, "project", void 0);
|
|
152
|
-
EachCommand = _([
|
|
153
|
-
Command({
|
|
154
|
-
command: 'each <expr>',
|
|
155
|
-
describe: 'Run a task expression in many workspace, after having built all theirs dependencies.',
|
|
156
|
-
middlewares: [
|
|
157
|
-
LoadProject
|
|
158
|
-
]
|
|
159
|
-
}),
|
|
160
|
-
_$1(0, inject(Logger)),
|
|
161
|
-
_$1(1, inject(TaskExpressionService))
|
|
162
|
-
], EachCommand);
|
|
163
|
-
|
|
164
|
-
class ExecCommand extends TaskCommand {
|
|
165
|
-
// Constructor
|
|
166
|
-
constructor(logger){
|
|
167
|
-
super();
|
|
168
|
-
this._logger = logger.child(withLabel('exec'));
|
|
169
|
-
}
|
|
170
|
-
// Methods
|
|
171
|
-
builder(parser) {
|
|
172
|
-
return this.addTaskOptions(parser).positional('command', {
|
|
173
|
-
type: 'string',
|
|
174
|
-
demandOption: true
|
|
175
|
-
}).option('build-script', {
|
|
176
|
-
default: 'build',
|
|
177
|
-
desc: 'Script to use to build dependencies'
|
|
178
|
-
}).option('deps-mode', {
|
|
179
|
-
alias: 'd',
|
|
180
|
-
choice: [
|
|
181
|
-
'all',
|
|
182
|
-
'prod',
|
|
183
|
-
'none'
|
|
184
|
-
],
|
|
185
|
-
default: 'all',
|
|
186
|
-
desc: 'Dependency selection mode:\n' + ' - all = dependencies AND devDependencies\n' + ' - prod = dependencies\n' + ' - none = nothing'
|
|
187
|
-
})// Documentation
|
|
188
|
-
.example('jill eslint', '').example('jill eslint --env-info', 'Unknown arguments are passed down to command. Here it would run eslint --env-info').example('jill eslint -- -v', 'You can use -- to stop argument parsing. Here it would run eslint -v')// Config
|
|
189
|
-
.strict(false).parserConfiguration({
|
|
190
|
-
'unknown-options-as-args': true
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
async *prepare(args) {
|
|
194
|
-
// Extract arguments
|
|
195
|
-
const rest = args._.map((arg)=>arg.toString());
|
|
196
|
-
if (rest[0] === 'exec') {
|
|
197
|
-
rest.splice(0, 1);
|
|
198
|
-
}
|
|
199
|
-
// Run script in workspace
|
|
200
|
-
const task = await this.workspace.exec(args.command, rest, {
|
|
201
|
-
buildScript: args.buildScript,
|
|
202
|
-
buildDeps: args.depsMode
|
|
203
|
-
});
|
|
204
|
-
if (args.plan) {
|
|
205
|
-
yield task;
|
|
206
|
-
} else {
|
|
207
|
-
this._finalTask = task;
|
|
208
|
-
yield* task.dependencies;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
async handler(args) {
|
|
212
|
-
await super.handler(args);
|
|
213
|
-
if (!args.plan) {
|
|
214
|
-
this.app.unmount();
|
|
215
|
-
// Execute command
|
|
216
|
-
this._logger.debug`${this._finalTask.cmd} ${this._finalTask.args.join(' ')}`;
|
|
217
|
-
const child = cp.spawn(this._finalTask.cmd, this._finalTask.args, {
|
|
218
|
-
stdio: 'inherit',
|
|
219
|
-
cwd: this._finalTask.cwd,
|
|
220
|
-
env: {
|
|
221
|
-
...process$1.env,
|
|
222
|
-
...this._finalTask.env
|
|
223
|
-
},
|
|
224
|
-
shell: true,
|
|
225
|
-
windowsHide: true
|
|
226
|
-
});
|
|
227
|
-
const code = await new Promise((resolve)=>{
|
|
228
|
-
child.on('close', (code)=>{
|
|
229
|
-
resolve(code ?? 0);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
if (code) {
|
|
233
|
-
throw new ExitException(code);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
_([
|
|
239
|
-
LazyCurrentProject()
|
|
240
|
-
], ExecCommand.prototype, "project", void 0);
|
|
241
|
-
_([
|
|
242
|
-
LazyCurrentWorkspace()
|
|
243
|
-
], ExecCommand.prototype, "workspace", void 0);
|
|
244
|
-
ExecCommand = _([
|
|
245
|
-
Command({
|
|
246
|
-
command: 'exec <command>',
|
|
247
|
-
aliases: [
|
|
248
|
-
'$0'
|
|
249
|
-
],
|
|
250
|
-
describe: 'Run command inside workspace, after all its dependencies has been built.',
|
|
251
|
-
middlewares: [
|
|
252
|
-
LoadProject,
|
|
253
|
-
LoadWorkspace
|
|
254
|
-
]
|
|
255
|
-
}),
|
|
256
|
-
_$1(0, inject(Logger))
|
|
257
|
-
], ExecCommand);
|
|
258
|
-
|
|
259
|
-
class GroupCommand extends TaskCommand {
|
|
260
|
-
// Constructor
|
|
261
|
-
constructor(taskExpr){
|
|
262
|
-
super();
|
|
263
|
-
this.taskExpr = taskExpr;
|
|
264
|
-
}
|
|
265
|
-
// Methods
|
|
266
|
-
builder(parser) {
|
|
267
|
-
return this.addTaskOptions(parser).positional('script', {
|
|
268
|
-
demandOption: true,
|
|
269
|
-
desc: 'Task expression',
|
|
270
|
-
coerce: (expr)=>this.taskExpr.parse(expr.join(' '))
|
|
271
|
-
}).option('build-script', {
|
|
272
|
-
default: 'build',
|
|
273
|
-
desc: 'Script to use to build dependencies'
|
|
274
|
-
}).option('deps-mode', {
|
|
275
|
-
alias: 'd',
|
|
276
|
-
choice: [
|
|
277
|
-
'all',
|
|
278
|
-
'prod',
|
|
279
|
-
'none'
|
|
280
|
-
],
|
|
281
|
-
default: 'all',
|
|
282
|
-
desc: 'Dependency selection mode:\n' + ' - all = dependencies AND devDependencies\n' + ' - prod = dependencies\n' + ' - none = nothing'
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
async *prepare(args) {
|
|
286
|
-
// Run script in workspace
|
|
287
|
-
const group = await this.taskExpr.buildTask(args.script.roots[0], this.workspace, {
|
|
288
|
-
buildScript: args.buildScript,
|
|
289
|
-
buildDeps: args.depsMode
|
|
290
|
-
});
|
|
291
|
-
yield group;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
_([
|
|
295
|
-
LazyCurrentWorkspace()
|
|
296
|
-
], GroupCommand.prototype, "workspace", void 0);
|
|
297
|
-
GroupCommand = _([
|
|
298
|
-
Command({
|
|
299
|
-
command: 'group <script..>',
|
|
300
|
-
describe: 'Run many scripts inside a workspace (experimental)',
|
|
301
|
-
deprecated: true,
|
|
302
|
-
middlewares: [
|
|
303
|
-
LoadProject,
|
|
304
|
-
LoadWorkspace
|
|
305
|
-
]
|
|
306
|
-
}),
|
|
307
|
-
_$1(0, inject(TaskExpressionService))
|
|
308
|
-
], GroupCommand);
|
|
309
|
-
|
|
310
|
-
// Constants
|
|
311
|
-
const LONG_ATTRIBUTES = [
|
|
312
|
-
'name',
|
|
313
|
-
'version',
|
|
314
|
-
'root'
|
|
315
|
-
];
|
|
316
|
-
const JSON_ATTRIBUTES = [
|
|
317
|
-
'name',
|
|
318
|
-
'version',
|
|
319
|
-
'slug',
|
|
320
|
-
'root'
|
|
321
|
-
];
|
|
322
|
-
const DEFAULT_ATTRIBUTES = [
|
|
323
|
-
'name'
|
|
324
|
-
];
|
|
325
|
-
const EXTRACTORS = {
|
|
326
|
-
name: (wks)=>wks.name,
|
|
327
|
-
version: (wks, json)=>wks.manifest.version || (json ? undefined : chalk.grey('unset')),
|
|
328
|
-
root: (wks)=>wks.cwd,
|
|
329
|
-
slug: (wks)=>slugify.default(wks.name)
|
|
330
|
-
};
|
|
331
|
-
const COMPARATORS = {
|
|
332
|
-
name: (a = '', b = '')=>a.localeCompare(b),
|
|
333
|
-
version: (a, b)=>compare(parse(a) ?? '0.0.0', parse(b) ?? '0.0.0'),
|
|
334
|
-
root: (a = '', b = '')=>a.localeCompare(b),
|
|
335
|
-
slug: (a = '', b = '')=>a.localeCompare(b)
|
|
336
|
-
};
|
|
337
|
-
// Utils
|
|
338
|
-
function buildExtractor(attrs) {
|
|
339
|
-
return (wks, json)=>{
|
|
340
|
-
const data = {};
|
|
341
|
-
for (const attr of attrs){
|
|
342
|
-
data[attr] = EXTRACTORS[attr](wks, json);
|
|
343
|
-
}
|
|
344
|
-
return data;
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
class ListCommand extends InkCommand {
|
|
348
|
-
// Constructor
|
|
349
|
-
constructor(logger){
|
|
350
|
-
super();
|
|
351
|
-
this.logger = logger;
|
|
352
|
-
}
|
|
353
|
-
// Methods
|
|
354
|
-
builder(parser) {
|
|
355
|
-
return parser// Filters
|
|
356
|
-
.option('private', {
|
|
357
|
-
type: 'boolean',
|
|
358
|
-
group: 'Filters:',
|
|
359
|
-
desc: 'Print only private workspaces'
|
|
360
|
-
}).option('with-script', {
|
|
361
|
-
type: 'array',
|
|
362
|
-
string: true,
|
|
363
|
-
group: 'Filters:',
|
|
364
|
-
desc: 'Print only workspaces having the given script'
|
|
365
|
-
}).option('affected', {
|
|
366
|
-
alias: 'a',
|
|
367
|
-
type: 'string',
|
|
368
|
-
coerce: (rev)=>rev === '' ? 'master' : rev,
|
|
369
|
-
group: 'Filters:',
|
|
370
|
-
desc: 'Print only affected workspaces towards given git revision. If no revision is given, it will check towards master. Replaces %name by workspace name.'
|
|
371
|
-
}).option('affected-rev-sort', {
|
|
372
|
-
type: 'string',
|
|
373
|
-
group: 'Filters:',
|
|
374
|
-
desc: 'Sort applied to git tag / git branch command'
|
|
375
|
-
}).option('affected-rev-fallback', {
|
|
376
|
-
type: 'string',
|
|
377
|
-
default: 'master',
|
|
378
|
-
group: 'Filters:',
|
|
379
|
-
desc: 'Fallback revision, used if no revision matching the given format is found'
|
|
380
|
-
})// Format
|
|
381
|
-
.option('attrs', {
|
|
382
|
-
type: 'array',
|
|
383
|
-
choices: [
|
|
384
|
-
'name',
|
|
385
|
-
'version',
|
|
386
|
-
'root',
|
|
387
|
-
'slug'
|
|
388
|
-
],
|
|
389
|
-
group: 'Format:',
|
|
390
|
-
desc: 'Select printed attributes'
|
|
391
|
-
}).option('headers', {
|
|
392
|
-
type: 'boolean',
|
|
393
|
-
group: 'Format:',
|
|
394
|
-
desc: 'Prints columns headers'
|
|
395
|
-
}).option('long', {
|
|
396
|
-
alias: 'l',
|
|
397
|
-
type: 'boolean',
|
|
398
|
-
group: 'Format:',
|
|
399
|
-
desc: 'Prints name, version and root of all workspaces'
|
|
400
|
-
}).option('json', {
|
|
401
|
-
type: 'boolean',
|
|
402
|
-
group: 'Format:',
|
|
403
|
-
desc: 'Prints data as a JSON array'
|
|
404
|
-
})// Sort
|
|
405
|
-
.option('sort-by', {
|
|
406
|
-
alias: 's',
|
|
407
|
-
type: 'array',
|
|
408
|
-
choices: [
|
|
409
|
-
'name',
|
|
410
|
-
'version',
|
|
411
|
-
'root',
|
|
412
|
-
'slug'
|
|
413
|
-
],
|
|
414
|
-
group: 'Sort:',
|
|
415
|
-
desc: 'Sort output by given attribute. By default sorts by name if printed'
|
|
416
|
-
}).option('order', {
|
|
417
|
-
alias: 'o',
|
|
418
|
-
type: 'string',
|
|
419
|
-
choices: [
|
|
420
|
-
'asc',
|
|
421
|
-
'desc'
|
|
422
|
-
],
|
|
423
|
-
default: 'asc',
|
|
424
|
-
group: 'Sort:',
|
|
425
|
-
desc: 'Sort order'
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
async *render(args) {
|
|
429
|
-
const { attrs, sortBy } = this._applyDefaults(args);
|
|
430
|
-
// Load workspaces
|
|
431
|
-
const pipeline = this._preparePipeline(args);
|
|
432
|
-
const workspaces = [];
|
|
433
|
-
for await (const wks of pipeline.filter(this.project.workspaces())){
|
|
434
|
-
workspaces.push(wks);
|
|
435
|
-
}
|
|
436
|
-
// Build data
|
|
437
|
-
const data = workspaces.map((wks)=>buildExtractor(attrs)(wks, args.json || false));
|
|
438
|
-
if (sortBy.length > 0) {
|
|
439
|
-
data.sort(this._dataComparator(sortBy, args.order));
|
|
440
|
-
}
|
|
441
|
-
// Print list
|
|
442
|
-
if (args.json) {
|
|
443
|
-
printJson(data);
|
|
444
|
-
} else {
|
|
445
|
-
for (const d of data){
|
|
446
|
-
if (d.root) {
|
|
447
|
-
d.root = path.relative(process.cwd(), d.root) || '.';
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
yield /*#__PURE__*/ jsx(List, {
|
|
451
|
-
items: data,
|
|
452
|
-
headers: args.headers ?? attrs.length > 1
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
_applyDefaults(argv) {
|
|
457
|
-
// Compute attributes
|
|
458
|
-
let attrs = argv.attrs ?? [];
|
|
459
|
-
if (attrs.length === 0) {
|
|
460
|
-
if (argv.long) {
|
|
461
|
-
attrs = LONG_ATTRIBUTES;
|
|
462
|
-
} else if (argv.json) {
|
|
463
|
-
attrs = JSON_ATTRIBUTES;
|
|
464
|
-
} else {
|
|
465
|
-
attrs = argv.sortBy ?? DEFAULT_ATTRIBUTES;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
// Check sorted attributes
|
|
469
|
-
let sortBy = argv.sortBy ?? [];
|
|
470
|
-
if (attrs.length > 0 && sortBy.length > 0) {
|
|
471
|
-
const miss = sortBy.filter((attr)=>!attrs.includes(attr));
|
|
472
|
-
if (miss.length > 0) {
|
|
473
|
-
this.logger.error(`Cannot sort by non printed attributes. Missing ${miss.join(', ')}.`);
|
|
474
|
-
throw new ExitException(1);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
if (sortBy.length === 0 && attrs.includes('name')) {
|
|
478
|
-
sortBy = [
|
|
479
|
-
'name'
|
|
480
|
-
];
|
|
481
|
-
}
|
|
482
|
-
return {
|
|
483
|
-
attrs,
|
|
484
|
-
sortBy
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
_preparePipeline(argv) {
|
|
488
|
-
const pipeline = new Pipeline();
|
|
489
|
-
if (argv.private !== undefined) {
|
|
490
|
-
pipeline.add(new PrivateFilter(argv.private));
|
|
491
|
-
}
|
|
492
|
-
if (argv.withScript) {
|
|
493
|
-
pipeline.add(new ScriptsFilter(argv.withScript));
|
|
494
|
-
}
|
|
495
|
-
if (argv.affected !== undefined) {
|
|
496
|
-
pipeline.add(new AffectedFilter(argv.affected, argv.affectedRevFallback, argv.affectedRevSort));
|
|
497
|
-
}
|
|
498
|
-
return pipeline;
|
|
499
|
-
}
|
|
500
|
-
_dataComparator(sortBy, order) {
|
|
501
|
-
const factor = order === 'asc' ? 1 : -1;
|
|
502
|
-
return (a, b)=>{
|
|
503
|
-
for (const attr of sortBy){
|
|
504
|
-
const diff = COMPARATORS[attr](a[attr], b[attr]);
|
|
505
|
-
if (diff !== 0) {
|
|
506
|
-
return factor * diff;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return 0;
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
_([
|
|
514
|
-
LazyCurrentProject()
|
|
515
|
-
], ListCommand.prototype, "project", void 0);
|
|
516
|
-
ListCommand = _([
|
|
517
|
-
Command({
|
|
518
|
-
command: 'list',
|
|
519
|
-
aliases: [
|
|
520
|
-
'ls'
|
|
521
|
-
],
|
|
522
|
-
describe: 'List workspace',
|
|
523
|
-
middlewares: [
|
|
524
|
-
LoadProject
|
|
525
|
-
]
|
|
526
|
-
}),
|
|
527
|
-
_$1(0, inject(Logger))
|
|
528
|
-
], ListCommand);
|
|
529
|
-
|
|
530
|
-
class RunCommand extends TaskCommand {
|
|
531
|
-
// Constructor
|
|
532
|
-
constructor(logger, taskExpression){
|
|
533
|
-
super();
|
|
534
|
-
this.logger = logger;
|
|
535
|
-
this.taskExpression = taskExpression;
|
|
536
|
-
}
|
|
537
|
-
// Methods
|
|
538
|
-
builder(parser) {
|
|
539
|
-
return this.addTaskOptions(parser).positional('expr', {
|
|
540
|
-
type: 'string',
|
|
541
|
-
demandOption: true,
|
|
542
|
-
desc: 'Script or task expression'
|
|
543
|
-
}).option('build-script', {
|
|
544
|
-
default: 'build',
|
|
545
|
-
desc: 'Script to use to build dependencies'
|
|
546
|
-
}).option('deps-mode', {
|
|
547
|
-
alias: 'd',
|
|
548
|
-
choice: [
|
|
549
|
-
'all',
|
|
550
|
-
'prod',
|
|
551
|
-
'none'
|
|
552
|
-
],
|
|
553
|
-
default: 'all',
|
|
554
|
-
desc: 'Dependency selection mode:\n' + ' - all = dependencies AND devDependencies\n' + ' - prod = dependencies\n' + ' - none = nothing'
|
|
555
|
-
})// Config
|
|
556
|
-
.strict(false).parserConfiguration({
|
|
557
|
-
'unknown-options-as-args': true
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
async *prepare(args) {
|
|
561
|
-
// Extract expression
|
|
562
|
-
const expr = args._.map((arg)=>arg.toString());
|
|
563
|
-
if (expr[0] === 'run') {
|
|
564
|
-
expr.splice(0, 1);
|
|
565
|
-
}
|
|
566
|
-
expr.unshift(args.expr);
|
|
567
|
-
// Parse task expression
|
|
568
|
-
try {
|
|
569
|
-
const tree = this.taskExpression.parse(expr.join(' '));
|
|
570
|
-
yield await this.taskExpression.buildTask(tree.roots[0], this.workspace, {
|
|
571
|
-
buildScript: args.buildScript,
|
|
572
|
-
buildDeps: args.depsMode
|
|
573
|
-
});
|
|
574
|
-
} catch (err) {
|
|
575
|
-
if (err instanceof TaskExpressionError) {
|
|
576
|
-
this.logger.error(err.message);
|
|
577
|
-
throw new ExitException(1);
|
|
578
|
-
}
|
|
579
|
-
if (err instanceof TaskSyntaxError) {
|
|
580
|
-
this.logger.error(`Syntax error in task expression: ${err.message}`);
|
|
581
|
-
throw new ExitException(1);
|
|
582
|
-
}
|
|
583
|
-
throw err;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
_([
|
|
588
|
-
LazyCurrentWorkspace()
|
|
589
|
-
], RunCommand.prototype, "workspace", void 0);
|
|
590
|
-
RunCommand = _([
|
|
591
|
-
Command({
|
|
592
|
-
command: 'run <expr>',
|
|
593
|
-
describe: 'Run a task expression in a workspace, after having built all its dependencies.',
|
|
594
|
-
middlewares: [
|
|
595
|
-
LoadProject,
|
|
596
|
-
LoadWorkspace
|
|
597
|
-
]
|
|
598
|
-
}),
|
|
599
|
-
_$1(0, inject(Logger)),
|
|
600
|
-
_$1(1, inject(TaskExpressionService))
|
|
601
|
-
], RunCommand);
|
|
602
|
-
|
|
603
|
-
class TreeCommand extends InkCommand {
|
|
604
|
-
// Methods
|
|
605
|
-
*render() {
|
|
606
|
-
yield /*#__PURE__*/ jsx(WorkspaceTree, {
|
|
607
|
-
workspace: this.workspace
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
_([
|
|
612
|
-
LazyCurrentWorkspace()
|
|
613
|
-
], TreeCommand.prototype, "workspace", void 0);
|
|
614
|
-
TreeCommand = _([
|
|
615
|
-
Command({
|
|
616
|
-
command: 'tree',
|
|
617
|
-
describe: 'Print workspace dependency tree',
|
|
618
|
-
middlewares: [
|
|
619
|
-
LoadProject,
|
|
620
|
-
LoadWorkspace
|
|
621
|
-
]
|
|
622
|
-
})
|
|
623
|
-
], TreeCommand);
|
|
624
|
-
|
|
625
|
-
class CorePlugin {
|
|
626
|
-
}
|
|
627
|
-
CorePlugin = _([
|
|
628
|
-
Plugin({
|
|
629
|
-
name: 'core',
|
|
630
|
-
commands: [
|
|
631
|
-
EachCommand,
|
|
632
|
-
ExecCommand,
|
|
633
|
-
GroupCommand,
|
|
634
|
-
ListCommand,
|
|
635
|
-
RunCommand,
|
|
636
|
-
TreeCommand
|
|
637
|
-
]
|
|
638
|
-
})
|
|
639
|
-
], CorePlugin);
|
|
640
|
-
|
|
641
|
-
export { CorePlugin };
|
|
642
|
-
//# sourceMappingURL=core.plugin-CxgfxFUI.js.map
|