hereya-cli 0.34.0 → 0.36.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 +108 -23
- package/dist/backend/cloud/cloud-backend.d.ts +29 -0
- package/dist/backend/cloud/cloud-backend.js +379 -0
- package/dist/backend/cloud/login.d.ts +16 -0
- package/dist/backend/cloud/login.js +145 -0
- package/dist/backend/cloud/logout.d.ts +9 -0
- package/dist/backend/cloud/logout.js +12 -0
- package/dist/backend/cloud/utils.d.ts +3 -0
- package/dist/backend/cloud/utils.js +6 -0
- package/dist/backend/common.d.ts +21 -0
- package/dist/backend/config.d.ts +30 -3
- package/dist/backend/config.js +36 -2
- package/dist/backend/file.d.ts +3 -1
- package/dist/backend/file.js +14 -2
- package/dist/backend/index.d.ts +3 -1
- package/dist/backend/index.js +26 -3
- package/dist/backend/secrets.d.ts +5 -0
- package/dist/backend/secrets.js +66 -0
- package/dist/commands/config/export-backend/index.d.ts +9 -0
- package/dist/commands/config/export-backend/index.js +28 -0
- package/dist/commands/config/import-backend/index.d.ts +9 -0
- package/dist/commands/config/import-backend/index.js +25 -0
- package/dist/commands/init/index.js +1 -1
- package/dist/commands/login/index.d.ts +9 -0
- package/dist/commands/login/index.js +27 -0
- package/dist/commands/logout/index.d.ts +6 -0
- package/dist/commands/logout/index.js +23 -0
- package/dist/executor/local.js +3 -1
- package/dist/infrastructure/aws.js +2 -17
- package/oclif.manifest.json +119 -1
- package/package.json +5 -2
package/dist/backend/config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { load, save } from
|
|
4
|
-
import { BackendType } from
|
|
3
|
+
import { load, save } from '../lib/yaml-utils.js';
|
|
4
|
+
import { BackendType } from './index.js';
|
|
5
|
+
import { secretManager } from './secrets.js';
|
|
5
6
|
export async function getCurrentBackendType() {
|
|
6
7
|
const config = await loadBackendConfig();
|
|
7
8
|
return config.current;
|
|
@@ -18,6 +19,39 @@ export async function loadBackendConfig() {
|
|
|
18
19
|
}
|
|
19
20
|
return data;
|
|
20
21
|
}
|
|
22
|
+
export async function saveCloudCredentials(credentials) {
|
|
23
|
+
await secretManager.saveSecret(credentials.clientId, {
|
|
24
|
+
accessToken: credentials.accessToken,
|
|
25
|
+
refreshToken: credentials.refreshToken,
|
|
26
|
+
});
|
|
27
|
+
const config = await loadBackendConfig();
|
|
28
|
+
config.cloud = {
|
|
29
|
+
clientId: credentials.clientId,
|
|
30
|
+
url: credentials.url,
|
|
31
|
+
};
|
|
32
|
+
config.current = BackendType.Cloud;
|
|
33
|
+
await save(config, getBackendConfigPath());
|
|
34
|
+
}
|
|
35
|
+
export async function deleteCloudCredentials() {
|
|
36
|
+
const config = await loadBackendConfig();
|
|
37
|
+
const originalConfig = { ...config };
|
|
38
|
+
if (!config.cloud) {
|
|
39
|
+
return { didDelete: false, originalConfig, secret: null, success: true };
|
|
40
|
+
}
|
|
41
|
+
const secret = await secretManager.getSecret(config.cloud.clientId);
|
|
42
|
+
if (secret) {
|
|
43
|
+
await secretManager.deleteSecret(config.cloud.clientId);
|
|
44
|
+
}
|
|
45
|
+
config.cloud = undefined;
|
|
46
|
+
if (config.current === BackendType.Cloud) {
|
|
47
|
+
config.current = BackendType.Local;
|
|
48
|
+
}
|
|
49
|
+
await save(config, getBackendConfigPath());
|
|
50
|
+
return { didDelete: true, originalConfig, secret, success: true };
|
|
51
|
+
}
|
|
52
|
+
export async function getCloudCredentials(clientId) {
|
|
53
|
+
return secretManager.getSecret(clientId);
|
|
54
|
+
}
|
|
21
55
|
export function getBackendConfigPath() {
|
|
22
56
|
return path.join(os.homedir(), '.hereya', 'backend.yaml');
|
|
23
57
|
}
|
package/dist/backend/file.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from '../lib/config/common.js';
|
|
2
|
-
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput } from './common.js';
|
|
2
|
+
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, ExportBackendOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, ImportBackendInput, ImportBackendOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput } from './common.js';
|
|
3
3
|
import { FileStorage } from './file-storage/common.js';
|
|
4
4
|
export declare class FileBackend implements Backend {
|
|
5
5
|
private readonly fileStorage;
|
|
@@ -7,10 +7,12 @@ export declare class FileBackend implements Backend {
|
|
|
7
7
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
8
8
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
9
9
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
10
|
+
exportBackend(): Promise<ExportBackendOutput>;
|
|
10
11
|
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
|
11
12
|
getState(input: GetStateInput): Promise<GetStateOutput>;
|
|
12
13
|
getWorkspace(workspace: string): Promise<GetWorkspaceOutput>;
|
|
13
14
|
getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
|
|
15
|
+
importBackend(_: ImportBackendInput): Promise<ImportBackendOutput>;
|
|
14
16
|
init(options: InitProjectInput): Promise<InitProjectOutput>;
|
|
15
17
|
listWorkspaces(): Promise<string[]>;
|
|
16
18
|
removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
|
package/dist/backend/file.js
CHANGED
|
@@ -24,7 +24,7 @@ export class FileBackend {
|
|
|
24
24
|
const { workspace } = workspace$;
|
|
25
25
|
if (workspace.mirrorOf) {
|
|
26
26
|
return {
|
|
27
|
-
reason: `Cannot add package to
|
|
27
|
+
reason: `Cannot add package to mirroring workspace ${input.workspace}`,
|
|
28
28
|
success: false,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -154,6 +154,12 @@ export class FileBackend {
|
|
|
154
154
|
success: false,
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
+
async exportBackend() {
|
|
158
|
+
return {
|
|
159
|
+
reason: 'This backend does not support exporting',
|
|
160
|
+
success: false,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
157
163
|
async getProvisioningId(input) {
|
|
158
164
|
const idPaths = [`provisioning/${input.logicalId}.yaml`, `provisioning/${input.logicalId}.yml`];
|
|
159
165
|
const newId = `p-${randomUUID()}`;
|
|
@@ -285,6 +291,12 @@ export class FileBackend {
|
|
|
285
291
|
success: true,
|
|
286
292
|
};
|
|
287
293
|
}
|
|
294
|
+
async importBackend(_) {
|
|
295
|
+
return {
|
|
296
|
+
reason: 'This backend does not support importing',
|
|
297
|
+
success: false,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
288
300
|
async init(options) {
|
|
289
301
|
return {
|
|
290
302
|
project: {
|
|
@@ -372,7 +384,7 @@ export class FileBackend {
|
|
|
372
384
|
const { workspace } = workspace$;
|
|
373
385
|
workspace.env = {
|
|
374
386
|
...workspace.env,
|
|
375
|
-
[input.name]: input.value
|
|
387
|
+
[input.name]: `${input.infrastructure}:${input.value}`,
|
|
376
388
|
};
|
|
377
389
|
await this.saveWorkspace(workspace, input.workspace);
|
|
378
390
|
return {
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Backend } from './common.js';
|
|
2
|
-
export declare function getBackend(): Promise<Backend>;
|
|
2
|
+
export declare function getBackend(type?: BackendType): Promise<Backend>;
|
|
3
|
+
export declare function clearBackend(): void;
|
|
3
4
|
export declare function setBackendType(type: BackendType): void;
|
|
4
5
|
export declare enum BackendType {
|
|
6
|
+
Cloud = "cloud",
|
|
5
7
|
Local = "local",
|
|
6
8
|
S3 = "s3"
|
|
7
9
|
}
|
package/dist/backend/index.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { getAwsConfig } from '../infrastructure/aws-config.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CloudBackend } from './cloud/cloud-backend.js';
|
|
3
|
+
import { getCloudCredentials, loadBackendConfig } from './config.js';
|
|
3
4
|
import { LocalFileBackend } from './local.js';
|
|
4
5
|
import { S3FileBackend } from './s3.js';
|
|
5
6
|
let backend;
|
|
6
7
|
let currentBackendType;
|
|
7
|
-
export async function getBackend() {
|
|
8
|
+
export async function getBackend(type) {
|
|
8
9
|
if (backend) {
|
|
9
10
|
return backend;
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
+
const backendConfig = await loadBackendConfig();
|
|
13
|
+
const backendType = type ?? currentBackendType ?? backendConfig.current;
|
|
12
14
|
switch (backendType) {
|
|
15
|
+
case BackendType.Cloud: {
|
|
16
|
+
if (!backendConfig.cloud) {
|
|
17
|
+
throw new Error('Cloud credentials not found. Please run `hereya login` first.');
|
|
18
|
+
}
|
|
19
|
+
const credentials = await getCloudCredentials(backendConfig.cloud.clientId);
|
|
20
|
+
if (!credentials) {
|
|
21
|
+
throw new Error('Cloud credentials not found. Please run `hereya login` first.');
|
|
22
|
+
}
|
|
23
|
+
backend = new CloudBackend({
|
|
24
|
+
accessToken: credentials.accessToken,
|
|
25
|
+
clientId: backendConfig.cloud.clientId,
|
|
26
|
+
refreshToken: credentials.refreshToken,
|
|
27
|
+
url: backendConfig.cloud.url,
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
13
31
|
case BackendType.Local: {
|
|
14
32
|
backend = new LocalFileBackend();
|
|
15
33
|
break;
|
|
@@ -28,11 +46,16 @@ export async function getBackend() {
|
|
|
28
46
|
}
|
|
29
47
|
return backend;
|
|
30
48
|
}
|
|
49
|
+
export function clearBackend() {
|
|
50
|
+
backend = undefined;
|
|
51
|
+
currentBackendType = undefined;
|
|
52
|
+
}
|
|
31
53
|
export function setBackendType(type) {
|
|
32
54
|
currentBackendType = type;
|
|
33
55
|
}
|
|
34
56
|
export var BackendType;
|
|
35
57
|
(function (BackendType) {
|
|
58
|
+
BackendType["Cloud"] = "cloud";
|
|
36
59
|
BackendType["Local"] = "local";
|
|
37
60
|
BackendType["S3"] = "s3";
|
|
38
61
|
})(BackendType || (BackendType = {}));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
const SECRETS_DIR = path.join(os.homedir(), '.hereya', 'secrets');
|
|
5
|
+
async function ensureSecretsDir() {
|
|
6
|
+
try {
|
|
7
|
+
await fs.mkdir(SECRETS_DIR, { recursive: true });
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
// Ignore if directory already exists
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function getSecretPath(name) {
|
|
14
|
+
await ensureSecretsDir();
|
|
15
|
+
return path.join(SECRETS_DIR, `${name}.json`);
|
|
16
|
+
}
|
|
17
|
+
export const secretManager = {
|
|
18
|
+
async deleteSecret(name) {
|
|
19
|
+
try {
|
|
20
|
+
const keytar = await import('keytar').then((m) => m.default);
|
|
21
|
+
await keytar.deletePassword('hereya', name);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Fallback to file-based storage
|
|
25
|
+
const secretPath = await getSecretPath(name);
|
|
26
|
+
try {
|
|
27
|
+
await fs.unlink(secretPath);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Ignore if file doesn't exist
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
async getSecret(name) {
|
|
35
|
+
try {
|
|
36
|
+
const keytar = await import('keytar').then((m) => m.default);
|
|
37
|
+
const value = await keytar.getPassword('hereya', name);
|
|
38
|
+
if (!value) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return JSON.parse(value);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Fallback to file-based storage
|
|
45
|
+
const secretPath = await getSecretPath(name);
|
|
46
|
+
try {
|
|
47
|
+
const value = await fs.readFile(secretPath, 'utf8');
|
|
48
|
+
return JSON.parse(value);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async saveSecret(name, value) {
|
|
56
|
+
try {
|
|
57
|
+
const keytar = await import('keytar').then((m) => m.default);
|
|
58
|
+
await keytar.setPassword('hereya', name, JSON.stringify(value));
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Fallback to file-based storage
|
|
62
|
+
const secretPath = await getSecretPath(name);
|
|
63
|
+
await fs.writeFile(secretPath, JSON.stringify(value), 'utf8');
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ConfigExportBackend extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
file: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
|
+
import { writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { getBackend } from '../../../backend/index.js';
|
|
5
|
+
export default class ConfigExportBackend extends Command {
|
|
6
|
+
static args = {
|
|
7
|
+
file: Args.string({
|
|
8
|
+
description: 'Path to save the export file. Defaults to cloud-backend.json in current directory',
|
|
9
|
+
required: false,
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
static description = 'Export the cloud backend configuration to a file';
|
|
13
|
+
static examples = [
|
|
14
|
+
'<%= config.bin %> <%= command.id %>',
|
|
15
|
+
'<%= config.bin %> <%= command.id %> ./path/to/export.json',
|
|
16
|
+
];
|
|
17
|
+
async run() {
|
|
18
|
+
const { args } = await this.parse(ConfigExportBackend);
|
|
19
|
+
const backend = await getBackend();
|
|
20
|
+
const result = await backend.exportBackend();
|
|
21
|
+
if (!result.success) {
|
|
22
|
+
this.error(`Failed to export backend: ${result.reason}`);
|
|
23
|
+
}
|
|
24
|
+
const filePath = args.file ?? join(process.cwd(), 'cloud-backend.json');
|
|
25
|
+
await writeFile(filePath, result.data);
|
|
26
|
+
this.log(`Backend configuration exported to ${filePath}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ConfigImportBackend extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { getBackend } from '../../../backend/index.js';
|
|
4
|
+
export default class ConfigImportBackend extends Command {
|
|
5
|
+
static args = {
|
|
6
|
+
file: Args.string({
|
|
7
|
+
description: 'Path to the file containing the backend configuration to import',
|
|
8
|
+
required: true,
|
|
9
|
+
}),
|
|
10
|
+
};
|
|
11
|
+
static description = 'Import a backend configuration from a file';
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> <%= command.id %> ./path/to/cloud-backend.json',
|
|
14
|
+
];
|
|
15
|
+
async run() {
|
|
16
|
+
const { args } = await this.parse(ConfigImportBackend);
|
|
17
|
+
const backend = await getBackend();
|
|
18
|
+
const fileContent = await readFile(args.file, 'utf8');
|
|
19
|
+
const result = await backend.importBackend({ data: fileContent });
|
|
20
|
+
if (!result.success) {
|
|
21
|
+
this.error(`Failed to import backend: ${result.reason}`);
|
|
22
|
+
}
|
|
23
|
+
this.log('Backend configuration imported successfully');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -36,7 +36,7 @@ export default class Init extends Command {
|
|
|
36
36
|
workspace: flags.workspace,
|
|
37
37
|
});
|
|
38
38
|
const content = {
|
|
39
|
-
project: initProjectOutput.project.
|
|
39
|
+
project: initProjectOutput.project.name,
|
|
40
40
|
workspace: initProjectOutput.workspace.name,
|
|
41
41
|
};
|
|
42
42
|
await configManager.saveConfig({ config: content, projectRootDir });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Login extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
url: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
|
+
import { loginToCloudBackend } from '../../backend/cloud/login.js';
|
|
3
|
+
import { saveCloudCredentials } from '../../backend/config.js';
|
|
4
|
+
export default class Login extends Command {
|
|
5
|
+
static args = {
|
|
6
|
+
url: Args.string({ description: 'URL of the Hereya Cloud backend', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = 'Login to the Hereya Cloud backend';
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> <%= command.id %> https://cloud.hereya.dev',
|
|
11
|
+
'<%= config.bin %> <%= command.id %> http://localhost:5173',
|
|
12
|
+
];
|
|
13
|
+
async run() {
|
|
14
|
+
const { args } = await this.parse(Login);
|
|
15
|
+
const result = await loginToCloudBackend(args.url);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
this.error(result.error);
|
|
18
|
+
}
|
|
19
|
+
await saveCloudCredentials({
|
|
20
|
+
accessToken: result.accessToken,
|
|
21
|
+
clientId: result.clientId,
|
|
22
|
+
refreshToken: result.refreshToken,
|
|
23
|
+
url: args.url,
|
|
24
|
+
});
|
|
25
|
+
this.log(`Logged in to ${args.url}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { logoutFromCloudBackend } from '../../backend/cloud/logout.js';
|
|
3
|
+
import { deleteCloudCredentials } from '../../backend/config.js';
|
|
4
|
+
export default class Logout extends Command {
|
|
5
|
+
static description = 'Logout from Hereya Cloud';
|
|
6
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
7
|
+
async run() {
|
|
8
|
+
await this.parse(Logout);
|
|
9
|
+
const result = await deleteCloudCredentials();
|
|
10
|
+
if (result.originalConfig.cloud) {
|
|
11
|
+
await logoutFromCloudBackend({
|
|
12
|
+
secret: result.secret,
|
|
13
|
+
url: result.originalConfig.cloud.url,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (result.didDelete) {
|
|
17
|
+
this.log('Logged out from Hereya Cloud');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.log('Not logged in to Hereya Cloud');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/executor/local.js
CHANGED
|
@@ -76,8 +76,9 @@ export class LocalExecutor {
|
|
|
76
76
|
return { reason: setEnvVarOutput.reason, success: false };
|
|
77
77
|
}
|
|
78
78
|
return backend.setEnvVar({
|
|
79
|
+
infrastructure: input.infra,
|
|
79
80
|
name: input.name,
|
|
80
|
-
value:
|
|
81
|
+
value: setEnvVarOutput.value,
|
|
81
82
|
workspace: input.workspace,
|
|
82
83
|
});
|
|
83
84
|
}
|
|
@@ -116,6 +117,7 @@ export class LocalExecutor {
|
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
return backend.unsetEnvVar({
|
|
120
|
+
infrastructure: infra,
|
|
119
121
|
name: input.name,
|
|
120
122
|
workspace: input.workspace,
|
|
121
123
|
});
|
|
@@ -7,24 +7,9 @@ import { getIac } from '../iac/index.js';
|
|
|
7
7
|
import { downloadPackage } from '../lib/package/index.js';
|
|
8
8
|
import { runShell } from '../lib/shell.js';
|
|
9
9
|
import { getAwsConfig, getAwsConfigKey } from './aws-config.js';
|
|
10
|
-
import { getPackageDownloadPath } from './common.js';
|
|
10
|
+
import { getPackageDownloadPath, } from './common.js';
|
|
11
11
|
import { destroyPackage, provisionPackage } from './index.js';
|
|
12
12
|
export class AwsInfrastructure {
|
|
13
|
-
// public static configKey = '/hereya-bootstrap/config'
|
|
14
|
-
// public static async getConfig(): Promise<{
|
|
15
|
-
// backendBucket: string
|
|
16
|
-
// terraformStateBucketName: string
|
|
17
|
-
// terraformStateBucketRegion?: string
|
|
18
|
-
// terraformStateLockTableName: string
|
|
19
|
-
// }> {
|
|
20
|
-
// const ssmClient = new SSMClient({})
|
|
21
|
-
// const ssmParameter = await ssmClient.send(
|
|
22
|
-
// new GetParameterCommand({
|
|
23
|
-
// Name: AwsInfrastructure.configKey,
|
|
24
|
-
// }),
|
|
25
|
-
// )
|
|
26
|
-
// return JSON.parse(ssmParameter.Parameter?.Value ?? '{}')
|
|
27
|
-
// }
|
|
28
13
|
async bootstrap(_) {
|
|
29
14
|
const stsClient = new STSClient({});
|
|
30
15
|
const { Account: accountId } = await stsClient.send(new GetCallerIdentityCommand({}));
|
|
@@ -59,7 +44,7 @@ export class AwsInfrastructure {
|
|
|
59
44
|
const downloadPath = await downloadPackage(input.pkgUrl, destPath);
|
|
60
45
|
const region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
|
|
61
46
|
const infraConfig = {
|
|
62
|
-
...await getAwsConfig(),
|
|
47
|
+
...(await getAwsConfig()),
|
|
63
48
|
region,
|
|
64
49
|
};
|
|
65
50
|
if (!infraConfig.terraformStateBucketName || !infraConfig.terraformStateLockTableName) {
|
package/oclif.manifest.json
CHANGED
|
@@ -313,6 +313,61 @@
|
|
|
313
313
|
"index.js"
|
|
314
314
|
]
|
|
315
315
|
},
|
|
316
|
+
"login": {
|
|
317
|
+
"aliases": [],
|
|
318
|
+
"args": {
|
|
319
|
+
"url": {
|
|
320
|
+
"description": "URL of the Hereya Cloud backend",
|
|
321
|
+
"name": "url",
|
|
322
|
+
"required": true
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"description": "Login to the Hereya Cloud backend",
|
|
326
|
+
"examples": [
|
|
327
|
+
"<%= config.bin %> <%= command.id %> https://cloud.hereya.dev",
|
|
328
|
+
"<%= config.bin %> <%= command.id %> http://localhost:5173"
|
|
329
|
+
],
|
|
330
|
+
"flags": {},
|
|
331
|
+
"hasDynamicHelp": false,
|
|
332
|
+
"hiddenAliases": [],
|
|
333
|
+
"id": "login",
|
|
334
|
+
"pluginAlias": "hereya-cli",
|
|
335
|
+
"pluginName": "hereya-cli",
|
|
336
|
+
"pluginType": "core",
|
|
337
|
+
"strict": true,
|
|
338
|
+
"enableJsonFlag": false,
|
|
339
|
+
"isESM": true,
|
|
340
|
+
"relativePath": [
|
|
341
|
+
"dist",
|
|
342
|
+
"commands",
|
|
343
|
+
"login",
|
|
344
|
+
"index.js"
|
|
345
|
+
]
|
|
346
|
+
},
|
|
347
|
+
"logout": {
|
|
348
|
+
"aliases": [],
|
|
349
|
+
"args": {},
|
|
350
|
+
"description": "Logout from Hereya Cloud",
|
|
351
|
+
"examples": [
|
|
352
|
+
"<%= config.bin %> <%= command.id %>"
|
|
353
|
+
],
|
|
354
|
+
"flags": {},
|
|
355
|
+
"hasDynamicHelp": false,
|
|
356
|
+
"hiddenAliases": [],
|
|
357
|
+
"id": "logout",
|
|
358
|
+
"pluginAlias": "hereya-cli",
|
|
359
|
+
"pluginName": "hereya-cli",
|
|
360
|
+
"pluginType": "core",
|
|
361
|
+
"strict": true,
|
|
362
|
+
"enableJsonFlag": false,
|
|
363
|
+
"isESM": true,
|
|
364
|
+
"relativePath": [
|
|
365
|
+
"dist",
|
|
366
|
+
"commands",
|
|
367
|
+
"logout",
|
|
368
|
+
"index.js"
|
|
369
|
+
]
|
|
370
|
+
},
|
|
316
371
|
"remove": {
|
|
317
372
|
"aliases": [],
|
|
318
373
|
"args": {
|
|
@@ -558,6 +613,38 @@
|
|
|
558
613
|
"index.js"
|
|
559
614
|
]
|
|
560
615
|
},
|
|
616
|
+
"config:export-backend": {
|
|
617
|
+
"aliases": [],
|
|
618
|
+
"args": {
|
|
619
|
+
"file": {
|
|
620
|
+
"description": "Path to save the export file. Defaults to cloud-backend.json in current directory",
|
|
621
|
+
"name": "file",
|
|
622
|
+
"required": false
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
"description": "Export the cloud backend configuration to a file",
|
|
626
|
+
"examples": [
|
|
627
|
+
"<%= config.bin %> <%= command.id %>",
|
|
628
|
+
"<%= config.bin %> <%= command.id %> ./path/to/export.json"
|
|
629
|
+
],
|
|
630
|
+
"flags": {},
|
|
631
|
+
"hasDynamicHelp": false,
|
|
632
|
+
"hiddenAliases": [],
|
|
633
|
+
"id": "config:export-backend",
|
|
634
|
+
"pluginAlias": "hereya-cli",
|
|
635
|
+
"pluginName": "hereya-cli",
|
|
636
|
+
"pluginType": "core",
|
|
637
|
+
"strict": true,
|
|
638
|
+
"enableJsonFlag": false,
|
|
639
|
+
"isESM": true,
|
|
640
|
+
"relativePath": [
|
|
641
|
+
"dist",
|
|
642
|
+
"commands",
|
|
643
|
+
"config",
|
|
644
|
+
"export-backend",
|
|
645
|
+
"index.js"
|
|
646
|
+
]
|
|
647
|
+
},
|
|
561
648
|
"config:get-backend": {
|
|
562
649
|
"aliases": [],
|
|
563
650
|
"args": {},
|
|
@@ -583,6 +670,37 @@
|
|
|
583
670
|
"index.js"
|
|
584
671
|
]
|
|
585
672
|
},
|
|
673
|
+
"config:import-backend": {
|
|
674
|
+
"aliases": [],
|
|
675
|
+
"args": {
|
|
676
|
+
"file": {
|
|
677
|
+
"description": "Path to the file containing the backend configuration to import",
|
|
678
|
+
"name": "file",
|
|
679
|
+
"required": true
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
"description": "Import a backend configuration from a file",
|
|
683
|
+
"examples": [
|
|
684
|
+
"<%= config.bin %> <%= command.id %> ./path/to/cloud-backend.json"
|
|
685
|
+
],
|
|
686
|
+
"flags": {},
|
|
687
|
+
"hasDynamicHelp": false,
|
|
688
|
+
"hiddenAliases": [],
|
|
689
|
+
"id": "config:import-backend",
|
|
690
|
+
"pluginAlias": "hereya-cli",
|
|
691
|
+
"pluginName": "hereya-cli",
|
|
692
|
+
"pluginType": "core",
|
|
693
|
+
"strict": true,
|
|
694
|
+
"enableJsonFlag": false,
|
|
695
|
+
"isESM": true,
|
|
696
|
+
"relativePath": [
|
|
697
|
+
"dist",
|
|
698
|
+
"commands",
|
|
699
|
+
"config",
|
|
700
|
+
"import-backend",
|
|
701
|
+
"index.js"
|
|
702
|
+
]
|
|
703
|
+
},
|
|
586
704
|
"config:use-backend": {
|
|
587
705
|
"aliases": [],
|
|
588
706
|
"args": {
|
|
@@ -1063,5 +1181,5 @@
|
|
|
1063
1181
|
]
|
|
1064
1182
|
}
|
|
1065
1183
|
},
|
|
1066
|
-
"version": "0.
|
|
1184
|
+
"version": "0.36.0"
|
|
1067
1185
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hereya-cli",
|
|
3
3
|
"description": "Infrastructure as Package",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.36.0",
|
|
5
5
|
"author": "Hereya Developers",
|
|
6
6
|
"bin": {
|
|
7
7
|
"hereya": "./bin/run.js"
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
"@oclif/plugin-plugins": "^5.4.31",
|
|
22
22
|
"glob": "^11.0.1",
|
|
23
23
|
"ignore": "^7.0.3",
|
|
24
|
+
"keytar": "^7.9.0",
|
|
24
25
|
"listr2": "^8.2.5",
|
|
26
|
+
"node-machine-id": "^1.1.12",
|
|
27
|
+
"open": "^10.1.1",
|
|
25
28
|
"simple-git": "^3.27.0",
|
|
26
29
|
"unzip-stream": "^0.3.4",
|
|
27
30
|
"yaml": "^2.7.0",
|
|
@@ -43,7 +46,7 @@
|
|
|
43
46
|
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
44
47
|
"mocha": "^11.1.0",
|
|
45
48
|
"mock-fs": "^5.5.0",
|
|
46
|
-
"nock": "^14.0.
|
|
49
|
+
"nock": "^14.0.3",
|
|
47
50
|
"oclif": "^4.17.27",
|
|
48
51
|
"shx": "^0.3.4",
|
|
49
52
|
"sinon": "^19.0.2",
|