powersync 0.9.1 → 0.9.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/README.md +103 -74
- package/bin/dev.js +7 -1
- package/dist/api/BaseDeployCommand.d.ts +39 -0
- package/dist/api/BaseDeployCommand.js +230 -0
- package/dist/api/BaseDeployCommand.js.map +1 -0
- package/dist/api/build-service-yaml.d.ts +29 -0
- package/dist/api/build-service-yaml.js +246 -0
- package/dist/api/build-service-yaml.js.map +1 -0
- package/dist/api/cloud/create-cloud-instance.js +1 -0
- package/dist/api/cloud/create-cloud-instance.js.map +1 -0
- package/dist/api/cloud/create-cloud-template.d.ts +15 -0
- package/dist/api/cloud/create-cloud-template.js +33 -0
- package/dist/api/cloud/create-cloud-template.js.map +1 -0
- package/dist/api/cloud/fetch-cloud-config.js +1 -0
- package/dist/api/cloud/fetch-cloud-config.js.map +1 -0
- package/dist/api/cloud/fetch-cloud-sync-rules-content.js +6 -7
- package/dist/api/cloud/fetch-cloud-sync-rules-content.js.map +1 -0
- package/dist/api/cloud/test-connection.js +3 -3
- package/dist/api/cloud/test-connection.js.map +1 -0
- package/dist/api/cloud/validate-cloud-link-config.js +1 -0
- package/dist/api/cloud/validate-cloud-link-config.js.map +1 -0
- package/dist/api/cloud/wait-for-operation.js +1 -0
- package/dist/api/cloud/wait-for-operation.js.map +1 -0
- package/dist/api/cloud/write-cloud-link.js +1 -0
- package/dist/api/cloud/write-cloud-link.js.map +1 -0
- package/dist/api/display-status.js +1 -0
- package/dist/api/display-status.js.map +1 -0
- package/dist/api/ide/configure-vscode-ide.js +1 -0
- package/dist/api/ide/configure-vscode-ide.js.map +1 -0
- package/dist/api/login-server.js +1 -0
- package/dist/api/login-server.js.map +1 -0
- package/dist/api/parse-local-cloud-service-config.d.ts +13 -0
- package/dist/api/parse-local-cloud-service-config.js +35 -0
- package/dist/api/parse-local-cloud-service-config.js.map +1 -0
- package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.js +7 -8
- package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.js.map +1 -0
- package/dist/api/validations/ValidationTestDefinition.d.ts +23 -0
- package/dist/api/validations/ValidationTestDefinition.js +10 -0
- package/dist/api/validations/ValidationTestDefinition.js.map +1 -0
- package/dist/api/validations/ValidationsRunner.d.ts +35 -0
- package/dist/api/validations/ValidationsRunner.js +82 -0
- package/dist/api/validations/ValidationsRunner.js.map +1 -0
- package/dist/api/validations/cloud-validations.d.ts +15 -0
- package/dist/api/validations/cloud-validations.js +120 -0
- package/dist/api/validations/cloud-validations.js.map +1 -0
- package/dist/api/validations/self-hosted-validations.d.ts +7 -0
- package/dist/api/validations/self-hosted-validations.js +25 -0
- package/dist/api/validations/self-hosted-validations.js.map +1 -0
- package/dist/api/validations/validation-flags.d.ts +38 -0
- package/dist/api/validations/validation-flags.js +77 -0
- package/dist/api/validations/validation-flags.js.map +1 -0
- package/dist/api/validations/validation-utils.d.ts +46 -0
- package/dist/api/validations/validation-utils.js +154 -0
- package/dist/api/validations/validation-utils.js.map +1 -0
- package/dist/api/validations/validations.d.ts +15 -0
- package/dist/api/validations/validations.js +102 -0
- package/dist/api/validations/validations.js.map +1 -0
- package/dist/commands/configure/ide.js +1 -0
- package/dist/commands/configure/ide.js.map +1 -0
- package/dist/commands/configure/index.js +1 -0
- package/dist/commands/configure/index.js.map +1 -0
- package/dist/commands/deploy/index.d.ts +5 -41
- package/dist/commands/deploy/index.js +69 -279
- package/dist/commands/deploy/index.js.map +1 -0
- package/dist/commands/deploy/service-config.d.ts +3 -7
- package/dist/commands/deploy/service-config.js +30 -7
- package/dist/commands/deploy/service-config.js.map +1 -0
- package/dist/commands/deploy/sync-config.d.ts +5 -8
- package/dist/commands/deploy/sync-config.js +43 -20
- package/dist/commands/deploy/sync-config.js.map +1 -0
- package/dist/commands/destroy.d.ts +0 -4
- package/dist/commands/destroy.js +2 -2
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/fetch/config.d.ts +0 -4
- package/dist/commands/fetch/config.js +2 -2
- package/dist/commands/fetch/config.js.map +1 -0
- package/dist/commands/fetch/index.js +1 -0
- package/dist/commands/fetch/index.js.map +1 -0
- package/dist/commands/fetch/instances.js +1 -0
- package/dist/commands/fetch/instances.js.map +1 -0
- package/dist/commands/fetch/status.d.ts +0 -5
- package/dist/commands/fetch/status.js +2 -2
- package/dist/commands/fetch/status.js.map +1 -0
- package/dist/commands/generate/index.js +1 -0
- package/dist/commands/generate/index.js.map +1 -0
- package/dist/commands/generate/schema.d.ts +3 -6
- package/dist/commands/generate/schema.js +5 -5
- package/dist/commands/generate/schema.js.map +1 -0
- package/dist/commands/generate/token.d.ts +0 -5
- package/dist/commands/generate/token.js +2 -2
- package/dist/commands/generate/token.js.map +1 -0
- package/dist/commands/init/cloud.d.ts +0 -3
- package/dist/commands/init/cloud.js +21 -18
- package/dist/commands/init/cloud.js.map +1 -0
- package/dist/commands/init/index.js +1 -0
- package/dist/commands/init/index.js.map +1 -0
- package/dist/commands/init/self-hosted.d.ts +0 -3
- package/dist/commands/init/self-hosted.js +29 -6
- package/dist/commands/init/self-hosted.js.map +1 -0
- package/dist/commands/link/cloud.d.ts +0 -1
- package/dist/commands/link/cloud.js +3 -3
- package/dist/commands/link/cloud.js.map +1 -0
- package/dist/commands/link/index.js +1 -0
- package/dist/commands/link/index.js.map +1 -0
- package/dist/commands/link/self-hosted.d.ts +0 -1
- package/dist/commands/link/self-hosted.js +3 -3
- package/dist/commands/link/self-hosted.js.map +1 -0
- package/dist/commands/login.js +1 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.js +1 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/migrate/index.js +1 -0
- package/dist/commands/migrate/index.js.map +1 -0
- package/dist/commands/migrate/sync-rules.d.ts +0 -5
- package/dist/commands/migrate/sync-rules.js +2 -2
- package/dist/commands/migrate/sync-rules.js.map +1 -0
- package/dist/commands/pull/index.js +1 -0
- package/dist/commands/pull/index.js.map +1 -0
- package/dist/commands/pull/instance.d.ts +1 -4
- package/dist/commands/pull/instance.js +26 -12
- package/dist/commands/pull/instance.js.map +1 -0
- package/dist/commands/status.js +1 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +0 -4
- package/dist/commands/stop.js +2 -2
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -8
- package/dist/commands/validate.js +50 -128
- package/dist/commands/validate.js.map +1 -0
- package/dist/help.js +1 -0
- package/dist/help.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/oclif.manifest.json +263 -161
- package/package.json +11 -10
- package/templates/cloud/powersync/service.template.yaml +164 -0
- package/templates/self-hosted/base/powersync/service.template.yaml +209 -0
- package/dist/api/run-validation-tests.d.ts +0 -63
- package/dist/api/run-validation-tests.js +0 -202
- package/templates/cloud/powersync/service.yaml +0 -174
- package/templates/self-hosted/base/powersync/service.yaml +0 -243
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default class DeployAll extends CloudInstanceCommand {
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import { WithSyncConfigFilePath } from '@powersync/cli-core';
|
|
3
|
+
import BaseDeployCommand from '../../api/BaseDeployCommand.js';
|
|
4
|
+
import { DEFAULT_DEPLOY_TIMEOUT_MS } from '../../api/cloud/wait-for-operation.js';
|
|
5
|
+
import { getCloudValidations } from '../../api/validations/cloud-validations.js';
|
|
6
|
+
import { GENERAL_VALIDATION_FLAG_HELPERS } from '../../api/validations/validation-flags.js';
|
|
7
|
+
import { formatValidationHuman } from '../../api/validations/validation-utils.js';
|
|
8
|
+
import { ValidationsRunner } from '../../api/validations/ValidationsRunner.js';
|
|
9
|
+
import { ValidationTest } from '../../api/validations/ValidationTestDefinition.js';
|
|
10
|
+
export default class DeployAll extends WithSyncConfigFilePath(BaseDeployCommand) {
|
|
12
11
|
static description = [
|
|
13
12
|
'Deploy local config (service.yaml, sync config) to the linked PowerSync Cloud instance.',
|
|
14
13
|
'Validates connections and sync config before deploying.',
|
|
@@ -20,126 +19,19 @@ export default class DeployAll extends CloudInstanceCommand {
|
|
|
20
19
|
'<%= config.bin %> <%= command.id %> --instance-id=<id> --project-id=<id>'
|
|
21
20
|
];
|
|
22
21
|
static flags = {
|
|
23
|
-
|
|
24
|
-
default: DEFAULT_DEPLOY_TIMEOUT_MS / 1000,
|
|
25
|
-
description: 'Seconds to wait after scheduling a deploy before timing out while polling status (default 300 seconds).',
|
|
26
|
-
async parse(input) {
|
|
27
|
-
const value = Number(input);
|
|
28
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
29
|
-
throw new Error('deploy-timeout must be a positive number of seconds');
|
|
30
|
-
}
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
}),
|
|
34
|
-
...CloudInstanceCommand.flags
|
|
22
|
+
...GENERAL_VALIDATION_FLAG_HELPERS.flags
|
|
35
23
|
};
|
|
36
24
|
static summary = '[Cloud only] Deploy local config to the linked Cloud instance (connections + auth + sync config).';
|
|
37
|
-
async deployAll(params) {
|
|
38
|
-
const { cloudConfigState, deployTimeoutMs, updateSyncConfig } = params;
|
|
39
|
-
return this.withDeploy(deployTimeoutMs, async () => this.deployInstanceConfig({
|
|
40
|
-
cloudConfigState,
|
|
41
|
-
updateSyncConfig
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
async deployInstanceConfig(params) {
|
|
45
|
-
const { cloudConfigState, updateSyncConfig } = params;
|
|
46
|
-
const { client, project } = this;
|
|
47
|
-
const { linked, syncRulesContent } = project;
|
|
48
|
-
const config = this.serviceConfig;
|
|
49
|
-
if (!config) {
|
|
50
|
-
this.styledError({
|
|
51
|
-
message: `Service config not loaded. Ensure ${SERVICE_FILENAME} is present and valid.`
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return client.deployInstance(routes.DeployInstanceRequest.encode({
|
|
55
|
-
// Spread the existing config like name, and program version contraints.
|
|
56
|
-
// Should we allow specifying these in the config file?
|
|
57
|
-
...cloudConfigState,
|
|
58
|
-
app_id: new ObjectId(linked.project_id),
|
|
59
|
-
// The encoding will ensure the correct typing
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
config: config,
|
|
62
|
-
// Allow updating the instance name
|
|
63
|
-
name: config.name,
|
|
64
|
-
org_id: new ObjectId(linked.org_id),
|
|
65
|
-
sync_rules: updateSyncConfig ? syncRulesContent : cloudConfigState.sync_rules
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
async loadCloudConfigState() {
|
|
69
|
-
const { client, project } = this;
|
|
70
|
-
const { linked } = project;
|
|
71
|
-
return client
|
|
72
|
-
.getInstanceConfig({
|
|
73
|
-
app_id: linked.project_id,
|
|
74
|
-
id: linked.instance_id,
|
|
75
|
-
org_id: linked.org_id
|
|
76
|
-
})
|
|
77
|
-
.catch((error) => {
|
|
78
|
-
this.styledError({
|
|
79
|
-
error,
|
|
80
|
-
message: `Failed to get existing config for instance ${linked.instance_id} in project ${linked.project_id} in org ${linked.org_id}. Ensure the instance has been created before deploying.`
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
parseLocalConfig(projectDirectory) {
|
|
85
|
-
const config = super.parseLocalConfig(projectDirectory);
|
|
86
|
-
/**
|
|
87
|
-
* This is a temporary hack to maintain compatibilty with the PowerSync Dashboard.
|
|
88
|
-
* The dashboard requires replication connections to have a name field set.
|
|
89
|
-
* This is not enforced by the management service.
|
|
90
|
-
*/
|
|
91
|
-
for (const [index, connection] of config.replication?.connections?.entries() ?? []) {
|
|
92
|
-
if (!connection.name) {
|
|
93
|
-
connection.name = `Default${index > 0 ? `_${index}` : ''}`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return config;
|
|
97
|
-
}
|
|
98
|
-
async provision(params) {
|
|
99
|
-
const { cloudConfigState, deployTimeoutMs, indentationLevel } = params;
|
|
100
|
-
const indentation = '\t'.repeat(Math.max(0, indentationLevel));
|
|
101
|
-
const spinner = ora({
|
|
102
|
-
discardStdin: false,
|
|
103
|
-
prefixText: `\n${indentation}Initial provision: deploying without sync config changes in order to validate sync config before final deploy...\n`,
|
|
104
|
-
spinner: 'moon',
|
|
105
|
-
suffixText: `\n${indentation}This may take a few minutes.\n`
|
|
106
|
-
});
|
|
107
|
-
spinner.start();
|
|
108
|
-
try {
|
|
109
|
-
const deployResult = await this.deployInstanceConfig({
|
|
110
|
-
cloudConfigState,
|
|
111
|
-
updateSyncConfig: false
|
|
112
|
-
});
|
|
113
|
-
await this.waitForDeployCompletion({
|
|
114
|
-
deployResult,
|
|
115
|
-
indentation,
|
|
116
|
-
logCompletionMessage: false,
|
|
117
|
-
logScheduledMessage: false,
|
|
118
|
-
timeoutMs: deployTimeoutMs
|
|
119
|
-
});
|
|
120
|
-
spinner.stop();
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
spinner.stop();
|
|
124
|
-
const { linked } = this.project;
|
|
125
|
-
this.styledError({
|
|
126
|
-
error,
|
|
127
|
-
message: `Failed to deploy changes to instance ${linked.instance_id} in project ${linked.project_id} in org ${linked.org_id}`,
|
|
128
|
-
suggestions: ['Check your network connection and try again.', 'If the problem persists, contact support.']
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
25
|
async run() {
|
|
133
26
|
const { flags } = await this.parse(DeployAll);
|
|
134
27
|
const project = await this.loadProject(flags, {
|
|
135
|
-
// local config state is required when deploying all
|
|
136
28
|
configFileRequired: true
|
|
137
29
|
});
|
|
138
30
|
const deployTimeoutMs = (flags['deploy-timeout'] ?? DEFAULT_DEPLOY_TIMEOUT_MS / 1000) * 1000;
|
|
139
|
-
|
|
140
|
-
this.parseLocalConfig(project.projectDirectory);
|
|
141
|
-
// The existing config is required to deploy changes. The instance should have been created already.
|
|
31
|
+
const validationTestsFilter = GENERAL_VALIDATION_FLAG_HELPERS.parseValidationTestFlags(flags);
|
|
142
32
|
const cloudConfigState = await this.loadCloudConfigState();
|
|
33
|
+
// Parse and store for later
|
|
34
|
+
this.parseLocalConfig(project.projectDirectory, validationTestsFilter.skipped.includes(ValidationTest.CONFIGURATION));
|
|
143
35
|
// Start of validations
|
|
144
36
|
this.log('Performing validations before deploy...');
|
|
145
37
|
const instanceStatus = await this.client
|
|
@@ -157,16 +49,36 @@ export default class DeployAll extends CloudInstanceCommand {
|
|
|
157
49
|
});
|
|
158
50
|
const requiresReprovision = instanceStatus.provisioned === false;
|
|
159
51
|
const syncConfigHasChanges = project.syncRulesContent !== cloudConfigState.sync_rules;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
52
|
+
let didReprovision = false;
|
|
53
|
+
if (requiresReprovision && validationTestsFilter.testsToRun.includes(ValidationTest['SYNC-CONFIG'])) {
|
|
54
|
+
/**
|
|
55
|
+
* The instance is deprovisioned and sync-config validation is requested.
|
|
56
|
+
* Sync-config validation requires a provisioned instance, so we can't validate it yet.
|
|
57
|
+
* We must first validate everything else, reprovision, and then validate sync-config separately.
|
|
58
|
+
*/
|
|
59
|
+
const runner = new ValidationsRunner({
|
|
60
|
+
skippedTests: validationTestsFilter.skipped,
|
|
61
|
+
tests: getCloudValidations({
|
|
62
|
+
cloudConfigState,
|
|
63
|
+
project,
|
|
64
|
+
serviceConfigState: this.serviceConfig,
|
|
65
|
+
// We only remove the sync-config validation, this allows users to additionally skip other validations like connections and service config.
|
|
66
|
+
tests: validationTestsFilter.testsToRun.filter((test) => test !== ValidationTest['SYNC-CONFIG'])
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const intermediateResult = await runner.run();
|
|
70
|
+
// Always print the intermediate results so the user can see those tests passed before we reprovision.
|
|
71
|
+
this.log(formatValidationHuman(intermediateResult));
|
|
72
|
+
if (!intermediateResult.passed) {
|
|
73
|
+
this.styledError({
|
|
74
|
+
message: 'The instance is currently deprovisioned. We need to reprovision the instance to validate the sync config, but there are other validation errors that need to be fixed first.',
|
|
75
|
+
suggestions: ['Review the validation test results above, fix any issues, and run deploy again.']
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The non-sync-config validations passed. Reprovision now so that the instance is active
|
|
80
|
+
* and we can validate the sync config against it in the second pass below.
|
|
81
|
+
*/
|
|
170
82
|
this.log([
|
|
171
83
|
`The instance is ${ux.colorize('yellow', 'not currently provisioned')} and we have detected changes to the sync config.`,
|
|
172
84
|
`To ensure the instance is successfully provisioned with a valid config, we will first deploy without the sync config, then validate and deploy again with the sync config.`
|
|
@@ -176,158 +88,36 @@ export default class DeployAll extends CloudInstanceCommand {
|
|
|
176
88
|
deployTimeoutMs,
|
|
177
89
|
indentationLevel: 1
|
|
178
90
|
});
|
|
91
|
+
didReprovision = true;
|
|
179
92
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
const connectionResults = await testCloudConnections(client, linked, serviceConfig.replication?.connections ?? []).catch((error) => {
|
|
201
|
-
this.styledError({
|
|
202
|
-
error,
|
|
203
|
-
message: 'Failed to test connections',
|
|
204
|
-
suggestions: ['Check your network connection and try again.', 'If the problem persists, contact support.']
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
for (const { connectionName, response } of connectionResults) {
|
|
208
|
-
if (response.success !== true) {
|
|
209
|
-
this.styledError({ message: formatTestConnectionFailure(response, connectionName) });
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async validateServiceConfig(params) {
|
|
214
|
-
const { cloudConfigState } = params;
|
|
215
|
-
const { linked } = this.project;
|
|
216
|
-
const { serviceConfig } = this;
|
|
217
|
-
if (!serviceConfig) {
|
|
218
|
-
this.styledError({
|
|
219
|
-
message: `Service config not loaded. Ensure ${SERVICE_FILENAME} is present and valid.`
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
this.log('\tValidating configuration...');
|
|
223
|
-
const existingRegion = cloudConfigState.config?.region;
|
|
224
|
-
if (existingRegion && existingRegion !== serviceConfig.region) {
|
|
225
|
-
this.styledError({
|
|
226
|
-
message: `The existing config for instance ${linked.instance_id} in project ${linked.project_id} in org ${linked.org_id} has a different region than the config being deployed. Existing region: ${existingRegion}. New region: ${serviceConfig.region}. The region cannot be changed after the initial deployment.`,
|
|
227
|
-
suggestions: ['Check your config and try again.']
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
// Validate region against list of regions obtained from client.listRegions()
|
|
231
|
-
const regions = await this.client.listRegions().catch((error) => {
|
|
232
|
-
this.styledError({
|
|
233
|
-
error,
|
|
234
|
-
message: 'Could not validate region against list of regions: Failed to list regions',
|
|
235
|
-
suggestions: ['Check your network connection and try again.', 'If the problem persists, contact support.']
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
const foundRegion = regions.regions.find((region) => region.name === serviceConfig.region);
|
|
239
|
-
if (!foundRegion) {
|
|
240
|
-
this.styledError({
|
|
241
|
-
message: `The region ${serviceConfig.region} is not supported. Please choose a region from the list of supported regions: ${regions.regions.map((region) => region.name).join(', ')}.`
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async validateSyncConfig() {
|
|
246
|
-
const { client, project } = this;
|
|
247
|
-
// It might take a while for the instance to be fully provisioned after the deploy, so we retry the validation until it succeeds or we hit the timeout
|
|
248
|
-
for (let retry = 0; retry < 100; retry++) {
|
|
249
|
-
const validation = await client
|
|
250
|
-
.validateSyncRules({
|
|
251
|
-
app_id: project.linked.project_id,
|
|
252
|
-
id: project.linked.instance_id,
|
|
253
|
-
org_id: project.linked.org_id,
|
|
254
|
-
sync_rules: project.syncRulesContent ?? ''
|
|
93
|
+
/**
|
|
94
|
+
* Run the final validation pass.
|
|
95
|
+
* If we reprovisioned above, all non-sync-config tests already passed and their results were
|
|
96
|
+
* printed, so we only need to run SYNC-CONFIG here. We don't re-list the already-run tests
|
|
97
|
+
* as skipped either — the printed intermediate results already communicated their status.
|
|
98
|
+
* If no reprovision was needed, run all requested tests as normal.
|
|
99
|
+
*/
|
|
100
|
+
const finalTestsToRun = didReprovision ? [ValidationTest['SYNC-CONFIG']] : validationTestsFilter.testsToRun;
|
|
101
|
+
// Always use only the user-specified skipped tests. If we reprovisioned, all other requested tests
|
|
102
|
+
// already ran and their results were printed — there's no need to re-surface them as skipped here.
|
|
103
|
+
const finalSkippedTests = validationTestsFilter.skipped;
|
|
104
|
+
const runner = new ValidationsRunner({
|
|
105
|
+
skippedTests: finalSkippedTests,
|
|
106
|
+
tests: getCloudValidations({
|
|
107
|
+
cloudConfigState,
|
|
108
|
+
project,
|
|
109
|
+
serviceConfigState: this.serviceConfig,
|
|
110
|
+
tests: finalTestsToRun
|
|
255
111
|
})
|
|
256
|
-
.catch((error) => {
|
|
257
|
-
if (retry === 99) {
|
|
258
|
-
this.styledError({
|
|
259
|
-
error,
|
|
260
|
-
message: `Failed to validate sync config for instance ${project.linked.instance_id} in project ${project.linked.project_id} in org ${project.linked.org_id}. Ensure the sync config is valid before deploying.`,
|
|
261
|
-
suggestions: ['Check your sync config and try again.']
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
// signal a retry
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
if (!validation) {
|
|
270
|
-
await new Promise((resolve) => {
|
|
271
|
-
setTimeout(resolve, 1000);
|
|
272
|
-
});
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
if (validation.errors.length > 0) {
|
|
276
|
-
this.styledError({
|
|
277
|
-
message: `Sync config validation failed for instance. Validation errors:\n${validation.errors.map((error) => error.message).join('\n')}`,
|
|
278
|
-
suggestions: ['Check your sync config and try again.']
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
// Validation succeeded with no errors
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
async waitForDeployCompletion(params) {
|
|
286
|
-
const { deployResult, indentation = '', logCompletionMessage = true, logScheduledMessage = true, timeoutMs } = params;
|
|
287
|
-
const { client, project } = this;
|
|
288
|
-
if (logScheduledMessage) {
|
|
289
|
-
this.log(`${indentation}Deploy operation has been scheduled. Waiting for completion...`);
|
|
290
|
-
}
|
|
291
|
-
const status = await waitForOperationStatusChange({
|
|
292
|
-
client,
|
|
293
|
-
instanceId: deployResult.id,
|
|
294
|
-
linked: project.linked,
|
|
295
|
-
operationId: deployResult.operation_id,
|
|
296
|
-
timeoutMs
|
|
297
112
|
});
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
this.log(ux.colorize('green', 'Deployment operation completed successfully!'));
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
113
|
+
const result = await runner.runWithProgress({ printSummary: (summary) => this.log(summary) });
|
|
114
|
+
if (!result.passed) {
|
|
305
115
|
this.styledError({
|
|
306
|
-
message:
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
async withDeploy(timeoutMs, fn) {
|
|
311
|
-
const { project } = this;
|
|
312
|
-
const spinner = ora({
|
|
313
|
-
discardStdin: false,
|
|
314
|
-
prefixText: '\nDeploying instance...\n',
|
|
315
|
-
spinner: 'moon',
|
|
316
|
-
suffixText: '\nThis may take a few minutes.\n'
|
|
317
|
-
});
|
|
318
|
-
spinner.start();
|
|
319
|
-
try {
|
|
320
|
-
const deployResult = await fn();
|
|
321
|
-
await this.waitForDeployCompletion({ deployResult, timeoutMs });
|
|
322
|
-
spinner.stop();
|
|
323
|
-
}
|
|
324
|
-
catch (error) {
|
|
325
|
-
spinner.stop();
|
|
326
|
-
this.styledError({
|
|
327
|
-
error,
|
|
328
|
-
message: `Failed to deploy changes to instance ${project.linked.instance_id} in project ${project.linked.project_id} in org ${project.linked.org_id}`,
|
|
329
|
-
suggestions: ['Check your network connection and try again.', 'If the problem persists, contact support.']
|
|
116
|
+
message: 'Validation tests failed. Fix the issues and try deploying again.',
|
|
117
|
+
suggestions: ['Review the validation test results above, fix any issues, and run deploy again.']
|
|
330
118
|
});
|
|
331
119
|
}
|
|
120
|
+
await this.deployAll({ cloudConfigState, deployTimeoutMs, updateSyncConfig: syncConfigHasChanges });
|
|
332
121
|
}
|
|
333
122
|
}
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAEnF,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,sBAAsB,CAAC,iBAAiB,CAAC;IA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kE;gBAC3E,WAAW,EAAE,CAAC,iFAAiF,CAAC;aACjG,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,CAAC;IACtG,CAAC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class DeployServiceConfig extends
|
|
1
|
+
import BaseDeployCommand from '../../api/BaseDeployCommand.js';
|
|
2
|
+
export default class DeployServiceConfig extends BaseDeployCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
7
|
-
'org-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
'deploy-timeout': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
[x: string]: import("@oclif/core/interfaces").Flag<string>;
|
|
11
7
|
};
|
|
12
8
|
static summary: string;
|
|
13
9
|
run(): Promise<void>;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import BaseDeployCommand from '../../api/BaseDeployCommand.js';
|
|
1
2
|
import { DEFAULT_DEPLOY_TIMEOUT_MS } from '../../api/cloud/wait-for-operation.js';
|
|
2
|
-
import
|
|
3
|
-
|
|
3
|
+
import { getCloudValidations } from '../../api/validations/cloud-validations.js';
|
|
4
|
+
import { generateValidationTestFlags } from '../../api/validations/validation-flags.js';
|
|
5
|
+
import { ValidationsRunner } from '../../api/validations/ValidationsRunner.js';
|
|
6
|
+
import { ValidationTest } from '../../api/validations/ValidationTestDefinition.js';
|
|
7
|
+
const SERVICE_CONFIG_VALIDATION_FLAGS = generateValidationTestFlags({
|
|
8
|
+
// No sync config validation for this command
|
|
9
|
+
limitOptions: [ValidationTest.CONFIGURATION, ValidationTest.CONNECTIONS]
|
|
10
|
+
});
|
|
11
|
+
export default class DeployServiceConfig extends BaseDeployCommand {
|
|
4
12
|
static description = 'Deploy only service config changes (without sync config updates).';
|
|
5
13
|
static examples = [
|
|
6
14
|
'<%= config.bin %> <%= command.id %>',
|
|
7
15
|
'<%= config.bin %> <%= command.id %> --instance-id=<id> --project-id=<id>'
|
|
8
16
|
];
|
|
9
17
|
static flags = {
|
|
10
|
-
...
|
|
18
|
+
...SERVICE_CONFIG_VALIDATION_FLAGS.flags
|
|
11
19
|
};
|
|
12
20
|
static summary = '[Cloud only] Deploy only local service config to the linked Cloud instance.';
|
|
13
21
|
async run() {
|
|
@@ -17,14 +25,29 @@ export default class DeployServiceConfig extends DeployAll {
|
|
|
17
25
|
configFileRequired: true
|
|
18
26
|
});
|
|
19
27
|
const deployTimeoutMs = (flags['deploy-timeout'] ?? DEFAULT_DEPLOY_TIMEOUT_MS / 1000) * 1000;
|
|
28
|
+
const validationsFilter = SERVICE_CONFIG_VALIDATION_FLAGS.parseValidationTestFlags(flags);
|
|
20
29
|
// Parse and store for later
|
|
21
|
-
this.parseLocalConfig(project.projectDirectory);
|
|
30
|
+
this.parseLocalConfig(project.projectDirectory, validationsFilter.skipped.includes(ValidationTest.CONFIGURATION));
|
|
22
31
|
// The existing config is required to deploy changes. The instance should have been created already.
|
|
23
32
|
const cloudConfigState = await this.loadCloudConfigState();
|
|
24
33
|
this.log('Performing validations before deploy...');
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
const validationRunner = new ValidationsRunner({
|
|
35
|
+
skippedTests: validationsFilter.skipped,
|
|
36
|
+
tests: getCloudValidations({
|
|
37
|
+
cloudConfigState,
|
|
38
|
+
project,
|
|
39
|
+
serviceConfigState: this.serviceConfig,
|
|
40
|
+
tests: validationsFilter.testsToRun
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
const result = await validationRunner.runWithProgress({ printSummary: (summary) => this.log(summary) });
|
|
44
|
+
if (!result.passed) {
|
|
45
|
+
this.styledError({
|
|
46
|
+
message: 'Validation tests failed. Fix the issues and try deploying again.',
|
|
47
|
+
suggestions: ['Review the validation test results above, fix any issues, and run deploy again.']
|
|
48
|
+
});
|
|
49
|
+
}
|
|
28
50
|
await this.deployAll({ cloudConfigState, deployTimeoutMs, updateSyncConfig: false });
|
|
29
51
|
}
|
|
30
52
|
}
|
|
53
|
+
//# sourceMappingURL=service-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-config.js","sourceRoot":"","sources":["../../../src/commands/deploy/service-config.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAEnF,MAAM,+BAA+B,GAAG,2BAA2B,CAAC;IAClE,6CAA6C;IAC7C,YAAY,EAAE,CAAC,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC,WAAW,CAAC;CACzE,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,iBAAiB;IAChE,MAAM,CAAC,WAAW,GAAG,mEAAmE,CAAC;IACzF,MAAM,CAAC,QAAQ,GAAG;QAChB,qCAAqC;QACrC,0EAA0E;KAC3E,CAAC;IACF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,+BAA+B,CAAC,KAAK;KACzC,CAAC;IACF,MAAM,CAAC,OAAO,GAAG,6EAA6E,CAAC;IAE/F,K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CAAC,iFAAiF,CAAC;aACjG,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { routes } from '@powersync/management-types';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import BaseDeployCommand from '../../api/BaseDeployCommand.js';
|
|
3
|
+
declare const DeploySyncConfig_base: typeof BaseDeployCommand;
|
|
4
|
+
export default class DeploySyncConfig extends DeploySyncConfig_base {
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
6
7
|
static flags: {
|
|
7
|
-
|
|
8
|
-
'instance-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
'org-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
'deploy-timeout': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
[x: string]: import("@oclif/core/interfaces").Flag<string>;
|
|
13
9
|
};
|
|
14
10
|
static summary: string;
|
|
15
11
|
/**
|
|
@@ -22,3 +18,4 @@ export default class DeploySyncConfig extends DeployAll {
|
|
|
22
18
|
}): Promise<void>;
|
|
23
19
|
run(): Promise<void>;
|
|
24
20
|
}
|
|
21
|
+
export {};
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
1
|
import { ux } from '@oclif/core/ux';
|
|
2
|
+
import { WithSyncConfigFilePath } from '@powersync/cli-core';
|
|
3
3
|
import { routes } from '@powersync/management-types';
|
|
4
4
|
import { ObjectId } from 'bson';
|
|
5
|
-
import
|
|
5
|
+
import BaseDeployCommand from '../../api/BaseDeployCommand.js';
|
|
6
6
|
import { DEFAULT_DEPLOY_TIMEOUT_MS } from '../../api/cloud/wait-for-operation.js';
|
|
7
|
-
import
|
|
8
|
-
|
|
7
|
+
import { getCloudValidations } from '../../api/validations/cloud-validations.js';
|
|
8
|
+
import { generateValidationTestFlags } from '../../api/validations/validation-flags.js';
|
|
9
|
+
import { ValidationsRunner } from '../../api/validations/ValidationsRunner.js';
|
|
10
|
+
import { ValidationTest } from '../../api/validations/ValidationTestDefinition.js';
|
|
11
|
+
const SYNC_CONFIG_VALIDATION_FLAGS = generateValidationTestFlags({
|
|
12
|
+
// We currently only validate sync config for this command.
|
|
13
|
+
limitOptions: [ValidationTest['SYNC-CONFIG']]
|
|
14
|
+
});
|
|
15
|
+
export default class DeploySyncConfig extends WithSyncConfigFilePath(BaseDeployCommand) {
|
|
9
16
|
static description = 'Deploy only sync config changes.';
|
|
10
17
|
static examples = [
|
|
11
18
|
'<%= config.bin %> <%= command.id %>',
|
|
12
19
|
'<%= config.bin %> <%= command.id %> --instance-id=<id> --project-id=<id>'
|
|
13
20
|
];
|
|
14
21
|
static flags = {
|
|
15
|
-
...
|
|
16
|
-
'sync-config-file-path': Flags.file({
|
|
17
|
-
description: 'Path to a sync config file. If provided, this file will be validated and deployed instead of the default sync-config.yaml.',
|
|
18
|
-
exists: true
|
|
19
|
-
})
|
|
22
|
+
...SYNC_CONFIG_VALIDATION_FLAGS.flags
|
|
20
23
|
};
|
|
21
24
|
static summary = '[Cloud only] Deploy only local sync config to the linked Cloud instance.';
|
|
22
25
|
/**
|
|
@@ -56,9 +59,15 @@ export default class DeploySyncConfig extends DeployAll {
|
|
|
56
59
|
});
|
|
57
60
|
const { linked } = project;
|
|
58
61
|
const deployTimeoutMs = (flags['deploy-timeout'] ?? DEFAULT_DEPLOY_TIMEOUT_MS / 1000) * 1000;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
if (!project.syncRulesContent) {
|
|
63
|
+
this.styledError({
|
|
64
|
+
message: `Sync config content not loaded. Ensure sync config is present and valid.`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!project.syncRulesContent) {
|
|
68
|
+
this.styledError({
|
|
69
|
+
message: `Sync config content not loaded. Ensure sync config is present and valid.`
|
|
70
|
+
});
|
|
62
71
|
}
|
|
63
72
|
// The existing config is required to deploy changes. The instance should have been created already.
|
|
64
73
|
const cloudConfigState = await this.loadCloudConfigState();
|
|
@@ -72,10 +81,9 @@ export default class DeploySyncConfig extends DeployAll {
|
|
|
72
81
|
this.serviceConfig = {
|
|
73
82
|
_type: linked.type,
|
|
74
83
|
name: cloudConfigState.name,
|
|
75
|
-
...cloudConfigState.config
|
|
76
|
-
...linked
|
|
84
|
+
...cloudConfigState.config
|
|
77
85
|
};
|
|
78
|
-
|
|
86
|
+
// Validate sync config
|
|
79
87
|
const instanceStatus = await this.client
|
|
80
88
|
.getInstanceStatus({
|
|
81
89
|
app_id: project.linked.project_id,
|
|
@@ -92,12 +100,27 @@ export default class DeploySyncConfig extends DeployAll {
|
|
|
92
100
|
if (!instanceStatus.provisioned) {
|
|
93
101
|
this.log(`\nThe instance is not currently provisioned. Triggering a deploy in order to reprovision. This may take a few minutes.\n`);
|
|
94
102
|
// Don't yet update the sync config since the instance is not provisioned, but deploy to trigger provisioning
|
|
95
|
-
await this.
|
|
103
|
+
await this.provision({ cloudConfigState, deployTimeoutMs, indentationLevel: 1 });
|
|
104
|
+
}
|
|
105
|
+
this.log('Performing validations before deploy...');
|
|
106
|
+
const validationsFilter = SYNC_CONFIG_VALIDATION_FLAGS.parseValidationTestFlags(flags);
|
|
107
|
+
const validationRunner = new ValidationsRunner({
|
|
108
|
+
skippedTests: validationsFilter.skipped,
|
|
109
|
+
tests: getCloudValidations({
|
|
110
|
+
cloudConfigState,
|
|
111
|
+
project,
|
|
112
|
+
serviceConfigState: this.serviceConfig,
|
|
113
|
+
tests: validationsFilter.testsToRun
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
const result = await validationRunner.runWithProgress({ printSummary: (summary) => this.log(summary) });
|
|
117
|
+
if (!result.passed) {
|
|
118
|
+
this.styledError({
|
|
119
|
+
message: 'Validation tests failed. Fix the issues and try deploying again.',
|
|
120
|
+
suggestions: ['Review the validation test results above, fix any issues, and run deploy again.']
|
|
121
|
+
});
|
|
96
122
|
}
|
|
97
|
-
// Validate sync config
|
|
98
|
-
this.log('\tValidating sync config...');
|
|
99
|
-
await this.validateSyncConfig();
|
|
100
|
-
this.log('Validations completed successfully.\n');
|
|
101
123
|
await this.deploySyncConfig({ cloudConfigState, timeout: deployTimeoutMs });
|
|
102
124
|
}
|
|
103
125
|
}
|
|
126
|
+
//# sourceMappingURL=sync-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-config.js","sourceRoot":"","sources":["../../../src/commands/deploy/sync-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAEnF,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;IAC/D,2DAA2D;IAC3D,YAA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AAE,iBAAiB,CAAC,OAAO;YACvC,KAAK,EAAE,mBAAmB,CAAC;gBACzB,gBAAgB;gBAChB,OAAO;gBACP,kBAAkB,EAAE,IAAI,CAAC,aAAc;gBACvC,KAAK,EAAE,iBAAiB,CAAC,UAAU;aACpC,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,CAAC;gBACf,OAAO,EAAE,kEAAkE;gBAC3E,WAAW,EAAE,CAAC,iFAAiF,CAAC;aACjG,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC9E,CAAC"}
|
|
@@ -3,10 +3,6 @@ export default class Destroy extends CloudInstanceCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
'instance-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
'org-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
6
|
confirm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
7
|
};
|
|
12
8
|
static summary: string;
|