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