@jujulego/jill 2.4.0-alpha.5 → 2.4.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 (37) hide show
  1. package/README.md +8 -11
  2. package/dist/commands/each.d.ts +9 -6
  3. package/dist/commands/group.d.ts +2 -2
  4. package/dist/commands/run.d.ts +6 -4
  5. package/dist/{core.plugin-ED-2XO_T.js → core.plugin-eIXhcLId.js} +119 -148
  6. package/dist/core.plugin-eIXhcLId.js.map +1 -0
  7. package/dist/filters/scripts.filter.d.ts +2 -1
  8. package/dist/index.d.ts +1 -5
  9. package/dist/index.js +8 -6
  10. package/dist/index.js.map +1 -1
  11. package/dist/{ink-command-HSaTNbaX.js → ink-command-8BDSCbqp.js} +30 -190
  12. package/dist/ink-command-8BDSCbqp.js.map +1 -0
  13. package/dist/jill.application-8LJ2a7MD.js +636 -0
  14. package/dist/jill.application-8LJ2a7MD.js.map +1 -0
  15. package/dist/main.js +10 -8
  16. package/dist/main.js.map +1 -1
  17. package/dist/tasks/errors.d.ts +4 -0
  18. package/dist/tasks/{task-expr.service.d.ts → task-expression.service.d.ts} +2 -1
  19. package/dist/tsconfig.build.tsbuildinfo +1 -1
  20. package/dist/ui/hooks/useFlatTaskTree.d.ts +14 -0
  21. package/dist/ui/hooks/useIsVerbose.d.ts +1 -0
  22. package/dist/ui/hooks/useStdoutDimensions.d.ts +4 -0
  23. package/dist/ui/task-tree-completed.d.ts +5 -0
  24. package/dist/ui/task-tree-full-spinner.d.ts +5 -0
  25. package/dist/ui/task-tree-scrollable-spinner.d.ts +5 -0
  26. package/dist/ui/task-tree-spinner.d.ts +5 -0
  27. package/dist/ui/task-tree-stats.d.ts +5 -0
  28. package/dist/{workspace-tree-DEg4wm69.js → workspace-tree-1zFRh2Fq.js} +86 -128
  29. package/dist/workspace-tree-1zFRh2Fq.js.map +1 -0
  30. package/package.json +17 -15
  31. package/dist/core.plugin-ED-2XO_T.js.map +0 -1
  32. package/dist/ink-command-HSaTNbaX.js.map +0 -1
  33. package/dist/jill.application-nR6EmV7y.js +0 -279
  34. package/dist/jill.application-nR6EmV7y.js.map +0 -1
  35. package/dist/ui/group-task-spinner.d.ts +0 -5
  36. package/dist/ui/task-manager-spinner.d.ts +0 -5
  37. package/dist/workspace-tree-DEg4wm69.js.map +0 -1
package/README.md CHANGED
@@ -11,9 +11,9 @@ Zero-config monorepo cli
11
11
  Jill uses the `workspaces` attribute of your root package.json manifest to build your workspaces dependency tree.
12
12
  That done it can offer you various utilities:
13
13
  - `jill list` prints a list of all your workspaces, with many useful filters
14
- - `jill run` build all workspace's local dependencies before run a given script
15
- - `jill each` do the same as `run` but for a list of workspaces, optimizing builds.<br />
16
- Supports the same filters as `list`.
14
+ - `jill run` Run a task expression in a workspace, after having built all its dependencies.
15
+ - `jill group` Deprecated in favor of run
16
+ - `jill each` Run a task expression in many workspace, after having built all theirs dependencies.
17
17
  - `jill tree` prints current workspace's local dependency tree
18
18
 
19
19
  It supports both `npm` and `yarn`.
@@ -24,10 +24,7 @@ Jill will run hook script like npm do, for both npm and yarn. As npm, when you t
24
24
 
25
25
  This feature can be disabled using the `--no-hooks` option: `jill run --no-hooks test`.
