@ductape/cli 0.2.6 → 0.2.8
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/dist/commands/products.d.ts +6 -0
- package/dist/commands/products.js +23 -0
- package/dist/index.js +16 -1
- package/dist/lib/resources.js +3 -1
- package/package.json +1 -1
- package/src/commands/products.ts +29 -0
- package/src/index.ts +23 -1
- package/src/lib/resources.ts +3 -1
|
@@ -12,3 +12,9 @@ export declare function runProductApps(verb: string, opts: {
|
|
|
12
12
|
product?: string;
|
|
13
13
|
json?: boolean;
|
|
14
14
|
}, extraArgs: string[]): Promise<void>;
|
|
15
|
+
export declare function runProductEnvironments(verb: string, opts: {
|
|
16
|
+
product?: string;
|
|
17
|
+
tag?: string;
|
|
18
|
+
slug?: string;
|
|
19
|
+
json?: boolean;
|
|
20
|
+
}, extraArgs: string[]): Promise<void>;
|
|
@@ -5,6 +5,7 @@ import { bodyRequiredHint, resolveBody } from '../lib/read-body.js';
|
|
|
5
5
|
import { createProduct, deleteProduct, getProduct, listProductApps, listProducts, updateProduct, } from '../lib/platform-api.js';
|
|
6
6
|
import { printJson } from '../lib/output.js';
|
|
7
7
|
import { requireWorkspaceContext } from '../lib/workspace-context.js';
|
|
8
|
+
import { requireSession, getSdkProxy } from '../lib/proxy/context.js';
|
|
8
9
|
const VERBS = ['list', 'get', 'create', 'update', 'delete'];
|
|
9
10
|
export async function runProducts(verb, opts, extraArgs) {
|
|
10
11
|
const v = verb.toLowerCase();
|
|
@@ -72,3 +73,25 @@ export async function runProductApps(verb, opts, extraArgs) {
|
|
|
72
73
|
const result = await listProductApps(ctx, productId);
|
|
73
74
|
printJson(result, Boolean(opts.json));
|
|
74
75
|
}
|
|
76
|
+
export async function runProductEnvironments(verb, opts, extraArgs) {
|
|
77
|
+
const v = verb.toLowerCase();
|
|
78
|
+
const allowed = ['list', 'get', 'fetch'];
|
|
79
|
+
if (!allowed.includes(v)) {
|
|
80
|
+
throw new Error(`Unknown environments verb "${verb}". Use: ${allowed.join(', ')}`);
|
|
81
|
+
}
|
|
82
|
+
const session = requireSession();
|
|
83
|
+
const proxy = getSdkProxy(session);
|
|
84
|
+
const productTag = opts.product ?? extraArgs[0] ?? session.project?.product_tag;
|
|
85
|
+
if (!productTag)
|
|
86
|
+
throw new Error('Provide the product tag as the first argument or --product <tag>');
|
|
87
|
+
if (v === 'list') {
|
|
88
|
+
const result = await proxy.execute('product', 'environments.list', [productTag]);
|
|
89
|
+
printJson(result, Boolean(opts.json));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const slug = opts.slug ?? opts.tag ?? extraArgs[1] ?? extraArgs[0];
|
|
93
|
+
if (!slug)
|
|
94
|
+
throw new Error('Provide the environment slug as the second argument or --slug <slug>');
|
|
95
|
+
const result = await proxy.execute('product', 'environments.fetch', [productTag, slug]);
|
|
96
|
+
printJson(result, Boolean(opts.json));
|
|
97
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { runSecrets } from './commands/secrets.js';
|
|
|
22
22
|
import { runWorkspacesCurrent, runWorkspacesList, runWorkspacesRefresh, runWorkspacesUse, } from './commands/workspaces.js';
|
|
23
23
|
import { runGeneratePayload, runGenerateSnippet } from './commands/generate.js';
|
|
24
24
|
import { runCompletion } from './commands/completion.js';
|
|
25
|
-
import { runProducts, runProductApps } from './commands/products.js';
|
|
25
|
+
import { runProducts, runProductApps, runProductEnvironments } from './commands/products.js';
|
|
26
26
|
import { runApps } from './commands/apps.js';
|
|
27
27
|
import { runAppsImport } from './commands/apps-import.js';
|
|
28
28
|
import { runApply } from './commands/apply.js';
|
|
@@ -192,6 +192,21 @@ productApps
|
|
|
192
192
|
.option('--product <id>', 'Product _id')
|
|
193
193
|
.option('--json', 'JSON output')
|
|
194
194
|
.action(wrap((opts) => runProductApps('list', opts, [])));
|
|
195
|
+
const productEnvironments = products
|
|
196
|
+
.command('environments')
|
|
197
|
+
.description('Product environments (list, get)');
|
|
198
|
+
productEnvironments
|
|
199
|
+
.command('list [product_tag]')
|
|
200
|
+
.description('List all environments for a product')
|
|
201
|
+
.option('--product <tag>', 'Product tag (defaults to linked project)')
|
|
202
|
+
.option('--json', 'JSON output')
|
|
203
|
+
.action(wrap((productTagArg, opts) => runProductEnvironments('list', { product: opts.product ?? productTagArg, json: opts.json }, [])));
|
|
204
|
+
productEnvironments
|
|
205
|
+
.command('get <product_tag> [slug]')
|
|
206
|
+
.description('Fetch a single product environment by slug')
|
|
207
|
+
.option('--slug <slug>', 'Environment slug')
|
|
208
|
+
.option('--json', 'JSON output')
|
|
209
|
+
.action(wrap((productTagArg, slugArg, opts) => runProductEnvironments('get', { product: productTagArg, slug: opts.slug ?? slugArg, json: opts.json }, [])));
|
|
195
210
|
const apps = program
|
|
196
211
|
.command('apps')
|
|
197
212
|
.description('Workspace integration apps CRUD (REST)')
|
package/dist/lib/resources.js
CHANGED
|
@@ -65,7 +65,9 @@ export function buildCrudParams(module, method, productTag, args) {
|
|
|
65
65
|
return [payload];
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
if (module === 'storage' && method === 'create') {
|
|
68
|
+
if ((module === 'storage' || module === 'databases') && method === 'create') {
|
|
69
|
+
// databases.create and storage.create expect a single config object with product embedded,
|
|
70
|
+
// not the default (productTag, data) two-argument form.
|
|
69
71
|
const payload = body && typeof body === 'object'
|
|
70
72
|
? { product: productTag, ...body }
|
|
71
73
|
: { product: productTag };
|
package/package.json
CHANGED
package/src/commands/products.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '../lib/platform-api.js';
|
|
13
13
|
import { printJson } from '../lib/output.js';
|
|
14
14
|
import { requireWorkspaceContext } from '../lib/workspace-context.js';
|
|
15
|
+
import { requireSession, getSdkProxy } from '../lib/proxy/context.js';
|
|
15
16
|
|
|
16
17
|
const VERBS = ['list', 'get', 'create', 'update', 'delete'] as const;
|
|
17
18
|
type Verb = (typeof VERBS)[number];
|
|
@@ -102,3 +103,31 @@ export async function runProductApps(
|
|
|
102
103
|
const result = await listProductApps(ctx, productId);
|
|
103
104
|
printJson(result, Boolean(opts.json));
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
export async function runProductEnvironments(
|
|
108
|
+
verb: string,
|
|
109
|
+
opts: { product?: string; tag?: string; slug?: string; json?: boolean },
|
|
110
|
+
extraArgs: string[],
|
|
111
|
+
): Promise<void> {
|
|
112
|
+
const v = verb.toLowerCase();
|
|
113
|
+
const allowed = ['list', 'get', 'fetch'];
|
|
114
|
+
if (!allowed.includes(v)) {
|
|
115
|
+
throw new Error(`Unknown environments verb "${verb}". Use: ${allowed.join(', ')}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const session = requireSession();
|
|
119
|
+
const proxy = getSdkProxy(session);
|
|
120
|
+
const productTag = opts.product ?? extraArgs[0] ?? session.project?.product_tag;
|
|
121
|
+
if (!productTag) throw new Error('Provide the product tag as the first argument or --product <tag>');
|
|
122
|
+
|
|
123
|
+
if (v === 'list') {
|
|
124
|
+
const result = await proxy.execute('product', 'environments.list', [productTag]);
|
|
125
|
+
printJson(result, Boolean(opts.json));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const slug = opts.slug ?? opts.tag ?? extraArgs[1] ?? extraArgs[0];
|
|
130
|
+
if (!slug) throw new Error('Provide the environment slug as the second argument or --slug <slug>');
|
|
131
|
+
const result = await proxy.execute('product', 'environments.fetch', [productTag, slug]);
|
|
132
|
+
printJson(result, Boolean(opts.json));
|
|
133
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from './commands/workspaces.js';
|
|
28
28
|
import { runGeneratePayload, runGenerateSnippet } from './commands/generate.js';
|
|
29
29
|
import { runCompletion } from './commands/completion.js';
|
|
30
|
-
import { runProducts, runProductApps } from './commands/products.js';
|
|
30
|
+
import { runProducts, runProductApps, runProductEnvironments } from './commands/products.js';
|
|
31
31
|
import { runApps } from './commands/apps.js';
|
|
32
32
|
import { runAppsImport } from './commands/apps-import.js';
|
|
33
33
|
import { runApply, type ApplyType } from './commands/apply.js';
|
|
@@ -248,6 +248,28 @@ productApps
|
|
|
248
248
|
.option('--json', 'JSON output')
|
|
249
249
|
.action(wrap((opts) => runProductApps('list', opts, [])));
|
|
250
250
|
|
|
251
|
+
const productEnvironments = products
|
|
252
|
+
.command('environments')
|
|
253
|
+
.description('Product environments (list, get)');
|
|
254
|
+
|
|
255
|
+
productEnvironments
|
|
256
|
+
.command('list [product_tag]')
|
|
257
|
+
.description('List all environments for a product')
|
|
258
|
+
.option('--product <tag>', 'Product tag (defaults to linked project)')
|
|
259
|
+
.option('--json', 'JSON output')
|
|
260
|
+
.action(wrap((productTagArg: string | undefined, opts) =>
|
|
261
|
+
runProductEnvironments('list', { product: opts.product ?? productTagArg, json: opts.json }, []),
|
|
262
|
+
));
|
|
263
|
+
|
|
264
|
+
productEnvironments
|
|
265
|
+
.command('get <product_tag> [slug]')
|
|
266
|
+
.description('Fetch a single product environment by slug')
|
|
267
|
+
.option('--slug <slug>', 'Environment slug')
|
|
268
|
+
.option('--json', 'JSON output')
|
|
269
|
+
.action(wrap((productTagArg: string, slugArg: string | undefined, opts) =>
|
|
270
|
+
runProductEnvironments('get', { product: productTagArg, slug: opts.slug ?? slugArg, json: opts.json }, []),
|
|
271
|
+
));
|
|
272
|
+
|
|
251
273
|
const apps = program
|
|
252
274
|
.command('apps')
|
|
253
275
|
.description('Workspace integration apps CRUD (REST)')
|
package/src/lib/resources.ts
CHANGED
|
@@ -79,7 +79,9 @@ export function buildCrudParams(
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
if (module === 'storage' && method === 'create') {
|
|
82
|
+
if ((module === 'storage' || module === 'databases') && method === 'create') {
|
|
83
|
+
// databases.create and storage.create expect a single config object with product embedded,
|
|
84
|
+
// not the default (productTag, data) two-argument form.
|
|
83
85
|
const payload =
|
|
84
86
|
body && typeof body === 'object'
|
|
85
87
|
? { product: productTag, ...(body as object) }
|