mulesoft-anypoint-cli-agent-fabric-plugin 1.2.10 → 1.3.0
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 +117 -8
- package/dist/commands/agent-network/project/undeploy.d.ts +2 -1
- package/dist/commands/agent-network/project/undeploy.js +49 -33
- package/dist/commands/agent-network/project/undeploy.js.map +1 -1
- package/dist/commands/agent-network/project/unpublish.d.ts +11 -2
- package/dist/commands/agent-network/project/unpublish.js +195 -58
- package/dist/commands/agent-network/project/unpublish.js.map +1 -1
- package/dist/errors/error-factory.d.ts +1 -0
- package/dist/errors/error-factory.js +8 -0
- package/dist/errors/error-factory.js.map +1 -1
- package/dist/helpers/project/constants.d.ts +1 -0
- package/dist/helpers/project/constants.js +1 -0
- package/dist/helpers/project/constants.js.map +1 -1
- package/dist/helpers/utils.d.ts +15 -0
- package/dist/helpers/utils.js +22 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/utils/builders/component-factory.d.ts +2 -0
- package/dist/utils/builders/component-factory.js +24 -0
- package/dist/utils/builders/component-factory.js.map +1 -0
- package/dist/utils/builders/local-space-resolver.d.ts +18 -0
- package/dist/utils/builders/local-space-resolver.js +43 -0
- package/dist/utils/builders/local-space-resolver.js.map +1 -0
- package/dist/utils/builders/network-lock.d.ts +1 -0
- package/dist/utils/builders/network-lock.js +10 -0
- package/dist/utils/builders/network-lock.js.map +1 -1
- package/dist/utils/builders/project-builder.d.ts +1 -0
- package/dist/utils/builders/project-builder.js.map +1 -1
- package/dist/utils/builders/remote-space-resolver.d.ts +4 -0
- package/dist/utils/builders/remote-space-resolver.js +94 -40
- package/dist/utils/builders/remote-space-resolver.js.map +1 -1
- package/dist/utils/dry-run/dry-run-render.d.ts +19 -0
- package/dist/utils/dry-run/dry-run-render.js +137 -0
- package/dist/utils/dry-run/dry-run-render.js.map +1 -0
- package/dist/utils/facets/agent-graph-facet.js +3 -3
- package/dist/utils/facets/agent-graph-facet.js.map +1 -1
- package/dist/utils/facets/asset-facet.js +7 -9
- package/dist/utils/facets/asset-facet.js.map +1 -1
- package/dist/utils/facets/mule-application-facet.js +2 -2
- package/dist/utils/facets/mule-application-facet.js.map +1 -1
- package/dist/utils/naming.d.ts +1 -0
- package/dist/utils/naming.js +4 -0
- package/dist/utils/naming.js.map +1 -1
- package/package.json +1 -1
- package/scripts/resolve-version.sh +37 -9
- package/scripts/resolve-version.test.sh +10 -0
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ This plugin provides CLI commands for managing Agent Fabric projects, specifical
|
|
|
9
9
|
* [`anypoint-cli-agent-fabric-plugin agent-network project create`](#anypoint-cli-agent-fabric-plugin-agent-network-project-create)
|
|
10
10
|
* [`anypoint-cli-agent-fabric-plugin agent-network project deploy`](#anypoint-cli-agent-fabric-plugin-agent-network-project-deploy)
|
|
11
11
|
* [`anypoint-cli-agent-fabric-plugin agent-network project publish`](#anypoint-cli-agent-fabric-plugin-agent-network-project-publish)
|
|
12
|
+
* [`anypoint-cli-agent-fabric-plugin agent-network project undeploy`](#anypoint-cli-agent-fabric-plugin-agent-network-project-undeploy)
|
|
13
|
+
* [`anypoint-cli-agent-fabric-plugin agent-network project unpublish`](#anypoint-cli-agent-fabric-plugin-agent-network-project-unpublish)
|
|
12
14
|
* [`anypoint-cli-agent-fabric-plugin agent-network setup gateways`](#anypoint-cli-agent-fabric-plugin-agent-network-setup-gateways)
|
|
13
15
|
* [`anypoint-cli-agent-fabric-plugin conf [KEY] [VALUE]`](#anypoint-cli-agent-fabric-plugin-conf-key-value)
|
|
14
16
|
* [`anypoint-cli-agent-fabric-plugin help [COMMAND]`](#anypoint-cli-agent-fabric-plugin-help-command)
|
|
@@ -30,7 +32,8 @@ FLAGS
|
|
|
30
32
|
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
31
33
|
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
32
34
|
--debug Enable debug mode
|
|
33
|
-
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
35
|
+
--environment=<value> [default: prod-eu] Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
36
|
+
variable.
|
|
34
37
|
--forceUpdate Force update the dependencies
|
|
35
38
|
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
36
39
|
environment variable.
|
|
@@ -68,7 +71,8 @@ FLAGS
|
|
|
68
71
|
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
69
72
|
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
70
73
|
--[no-]create-dir Create new directory at output-dir for the new project using project's name
|
|
71
|
-
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
74
|
+
--environment=<value> [default: prod-eu] Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
75
|
+
variable.
|
|
72
76
|
--group-id=<value> Group Id (GAV)
|
|
73
77
|
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
74
78
|
environment variable.
|
|
@@ -94,7 +98,7 @@ USAGE
|
|
|
94
98
|
]] [--client_secret <value> ] [--bearer <value> | | ] [--organization <value>] [--environment <value>] [--host
|
|
95
99
|
<value>] [--collectMetrics] [-g <value>] [-i <value>] [-e <value>] [-t <value>] [--dont-wait-for-agent-network]
|
|
96
100
|
[--disable-tracing] [--property <value>] [--path <value>] [--max-retries <value>] [--request-timeout <value>]
|
|
97
|
-
[--process-timeout <value>] [--json]
|
|
101
|
+
[--process-timeout <value>] [--disable-autopublish] [--json]
|
|
98
102
|
|
|
99
103
|
FLAGS
|
|
100
104
|
-e, --egress-gw=<value> Name of the target egress gw (separate-gateways mode; requires --ingress-gw). When no
|
|
@@ -112,16 +116,18 @@ FLAGS
|
|
|
112
116
|
--client_id=<value> Client ID. You can define this in the ANYPOINT_CLIENT_ID environment variable.
|
|
113
117
|
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
114
118
|
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
119
|
+
--disable-autopublish Disable automatic publishing when lock file is not found.
|
|
115
120
|
--disable-tracing Disable tracing functionalities
|
|
116
121
|
--dont-wait-for-agent-network Do not wait for the Agent Network to be ready
|
|
117
|
-
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV
|
|
122
|
+
--environment=<value> [default: prod-eu] Environment Name. You can define this in the ANYPOINT_ENV
|
|
123
|
+
environment variable.
|
|
118
124
|
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
119
125
|
environment variable.
|
|
120
126
|
--max-retries=<value> [default: 3] Max retries to check the status of the deploying application.
|
|
121
127
|
--organization=<value> Organization Name. You can define this in the ANYPOINT_ORG environment variable.
|
|
122
128
|
--password=<value> Password. You can define this in the ANYPOINT_PASSWORD environment variable.
|
|
123
129
|
--path=<value> [default: .] The path to the project.
|
|
124
|
-
--process-timeout=<value> [default:
|
|
130
|
+
--process-timeout=<value> [default: 900000] Request timeout in millis.
|
|
125
131
|
--property=<value>... [default: ] Property to override in format name:value (e.g., --property apiKey:sk-xxx)
|
|
126
132
|
--request-timeout=<value> [default: 60000] Request timeout in millis.
|
|
127
133
|
--username=<value> Username. You can define this in the ANYPOINT_USERNAME environment variable.
|
|
@@ -158,7 +164,8 @@ FLAGS
|
|
|
158
164
|
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
159
165
|
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
160
166
|
--debug Enable debug mode
|
|
161
|
-
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
167
|
+
--environment=<value> [default: prod-eu] Environment Name. You can define this in the ANYPOINT_ENV environment
|
|
168
|
+
variable.
|
|
162
169
|
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
163
170
|
environment variable.
|
|
164
171
|
--organization=<value> Organization Name. You can define this in the ANYPOINT_ORG environment variable.
|
|
@@ -176,6 +183,107 @@ EXAMPLES
|
|
|
176
183
|
$ agent-network project publish
|
|
177
184
|
```
|
|
178
185
|
|
|
186
|
+
## `anypoint-cli-agent-fabric-plugin agent-network project undeploy`
|
|
187
|
+
|
|
188
|
+
Undeploys the Agent Network application, removing all deployed resources
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
USAGE
|
|
192
|
+
$ anypoint-cli-agent-fabric-plugin agent-network project undeploy [--password <value> [--username <value> | --client_id <value> |
|
|
193
|
+
]] [--client_secret <value> ] [--bearer <value> | | ] [--organization <value>] [--environment <value>] [--host
|
|
194
|
+
<value>] [--collectMetrics] [--path <value> | --gav <value>] [--api-version <value>] [--request-timeout <value>]
|
|
195
|
+
[--process-timeout <value>] [--dry-run | ] [--json]
|
|
196
|
+
|
|
197
|
+
FLAGS
|
|
198
|
+
--api-version=<value> [default: v1] Api Version used to discover remotely deployed resources when using --gav.
|
|
199
|
+
--bearer=<value> Token Bearer. You can define this in the ANYPOINT_BEARER environment variable.
|
|
200
|
+
--client_id=<value> Client ID. You can define this in the ANYPOINT_CLIENT_ID environment variable.
|
|
201
|
+
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
202
|
+
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
203
|
+
--dry-run Preview the deploy-plane resources that would be undeployed without deleting anything.
|
|
204
|
+
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV environment variable.
|
|
205
|
+
--gav=<value> Parent asset GAV (groupId:assetId:version). Discovers deployed resources remotely.
|
|
206
|
+
Requires an environment to be selected.
|
|
207
|
+
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
208
|
+
environment variable.
|
|
209
|
+
--organization=<value> Organization Name. You can define this in the ANYPOINT_ORG environment variable.
|
|
210
|
+
--password=<value> Password. You can define this in the ANYPOINT_PASSWORD environment variable.
|
|
211
|
+
--path=<value> The path to the project. Discovers deployed resources remotely from the project lock
|
|
212
|
+
file. Requires an environment to be selected.
|
|
213
|
+
--process-timeout=<value> [default: 900000] Process timeout in millis.
|
|
214
|
+
--request-timeout=<value> [default: 60000] Request timeout in millis.
|
|
215
|
+
--username=<value> Username. You can define this in the ANYPOINT_USERNAME environment variable.
|
|
216
|
+
|
|
217
|
+
GLOBAL FLAGS
|
|
218
|
+
--json Format output as json.
|
|
219
|
+
|
|
220
|
+
DESCRIPTION
|
|
221
|
+
Undeploys the Agent Network application, removing all deployed resources
|
|
222
|
+
|
|
223
|
+
EXAMPLES
|
|
224
|
+
$ agent-network project undeploy --environment Sandbox
|
|
225
|
+
|
|
226
|
+
$ agent-network project undeploy --path ./my-project --environment Sandbox
|
|
227
|
+
|
|
228
|
+
$ agent-network project undeploy --gav myOrgId:my-network:0.0.0 --environment Sandbox
|
|
229
|
+
|
|
230
|
+
$ agent-network project undeploy --dry-run --environment Sandbox
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## `anypoint-cli-agent-fabric-plugin agent-network project unpublish`
|
|
234
|
+
|
|
235
|
+
Removes the Agent Network assets from Anypoint Exchange. By default performs a soft-delete: the asset version is deleted and can no longer be used, but its GAV (groupId, assetId, version) stays reserved and cannot be claimed by a new asset, and the removal cannot be restored or undeleted. To free the GAV for reuse by another asset, use --hard-delete for an irreversible permanent removal.
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
USAGE
|
|
239
|
+
$ anypoint-cli-agent-fabric-plugin agent-network project unpublish [--password <value> [--username <value> | --client_id <value> |
|
|
240
|
+
]] [--client_secret <value> ] [--bearer <value> | | ] [--organization <value>] [--environment <value>] [--host
|
|
241
|
+
<value>] [--collectMetrics] [--path <value> | --gav <value>] [--api-version <value>] [--hard-delete] [--dry-run | ]
|
|
242
|
+
[--json]
|
|
243
|
+
|
|
244
|
+
FLAGS
|
|
245
|
+
--api-version=<value> [default: v1] Api Version used to discover remotely published assets when using --gav.
|
|
246
|
+
--bearer=<value> Token Bearer. You can define this in the ANYPOINT_BEARER environment variable.
|
|
247
|
+
--client_id=<value> Client ID. You can define this in the ANYPOINT_CLIENT_ID environment variable.
|
|
248
|
+
--client_secret=<value> Client Secret. You can define this in the ANYPOINT_CLIENT_SECRET environment variable.
|
|
249
|
+
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
250
|
+
--dry-run Preview the Exchange assets that would be unpublished without deleting anything.
|
|
251
|
+
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV environment variable.
|
|
252
|
+
--gav=<value> Parent asset GAV (groupId:assetId:version). Discovers assets remotely. Use --environment
|
|
253
|
+
to enable the active API instances safety check.
|
|
254
|
+
--hard-delete Permanently delete assets from Exchange. Unlike the default soft-delete, this frees the
|
|
255
|
+
asset GAV (groupId, assetId, version) so it can be reused by another asset. This cannot
|
|
256
|
+
be undone. Assets with dependent versions, API instances, or policies applied to managed
|
|
257
|
+
APIs must have those removed first.
|
|
258
|
+
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
259
|
+
environment variable.
|
|
260
|
+
--organization=<value> Organization Name. You can define this in the ANYPOINT_ORG environment variable.
|
|
261
|
+
--password=<value> Password. You can define this in the ANYPOINT_PASSWORD environment variable.
|
|
262
|
+
--path=<value> The path to the project. Reads the published assets from the project lock file. Select
|
|
263
|
+
an environment to enable the active API instances safety check.
|
|
264
|
+
--username=<value> Username. You can define this in the ANYPOINT_USERNAME environment variable.
|
|
265
|
+
|
|
266
|
+
GLOBAL FLAGS
|
|
267
|
+
--json Format output as json.
|
|
268
|
+
|
|
269
|
+
DESCRIPTION
|
|
270
|
+
Removes the Agent Network assets from Anypoint Exchange. By default performs a soft-delete: the asset version is
|
|
271
|
+
deleted and can no longer be used, but its GAV (groupId, assetId, version) stays reserved and cannot be claimed by a
|
|
272
|
+
new asset, and the removal cannot be restored or undeleted. To free the GAV for reuse by another asset, use
|
|
273
|
+
--hard-delete for an irreversible permanent removal.
|
|
274
|
+
|
|
275
|
+
EXAMPLES
|
|
276
|
+
$ agent-network project unpublish --environment Sandbox
|
|
277
|
+
|
|
278
|
+
$ agent-network project unpublish --path ./my-project --environment Sandbox
|
|
279
|
+
|
|
280
|
+
$ agent-network project unpublish --hard-delete --environment Sandbox
|
|
281
|
+
|
|
282
|
+
$ agent-network project unpublish --gav myOrgId:my-network:0.0.0 --environment Sandbox
|
|
283
|
+
|
|
284
|
+
$ agent-network project unpublish --dry-run --environment Sandbox
|
|
285
|
+
```
|
|
286
|
+
|
|
179
287
|
## `anypoint-cli-agent-fabric-plugin agent-network setup gateways`
|
|
180
288
|
|
|
181
289
|
Set up the Agent Network environment with the required gateways.
|
|
@@ -199,7 +307,8 @@ FLAGS
|
|
|
199
307
|
variable.
|
|
200
308
|
--[no-]collectMetrics collect metrics. You can define this in the COLLECT_METRICS environment variable.
|
|
201
309
|
--dont-wait-for-gateways-running Do not wait for the Gateways to be running
|
|
202
|
-
--environment=<value> Environment Name. You can define this in the ANYPOINT_ENV
|
|
310
|
+
--environment=<value> [default: prod-eu] Environment Name. You can define this in the ANYPOINT_ENV
|
|
311
|
+
environment variable.
|
|
203
312
|
--host=anypoint.mulesoft.com [default: anypoint.mulesoft.com] Host URL. You can define this in the ANYPOINT_HOST
|
|
204
313
|
environment variable.
|
|
205
314
|
--organization=<value> Organization Name. You can define this in the ANYPOINT_ORG environment variable.
|
|
@@ -283,7 +392,7 @@ $ npm install -g @mulesoft/anypoint-cli-agent-fabric-plugin
|
|
|
283
392
|
$ anypoint-cli-agent-fabric-plugin COMMAND
|
|
284
393
|
running command...
|
|
285
394
|
$ anypoint-cli-agent-fabric-plugin (--version)
|
|
286
|
-
@mulesoft/anypoint-cli-agent-fabric-plugin/1.
|
|
395
|
+
@mulesoft/anypoint-cli-agent-fabric-plugin/1.2.0 darwin-arm64 node-v20.19.3
|
|
287
396
|
$ anypoint-cli-agent-fabric-plugin --help [COMMAND]
|
|
288
397
|
USAGE
|
|
289
398
|
$ anypoint-cli-agent-fabric-plugin COMMAND
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthenticationBaseCommand } from 'anypoint-cli-command-lib';
|
|
2
2
|
export default class Undeploy extends AuthenticationBaseCommand {
|
|
3
|
-
static hidden: boolean;
|
|
4
3
|
static description: string;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
@@ -10,6 +9,7 @@ export default class Undeploy extends AuthenticationBaseCommand {
|
|
|
10
9
|
'request-timeout': import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
11
10
|
'process-timeout': import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
12
11
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
13
|
"skip-environment": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
14
|
collectMetrics: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
15
|
host: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
@@ -25,5 +25,6 @@ export default class Undeploy extends AuthenticationBaseCommand {
|
|
|
25
25
|
run(): Promise<void>;
|
|
26
26
|
private resolveFromGav;
|
|
27
27
|
private resolveFromLocal;
|
|
28
|
+
private resolveRemotely;
|
|
28
29
|
protected toErrorJson(err: any): any;
|
|
29
30
|
}
|
|
@@ -14,12 +14,13 @@ const error_factory_1 = require("../../../errors/error-factory");
|
|
|
14
14
|
const utils_1 = require("../../../helpers/utils");
|
|
15
15
|
const project_builder_1 = require("../../../utils/builders/project-builder");
|
|
16
16
|
const project_builder_impl_1 = require("../../../utils/builders/project-builder-impl");
|
|
17
|
-
const
|
|
17
|
+
const network_lock_1 = require("../../../utils/builders/network-lock");
|
|
18
18
|
const facets_1 = require("../../../utils/facets/facets");
|
|
19
19
|
const request_utils_1 = require("../../../helpers/request-utils");
|
|
20
20
|
const constants_1 = require("../../../utils/constants");
|
|
21
21
|
const remote_space_resolver_1 = require("../../../utils/builders/remote-space-resolver");
|
|
22
22
|
const request_logging_1 = require("../../../helpers/request-logging");
|
|
23
|
+
const dry_run_render_1 = require("../../../utils/dry-run/dry-run-render");
|
|
23
24
|
class Undeploy extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
24
25
|
async run() {
|
|
25
26
|
const { flags } = await this.parse(Undeploy);
|
|
@@ -30,8 +31,18 @@ class Undeploy extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
30
31
|
node_events_1.EventEmitter.defaultMaxListeners = constants_1.MAX_EVENT_LISTENERS;
|
|
31
32
|
const { space, projectName } = flags.gav ?
|
|
32
33
|
await this.resolveFromGav(flags.gav, flags['api-version']) :
|
|
33
|
-
this.resolveFromLocal(flags.path);
|
|
34
|
-
|
|
34
|
+
await this.resolveFromLocal(flags.path);
|
|
35
|
+
const resources = (0, dry_run_render_1.collectUndeployResources)(space);
|
|
36
|
+
if (flags['dry-run']) {
|
|
37
|
+
if (flags.json) {
|
|
38
|
+
logger_1.Log.print(JSON.stringify((0, dry_run_render_1.toDryRunJson)(resources, 'resources'), null, 2));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
(0, dry_run_render_1.renderDryRun)(resources, 'resources', 'undeployed');
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (Object.keys(space.components).length === 0) {
|
|
35
46
|
logger_1.Log.info('No deployed resources found. Nothing to undeploy.');
|
|
36
47
|
return;
|
|
37
48
|
}
|
|
@@ -60,56 +71,55 @@ class Undeploy extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
60
71
|
});
|
|
61
72
|
}
|
|
62
73
|
async resolveFromGav(gav, apiVersion) {
|
|
74
|
+
return this.resolveRemotely((0, utils_1.parseGAVFlag)(gav), apiVersion, 'GAV groupId', true);
|
|
75
|
+
}
|
|
76
|
+
// Local undeploy derives the parent GAV + apiVersion from the network lock file
|
|
77
|
+
// (the authoritative record of what was published) and then discovers deployed
|
|
78
|
+
// resources remotely — the same path as --gav. The serialized target/ Space is not
|
|
79
|
+
// used because it carries no deployment facet state (connectionIds, deployment names)
|
|
80
|
+
// that undeploy needs, and it diverges from what is actually deployed after a clean.
|
|
81
|
+
async resolveFromLocal(path) {
|
|
82
|
+
const projectPath = path || process.cwd();
|
|
83
|
+
const exchangeJsonPath = (0, node_path_1.join)(projectPath, constants_1.DESCRIPTOR_FILE);
|
|
84
|
+
const agentNetworkDescriptor = (0, utils_1.safeJsonFileParse)(exchangeJsonPath).jsonObject;
|
|
85
|
+
const targetDir = (0, node_path_1.join)(projectPath, 'target');
|
|
86
|
+
const lock = (0, network_lock_1.readNetworkLock)(targetDir, agentNetworkDescriptor.name);
|
|
87
|
+
const parentGav = { groupId: lock.groupId, assetId: lock.assetId, version: lock.version };
|
|
88
|
+
return this.resolveRemotely(parentGav, lock.versionGroup, 'lock file groupId', false);
|
|
89
|
+
}
|
|
90
|
+
async resolveRemotely(parentGav, apiVersion, groupIdLabel, resolveVersionGroup) {
|
|
63
91
|
var _a, _b, _c, _d, _e;
|
|
64
|
-
const parentGav = (0, utils_1.parseGAVFlag)(gav);
|
|
65
92
|
if (!(0, utils_1.validateOrganizationAccess)((_a = this.session) === null || _a === void 0 ? void 0 : _a.account, parentGav.groupId)) {
|
|
66
93
|
throw error_factory_1.ErrorFactory.genericError(`You do not have access to organization '${parentGav.groupId}'.`);
|
|
67
94
|
}
|
|
68
|
-
|
|
69
|
-
if (parentGav.groupId !== selectedOrgId) {
|
|
70
|
-
throw error_factory_1.ErrorFactory.genericError(`GAV groupId '${parentGav.groupId}' does not match the selected organization '${selectedOrgId}'. ` +
|
|
71
|
-
'Switch to the correct organization or provide a GAV whose groupId matches your selected org.');
|
|
72
|
-
}
|
|
95
|
+
(0, utils_1.assertOrgSelected)(parentGav.groupId, (_c = (_b = this.session) === null || _b === void 0 ? void 0 : _b.selectedOrganization) === null || _c === void 0 ? void 0 : _c.id, groupIdLabel);
|
|
73
96
|
const environmentId = (_e = (_d = this.session) === null || _d === void 0 ? void 0 : _d.selectedEnvironment) === null || _e === void 0 ? void 0 : _e.id;
|
|
74
97
|
if (!environmentId) {
|
|
75
|
-
throw error_factory_1.ErrorFactory.genericError('An environment must be selected
|
|
98
|
+
throw error_factory_1.ErrorFactory.genericError('An environment must be selected for undeploy. Use --environment to specify one.');
|
|
76
99
|
}
|
|
77
|
-
const
|
|
100
|
+
const versionGroup = resolveVersionGroup ?
|
|
101
|
+
await (0, remote_space_resolver_1.resolveParentVersionGroup)(this.req, parentGav, apiVersion) :
|
|
102
|
+
apiVersion;
|
|
103
|
+
const resolver = new remote_space_resolver_1.RemoteSpaceResolver(this.req, parentGav, parentGav.groupId, versionGroup, environmentId);
|
|
78
104
|
const space = await resolver.resolveForUndeploy();
|
|
79
105
|
return { space, projectName: parentGav.assetId };
|
|
80
106
|
}
|
|
81
|
-
resolveFromLocal(path) {
|
|
82
|
-
var _a;
|
|
83
|
-
const projectPath = path || process.cwd();
|
|
84
|
-
const targetDir = (0, node_path_1.join)(projectPath, 'target');
|
|
85
|
-
const spaceSerializer = new space_serializer_1.SpaceSerializer(targetDir);
|
|
86
|
-
const loadedSpace = spaceSerializer.load();
|
|
87
|
-
if (!loadedSpace) {
|
|
88
|
-
throw error_factory_1.ErrorFactory.invalidOrNotBuiltAgentNetworkProject();
|
|
89
|
-
}
|
|
90
|
-
const exchangeJsonPath = (0, node_path_1.join)(projectPath, constants_1.DESCRIPTOR_FILE);
|
|
91
|
-
const agentNetworkDescriptor = (0, utils_1.safeJsonFileParse)(exchangeJsonPath).jsonObject;
|
|
92
|
-
if (!(0, utils_1.validateOrganizationAccess)((_a = this.session) === null || _a === void 0 ? void 0 : _a.account, agentNetworkDescriptor.groupId)) {
|
|
93
|
-
throw error_factory_1.ErrorFactory.genericError(`You do not have access to organization '${agentNetworkDescriptor.groupId}'.`);
|
|
94
|
-
}
|
|
95
|
-
return { space: loadedSpace, projectName: agentNetworkDescriptor.name };
|
|
96
|
-
}
|
|
97
107
|
toErrorJson(err) {
|
|
98
108
|
return { error: { ...err, message: err.message } };
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
|
-
Undeploy.hidden = true;
|
|
102
111
|
Undeploy.description = 'Undeploys the Agent Network application, removing all deployed resources';
|
|
103
112
|
Undeploy.examples = [
|
|
104
|
-
'$ agent-network project undeploy',
|
|
105
|
-
'$ agent-network project undeploy --path ./my-project',
|
|
106
|
-
'$ agent-network project undeploy --
|
|
107
|
-
'$ agent-network project undeploy --
|
|
113
|
+
'$ agent-network project undeploy --environment Sandbox',
|
|
114
|
+
'$ agent-network project undeploy --path ./my-project --environment Sandbox',
|
|
115
|
+
'$ agent-network project undeploy --gav myOrgId:my-network:0.0.0 --environment Sandbox',
|
|
116
|
+
'$ agent-network project undeploy --dry-run --environment Sandbox',
|
|
108
117
|
];
|
|
109
118
|
Undeploy.flags = {
|
|
110
119
|
...anypoint_cli_command_lib_1.AuthenticationBaseCommand.flags,
|
|
111
120
|
path: core_1.Flags.file({
|
|
112
|
-
description: 'The path to the project.'
|
|
121
|
+
description: 'The path to the project. Discovers deployed resources remotely from the ' +
|
|
122
|
+
'project lock file. Requires an environment to be selected.',
|
|
113
123
|
exclusive: ['gav'],
|
|
114
124
|
}),
|
|
115
125
|
gav: core_1.Flags.string({
|
|
@@ -135,6 +145,12 @@ Undeploy.flags = {
|
|
|
135
145
|
force: core_1.Flags.boolean({
|
|
136
146
|
description: 'Skip confirmation prompt.',
|
|
137
147
|
default: false,
|
|
148
|
+
hidden: true,
|
|
149
|
+
}),
|
|
150
|
+
'dry-run': core_1.Flags.boolean({
|
|
151
|
+
description: 'Preview the deploy-plane resources that would be undeployed without deleting anything.',
|
|
152
|
+
default: false,
|
|
153
|
+
exclusive: ['force'],
|
|
138
154
|
}),
|
|
139
155
|
};
|
|
140
156
|
Undeploy.enableJsonFlag = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undeploy.js","sourceRoot":"","sources":["../../../../src/commands/agent-network/project/undeploy.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,6CAAwC;AACxC,sCAAiC;AACjC,uEAAkE;AAClE,kDAAyC;AACzC,yCAA8B;AAC9B,iEAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"undeploy.js","sourceRoot":"","sources":["../../../../src/commands/agent-network/project/undeploy.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,6CAAwC;AACxC,sCAAiC;AACjC,uEAAkE;AAClE,kDAAyC;AACzC,yCAA8B;AAC9B,iEAA0D;AAC1D,kDAAiK;AACjK,6EAAqE;AACrE,uFAAuF;AACvF,uEAAoE;AACpE,yDAA0D;AAE1D,kEAA+F;AAC/F,wDAA6E;AAC7E,yFAA4G;AAC5G,sEAAmE;AACnE,0EAA0G;AAE1G,MAAqB,QAAS,SAAQ,oDAAyB;IAoD7D,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC1C,MAAM,kBAAkB,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACnD,MAAM,kBAAkB,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAEnD,MAAM,kBAAkB,GAAG,IAAA,oCAAkB,EAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAEvD,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;YACjC,0BAAY,CAAC,mBAAmB,GAAG,+BAAmB,CAAA;YAEtD,MAAM,EAAC,KAAK,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;gBACtC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,C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,2BAA2B;QACxC,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb,CAAC;IACF,SAAS,EAAE,YAAK,CAAC,OAAO,CAAC;QACvB,WAAW,EAAE,wFAAwF;QACrG,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CAAC;CACH,CAAA;AAEa,uBAAc,GAAG,IAAI,CAAC;kBAlDjB,QAAQ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthenticationBaseCommand } from 'anypoint-cli-command-lib';
|
|
2
2
|
export default class Unpublish extends AuthenticationBaseCommand {
|
|
3
|
-
static hidden: boolean;
|
|
4
3
|
static description: string;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
@@ -8,7 +7,8 @@ export default class Unpublish extends AuthenticationBaseCommand {
|
|
|
8
7
|
gav: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
9
8
|
'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
10
9
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
|
|
10
|
+
"hard-delete": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
"skip-environment": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
13
|
collectMetrics: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
14
|
host: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
@@ -22,7 +22,16 @@ export default class Unpublish extends AuthenticationBaseCommand {
|
|
|
22
22
|
};
|
|
23
23
|
static enableJsonFlag: boolean;
|
|
24
24
|
run(): Promise<void>;
|
|
25
|
+
private runDryRun;
|
|
26
|
+
private confirmUnpublish;
|
|
27
|
+
private performUnpublish;
|
|
28
|
+
private buildStageContext;
|
|
25
29
|
private resolveFromGav;
|
|
30
|
+
private guardAgainstDeployedResources;
|
|
31
|
+
private guardWithoutEnvironment;
|
|
32
|
+
private handleGuardError;
|
|
33
|
+
private collectDeployedResourcesForDryRun;
|
|
34
|
+
private resolveDeployedResources;
|
|
26
35
|
private resolveFromLocal;
|
|
27
36
|
protected toErrorJson(err: any): any;
|
|
28
37
|
}
|