26
26
 
27
- ### Experimental features
28
- - `jill group` same as `run` but allows to run multiple scripts in sequence or in parallel using the task syntax
29
-
30
- #### Task syntax _(only supported by `jill group` command yet)_
27
+ #### Task expression syntax
31
28
  Allows to instruct multiple tasks with the given orchestration. The orchestration is given by the following operators:
32
29
  - `&&` in sequence
33
30
  - `||` fallbacks
@@ -36,22 +33,22 @@ Allows to instruct multiple tasks with the given orchestration. The orchestratio
36
33
  ##### Examples:
37
34
  - This will run scripts **taskA**, **taskB** and **taskC** in order, one after another.
38
35
  ```shell
39
- jill group 'taskA && taskB && taskC'
36
+ jill run 'taskA && taskB && taskC'
40
37
  ```
41
38
 
42
39
  - This will run first **taskA**, if it fails it will run **taskB**, then **taskC** in order, until one succeed.
43
40
  ```shell
44
- jill group 'taskA || taskB || taskC'
41
+ jill run 'taskA || taskB || taskC'
45
42
  ```
46
43
 
47
44
  - This will run scripts **taskA**, **taskB** and **taskC** in parallel.
48
45
  ```shell
49
- jill group 'taskA // taskB // taskC'
46
+ jill run 'taskA // taskB // taskC'
50
47
  ```
51
48
 
52
49
  - And you can create more complex flows: this will run **taskA** and **taskB** in parallel, and then **taskC** when both tasks are ended
53
50
  ```shell
54
- jill group '(taskA // taskB) && taskC'
51
+ jill run '(taskA // taskB) && taskC'
55
52
  ```
56
53
 
57
54
  ## Installation
@@ -3,8 +3,9 @@ import { type ArgumentsCamelCase, type Argv } from 'yargs';
3
3
  import { TaskCommand } from '@/src/modules/task-command.tsx';
4
4
  import { type Project } from '@/src/project/project.ts';
5
5
  import { type WorkspaceDepsMode } from '@/src/project/workspace.ts';
