@enspirit/emb 0.13.1 → 0.13.2

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 CHANGED
@@ -14,7 +14,7 @@ $ npm install -g @enspirit/emb
14
14
  $ emb COMMAND
15
15
  running command...
16
16
  $ emb (--version)
17
- @enspirit/emb/0.13.1 darwin-x64 node-v22.18.0
17
+ @enspirit/emb/0.13.2 darwin-x64 node-v22.18.0
18
18
  $ emb --help [COMMAND]
19
19
  USAGE
20
20
  $ emb COMMAND
@@ -25,7 +25,7 @@ export default class RestartComand extends BaseCommand {
25
25
  const { monorepo } = getContext();
26
26
  const components = argv.length > 0
27
27
  ? argv.map((name) => monorepo.component(name))
28
- : monorepo.components;
28
+ : undefined;
29
29
  await monorepo.run(new ComposeRestartOperation(), {
30
30
  noDeps: flags['no-deps'],
31
31
  services: components?.map((c) => c.name),
@@ -21,7 +21,7 @@ export default class StartCommand extends BaseCommand {
21
21
  components =
22
22
  argv.length > 0
23
23
  ? argv.map((name) => monorepo.component(name))
24
- : monorepo.components;
24
+ : undefined;
25
25
  }
26
26
  await monorepo.run(new ComposeStartOperation(), {
27
27
  services: components?.map((c) => c.name),
@@ -12,6 +12,7 @@ export type TaskConfig = TaskConfig1 & {
12
12
  [k: string]: unknown;
13
13
  };
14
14
  pre?: QualifiedIdentifier[];
15
+ executors?: ("local" | "container")[];
15
16
  /**
16
17
  * Variables to pass onto the task
17
18
  */
@@ -137,6 +137,15 @@
137
137
  "$ref": "#/definitions/QualifiedIdentifier"
138
138
  }
139
139
  },
140
+ "executors": {
141
+ "type": "array",
142
+ "items": {
143
+ "anyOf": [
144
+ { "const": "local" },
145
+ { "const": "container" }
146
+ ]
147
+ }
148
+ },
140
149
  "vars": {
141
150
  "type": "object",
142
151
  "description": "Variables to pass onto the task",
@@ -22,4 +22,7 @@ export declare class RunTasksOperation implements IOperation<RunTasksOperationPa
22
22
  run(params: RunTasksOperationParams): Promise<Array<TaskInfo>>;
23
23
  protected runDocker(task: TaskWithScriptAndComponent, out?: Writable): Promise<void>;
24
24
  protected runLocal(task: TaskWithScript, out: Writable): Promise<import("stream").Readable>;
25
+ private defaultExecutorFor;
26
+ private ensureExecutorValid;
27
+ private availableExecutorsFor;
25
28
  }
@@ -12,7 +12,7 @@ export var ExecutorType;
12
12
  })(ExecutorType || (ExecutorType = {}));
13
13
  export class RunTasksOperation {
14
14
  async run(params) {
15
- const { monorepo, compose } = getContext();
15
+ const { monorepo } = getContext();
16
16
  const manager = monorepo.taskManager();
17
17
  // First ensure the selection is valid (user can use task IDs or names)
18
18
  const collection = new EMBCollection(monorepo.tasks, {
@@ -32,16 +32,8 @@ export class RunTasksOperation {
32
32
  return;
33
33
  }
34
34
  const vars = await monorepo.expand(task.vars || {});
35
- const executor = params.executor ??
36
- (task.component
37
- ? (await compose.isService(task.component))
38
- ? ExecutorType.container
39
- : ExecutorType.local
40
- : ExecutorType.local);
41
- if (executor === ExecutorType.container &&
42
- (!task.component || !compose.isService(task.component))) {
43
- throw new Error('Cannot use the container executor with this task');
44
- }
35
+ const executor = params.executor ?? (await this.defaultExecutorFor(task));
36
+ await this.ensureExecutorValid(executor, task);
45
37
  // Handle tasks that require confirmation
46
38
  if (task.confirm) {
47
39
  const expected = await monorepo.expand(task.confirm.expect || 'yes', vars);
@@ -67,7 +59,7 @@ export class RunTasksOperation {
67
59
  return this.runLocal(task, tee);
68
60
  }
69
61
  default: {
70
- throw new Error(`Unssuported executor type: ${executor}`);
62
+ throw new Error(`Unsuported executor type: ${executor}`);
71
63
  }
72
64
  }
73
65
  },
@@ -96,4 +88,26 @@ export class RunTasksOperation {
96
88
  env: await monorepo.expand(task.vars || {}),
97
89
  });
98
90
  }
91
+ async defaultExecutorFor(task) {
92
+ const available = await this.availableExecutorsFor(task);
93
+ if (available.length === 0) {
94
+ throw new Error('No available executor found for task');
95
+ }
96
+ return available[0];
97
+ }
98
+ async ensureExecutorValid(executor, task) {
99
+ const available = await this.availableExecutorsFor(task);
100
+ if (!available.includes(executor)) {
101
+ throw new Error(`Unsuported executor type: ${executor}`);
102
+ }
103
+ }
104
+ async availableExecutorsFor(task) {
105
+ const { compose } = getContext();
106
+ if (task.executors) {
107
+ return task.executors;
108
+ }
109
+ return task.component && (await compose.isService(task.component))
110
+ ? [ExecutorType.container, ExecutorType.local]
111
+ : [ExecutorType.local];
112
+ }
99
113
  }
@@ -777,6 +777,121 @@
777
777
  "push.js"
778
778
  ]
