@enspirit/emb 0.13.0 → 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 +1 -1
- package/dist/src/cli/commands/kubernetes/shell.js +1 -19
- package/dist/src/cli/commands/restart.js +1 -1
- package/dist/src/cli/commands/start.js +1 -1
- package/dist/src/config/schema.d.ts +3 -2
- package/dist/src/config/schema.json +10 -1
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.d.ts +3 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +26 -12
- package/dist/src/utils/streams.d.ts +1 -0
- package/dist/src/utils/streams.js +17 -0
- package/oclif.manifest.json +106 -106
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,25 +2,7 @@ import { Exec } from '@kubernetes/client-node';
|
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
3
|
import { getContext, KubernetesCommand } from '../../index.js';
|
|
4
4
|
import { GetDeploymentPodsOperation } from '../../../kubernetes/operations/GetDeploymentPodsOperation.js';
|
|
5
|
-
|
|
6
|
-
const wasRaw = stdin.isRaw;
|
|
7
|
-
const { isTTY } = stdin;
|
|
8
|
-
if (isTTY) {
|
|
9
|
-
stdin.setRawMode?.(true);
|
|
10
|
-
stdin.resume();
|
|
11
|
-
// Do NOT set encoding; keep it binary so control chars pass through.
|
|
12
|
-
}
|
|
13
|
-
// Let the remote shell handle Ctrl+C. If you prefer local exit on ^C, uncomment:
|
|
14
|
-
// stdin.on('data', (buf) => { if (buf.equals(Buffer.from([3]))) process.exit(130); });
|
|
15
|
-
return () => {
|
|
16
|
-
if (isTTY) {
|
|
17
|
-
stdin.setRawMode?.(Boolean(wasRaw));
|
|
18
|
-
if (!wasRaw) {
|
|
19
|
-
stdin.pause();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
5
|
+
import { enableRawMode } from '../../../utils/streams.js';
|
|
24
6
|
export default class PodShellCommand extends KubernetesCommand {
|
|
25
7
|
static aliases = ['shell'];
|
|
26
8
|
static description = 'Get a shell on a deployed component.';
|
|
@@ -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
|
-
:
|
|
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
|
-
:
|
|
24
|
+
: undefined;
|
|
25
25
|
}
|
|
26
26
|
await monorepo.run(new ComposeStartOperation(), {
|
|
27
27
|
services: components?.map((c) => c.name),
|
|
@@ -11,7 +11,8 @@ export type TaskConfig = TaskConfig1 & {
|
|
|
11
11
|
options?: {
|
|
12
12
|
[k: string]: unknown;
|
|
13
13
|
};
|
|
14
|
-
pre?:
|
|
14
|
+
pre?: QualifiedIdentifier[];
|
|
15
|
+
executors?: ("local" | "container")[];
|
|
15
16
|
/**
|
|
16
17
|
* Variables to pass onto the task
|
|
17
18
|
*/
|
|
@@ -30,6 +31,7 @@ export type TaskConfig = TaskConfig1 & {
|
|
|
30
31
|
export type TaskConfig1 = {
|
|
31
32
|
[k: string]: unknown;
|
|
32
33
|
};
|
|
34
|
+
export type QualifiedIdentifier = string;
|
|
33
35
|
export type ResourceConfig = {
|
|
34
36
|
[k: string]: unknown;
|
|
35
37
|
} & {
|
|
@@ -37,7 +39,6 @@ export type ResourceConfig = {
|
|
|
37
39
|
params?: unknown;
|
|
38
40
|
dependencies?: QualifiedIdentifier[];
|
|
39
41
|
};
|
|
40
|
-
export type QualifiedIdentifier = string;
|
|
41
42
|
export type JsonPatchOperation = JsonPatchAddOperation | JsonPatchRemoveOperation | JsonPatchReplaceOperation | JsonPatchMoveOperation | JsonPatchCopyOperation;
|
|
42
43
|
export interface EMBConfig {
|
|
43
44
|
project: {
|
|
@@ -134,7 +134,16 @@
|
|
|
134
134
|
"pre": {
|
|
135
135
|
"type": "array",
|
|
136
136
|
"items": {
|
|
137
|
-
"$ref": "#/definitions/
|
|
137
|
+
"$ref": "#/definitions/QualifiedIdentifier"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"executors": {
|
|
141
|
+
"type": "array",
|
|
142
|
+
"items": {
|
|
143
|
+
"anyOf": [
|
|
144
|
+
{ "const": "local" },
|
|
145
|
+
{ "const": "container" }
|
|
146
|
+
]
|
|
138
147
|
}
|
|
139
148
|
},
|
|
140
149
|
"vars": {
|
|
@@ -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
|
|
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
|
-
|
|
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(`
|
|
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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function enableRawMode(stdin: NodeJS.ReadStream): () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function enableRawMode(stdin) {
|
|
2
|
+
const wasRaw = stdin.isRaw;
|
|
3
|
+
const { isTTY } = stdin;
|
|
4
|
+
if (isTTY) {
|
|
5
|
+
stdin.setRawMode?.(true);
|
|
6
|
+
stdin.resume();
|
|
7
|
+
// Do NOT set encoding; keep it binary so control chars pass through.
|
|
8
|
+
}
|
|
9
|
+
return () => {
|
|
10
|
+
if (isTTY) {
|
|
11
|
+
stdin.setRawMode?.(Boolean(wasRaw));
|
|
12
|
+
if (!wasRaw) {
|
|
13
|
+
stdin.pause();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -892,111 +892,6 @@
|
|
|
892
892
|
"index.js"
|
|
893
893
|
]
|
|
894
894
|
},
|
|
895
|
-
"tasks": {
|
|
896
|
-
"aliases": [],
|
|
897
|
-
"args": {},
|
|
898
|
-
"description": "List tasks.",
|
|
899
|
-
"examples": [
|
|
900
|
-
"<%= config.bin %> <%= command.id %>"
|
|
901
|
-
],
|
|
902
|
-
"flags": {
|
|
903
|
-
"json": {
|
|
904
|
-
"description": "Format output as json.",
|
|
905
|
-
"helpGroup": "GLOBAL",
|
|
906
|
-
"name": "json",
|
|
907
|
-
"allowNo": false,
|
|
908
|
-
"type": "boolean"
|
|
909
|
-
},
|
|
910
|
-
"verbose": {
|
|
911
|
-
"name": "verbose",
|
|
912
|
-
"allowNo": true,
|
|
913
|
-
"type": "boolean"
|
|
914
|
-
}
|
|
915
|
-
},
|
|
916
|
-
"hasDynamicHelp": false,
|
|
917
|
-
"hiddenAliases": [],
|
|
918
|
-
"id": "tasks",
|
|
919
|
-
"pluginAlias": "@enspirit/emb",
|
|
920
|
-
"pluginName": "@enspirit/emb",
|
|
921
|
-
"pluginType": "core",
|
|
922
|
-
"strict": true,
|
|
923
|
-
"enableJsonFlag": true,
|
|
924
|
-
"isESM": true,
|
|
925
|
-
"relativePath": [
|
|
926
|
-
"dist",
|
|
927
|
-
"src",
|
|
928
|
-
"cli",
|
|
929
|
-
"commands",
|
|
930
|
-
"tasks",
|
|
931
|
-
"index.js"
|
|
932
|
-
]
|
|
933
|
-
},
|
|
934
|
-
"tasks:run": {
|
|
935
|
-
"aliases": [
|
|
936
|
-
"run"
|
|
937
|
-
],
|
|
938
|
-
"args": {
|
|
939
|
-
"task": {
|
|
940
|
-
"description": "List of tasks to run. You can provide either ids or names (eg: component:task or task)",
|
|
941
|
-
"name": "task",
|
|
942
|
-
"required": true
|
|
943
|
-
}
|
|
944
|
-
},
|
|
945
|
-
"description": "Run tasks.",
|
|
946
|
-
"examples": [
|
|
947
|
-
"<%= config.bin %> <%= command.id %>"
|
|
948
|
-
],
|
|
949
|
-
"flags": {
|
|
950
|
-
"json": {
|
|
951
|
-
"description": "Format output as json.",
|
|
952
|
-
"helpGroup": "GLOBAL",
|
|
953
|
-
"name": "json",
|
|
954
|
-
"allowNo": false,
|
|
955
|
-
"type": "boolean"
|
|
956
|
-
},
|
|
957
|
-
"verbose": {
|
|
958
|
-
"name": "verbose",
|
|
959
|
-
"allowNo": true,
|
|
960
|
-
"type": "boolean"
|
|
961
|
-
},
|
|
962
|
-
"executor": {
|
|
963
|
-
"char": "x",
|
|
964
|
-
"description": "Where to run the task. (experimental!)",
|
|
965
|
-
"name": "executor",
|
|
966
|
-
"hasDynamicHelp": false,
|
|
967
|
-
"multiple": false,
|
|
968
|
-
"options": [
|
|
969
|
-
"container",
|
|
970
|
-
"local"
|
|
971
|
-
],
|
|
972
|
-
"type": "option"
|
|
973
|
-
},
|
|
974
|
-
"all-matching": {
|
|
975
|
-
"char": "a",
|
|
976
|
-
"description": "Run all tasks matching (when multiple matches)",
|
|
977
|
-
"name": "all-matching",
|
|
978
|
-
"allowNo": false,
|
|
979
|
-
"type": "boolean"
|
|
980
|
-
}
|
|
981
|
-
},
|
|
982
|
-
"hasDynamicHelp": false,
|
|
983
|
-
"hiddenAliases": [],
|
|
984
|
-
"id": "tasks:run",
|
|
985
|
-
"pluginAlias": "@enspirit/emb",
|
|
986
|
-
"pluginName": "@enspirit/emb",
|
|
987
|
-
"pluginType": "core",
|
|
988
|
-
"strict": false,
|
|
989
|
-
"enableJsonFlag": true,
|
|
990
|
-
"isESM": true,
|
|
991
|
-
"relativePath": [
|
|
992
|
-
"dist",
|
|
993
|
-
"src",
|
|
994
|
-
"cli",
|
|
995
|
-
"commands",
|
|
996
|
-
"tasks",
|
|
997
|
-
"run.js"
|
|
998
|
-
]
|
|
999
|
-
},
|
|
1000
895
|
"kubernetes:logs": {
|
|
1001
896
|
"aliases": [
|
|
1002
897
|
"logs"
|
|
@@ -1218,7 +1113,112 @@
|
|
|
1218
1113
|
"kubernetes",
|
|
1219
1114
|
"shell.js"
|
|
1220
1115
|
]
|
|
1116
|
+
},
|
|
1117
|
+
"tasks": {
|
|
1118
|
+
"aliases": [],
|
|
1119
|
+
"args": {},
|
|
1120
|
+
"description": "List tasks.",
|
|
1121
|
+
"examples": [
|
|
1122
|
+
"<%= config.bin %> <%= command.id %>"
|
|
1123
|
+
],
|
|
1124
|
+
"flags": {
|
|
1125
|
+
"json": {
|
|
1126
|
+
"description": "Format output as json.",
|
|
1127
|
+
"helpGroup": "GLOBAL",
|
|
1128
|
+
"name": "json",
|
|
1129
|
+
"allowNo": false,
|
|
1130
|
+
"type": "boolean"
|
|
1131
|
+
},
|
|
1132
|
+
"verbose": {
|
|
1133
|
+
"name": "verbose",
|
|
1134
|
+
"allowNo": true,
|
|
1135
|
+
"type": "boolean"
|
|
1136
|
+
}
|
|
1137
|
+
},
|
|
1138
|
+
"hasDynamicHelp": false,
|
|
1139
|
+
"hiddenAliases": [],
|
|
1140
|
+
"id": "tasks",
|
|
1141
|
+
"pluginAlias": "@enspirit/emb",
|
|
1142
|
+
"pluginName": "@enspirit/emb",
|
|
1143
|
+
"pluginType": "core",
|
|
1144
|
+
"strict": true,
|
|
1145
|
+
"enableJsonFlag": true,
|
|
1146
|
+
"isESM": true,
|
|
1147
|
+
"relativePath": [
|
|
1148
|
+
"dist",
|
|
1149
|
+
"src",
|
|
1150
|
+
"cli",
|
|
1151
|
+
"commands",
|
|
1152
|
+
"tasks",
|
|
1153
|
+
"index.js"
|
|
1154
|
+
]
|
|
1155
|
+
},
|
|
1156
|
+
"tasks:run": {
|
|
1157
|
+
"aliases": [
|
|
1158
|
+
"run"
|
|
1159
|
+
],
|
|
1160
|
+
"args": {
|
|
1161
|
+
"task": {
|
|
1162
|
+
"description": "List of tasks to run. You can provide either ids or names (eg: component:task or task)",
|
|
1163
|
+
"name": "task",
|
|
1164
|
+
"required": true
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
"description": "Run tasks.",
|
|
1168
|
+
"examples": [
|
|
1169
|
+
"<%= config.bin %> <%= command.id %>"
|
|
1170
|
+
],
|
|
1171
|
+
"flags": {
|
|
1172
|
+
"json": {
|
|
1173
|
+
"description": "Format output as json.",
|
|
1174
|
+
"helpGroup": "GLOBAL",
|
|
1175
|
+
"name": "json",
|
|
1176
|
+
"allowNo": false,
|
|
1177
|
+
"type": "boolean"
|
|
1178
|
+
},
|
|
1179
|
+
"verbose": {
|
|
1180
|
+
"name": "verbose",
|
|
1181
|
+
"allowNo": true,
|
|
1182
|
+
"type": "boolean"
|
|
1183
|
+
},
|
|
1184
|
+
"executor": {
|
|
1185
|
+
"char": "x",
|
|
1186
|
+
"description": "Where to run the task. (experimental!)",
|
|
1187
|
+
"name": "executor",
|
|
1188
|
+
"hasDynamicHelp": false,
|
|
1189
|
+
"multiple": false,
|
|
1190
|
+
"options": [
|
|
1191
|
+
"container",
|
|
1192
|
+
"local"
|
|
1193
|
+
],
|
|
1194
|
+
"type": "option"
|
|
1195
|
+
},
|
|
1196
|
+
"all-matching": {
|
|
1197
|
+
"char": "a",
|
|
1198
|
+
"description": "Run all tasks matching (when multiple matches)",
|
|
1199
|
+
"name": "all-matching",
|
|
1200
|
+
"allowNo": false,
|
|
1201
|
+
"type": "boolean"
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
"hasDynamicHelp": false,
|
|
1205
|
+
"hiddenAliases": [],
|
|
1206
|
+
"id": "tasks:run",
|
|
1207
|
+
"pluginAlias": "@enspirit/emb",
|
|
1208
|
+
"pluginName": "@enspirit/emb",
|
|
1209
|
+
"pluginType": "core",
|
|
1210
|
+
"strict": false,
|
|
1211
|
+
"enableJsonFlag": true,
|
|
1212
|
+
"isESM": true,
|
|
1213
|
+
"relativePath": [
|
|
1214
|
+
"dist",
|
|
1215
|
+
"src",
|
|
1216
|
+
"cli",
|
|
1217
|
+
"commands",
|
|
1218
|
+
"tasks",
|
|
1219
|
+
"run.js"
|
|
1220
|
+
]
|
|
1221
1221
|
}
|
|
1222
1222
|
},
|
|
1223
|
-
"version": "0.13.
|
|
1223
|
+
"version": "0.13.2"
|
|
1224
1224
|
}
|