6
- export interface IEachCommandArgs {
7
- script: string;
6
+ import { TaskExpressionService } from '@/src/tasks/task-expression.service.ts';
7
+ export interface EachCommandArgs {
8
+ expr: string;
8
9
  'build-script': string;
9
10
  'deps-mode': WorkspaceDepsMode;
10
11
  'allow-no-workspaces'?: boolean;
@@ -13,10 +14,12 @@ export interface IEachCommandArgs {
13
14
  'affected-rev-fallback': string;
14
15
  'affected-rev-sort'?: string;
15
16
  }
16
- export declare class EachCommand extends TaskCommand<IEachCommandArgs> {
17
+ export declare class EachCommand extends TaskCommand<EachCommandArgs> {
17
18
  private readonly logger;
19
+ private readonly taskExpression;
18
20
  readonly project: Project;
19
- constructor(logger: Logger);
20
- builder(parser: Argv): Argv<IEachCommandArgs>;
21
- prepare(args: ArgumentsCamelCase<IEachCommandArgs>): AsyncGenerator<import("../index.ts").ScriptTask, void, unknown>;
21
+ constructor(logger: Logger, taskExpression: TaskExpressionService);
22
+ builder(parser: Argv): Argv<EachCommandArgs>;
23
+ prepare(argv: ArgumentsCamelCase<EachCommandArgs>): AsyncGenerator<import("@jujulego/tasks").Task<import("@jujulego/tasks").TaskContext>, void, unknown>;
24
+ private _preparePipeline;
22
25
  }
@@ -1,7 +1,7 @@
1
1
  import { type ArgumentsCamelCase, type Argv } from 'yargs';
2
2
  import { TaskCommand } from '@/src/modules/task-command.tsx';
3
3
  import { type Workspace, type WorkspaceDepsMode } from '@/src/project/workspace.ts';
4
- import { TaskExprService, type TaskTree } from '@/src/tasks/task-expr.service.ts';
4
+ import { TaskExpressionService, type TaskTree } from '@/src/tasks/task-expression.service.ts';
5
5
  export interface IGroupCommandArgs {
6
6
  script: TaskTree;
7
7
  'build-script': string;
@@ -10,7 +10,7 @@ export interface IGroupCommandArgs {
10
10
  export declare class GroupCommand extends TaskCommand<IGroupCommandArgs> {
11
11
  private readonly taskExpr;
12
12
  readonly workspace: Workspace;
13
- constructor(taskExpr: TaskExprService);
13
+ constructor(taskExpr: TaskExpressionService);
14
14
  builder(parser: Argv): Argv<IGroupCommandArgs>;
15
15
  prepare(args: ArgumentsCamelCase<IGroupCommandArgs>): AsyncGenerator<import("@jujulego/tasks").Task<import("@jujulego/tasks").TaskContext>, void, unknown>;
16
16
  }
@@ -2,21 +2,23 @@ import { Logger } from '@jujulego/logger';
2
2
  import { type ArgumentsCamelCase, type Argv } from 'yargs';
3
3
  import { TaskCommand } from '@/src/modules/task-command.tsx';
4
4
  import { type Workspace, type WorkspaceDepsMode } from '@/src/project/workspace.ts';
5
+ import { TaskExpressionService } from '@/src/tasks/task-expression.service.ts';
5
6
  export interface IRunCommandArgs {
6
- script: string;
7
+ expr: string;
7
8
  'build-script': string;
8
9
  'deps-mode': WorkspaceDepsMode;
9
10
  }
10
11
  export declare class RunCommand extends TaskCommand<IRunCommandArgs> {
11
12
  private readonly logger;
13
+ private readonly taskExpression;
12
14
  readonly workspace: Workspace;
13
- constructor(logger: Logger);
15
+ constructor(logger: Logger, taskExpression: TaskExpressionService);
14
16
  builder(parser: Argv): Argv<import("@/src/modules/task-command.tsx").ITaskCommandArgs & {
15
- script: string;
17
+ expr: string;
16
18
  } & {
17
19
  "build-script": string;
18
20
  } & {
19
21
  "deps-mode": "all";
20
22
  }>;
21
- prepare(args: ArgumentsCamelCase<IRunCommandArgs>): AsyncGenerator<import("../index.ts").ScriptTask, void, unknown>;
23
+ prepare(args: ArgumentsCamelCase<IRunCommandArgs>): AsyncGenerator<import("@jujulego/tasks").Task<import("@jujulego/tasks").TaskContext>, void, unknown>;
22
24
  }
@@ -1,9 +1,11 @@
1
+ import { _ } from '@swc/helpers/_/_ts_decorate';
2
+ import { _ as _$1 } from '@swc/helpers/_/_ts_param';
1
3
  import { Logger } from '@jujulego/logger';
2
4
  import { inject } from 'inversify';
3
5
  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-DEg4wm69.js';
5
- import { h as Command, E as ExitException, I as InkCommand, z as printJson, a as List } from './ink-command-HSaTNbaX.js';
6
- import { T as TaskCommand } from './jill.application-nR6EmV7y.js';
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-1zFRh2Fq.js';
7
+ import { f as Command, E as ExitException, I as InkCommand, y as printJson, a as List } from './ink-command-8BDSCbqp.js';
8
+ import { T as TaskCommand } from './jill.application-8LJ2a7MD.js';
7
9
  import { jsx } from 'react/jsx-runtime';
8
10
  import chalk from 'chalk';
9
11
  import path from 'node:path';
@@ -35,29 +37,20 @@ import '@jujulego/aegis';
35
37
  import '@jujulego/quick-tag';
36
38
  import 'chalk-template';
37
39
 
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 {
40
+ class EachCommand extends TaskCommand {
50
41
  // Constructor
51
- constructor(logger){
42
+ constructor(logger, taskExpression){
52
43
  super();
53
44
  this.logger = logger;
45
+ this.taskExpression = taskExpression;
54
46
  }
55
47
  // Methods
56
48
  builder(parser) {
57
49
  return this.addTaskOptions(parser)// Run options
58
- .positional("script", {
50
+ .positional("expr", {
59
51
  type: "string",
60
- demandOption: true
52
+ demandOption: true,
53
+ desc: "Script or task expression"
61
54
  }).option("build-script", {
62
55
  default: "build",
63
56
  desc: "Script to use to build dependencies"
@@ -73,7 +66,7 @@ let EachCommand = class EachCommand extends TaskCommand {
73
66
  }).option("allow-no-workspaces", {
74
67
  type: "boolean",
75
68
  default: false,
76
- desc: "Allow no matching workspaces. By default, jill will throw when no affected workspaces are found"
69
+ desc: "Allow no matching workspaces. Without it jill will exit with code 1 if no workspace matches"
77
70
  })// Filters
78
71
  .option("private", {
79
72
  type: "boolean",
@@ -99,64 +92,75 @@ let EachCommand = class EachCommand extends TaskCommand {
99
92
  "unknown-options-as-args": true
100
93
  });
101
94
  }
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
95
+ async *prepare(argv) {
120
96
  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;
97
+ try {
98
+ // Extract expression
99
+ const expr = argv._.map((arg)=>arg.toString());
100
+ if (expr[0] === "each") {
101
+ expr.splice(0, 1);
102
+ }
103
+ expr.unshift(argv.expr);
104
+ const tree = this.taskExpression.parse(expr.join(" "));
105
+ const scripts = Array.from(this.taskExpression.extractScripts(tree));
106
+ // Create script tasks
107
+ const pipeline = this._preparePipeline(argv, scripts);
108
+ for await (const wks of pipeline.filter(this.project.workspaces())){
109
+ const task = await this.taskExpression.buildTask(tree.roots[0], wks, {
110
+ buildScript: argv.buildScript,
111
+ buildDeps: argv.depsMode
112
+ });
113
+ if (task) {
114
+ yield task;
115
+ empty = false;
116
+ }
117
+ }
118
+ } catch (err) {
119
+ if (err instanceof TaskExpressionError) {
120
+ this.logger.error(err.message);
121
+ throw new ExitException(1);
122
+ }
123
+ if (err instanceof TaskSyntaxError) {
124
+ this.logger.error(`Syntax error in task expression: ${err.message}`);
125
+ throw new ExitException(1);
129
126
  }
127
+ throw err;
130
128
  }
131
129
  if (empty) {
132
130
  this.logger.error(`${symbols.error} No matching workspace found !`);
133
- if (args.allowNoWorkspaces === false) {
131
+ if (argv.allowNoWorkspaces === false) {
134
132
  throw new ExitException(1);
135
133
  }
136
134
  }
137
135
  }
138
- };
139
- _ts_decorate$6([
136
+ _preparePipeline(argv, scripts) {
137
+ const pipeline = new Pipeline();
138
+ pipeline.add(new ScriptsFilter(scripts, true));
139
+ if (argv.private !== undefined) {
140
+ pipeline.add(new PrivateFilter(argv.private));
141
+ }
142
+ if (argv.affected !== undefined) {
143
+ pipeline.add(new AffectedFilter(argv.affected, argv.affectedRevFallback, argv.affectedRevSort));
144
+ }
145
+ return pipeline;
146
+ }
147
+ }
148
+ _([
140
149
  LazyCurrentProject()
141
150
  ], EachCommand.prototype, "project", void 0);
142
- EachCommand = _ts_decorate$6([
151
+ EachCommand = _([
143
152
  Command({
144
- command: "each <script>",
145
- describe: "Run script on many workspaces",
153
+ command: "each <expr>",
154
+ describe: "Run a task expression in many workspace, after having built all theirs dependencies.",
146
155
  middlewares: [
147
156
  LoadProject
148
157
  ]
149
158
  }),
150
- _ts_param$3(0, inject(Logger))
159
+ _$1(0, inject(Logger)),
160
+ _$1(1, inject(TaskExpressionService))
151
161
  ], EachCommand);
152
162
 
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 {
163
+ class ExecCommand extends TaskCommand {
160
164
  // Methods
161
165
  builder(parser) {
162
166
  return this.addTaskOptions(parser).positional("command", {
@@ -193,11 +197,11 @@ let ExecCommand = class ExecCommand extends TaskCommand {
193
197
  });
194
198
  yield task;
195
199
  }
196
- };
197
- _ts_decorate$5([
200
+ }
201
+ _([
198
202
  LazyCurrentWorkspace()
199
203
  ], ExecCommand.prototype, "workspace", void 0);
200
- ExecCommand = _ts_decorate$5([
204
+ ExecCommand = _([
201
205
  Command({
202
206
  command: "exec <command>",
203
207
  aliases: [
@@ -211,18 +215,7 @@ ExecCommand = _ts_decorate$5([
211
215
  })
212
216
  ], ExecCommand);
213
217
 
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 {
218
+ class GroupCommand extends TaskCommand {
226
219
  // Constructor
227
220
  constructor(taskExpr){
228
221
  super();
@@ -256,33 +249,23 @@ let GroupCommand = class GroupCommand extends TaskCommand {
256
249
  });
257
250
  yield group;
258
251
  }
259
- };
260
- _ts_decorate$4([
252
+ }
253
+ _([
261
254
  LazyCurrentWorkspace()
262
255
  ], GroupCommand.prototype, "workspace", void 0);
263
- GroupCommand = _ts_decorate$4([
256
+ GroupCommand = _([
264
257
  Command({
265
258
  command: "group <script..>",
266
259
  describe: "Run many scripts inside a workspace (experimental)",
260
+ deprecated: true,
267
261
  middlewares: [
268
262
  LoadProject,
269
263
  LoadWorkspace
270
264
  ]
271
265
  }),
272
- _ts_param$2(0, inject(TaskExprService))
266
+ _$1(0, inject(TaskExpressionService))
273
267
  ], GroupCommand);
274
268
 
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
269
  // Constants
287
270
  const LONG_ATTRIBUTES = [
288
271
  "name",
@@ -320,7 +303,7 @@ function buildExtractor(attrs) {
320
303
  return data;
321
304
  };
322
305
  }
323
- let ListCommand = class ListCommand extends InkCommand {
306
+ class ListCommand extends InkCommand {
324
307
  // Constructor
325
308
  constructor(logger){
326
309
  super();
@@ -485,11 +468,11 @@ let ListCommand = class ListCommand extends InkCommand {
485
468
  return 0;
486
469
  };
487
470
  }
488
- };
489
- _ts_decorate$3([
471
+ }
472
+ _([
490
473
  LazyCurrentProject()
491
474
  ], ListCommand.prototype, "project", void 0);
492
- ListCommand = _ts_decorate$3([
475
+ ListCommand = _([
493
476
  Command({
494
477
  command: "list",
495
478
  aliases: [
@@ -500,31 +483,22 @@ ListCommand = _ts_decorate$3([
500
483
  LoadProject
501
484
  ]
502
485
  }),
503
- _ts_param$1(0, inject(Logger))
486
+ _$1(0, inject(Logger))
504
487
  ], ListCommand);
505
488
 
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 {
489
+ class RunCommand extends TaskCommand {
518
490
  // Constructor
519
- constructor(logger){
491
+ constructor(logger, taskExpression){
520
492
  super();
521
493
  this.logger = logger;
494
+ this.taskExpression = taskExpression;
522
495
  }
523
496
  // Methods
524
497
  builder(parser) {
525
- return this.addTaskOptions(parser).positional("script", {
498
+ return this.addTaskOptions(parser).positional("expr", {
526
499
  type: "string",
527
- demandOption: true
500
+ demandOption: true,
501
+ desc: "Script or task expression"
528
502
  }).option("build-script", {
529
503
  default: "build",
530
504
  desc: "Script to use to build dependencies"
@@ -543,57 +517,60 @@ let RunCommand = class RunCommand extends TaskCommand {
543
517
  });
544
518
  }
545
519
  async *prepare(args) {
546
- // Extract arguments
547
- const rest = args._.map((arg)=>arg.toString());
548
- if (rest[0] === "run") {
549
- rest.splice(0, 1);
520
+ // Extract expression
521
+ const expr = args._.map((arg)=>arg.toString());
522
+ if (expr[0] === "run") {
523
+ expr.splice(0, 1);
550
524
  }
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);
525
+ expr.unshift(args.expr);
526
+ // Parse task expression
527
+ try {
528
+ const tree = this.taskExpression.parse(expr.join(" "));
529
+ yield await this.taskExpression.buildTask(tree.roots[0], this.workspace, {
530
+ buildScript: args.buildScript,
531
+ buildDeps: args.depsMode
532
+ });
533
+ } catch (err) {
534
+ if (err instanceof TaskExpressionError) {
535
+ this.logger.error(err.message);
536
+ throw new ExitException(1);
537
+ }
538
+ if (err instanceof TaskSyntaxError) {
539
+ this.logger.error(`Syntax error in task expression: ${err.message}`);
540
+ throw new ExitException(1);
541
+ }
542
+ throw err;
561
543
  }
562
544
  }
563
- };
564
- _ts_decorate$2([
545
+ }
546
+ _([
565
547
  LazyCurrentWorkspace()
566
548
  ], RunCommand.prototype, "workspace", void 0);
567
- RunCommand = _ts_decorate$2([
549
+ RunCommand = _([
568
550
  Command({
569
- command: "run <script>",
570
- describe: "Run script inside workspace",
551
+ command: "run <expr>",
552
+ describe: "Run a task expression in a workspace, after having built all its dependencies.",
571
553
  middlewares: [
572
554
  LoadProject,
573
555
  LoadWorkspace
574
556
  ]
575
557
  }),
576
- _ts_param(0, inject(Logger))
558
+ _$1(0, inject(Logger)),
559
+ _$1(1, inject(TaskExpressionService))
577
560
  ], RunCommand);
578
561
 
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 {
562
+ class TreeCommand extends InkCommand {
586
563
  // Methods
587
564
  *render() {
588
565
  yield /*#__PURE__*/ jsx(WorkspaceTree, {
589
566
  workspace: this.workspace
590
567
  });
591
568
  }
592
- };
593
- _ts_decorate$1([
569
+ }
570
+ _([
594
571
  LazyCurrentWorkspace()
595
572
  ], TreeCommand.prototype, "workspace", void 0);
596
- TreeCommand = _ts_decorate$1([
573
+ TreeCommand = _([
597
574
  Command({
598
575
  command: "tree",
599
576
  describe: "Print workspace dependency tree",
@@ -604,15 +581,9 @@ TreeCommand = _ts_decorate$1([
604
581
  })
605
582
  ], TreeCommand);
606
583
 
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;
584
+ class CorePlugin {
612
585
  }
613
- let CorePlugin = class CorePlugin {
614
- };
615
- CorePlugin = _ts_decorate([
586
+ CorePlugin = _([
616
587
  Plugin({
617
588
  name: "core",
618
589
  commands: [
@@ -627,4 +598,4 @@ CorePlugin = _ts_decorate([
627
598
  ], CorePlugin);
628
599
 
629
600
  export { CorePlugin };
630
- //# sourceMappingURL=core.plugin-ED-2XO_T.js.map
601
+ //# sourceMappingURL=core.plugin-eIXhcLId.js.map