@eve-horizon/cli 0.2.11 → 0.2.13

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.
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleManifest = handleManifest;
4
- const args_1 = require("../lib/args");
5
- const client_1 = require("../lib/client");
6
- const output_1 = require("../lib/output");
7
- const node_fs_1 = require("node:fs");
8
- const node_path_1 = require("node:path");
9
- async function handleManifest(subcommand, positionals, flags, context) {
10
- const json = Boolean(flags.json);
11
- switch (subcommand) {
12
- case 'validate': {
13
- const useLatest = (0, args_1.toBoolean)(flags.latest) ?? false;
14
- const strict = (0, args_1.toBoolean)(flags.strict) ?? false;
15
- const validateSecretsFlag = flags['validate-secrets'] ?? flags.validate_secrets;
16
- const validateSecrets = (0, args_1.toBoolean)(validateSecretsFlag) ?? false;
17
- const dir = typeof flags.dir === 'string' ? flags.dir : process.cwd();
18
- const manifestPath = (0, args_1.getStringFlag)(flags, ['path']) ?? (0, node_path_1.join)(dir, '.eve', 'manifest.yaml');
19
- let manifestYaml;
20
- if (!useLatest) {
21
- try {
22
- manifestYaml = (0, node_fs_1.readFileSync)(manifestPath, 'utf-8');
23
- }
24
- catch (error) {
25
- throw new Error(`Failed to read manifest at ${manifestPath}: ${error.message}`);
26
- }
27
- }
28
- let projectId = (0, args_1.getStringFlag)(flags, ['project']) ?? context.projectId;
29
- if (!projectId && manifestYaml) {
30
- const match = manifestYaml.match(/^project:\s*(\S+)/m);
31
- if (match) {
32
- projectId = match[1];
33
- }
34
- }
35
- if (!projectId) {
36
- throw new Error('Missing project id. Provide --project, set a profile default, or add "project: proj_xxx" to manifest.');
37
- }
38
- const response = await (0, client_1.requestJson)(context, `/projects/${projectId}/manifest/validate`, {
39
- method: 'POST',
40
- body: {
41
- manifest_yaml: manifestYaml,
42
- validate_secrets: validateSecrets || strict,
43
- strict,
44
- },
45
- });
46
- if (json) {
47
- (0, output_1.outputJson)(response, json);
48
- }
49
- else {
50
- if (response.valid) {
51
- console.log('✓ Manifest valid');
52
- }
53
- else {
54
- console.log('✗ Manifest invalid');
55
- }
56
- if (response.manifest_hash) {
57
- console.log(` Hash: ${response.manifest_hash.substring(0, 12)}...`);
58
- }
59
- if (response.errors && response.errors.length > 0) {
60
- console.log('');
61
- console.log('Errors:');
62
- response.errors.forEach((error) => console.log(` - ${error}`));
63
- }
64
- if (response.warnings && response.warnings.length > 0) {
65
- console.log('');
66
- console.log('Warnings:');
67
- response.warnings.forEach((warning) => console.log(` - ${warning}`));
68
- }
69
- if (response.secret_validation?.missing?.length) {
70
- console.log('');
71
- console.log('Missing secrets:');
72
- response.secret_validation.missing.forEach((item) => {
73
- const hint = item.hints?.[0] ? ` (${item.hints[0]})` : '';
74
- console.log(` - ${item.key}${hint}`);
75
- });
76
- }
77
- }
78
- if (!response.valid) {
79
- process.exitCode = 1;
80
- }
81
- return;
82
- }
83
- default:
84
- throw new Error('Usage: eve manifest <validate>');
85
- }
86
- }
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleOrg = handleOrg;
4
- const args_1 = require("../lib/args");
5
- const client_1 = require("../lib/client");
6
- const output_1 = require("../lib/output");
7
- const DEFAULT_ORG_NAME = process.env.EVE_ORG_NAME || 'default-test-org';
8
- const DEFAULT_ORG_ID = process.env.EVE_ORG_ID || 'org_defaulttestorg';
9
- async function handleOrg(subcommand, positionals, flags, context) {
10
- const json = Boolean(flags.json);
11
- switch (subcommand) {
12
- case 'ensure': {
13
- let orgId = typeof flags.id === 'string' ? flags.id : '';
14
- let orgName = typeof flags.name === 'string' ? flags.name : '';
15
- let orgSlug = typeof flags.slug === 'string' ? flags.slug : '';
16
- const nameOrId = positionals[0];
17
- if (!orgId && nameOrId) {
18
- if (/^org_[a-zA-Z0-9]+$/.test(nameOrId)) {
19
- orgId = nameOrId;
20
- orgName = orgName || nameOrId;
21
- }
22
- else {
23
- orgName = orgName || nameOrId;
24
- orgId = normalizeOrgId(nameOrId);
25
- }
26
- }
27
- orgId = orgId || context.orgId || DEFAULT_ORG_ID;
28
- orgName = orgName || DEFAULT_ORG_NAME;
29
- const body = { id: orgId, name: orgName, ...(orgSlug ? { slug: orgSlug } : {}) };
30
- const org = await (0, client_1.requestJson)(context, '/orgs/ensure', {
31
- method: 'POST',
32
- body,
33
- });
34
- (0, output_1.outputJson)(org, json, `✓ Organization ready: ${org.id} (${org.name})`);
35
- return;
36
- }
37
- case 'list': {
38
- const includeDeletedFlag = flags.include_deleted ?? flags['include-deleted'];
39
- const query = buildQuery({
40
- limit: typeof flags.limit === 'string' ? flags.limit : undefined,
41
- offset: typeof flags.offset === 'string' ? flags.offset : undefined,
42
- include_deleted: (0, args_1.toBoolean)(includeDeletedFlag) ? 'true' : undefined,
43
- name: typeof flags.name === 'string' ? flags.name : undefined,
44
- });
45
- const response = await (0, client_1.requestJson)(context, `/orgs${query}`);
46
- (0, output_1.outputJson)(response, json);
47
- return;
48
- }
49
- case 'get': {
50
- const orgId = positionals[0];
51
- if (!orgId)
52
- throw new Error('Usage: eve org get <org_id>');
53
- const includeDeletedFlag = flags.include_deleted ?? flags['include-deleted'];
54
- const query = buildQuery({
55
- include_deleted: (0, args_1.toBoolean)(includeDeletedFlag) ? 'true' : undefined,
56
- });
57
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}${query}`);
58
- (0, output_1.outputJson)(response, json);
59
- return;
60
- }
61
- case 'update': {
62
- const orgId = positionals[0];
63
- if (!orgId)
64
- throw new Error('Usage: eve org update <org_id> [--name <name>] [--deleted <bool>]');
65
- const body = {};
66
- if (typeof flags.name === 'string')
67
- body.name = flags.name;
68
- const deleted = (0, args_1.toBoolean)(flags.deleted);
69
- if (deleted !== undefined)
70
- body.deleted = deleted;
71
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}`, { method: 'PATCH', body });
72
- (0, output_1.outputJson)(response, json);
73
- return;
74
- }
75
- case 'delete': {
76
- const orgId = positionals[0];
77
- if (!orgId)
78
- throw new Error('Usage: eve org delete <org_id> [--force]');
79
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}`, { method: 'PATCH', body: { deleted: true } });
80
- (0, output_1.outputJson)(response, json, `✓ Organization deleted: ${orgId}`);
81
- return;
82
- }
83
- default:
84
- throw new Error('Usage: eve org <ensure|list|get|update|delete>');
85
- }
86
- }
87
- function normalizeOrgId(raw) {
88
- if (/^org_[a-zA-Z0-9]+$/.test(raw)) {
89
- return raw;
90
- }
91
- const stripped = raw.replace(/[^a-zA-Z0-9]/g, '');
92
- if (!stripped) {
93
- throw new Error('Organization id must contain alphanumeric characters');
94
- }
95
- return `org_${stripped}`;
96
- }
97
- function buildQuery(params) {
98
- const search = new URLSearchParams();
99
- Object.entries(params).forEach(([key, value]) => {
100
- if (value === undefined || value === '')
101
- return;
102
- search.set(key, String(value));
103
- });
104
- const query = search.toString();
105
- return query ? `?${query}` : '';
106
- }