hereya-cli 0.89.1 → 0.91.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.
- package/README.md +88 -75
- package/dist/backend/cloud/cloud-backend/apps-deploy.d.ts +69 -0
- package/dist/backend/cloud/cloud-backend/apps-deploy.js +94 -0
- package/dist/backend/cloud/cloud-backend/apps-versions.d.ts +69 -0
- package/dist/backend/cloud/cloud-backend/apps-versions.js +113 -0
- package/dist/backend/cloud/cloud-backend/executor-broker.d.ts +25 -0
- package/dist/backend/cloud/cloud-backend/executor-broker.js +38 -0
- package/dist/backend/cloud/cloud-backend/executor-jobs.d.ts +75 -0
- package/dist/backend/cloud/cloud-backend/executor-jobs.js +110 -0
- package/dist/backend/cloud/cloud-backend/misc.d.ts +5 -0
- package/dist/backend/cloud/cloud-backend/misc.js +78 -0
- package/dist/backend/cloud/cloud-backend/packages-publish.d.ts +3 -0
- package/dist/backend/cloud/cloud-backend/packages-publish.js +99 -0
- package/dist/backend/cloud/cloud-backend/packages-registry.d.ts +6 -0
- package/dist/backend/cloud/cloud-backend/packages-registry.js +146 -0
- package/dist/backend/cloud/cloud-backend/packages-workspace.d.ts +4 -0
- package/dist/backend/cloud/cloud-backend/packages-workspace.js +50 -0
- package/dist/backend/cloud/cloud-backend/projects.d.ts +7 -0
- package/dist/backend/cloud/cloud-backend/projects.js +122 -0
- package/dist/backend/cloud/cloud-backend/state.d.ts +6 -0
- package/dist/backend/cloud/cloud-backend/state.js +86 -0
- package/dist/backend/cloud/cloud-backend/utils.d.ts +55 -0
- package/dist/backend/cloud/cloud-backend/utils.js +56 -0
- package/dist/backend/cloud/cloud-backend/workspace-env.d.ts +5 -0
- package/dist/backend/cloud/cloud-backend/workspace-env.js +63 -0
- package/dist/backend/cloud/cloud-backend/workspaces.d.ts +7 -0
- package/dist/backend/cloud/cloud-backend/workspaces.js +124 -0
- package/dist/backend/cloud/cloud-backend.d.ts +59 -126
- package/dist/backend/cloud/cloud-backend.js +100 -1087
- package/dist/backend/cloud/cloud-backend.test.setup.d.ts +13 -0
- package/dist/backend/cloud/cloud-backend.test.setup.js +14 -0
- package/dist/backend/common.d.ts +2 -2
- package/dist/backend/local.setup.d.ts +10 -0
- package/dist/backend/local.setup.js +20 -0
- package/dist/commands/executor/start/index.d.ts +4 -11
- package/dist/commands/executor/start/index.js +118 -520
- package/dist/commands/workspace/executor/install/index.d.ts +3 -0
- package/dist/commands/workspace/executor/install/index.js +210 -76
- package/dist/commands/workspace/executor/uninstall/index.d.ts +1 -0
- package/dist/commands/workspace/executor/uninstall/index.js +30 -4
- package/dist/executor/local.d.ts +0 -1
- package/dist/executor/local.js +10 -62
- package/dist/executor/resolve-env.d.ts +88 -0
- package/dist/executor/resolve-env.js +77 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/infrastructure/index.d.ts +12 -16
- package/dist/infrastructure/index.js +18 -25
- package/dist/infrastructure/registry.d.ts +38 -0
- package/dist/infrastructure/registry.js +61 -0
- package/dist/lib/env/test.setup.d.ts +7 -0
- package/dist/lib/env/test.setup.js +18 -0
- package/dist/lib/executor-start/auth.d.ts +2 -0
- package/dist/lib/executor-start/auth.js +21 -0
- package/dist/lib/executor-start/execute-app-job.d.ts +13 -0
- package/dist/lib/executor-start/execute-app-job.js +146 -0
- package/dist/lib/executor-start/execute-deploy-job.d.ts +14 -0
- package/dist/lib/executor-start/execute-deploy-job.js +64 -0
- package/dist/lib/executor-start/execute-init-job.d.ts +14 -0
- package/dist/lib/executor-start/execute-init-job.js +135 -0
- package/dist/lib/executor-start/format.d.ts +13 -0
- package/dist/lib/executor-start/format.js +22 -0
- package/dist/lib/executor-start/job-dispatch.d.ts +15 -0
- package/dist/lib/executor-start/job-dispatch.js +89 -0
- package/dist/lib/package/index.d.ts +25 -25
- package/oclif.manifest.json +43 -3
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspaces look like `org/name`, which is not filesystem-safe. The
|
|
3
|
+
* write-side in `app deploy --local` (commands/app/deploy/index.ts) MUST use
|
|
4
|
+
* the same sanitization.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeWorkspaceForFilename(workspace: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Strip credentials from log strings before flushing them to the cloud.
|
|
9
|
+
* Removes:
|
|
10
|
+
* - any occurrence of the actual hereyaGitPassword value
|
|
11
|
+
* - userinfo from URLs (https://user:pass@host -> https://host)
|
|
12
|
+
*/
|
|
13
|
+
export declare function redactCredentials(str: string, password?: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspaces look like `org/name`, which is not filesystem-safe. The
|
|
3
|
+
* write-side in `app deploy --local` (commands/app/deploy/index.ts) MUST use
|
|
4
|
+
* the same sanitization.
|
|
5
|
+
*/
|
|
6
|
+
export function sanitizeWorkspaceForFilename(workspace) {
|
|
7
|
+
return workspace.replaceAll('/', '-');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Strip credentials from log strings before flushing them to the cloud.
|
|
11
|
+
* Removes:
|
|
12
|
+
* - any occurrence of the actual hereyaGitPassword value
|
|
13
|
+
* - userinfo from URLs (https://user:pass@host -> https://host)
|
|
14
|
+
*/
|
|
15
|
+
export function redactCredentials(str, password) {
|
|
16
|
+
let out = str;
|
|
17
|
+
if (password) {
|
|
18
|
+
out = out.split(password).join('[REDACTED]');
|
|
19
|
+
}
|
|
20
|
+
out = out.replaceAll(/(https?:\/\/|git:\/\/)([^/\s@]+@)/g, '$1');
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CloudBackend } from '../../backend/cloud/cloud-backend.js';
|
|
2
|
+
import { LocalExecutor } from '../../executor/local.js';
|
|
3
|
+
export interface JobDispatchHooks {
|
|
4
|
+
log(msg: string): void;
|
|
5
|
+
warn(msg: string): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Dispatches a single job to the right handler, with periodic log flushing
|
|
9
|
+
* and heartbeating to the cloud. Errors are caught and reported as failed jobs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchJob(job: {
|
|
12
|
+
id: string;
|
|
13
|
+
payload: any;
|
|
14
|
+
type: string;
|
|
15
|
+
}, executor: LocalExecutor, cloudBackend: CloudBackend, hooks: JobDispatchHooks): Promise<void>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { executeAppJob } from './execute-app-job.js';
|
|
2
|
+
import { executeDeployJob } from './execute-deploy-job.js';
|
|
3
|
+
import { executeInitJob } from './execute-init-job.js';
|
|
4
|
+
/**
|
|
5
|
+
* Dispatches a single job to the right handler, with periodic log flushing
|
|
6
|
+
* and heartbeating to the cloud. Errors are caught and reported as failed jobs.
|
|
7
|
+
*/
|
|
8
|
+
export async function dispatchJob(job, executor, cloudBackend, hooks) {
|
|
9
|
+
let logBuffer = '';
|
|
10
|
+
const logInterval = setInterval(async () => {
|
|
11
|
+
if (logBuffer) {
|
|
12
|
+
const logs = logBuffer;
|
|
13
|
+
logBuffer = '';
|
|
14
|
+
try {
|
|
15
|
+
await cloudBackend.updateExecutorJob({ jobId: job.id, logs });
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// log flush errors are non-fatal
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}, 10_000);
|
|
22
|
+
const heartbeatInterval = setInterval(async () => {
|
|
23
|
+
try {
|
|
24
|
+
await cloudBackend.updateExecutorJob({ jobId: job.id });
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// heartbeat errors are non-fatal
|
|
28
|
+
}
|
|
29
|
+
}, 30_000);
|
|
30
|
+
const logger = {
|
|
31
|
+
debug(msg) {
|
|
32
|
+
logBuffer += msg + '\n';
|
|
33
|
+
},
|
|
34
|
+
error(msg) {
|
|
35
|
+
logBuffer += msg + '\n';
|
|
36
|
+
},
|
|
37
|
+
info(msg) {
|
|
38
|
+
logBuffer += msg + '\n';
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const finalize = async (result, label) => {
|
|
42
|
+
clearInterval(logInterval);
|
|
43
|
+
clearInterval(heartbeatInterval);
|
|
44
|
+
await cloudBackend.updateExecutorJob({
|
|
45
|
+
jobId: job.id,
|
|
46
|
+
logs: logBuffer,
|
|
47
|
+
result,
|
|
48
|
+
status: result.success ? 'completed' : 'failed',
|
|
49
|
+
});
|
|
50
|
+
hooks.log(`Job ${job.id} ${result.success ? 'completed' : 'failed'}${label ? ` (${label})` : ''}`);
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
if (job.type === 'resolve-env') {
|
|
54
|
+
const resolved = await executor.resolveEnvValues(job.payload);
|
|
55
|
+
await finalize({ env: resolved, success: true }, 'resolve-env');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (job.type === 'deploy' || job.type === 'undeploy') {
|
|
59
|
+
const deployResult = await executeDeployJob(job, executor, cloudBackend, logger);
|
|
60
|
+
await finalize(deployResult, job.type);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (job.type === 'init') {
|
|
64
|
+
const initResult = await executeInitJob(job, executor, logger);
|
|
65
|
+
await finalize(initResult, 'init');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (job.type === 'app-deploy' || job.type === 'app-destroy') {
|
|
69
|
+
const appJobResult = await executeAppJob(job, cloudBackend, logger);
|
|
70
|
+
await finalize(appJobResult, job.type);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const result = job.type === 'provision'
|
|
74
|
+
? await executor.provision({ ...job.payload, logger })
|
|
75
|
+
: await executor.destroy({ ...job.payload, logger });
|
|
76
|
+
await finalize(result, '');
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
clearInterval(logInterval);
|
|
80
|
+
clearInterval(heartbeatInterval);
|
|
81
|
+
await cloudBackend.updateExecutorJob({
|
|
82
|
+
jobId: job.id,
|
|
83
|
+
logs: logBuffer + `\nError: ${error.message}\n`,
|
|
84
|
+
result: { reason: error.message, success: false },
|
|
85
|
+
status: 'failed',
|
|
86
|
+
});
|
|
87
|
+
hooks.warn(`Job ${job.id} failed: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -37,20 +37,20 @@ export declare const ParameterSpec: z.ZodEffects<z.ZodObject<{
|
|
|
37
37
|
description: z.ZodOptional<z.ZodString>;
|
|
38
38
|
mandatory: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
39
39
|
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
description?: string | undefined;
|
|
41
40
|
default?: string | undefined;
|
|
41
|
+
description?: string | undefined;
|
|
42
42
|
mandatory?: boolean | undefined;
|
|
43
43
|
}, {
|
|
44
|
-
description?: string | undefined;
|
|
45
44
|
default?: string | undefined;
|
|
45
|
+
description?: string | undefined;
|
|
46
46
|
mandatory?: boolean | undefined;
|
|
47
47
|
}>, {
|
|
48
|
-
description?: string | undefined;
|
|
49
48
|
default?: string | undefined;
|
|
49
|
+
description?: string | undefined;
|
|
50
50
|
mandatory?: boolean | undefined;
|
|
51
51
|
}, {
|
|
52
|
-
description?: string | undefined;
|
|
53
52
|
default?: string | undefined;
|
|
53
|
+
description?: string | undefined;
|
|
54
54
|
mandatory?: boolean | undefined;
|
|
55
55
|
}>;
|
|
56
56
|
export type IParameterSpec = z.infer<typeof ParameterSpec>;
|
|
@@ -79,42 +79,37 @@ export declare const PackageMetadata: z.ZodObject<{
|
|
|
79
79
|
description: z.ZodOptional<z.ZodString>;
|
|
80
80
|
mandatory: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
description?: string | undefined;
|
|
83
82
|
default?: string | undefined;
|
|
83
|
+
description?: string | undefined;
|
|
84
84
|
mandatory?: boolean | undefined;
|
|
85
85
|
}, {
|
|
86
|
-
description?: string | undefined;
|
|
87
86
|
default?: string | undefined;
|
|
87
|
+
description?: string | undefined;
|
|
88
88
|
mandatory?: boolean | undefined;
|
|
89
89
|
}>, {
|
|
90
|
-
description?: string | undefined;
|
|
91
90
|
default?: string | undefined;
|
|
91
|
+
description?: string | undefined;
|
|
92
92
|
mandatory?: boolean | undefined;
|
|
93
93
|
}, {
|
|
94
|
-
description?: string | undefined;
|
|
95
94
|
default?: string | undefined;
|
|
95
|
+
description?: string | undefined;
|
|
96
96
|
mandatory?: boolean | undefined;
|
|
97
97
|
}>>>, Record<string, {
|
|
98
|
-
description?: string | undefined;
|
|
99
98
|
default?: string | undefined;
|
|
99
|
+
description?: string | undefined;
|
|
100
100
|
mandatory?: boolean | undefined;
|
|
101
101
|
}> | undefined, Record<string, {
|
|
102
|
-
description?: string | undefined;
|
|
103
102
|
default?: string | undefined;
|
|
103
|
+
description?: string | undefined;
|
|
104
104
|
mandatory?: boolean | undefined;
|
|
105
105
|
}> | undefined>;
|
|
106
106
|
snakeCase: z.ZodOptional<z.ZodBoolean>;
|
|
107
107
|
}, "strip", z.ZodTypeAny, {
|
|
108
|
-
infra: InfrastructureType;
|
|
109
108
|
iac: IacType;
|
|
110
|
-
|
|
111
|
-
kind?: "
|
|
112
|
-
parameters?: Record<string, {
|
|
113
|
-
description?: string | undefined;
|
|
114
|
-
default?: string | undefined;
|
|
115
|
-
mandatory?: boolean | undefined;
|
|
116
|
-
}> | undefined;
|
|
109
|
+
infra: InfrastructureType;
|
|
110
|
+
kind?: "app" | "package" | undefined;
|
|
117
111
|
deploy?: boolean | undefined;
|
|
112
|
+
dependencies?: Record<string, string> | undefined;
|
|
118
113
|
devDeploy?: boolean | undefined;
|
|
119
114
|
inputs?: Record<string, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">> | undefined;
|
|
120
115
|
onDeploy?: {
|
|
@@ -123,18 +118,18 @@ export declare const PackageMetadata: z.ZodObject<{
|
|
|
123
118
|
} | undefined;
|
|
124
119
|
originalInfra?: InfrastructureType | undefined;
|
|
125
120
|
outputs?: Record<string, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">> | undefined;
|
|
126
|
-
snakeCase?: boolean | undefined;
|
|
127
|
-
}, {
|
|
128
|
-
infra: InfrastructureType;
|
|
129
|
-
iac: IacType;
|
|
130
|
-
dependencies?: Record<string, string> | undefined;
|
|
131
|
-
kind?: "package" | "app" | undefined;
|
|
132
121
|
parameters?: Record<string, {
|
|
133
|
-
description?: string | undefined;
|
|
134
122
|
default?: string | undefined;
|
|
123
|
+
description?: string | undefined;
|
|
135
124
|
mandatory?: boolean | undefined;
|
|
136
125
|
}> | undefined;
|
|
126
|
+
snakeCase?: boolean | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
iac: IacType;
|
|
129
|
+
infra: InfrastructureType;
|
|
130
|
+
kind?: "app" | "package" | undefined;
|
|
137
131
|
deploy?: boolean | undefined;
|
|
132
|
+
dependencies?: Record<string, string> | undefined;
|
|
138
133
|
devDeploy?: boolean | undefined;
|
|
139
134
|
inputs?: Record<string, z.objectInputType<{}, z.ZodTypeAny, "passthrough">> | undefined;
|
|
140
135
|
onDeploy?: {
|
|
@@ -143,6 +138,11 @@ export declare const PackageMetadata: z.ZodObject<{
|
|
|
143
138
|
} | undefined;
|
|
144
139
|
originalInfra?: InfrastructureType | undefined;
|
|
145
140
|
outputs?: Record<string, z.objectInputType<{}, z.ZodTypeAny, "passthrough">> | undefined;
|
|
141
|
+
parameters?: Record<string, {
|
|
142
|
+
default?: string | undefined;
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
mandatory?: boolean | undefined;
|
|
145
|
+
}> | undefined;
|
|
146
146
|
snakeCase?: boolean | undefined;
|
|
147
147
|
}>;
|
|
148
148
|
export type IPackageMetadata = z.infer<typeof PackageMetadata>;
|
package/oclif.manifest.json
CHANGED
|
@@ -2018,6 +2018,14 @@
|
|
|
2018
2018
|
"multiple": false,
|
|
2019
2019
|
"type": "option"
|
|
2020
2020
|
},
|
|
2021
|
+
"idleTimeout": {
|
|
2022
|
+
"char": "i",
|
|
2023
|
+
"description": "seconds idle before exit; omit to keep running indefinitely",
|
|
2024
|
+
"name": "idleTimeout",
|
|
2025
|
+
"hasDynamicHelp": false,
|
|
2026
|
+
"multiple": false,
|
|
2027
|
+
"type": "option"
|
|
2028
|
+
},
|
|
2021
2029
|
"workspace": {
|
|
2022
2030
|
"char": "w",
|
|
2023
2031
|
"description": "name of the workspace to poll jobs for",
|
|
@@ -3161,7 +3169,7 @@
|
|
|
3161
3169
|
"workspace:executor:install": {
|
|
3162
3170
|
"aliases": [],
|
|
3163
3171
|
"args": {},
|
|
3164
|
-
"description": "Install a remote executor into a workspace",
|
|
3172
|
+
"description": "Install a remote executor into a workspace.\n\nTwo modes are supported:\n - ephemeral (default): provisions hereya/aws-executor-broker (Lambda + on-demand EC2).\n - always-on: provisions hereya/remote-executor-aws (legacy always-on EC2).",
|
|
3165
3173
|
"flags": {
|
|
3166
3174
|
"debug": {
|
|
3167
3175
|
"description": "enable debug mode",
|
|
@@ -3176,6 +3184,26 @@
|
|
|
3176
3184
|
"allowNo": false,
|
|
3177
3185
|
"type": "boolean"
|
|
3178
3186
|
},
|
|
3187
|
+
"mode": {
|
|
3188
|
+
"description": "executor mode: ephemeral (Lambda + on-demand EC2) or always-on (legacy)",
|
|
3189
|
+
"name": "mode",
|
|
3190
|
+
"default": "ephemeral",
|
|
3191
|
+
"hasDynamicHelp": false,
|
|
3192
|
+
"multiple": false,
|
|
3193
|
+
"options": [
|
|
3194
|
+
"ephemeral",
|
|
3195
|
+
"always-on"
|
|
3196
|
+
],
|
|
3197
|
+
"type": "option"
|
|
3198
|
+
},
|
|
3199
|
+
"parameter": {
|
|
3200
|
+
"char": "p",
|
|
3201
|
+
"description": "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
|
|
3202
|
+
"name": "parameter",
|
|
3203
|
+
"hasDynamicHelp": false,
|
|
3204
|
+
"multiple": true,
|
|
3205
|
+
"type": "option"
|
|
3206
|
+
},
|
|
3179
3207
|
"workspace": {
|
|
3180
3208
|
"char": "w",
|
|
3181
3209
|
"description": "name of the workspace",
|
|
@@ -3240,7 +3268,7 @@
|
|
|
3240
3268
|
"workspace:executor:uninstall": {
|
|
3241
3269
|
"aliases": [],
|
|
3242
3270
|
"args": {},
|
|
3243
|
-
"description": "Uninstall the remote executor from a workspace",
|
|
3271
|
+
"description": "Uninstall the remote executor from a workspace.\n\nThe --mode flag must match the mode used at install time (default: ephemeral).",
|
|
3244
3272
|
"flags": {
|
|
3245
3273
|
"debug": {
|
|
3246
3274
|
"description": "enable debug mode",
|
|
@@ -3248,6 +3276,18 @@
|
|
|
3248
3276
|
"allowNo": false,
|
|
3249
3277
|
"type": "boolean"
|
|
3250
3278
|
},
|
|
3279
|
+
"mode": {
|
|
3280
|
+
"description": "executor mode used at install time",
|
|
3281
|
+
"name": "mode",
|
|
3282
|
+
"default": "ephemeral",
|
|
3283
|
+
"hasDynamicHelp": false,
|
|
3284
|
+
"multiple": false,
|
|
3285
|
+
"options": [
|
|
3286
|
+
"ephemeral",
|
|
3287
|
+
"always-on"
|
|
3288
|
+
],
|
|
3289
|
+
"type": "option"
|
|
3290
|
+
},
|
|
3251
3291
|
"workspace": {
|
|
3252
3292
|
"char": "w",
|
|
3253
3293
|
"description": "name of the workspace",
|
|
@@ -3277,5 +3317,5 @@
|
|
|
3277
3317
|
]
|
|
3278
3318
|
}
|
|
3279
3319
|
},
|
|
3280
|
-
"version": "0.
|
|
3320
|
+
"version": "0.91.0"
|
|
3281
3321
|
}
|