779
779
  },
780
+ "resources:build": {
781
+ "aliases": [],
782
+ "args": {
783
+ "component": {
784
+ "description": "List of resources to build (defaults to all)",
785
+ "name": "component",
786
+ "required": false
787
+ }
788
+ },
789
+ "description": "Build the resources of the monorepo",
790
+ "examples": [
791
+ "<%= config.bin %> <%= command.id %> build --flavor development"
792
+ ],
793
+ "flags": {
794
+ "json": {
795
+ "description": "Format output as json.",
796
+ "helpGroup": "GLOBAL",
797
+ "name": "json",
798
+ "allowNo": false,
799
+ "type": "boolean"
800
+ },
801
+ "verbose": {
802
+ "name": "verbose",
803
+ "allowNo": true,
804
+ "type": "boolean"
805
+ },
806
+ "flavor": {
807
+ "description": "Specify the flavor to use.",
808
+ "name": "flavor",
809
+ "required": false,
810
+ "hasDynamicHelp": false,
811
+ "multiple": false,
812
+ "type": "option"
813
+ },
814
+ "dry-run": {
815
+ "description": "Do not build the resources but only produce build meta information",
816
+ "name": "dry-run",
817
+ "required": false,
818
+ "allowNo": false,
819
+ "type": "boolean"
820
+ },
821
+ "force": {
822
+ "char": "f",
823
+ "description": "Bypass the cache and force the build",
824
+ "name": "force",
825
+ "required": false,
826
+ "allowNo": false,
827
+ "type": "boolean"
828
+ }
829
+ },
830
+ "hasDynamicHelp": false,
831
+ "hiddenAliases": [],
832
+ "id": "resources:build",
833
+ "pluginAlias": "@enspirit/emb",
834
+ "pluginName": "@enspirit/emb",
835
+ "pluginType": "core",
836
+ "strict": false,
837
+ "enableJsonFlag": true,
838
+ "isESM": true,
839
+ "relativePath": [
840
+ "dist",
841
+ "src",
842
+ "cli",
843
+ "commands",
844
+ "resources",
845
+ "build.js"
846
+ ]
847
+ },
848
+ "resources": {
849
+ "aliases": [],
850
+ "args": {},
851
+ "description": "List resources.",
852
+ "examples": [
853
+ "<%= config.bin %> <%= command.id %>"
854
+ ],
855
+ "flags": {
856
+ "json": {
857
+ "description": "Format output as json.",
858
+ "helpGroup": "GLOBAL",
859
+ "name": "json",
860
+ "allowNo": false,
861
+ "type": "boolean"
862
+ },
863
+ "verbose": {
864
+ "name": "verbose",
865
+ "allowNo": true,
866
+ "type": "boolean"
867
+ },
868
+ "flavor": {
869
+ "description": "Specify the flavor to use.",
870
+ "name": "flavor",
871
+ "required": false,
872
+ "hasDynamicHelp": false,
873
+ "multiple": false,
874
+ "type": "option"
875
+ }
876
+ },
877
+ "hasDynamicHelp": false,
878
+ "hiddenAliases": [],
879
+ "id": "resources",
880
+ "pluginAlias": "@enspirit/emb",
881
+ "pluginName": "@enspirit/emb",
882
+ "pluginType": "core",
883
+ "strict": true,
884
+ "enableJsonFlag": true,
885
+ "isESM": true,
886
+ "relativePath": [
887
+ "dist",
888
+ "src",
889
+ "cli",
890
+ "commands",
891
+ "resources",
892
+ "index.js"
893
+ ]
894
+ },
780
895
  "kubernetes:logs": {
781
896
  "aliases": [
782
897
  "logs"
@@ -999,121 +1114,6 @@
999
1114
  "shell.js"
1000
1115
  ]
1001
1116
  },
