@aws-cdk/toolkit-lib 0.1.5 → 0.1.6
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/build-info.json +2 -2
- package/lib/actions/deploy/index.d.ts +1 -17
- package/lib/actions/deploy/index.js +2 -20
- package/lib/api/aws-cdk.js +548 -267
- package/lib/api/aws-cdk.js.map +4 -4
- package/lib/api/shared-private.js +189 -30
- package/lib/api/shared-private.js.map +4 -4
- package/lib/api/shared-public.d.ts +158 -4
- package/lib/api/shared-public.js +10 -0
- package/lib/api/shared-public.js.map +4 -4
- package/lib/private/util.js +13 -3
- package/lib/private/util.js.map +2 -2
- package/lib/toolkit/toolkit.js +2 -2
- package/package.json +3 -4
|
@@ -30,10 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// lib/api/shared-private.ts
|
|
31
31
|
var shared_private_exports = {};
|
|
32
32
|
__export(shared_private_exports, {
|
|
33
|
+
FakeIoHost: () => FakeIoHost,
|
|
33
34
|
IO: () => IO,
|
|
35
|
+
IoDefaultMessages: () => IoDefaultMessages,
|
|
34
36
|
IoHelper: () => IoHelper,
|
|
35
37
|
SPAN: () => SPAN,
|
|
36
38
|
SpanMaker: () => SpanMaker,
|
|
39
|
+
TestIoHost: () => TestIoHost,
|
|
37
40
|
asIoHelper: () => asIoHelper,
|
|
38
41
|
confirm: () => confirm,
|
|
39
42
|
debug: () => debug,
|
|
@@ -130,19 +133,20 @@ var SpanMaker = class {
|
|
|
130
133
|
this.definition = definition;
|
|
131
134
|
this.ioHelper = ioHelper;
|
|
132
135
|
}
|
|
133
|
-
async begin(
|
|
136
|
+
async begin(a, b) {
|
|
134
137
|
const spanId = uuid.v4();
|
|
135
138
|
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
136
139
|
const notify = (msg) => {
|
|
137
140
|
return this.ioHelper.notify(withSpanId(spanId, msg));
|
|
138
141
|
};
|
|
139
|
-
const
|
|
140
|
-
const
|
|
142
|
+
const startInput = parseArgs(a, b);
|
|
143
|
+
const startMsg = startInput.message ?? `Starting ${this.definition.name} ...`;
|
|
144
|
+
const startPayload = startInput.payload;
|
|
141
145
|
await notify(this.definition.start.msg(
|
|
142
|
-
|
|
146
|
+
startMsg,
|
|
143
147
|
startPayload
|
|
144
148
|
));
|
|
145
|
-
const
|
|
149
|
+
const timingMsgTemplate = "\n\u2728 %s time: %ds\n";
|
|
146
150
|
const time = () => {
|
|
147
151
|
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - startTime;
|
|
148
152
|
return {
|
|
@@ -151,13 +155,7 @@ var SpanMaker = class {
|
|
|
151
155
|
};
|
|
152
156
|
};
|
|
153
157
|
return {
|
|
154
|
-
elapsedTime: async (
|
|
155
|
-
if (msg) {
|
|
156
|
-
await notify({
|
|
157
|
-
...msg,
|
|
158
|
-
data: msg.data
|
|
159
|
-
});
|
|
160
|
-
}
|
|
158
|
+
elapsedTime: async () => {
|
|
161
159
|
return time();
|
|
162
160
|
},
|
|
163
161
|
notify: async (msg) => {
|
|
@@ -165,18 +163,19 @@ var SpanMaker = class {
|
|
|
165
163
|
},
|
|
166
164
|
timing: async (maker, message2) => {
|
|
167
165
|
const duration = time();
|
|
168
|
-
const
|
|
169
|
-
await notify(maker.msg(
|
|
166
|
+
const timingMsg = message2 ? message2 : util.format(timingMsgTemplate, this.definition.name, duration.asSec);
|
|
167
|
+
await notify(maker.msg(timingMsg, {
|
|
170
168
|
duration: duration.asMs
|
|
171
169
|
}));
|
|
172
170
|
return duration;
|
|
173
171
|
},
|
|
174
|
-
end: async (
|
|
172
|
+
end: async (x, y) => {
|
|
175
173
|
const duration = time();
|
|
176
|
-
const
|
|
177
|
-
const
|
|
174
|
+
const endInput = parseArgs(x, y);
|
|
175
|
+
const endMsg = endInput.message ?? util.format(timingMsgTemplate, this.definition.name, duration.asSec);
|
|
176
|
+
const endPayload = endInput.payload;
|
|
178
177
|
await notify(this.definition.end.msg(
|
|
179
|
-
|
|
178
|
+
endMsg,
|
|
180
179
|
{
|
|
181
180
|
duration: duration.asMs,
|
|
182
181
|
...endPayload
|
|
@@ -187,6 +186,15 @@ var SpanMaker = class {
|
|
|
187
186
|
};
|
|
188
187
|
}
|
|
189
188
|
};
|
|
189
|
+
function parseArgs(first, second) {
|
|
190
|
+
const firstIsMessage = typeof first === "string";
|
|
191
|
+
const message2 = firstIsMessage || second ? first : void 0;
|
|
192
|
+
const payload = firstIsMessage || second ? second : first;
|
|
193
|
+
return {
|
|
194
|
+
message: message2,
|
|
195
|
+
payload
|
|
196
|
+
};
|
|
197
|
+
}
|
|
190
198
|
function withSpanId(span, message2) {
|
|
191
199
|
return {
|
|
192
200
|
...message2,
|
|
@@ -295,7 +303,7 @@ var confirm = (details) => request("info", {
|
|
|
295
303
|
|
|
296
304
|
// ../tmp-toolkit-helpers/src/api/io/private/messages.ts
|
|
297
305
|
var IO = {
|
|
298
|
-
// Defaults
|
|
306
|
+
// Defaults (0000)
|
|
299
307
|
DEFAULT_TOOLKIT_INFO: info({
|
|
300
308
|
code: "CDK_TOOLKIT_I0000",
|
|
301
309
|
description: "Default info messages emitted from the Toolkit"
|
|
@@ -308,7 +316,15 @@ var IO = {
|
|
|
308
316
|
code: "CDK_TOOLKIT_W0000",
|
|
309
317
|
description: "Default warning messages emitted from the Toolkit"
|
|
310
318
|
}),
|
|
311
|
-
|
|
319
|
+
DEFAULT_TOOLKIT_ERROR: error({
|
|
320
|
+
code: "CDK_TOOLKIT_E0000",
|
|
321
|
+
description: "Default error messages emitted from the Toolkit"
|
|
322
|
+
}),
|
|
323
|
+
DEFAULT_TOOLKIT_TRACE: trace({
|
|
324
|
+
code: "CDK_TOOLKIT_I0000",
|
|
325
|
+
description: "Default trace messages emitted from the Toolkit"
|
|
326
|
+
}),
|
|
327
|
+
// 1: Synth (1xxx)
|
|
312
328
|
CDK_TOOLKIT_I1000: info({
|
|
313
329
|
code: "CDK_TOOLKIT_I1000",
|
|
314
330
|
description: "Provides synthesis times.",
|
|
@@ -329,7 +345,7 @@ var IO = {
|
|
|
329
345
|
description: "Successfully deployed stacks",
|
|
330
346
|
interface: "AssemblyData"
|
|
331
347
|
}),
|
|
332
|
-
// 2: List
|
|
348
|
+
// 2: List (2xxx)
|
|
333
349
|
CDK_TOOLKIT_I2901: result({
|
|
334
350
|
code: "CDK_TOOLKIT_I2901",
|
|
335
351
|
description: "Provides details on the selected stacks and their dependencies",
|
|
@@ -340,8 +356,8 @@ var IO = {
|
|
|
340
356
|
code: "CDK_TOOLKIT_E3900",
|
|
341
357
|
description: "Resource import failed"
|
|
342
358
|
}),
|
|
343
|
-
// 4: Diff
|
|
344
|
-
// 5: Deploy & Watch
|
|
359
|
+
// 4: Diff (4xxx)
|
|
360
|
+
// 5: Deploy & Watch (5xxx)
|
|
345
361
|
CDK_TOOLKIT_I5000: info({
|
|
346
362
|
code: "CDK_TOOLKIT_I5000",
|
|
347
363
|
description: "Provides deployment times",
|
|
@@ -403,7 +419,7 @@ var IO = {
|
|
|
403
419
|
description: "Stack deploy progress",
|
|
404
420
|
interface: "StackDeployProgress"
|
|
405
421
|
}),
|
|
406
|
-
// Assets
|
|
422
|
+
// Assets (52xx)
|
|
407
423
|
CDK_TOOLKIT_I5210: trace({
|
|
408
424
|
code: "CDK_TOOLKIT_I5210",
|
|
409
425
|
description: "Started building a specific asset",
|
|
@@ -424,7 +440,7 @@ var IO = {
|
|
|
424
440
|
description: "Publishing the asset has completed",
|
|
425
441
|
interface: "Duration"
|
|
426
442
|
}),
|
|
427
|
-
// Watch
|
|
443
|
+
// Watch (53xx)
|
|
428
444
|
CDK_TOOLKIT_I5310: debug({
|
|
429
445
|
code: "CDK_TOOLKIT_I5310",
|
|
430
446
|
description: "The computed settings used for file watching",
|
|
@@ -453,7 +469,18 @@ var IO = {
|
|
|
453
469
|
code: "CDK_TOOLKIT_I5315",
|
|
454
470
|
description: "Queued watch deployment started"
|
|
455
471
|
}),
|
|
456
|
-
//
|
|
472
|
+
// Hotswap (54xx)
|
|
473
|
+
CDK_TOOLKIT_I5400: trace({
|
|
474
|
+
code: "CDK_TOOLKIT_I5400",
|
|
475
|
+
description: "Starting a hotswap deployment",
|
|
476
|
+
interface: "HotswapDeployment"
|
|
477
|
+
}),
|
|
478
|
+
CDK_TOOLKIT_I5410: info({
|
|
479
|
+
code: "CDK_TOOLKIT_I5410",
|
|
480
|
+
description: "Hotswap deployment has ended, a full deployment might still follow if needed",
|
|
481
|
+
interface: "Duration"
|
|
482
|
+
}),
|
|
483
|
+
// Stack Monitor (55xx)
|
|
457
484
|
CDK_TOOLKIT_I5501: info({
|
|
458
485
|
code: "CDK_TOOLKIT_I5501",
|
|
459
486
|
description: "Stack Monitoring: Start monitoring of a single stack",
|
|
@@ -469,7 +496,7 @@ var IO = {
|
|
|
469
496
|
description: "Stack Monitoring: Finished monitoring of a single stack",
|
|
470
497
|
interface: "StackMonitoringControlEvent"
|
|
471
498
|
}),
|
|
472
|
-
// Success
|
|
499
|
+
// Success (59xx)
|
|
473
500
|
CDK_TOOLKIT_I5900: result({
|
|
474
501
|
code: "CDK_TOOLKIT_I5900",
|
|
475
502
|
description: "Deployment results on success",
|
|
@@ -493,7 +520,7 @@ var IO = {
|
|
|
493
520
|
description: "Stack Monitoring error",
|
|
494
521
|
interface: "ErrorPayload"
|
|
495
522
|
}),
|
|
496
|
-
// 6: Rollback
|
|
523
|
+
// 6: Rollback (6xxx)
|
|
497
524
|
CDK_TOOLKIT_I6000: info({
|
|
498
525
|
code: "CDK_TOOLKIT_I6000",
|
|
499
526
|
description: "Provides rollback times",
|
|
@@ -513,7 +540,7 @@ var IO = {
|
|
|
513
540
|
description: "Rollback failed",
|
|
514
541
|
interface: "ErrorPayload"
|
|
515
542
|
}),
|
|
516
|
-
// 7: Destroy
|
|
543
|
+
// 7: Destroy (7xxx)
|
|
517
544
|
CDK_TOOLKIT_I7000: info({
|
|
518
545
|
code: "CDK_TOOLKIT_I7000",
|
|
519
546
|
description: "Provides destroy times",
|
|
@@ -553,7 +580,7 @@ var IO = {
|
|
|
553
580
|
description: "Stack deletion failed",
|
|
554
581
|
interface: "ErrorPayload"
|
|
555
582
|
}),
|
|
556
|
-
// 9: Bootstrap
|
|
583
|
+
// 9: Bootstrap (9xxx)
|
|
557
584
|
CDK_TOOLKIT_I9000: info({
|
|
558
585
|
code: "CDK_TOOLKIT_I9000",
|
|
559
586
|
description: "Provides bootstrap times",
|
|
@@ -574,6 +601,23 @@ var IO = {
|
|
|
574
601
|
description: "Bootstrap failed",
|
|
575
602
|
interface: "ErrorPayload"
|
|
576
603
|
}),
|
|
604
|
+
// Notices
|
|
605
|
+
CDK_TOOLKIT_I0100: info({
|
|
606
|
+
code: "CDK_TOOLKIT_I0100",
|
|
607
|
+
description: "Notices decoration (the header or footer of a list of notices)"
|
|
608
|
+
}),
|
|
609
|
+
CDK_TOOLKIT_W0101: warn({
|
|
610
|
+
code: "CDK_TOOLKIT_W0101",
|
|
611
|
+
description: "A notice that is marked as a warning"
|
|
612
|
+
}),
|
|
613
|
+
CDK_TOOLKIT_E0101: error({
|
|
614
|
+
code: "CDK_TOOLKIT_E0101",
|
|
615
|
+
description: "A notice that is marked as an error"
|
|
616
|
+
}),
|
|
617
|
+
CDK_TOOLKIT_I0101: info({
|
|
618
|
+
code: "CDK_TOOLKIT_I0101",
|
|
619
|
+
description: "A notice that is marked as informational"
|
|
620
|
+
}),
|
|
577
621
|
// Assembly codes
|
|
578
622
|
CDK_ASSEMBLY_I0010: debug({
|
|
579
623
|
code: "CDK_ASSEMBLY_I0010",
|
|
@@ -690,14 +734,129 @@ var SPAN = {
|
|
|
690
734
|
name: "Publish Asset",
|
|
691
735
|
start: IO.CDK_TOOLKIT_I5220,
|
|
692
736
|
end: IO.CDK_TOOLKIT_I5221
|
|
737
|
+
},
|
|
738
|
+
HOTSWAP: {
|
|
739
|
+
name: "hotswap-deployment",
|
|
740
|
+
start: IO.CDK_TOOLKIT_I5400,
|
|
741
|
+
end: IO.CDK_TOOLKIT_I5410
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// ../tmp-toolkit-helpers/src/api/io/private/io-default-messages.ts
|
|
746
|
+
var util2 = __toESM(require("util"));
|
|
747
|
+
var IoDefaultMessages = class {
|
|
748
|
+
constructor(ioHelper) {
|
|
749
|
+
this.ioHelper = ioHelper;
|
|
750
|
+
}
|
|
751
|
+
notify(msg) {
|
|
752
|
+
return this.ioHelper.notify(msg);
|
|
753
|
+
}
|
|
754
|
+
requestResponse(msg) {
|
|
755
|
+
return this.ioHelper.requestResponse(msg);
|
|
756
|
+
}
|
|
757
|
+
error(input, ...args) {
|
|
758
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_ERROR, input, ...args);
|
|
759
|
+
}
|
|
760
|
+
warn(input, ...args) {
|
|
761
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
|
|
762
|
+
}
|
|
763
|
+
warning(input, ...args) {
|
|
764
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
|
|
765
|
+
}
|
|
766
|
+
info(input, ...args) {
|
|
767
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_INFO, input, ...args);
|
|
768
|
+
}
|
|
769
|
+
debug(input, ...args) {
|
|
770
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_DEBUG, input, ...args);
|
|
771
|
+
}
|
|
772
|
+
trace(input, ...args) {
|
|
773
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_TRACE, input, ...args);
|
|
774
|
+
}
|
|
775
|
+
result(input, ...args) {
|
|
776
|
+
const message2 = args.length > 0 ? util2.format(input, ...args) : input;
|
|
777
|
+
void this.ioHelper.notify({
|
|
778
|
+
time: /* @__PURE__ */ new Date(),
|
|
779
|
+
code: IO.DEFAULT_TOOLKIT_INFO.code,
|
|
780
|
+
level: "result",
|
|
781
|
+
message: message2,
|
|
782
|
+
data: void 0
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
emitMessage(maker, input, ...args) {
|
|
786
|
+
const message2 = args.length > 0 ? util2.format(input, ...args) : input;
|
|
787
|
+
void this.ioHelper.notify(maker.msg(message2));
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
// ../tmp-toolkit-helpers/src/api/io/private/testing/test-io-host.ts
|
|
792
|
+
var TestIoHost = class {
|
|
793
|
+
constructor(level = "info") {
|
|
794
|
+
this.level = level;
|
|
795
|
+
this.notifySpy = jest.fn();
|
|
796
|
+
this.requestSpy = jest.fn();
|
|
797
|
+
}
|
|
798
|
+
notifySpy;
|
|
799
|
+
requestSpy;
|
|
800
|
+
requireDeployApproval = "never" /* NEVER */;
|
|
801
|
+
async notify(msg) {
|
|
802
|
+
if (isMessageRelevantForLevel(msg, this.level)) {
|
|
803
|
+
this.notifySpy(msg);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
async requestResponse(msg) {
|
|
807
|
+
if (isMessageRelevantForLevel(msg, this.level) && this.needsApproval(msg)) {
|
|
808
|
+
this.requestSpy(msg);
|
|
809
|
+
}
|
|
810
|
+
return msg.defaultResponse;
|
|
811
|
+
}
|
|
812
|
+
needsApproval(msg) {
|
|
813
|
+
if (!["CDK_TOOLKIT_I5060"].includes(msg.code)) {
|
|
814
|
+
return true;
|
|
815
|
+
}
|
|
816
|
+
switch (this.requireDeployApproval) {
|
|
817
|
+
case "never" /* NEVER */:
|
|
818
|
+
return false;
|
|
819
|
+
case "any-change" /* ANY_CHANGE */:
|
|
820
|
+
return true;
|
|
821
|
+
case "broadening" /* BROADENING */:
|
|
822
|
+
return msg.data?.permissionChangeType === "broadening";
|
|
823
|
+
default:
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
// ../tmp-toolkit-helpers/src/api/io/private/testing/fake-io-host.ts
|
|
830
|
+
var FakeIoHost = class {
|
|
831
|
+
messages = [];
|
|
832
|
+
requestResponse;
|
|
833
|
+
constructor() {
|
|
834
|
+
this.clear();
|
|
835
|
+
}
|
|
836
|
+
clear() {
|
|
837
|
+
this.messages.splice(0, this.messages.length);
|
|
838
|
+
this.requestResponse = jest.fn().mockRejectedValue(new Error("requestResponse not mocked"));
|
|
839
|
+
}
|
|
840
|
+
async notify(msg) {
|
|
841
|
+
this.messages.push(msg);
|
|
842
|
+
}
|
|
843
|
+
expectMessage(m) {
|
|
844
|
+
expect(this.messages).toContainEqual(expect.objectContaining({
|
|
845
|
+
...m.level ? { level: m.level } : void 0,
|
|
846
|
+
// Can be a partial string as well
|
|
847
|
+
message: expect.stringContaining(m.containing)
|
|
848
|
+
}));
|
|
693
849
|
}
|
|
694
850
|
};
|
|
695
851
|
// Annotate the CommonJS export names for ESM import in node:
|
|
696
852
|
0 && (module.exports = {
|
|
853
|
+
FakeIoHost,
|
|
697
854
|
IO,
|
|
855
|
+
IoDefaultMessages,
|
|
698
856
|
IoHelper,
|
|
699
857
|
SPAN,
|
|
700
858
|
SpanMaker,
|
|
859
|
+
TestIoHost,
|
|
701
860
|
asIoHelper,
|
|
702
861
|
confirm,
|
|
703
862
|
debug,
|