@ductape/cli 0.5.0 → 0.5.3
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/app-webhooks.d.ts +16 -0
- package/dist/commands/app-webhooks.js +60 -0
- package/dist/commands/apps.d.ts +6 -0
- package/dist/commands/apps.js +20 -4
- package/dist/commands/cloud.d.ts +8 -0
- package/dist/commands/cloud.js +40 -1
- package/dist/commands/deploy-builds.d.ts +3 -1
- package/dist/commands/deploy-builds.js +11 -3
- package/dist/commands/deploy-remote.d.ts +34 -1
- package/dist/commands/deploy-remote.js +109 -3
- package/dist/commands/deploy-worker.d.ts +30 -0
- package/dist/commands/deploy-worker.js +85 -0
- package/dist/commands/install.d.ts +28 -1
- package/dist/commands/install.js +72 -24
- package/dist/commands/platform.js +9 -3
- package/dist/commands/secrets-scan.d.ts +49 -0
- package/dist/commands/secrets-scan.js +113 -0
- package/dist/index.js +108 -17
- package/dist/lib/api-client.js +4 -2
- package/dist/lib/app-import.d.ts +1 -0
- package/dist/lib/app-import.js +8 -1
- package/dist/lib/cloud-connection.d.ts +89 -1
- package/dist/lib/cloud-connection.js +417 -5
- package/dist/lib/env-scan.d.ts +57 -0
- package/dist/lib/env-scan.js +161 -0
- package/dist/lib/platform-api.js +3 -9
- package/package.json +1 -1
- package/templates/api-gateway.conf +53 -34
- package/templates/docker-compose.backend.yml +7 -0
- package/templates/docker-compose.release.yml +122 -103
- package/templates/docker-compose.workbench.yml +58 -0
- package/templates/platform.env +65 -7
package/dist/commands/install.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -6,32 +7,70 @@ import { HUB_PLATFORM_DIR } from '../lib/config.js';
|
|
|
6
7
|
import { success } from '../lib/output.js';
|
|
7
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const TEMPLATES_DIR = path.resolve(__dirname, '../../templates');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The files `ductape install` writes, and where they come from. They are generated from the platform's own compose file by
|
|
12
|
+
* platform/scripts/render-release.mjs, so what a customer runs is what this repository runs.
|
|
13
|
+
*/
|
|
14
|
+
const PLATFORM_FILES = [
|
|
15
|
+
['docker-compose.release.yml', 'docker-compose.yml'],
|
|
16
|
+
['docker-compose.backend.yml', 'docker-compose.backend.yml'],
|
|
17
|
+
['docker-compose.workbench.yml', 'docker-compose.workbench.yml'],
|
|
18
|
+
['api-gateway.conf', 'api-gateway.conf'],
|
|
12
19
|
];
|
|
13
20
|
function checkCommand(cmd, args) {
|
|
14
21
|
const r = spawnSync(cmd, args, { stdio: 'ignore' });
|
|
15
22
|
return r.status === 0;
|
|
16
23
|
}
|
|
17
|
-
|
|
24
|
+
/** Runs `docker compose pull` in the platform folder, so every image the compose file names is fetched, whoever published it. */
|
|
25
|
+
function pullImages(platformDir, tag) {
|
|
18
26
|
return new Promise((resolve, reject) => {
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const child = spawn('docker', ['compose', 'pull'], {
|
|
28
|
+
cwd: platformDir,
|
|
21
29
|
stdio: 'inherit',
|
|
22
30
|
shell: process.platform === 'win32',
|
|
31
|
+
env: { ...process.env, ...(tag ? { DUCTAPE_TAG: tag } : {}) },
|
|
23
32
|
});
|
|
24
33
|
child.on('error', reject);
|
|
25
34
|
child.on('close', (code) => resolve(code ?? 1));
|
|
26
35
|
});
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const newEncKey = () => crypto.randomBytes(48).toString('base64url');
|
|
38
|
+
/** Sets `NAME=value` in env text: replaces an uncommented line, or adds one. Never echoes the value. */
|
|
39
|
+
function setEnvValue(text, name, value) {
|
|
40
|
+
const line = new RegExp(`^${name}=.*$`, 'm');
|
|
41
|
+
return line.test(text) ? text.replace(line, `${name}=${value}`) : `${text.replace(/\n*$/, '\n')}${name}=${value}\n`;
|
|
33
42
|
}
|
|
34
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Writes the compose files, the gateway configuration and the settings file. The compose files are always replaced, because they
|
|
45
|
+
* describe the release. The settings file is never replaced: it is the customer's. It is made once, with an ENC_KEY of its own
|
|
46
|
+
* (the key that encrypts everything this install stores), and an existing one without a key is given one.
|
|
47
|
+
*/
|
|
48
|
+
export function writePlatformFiles(options) {
|
|
49
|
+
const { platformDir, tag } = options;
|
|
50
|
+
const templatesDir = options.templatesDir ?? TEMPLATES_DIR;
|
|
51
|
+
const makeKey = options.newKey ?? newEncKey;
|
|
52
|
+
fs.mkdirSync(platformDir, { recursive: true });
|
|
53
|
+
const composeTarget = path.join(platformDir, 'docker-compose.yml');
|
|
54
|
+
let previous;
|
|
55
|
+
if (fs.existsSync(composeTarget) && /platform-api\b/.test(fs.readFileSync(composeTarget, 'utf8'))) {
|
|
56
|
+
previous = path.join(platformDir, 'docker-compose.previous.yml');
|
|
57
|
+
fs.copyFileSync(composeTarget, previous);
|
|
58
|
+
}
|
|
59
|
+
for (const [template, target] of PLATFORM_FILES)
|
|
60
|
+
fs.copyFileSync(path.join(templatesDir, template), path.join(platformDir, target));
|
|
61
|
+
const envTarget = path.join(platformDir, '.env');
|
|
62
|
+
const created = !fs.existsSync(envTarget);
|
|
63
|
+
let env = created ? fs.readFileSync(path.join(templatesDir, 'platform.env'), 'utf8') : fs.readFileSync(envTarget, 'utf8');
|
|
64
|
+
const hasKey = /^ENC_KEY=\S+/m.test(env);
|
|
65
|
+
if (!hasKey)
|
|
66
|
+
env = setEnvValue(env, 'ENC_KEY', makeKey());
|
|
67
|
+
if (tag)
|
|
68
|
+
env = setEnvValue(env, 'DUCTAPE_TAG', tag);
|
|
69
|
+
fs.writeFileSync(envTarget, env, { mode: 0o600 });
|
|
70
|
+
fs.chmodSync(envTarget, 0o600);
|
|
71
|
+
return { createdEnv: created, addedKey: !hasKey, ...(previous ? { previous } : {}) };
|
|
72
|
+
}
|
|
73
|
+
export async function runInstall(opts = {}) {
|
|
35
74
|
const issues = [];
|
|
36
75
|
if (!checkCommand('docker', ['--version'])) {
|
|
37
76
|
issues.push('Docker is not installed or not on PATH');
|
|
@@ -43,22 +82,31 @@ export async function runInstall() {
|
|
|
43
82
|
console.error('Install check failed:\n' + issues.map((i) => ` - ${i}`).join('\n'));
|
|
44
83
|
process.exit(1);
|
|
45
84
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
const platformDir = process.env.DUCTAPE_PLATFORM_DIR ? path.resolve(process.env.DUCTAPE_PLATFORM_DIR) : HUB_PLATFORM_DIR;
|
|
86
|
+
const result = writePlatformFiles({ platformDir, tag: opts.tag });
|
|
87
|
+
if (opts.pull !== false) {
|
|
88
|
+
const code = await pullImages(platformDir, opts.tag);
|
|
49
89
|
if (code !== 0) {
|
|
50
|
-
console.error(`Failed to pull
|
|
90
|
+
console.error(`Failed to pull the platform images (exit ${code}). Check your internet connection, run \`docker login\`, or use --no-pull to run images already on this machine.`);
|
|
51
91
|
process.exit(1);
|
|
52
92
|
}
|
|
53
93
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
94
|
+
success(`Platform installed to ${platformDir}`);
|
|
95
|
+
console.log('');
|
|
96
|
+
if (result.previous) {
|
|
97
|
+
console.log(` An earlier install was here. Its compose file is kept as ${path.basename(result.previous)}.`);
|
|
98
|
+
console.log(` If it is still running, stop it first: docker compose -f ${result.previous} down --remove-orphans`);
|
|
99
|
+
console.log('');
|
|
100
|
+
}
|
|
101
|
+
if (result.createdEnv || result.addedKey) {
|
|
102
|
+
console.log(` Settings: ${path.join(platformDir, '.env')}`);
|
|
103
|
+
console.log(' This install has its own ENC_KEY there. Back that file up: without the key, secrets this install stores cannot be read.');
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(` Your settings in ${path.join(platformDir, '.env')} were left as they were.`);
|
|
107
|
+
}
|
|
108
|
+
console.log(' Add your AWS credentials there for cloud connections, and the DEPLOY_ settings to use Ductape Deploy.');
|
|
60
109
|
console.log('');
|
|
61
|
-
console.log(' Edit ~/.ductape/platform/.env to add your AWS credentials (needed for cloud connections).');
|
|
62
110
|
console.log(' Then run: ductape start');
|
|
63
111
|
console.log('');
|
|
64
112
|
console.log(' Workbench: http://localhost:4310');
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
2
4
|
import { getApiUrl, loadGlobalConfig, resolvePlatformDir } from '../lib/config.js';
|
|
3
5
|
import { printJson, success } from '../lib/output.js';
|
|
4
6
|
const WORKBENCH_ONLY_COMPOSE = [
|
|
@@ -10,12 +12,13 @@ const WORKBENCH_ONLY_COMPOSE = [
|
|
|
10
12
|
function normalizeViteApiBase(url) {
|
|
11
13
|
return url.endsWith('/') ? url : `${url}/`;
|
|
12
14
|
}
|
|
13
|
-
function runCompose(args, cwd) {
|
|
15
|
+
function runCompose(args, cwd, env = {}) {
|
|
14
16
|
return new Promise((resolve, reject) => {
|
|
15
17
|
const child = spawn('docker', ['compose', ...args], {
|
|
16
18
|
cwd,
|
|
17
19
|
stdio: 'inherit',
|
|
18
20
|
shell: process.platform === 'win32',
|
|
21
|
+
env: { ...process.env, ...env },
|
|
19
22
|
});
|
|
20
23
|
child.on('error', reject);
|
|
21
24
|
child.on('close', (code) => resolve(code ?? 1));
|
|
@@ -26,7 +29,10 @@ export async function runStart(opts) {
|
|
|
26
29
|
if (opts.remote) {
|
|
27
30
|
const apiBase = normalizeViteApiBase(getApiUrl('cloud'));
|
|
28
31
|
const composeArgs = [...WORKBENCH_ONLY_COMPOSE];
|
|
29
|
-
|
|
32
|
+
// A source checkout can rebuild the Workbench for another API. An installed platform has only the published image, which reads its
|
|
33
|
+
// API address when it starts, so it is pointed at the other API with an environment variable instead.
|
|
34
|
+
const hasSource = fs.existsSync(path.join(platformDir, 'workbench', 'Dockerfile'));
|
|
35
|
+
if (opts.build && hasSource) {
|
|
30
36
|
const buildCode = await runCompose([
|
|
31
37
|
...composeArgs,
|
|
32
38
|
'build',
|
|
@@ -39,7 +45,7 @@ export async function runStart(opts) {
|
|
|
39
45
|
if (buildCode !== 0)
|
|
40
46
|
throw new Error(`docker compose build exited with ${buildCode}`);
|
|
41
47
|
}
|
|
42
|
-
const code = await runCompose([...composeArgs, 'up', '-d', 'workbench'], platformDir);
|
|
48
|
+
const code = await runCompose([...composeArgs, 'up', '-d', 'workbench'], platformDir, hasSource ? {} : { DUCTAPE_PUBLIC_URL: apiBase.replace(/\/$/, '') });
|
|
43
49
|
if (code !== 0)
|
|
44
50
|
throw new Error(`docker compose exited with ${code}`);
|
|
45
51
|
success(`Workbench UI: http://localhost:4310 (API → ${apiBase})`);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { classifyEntry, type IScanOptions, type IScanRow } from '../lib/env-scan.js';
|
|
2
|
+
/** The workspace's secrets, as far as this command needs them. The real one is the SDK proxy; a test passes its own. */
|
|
3
|
+
export interface ISecretStore {
|
|
4
|
+
/** The keys of the secrets the workspace already has. */
|
|
5
|
+
keys(): Promise<string[]>;
|
|
6
|
+
create(input: {
|
|
7
|
+
key: string;
|
|
8
|
+
value: string;
|
|
9
|
+
description: string;
|
|
10
|
+
envs?: string[];
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
update(key: string, input: {
|
|
13
|
+
value: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface IScanCommandOptions extends IScanOptions {
|
|
18
|
+
/** The file to read. Default: .env in `dir`. */
|
|
19
|
+
envFile?: string;
|
|
20
|
+
/** The project folder. Default: the current folder. */
|
|
21
|
+
dir?: string;
|
|
22
|
+
/** The environment slug the saved secrets are limited to. Without it they are available in every environment. */
|
|
23
|
+
env?: string;
|
|
24
|
+
/** Save them. Without it nothing is saved and the result says what would be. */
|
|
25
|
+
apply?: boolean;
|
|
26
|
+
json?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The file to read: the one named, or `.env` in the project folder. When there is none, the ones that are there are named, never read. */
|
|
29
|
+
export declare function locateEnvFile(options: {
|
|
30
|
+
envFile?: string;
|
|
31
|
+
dir?: string;
|
|
32
|
+
}, cwd?: string): string;
|
|
33
|
+
export interface IScanOutcome {
|
|
34
|
+
rows: IScanRow[];
|
|
35
|
+
applied: boolean;
|
|
36
|
+
failures: Array<{
|
|
37
|
+
key: string;
|
|
38
|
+
message: string;
|
|
39
|
+
}>;
|
|
40
|
+
result: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads a .env file on this machine, decides which variables are secrets, and (only with `apply`) saves them to the workspace's secrets. A value
|
|
44
|
+
* goes from the file to the workspace and nowhere else: it is not printed, not logged and not in any result, and an error from the workspace is
|
|
45
|
+
* stripped of any value before it is shown.
|
|
46
|
+
*/
|
|
47
|
+
export declare function scanEnvFile(options: IScanCommandOptions, store?: ISecretStore, cwd?: string): Promise<IScanOutcome>;
|
|
48
|
+
export declare function runSecretsScanEnv(options: IScanCommandOptions): Promise<void>;
|
|
49
|
+
export { classifyEntry };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { classifyEntry, describePlan, parseDotenv, planScan } from '../lib/env-scan.js';
|
|
4
|
+
import { printJson } from '../lib/output.js';
|
|
5
|
+
import { getSdkProxyForContext } from '../lib/proxy/context.js';
|
|
6
|
+
import { requireWorkspaceContext } from '../lib/workspace-context.js';
|
|
7
|
+
function proxyStore() {
|
|
8
|
+
const ctx = requireWorkspaceContext();
|
|
9
|
+
const proxy = getSdkProxyForContext(ctx);
|
|
10
|
+
return {
|
|
11
|
+
async keys() {
|
|
12
|
+
const result = await proxy.execute('secrets', 'list', []);
|
|
13
|
+
const list = Array.isArray(result) ? result : Array.isArray(result?.data) ? result.data : Array.isArray(result?.secrets) ? result.secrets : [];
|
|
14
|
+
return list.map((item) => (typeof item === 'string' ? item : String(item?.key ?? ''))).filter(Boolean);
|
|
15
|
+
},
|
|
16
|
+
async create(input) { await proxy.execute('secrets', 'create', [input]); },
|
|
17
|
+
async update(key, input) { await proxy.execute('secrets', 'update', [key, input]); },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The file to read: the one named, or `.env` in the project folder. When there is none, the ones that are there are named, never read. */
|
|
21
|
+
export function locateEnvFile(options, cwd = process.cwd()) {
|
|
22
|
+
const dir = path.resolve(cwd, options.dir ?? '.');
|
|
23
|
+
if (options.envFile) {
|
|
24
|
+
const file = path.resolve(dir, options.envFile);
|
|
25
|
+
if (!fs.existsSync(file))
|
|
26
|
+
throw new Error(`The file ${file} does not exist`);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
const file = path.join(dir, '.env');
|
|
30
|
+
if (fs.existsSync(file))
|
|
31
|
+
return file;
|
|
32
|
+
const others = fs.existsSync(dir) ? fs.readdirSync(dir).filter((name) => name.startsWith('.env') && fs.statSync(path.join(dir, name)).isFile()).sort() : [];
|
|
33
|
+
throw new Error(`There is no .env in ${dir}.${others.length ? ` These are here: ${others.join(', ')}. Name one with --env-file.` : ' Name the file with --env-file.'}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads a .env file on this machine, decides which variables are secrets, and (only with `apply`) saves them to the workspace's secrets. A value
|
|
37
|
+
* goes from the file to the workspace and nowhere else: it is not printed, not logged and not in any result, and an error from the workspace is
|
|
38
|
+
* stripped of any value before it is shown.
|
|
39
|
+
*/
|
|
40
|
+
export async function scanEnvFile(options, store = proxyStore(), cwd = process.cwd()) {
|
|
41
|
+
if (options.env !== undefined && !/^[a-z0-9][a-z0-9_-]{0,31}$/i.test(options.env))
|
|
42
|
+
throw new Error('--env must be an environment slug such as stg or prd');
|
|
43
|
+
const file = locateEnvFile(options, cwd);
|
|
44
|
+
const entries = parseDotenv(fs.readFileSync(file, 'utf8'));
|
|
45
|
+
if (entries.length === 0)
|
|
46
|
+
throw new Error(`${file} has no variables in it`);
|
|
47
|
+
const existing = new Set(await store.keys());
|
|
48
|
+
const rows = planScan(entries, existing, options);
|
|
49
|
+
const source = path.basename(file);
|
|
50
|
+
const failures = [];
|
|
51
|
+
const done = new Map();
|
|
52
|
+
if (options.apply) {
|
|
53
|
+
const byName = new Map(entries.map((e) => [e.name, e]));
|
|
54
|
+
const values = entries.map((e) => e.value).filter((v) => v.length >= 4).sort((a, b) => b.length - a.length);
|
|
55
|
+
const scrub = (message) => values.reduce((text, value) => text.split(value).join('[redacted]'), message);
|
|
56
|
+
for (const row of rows) {
|
|
57
|
+
if (row.action !== 'create' && row.action !== 'update')
|
|
58
|
+
continue;
|
|
59
|
+
const entry = byName.get(row.name);
|
|
60
|
+
const description = `Imported from ${source}${options.env ? ` for ${options.env}` : ''}`;
|
|
61
|
+
try {
|
|
62
|
+
if (row.action === 'create')
|
|
63
|
+
await store.create({ key: row.key, value: entry.value, description, ...(options.env ? { envs: [options.env] } : {}) });
|
|
64
|
+
else
|
|
65
|
+
await store.update(row.key, { value: entry.value, description });
|
|
66
|
+
done.set(row.key, row.action === 'create' ? 'created' : 'updated');
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
done.set(row.key, 'failed');
|
|
70
|
+
failures.push({ key: row.key, message: scrub(error instanceof Error ? error.message : String(error)) });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const description = describePlan(rows, source, Boolean(options.apply));
|
|
75
|
+
if (options.apply) {
|
|
76
|
+
for (const variable of description.variables) {
|
|
77
|
+
const outcome = done.get(String(variable.key));
|
|
78
|
+
if (outcome)
|
|
79
|
+
variable.result = outcome;
|
|
80
|
+
}
|
|
81
|
+
description.summary.failed = failures.length;
|
|
82
|
+
}
|
|
83
|
+
const result = { ...description, ...(failures.length ? { failures } : {}) };
|
|
84
|
+
return { rows, applied: Boolean(options.apply), failures, result };
|
|
85
|
+
}
|
|
86
|
+
/** A workspace that cannot be asked: used for a preview when nobody is logged in, so the file can still be scanned. It cannot be written to. */
|
|
87
|
+
const unreachableWorkspace = {
|
|
88
|
+
async keys() { return []; },
|
|
89
|
+
async create() { throw new Error('Not logged in: log in to save secrets to a workspace (ductape login)'); },
|
|
90
|
+
async update() { throw new Error('Not logged in: log in to save secrets to a workspace (ductape login)'); },
|
|
91
|
+
};
|
|
92
|
+
export async function runSecretsScanEnv(options) {
|
|
93
|
+
let store;
|
|
94
|
+
let asked = true;
|
|
95
|
+
try {
|
|
96
|
+
store = proxyStore();
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
// Saving needs a workspace. A preview does not: it can still say what the file holds and what would be saved.
|
|
100
|
+
if (options.apply)
|
|
101
|
+
throw error;
|
|
102
|
+
store = unreachableWorkspace;
|
|
103
|
+
asked = false;
|
|
104
|
+
}
|
|
105
|
+
const outcome = await scanEnvFile(options, store);
|
|
106
|
+
const result = asked
|
|
107
|
+
? outcome.result
|
|
108
|
+
: { ...outcome.result, workspace_checked: false, note: `${String(outcome.result.note)} You are not logged in, so the workspace was not asked which secrets it already has: anything it has is marked create here and would be left alone when saved.` };
|
|
109
|
+
printJson(result, Boolean(options.json));
|
|
110
|
+
if (outcome.failures.length > 0)
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
}
|
|
113
|
+
export { classifyEntry };
|
package/dist/index.js
CHANGED
|
@@ -23,17 +23,20 @@ import { runSessionsValidate } from './commands/sessions-validate.js';
|
|
|
23
23
|
import { runRateLimits } from './commands/rate-limits.js';
|
|
24
24
|
import { runDeploy } from './commands/deploy.js';
|
|
25
25
|
import { runDeployRemote } from './commands/deploy-remote.js';
|
|
26
|
+
import { runDeployWorker } from './commands/deploy-worker.js';
|
|
26
27
|
import { runDeployBuilds } from './commands/deploy-builds.js';
|
|
27
28
|
import { runDbSchemaGenerate, runDbSchemaPush } from './commands/db-schema.js';
|
|
28
29
|
import { runGraph } from './commands/graph.js';
|
|
29
30
|
import { runSecretImportEnv, runSecrets } from './commands/secrets.js';
|
|
31
|
+
import { runSecretsScanEnv } from './commands/secrets-scan.js';
|
|
30
32
|
import { runWorkspacesCurrent, runWorkspacesList, runWorkspacesRefresh, runWorkspacesUse, } from './commands/workspaces.js';
|
|
31
33
|
import { runGeneratePayload, runGenerateSnippet } from './commands/generate.js';
|
|
32
34
|
import { runCompletion } from './commands/completion.js';
|
|
33
35
|
import { runProducts, runProductApps, runProductAppActions, runProductComponents, runProductEnvironments } from './commands/products.js';
|
|
34
|
-
import { runApps } from './commands/apps.js';
|
|
36
|
+
import { runApps, runAppVersionRename } from './commands/apps.js';
|
|
35
37
|
import { runAppsImport } from './commands/apps-import.js';
|
|
36
38
|
import { runAppActions } from './commands/app-actions.js';
|
|
39
|
+
import { registerAppWebhooks } from './commands/app-webhooks.js';
|
|
37
40
|
import { runMarketplace } from './commands/marketplace.js';
|
|
38
41
|
import { runCapabilitySearch } from './commands/capabilities.js';
|
|
39
42
|
import { runApply } from './commands/apply.js';
|
|
@@ -107,22 +110,48 @@ const op = (operation) => wrap((...args) => {
|
|
|
107
110
|
return runDeployRemote(operation, { ...options, version: options.fnVersion, id: positional[0] });
|
|
108
111
|
});
|
|
109
112
|
remote('releases', 'register', 'Register an immutable release from a JSON file', (c) => c.requiredOption('--file <file>', 'Release JSON')).action(op('releases.register'));
|
|
113
|
+
remote('releases', 'publish-worker', 'Publish a Cloudflare Worker release: the bundle is stored in your own Cloudflare account (not kept by Ductape) and a release is registered from it', (c) => c.requiredOption('--file <file>', 'Release JSON: product, function, version, contract, config, verification (no image)')
|
|
114
|
+
.requiredOption('--connection <tag>', 'A Cloudflare connection made with the deploy scope')
|
|
115
|
+
.option('--bundle <file>', 'A bundle you built: one ES module with a default fetch handler')
|
|
116
|
+
.option('--entry <file>', 'Source to bundle here with esbuild (esbuild must be installed in the project)')).action(wrap((options) => runDeployWorker(options)));
|
|
117
|
+
remote('releases', 'list', 'List releases', (c) => c.option('--product <tag>').option('--function <name>', 'a function or service name').option('--fn-version <version>')).action(op('releases.list'));
|
|
118
|
+
remote('releases', 'get <releaseHash>', 'Show one release: its image, contract and configuration (secret references only, never values)').action(op('releases.get'));
|
|
119
|
+
remote('capabilities', 'show', 'Show what this control plane will do: whether changes are on, whether it reads your cloud itself, step-up and which clouds it can deploy to').action(op('capabilities'));
|
|
120
|
+
remote('connections', 'orphans <connection>', 'List what this workspace made in a cloud account (Google Cloud, AWS, Azure or Cloudflare) that no deployment accounts for (read only)', (c) => c.option('--region <region>')).action(op('orphans'));
|
|
121
|
+
const grantOption = (c) => c.option('--grant-env <VAR>', 'Name of the environment variable holding a step-up grant, when this server asks for an emailed code (see: deploy step-up)');
|
|
122
|
+
const codeTarget = (c) => c
|
|
123
|
+
.option('--plan <planId>', 'the code is for approving this plan')
|
|
124
|
+
.option('--retire', 'the code is for retiring a version (with --product --function --fn-version)')
|
|
125
|
+
.option('--policy', 'the code is for changing an environment\'s policy (with --product --env)')
|
|
126
|
+
.option('--scope <scope>', 'what the code is for, exactly as the server asks')
|
|
127
|
+
.option('--product <tag>').option('--function <name>').option('--fn-version <version>').option('--env <slug>');
|
|
128
|
+
remote('step-up', 'start', 'Email yourself a six-digit code for one change (a person only)', codeTarget).action(op('stepup.start'));
|
|
129
|
+
remote('step-up', 'verify', 'Check the code and print a grant, good for ten minutes and for that one change; put it in an environment variable and pass its name with --grant-env', (c) => codeTarget(c).requiredOption('--code <code>', 'the six-digit code from your email')).action(op('stepup.verify'));
|
|
110
130
|
remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON')).action(op('plans.create'));
|
|
111
|
-
remote('plans', 'approve <planId>', 'Approve a plan (a person only; refused for agents)').action(op('plans.approve'));
|
|
131
|
+
remote('plans', 'approve <planId>', 'Approve a plan (a person only; refused for agents)', grantOption).action(op('plans.approve'));
|
|
132
|
+
remote('plans', 'list', 'List plans with where each stands: blocked, pending_approval, approved, ready, applied or expired', (c) => c.option('--product <tag>').option('--env <env>').option('--stage <stage>')).action(op('plans.list'));
|
|
133
|
+
remote('plans', 'get <planId>', 'Show one plan: what it would change, its warnings and the state of the cloud it was made from').action(op('plans.get'));
|
|
112
134
|
remote('plans', 'apply <planId>', 'Apply an approved or permitted plan').action(op('plans.apply'));
|
|
113
|
-
remote('deployments', 'list', 'List deployments (functions and services)', (c) => c.option('--product <tag>').option('--env <env>').option('--fn-version <version>').option('--kind <kind>', 'function or service')).action(op('deployments.list'));
|
|
135
|
+
remote('deployments', 'list', 'List deployments (functions and services)', (c) => c.option('--product <tag>').option('--env <env>').option('--fn-version <version>').option('--kind <kind>', 'function or service').option('--connection <tag>', 'only what was applied through this cloud connection')).action(op('deployments.list'));
|
|
114
136
|
remote('deployments', 'get <deploymentId>', 'Show one deployment').action(op('deployments.get'));
|
|
115
137
|
remote('deployments', 'journal <deploymentId>', 'Show a deployment\'s journal').action(op('deployments.journal'));
|
|
138
|
+
const planFromDeployment = (c) => c
|
|
139
|
+
.option('--runtime-file <file>', 'Runtime settings JSON that replace the deployment\'s own (cpu, memory, minInstances, maxInstances ...)')
|
|
140
|
+
.option('--observed-file <file>', 'What the provider holds; only while the control plane does not read the provider itself');
|
|
141
|
+
remote('deployments', 'redeploy <deploymentId>', 'Plan running the deployment\'s current release again (retry a failed one); nothing changes until the plan is approved and applied', planFromDeployment).action(op('deployments.redeploy'));
|
|
142
|
+
remote('deployments', 'rollback <deploymentId>', 'Plan putting an earlier release back at full traffic (default: the last one that held all traffic)', (c) => planFromDeployment(c).option('--release-hash <hash>', 'A release this deployment has run')).action(op('deployments.rollback'));
|
|
143
|
+
remote('deployments', 'traffic <deploymentId>', 'Plan a new share of traffic for the current release', (c) => planFromDeployment(c).requiredOption('--percent <n>', 'A whole number from 0 to 100')).action(op('deployments.traffic'));
|
|
116
144
|
remote('environments', 'list', 'List a product\'s environments with how each is governed and what is deployed in it', (c) => c.requiredOption('--product <tag>')).action(op('environments.list'));
|
|
117
|
-
remote('environments', 'policy', 'Set whether applying to an environment needs a person\'s approval (a person only)', (c) => c.requiredOption('--product <tag>').requiredOption('--env <slug>').requiredOption('--require-approval <bool>', 'true: a person must approve each plan').requiredOption('--allow-agent-apply <bool>', 'true: an agent may apply without approval (ignored when approval is required)')).action(op('environments.policy'));
|
|
145
|
+
remote('environments', 'policy', 'Set whether applying to an environment needs a person\'s approval (a person only)', (c) => grantOption(c.requiredOption('--product <tag>').requiredOption('--env <slug>').requiredOption('--require-approval <bool>', 'true: a person must approve each plan').requiredOption('--allow-agent-apply <bool>', 'true: an agent may apply without approval (ignored when approval is required)'))).action(op('environments.policy'));
|
|
146
|
+
remote('environments', 'history', 'Show who changed how an environment is governed, and when', (c) => c.requiredOption('--product <tag>').requiredOption('--env <slug>')).action(op('environments.history'));
|
|
118
147
|
remote('functions', 'list', 'List functions and services with their latest available version', (c) => c.option('--product <tag>').option('--kind <kind>', 'function or service')).action(op('functions.list'));
|
|
119
148
|
const versionTarget = (c) => c.requiredOption('--product <tag>').requiredOption('--function <name>');
|
|
120
149
|
remote('versions', 'list', 'List the versions of a function', versionTarget).action(op('versions.list'));
|
|
121
150
|
remote('versions', 'history', 'Show what happened to a version', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.history'));
|
|
122
151
|
remote('versions', 'deprecate', 'Deprecate a version (existing deployments keep serving)', (c) => versionTarget(c).requiredOption('--fn-version <version>').requiredOption('--reason <text>').option('--sunset <iso-date>').option('--replacement <version>')).action(op('versions.deprecate'));
|
|
123
152
|
remote('versions', 'undeprecate', 'Make a deprecated version available again', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.undeprecate'));
|
|
124
|
-
remote('versions', 'retire', 'Retire a deprecated version that is no longer serving (a person only; final)', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.retire'));
|
|
125
|
-
remote('builds', 'create', 'Build source in your own cloud account and register a release from the image', (c) => c.requiredOption('--file <file>', 'Build JSON. A function:
|
|
153
|
+
remote('versions', 'retire', 'Retire a deprecated version that is no longer serving (a person only; final)', (c) => grantOption(versionTarget(c).requiredOption('--fn-version <version>'))).action(op('versions.retire'));
|
|
154
|
+
remote('builds', 'create', 'Build source in your own cloud account and register a release from the image', (c) => c.requiredOption('--file <file>', 'Build JSON. A function: product, function, version, connection, region, contract, config, verification. A service: kind "service", product, service, version, connection, region, port, checks, config')
|
|
126
155
|
.option('--dir <dir>', 'Source directory (default: the current directory)')
|
|
127
156
|
.option('--builder <builder>', 'dockerfile (default) or buildpacks')
|
|
128
157
|
.option('--dockerfile <path>', 'Dockerfile inside the source (default: Dockerfile)')
|
|
@@ -130,7 +159,8 @@ remote('builds', 'create', 'Build source in your own cloud account and register
|
|
|
130
159
|
.option('--wait', 'Wait for the build to finish')
|
|
131
160
|
.option('--wait-minutes <n>', 'How long --wait waits (default 30)')).action(wrap((options) => runDeployBuilds('create', options)));
|
|
132
161
|
remote('builds', 'status <buildId>', 'Show a build').action(wrap((...args) => runDeployBuilds('status', { id: args[0] })));
|
|
133
|
-
remote('builds', '
|
|
162
|
+
remote('builds', 'cancel <buildId>', 'Stop a build that has not finished; a running one is cancelled in your cloud account').action(wrap((...args) => runDeployBuilds('cancel', { id: args[0] })));
|
|
163
|
+
remote('builds', 'list', 'List builds', (c) => c.option('--product <tag>').option('--status <status>').option('--connection <tag>', 'only builds that ran through this cloud connection')).action(wrap((options) => runDeployBuilds('list', options)));
|
|
134
164
|
program
|
|
135
165
|
.name('ductape')
|
|
136
166
|
.description('Ductape CLI — local platform, auth, project linking, and resource CRUD via Workbench-compatible encrypted proxy')
|
|
@@ -175,8 +205,10 @@ program
|
|
|
175
205
|
.action(wrap((opts) => runWhoami(Boolean(opts.json))));
|
|
176
206
|
program
|
|
177
207
|
.command('install')
|
|
178
|
-
.description('
|
|
179
|
-
.
|
|
208
|
+
.description('Install the Ductape platform on this machine: write its compose files and settings, and pull the images')
|
|
209
|
+
.option('--tag <tag>', 'Install this release of the images instead of latest')
|
|
210
|
+
.option('--no-pull', 'Do not pull images: use the ones already on this machine (for images you built yourself)')
|
|
211
|
+
.action(wrap((opts) => runInstall(opts)));
|
|
180
212
|
const profiles = program.command('profiles').description('Manage API profiles (cloud / local)');
|
|
181
213
|
profiles
|
|
182
214
|
.command('list')
|
|
@@ -730,7 +762,7 @@ const apps = program
|
|
|
730
762
|
.option('--profile <name>')
|
|
731
763
|
.option('--status <status>', 'Filter for list', 'all')
|
|
732
764
|
.option('--id <id>', 'App _id')
|
|
733
|
-
.option('-t, --tag <tag>', 'App tag (get; update with --proxy)')
|
|
765
|
+
.option('-t, --tag <tag>', 'App tag (get, delete; update with --proxy)')
|
|
734
766
|
.option('--proxy', 'Update via sdk-proxy (use with --tag)')
|
|
735
767
|
.option('-f, --file <path>', 'JSON body')
|
|
736
768
|
.option('-i, --interactive', 'Prompt for fields (default in TTY when -f omitted)')
|
|
@@ -741,6 +773,14 @@ const apps = program
|
|
|
741
773
|
throw new Error('Specify a verb: list | get | create | update | delete');
|
|
742
774
|
return runApps(verb, opts, []);
|
|
743
775
|
}));
|
|
776
|
+
apps.command('rename-version')
|
|
777
|
+
.description('Rename a version label atomically without changing its contents')
|
|
778
|
+
.requiredOption('--id <id>', 'App ID')
|
|
779
|
+
.requiredOption('--from <label>', 'Existing version label')
|
|
780
|
+
.requiredOption('--to <label>', 'New, unused version label')
|
|
781
|
+
.option('--profile <name>')
|
|
782
|
+
.option('--json', 'JSON output')
|
|
783
|
+
.action(wrap((opts) => runAppVersionRename(opts)));
|
|
744
784
|
apps
|
|
745
785
|
.command('import <file>')
|
|
746
786
|
.description('Import Postman v2.1 or OpenAPI 3.0 into a new or existing app')
|
|
@@ -749,7 +789,7 @@ apps
|
|
|
749
789
|
.option('--app-id <id>', 'Update existing app by _id')
|
|
750
790
|
.option('--app-tag <tag>', 'Update existing app by tag')
|
|
751
791
|
.option('--update', 'Replace/update if app already exists')
|
|
752
|
-
.
|
|
792
|
+
.requiredOption('--version <tag>', 'Verified provider API version or explicit integration revision (no automatic default)')
|
|
753
793
|
.option('--json', 'JSON output')
|
|
754
794
|
.action(wrap((file, opts) => runAppsImport(file, {
|
|
755
795
|
profile: opts.profile,
|
|
@@ -762,6 +802,7 @@ apps
|
|
|
762
802
|
})));
|
|
763
803
|
const appActions = apps.command('actions').description("An app's own actions (endpoints). resource is a path relative to each of the app's " +
|
|
764
804
|
'environment base_urls (e.g. "/v1/users/{id}"), not a full URL.');
|
|
805
|
+
registerAppWebhooks(apps, wrap);
|
|
765
806
|
appActions
|
|
766
807
|
.command('list')
|
|
767
808
|
.requiredOption('--app <tag>', 'App tag')
|
|
@@ -863,23 +904,53 @@ cloud
|
|
|
863
904
|
.command('connections <verb> [id]')
|
|
864
905
|
.description('Cloud connections: guide | create | complete | validate | list | fetch | update | delete. Secrets come from files or environment variables, never from flags.')
|
|
865
906
|
.option('-f, --file <path>', 'JSON body (flags below override it)')
|
|
866
|
-
.option('--provider <name>', 'aws | gcp | azure | mongodb_atlas | neo4j_aura (create, guide)')
|
|
907
|
+
.option('--provider <name>', 'aws | gcp | azure | cloudflare | mongodb_atlas | neo4j_aura (create, guide)')
|
|
867
908
|
.option('--purpose <purpose>', 'guide: "resources" (default) or "deploy"')
|
|
868
909
|
.option('--name <name>', 'Display name (create, update)')
|
|
869
910
|
.option('--tag <tag>', 'Connection tag (create)')
|
|
870
911
|
.option('--description <text>', 'Description (create, update)')
|
|
871
912
|
.option('--scopes <list>', 'Comma-separated scopes (create, update)')
|
|
872
913
|
.option('--auth-mode <mode>', 'iam_role | oauth | service_principal | workload_identity | api_key (create)')
|
|
873
|
-
.option('--deploy', 'Add the "deploy" scope so validation checks Ductape Deploy permissions (GCP, create)')
|
|
914
|
+
.option('--deploy', 'Add the "deploy" scope so validation checks Ductape Deploy permissions (GCP, AWS, Azure and Cloudflare, create)')
|
|
874
915
|
.option('--project-id <id>', 'GCP or Atlas project id (complete)')
|
|
875
916
|
.option('--service-account-file <path>', 'GCP service account key file; read from disk, never printed (complete)')
|
|
876
917
|
.option('--runtime-service-account <email>', 'GCP account the deployed services run as (complete)')
|
|
877
|
-
.option('--role-arn <arn>', 'AWS IAM role ARN (complete)')
|
|
918
|
+
.option('--role-arn <arn>', 'AWS IAM role ARN Ductape assumes (complete)')
|
|
919
|
+
.option('--runtime-role-arn <arn>', 'AWS role the deployed functions run as (complete)')
|
|
920
|
+
.option('--build-role-arn <arn>', 'AWS role the builds run as (complete)')
|
|
921
|
+
.option('--default-region <region>', 'AWS region used when none is given, such as eu-west-2 (complete)')
|
|
922
|
+
.option('--save-template <file>', 'create, get: write the AWS (CloudFormation) or Azure (deployment) setup template to this file')
|
|
923
|
+
.option('--save-fargate-template <file>', 'create, get: write the AWS Fargate setup stack (CloudFormation) to this file')
|
|
924
|
+
.option('--save-express-template <file>', 'create, get: write the AWS ECS Express Mode stack (CloudFormation) to this file')
|
|
925
|
+
.option('--express-infrastructure-role-arn <arn>', 'AWS ECS Express Mode: the role AWS uses to build the load balancer (complete)')
|
|
926
|
+
.option('--express-outputs-file <file>', 'AWS ECS Express Mode: the saved output of `aws cloudformation describe-stacks --stack-name ductape-ecs-express` (complete)')
|
|
927
|
+
.option('--fargate-outputs-file <file>', 'AWS Fargate: the saved output of `aws cloudformation describe-stacks --stack-name ductape-fargate` (complete)')
|
|
928
|
+
.option('--fargate-cluster <name>', 'AWS Fargate: ECS cluster name (complete)')
|
|
929
|
+
.option('--fargate-listener-arn <arn>', 'AWS Fargate: ARN of the HTTPS listener of the load balancer (complete)')
|
|
930
|
+
.option('--fargate-base-domain <domain>', 'AWS Fargate: the domain every deployment is a name under, such as deploy.example.com (complete)')
|
|
931
|
+
.option('--fargate-vpc-id <id>', 'AWS Fargate: VPC id (complete)')
|
|
932
|
+
.option('--fargate-subnets <list>', 'AWS Fargate: comma-separated subnet ids (complete)')
|
|
933
|
+
.option('--fargate-security-groups <list>', 'AWS Fargate: comma-separated security group ids for the tasks (complete)')
|
|
934
|
+
.option('--fargate-task-role-arn <arn>', 'AWS Fargate: role the tasks run as (complete)')
|
|
935
|
+
.option('--fargate-execution-role-arn <arn>', 'AWS Fargate: role ECS uses to pull images and read secrets (complete)')
|
|
936
|
+
.option('--fargate-log-group <name>', 'AWS Fargate: CloudWatch log group for the tasks (complete)')
|
|
937
|
+
.option('--fargate-scale-down-idle <on|off>', 'AWS Fargate: scale releases that no longer serve to zero tasks, never deleting them (complete)')
|
|
938
|
+
.option('--fargate-internal <on|off>', 'AWS Fargate: the load balancer is internal, so releases are checked through the relay function (complete)')
|
|
939
|
+
.option('--fargate-verifier-function <name>', 'AWS Fargate: the relay function inside your network, the stack output VerifierFunctionName (complete)')
|
|
940
|
+
.option('--fargate-private-tasks', 'AWS Fargate: tasks run in private subnets with no public address (complete)')
|
|
878
941
|
.option('--tenant-id <id>', 'Azure tenant id (complete)')
|
|
879
942
|
.option('--subscription-id <id>', 'Azure subscription id (complete)')
|
|
880
943
|
.option('--client-id <id>', 'Azure client id (complete)')
|
|
881
944
|
.option('--client-secret-env <VAR>', 'Name of the environment variable holding the Azure client secret (complete)')
|
|
882
945
|
.option('--default-location <region>', 'Azure default location (complete)')
|
|
946
|
+
.option('--account-id <id>', 'Cloudflare account id, 32 characters (complete)')
|
|
947
|
+
.option('--secrets-store-id <id>', 'Cloudflare Secrets Store that { secret: NAME } references are bound from (complete)')
|
|
948
|
+
.option('--api-token-env <VAR>', 'Name of the environment variable holding the Cloudflare API token (complete)')
|
|
949
|
+
.option('--resource-group <name>', 'Azure resource group Ductape Deploy works in (complete)')
|
|
950
|
+
.option('--registry-name <name>', 'Azure container registry from the setup template (complete)')
|
|
951
|
+
.option('--runtime-identity-id <id>', 'Azure user assigned identity id the apps run as (complete)')
|
|
952
|
+
.option('--key-vault-uri <uri>', 'Azure Key Vault that { secret: NAME } references are read from by the app\'s identity (complete)')
|
|
953
|
+
.option('--environment-name <name>', 'Azure container apps environment from the setup template (complete)')
|
|
883
954
|
.option('--atlas-public-key <key>', 'Atlas API public key (complete)')
|
|
884
955
|
.option('--atlas-private-key-env <VAR>', 'Name of the environment variable holding the Atlas private key (complete)')
|
|
885
956
|
.option('--aura-client-id <id>', 'Aura client id (complete)')
|
|
@@ -887,11 +958,12 @@ cloud
|
|
|
887
958
|
.option('--aura-instance-id <id>', 'Aura instance id (complete)')
|
|
888
959
|
.option('--dry-run', 'create, complete, update: print the request that would be sent, with secrets masked, and contact nothing')
|
|
889
960
|
.option('--json', 'JSON output')
|
|
890
|
-
.action(wrap((verb, id, opts) => runCloud('connections', verb, { id, file: opts.file, json: opts.json, purpose: opts.purpose, dryRun: Boolean(opts.dryRun), connection: {
|
|
961
|
+
.action(wrap((verb, id, opts) => runCloud('connections', verb, { id, file: opts.file, json: opts.json, purpose: opts.purpose, saveTemplate: opts.saveTemplate, saveFargateTemplate: opts.saveFargateTemplate, saveExpressTemplate: opts.saveExpressTemplate, dryRun: Boolean(opts.dryRun), connection: {
|
|
891
962
|
provider: opts.provider, name: opts.name, tag: opts.tag, description: opts.description, scopes: opts.scopes, authMode: opts.authMode,
|
|
892
963
|
deploy: opts.deploy, projectId: opts.projectId, serviceAccountFile: opts.serviceAccountFile, runtimeServiceAccount: opts.runtimeServiceAccount,
|
|
893
|
-
|
|
894
|
-
|
|
964
|
+
fargateOutputsFile: opts.fargateOutputsFile, fargateInternal: opts.fargateInternal, fargateVerifierFunction: opts.fargateVerifierFunction, fargateCluster: opts.fargateCluster, fargateListenerArn: opts.fargateListenerArn, fargateBaseDomain: opts.fargateBaseDomain, fargateVpcId: opts.fargateVpcId, fargateSubnets: opts.fargateSubnets, fargateSecurityGroups: opts.fargateSecurityGroups, fargateTaskRoleArn: opts.fargateTaskRoleArn, fargateExecutionRoleArn: opts.fargateExecutionRoleArn, fargateLogGroup: opts.fargateLogGroup, fargatePrivateTasks: opts.fargatePrivateTasks, fargateScaleDownIdle: opts.fargateScaleDownIdle, expressInfrastructureRoleArn: opts.expressInfrastructureRoleArn, expressOutputsFile: opts.expressOutputsFile,
|
|
965
|
+
roleArn: opts.roleArn, runtimeRoleArn: opts.runtimeRoleArn, buildRoleArn: opts.buildRoleArn, defaultRegion: opts.defaultRegion, tenantId: opts.tenantId, subscriptionId: opts.subscriptionId, clientId: opts.clientId, clientSecretEnv: opts.clientSecretEnv,
|
|
966
|
+
defaultLocation: opts.defaultLocation, accountId: opts.accountId, apiTokenEnv: opts.apiTokenEnv, secretsStoreId: opts.secretsStoreId, resourceGroup: opts.resourceGroup, registryName: opts.registryName, runtimeIdentityId: opts.runtimeIdentityId, environmentName: opts.environmentName, keyVaultUri: opts.keyVaultUri, atlasPublicKey: opts.atlasPublicKey, atlasPrivateKeyEnv: opts.atlasPrivateKeyEnv,
|
|
895
967
|
auraClientId: opts.auraClientId, auraClientSecretEnv: opts.auraClientSecretEnv, auraInstanceId: opts.auraInstanceId,
|
|
896
968
|
} }, [])));
|
|
897
969
|
cloud
|
|
@@ -1109,6 +1181,25 @@ program
|
|
|
1109
1181
|
description: opts.description,
|
|
1110
1182
|
json: Boolean(opts.json),
|
|
1111
1183
|
})));
|
|
1184
|
+
program
|
|
1185
|
+
.command('secrets-scan-env')
|
|
1186
|
+
.description('Scan a project\'s .env file, find the secrets in it, and save them to the workspace (preview unless --apply; values are never printed)')
|
|
1187
|
+
.option('--env-file <path>', 'The file to read (default: .env in the project folder)')
|
|
1188
|
+
.option('--dir <path>', 'The project folder (default: the current folder)')
|
|
1189
|
+
.option('--env <slug>', 'Limit the saved secrets to this environment (default: every environment)')
|
|
1190
|
+
.option('--all', 'Save every variable that has a real value, not only the ones that look like secrets')
|
|
1191
|
+
.option('--only <names>', 'Save exactly these variables (comma separated), whatever they look like')
|
|
1192
|
+
.option('--exclude <names>', 'Never save these variables (comma separated)')
|
|
1193
|
+
.option('--prefix <text>', 'Put this in front of each name to make the secret\'s key')
|
|
1194
|
+
.option('--overwrite', 'Replace a secret the workspace already has (default: leave it)')
|
|
1195
|
+
.option('--apply', 'Save them. Without it nothing is saved and the result says what would be')
|
|
1196
|
+
.option('--json', 'JSON output (names, decisions and lengths only)')
|
|
1197
|
+
.action(wrap((opts) => runSecretsScanEnv({
|
|
1198
|
+
envFile: opts.envFile, dir: opts.dir, env: opts.env, all: Boolean(opts.all), overwrite: Boolean(opts.overwrite), apply: Boolean(opts.apply), prefix: opts.prefix,
|
|
1199
|
+
only: opts.only ? String(opts.only).split(',').map((s) => s.trim()).filter(Boolean) : undefined,
|
|
1200
|
+
exclude: opts.exclude ? String(opts.exclude).split(',').map((s) => s.trim()).filter(Boolean) : undefined,
|
|
1201
|
+
json: Boolean(opts.json),
|
|
1202
|
+
})));
|
|
1112
1203
|
const generate = program.command('generate').description('Payload templates & code snippets');
|
|
1113
1204
|
generate
|
|
1114
1205
|
.command('payload <family> <method>')
|
package/dist/lib/api-client.js
CHANGED
|
@@ -13,8 +13,10 @@ export class ApiClient {
|
|
|
13
13
|
}
|
|
14
14
|
async request(method, path, body, extraHeaders) {
|
|
15
15
|
const url = `${this.apiUrl}${path.startsWith('/') ? path : `/${path}`}`;
|
|
16
|
+
// Bytes (a Worker bundle) are sent as they are; everything else is JSON.
|
|
17
|
+
const raw = body instanceof Uint8Array;
|
|
16
18
|
const headers = {
|
|
17
|
-
'Content-Type': 'application/json',
|
|
19
|
+
'Content-Type': raw ? 'application/octet-stream' : 'application/json',
|
|
18
20
|
...extraHeaders,
|
|
19
21
|
};
|
|
20
22
|
if (this.token) {
|
|
@@ -25,7 +27,7 @@ export class ApiClient {
|
|
|
25
27
|
res = await fetch(url, {
|
|
26
28
|
method,
|
|
27
29
|
headers,
|
|
28
|
-
body: body
|
|
30
|
+
body: body === undefined ? undefined : raw ? body : JSON.stringify(body),
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
catch (cause) {
|
package/dist/lib/app-import.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const IMPORT_DOC_TYPES: {
|
|
|
5
5
|
readonly openapi: "OpenApiV3.0";
|
|
6
6
|
};
|
|
7
7
|
export type ImportFormat = keyof typeof IMPORT_DOC_TYPES;
|
|
8
|
+
export declare function requireImportVersion(version?: string): string;
|
|
8
9
|
export declare function parseImportFormat(value: string): ImportFormat;
|
|
9
10
|
export declare function importAppFromFile(ctx: WorkspaceContext, opts: {
|
|
10
11
|
filePath: string;
|