1002
- "resources:build": {
1003
- "aliases": [],
1004
- "args": {
1005
- "component": {
1006
- "description": "List of resources to build (defaults to all)",
1007
- "name": "component",
1008
- "required": false
1009
- }
1010
- },
1011
- "description": "Build the resources of the monorepo",
1012
- "examples": [
1013
- "<%= config.bin %> <%= command.id %> build --flavor development"
1014
- ],
1015
- "flags": {
1016
- "json": {
1017
- "description": "Format output as json.",
1018
- "helpGroup": "GLOBAL",
1019
- "name": "json",
1020
- "allowNo": false,
1021
- "type": "boolean"
1022
- },
1023
- "verbose": {
1024
- "name": "verbose",
1025
- "allowNo": true,
1026
- "type": "boolean"
1027
- },
1028
- "flavor": {
1029
- "description": "Specify the flavor to use.",
1030
- "name": "flavor",
1031
- "required": false,
1032
- "hasDynamicHelp": false,
1033
- "multiple": false,
1034
- "type": "option"
1035
- },
1036
- "dry-run": {
1037
- "description": "Do not build the resources but only produce build meta information",
1038
- "name": "dry-run",
1039
- "required": false,
1040
- "allowNo": false,
1041
- "type": "boolean"
1042
- },
1043
- "force": {
1044
- "char": "f",
1045
- "description": "Bypass the cache and force the build",
1046
- "name": "force",
1047
- "required": false,
1048
- "allowNo": false,
1049
- "type": "boolean"
1050
- }
1051
- },
1052
- "hasDynamicHelp": false,
1053
- "hiddenAliases": [],
1054
- "id": "resources:build",
1055
- "pluginAlias": "@enspirit/emb",
1056
- "pluginName": "@enspirit/emb",
1057
- "pluginType": "core",
1058
- "strict": false,
1059
- "enableJsonFlag": true,
1060
- "isESM": true,
1061
- "relativePath": [
1062
- "dist",
1063
- "src",
1064
- "cli",
1065
- "commands",
1066
- "resources",
1067
- "build.js"
1068
- ]
1069
- },
1070
- "resources": {
1071
- "aliases": [],
1072
- "args": {},
1073
- "description": "List resources.",
1074
- "examples": [
1075
- "<%= config.bin %> <%= command.id %>"
1076
- ],
1077
- "flags": {
1078
- "json": {
1079
- "description": "Format output as json.",
1080
- "helpGroup": "GLOBAL",
1081
- "name": "json",
1082
- "allowNo": false,
1083
- "type": "boolean"
1084
- },
1085
- "verbose": {
1086
- "name": "verbose",
1087
- "allowNo": true,
1088
- "type": "boolean"
1089
- },
1090
- "flavor": {
1091
- "description": "Specify the flavor to use.",
1092
- "name": "flavor",
1093
- "required": false,
1094
- "hasDynamicHelp": false,
1095
- "multiple": false,
1096
- "type": "option"
1097
- }
1098
- },
1099
- "hasDynamicHelp": false,
1100
- "hiddenAliases": [],
1101
- "id": "resources",
1102
- "pluginAlias": "@enspirit/emb",
1103
- "pluginName": "@enspirit/emb",
1104
- "pluginType": "core",
1105
- "strict": true,
1106
- "enableJsonFlag": true,
1107
- "isESM": true,
1108
- "relativePath": [
1109
- "dist",
1110
- "src",
1111
- "cli",
1112
- "commands",
1113
- "resources",
1114
- "index.js"
1115
- ]
1116
- },
1117
1117
  "tasks": {
1118
1118
  "aliases": [],
1119
1119
  "args": {},
@@ -1220,5 +1220,5 @@
1220
1220
  ]
1221
1221
  }
1222
1222
  },
1223
- "version": "0.13.1"
1223
+ "version": "0.13.2"
1224
1224
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@enspirit/emb",
3
3
  "type": "module",
4
- "version": "0.13.1",
4
+ "version": "0.13.2",
5
5
  "keywords": [
6
6
  "monorepo",
7
7
  "docker",