grada-run 0.40.15 → 0.40.17
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/bin/cli.js +22 -18
- package/package.json +1 -1
- package/src/commands/add.js +70 -3
- package/src/commands/alerts.js +6 -3
- package/src/commands/apply.js +6 -3
- package/src/commands/db/backup.js +5 -2
- package/src/commands/db/connect.js +6 -3
- package/src/commands/db/enable-vector.js +5 -2
- package/src/commands/db/import.js +5 -2
- package/src/commands/db/migrate.js +38 -30
- package/src/commands/db/restore.js +5 -2
- package/src/commands/destroy.js +6 -3
- package/src/commands/doctor.js +5 -1
- package/src/commands/domain.js +5 -2
- package/src/commands/drift.js +6 -3
- package/src/commands/eject.js +5 -2
- package/src/commands/exec.js +6 -2
- package/src/commands/gc.js +6 -3
- package/src/commands/init.js +6 -3
- package/src/commands/logs.js +6 -2
- package/src/commands/mcp.js +5 -2
- package/src/commands/rollback.js +6 -3
- package/src/commands/sleep.js +5 -2
- package/src/commands/status.js +6 -2
- package/src/commands/wake.js +6 -3
- package/src/core/parser.js +16 -5
- package/src/utils/args.js +11 -5
- package/src/utils/aws.js +11 -4
- package/src/utils/command.js +20 -0
- package/src/utils/hcl.js +22 -0
- package/templates/github/deploy-lambda.yml +7 -0
- package/templates/github/deploy-static.yml +7 -0
- package/templates/github/deploy.yml +7 -0
- package/templates/github/drift.yml +4 -1
- package/templates/github/preview-lambda.yml +8 -1
- package/templates/github/preview.yml +12 -4
- package/templates/github/teardown.yml +16 -1
- package/templates/terraform/addons/redis.tf +2 -2
- package/templates/terraform/database-aurora-postgresql.tf +2 -12
- package/templates/terraform/database-mysql.tf +2 -12
- package/templates/terraform/database.tf +2 -12
- package/templates/terraform/main.tf +1 -1
- package/templates/terraform/network.tf +30 -6
package/bin/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ import { runDrift, parseDriftArgs } from '../src/commands/drift.js';
|
|
|
23
23
|
import { runAlerts, parseAlertsArgs } from '../src/commands/alerts.js';
|
|
24
24
|
import { runMcp, parseMcpArgs } from '../src/commands/mcp.js';
|
|
25
25
|
import { runTelemetry } from '../src/commands/telemetry.js';
|
|
26
|
-
import { parseCliArgs } from '../src/core/parser.js';
|
|
26
|
+
import { parseCliArgs, stripGlobalOnlyFlags } from '../src/core/parser.js';
|
|
27
27
|
import { getCliVersion } from '../src/core/telemetry.js';
|
|
28
28
|
|
|
29
29
|
const HELP_TEXT = [
|
|
@@ -77,6 +77,10 @@ const HELP_TEXT = [
|
|
|
77
77
|
|
|
78
78
|
const rawArgs = process.argv.slice(2);
|
|
79
79
|
const parsed = parseCliArgs(rawArgs);
|
|
80
|
+
// Per-command parsers see everything except globally-honored flags:
|
|
81
|
+
// --no-telemetry already took effect via DO_NOT_TRACK, and the
|
|
82
|
+
// unknown-flag gate would otherwise reject it on every command.
|
|
83
|
+
const commandArgs = stripGlobalOnlyFlags(rawArgs);
|
|
80
84
|
|
|
81
85
|
if (parsed.hasNoTelemetry) {
|
|
82
86
|
process.env.DO_NOT_TRACK = '1';
|
|
@@ -138,43 +142,43 @@ if (wantsVersion) {
|
|
|
138
142
|
const projectName = path.basename(process.cwd());
|
|
139
143
|
runCommand(auditSecrets(envFile, projectName, { region: parseRegionFlag(rawArgs) }));
|
|
140
144
|
} else if (dispatchCommand === 'apply') {
|
|
141
|
-
runCommand(applyStack({ ...parseApplyArgs(
|
|
145
|
+
runCommand(applyStack({ ...parseApplyArgs(commandArgs), isDryRun, ...(autoApprove ? { autoApprove: true } : {}), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
142
146
|
} else if (positionalArgs[0] === 'doctor') {
|
|
143
|
-
runCommand(runDoctor({ ...parseDoctorArgs(
|
|
147
|
+
runCommand(runDoctor({ ...parseDoctorArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
144
148
|
} else if (positionalArgs[0] === 'destroy') {
|
|
145
|
-
runCommand(destroyStack({ ...parseDestroyArgs(
|
|
149
|
+
runCommand(destroyStack({ ...parseDestroyArgs(commandArgs), ...(confirmYes ? { yes: true } : {}), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
146
150
|
} else if (positionalArgs[0] === 'eject') {
|
|
147
|
-
runCommand(ejectStack({ ...parseEjectArgs(
|
|
151
|
+
runCommand(ejectStack({ ...parseEjectArgs(commandArgs), ...(confirmYes ? { yes: true } : {}), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
148
152
|
} else if (positionalArgs[0] === 'sync-ai') {
|
|
149
153
|
runCommand(syncAi());
|
|
150
154
|
} else if (positionalArgs[0] === 'diagnose' || positionalArgs[0] === 'wtf') {
|
|
151
155
|
runCommand(runDiagnose(headlessOptions));
|
|
152
156
|
} else if (positionalArgs[0] === 'logs') {
|
|
153
|
-
runCommand(runLogs(parseLogsArgs(
|
|
157
|
+
runCommand(runLogs({ ...parseLogsArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
154
158
|
} else if (positionalArgs[0] === 'status') {
|
|
155
|
-
runCommand(runStatus(parseStatusArgs(
|
|
159
|
+
runCommand(runStatus({ ...parseStatusArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
156
160
|
} else if (positionalArgs[0] === 'rollback') {
|
|
157
|
-
runCommand(runRollback({ ...parseRollbackArgs(
|
|
161
|
+
runCommand(runRollback({ ...parseRollbackArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
158
162
|
} else if (positionalArgs[0] === 'exec') {
|
|
159
|
-
runCommand(runExec(parseExecArgs(
|
|
163
|
+
runCommand(runExec({ ...parseExecArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
160
164
|
} else if (positionalArgs[0] === 'db') {
|
|
161
|
-
runCommand(runDb(
|
|
165
|
+
runCommand(runDb(commandArgs, { ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
162
166
|
} else if (positionalArgs[0] === 'gc') {
|
|
163
|
-
runCommand(runGc(parseGcArgs(
|
|
167
|
+
runCommand(runGc({ ...parseGcArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
164
168
|
} else if (positionalArgs[0] === 'add') {
|
|
165
|
-
runCommand(runAdd(parseAddArgs(
|
|
169
|
+
runCommand(runAdd(parseAddArgs(commandArgs)));
|
|
166
170
|
} else if (positionalArgs[0] === 'domain') {
|
|
167
|
-
runCommand(runDomain(parseDomainArgs(
|
|
171
|
+
runCommand(runDomain(parseDomainArgs(commandArgs)));
|
|
168
172
|
} else if (positionalArgs[0] === 'sleep') {
|
|
169
|
-
runCommand(runSleep({ ...parseSleepArgs(
|
|
173
|
+
runCommand(runSleep({ ...parseSleepArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
170
174
|
} else if (positionalArgs[0] === 'wake') {
|
|
171
|
-
runCommand(runWake({ ...parseWakeArgs(
|
|
175
|
+
runCommand(runWake({ ...parseWakeArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
172
176
|
} else if (positionalArgs[0] === 'drift') {
|
|
173
|
-
runCommand(runDrift({ ...parseDriftArgs(
|
|
177
|
+
runCommand(runDrift({ ...parseDriftArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
174
178
|
} else if (positionalArgs[0] === 'alerts') {
|
|
175
|
-
runCommand(runAlerts({ ...parseAlertsArgs(
|
|
179
|
+
runCommand(runAlerts({ ...parseAlertsArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
176
180
|
} else if (positionalArgs[0] === 'mcp') {
|
|
177
|
-
runCommand(runMcp(parseMcpArgs(
|
|
181
|
+
runCommand(runMcp({ ...parseMcpArgs(commandArgs), ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
178
182
|
} else if (positionalArgs[0] === 'telemetry') {
|
|
179
183
|
runCommand(runTelemetry({ subcommand: positionalArgs[1], ...(isHeadless ? { isHeadless: true } : {}) }));
|
|
180
184
|
} else if (positionalArgs[0] === undefined || positionalArgs[0] === 'init') {
|
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -11,8 +11,8 @@ import { ADDON_REGISTRY, ADDON_UPSERT_KEYS, resolveAddonEnvVars, addonTargetDisp
|
|
|
11
11
|
import { stripTerraformMetadata, readEjectedMarker } from '../utils/terraform-metadata.js';
|
|
12
12
|
import { normalizeDomain, isValidDomain, normalizeZoneId, isValidFromEmail, parseDomainTf } from '../utils/domains.js';
|
|
13
13
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
|
|
14
|
-
import { failCommand, failProjectNotInitialized, isProgrammaticCall, refuseIfNonInteractive } from '../utils/command.js';
|
|
15
|
-
import { findArrayBounds, findMapBounds, findNestedBlock, findResourceBlock, enclosingBraceBounds, normalizeBlankLines, realignAssignmentRuns } from '../utils/hcl.js';
|
|
14
|
+
import { failCommand, failProjectNotInitialized, isProgrammaticCall, refuseIfNonInteractive, refuseUnknownFlags } from '../utils/command.js';
|
|
15
|
+
import { findArrayBounds, findMapBounds, findNestedBlock, findResourceBlock, removeResourceBlock, enclosingBraceBounds, normalizeBlankLines, realignAssignmentRuns } from '../utils/hcl.js';
|
|
16
16
|
import { syncDocCostEstimate } from '../utils/visualizer.js';
|
|
17
17
|
import { withProjectLock } from '../utils/file-lock.js';
|
|
18
18
|
import { guardSleepingEnv, resolveSleepTarget } from '../utils/sleep-state.js';
|
|
@@ -76,7 +76,7 @@ export const DB_ADD_ENGINES = {
|
|
|
76
76
|
export function parseAddArgs(argv = []) {
|
|
77
77
|
const args = normalizeArgv(argv);
|
|
78
78
|
if (args[0] === 'add') args.shift();
|
|
79
|
-
const { options: parsed, rest } = parseFlags(args, {
|
|
79
|
+
const { options: parsed, rest, unknown } = parseFlags(args, {
|
|
80
80
|
string: ['region', 'project-name', 'partition-key', 'model', 'domain', 'from-email', 'zone-id', 'schedule', { name: 'cmd', key: 'cronCommand' }, { name: 'cron-command', key: 'cronCommand' }, 'name', 'timezone'],
|
|
81
81
|
boolean: ['force', { name: 'headless', key: 'isHeadless' }],
|
|
82
82
|
bareBoolean: ['list-models', 'refresh'],
|
|
@@ -92,6 +92,7 @@ export function parseAddArgs(argv = []) {
|
|
|
92
92
|
...parsed,
|
|
93
93
|
};
|
|
94
94
|
if (parsed.model !== undefined) options.modelProvided = true;
|
|
95
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
95
96
|
for (const arg of rest) {
|
|
96
97
|
if (typeof arg === 'string' && !arg.startsWith('-') && options.capability === undefined) {
|
|
97
98
|
options.capability = arg;
|
|
@@ -460,6 +461,58 @@ export const LAMBDA_VPC_CONFIG_BLOCK = ` vpc_config {
|
|
|
460
461
|
security_group_ids = [aws_security_group.ecs_tasks.id]
|
|
461
462
|
}`;
|
|
462
463
|
|
|
464
|
+
// Isolated subnets shared by every data-plane subnet group (RDS,
|
|
465
|
+
// ElastiCache). network.tf carries this block on new trees; `add` backfills
|
|
466
|
+
// it for trees generated before it moved out of database.tf (which only
|
|
467
|
+
// existed alongside a database).
|
|
468
|
+
export const ISOLATED_SUBNETS_BLOCK = `# Isolated Subnets (No Internet Gateway routing). Shared by every
|
|
469
|
+
# data-plane subnet group (RDS, ElastiCache).
|
|
470
|
+
resource "aws_subnet" "db_isolated" {
|
|
471
|
+
count = 2
|
|
472
|
+
vpc_id = aws_vpc.main.id
|
|
473
|
+
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
|
|
474
|
+
availability_zone = data.aws_availability_zones.available.names[count.index]
|
|
475
|
+
|
|
476
|
+
tags = {
|
|
477
|
+
Name = "\${local.app_name}-db-isolated-\${count.index}"
|
|
478
|
+
}
|
|
479
|
+
}`;
|
|
480
|
+
|
|
481
|
+
// Idempotently appends the isolated-subnet block to network.tf content.
|
|
482
|
+
// Returns the content unchanged when the block already exists. Uses the
|
|
483
|
+
// HCL-aware lookup so a comment quoting the header never false-positives.
|
|
484
|
+
export function ensureIsolatedSubnets(networkTfContent) {
|
|
485
|
+
const content = String(networkTfContent ?? '');
|
|
486
|
+
if (findResourceBlock(content, 'aws_subnet', 'db_isolated')) return content;
|
|
487
|
+
const prefix = content.endsWith('\n') ? content : `${content}\n`;
|
|
488
|
+
return `${prefix}\n${ISOLATED_SUBNETS_BLOCK}\n`;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Backfills the isolated-subnet block into a tree whose network.tf predates
|
|
492
|
+
// it. Legacy trees carry the block in database.tf instead: it is migrated
|
|
493
|
+
// (same state address — no state move needed), never duplicated. No-op
|
|
494
|
+
// when network.tf is missing (static), already has the block, or an
|
|
495
|
+
// unexpected file declares it. Returns true when network.tf was written.
|
|
496
|
+
async function backfillIsolatedSubnets(projectDir) {
|
|
497
|
+
const tfDir = path.join(projectDir, 'terraform');
|
|
498
|
+
const networkTfPath = path.join(tfDir, 'network.tf');
|
|
499
|
+
if (!fsSync.existsSync(networkTfPath)) return false;
|
|
500
|
+
const before = await fs.readFile(networkTfPath, 'utf-8');
|
|
501
|
+
if (findResourceBlock(before, 'aws_subnet', 'db_isolated')) return false;
|
|
502
|
+
for (const file of fsSync.readdirSync(tfDir).filter((f) => f.endsWith('.tf'))) {
|
|
503
|
+
if (file === 'network.tf') continue;
|
|
504
|
+
const filePath = path.join(tfDir, file);
|
|
505
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
506
|
+
if (!findResourceBlock(content, 'aws_subnet', 'db_isolated')) continue;
|
|
507
|
+
if (file !== 'database.tf') return false;
|
|
508
|
+
await atomicWriteFile(filePath, normalizeBlankLines(removeResourceBlock(content, 'aws_subnet', 'db_isolated')));
|
|
509
|
+
}
|
|
510
|
+
const after = ensureIsolatedSubnets(before);
|
|
511
|
+
if (after === before) return false;
|
|
512
|
+
await atomicWriteFile(networkTfPath, normalizeBlankLines(after));
|
|
513
|
+
return true;
|
|
514
|
+
}
|
|
515
|
+
|
|
463
516
|
// Idempotently attaches `vpc_config` to `aws_lambda_function."app"` (used
|
|
464
517
|
// when `add db:redis` runs on a Lambda project generated without a
|
|
465
518
|
// database). Returns the content unchanged for ECS projects or when the
|
|
@@ -1205,6 +1258,8 @@ export async function runAdd(input = {}) {
|
|
|
1205
1258
|
|
|
1206
1259
|
async function runAddMain(input = {}) {
|
|
1207
1260
|
const options = normalizeOptions(input);
|
|
1261
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'add', event: 'add_run' });
|
|
1262
|
+
if (unknownRefusal) return unknownRefusal;
|
|
1208
1263
|
const noExit = isProgrammaticCall(options);
|
|
1209
1264
|
let cwd;
|
|
1210
1265
|
let projectName;
|
|
@@ -1469,6 +1524,9 @@ async function scaffoldDatabaseInner(engine, projectDir, refs) {
|
|
|
1469
1524
|
} else {
|
|
1470
1525
|
await atomicWriteFile(databaseTfPath, normalizeBlankLines(rendered));
|
|
1471
1526
|
}
|
|
1527
|
+
// Engine templates reference the shared isolated subnets: backfill the
|
|
1528
|
+
// block on trees generated before it moved to network.tf.
|
|
1529
|
+
const subnetsBackfilled = await backfillIsolatedSubnets(projectDir);
|
|
1472
1530
|
|
|
1473
1531
|
let randomInjected = false;
|
|
1474
1532
|
if (isLambda) {
|
|
@@ -1518,6 +1576,7 @@ async function scaffoldDatabaseInner(engine, projectDir, refs) {
|
|
|
1518
1576
|
workerEnvInjected,
|
|
1519
1577
|
vpcInjected,
|
|
1520
1578
|
randomInjected,
|
|
1579
|
+
subnetsBackfilled,
|
|
1521
1580
|
ejected,
|
|
1522
1581
|
};
|
|
1523
1582
|
}
|
|
@@ -1659,6 +1718,13 @@ async function scaffoldAddonInner(capability, resolvedOpts, { cwd, region } = {}
|
|
|
1659
1718
|
await atomicWriteFile(targetPath, normalizeBlankLines(rendered));
|
|
1660
1719
|
}
|
|
1661
1720
|
|
|
1721
|
+
// Addons referencing the shared isolated subnets (db:redis) backfill the
|
|
1722
|
+
// block on trees generated before it moved to network.tf.
|
|
1723
|
+
let subnetsBackfilled = false;
|
|
1724
|
+
if (rendered.includes('aws_subnet.db_isolated')) {
|
|
1725
|
+
subnetsBackfilled = await backfillIsolatedSubnets(projectDir);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1662
1728
|
const envVars = Array.isArray(opts.envVars) ? opts.envVars : [];
|
|
1663
1729
|
const upsertKeys = Array.isArray(opts.upsertKeys) ? opts.upsertKeys : [];
|
|
1664
1730
|
const injectOptions = upsertKeys.length > 0 ? { upsertKeys } : {};
|
|
@@ -1697,6 +1763,7 @@ async function scaffoldAddonInner(capability, resolvedOpts, { cwd, region } = {}
|
|
|
1697
1763
|
envInjected,
|
|
1698
1764
|
workerEnvInjected,
|
|
1699
1765
|
vpcInjected,
|
|
1766
|
+
subnetsBackfilled,
|
|
1700
1767
|
ejected,
|
|
1701
1768
|
};
|
|
1702
1769
|
}
|
package/src/commands/alerts.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import color from 'picocolors';
|
|
4
4
|
import { intro, outro, select, text, cancel, isCancel } from '@clack/prompts';
|
|
5
5
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
|
|
6
|
-
import { failCommand, failProjectNotInitialized, refuseIfNonInteractive } from '../utils/command.js';
|
|
6
|
+
import { failCommand, failProjectNotInitialized, refuseIfNonInteractive, refuseUnknownFlags } from '../utils/command.js';
|
|
7
7
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
|
|
8
8
|
import { resolveRegion, resolveProjectName, resolveCwd, resolveHeadless, readFileSafe, readTerraformComputeTarget } from '../utils/resolvers.js';
|
|
9
9
|
import { findNestedBlock } from '../utils/hcl.js';
|
|
@@ -33,12 +33,13 @@ const TARGET_ANCHORS = {
|
|
|
33
33
|
export function parseAlertsArgs(argv = []) {
|
|
34
34
|
const args = normalizeArgv(argv);
|
|
35
35
|
if (args[0] === 'alerts') args.shift();
|
|
36
|
-
const { options, rest } = parseFlags(args, {
|
|
36
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
37
37
|
string: ['region', 'project-name', 'email', 'webhook', 'threshold'],
|
|
38
|
-
boolean: ['force'],
|
|
38
|
+
boolean: ['force', 'headless'],
|
|
39
39
|
});
|
|
40
40
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
41
41
|
if (positionals.length > 0) options.unexpectedPositionals = positionals;
|
|
42
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
42
43
|
return options;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -396,6 +397,8 @@ export async function runAlerts(input = {}) {
|
|
|
396
397
|
|
|
397
398
|
async function runAlertsMain(input = {}) {
|
|
398
399
|
const options = normalizeOptions(input);
|
|
400
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'alerts', event: 'alerts_run' });
|
|
401
|
+
if (unknownRefusal) return unknownRefusal;
|
|
399
402
|
let cwd;
|
|
400
403
|
let region;
|
|
401
404
|
let projectName;
|
package/src/commands/apply.js
CHANGED
|
@@ -5,7 +5,7 @@ import color from 'picocolors';
|
|
|
5
5
|
import { renderDryRunPreview, parseTerraformConfig, buildCostTelemetryProps } from '../utils/visualizer.js';
|
|
6
6
|
import { detectFramework } from '../utils/detector.js';
|
|
7
7
|
import { trackEvent, flushTelemetry, trackSuccess, trackFailure, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
|
|
8
|
-
import { failCommand, shouldAutoApprove, refuseIfNonInteractive } from '../utils/command.js';
|
|
8
|
+
import { failCommand, shouldAutoApprove, refuseIfNonInteractive, refuseUnknownFlags } from '../utils/command.js';
|
|
9
9
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
|
|
10
10
|
import { spawnSync } from 'child_process';
|
|
11
11
|
import { runTerraformCommand, getTerraformOutputs, readLastRunMarker, isInterruptedMarker, ensureTerraformInit, checkOutputsContract, DEFAULT_TERRAFORM_PHASE_TIMEOUT_MS } from '../utils/terraform.js';
|
|
@@ -22,10 +22,11 @@ import { runWake } from './wake.js';
|
|
|
22
22
|
export function parseApplyArgs(argv = []) {
|
|
23
23
|
const args = normalizeArgv(argv);
|
|
24
24
|
if (args[0] === 'apply' || args[0] === 'deploy') args.shift();
|
|
25
|
-
const { options } = parseFlags(args, {
|
|
26
|
-
boolean: ['force', 'destroy-previous-target', 'force-resume', 'allow-partial-outputs'],
|
|
25
|
+
const { options, unknown } = parseFlags(args, {
|
|
26
|
+
boolean: ['force', 'destroy-previous-target', 'force-resume', 'allow-partial-outputs', 'headless', 'auto-approve', 'dry-run'],
|
|
27
27
|
string: ['force-unlock'],
|
|
28
28
|
});
|
|
29
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
29
30
|
return { force: false, ...options };
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -188,6 +189,8 @@ export async function applyStack(input = {}) {
|
|
|
188
189
|
|
|
189
190
|
async function applyStackMain(input = {}) {
|
|
190
191
|
const options = normalizeOptions(input);
|
|
192
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'apply', event: 'infrastructure_applied' });
|
|
193
|
+
if (unknownRefusal) return unknownRefusal;
|
|
191
194
|
intro(color.bgCyan(color.black(' grada apply ☁️ ')));
|
|
192
195
|
|
|
193
196
|
const targetDir = process.cwd();
|
|
@@ -2,7 +2,7 @@ import { RDSClient, CreateDBSnapshotCommand, DescribeDBSnapshotsCommand, CreateD
|
|
|
2
2
|
import color from 'picocolors';
|
|
3
3
|
import { intro, outro, spinner } from '@clack/prompts';
|
|
4
4
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
5
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
5
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
6
6
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
7
7
|
import { isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
8
8
|
import { resolveRegion, resolveProjectName, resolveAppName, resolveCwd } from '../../utils/resolvers.js';
|
|
@@ -22,7 +22,7 @@ export function parseDbBackupArgs(argv = []) {
|
|
|
22
22
|
const args = normalizeArgv(argv);
|
|
23
23
|
if (args[0] === 'db') args.shift();
|
|
24
24
|
if (args[0] === 'backup') args.shift();
|
|
25
|
-
const { options, rest } = parseFlags(args, {
|
|
25
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
26
26
|
string: [
|
|
27
27
|
{ name: 'id', key: 'snapshotId' },
|
|
28
28
|
{ name: 'timeout', key: 'timeout' },
|
|
@@ -35,6 +35,7 @@ export function parseDbBackupArgs(argv = []) {
|
|
|
35
35
|
});
|
|
36
36
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
37
37
|
if (positionals.length > 0) options.unexpectedPositionals = positionals;
|
|
38
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
38
39
|
return options;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -51,6 +52,8 @@ export async function runDbBackup(input = {}) {
|
|
|
51
52
|
|
|
52
53
|
async function runDbBackupMain(input = {}) {
|
|
53
54
|
const options = normalizeOptions(input);
|
|
55
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db backup', event: 'db_backup_run' });
|
|
56
|
+
if (unknownRefusal) return unknownRefusal;
|
|
54
57
|
let cwd;
|
|
55
58
|
let region;
|
|
56
59
|
let projectName;
|
|
@@ -5,7 +5,7 @@ import { spawn } from 'child_process';
|
|
|
5
5
|
import color from 'picocolors';
|
|
6
6
|
import { intro, outro, spinner } from '@clack/prompts';
|
|
7
7
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
8
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
8
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
9
9
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
10
10
|
import { hasAwsCli, AWS_CLI_INSTALL_URL, isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
11
11
|
import { resolveRegion, resolveProjectName, resolveCluster, resolveService, resolveAppName, resolveCwd } from '../../utils/resolvers.js';
|
|
@@ -46,10 +46,11 @@ export function parseDbArgs(argv = []) {
|
|
|
46
46
|
const args = normalizeArgv(argv);
|
|
47
47
|
if (args[0] === 'db') args.shift();
|
|
48
48
|
if (args[0] === 'connect') args.shift();
|
|
49
|
-
const { options } = parseFlags(args, {
|
|
49
|
+
const { options, unknown } = parseFlags(args, {
|
|
50
50
|
string: ['port', 'region', 'cluster', 'service', 'workspace'],
|
|
51
|
-
boolean: ['show-credentials'],
|
|
51
|
+
boolean: ['show-credentials', 'headless'],
|
|
52
52
|
});
|
|
53
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
53
54
|
return options;
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -104,6 +105,8 @@ export async function runDbConnect(input = {}) {
|
|
|
104
105
|
|
|
105
106
|
async function runDbConnectMain(input = {}) {
|
|
106
107
|
const options = normalizeOptions(input);
|
|
108
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db connect', event: 'db_connect_run' });
|
|
109
|
+
if (unknownRefusal) return unknownRefusal;
|
|
107
110
|
let cwd;
|
|
108
111
|
let region;
|
|
109
112
|
let projectName;
|
|
@@ -3,7 +3,7 @@ import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
|
|
|
3
3
|
import color from 'picocolors';
|
|
4
4
|
import { intro, outro, spinner } from '@clack/prompts';
|
|
5
5
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
6
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
6
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
7
7
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
8
8
|
import { isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
9
9
|
import {
|
|
@@ -37,7 +37,7 @@ export function parseDbEnableVectorArgs(argv = []) {
|
|
|
37
37
|
const args = normalizeArgv(argv);
|
|
38
38
|
if (args[0] === 'db') args.shift();
|
|
39
39
|
if (args[0] === 'enable-vector') args.shift();
|
|
40
|
-
const { options, rest } = parseFlags(args, {
|
|
40
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
41
41
|
string: [
|
|
42
42
|
{ name: 'cluster', key: 'cluster' },
|
|
43
43
|
{ name: 'service', key: 'service' },
|
|
@@ -52,6 +52,7 @@ export function parseDbEnableVectorArgs(argv = []) {
|
|
|
52
52
|
});
|
|
53
53
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
54
54
|
if (positionals.length > 0) options.unexpectedPositionals = positionals;
|
|
55
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
55
56
|
return options;
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -129,6 +130,8 @@ export async function runDbEnableVector(input = {}) {
|
|
|
129
130
|
|
|
130
131
|
async function runDbEnableVectorMain(input = {}) {
|
|
131
132
|
const options = normalizeOptions(input);
|
|
133
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db enable-vector', event: 'db_enable_vector_run' });
|
|
134
|
+
if (unknownRefusal) return unknownRefusal;
|
|
132
135
|
const startTime = Date.now();
|
|
133
136
|
let cwd;
|
|
134
137
|
let region;
|
|
@@ -8,7 +8,7 @@ import zlib from 'node:zlib';
|
|
|
8
8
|
import color from 'picocolors';
|
|
9
9
|
import { intro, outro, spinner, select, text, password, confirm, cancel, isCancel } from '@clack/prompts';
|
|
10
10
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
11
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
11
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
12
12
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
13
13
|
import { hasAwsCli, AWS_CLI_INSTALL_URL, isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
14
14
|
import {
|
|
@@ -49,7 +49,7 @@ export function parseDbImportArgs(argv = []) {
|
|
|
49
49
|
const args = normalizeArgv(argv);
|
|
50
50
|
if (args[0] === 'db') args.shift();
|
|
51
51
|
if (args[0] === 'import') args.shift();
|
|
52
|
-
const { options, rest } = parseFlags(args, {
|
|
52
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
53
53
|
string: [
|
|
54
54
|
{ name: 'file', key: 'file' },
|
|
55
55
|
{ name: 'from', key: 'from' },
|
|
@@ -62,6 +62,7 @@ export function parseDbImportArgs(argv = []) {
|
|
|
62
62
|
});
|
|
63
63
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
64
64
|
if (positionals.length > 0) options.unexpectedPositionals = positionals;
|
|
65
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
65
66
|
return options;
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -165,6 +166,8 @@ export async function runDbImport(input = {}) {
|
|
|
165
166
|
|
|
166
167
|
async function runDbImportMain(input = {}) {
|
|
167
168
|
const options = normalizeOptions(input);
|
|
169
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db import', event: 'db_import_run' });
|
|
170
|
+
if (unknownRefusal) return unknownRefusal;
|
|
168
171
|
let cwd;
|
|
169
172
|
let region;
|
|
170
173
|
let projectName;
|
|
@@ -2,8 +2,8 @@ import { ECSClient } from '@aws-sdk/client-ecs';
|
|
|
2
2
|
import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
|
|
3
3
|
import color from 'picocolors';
|
|
4
4
|
import { intro, outro, spinner, text, isCancel } from '@clack/prompts';
|
|
5
|
-
import { trackEvent, trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
6
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
5
|
+
import { trackEvent, trackSuccess, setActiveCommandName, resetActiveCommandName, getCliVersion } from '../../core/telemetry.js';
|
|
6
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
7
7
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
8
8
|
import { isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
9
9
|
import {
|
|
@@ -58,7 +58,7 @@ export function parseDbMigrateArgs(argv = []) {
|
|
|
58
58
|
const args = normalizeArgv(argv);
|
|
59
59
|
if (args[0] === 'db') args.shift();
|
|
60
60
|
if (args[0] === 'migrate') args.shift();
|
|
61
|
-
const { options, rest } = parseFlags(args, {
|
|
61
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
62
62
|
string: [
|
|
63
63
|
{ name: 'cmd', key: 'cmd' },
|
|
64
64
|
{ name: 'task-def', key: 'taskDef' },
|
|
@@ -74,6 +74,7 @@ export function parseDbMigrateArgs(argv = []) {
|
|
|
74
74
|
});
|
|
75
75
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
76
76
|
if (positionals.length > 0) options.unexpectedPositionals = positionals;
|
|
77
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
77
78
|
return options;
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -113,45 +114,50 @@ function stripPreviousGateBlock(content) {
|
|
|
113
114
|
return content.slice(0, lineStart) + content.slice(lineEnd === -1 ? content.length : lineEnd + 1);
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
// Builds the CI invocation of this CLI for injected gate blocks: pinned to
|
|
118
|
+
// the installing version so pipelines stay reproducible across releases.
|
|
119
|
+
// Falls back to the unpinned runner when the version is unknowable
|
|
120
|
+
// (source checkouts report 'unknown').
|
|
121
|
+
export function buildRunnerInvocation(cliVersion) {
|
|
122
|
+
const ver = typeof cliVersion === 'string' ? cliVersion.trim() : '';
|
|
123
|
+
if (ver === '' || ver === 'unknown') return 'npx grada-run';
|
|
124
|
+
return `npx --yes @grada-run/grada@${ver}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Shared injection core: strips any previous gate, renders the block, and
|
|
128
|
+
// splices it before the anchor step. Returns null without the anchor.
|
|
129
|
+
function injectGateBlock(content, { runLine, stepName, anchor }) {
|
|
130
|
+
const base = stripPreviousGateBlock(String(content ?? ''));
|
|
131
|
+
const includeSetupNode = !base.includes('actions/setup-node');
|
|
132
|
+
const block = renderGateBlock({ includeSetupNode, stepName, runLine });
|
|
133
|
+
const anchorIdx = base.indexOf(anchor);
|
|
134
|
+
if (anchorIdx === -1) return null;
|
|
135
|
+
const insertAt = base.lastIndexOf('\n', anchorIdx) + 1;
|
|
136
|
+
return `${base.slice(0, insertAt)}${block}${base.slice(insertAt)}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
116
139
|
// Idempotently injects (or refreshes) the migration gate block into a
|
|
117
140
|
// deploy.yml document. Returns the updated content, or null when neither
|
|
118
141
|
// anchor step is present. Pure and unit-tested.
|
|
119
|
-
export function injectMigrationGate(workflowContent, { cmd }) {
|
|
120
|
-
const content = String(workflowContent ?? '');
|
|
142
|
+
export function injectMigrationGate(workflowContent, { cmd, cliVersion } = {}) {
|
|
121
143
|
const taskDefRef = '${{ steps.register-task-def.outputs.task-arn }}';
|
|
122
|
-
|
|
123
|
-
const base = stripPreviousGateBlock(content);
|
|
124
|
-
const includeSetupNode = !base.includes('actions/setup-node');
|
|
125
|
-
const block = renderGateBlock({
|
|
126
|
-
includeSetupNode,
|
|
144
|
+
return injectGateBlock(workflowContent, {
|
|
127
145
|
stepName: 'Pre-Deploy Database Migration',
|
|
128
|
-
runLine:
|
|
146
|
+
runLine: `${buildRunnerInvocation(cliVersion)} db migrate --cmd ${quoteShellArg(cmd)} --task-def "${taskDefRef}" --headless`,
|
|
147
|
+
anchor: '- name: Force ECS deployment',
|
|
129
148
|
});
|
|
130
|
-
|
|
131
|
-
const forceIdx = base.indexOf('- name: Force ECS deployment');
|
|
132
|
-
if (forceIdx === -1) return null;
|
|
133
|
-
const insertAt = base.lastIndexOf('\n', forceIdx) + 1;
|
|
134
|
-
return `${base.slice(0, insertAt)}${block}${base.slice(insertAt)}`;
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
// Idempotently injects (or refreshes) the migration gate block into a
|
|
138
152
|
// preview.yml document (ECS only — Lambda has no migrate-gate story yet).
|
|
139
153
|
// Previews have no register step, so `db migrate` resolves the workspace
|
|
140
154
|
// service itself via --workspace. Returns null without the anchor.
|
|
141
|
-
export function injectPreviewMigrationGate(workflowContent, { cmd }) {
|
|
142
|
-
|
|
143
|
-
const base = stripPreviousGateBlock(content);
|
|
144
|
-
const includeSetupNode = !base.includes('actions/setup-node');
|
|
145
|
-
const block = renderGateBlock({
|
|
146
|
-
includeSetupNode,
|
|
155
|
+
export function injectPreviewMigrationGate(workflowContent, { cmd, cliVersion } = {}) {
|
|
156
|
+
return injectGateBlock(workflowContent, {
|
|
147
157
|
stepName: 'Preview Database Migration',
|
|
148
|
-
runLine:
|
|
158
|
+
runLine: `${buildRunnerInvocation(cliVersion)} db migrate --cmd ${quoteShellArg(cmd)} --workspace "\${{ env.WORKSPACE }}" --headless`,
|
|
159
|
+
anchor: '- name: Comment PR',
|
|
149
160
|
});
|
|
150
|
-
|
|
151
|
-
const commentIdx = base.indexOf('- name: Comment PR');
|
|
152
|
-
if (commentIdx === -1) return null;
|
|
153
|
-
const insertAt = base.lastIndexOf('\n', commentIdx) + 1;
|
|
154
|
-
return `${base.slice(0, insertAt)}${block}${base.slice(insertAt)}`;
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
// Builds the container override command for the migration task. When the
|
|
@@ -255,6 +261,8 @@ export async function runDbMigrate(input = {}) {
|
|
|
255
261
|
|
|
256
262
|
async function runDbMigrateMain(input = {}) {
|
|
257
263
|
const options = normalizeOptions(input);
|
|
264
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db migrate', event: 'db_migrate_run' });
|
|
265
|
+
if (unknownRefusal) return unknownRefusal;
|
|
258
266
|
let cwd;
|
|
259
267
|
let region;
|
|
260
268
|
let projectName;
|
|
@@ -380,7 +388,7 @@ async function runDbMigrateMain(input = {}) {
|
|
|
380
388
|
resultExtra: { cluster, service, region },
|
|
381
389
|
});
|
|
382
390
|
}
|
|
383
|
-
const updated = injectMigrationGate(workflowContent, { cmd: resolvedCmd });
|
|
391
|
+
const updated = injectMigrationGate(workflowContent, { cmd: resolvedCmd, cliVersion: getCliVersion() });
|
|
384
392
|
if (updated === null) {
|
|
385
393
|
return failCommand({
|
|
386
394
|
message: '\n✖ Could not find the task-definition registration or ECS deployment step in .github/workflows/deploy.yml to anchor the migration gate.\n',
|
|
@@ -403,7 +411,7 @@ async function runDbMigrateMain(input = {}) {
|
|
|
403
411
|
previewContent = null;
|
|
404
412
|
}
|
|
405
413
|
if (previewContent !== null) {
|
|
406
|
-
const previewUpdated = injectPreviewMigrationGate(previewContent, { cmd: resolvedCmd });
|
|
414
|
+
const previewUpdated = injectPreviewMigrationGate(previewContent, { cmd: resolvedCmd, cliVersion: getCliVersion() });
|
|
407
415
|
if (previewUpdated !== null) {
|
|
408
416
|
fsSync.writeFileSync(previewFile, previewUpdated, 'utf8');
|
|
409
417
|
console.log(color.green('✅ Preview migration gate installed in .github/workflows/preview.yml.'));
|
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import color from 'picocolors';
|
|
5
5
|
import { intro, outro, spinner, select, confirm, cancel, isCancel } from '@clack/prompts';
|
|
6
6
|
import { trackSuccess, setActiveCommandName, resetActiveCommandName } from '../../core/telemetry.js';
|
|
7
|
-
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized } from '../../utils/command.js';
|
|
7
|
+
import { failCommand, failAwsError, trackAwsFailure, failProjectNotInitialized, refuseUnknownFlags } from '../../utils/command.js';
|
|
8
8
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../../utils/args.js';
|
|
9
9
|
import { isAuthError, handleAuthErrorBranch, resolveClient } from '../../utils/aws.js';
|
|
10
10
|
import { resolveRegion, resolveProjectName, resolveAppName, resolveHeadless, resolveCwd } from '../../utils/resolvers.js';
|
|
@@ -24,7 +24,7 @@ export function parseDbRestoreArgs(argv = []) {
|
|
|
24
24
|
const args = normalizeArgv(argv);
|
|
25
25
|
if (args[0] === 'db') args.shift();
|
|
26
26
|
if (args[0] === 'restore') args.shift();
|
|
27
|
-
const { options, rest } = parseFlags(args, {
|
|
27
|
+
const { options, rest, unknown } = parseFlags(args, {
|
|
28
28
|
string: [
|
|
29
29
|
{ name: 'project-name', key: 'projectName' },
|
|
30
30
|
{ name: 'region', key: 'region' },
|
|
@@ -36,6 +36,7 @@ export function parseDbRestoreArgs(argv = []) {
|
|
|
36
36
|
const positionals = rest.filter((arg) => typeof arg === 'string' && !arg.startsWith('-'));
|
|
37
37
|
if (positionals.length > 0) options.snapshotId = positionals[0];
|
|
38
38
|
if (positionals.length > 1) options.unexpectedPositionals = positionals.slice(1);
|
|
39
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
39
40
|
return options;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -172,6 +173,8 @@ export async function runDbRestore(input = {}) {
|
|
|
172
173
|
|
|
173
174
|
async function runDbRestoreMain(input = {}) {
|
|
174
175
|
const options = normalizeOptions(input);
|
|
176
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'db restore', event: 'db_restore_run' });
|
|
177
|
+
if (unknownRefusal) return unknownRefusal;
|
|
175
178
|
let cwd;
|
|
176
179
|
let region;
|
|
177
180
|
let projectName;
|
package/src/commands/destroy.js
CHANGED
|
@@ -7,7 +7,7 @@ import { S3Client } from '@aws-sdk/client-s3';
|
|
|
7
7
|
import { teardownStateBucket, drainBucketObjects, resolveClient } from '../utils/aws.js';
|
|
8
8
|
import { checkDependency, pollUntil } from '../utils/system.js';
|
|
9
9
|
import { trackEvent, flushTelemetry, trackSuccess, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
|
|
10
|
-
import { failCommand, shouldAutoApprove, refuseIfNonInteractive } from '../utils/command.js';
|
|
10
|
+
import { failCommand, shouldAutoApprove, refuseIfNonInteractive, refuseUnknownFlags } from '../utils/command.js';
|
|
11
11
|
import { runTerraformCommand, readLastRunMarker, isInterruptedMarker, ensureTerraformInit, getTerraformStateBuckets, DEFAULT_TERRAFORM_PHASE_TIMEOUT_MS } from '../utils/terraform.js';
|
|
12
12
|
import { classifyTerraformError, getRunbook, ERROR_CODES } from '../utils/terraform-errors.js';
|
|
13
13
|
import { findDbTarget, dbStatusOf, resolveDbIdentifier, resolveDbClusterIdentifier, generateSnapshotId } from '../utils/rds.js';
|
|
@@ -38,10 +38,11 @@ export function treeDeclaresDataLossVar(tfDir) {
|
|
|
38
38
|
|
|
39
39
|
export function parseDestroyArgs(argv = []) {
|
|
40
40
|
const args = normalizeArgv(argv);
|
|
41
|
-
const { options } = parseFlags(args, {
|
|
42
|
-
boolean: ['allow-data-loss', 'force'],
|
|
41
|
+
const { options, unknown } = parseFlags(args, {
|
|
42
|
+
boolean: ['allow-data-loss', 'force', 'headless', 'yes'],
|
|
43
43
|
string: ['force-unlock'],
|
|
44
44
|
});
|
|
45
|
+
if (unknown.length > 0) options.unknownFlags = unknown;
|
|
45
46
|
return { allowDataLoss: false, force: false, ...options };
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -145,6 +146,8 @@ export async function destroyStack(input = {}) {
|
|
|
145
146
|
|
|
146
147
|
async function destroyStackMain(input = {}) {
|
|
147
148
|
const options = normalizeOptions(input);
|
|
149
|
+
const unknownRefusal = await refuseUnknownFlags(options, { command: 'destroy', event: 'infrastructure_destroyed' });
|
|
150
|
+
if (unknownRefusal) return unknownRefusal;
|
|
148
151
|
intro(color.bgRed(color.white(' grada destroy 🗑️ ')));
|
|
149
152
|
|
|
150
153
|
// Ejected trees are user-owned: refuse unless --force.
|