carlin 1.49.7 → 1.49.9
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 +20 -0
- package/dist/chunk-3GQAWCBQ.js +10 -0
- package/dist/defineConfig.d.ts +28 -0
- package/dist/defineConfig.js +136 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +412 -359
- package/package.json +21 -11
package/dist/index.js
CHANGED
|
@@ -1,41 +1,106 @@
|
|
|
1
|
+
import { __name, __require } from './chunk-3GQAWCBQ.js';
|
|
1
2
|
import 'dotenv/config';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as path2 from 'path';
|
|
4
|
+
import path2__default from 'path';
|
|
5
|
+
import * as fs4 from 'fs';
|
|
6
|
+
import fs4__default, { existsSync, statSync, chmodSync, createReadStream } from 'fs';
|
|
7
|
+
import yaml5 from 'js-yaml';
|
|
8
|
+
import * as esbuild from 'esbuild';
|
|
9
|
+
import importSync from 'import-sync';
|
|
10
|
+
import AWS2 from 'aws-sdk';
|
|
11
|
+
import { pascalCase, constantCase, kebabCase, camelCase } from 'change-case';
|
|
12
|
+
import deepEqual from 'deep-equal';
|
|
13
|
+
import deepmerge from 'deepmerge';
|
|
14
|
+
import findUpSync from 'findup-sync';
|
|
15
|
+
import yargs from 'yargs';
|
|
16
|
+
import { hideBin } from 'yargs/helpers';
|
|
17
|
+
import log6 from 'npmlog';
|
|
5
18
|
import 'uglify-js';
|
|
6
19
|
import 'prettier';
|
|
7
20
|
import git from 'simple-git';
|
|
8
|
-
import findUpSync from 'findup-sync';
|
|
9
|
-
import * as fs3 from 'fs';
|
|
10
|
-
import fs3__default, { existsSync, statSync, chmodSync, createReadStream } from 'fs';
|
|
11
|
-
import { pascalCase, kebabCase, constantCase, camelCase } from 'change-case';
|
|
12
21
|
import { stdout } from 'process';
|
|
13
22
|
import childProcess, { spawn as spawn$1 } from 'child_process';
|
|
14
|
-
import deepmerge from 'deepmerge';
|
|
15
|
-
import * as path from 'path';
|
|
16
|
-
import path__default from 'path';
|
|
17
23
|
import { ValidateTemplateCommand, DeleteStackCommand, CloudFormationClient, UpdateStackCommand, CreateStackCommand, UpdateTerminationProtectionCommand, DescribeStacksCommand, DescribeStackEventsCommand, DescribeStackResourceCommand } from '@aws-sdk/client-cloudformation';
|
|
18
24
|
import { ListObjectsV2Command, ListObjectVersionsCommand, DeleteObjectsCommand, HeadObjectCommand, CopyObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
19
25
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
20
26
|
import { glob } from 'glob';
|
|
21
27
|
import mime from 'mime-types';
|
|
22
|
-
import { hideBin } from 'yargs/helpers';
|
|
23
|
-
import yargs from 'yargs';
|
|
24
28
|
import { builtinModules } from 'module';
|
|
25
29
|
import { typescriptConfig } from '@ttoss/config';
|
|
26
|
-
import * as esbuild from 'esbuild';
|
|
27
30
|
import AdmZip from 'adm-zip';
|
|
28
|
-
import importSync from 'import-sync';
|
|
29
|
-
import deepEqual from 'deep-equal';
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
var loadConfig = /* @__PURE__ */ __name((entryPoint) => {
|
|
33
|
+
const lastEntryPointName = entryPoint.split("/").pop();
|
|
34
|
+
const filename = lastEntryPointName?.split(".")[0];
|
|
35
|
+
const outfile = path2__default.resolve(process.cwd(), "out", filename + ".js");
|
|
36
|
+
const result = esbuild.buildSync({
|
|
37
|
+
bundle: true,
|
|
38
|
+
entryPoints: [
|
|
39
|
+
entryPoint
|
|
40
|
+
],
|
|
41
|
+
/**
|
|
42
|
+
* ttoss packages cannot be market as external because it'd break the CI.
|
|
43
|
+
* On CI, ttoss packages point to the TS main file, not the compiled
|
|
44
|
+
* ones. See more details here https://github.com/ttoss/ttoss/issues/541.
|
|
45
|
+
*/
|
|
46
|
+
external: [],
|
|
47
|
+
format: "cjs",
|
|
48
|
+
outfile,
|
|
49
|
+
platform: "node",
|
|
50
|
+
target: "ES2021",
|
|
51
|
+
treeShaking: true
|
|
52
|
+
});
|
|
53
|
+
if (result.errors.length > 0) {
|
|
54
|
+
console.error("Error building config file: ", filename);
|
|
55
|
+
throw result.errors;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const config = importSync(outfile);
|
|
59
|
+
return config.default || config.config;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Failed importing build config file: ", filename);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}, "loadConfig");
|
|
65
|
+
|
|
66
|
+
// ../read-config-file/src/index.ts
|
|
67
|
+
var readConfigFileSync = /* @__PURE__ */ __name(({ configFilePath, options: options10 }) => {
|
|
68
|
+
const extension = configFilePath.split(".").pop();
|
|
69
|
+
if (extension === "yaml" || extension === "yml") {
|
|
70
|
+
const file = fs4__default.readFileSync(configFilePath, "utf8");
|
|
71
|
+
return yaml5.load(file);
|
|
72
|
+
}
|
|
73
|
+
if (extension === "json") {
|
|
74
|
+
const file = fs4__default.readFileSync(configFilePath, "utf8");
|
|
75
|
+
return JSON.parse(file);
|
|
76
|
+
}
|
|
77
|
+
if (extension === "js") {
|
|
78
|
+
return __require(configFilePath);
|
|
79
|
+
}
|
|
80
|
+
if (extension === "ts") {
|
|
81
|
+
let result = loadConfig(configFilePath);
|
|
82
|
+
if (typeof result === "function") {
|
|
83
|
+
result = result(options10);
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
throw new Error("Unsupported config file extension: " + extension);
|
|
88
|
+
}, "readConfigFileSync");
|
|
89
|
+
var readConfigFile = /* @__PURE__ */ __name(async ({ configFilePath, options: options10 }) => {
|
|
90
|
+
const extension = configFilePath.split(".").pop();
|
|
91
|
+
if (extension === "ts") {
|
|
92
|
+
let result = loadConfig(configFilePath);
|
|
93
|
+
if (typeof result === "function") {
|
|
94
|
+
result = result(options10);
|
|
95
|
+
}
|
|
96
|
+
result = await Promise.resolve(result);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
return readConfigFileSync({
|
|
100
|
+
configFilePath,
|
|
101
|
+
options: options10
|
|
102
|
+
});
|
|
103
|
+
}, "readConfigFile");
|
|
39
104
|
|
|
40
105
|
// src/config.ts
|
|
41
106
|
var NAME = "carlin";
|
|
@@ -43,6 +108,49 @@ var AWS_DEFAULT_REGION = "us-east-1";
|
|
|
43
108
|
var CLOUDFRONT_REGION = "us-east-1";
|
|
44
109
|
var DEFAULT_NODE_VERSION = "24";
|
|
45
110
|
var DEFAULT_NODE_RUNTIME = `nodejs${DEFAULT_NODE_VERSION}.x`;
|
|
111
|
+
var logPrefix = "cicd-ecs-task-report";
|
|
112
|
+
var sendEcsTaskReport = /* @__PURE__ */ __name(async ({ status }) => {
|
|
113
|
+
if (!process.env.ECS_TASK_REPORT_HANDLER_NAME) {
|
|
114
|
+
log6.info(logPrefix, "ECS_TASK_REPORT_HANDLER_NAME not defined.");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const lambda = new AWS2.Lambda();
|
|
118
|
+
const payload = {
|
|
119
|
+
status
|
|
120
|
+
};
|
|
121
|
+
if (process.env.ECS_TASK_ARN) {
|
|
122
|
+
payload.ecsTaskArn = process.env.ECS_TASK_ARN;
|
|
123
|
+
}
|
|
124
|
+
if (process.env.PIPELINE_NAME) {
|
|
125
|
+
payload.pipelineName = process.env.PIPELINE_NAME;
|
|
126
|
+
}
|
|
127
|
+
await lambda.invokeAsync({
|
|
128
|
+
FunctionName: process.env.ECS_TASK_REPORT_HANDLER_NAME,
|
|
129
|
+
InvokeArgs: JSON.stringify(payload)
|
|
130
|
+
}).promise();
|
|
131
|
+
log6.info(logPrefix, "Report sent.");
|
|
132
|
+
}, "sendEcsTaskReport");
|
|
133
|
+
var options = {
|
|
134
|
+
status: {
|
|
135
|
+
choices: [
|
|
136
|
+
"Approved",
|
|
137
|
+
"Rejected",
|
|
138
|
+
"MainTagFound"
|
|
139
|
+
],
|
|
140
|
+
demandOption: true,
|
|
141
|
+
type: "string"
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var ecsTaskReportCommand = {
|
|
145
|
+
command: "cicd-ecs-task-report",
|
|
146
|
+
describe: false,
|
|
147
|
+
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
148
|
+
return yargs3.options(options);
|
|
149
|
+
}, "builder"),
|
|
150
|
+
handler: /* @__PURE__ */ __name(async (args) => {
|
|
151
|
+
return sendEcsTaskReport(args);
|
|
152
|
+
}, "handler")
|
|
153
|
+
};
|
|
46
154
|
|
|
47
155
|
// src/utils/addGroupToOptions.ts
|
|
48
156
|
var addGroupToOptions = /* @__PURE__ */ __name((options10, group) => {
|
|
@@ -51,10 +159,10 @@ var addGroupToOptions = /* @__PURE__ */ __name((options10, group) => {
|
|
|
51
159
|
});
|
|
52
160
|
return options10;
|
|
53
161
|
}, "addGroupToOptions");
|
|
54
|
-
var
|
|
162
|
+
var logPrefix2 = "codebuild";
|
|
55
163
|
var WAIT_TIME = 10 * 1e3;
|
|
56
164
|
var waitCodeBuildFinish = /* @__PURE__ */ __name(async ({ buildId, name }) => {
|
|
57
|
-
const codeBuild2 = new
|
|
165
|
+
const codeBuild2 = new AWS2.CodeBuild();
|
|
58
166
|
let result;
|
|
59
167
|
const checkIfBuildIsFinished = /* @__PURE__ */ __name(async () => {
|
|
60
168
|
const { builds } = await codeBuild2.batchGetBuilds({
|
|
@@ -67,7 +175,7 @@ var waitCodeBuildFinish = /* @__PURE__ */ __name(async ({ buildId, name }) => {
|
|
|
67
175
|
const executedBuild = builds?.find(({ id }) => {
|
|
68
176
|
return id === buildId;
|
|
69
177
|
});
|
|
70
|
-
|
|
178
|
+
log6.info(logPrefix2, `Build status of ${name || buildId}: ${executedBuild?.buildStatus}`);
|
|
71
179
|
if (executedBuild && executedBuild.currentPhase === "COMPLETED") {
|
|
72
180
|
if (executedBuild.buildStatus === "SUCCEEDED") {
|
|
73
181
|
resolve6(executedBuild);
|
|
@@ -88,7 +196,7 @@ var waitCodeBuildFinish = /* @__PURE__ */ __name(async ({ buildId, name }) => {
|
|
|
88
196
|
return result;
|
|
89
197
|
}, "waitCodeBuildFinish");
|
|
90
198
|
var startCodeBuildBuild = /* @__PURE__ */ __name(async ({ projectName }) => {
|
|
91
|
-
const codeBuild2 = new
|
|
199
|
+
const codeBuild2 = new AWS2.CodeBuild();
|
|
92
200
|
const { build } = await codeBuild2.startBuild({
|
|
93
201
|
projectName
|
|
94
202
|
}).promise();
|
|
@@ -109,9 +217,9 @@ var setEnvVar = /* @__PURE__ */ __name((key, value) => {
|
|
|
109
217
|
}
|
|
110
218
|
return cache.set(key, value);
|
|
111
219
|
}, "setEnvVar");
|
|
112
|
-
|
|
220
|
+
log6.heading = "exec";
|
|
113
221
|
var getAwsAccountId = /* @__PURE__ */ __name(async () => {
|
|
114
|
-
const sts = new
|
|
222
|
+
const sts = new AWS2.STS();
|
|
115
223
|
const { Account } = await sts.getCallerIdentity().promise();
|
|
116
224
|
return Account;
|
|
117
225
|
}, "getAwsAccountId");
|
|
@@ -140,7 +248,7 @@ var readPackageJson = /* @__PURE__ */ __name(() => {
|
|
|
140
248
|
if (!packageJsonDir) {
|
|
141
249
|
return {};
|
|
142
250
|
}
|
|
143
|
-
return JSON.parse(
|
|
251
|
+
return JSON.parse(fs4__default.readFileSync(packageJsonDir).toString());
|
|
144
252
|
}, "readPackageJson");
|
|
145
253
|
var getPackageJsonProperty = /* @__PURE__ */ __name(({ property }) => {
|
|
146
254
|
try {
|
|
@@ -173,7 +281,7 @@ var getProjectName = /* @__PURE__ */ __name(() => {
|
|
|
173
281
|
return pascalCase(name);
|
|
174
282
|
}
|
|
175
283
|
}, "getProjectName");
|
|
176
|
-
|
|
284
|
+
log6.heading = "exec";
|
|
177
285
|
var spawn = /* @__PURE__ */ __name((cmd) => {
|
|
178
286
|
return new Promise((resolve6, reject) => {
|
|
179
287
|
const [cmdName, ...cmdArgs] = cmd.split(" ");
|
|
@@ -444,7 +552,7 @@ var getBaseStackResource = /* @__PURE__ */ __name(async (resource) => {
|
|
|
444
552
|
|
|
445
553
|
// src/deploy/config.ts
|
|
446
554
|
var LATEST_DEPLOY_OUTPUTS_FILENAME = "latest-deploy.json";
|
|
447
|
-
var
|
|
555
|
+
var logPrefix3 = "s3";
|
|
448
556
|
var s3Clients = {};
|
|
449
557
|
var s3 = /* @__PURE__ */ __name(() => {
|
|
450
558
|
const s3ClientConfig = {
|
|
@@ -465,14 +573,14 @@ var uploadFileToS3 = /* @__PURE__ */ __name(async ({ bucket, contentType, file,
|
|
|
465
573
|
}
|
|
466
574
|
const params = {
|
|
467
575
|
Bucket: bucket,
|
|
468
|
-
Key: key.split(
|
|
576
|
+
Key: key.split(path2__default.sep).join("/")
|
|
469
577
|
};
|
|
470
578
|
if (file) {
|
|
471
579
|
params.ContentType = contentType;
|
|
472
580
|
params.Body = file;
|
|
473
581
|
} else if (filePath) {
|
|
474
|
-
const readFile = await
|
|
475
|
-
params.ContentType = contentType || mime.contentType(
|
|
582
|
+
const readFile = await fs4__default.promises.readFile(filePath);
|
|
583
|
+
params.ContentType = contentType || mime.contentType(path2__default.extname(filePath)) || void 0;
|
|
476
584
|
params.Body = Buffer.from(readFile);
|
|
477
585
|
}
|
|
478
586
|
const upload = new Upload({
|
|
@@ -493,7 +601,7 @@ var uploadFileToS3 = /* @__PURE__ */ __name(async ({ bucket, contentType, file,
|
|
|
493
601
|
var getAllFilesInsideADirectory = /* @__PURE__ */ __name(async ({ directory }) => {
|
|
494
602
|
const allFilesAndDirectories = await glob(`${directory}/**/*`);
|
|
495
603
|
const allFiles = allFilesAndDirectories.filter((item) => {
|
|
496
|
-
return
|
|
604
|
+
return fs4__default.lstatSync(item).isFile();
|
|
497
605
|
});
|
|
498
606
|
return allFiles;
|
|
499
607
|
}, "getAllFilesInsideADirectory");
|
|
@@ -515,12 +623,12 @@ var copyRoot404To404Index = /* @__PURE__ */ __name(async ({ bucket }) => {
|
|
|
515
623
|
await s3().send(copyCommand);
|
|
516
624
|
}
|
|
517
625
|
} catch (error) {
|
|
518
|
-
|
|
626
|
+
log6.error(logPrefix3, `Cannot copy 404.html to 404/index.html`);
|
|
519
627
|
throw error;
|
|
520
628
|
}
|
|
521
629
|
}, "copyRoot404To404Index");
|
|
522
630
|
var uploadDirectoryToS3 = /* @__PURE__ */ __name(async ({ bucket, bucketKey = "", directory }) => {
|
|
523
|
-
|
|
631
|
+
log6.info(logPrefix3, `Uploading directory ${directory}/ to ${bucket}/${bucketKey}...`);
|
|
524
632
|
const allFiles = await getAllFilesInsideADirectory({
|
|
525
633
|
directory
|
|
526
634
|
});
|
|
@@ -538,18 +646,18 @@ var uploadDirectoryToS3 = /* @__PURE__ */ __name(async ({ bucket, bucketKey = ""
|
|
|
538
646
|
return acc;
|
|
539
647
|
}, []);
|
|
540
648
|
for (const [index, groupOfFiles] of aoaOfFiles.entries()) {
|
|
541
|
-
|
|
649
|
+
log6.info(logPrefix3, `Uploading group ${index + 1}/${aoaOfFiles.length}...`);
|
|
542
650
|
await Promise.all(groupOfFiles.map((file) => {
|
|
543
651
|
return uploadFileToS3({
|
|
544
652
|
bucket,
|
|
545
|
-
key:
|
|
653
|
+
key: path2__default.join(bucketKey, path2__default.relative(directory, file)),
|
|
546
654
|
filePath: file
|
|
547
655
|
});
|
|
548
656
|
}));
|
|
549
657
|
}
|
|
550
658
|
}, "uploadDirectoryToS3");
|
|
551
659
|
var emptyS3Directory = /* @__PURE__ */ __name(async ({ bucket, directory = "" }) => {
|
|
552
|
-
|
|
660
|
+
log6.info(logPrefix3, `${bucket}/${directory} will be empty`);
|
|
553
661
|
try {
|
|
554
662
|
const listCommand = new ListObjectsV2Command({
|
|
555
663
|
Bucket: bucket,
|
|
@@ -607,15 +715,15 @@ var emptyS3Directory = /* @__PURE__ */ __name(async ({ bucket, directory = "" })
|
|
|
607
715
|
directory
|
|
608
716
|
});
|
|
609
717
|
}
|
|
610
|
-
|
|
718
|
+
log6.info(logPrefix3, `${bucket}/${directory} is empty.`);
|
|
611
719
|
} catch (error) {
|
|
612
|
-
|
|
720
|
+
log6.error(logPrefix3, `Cannot empty ${bucket}/${directory}.`);
|
|
613
721
|
throw error;
|
|
614
722
|
}
|
|
615
723
|
}, "emptyS3Directory");
|
|
616
724
|
var deleteOldS3Files = /* @__PURE__ */ __name(async ({ bucket, continuationToken, directory = "", retentionDays, totalDeleted = 0 }) => {
|
|
617
725
|
if (!continuationToken) {
|
|
618
|
-
|
|
726
|
+
log6.info(logPrefix3, `Deleting files older than ${retentionDays} days from ${bucket}/${directory}...`);
|
|
619
727
|
}
|
|
620
728
|
try {
|
|
621
729
|
const listCommand = new ListObjectsV2Command({
|
|
@@ -671,23 +779,23 @@ var deleteOldS3Files = /* @__PURE__ */ __name(async ({ bucket, continuationToken
|
|
|
671
779
|
}
|
|
672
780
|
const finalTotal = totalDeleted + deletedCount;
|
|
673
781
|
if (finalTotal === 0) {
|
|
674
|
-
|
|
782
|
+
log6.info(logPrefix3, `No files older than ${retentionDays} days found in ${bucket}/${directory}`);
|
|
675
783
|
} else {
|
|
676
|
-
|
|
784
|
+
log6.info(logPrefix3, `Deleted ${finalTotal} old files from ${bucket}/${directory}`);
|
|
677
785
|
}
|
|
678
786
|
return finalTotal;
|
|
679
787
|
} catch (error) {
|
|
680
|
-
|
|
788
|
+
log6.error(logPrefix3, `Cannot delete old files from ${bucket}/${directory}.`);
|
|
681
789
|
throw error;
|
|
682
790
|
}
|
|
683
791
|
}, "deleteOldS3Files");
|
|
684
792
|
|
|
685
793
|
// src/deploy/cloudformation.core.ts
|
|
686
|
-
var
|
|
687
|
-
|
|
794
|
+
var logPrefix4 = "cloudformation";
|
|
795
|
+
log6.addLevel("event", 1e4, {
|
|
688
796
|
fg: "yellow"
|
|
689
797
|
});
|
|
690
|
-
|
|
798
|
+
log6.addLevel("output", 1e4, {
|
|
691
799
|
fg: "blue"
|
|
692
800
|
});
|
|
693
801
|
var TEMPLATE_BODY_MAX_SIZE = 51200;
|
|
@@ -722,7 +830,7 @@ var cloudformation = /* @__PURE__ */ __name(() => {
|
|
|
722
830
|
return cloudFormationClients[key];
|
|
723
831
|
}, "cloudformation");
|
|
724
832
|
var cloudFormationV2 = /* @__PURE__ */ __name(() => {
|
|
725
|
-
return new
|
|
833
|
+
return new AWS2.CloudFormation({
|
|
726
834
|
apiVersion: "2010-05-15"
|
|
727
835
|
});
|
|
728
836
|
}, "cloudFormationV2");
|
|
@@ -736,23 +844,23 @@ var describeStackResource = /* @__PURE__ */ __name(async (input) => {
|
|
|
736
844
|
return cloudformation().send(new DescribeStackResourceCommand(input));
|
|
737
845
|
}, "describeStackResource");
|
|
738
846
|
var doesStackExist = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
739
|
-
|
|
847
|
+
log6.info(logPrefix4, `Checking if stack ${stackName} already exists...`);
|
|
740
848
|
try {
|
|
741
849
|
await describeStacks({
|
|
742
850
|
stackName
|
|
743
851
|
});
|
|
744
|
-
|
|
852
|
+
log6.info(logPrefix4, `Stack ${stackName} already exists.`);
|
|
745
853
|
return true;
|
|
746
854
|
} catch (error) {
|
|
747
855
|
if (error.Code === "ValidationError") {
|
|
748
|
-
|
|
856
|
+
log6.info(logPrefix4, `Stack ${stackName} does not exist.`);
|
|
749
857
|
return false;
|
|
750
858
|
}
|
|
751
859
|
throw error;
|
|
752
860
|
}
|
|
753
861
|
}, "doesStackExist");
|
|
754
862
|
var describeStackEvents = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
755
|
-
|
|
863
|
+
log6.error(logPrefix4, "Stack events:");
|
|
756
864
|
const { StackEvents } = await cloudformation().send(new DescribeStackEventsCommand({
|
|
757
865
|
StackName: stackName
|
|
758
866
|
}));
|
|
@@ -762,7 +870,7 @@ var describeStackEvents = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
762
870
|
return ResourceStatusReason;
|
|
763
871
|
}).reverse();
|
|
764
872
|
for (const { LogicalResourceId, ResourceStatusReason } of events) {
|
|
765
|
-
|
|
873
|
+
log6.event(LogicalResourceId, ResourceStatusReason);
|
|
766
874
|
continue;
|
|
767
875
|
}
|
|
768
876
|
return events;
|
|
@@ -804,14 +912,14 @@ var saveEnvironmentOutput = /* @__PURE__ */ __name(async ({ outputs, stackName }
|
|
|
804
912
|
[output.OutputKey]: output
|
|
805
913
|
};
|
|
806
914
|
}, {});
|
|
807
|
-
const dotCarlinFolderPath =
|
|
808
|
-
if (!
|
|
809
|
-
await
|
|
915
|
+
const dotCarlinFolderPath = path2.join(process.cwd(), ".carlin");
|
|
916
|
+
if (!fs4.existsSync(dotCarlinFolderPath)) {
|
|
917
|
+
await fs4.promises.mkdir(dotCarlinFolderPath);
|
|
810
918
|
}
|
|
811
|
-
const filePath =
|
|
812
|
-
await
|
|
813
|
-
const latestFilePath =
|
|
814
|
-
await
|
|
919
|
+
const filePath = path2.join(dotCarlinFolderPath, `${stackName}.json`);
|
|
920
|
+
await fs4.promises.writeFile(filePath, JSON.stringify(envFile, null, 2));
|
|
921
|
+
const latestFilePath = path2.join(dotCarlinFolderPath, LATEST_DEPLOY_OUTPUTS_FILENAME);
|
|
922
|
+
await fs4.promises.writeFile(latestFilePath, JSON.stringify(envFile, null, 2));
|
|
815
923
|
}, "saveEnvironmentOutput");
|
|
816
924
|
var printStackOutputsAfterDeploy = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
817
925
|
const { EnableTerminationProtection, StackName, Outputs = [] } = await describeStack({
|
|
@@ -821,11 +929,11 @@ var printStackOutputsAfterDeploy = /* @__PURE__ */ __name(async ({ stackName })
|
|
|
821
929
|
stackName,
|
|
822
930
|
outputs: Outputs
|
|
823
931
|
});
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
932
|
+
log6.output("Describe Stack");
|
|
933
|
+
log6.output("StackName", StackName);
|
|
934
|
+
log6.output("EnableTerminationProtection", EnableTerminationProtection);
|
|
827
935
|
for (const { OutputKey, OutputValue, Description, ExportName } of Outputs) {
|
|
828
|
-
|
|
936
|
+
log6.output(`${OutputKey}`, [
|
|
829
937
|
"",
|
|
830
938
|
`OutputKey: ${OutputKey}`,
|
|
831
939
|
`OutputValue: ${OutputValue}`,
|
|
@@ -836,7 +944,7 @@ var printStackOutputsAfterDeploy = /* @__PURE__ */ __name(async ({ stackName })
|
|
|
836
944
|
}
|
|
837
945
|
}, "printStackOutputsAfterDeploy");
|
|
838
946
|
var deleteStack = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
839
|
-
|
|
947
|
+
log6.info(logPrefix4, `Deleting stack ${stackName}...`);
|
|
840
948
|
await cloudformation().send(new DeleteStackCommand({
|
|
841
949
|
StackName: stackName
|
|
842
950
|
}));
|
|
@@ -845,24 +953,24 @@ var deleteStack = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
845
953
|
StackName: stackName
|
|
846
954
|
}).promise();
|
|
847
955
|
} catch (error) {
|
|
848
|
-
|
|
956
|
+
log6.error(logPrefix4, `An error occurred when deleting stack ${stackName}.`);
|
|
849
957
|
await describeStackEvents({
|
|
850
958
|
stackName
|
|
851
959
|
});
|
|
852
960
|
throw error;
|
|
853
961
|
}
|
|
854
|
-
|
|
962
|
+
log6.info(logPrefix4, `Stack ${stackName} deleted.`);
|
|
855
963
|
}, "deleteStack");
|
|
856
964
|
var createStack = /* @__PURE__ */ __name(async ({ params }) => {
|
|
857
965
|
const { StackName: stackName = "" } = params;
|
|
858
|
-
|
|
966
|
+
log6.info(logPrefix4, `Creating stack ${stackName}...`);
|
|
859
967
|
await cloudformation().send(new CreateStackCommand(params));
|
|
860
968
|
try {
|
|
861
969
|
await cloudFormationV2().waitFor("stackCreateComplete", {
|
|
862
970
|
StackName: stackName
|
|
863
971
|
}).promise();
|
|
864
972
|
} catch (error) {
|
|
865
|
-
|
|
973
|
+
log6.error(logPrefix4, `An error occurred when creating stack ${stackName}.`);
|
|
866
974
|
await describeStackEvents({
|
|
867
975
|
stackName
|
|
868
976
|
});
|
|
@@ -871,11 +979,11 @@ var createStack = /* @__PURE__ */ __name(async ({ params }) => {
|
|
|
871
979
|
});
|
|
872
980
|
throw error;
|
|
873
981
|
}
|
|
874
|
-
|
|
982
|
+
log6.info(logPrefix4, `Stack ${stackName} was created.`);
|
|
875
983
|
}, "createStack");
|
|
876
984
|
var updateStack = /* @__PURE__ */ __name(async ({ params }) => {
|
|
877
985
|
const { StackName: stackName = "" } = params;
|
|
878
|
-
|
|
986
|
+
log6.info(logPrefix4, `Updating stack ${stackName}...`);
|
|
879
987
|
try {
|
|
880
988
|
await cloudformation().send(new UpdateStackCommand(params));
|
|
881
989
|
await cloudFormationV2().waitFor("stackUpdateComplete", {
|
|
@@ -883,26 +991,26 @@ var updateStack = /* @__PURE__ */ __name(async ({ params }) => {
|
|
|
883
991
|
}).promise();
|
|
884
992
|
} catch (error) {
|
|
885
993
|
if (error.message === "No updates are to be performed.") {
|
|
886
|
-
|
|
994
|
+
log6.info(logPrefix4, error.message);
|
|
887
995
|
return;
|
|
888
996
|
}
|
|
889
|
-
|
|
997
|
+
log6.error(logPrefix4, "An error occurred when updating stack.");
|
|
890
998
|
await describeStackEvents({
|
|
891
999
|
stackName
|
|
892
1000
|
});
|
|
893
1001
|
throw error;
|
|
894
1002
|
}
|
|
895
|
-
|
|
1003
|
+
log6.info(logPrefix4, `Stack ${stackName} was updated.`);
|
|
896
1004
|
}, "updateStack");
|
|
897
1005
|
var enableTerminationProtection = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
898
|
-
|
|
1006
|
+
log6.info(logPrefix4, `Enabling termination protection...`);
|
|
899
1007
|
try {
|
|
900
1008
|
await cloudformation().send(new UpdateTerminationProtectionCommand({
|
|
901
1009
|
EnableTerminationProtection: true,
|
|
902
1010
|
StackName: stackName
|
|
903
1011
|
}));
|
|
904
1012
|
} catch (error) {
|
|
905
|
-
|
|
1013
|
+
log6.error(logPrefix4, "An error occurred when enabling termination protection");
|
|
906
1014
|
throw error;
|
|
907
1015
|
}
|
|
908
1016
|
}, "enableTerminationProtection");
|
|
@@ -1018,8 +1126,8 @@ var getStackName = /* @__PURE__ */ __name(async () => {
|
|
|
1018
1126
|
return limitStackName(sanitizeStackName(name));
|
|
1019
1127
|
}, "getStackName");
|
|
1020
1128
|
var deployErrorLogs = /* @__PURE__ */ __name(({ error, logPrefix: logPrefix24 }) => {
|
|
1021
|
-
|
|
1022
|
-
|
|
1129
|
+
log6.error(logPrefix24, `An error occurred. Cannot deploy ${logPrefix24}.`);
|
|
1130
|
+
log6.error(logPrefix24, "Error message: %j", error?.message);
|
|
1023
1131
|
}, "deployErrorLogs");
|
|
1024
1132
|
var handleDeployError = /* @__PURE__ */ __name(({ error, logPrefix: logPrefix24 }) => {
|
|
1025
1133
|
deployErrorLogs({
|
|
@@ -1029,12 +1137,12 @@ var handleDeployError = /* @__PURE__ */ __name(({ error, logPrefix: logPrefix24
|
|
|
1029
1137
|
process.exit(1);
|
|
1030
1138
|
}, "handleDeployError");
|
|
1031
1139
|
var handleDeployInitialization = /* @__PURE__ */ __name(async ({ logPrefix: logPrefix24, stackName: preDefinedStackName }) => {
|
|
1032
|
-
|
|
1140
|
+
log6.info(logPrefix24, `Starting deploy ${logPrefix24}...`);
|
|
1033
1141
|
if (preDefinedStackName) {
|
|
1034
1142
|
setPreDefinedStackName(preDefinedStackName);
|
|
1035
1143
|
}
|
|
1036
1144
|
const stackName = await getStackName();
|
|
1037
|
-
|
|
1145
|
+
log6.info(logPrefix24, `stackName: ${stackName}`);
|
|
1038
1146
|
return {
|
|
1039
1147
|
stackName
|
|
1040
1148
|
};
|
|
@@ -1267,7 +1375,7 @@ var getLambdaImageBuilderTemplate = /* @__PURE__ */ __name(() => {
|
|
|
1267
1375
|
]
|
|
1268
1376
|
},
|
|
1269
1377
|
Source: {
|
|
1270
|
-
BuildSpec:
|
|
1378
|
+
BuildSpec: yaml5.dump({
|
|
1271
1379
|
version: "0.2",
|
|
1272
1380
|
phases: {
|
|
1273
1381
|
install: {
|
|
@@ -1668,7 +1776,7 @@ var getVpcTemplate = /* @__PURE__ */ __name(() => {
|
|
|
1668
1776
|
}, "getVpcTemplate");
|
|
1669
1777
|
|
|
1670
1778
|
// src/deploy/baseStack/deployBaseStack.ts
|
|
1671
|
-
var
|
|
1779
|
+
var logPrefix5 = "base-stack";
|
|
1672
1780
|
var baseStackTemplate = deepmerge.all([
|
|
1673
1781
|
getBucketTemplate(),
|
|
1674
1782
|
getCloudFrontTemplate(),
|
|
@@ -1679,7 +1787,7 @@ var baseStackTemplate = deepmerge.all([
|
|
|
1679
1787
|
var deployBaseStack = /* @__PURE__ */ __name(async () => {
|
|
1680
1788
|
try {
|
|
1681
1789
|
const { stackName } = await handleDeployInitialization({
|
|
1682
|
-
logPrefix:
|
|
1790
|
+
logPrefix: logPrefix5,
|
|
1683
1791
|
stackName: BASE_STACK_NAME
|
|
1684
1792
|
});
|
|
1685
1793
|
await deploy({
|
|
@@ -1692,7 +1800,7 @@ var deployBaseStack = /* @__PURE__ */ __name(async () => {
|
|
|
1692
1800
|
} catch (error) {
|
|
1693
1801
|
handleDeployError({
|
|
1694
1802
|
error,
|
|
1695
|
-
logPrefix:
|
|
1803
|
+
logPrefix: logPrefix5
|
|
1696
1804
|
});
|
|
1697
1805
|
}
|
|
1698
1806
|
}, "deployBaseStack");
|
|
@@ -1716,7 +1824,7 @@ var pipelines = [
|
|
|
1716
1824
|
"main",
|
|
1717
1825
|
"tag"
|
|
1718
1826
|
];
|
|
1719
|
-
var
|
|
1827
|
+
var options2 = {
|
|
1720
1828
|
cpu: {
|
|
1721
1829
|
type: "string"
|
|
1722
1830
|
},
|
|
@@ -1778,7 +1886,7 @@ var getCicdConfig = /* @__PURE__ */ __name(() => {
|
|
|
1778
1886
|
return false;
|
|
1779
1887
|
}
|
|
1780
1888
|
const { argv } = parsed;
|
|
1781
|
-
const config = Object.keys(
|
|
1889
|
+
const config = Object.keys(options2).reduce((acc, key) => {
|
|
1782
1890
|
const value = argv[key];
|
|
1783
1891
|
if (value) {
|
|
1784
1892
|
acc[key] = value;
|
|
@@ -1940,7 +2048,7 @@ var getRepositoryImageBuilder = /* @__PURE__ */ __name(() => {
|
|
|
1940
2048
|
]
|
|
1941
2049
|
},
|
|
1942
2050
|
Source: {
|
|
1943
|
-
BuildSpec:
|
|
2051
|
+
BuildSpec: yaml5.dump({
|
|
1944
2052
|
version: "0.2",
|
|
1945
2053
|
phases: {
|
|
1946
2054
|
install: {
|
|
@@ -2745,16 +2853,16 @@ var getCicdTemplate = /* @__PURE__ */ __name(({ pipelines: pipelines2 = [], cpu
|
|
|
2745
2853
|
}
|
|
2746
2854
|
};
|
|
2747
2855
|
}, "getCicdTemplate");
|
|
2748
|
-
var
|
|
2856
|
+
var logPrefix6 = "lambda";
|
|
2749
2857
|
var buildLambdaCode = /* @__PURE__ */ __name(async ({ lambdaEntryPoints, lambdaEntryPointsBaseDir = ".", lambdaExternal = [], lambdaFormat = "esm", lambdaOutdir }) => {
|
|
2750
|
-
|
|
2751
|
-
if (
|
|
2752
|
-
|
|
2858
|
+
log6.info(logPrefix6, "Building Lambda single file...");
|
|
2859
|
+
if (fs4__default.existsSync(lambdaOutdir)) {
|
|
2860
|
+
fs4__default.rmSync(lambdaOutdir, {
|
|
2753
2861
|
recursive: true
|
|
2754
2862
|
});
|
|
2755
2863
|
}
|
|
2756
2864
|
const entryPoints = lambdaEntryPoints.map((entryPoint) => {
|
|
2757
|
-
return
|
|
2865
|
+
return path2__default.resolve(process.cwd(), lambdaEntryPointsBaseDir, entryPoint);
|
|
2758
2866
|
});
|
|
2759
2867
|
const { errors } = esbuild.buildSync({
|
|
2760
2868
|
banner: {
|
|
@@ -2782,8 +2890,8 @@ var buildLambdaCode = /* @__PURE__ */ __name(async ({ lambdaEntryPoints, lambdaE
|
|
|
2782
2890
|
minifySyntax: true,
|
|
2783
2891
|
platform: "node",
|
|
2784
2892
|
splitting: lambdaFormat === "esm",
|
|
2785
|
-
outbase:
|
|
2786
|
-
outdir:
|
|
2893
|
+
outbase: path2__default.join(process.cwd(), lambdaEntryPointsBaseDir),
|
|
2894
|
+
outdir: path2__default.join(process.cwd(), lambdaOutdir),
|
|
2787
2895
|
outExtension: {
|
|
2788
2896
|
".js": lambdaFormat === "esm" ? ".mjs" : ".cjs"
|
|
2789
2897
|
},
|
|
@@ -2807,10 +2915,10 @@ var getPackageLambdaLayerStackName = /* @__PURE__ */ __name((packageName) => {
|
|
|
2807
2915
|
}, "getPackageLambdaLayerStackName");
|
|
2808
2916
|
|
|
2809
2917
|
// src/deploy/lambdaLayer/deployLambdaLayer.ts
|
|
2810
|
-
var
|
|
2918
|
+
var logPrefix7 = "lambda-layer";
|
|
2811
2919
|
var createLambdaLayerZipFile = /* @__PURE__ */ __name(async ({ codeBuildProjectName, packageName }) => {
|
|
2812
|
-
|
|
2813
|
-
const codeBuild2 = new
|
|
2920
|
+
log6.info(logPrefix7, `Creating zip file for package ${packageName}...`);
|
|
2921
|
+
const codeBuild2 = new AWS2.CodeBuild();
|
|
2814
2922
|
const { build } = await codeBuild2.startBuild({
|
|
2815
2923
|
environmentVariablesOverride: [
|
|
2816
2924
|
{
|
|
@@ -2923,7 +3031,7 @@ var deployLambdaLayer = /* @__PURE__ */ __name(async ({ packages, deployIfExists
|
|
|
2923
3031
|
} catch (error) {
|
|
2924
3032
|
handleDeployError({
|
|
2925
3033
|
error,
|
|
2926
|
-
logPrefix:
|
|
3034
|
+
logPrefix: logPrefix7
|
|
2927
3035
|
});
|
|
2928
3036
|
}
|
|
2929
3037
|
}, "deployLambdaLayerSinglePackage");
|
|
@@ -2933,21 +3041,21 @@ var deployLambdaLayer = /* @__PURE__ */ __name(async ({ packages, deployIfExists
|
|
|
2933
3041
|
} catch (error) {
|
|
2934
3042
|
handleDeployError({
|
|
2935
3043
|
error,
|
|
2936
|
-
logPrefix:
|
|
3044
|
+
logPrefix: logPrefix7
|
|
2937
3045
|
});
|
|
2938
3046
|
}
|
|
2939
3047
|
}, "deployLambdaLayer");
|
|
2940
|
-
var
|
|
3048
|
+
var logPrefix8 = "lambda";
|
|
2941
3049
|
var deployLambdaLayers = /* @__PURE__ */ __name(async ({ lambdaExternal = [] }) => {
|
|
2942
3050
|
if (lambdaExternal.length === 0) {
|
|
2943
3051
|
return;
|
|
2944
3052
|
}
|
|
2945
|
-
|
|
3053
|
+
log6.info(logPrefix8, `--lambda-externals [${lambdaExternal.join(", ")}] was found. Creating other layers...`);
|
|
2946
3054
|
const { dependencies = {} } = (() => {
|
|
2947
3055
|
try {
|
|
2948
|
-
return JSON.parse(
|
|
3056
|
+
return JSON.parse(fs4.readFileSync(path2.resolve(process.cwd(), "package.json"), "utf8"));
|
|
2949
3057
|
} catch (err) {
|
|
2950
|
-
|
|
3058
|
+
log6.error(logPrefix8, "Cannot read package.json. Error message: %j", err.message);
|
|
2951
3059
|
return {};
|
|
2952
3060
|
}
|
|
2953
3061
|
})();
|
|
@@ -2964,7 +3072,7 @@ var deployLambdaLayers = /* @__PURE__ */ __name(async ({ lambdaExternal = [] })
|
|
|
2964
3072
|
deployIfExists: false
|
|
2965
3073
|
});
|
|
2966
3074
|
}, "deployLambdaLayers");
|
|
2967
|
-
new
|
|
3075
|
+
new AWS2.CodeBuild({
|
|
2968
3076
|
region: AWS_DEFAULT_REGION
|
|
2969
3077
|
});
|
|
2970
3078
|
var uploadCodeToECR = /* @__PURE__ */ __name(async ({ bucket, key, lambdaExternal, lambdaDockerfile }) => {
|
|
@@ -2972,14 +3080,14 @@ var uploadCodeToECR = /* @__PURE__ */ __name(async ({ bucket, key, lambdaExterna
|
|
|
2972
3080
|
throw new Error("uploadCodeToECR not finished yet.");
|
|
2973
3081
|
}
|
|
2974
3082
|
}, "uploadCodeToECR");
|
|
2975
|
-
var
|
|
3083
|
+
var logPrefix9 = "lambda";
|
|
2976
3084
|
var zipFileName = "lambda.zip";
|
|
2977
3085
|
var uploadCodeToS3 = /* @__PURE__ */ __name(async ({ stackName, lambdaOutdir }) => {
|
|
2978
|
-
|
|
3086
|
+
log6.info(logPrefix9, `Uploading code to S3...`);
|
|
2979
3087
|
const zip = new AdmZip();
|
|
2980
3088
|
const zipFile = `${lambdaOutdir}/${zipFileName}`;
|
|
2981
|
-
if (
|
|
2982
|
-
await
|
|
3089
|
+
if (fs4__default.existsSync(zipFile)) {
|
|
3090
|
+
await fs4__default.promises.rm(zipFile);
|
|
2983
3091
|
}
|
|
2984
3092
|
zip.addLocalFolder(lambdaOutdir);
|
|
2985
3093
|
zip.writeZip(`${lambdaOutdir}/${zipFileName}`);
|
|
@@ -2993,15 +3101,15 @@ var uploadCodeToS3 = /* @__PURE__ */ __name(async ({ stackName, lambdaOutdir })
|
|
|
2993
3101
|
}, "uploadCodeToS3");
|
|
2994
3102
|
|
|
2995
3103
|
// src/deploy/lambda/deployLambdaCode.ts
|
|
2996
|
-
var
|
|
3104
|
+
var logPrefix10 = "lambda";
|
|
2997
3105
|
var deployLambdaCode = /* @__PURE__ */ __name(async ({ lambdaDockerfile, lambdaExternal = [], lambdaImage, lambdaEntryPoints, lambdaEntryPointsBaseDir = "src", lambdaFormat, lambdaOutdir = "out", stackName }) => {
|
|
2998
3106
|
if (!lambdaEntryPoints.length) {
|
|
2999
3107
|
return {};
|
|
3000
3108
|
}
|
|
3001
|
-
|
|
3109
|
+
log6.info(logPrefix10, "Deploying Lambda code...");
|
|
3002
3110
|
for (const entryPoint of lambdaEntryPoints) {
|
|
3003
|
-
const entryPointPath =
|
|
3004
|
-
if (!
|
|
3111
|
+
const entryPointPath = path2__default.resolve(lambdaEntryPointsBaseDir, entryPoint);
|
|
3112
|
+
if (!fs4__default.existsSync(entryPointPath)) {
|
|
3005
3113
|
throw new Error(`Entry point ${entryPointPath} does not exist.`);
|
|
3006
3114
|
}
|
|
3007
3115
|
}
|
|
@@ -3045,16 +3153,16 @@ var getCicdStackName = /* @__PURE__ */ __name(() => {
|
|
|
3045
3153
|
project
|
|
3046
3154
|
].join(" "));
|
|
3047
3155
|
}, "getCicdStackName");
|
|
3048
|
-
var
|
|
3156
|
+
var logPrefix11 = "cicd";
|
|
3049
3157
|
var getLambdaInput = /* @__PURE__ */ __name((extension) => {
|
|
3050
|
-
return
|
|
3158
|
+
return path2.resolve(__dirname, `lambdas/index.${extension}`);
|
|
3051
3159
|
}, "getLambdaInput");
|
|
3052
3160
|
var deployCicdLambdas = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
3053
3161
|
const lambdaInput = (() => {
|
|
3054
|
-
if (
|
|
3162
|
+
if (fs4.existsSync(getLambdaInput("js"))) {
|
|
3055
3163
|
return getLambdaInput("js");
|
|
3056
3164
|
}
|
|
3057
|
-
if (
|
|
3165
|
+
if (fs4.existsSync(getLambdaInput("ts"))) {
|
|
3058
3166
|
return getLambdaInput("ts");
|
|
3059
3167
|
}
|
|
3060
3168
|
throw new Error("Cannot read CICD lambdas file.");
|
|
@@ -3075,7 +3183,7 @@ var deployCicdLambdas = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
3075
3183
|
return s32;
|
|
3076
3184
|
}, "deployCicdLambdas");
|
|
3077
3185
|
var waitRepositoryImageUpdate = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
3078
|
-
|
|
3186
|
+
log6.info(logPrefix11, "Starting repository image update...");
|
|
3079
3187
|
const { OutputValue: projectName } = await getStackOutput({
|
|
3080
3188
|
stackName,
|
|
3081
3189
|
outputKey: REPOSITORY_IMAGE_CODE_BUILD_PROJECT_LOGICAL_ID
|
|
@@ -3096,7 +3204,7 @@ var waitRepositoryImageUpdate = /* @__PURE__ */ __name(async ({ stackName }) =>
|
|
|
3096
3204
|
var deployCicd = /* @__PURE__ */ __name(async ({ cpu, memory, pipelines: pipelines2, updateRepository, slackWebhookUrl, sshKey, sshUrl, taskEnvironment }) => {
|
|
3097
3205
|
try {
|
|
3098
3206
|
const { stackName } = await handleDeployInitialization({
|
|
3099
|
-
logPrefix:
|
|
3207
|
+
logPrefix: logPrefix11,
|
|
3100
3208
|
stackName: getCicdStackName()
|
|
3101
3209
|
});
|
|
3102
3210
|
await deploy({
|
|
@@ -3133,23 +3241,23 @@ var deployCicd = /* @__PURE__ */ __name(async ({ cpu, memory, pipelines: pipelin
|
|
|
3133
3241
|
} catch (error) {
|
|
3134
3242
|
handleDeployError({
|
|
3135
3243
|
error,
|
|
3136
|
-
logPrefix:
|
|
3244
|
+
logPrefix: logPrefix11
|
|
3137
3245
|
});
|
|
3138
3246
|
}
|
|
3139
3247
|
}, "deployCicd");
|
|
3140
3248
|
var readSSHKey = /* @__PURE__ */ __name((dir) => {
|
|
3141
|
-
return
|
|
3249
|
+
return fs4.readFileSync(dir, "utf-8");
|
|
3142
3250
|
}, "readSSHKey");
|
|
3143
|
-
var
|
|
3251
|
+
var logPrefix12 = "deploy-cicd";
|
|
3144
3252
|
var deployCicdCommand = {
|
|
3145
3253
|
command: "cicd",
|
|
3146
3254
|
describe: "Deploy CICD.",
|
|
3147
3255
|
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
3148
|
-
return yargs3.options(addGroupToOptions(
|
|
3256
|
+
return yargs3.options(addGroupToOptions(options2, "Deploy CICD Options"));
|
|
3149
3257
|
}, "builder"),
|
|
3150
3258
|
handler: /* @__PURE__ */ __name(({ destroy: destroy2, ...rest }) => {
|
|
3151
3259
|
if (destroy2) {
|
|
3152
|
-
|
|
3260
|
+
log6.info(logPrefix12, `${NAME} doesn't destroy CICD stack.`);
|
|
3153
3261
|
} else {
|
|
3154
3262
|
deployCicd({
|
|
3155
3263
|
...rest,
|
|
@@ -3283,17 +3391,17 @@ var cloudFormationTypes = [
|
|
|
3283
3391
|
];
|
|
3284
3392
|
var getYamlTypes = /* @__PURE__ */ __name((tagAndTypeArr) => {
|
|
3285
3393
|
return tagAndTypeArr.map(({ tag, options: options10 }) => {
|
|
3286
|
-
return new
|
|
3394
|
+
return new yaml5.Type(tag, options10);
|
|
3287
3395
|
});
|
|
3288
3396
|
}, "getYamlTypes");
|
|
3289
3397
|
var getSchema = /* @__PURE__ */ __name((tagAndTypeArr = []) => {
|
|
3290
|
-
return
|
|
3398
|
+
return yaml5.DEFAULT_SCHEMA.extend(getYamlTypes([
|
|
3291
3399
|
...tagAndTypeArr,
|
|
3292
3400
|
...cloudFormationTypes
|
|
3293
3401
|
]));
|
|
3294
3402
|
}, "getSchema");
|
|
3295
3403
|
var loadCloudFormationTemplate = /* @__PURE__ */ __name((template, tagAndTypeArr = []) => {
|
|
3296
|
-
return
|
|
3404
|
+
return yaml5.load(template, {
|
|
3297
3405
|
schema: getSchema(tagAndTypeArr)
|
|
3298
3406
|
});
|
|
3299
3407
|
}, "loadCloudFormationTemplate");
|
|
@@ -3306,92 +3414,20 @@ var getTypes = /* @__PURE__ */ __name(() => {
|
|
|
3306
3414
|
options: {
|
|
3307
3415
|
kind: "scalar",
|
|
3308
3416
|
construct: /* @__PURE__ */ __name((filePath) => {
|
|
3309
|
-
return
|
|
3417
|
+
return fs4.readFileSync(path2.resolve(process.cwd(), filePath)).toString();
|
|
3310
3418
|
}, "construct")
|
|
3311
3419
|
}
|
|
3312
3420
|
}
|
|
3313
3421
|
];
|
|
3314
3422
|
}, "getTypes");
|
|
3315
3423
|
var readCloudFormationYamlTemplate = /* @__PURE__ */ __name(({ templatePath }) => {
|
|
3316
|
-
const template =
|
|
3424
|
+
const template = fs4.readFileSync(templatePath).toString();
|
|
3317
3425
|
const parsed = loadCloudFormationTemplate(template, getTypes());
|
|
3318
3426
|
if (!parsed || typeof parsed === "string") {
|
|
3319
3427
|
throw new Error("Cannot parse CloudFormation template.");
|
|
3320
3428
|
}
|
|
3321
3429
|
return parsed;
|
|
3322
3430
|
}, "readCloudFormationYamlTemplate");
|
|
3323
|
-
var loadConfig = /* @__PURE__ */ __name((entryPoint) => {
|
|
3324
|
-
const lastEntryPointName = entryPoint.split("/").pop();
|
|
3325
|
-
const filename = lastEntryPointName?.split(".")[0];
|
|
3326
|
-
const outfile = path__default.resolve(process.cwd(), "out", filename + ".js");
|
|
3327
|
-
const result = esbuild.buildSync({
|
|
3328
|
-
bundle: true,
|
|
3329
|
-
entryPoints: [
|
|
3330
|
-
entryPoint
|
|
3331
|
-
],
|
|
3332
|
-
/**
|
|
3333
|
-
* ttoss packages cannot be market as external because it'd break the CI.
|
|
3334
|
-
* On CI, ttoss packages point to the TS main file, not the compiled
|
|
3335
|
-
* ones. See more details here https://github.com/ttoss/ttoss/issues/541.
|
|
3336
|
-
*/
|
|
3337
|
-
external: [],
|
|
3338
|
-
format: "cjs",
|
|
3339
|
-
outfile,
|
|
3340
|
-
platform: "node",
|
|
3341
|
-
target: "ES2021",
|
|
3342
|
-
treeShaking: true
|
|
3343
|
-
});
|
|
3344
|
-
if (result.errors.length > 0) {
|
|
3345
|
-
console.error("Error building config file: ", filename);
|
|
3346
|
-
throw result.errors;
|
|
3347
|
-
}
|
|
3348
|
-
try {
|
|
3349
|
-
const config = importSync(outfile);
|
|
3350
|
-
return config.default || config.config;
|
|
3351
|
-
} catch (error) {
|
|
3352
|
-
console.error("Failed importing build config file: ", filename);
|
|
3353
|
-
throw error;
|
|
3354
|
-
}
|
|
3355
|
-
}, "loadConfig");
|
|
3356
|
-
|
|
3357
|
-
// ../read-config-file/src/index.ts
|
|
3358
|
-
var readConfigFileSync = /* @__PURE__ */ __name(({ configFilePath, options: options10 }) => {
|
|
3359
|
-
const extension = configFilePath.split(".").pop();
|
|
3360
|
-
if (extension === "yaml" || extension === "yml") {
|
|
3361
|
-
const file = fs3__default.readFileSync(configFilePath, "utf8");
|
|
3362
|
-
return yaml4.load(file);
|
|
3363
|
-
}
|
|
3364
|
-
if (extension === "json") {
|
|
3365
|
-
const file = fs3__default.readFileSync(configFilePath, "utf8");
|
|
3366
|
-
return JSON.parse(file);
|
|
3367
|
-
}
|
|
3368
|
-
if (extension === "js") {
|
|
3369
|
-
return __require(configFilePath);
|
|
3370
|
-
}
|
|
3371
|
-
if (extension === "ts") {
|
|
3372
|
-
let result = loadConfig(configFilePath);
|
|
3373
|
-
if (typeof result === "function") {
|
|
3374
|
-
result = result(options10);
|
|
3375
|
-
}
|
|
3376
|
-
return result;
|
|
3377
|
-
}
|
|
3378
|
-
throw new Error("Unsupported config file extension: " + extension);
|
|
3379
|
-
}, "readConfigFileSync");
|
|
3380
|
-
var readConfigFile = /* @__PURE__ */ __name(async ({ configFilePath, options: options10 }) => {
|
|
3381
|
-
const extension = configFilePath.split(".").pop();
|
|
3382
|
-
if (extension === "ts") {
|
|
3383
|
-
let result = loadConfig(configFilePath);
|
|
3384
|
-
if (typeof result === "function") {
|
|
3385
|
-
result = result(options10);
|
|
3386
|
-
}
|
|
3387
|
-
result = await Promise.resolve(result);
|
|
3388
|
-
return result;
|
|
3389
|
-
}
|
|
3390
|
-
return readConfigFileSync({
|
|
3391
|
-
configFilePath,
|
|
3392
|
-
options: options10
|
|
3393
|
-
});
|
|
3394
|
-
}, "readConfigFile");
|
|
3395
3431
|
|
|
3396
3432
|
// ../cloudformation/src/findAndReadCloudFormationTemplate.ts
|
|
3397
3433
|
var defaultTemplatePaths2 = [
|
|
@@ -3408,7 +3444,7 @@ var findAndReadCloudFormationTemplate = /* @__PURE__ */ __name(async ({ template
|
|
|
3408
3444
|
if (acc) {
|
|
3409
3445
|
return acc;
|
|
3410
3446
|
}
|
|
3411
|
-
return
|
|
3447
|
+
return fs4.existsSync(path2.resolve(process.cwd(), cur)) ? cur : acc;
|
|
3412
3448
|
}, "");
|
|
3413
3449
|
if (!templatePath) {
|
|
3414
3450
|
throw new Error("Cannot find a CloudFormation template.");
|
|
@@ -3422,7 +3458,7 @@ var findAndReadCloudFormationTemplate = /* @__PURE__ */ __name(async ({ template
|
|
|
3422
3458
|
templatePath
|
|
3423
3459
|
});
|
|
3424
3460
|
}
|
|
3425
|
-
const configFilePath =
|
|
3461
|
+
const configFilePath = path2.resolve(process.cwd(), templatePath);
|
|
3426
3462
|
return readConfigFile({
|
|
3427
3463
|
configFilePath,
|
|
3428
3464
|
options: options10
|
|
@@ -3449,11 +3485,11 @@ var getLambdaEntryPointsFromTemplate = /* @__PURE__ */ __name((template) => {
|
|
|
3449
3485
|
}, "getLambdaEntryPointsFromTemplate");
|
|
3450
3486
|
|
|
3451
3487
|
// src/deploy/cloudformation.ts
|
|
3452
|
-
var
|
|
3453
|
-
|
|
3488
|
+
var logPrefix13 = "cloudformation";
|
|
3489
|
+
log6.addLevel("event", 1e4, {
|
|
3454
3490
|
fg: "yellow"
|
|
3455
3491
|
});
|
|
3456
|
-
|
|
3492
|
+
log6.addLevel("output", 1e4, {
|
|
3457
3493
|
fg: "blue"
|
|
3458
3494
|
});
|
|
3459
3495
|
var getCloudformationTemplateOptions = /* @__PURE__ */ __name(({ cliOptions, stackName }) => {
|
|
@@ -3470,7 +3506,7 @@ var deployCloudFormation = /* @__PURE__ */ __name(async (cliOptions) => {
|
|
|
3470
3506
|
try {
|
|
3471
3507
|
const { lambdaDockerfile, lambdaEntryPoints, lambdaEntryPointsBaseDir, lambdaImage, lambdaExternal, lambdaFormat, lambdaOutdir, parameters, template, templatePath } = cliOptions;
|
|
3472
3508
|
const { stackName } = await handleDeployInitialization({
|
|
3473
|
-
logPrefix:
|
|
3509
|
+
logPrefix: logPrefix13
|
|
3474
3510
|
});
|
|
3475
3511
|
const cloudFormationTemplate = await (async () => {
|
|
3476
3512
|
if (template) {
|
|
@@ -3635,7 +3671,7 @@ var deployCloudFormation = /* @__PURE__ */ __name(async (cliOptions) => {
|
|
|
3635
3671
|
} catch (error) {
|
|
3636
3672
|
return handleDeployError({
|
|
3637
3673
|
error,
|
|
3638
|
-
logPrefix:
|
|
3674
|
+
logPrefix: logPrefix13
|
|
3639
3675
|
});
|
|
3640
3676
|
}
|
|
3641
3677
|
}, "deployCloudFormation");
|
|
@@ -3664,13 +3700,13 @@ var emptyStackBuckets = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
3664
3700
|
var destroy = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
3665
3701
|
const environment = getEnvironment();
|
|
3666
3702
|
if (environment) {
|
|
3667
|
-
|
|
3703
|
+
log6.info(logPrefix13, `Cannot destroy stack when environment (${environment}) is defined.`);
|
|
3668
3704
|
return;
|
|
3669
3705
|
}
|
|
3670
3706
|
if (!await doesStackExist({
|
|
3671
3707
|
stackName
|
|
3672
3708
|
})) {
|
|
3673
|
-
|
|
3709
|
+
log6.info(logPrefix13, `Stack ${stackName} doesn't exist.`);
|
|
3674
3710
|
return;
|
|
3675
3711
|
}
|
|
3676
3712
|
if (!await canDestroyStack({
|
|
@@ -3684,7 +3720,7 @@ var destroy = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
3684
3720
|
stackName
|
|
3685
3721
|
});
|
|
3686
3722
|
} catch (error) {
|
|
3687
|
-
|
|
3723
|
+
log6.warn(logPrefix13, `Failed to empty buckets for stack ${stackName}: ${error?.message || error}. Proceeding with stack deletion.`);
|
|
3688
3724
|
}
|
|
3689
3725
|
await deleteStack({
|
|
3690
3726
|
stackName
|
|
@@ -3692,22 +3728,22 @@ var destroy = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
3692
3728
|
}, "destroy");
|
|
3693
3729
|
var destroyCloudFormation = /* @__PURE__ */ __name(async ({ stackName: defaultStackName } = {}) => {
|
|
3694
3730
|
try {
|
|
3695
|
-
|
|
3731
|
+
log6.info(logPrefix13, "CAUTION! Starting CloudFormation destroy...");
|
|
3696
3732
|
const stackName = defaultStackName || await getStackName();
|
|
3697
|
-
|
|
3733
|
+
log6.info(logPrefix13, `stackName: ${stackName}`);
|
|
3698
3734
|
await destroy({
|
|
3699
3735
|
stackName
|
|
3700
3736
|
});
|
|
3701
3737
|
} catch (error) {
|
|
3702
3738
|
handleDeployError({
|
|
3703
3739
|
error,
|
|
3704
|
-
logPrefix:
|
|
3740
|
+
logPrefix: logPrefix13
|
|
3705
3741
|
});
|
|
3706
3742
|
}
|
|
3707
3743
|
}, "destroyCloudFormation");
|
|
3708
|
-
var
|
|
3744
|
+
var logPrefix14 = "deploy-lambda-layer";
|
|
3709
3745
|
var packageNameRegex = /@[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)/;
|
|
3710
|
-
var
|
|
3746
|
+
var options3 = {
|
|
3711
3747
|
packages: {
|
|
3712
3748
|
array: true,
|
|
3713
3749
|
describe: `NPM packages' names to be deployed as Lambda Layers. It must follow the format: ${packageNameRegex.toString()}.`,
|
|
@@ -3719,7 +3755,7 @@ var deployLambdaLayerCommand = {
|
|
|
3719
3755
|
command: "lambda-layer",
|
|
3720
3756
|
describe: "Deploy Lambda Layer.",
|
|
3721
3757
|
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
3722
|
-
return yargs3.options(addGroupToOptions(
|
|
3758
|
+
return yargs3.options(addGroupToOptions(options3, "Deploy Lambda Layer Options")).check(({ packages }) => {
|
|
3723
3759
|
const invalidPackages = packages.map((packageName) => {
|
|
3724
3760
|
return packageNameRegex.test(packageName) ? void 0 : packageName;
|
|
3725
3761
|
}).filter((packageName) => {
|
|
@@ -3734,7 +3770,7 @@ var deployLambdaLayerCommand = {
|
|
|
3734
3770
|
}, "builder"),
|
|
3735
3771
|
handler: /* @__PURE__ */ __name(({ destroy: destroy2, lambdaRuntime, ...rest }) => {
|
|
3736
3772
|
if (destroy2) {
|
|
3737
|
-
|
|
3773
|
+
log6.info(logPrefix14, `${NAME} doesn't destroy lambda layers.`);
|
|
3738
3774
|
} else {
|
|
3739
3775
|
deployLambdaLayer({
|
|
3740
3776
|
...rest,
|
|
@@ -3745,12 +3781,12 @@ var deployLambdaLayerCommand = {
|
|
|
3745
3781
|
};
|
|
3746
3782
|
var readDockerfile = /* @__PURE__ */ __name((dockerfilePath) => {
|
|
3747
3783
|
try {
|
|
3748
|
-
return
|
|
3784
|
+
return fs4.readFileSync(path2.join(process.cwd(), dockerfilePath), "utf8");
|
|
3749
3785
|
} catch {
|
|
3750
3786
|
return "";
|
|
3751
3787
|
}
|
|
3752
3788
|
}, "readDockerfile");
|
|
3753
|
-
var
|
|
3789
|
+
var logPrefix15 = "report";
|
|
3754
3790
|
var getGitHubErrorMessage = /* @__PURE__ */ __name(async (response) => {
|
|
3755
3791
|
try {
|
|
3756
3792
|
const body = await response.json();
|
|
@@ -3773,13 +3809,13 @@ var readAllDeployFiles = /* @__PURE__ */ __name(async () => {
|
|
|
3773
3809
|
const results = [];
|
|
3774
3810
|
for (const file of files) {
|
|
3775
3811
|
try {
|
|
3776
|
-
const raw = await
|
|
3812
|
+
const raw = await fs4.promises.readFile(file, "utf-8");
|
|
3777
3813
|
const content = JSON.parse(raw);
|
|
3778
3814
|
if (content.stackName && content.outputs) {
|
|
3779
3815
|
results.push(content);
|
|
3780
3816
|
}
|
|
3781
3817
|
} catch {
|
|
3782
|
-
|
|
3818
|
+
log6.warn(logPrefix15, `Could not read deploy file: ${path2.basename(file)}`);
|
|
3783
3819
|
}
|
|
3784
3820
|
}
|
|
3785
3821
|
return results.sort((a, b) => {
|
|
@@ -3874,15 +3910,15 @@ var reportToGitHubPR = /* @__PURE__ */ __name(async () => {
|
|
|
3874
3910
|
if (!branch) {
|
|
3875
3911
|
throw new Error("CARLIN_BRANCH environment variable is required for --channel=github-pr");
|
|
3876
3912
|
}
|
|
3877
|
-
|
|
3913
|
+
log6.info(logPrefix15, "Reading deploy outputs from workspace...");
|
|
3878
3914
|
const deploys = await readAllDeployFiles();
|
|
3879
|
-
|
|
3915
|
+
log6.info(logPrefix15, `Found ${deploys.length} deploy file(s).`);
|
|
3880
3916
|
const prNumber = await getPrNumber({
|
|
3881
3917
|
branch,
|
|
3882
3918
|
repo,
|
|
3883
3919
|
token
|
|
3884
3920
|
});
|
|
3885
|
-
|
|
3921
|
+
log6.info(logPrefix15, `Reporting to PR #${prNumber}...`);
|
|
3886
3922
|
const body = buildMarkdownComment(deploys);
|
|
3887
3923
|
const existingComment = await findExistingComment({
|
|
3888
3924
|
prNumber,
|
|
@@ -3896,7 +3932,7 @@ var reportToGitHubPR = /* @__PURE__ */ __name(async () => {
|
|
|
3896
3932
|
repo,
|
|
3897
3933
|
token
|
|
3898
3934
|
});
|
|
3899
|
-
|
|
3935
|
+
log6.info(logPrefix15, existingComment ? "PR comment updated." : "PR comment created.");
|
|
3900
3936
|
}, "reportToGitHubPR");
|
|
3901
3937
|
|
|
3902
3938
|
// src/deploy/staticApp/findDefaultBuildFolder.ts
|
|
@@ -3952,11 +3988,11 @@ var getStaticAppBucket = /* @__PURE__ */ __name(async ({ stackName }) => {
|
|
|
3952
3988
|
}
|
|
3953
3989
|
}, "getStaticAppBucket");
|
|
3954
3990
|
var CLOUDFRONT_DISTRIBUTION_ID = "CloudFrontDistributionId";
|
|
3955
|
-
var
|
|
3991
|
+
var logPrefix16 = "static-app";
|
|
3956
3992
|
var invalidateCloudFront = /* @__PURE__ */ __name(async ({ outputs }) => {
|
|
3957
|
-
|
|
3993
|
+
log6.info(logPrefix16, "Invalidating CloudFront...");
|
|
3958
3994
|
if (!outputs) {
|
|
3959
|
-
|
|
3995
|
+
log6.info(logPrefix16, "Invalidation: outputs do not exist.");
|
|
3960
3996
|
return;
|
|
3961
3997
|
}
|
|
3962
3998
|
const cloudFrontDistributionIDOutput = outputs.find((output) => {
|
|
@@ -3976,16 +4012,16 @@ var invalidateCloudFront = /* @__PURE__ */ __name(async ({ outputs }) => {
|
|
|
3976
4012
|
}
|
|
3977
4013
|
}
|
|
3978
4014
|
};
|
|
3979
|
-
const cloudFront = new
|
|
4015
|
+
const cloudFront = new AWS2.CloudFront();
|
|
3980
4016
|
try {
|
|
3981
4017
|
await cloudFront.createInvalidation(params).promise();
|
|
3982
|
-
|
|
4018
|
+
log6.info(logPrefix16, `CloudFront Distribution ID ${distributionId} invalidated with success.`);
|
|
3983
4019
|
} catch (err) {
|
|
3984
|
-
|
|
3985
|
-
|
|
4020
|
+
log6.error(logPrefix16, `Error while trying to invalidate CloudFront distribution ${distributionId}.`);
|
|
4021
|
+
log6.error(logPrefix16, err);
|
|
3986
4022
|
}
|
|
3987
4023
|
} else {
|
|
3988
|
-
|
|
4024
|
+
log6.info(logPrefix16, `Cannot invalidate because distribution does not exist.`);
|
|
3989
4025
|
}
|
|
3990
4026
|
}, "invalidateCloudFront");
|
|
3991
4027
|
|
|
@@ -4443,11 +4479,11 @@ var uploadBuiltAppToS3 = /* @__PURE__ */ __name(async ({ buildFolder: directory,
|
|
|
4443
4479
|
}, "uploadBuiltAppToS3");
|
|
4444
4480
|
|
|
4445
4481
|
// src/deploy/staticApp/deployStaticApp.ts
|
|
4446
|
-
var
|
|
4482
|
+
var logPrefix17 = "static-app";
|
|
4447
4483
|
var deployStaticApp = /* @__PURE__ */ __name(async ({ acm, aliases, appendIndexHtml, buildFolder, cloudfront, spa, hostedZoneName, region, skipUpload }) => {
|
|
4448
4484
|
try {
|
|
4449
4485
|
const { stackName } = await handleDeployInitialization({
|
|
4450
|
-
logPrefix:
|
|
4486
|
+
logPrefix: logPrefix17
|
|
4451
4487
|
});
|
|
4452
4488
|
const params = {
|
|
4453
4489
|
StackName: stackName
|
|
@@ -4499,11 +4535,11 @@ var deployStaticApp = /* @__PURE__ */ __name(async ({ acm, aliases, appendIndexH
|
|
|
4499
4535
|
} catch (error) {
|
|
4500
4536
|
handleDeployError({
|
|
4501
4537
|
error,
|
|
4502
|
-
logPrefix:
|
|
4538
|
+
logPrefix: logPrefix17
|
|
4503
4539
|
});
|
|
4504
4540
|
}
|
|
4505
4541
|
}, "deployStaticApp");
|
|
4506
|
-
var
|
|
4542
|
+
var options4 = {
|
|
4507
4543
|
acm: {
|
|
4508
4544
|
describe: "The ARN of the certificate or the name of the exported variable whose value is the ARN of the certificate that will be associated to CloudFront.",
|
|
4509
4545
|
type: "string"
|
|
@@ -4563,8 +4599,8 @@ var deployStaticAppCommand = {
|
|
|
4563
4599
|
command: "static-app",
|
|
4564
4600
|
describe: "Deploy static app.",
|
|
4565
4601
|
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
4566
|
-
return yargs3.options(addGroupToOptions(
|
|
4567
|
-
|
|
4602
|
+
return yargs3.options(addGroupToOptions(options4, "Deploy Static App Options")).middleware(() => {
|
|
4603
|
+
AWS2.config.region = CLOUDFRONT_REGION;
|
|
4568
4604
|
});
|
|
4569
4605
|
}, "builder"),
|
|
4570
4606
|
handler: /* @__PURE__ */ __name(({ destroy: destroy2, ...rest }) => {
|
|
@@ -4575,7 +4611,7 @@ var deployStaticAppCommand = {
|
|
|
4575
4611
|
}
|
|
4576
4612
|
}, "handler")
|
|
4577
4613
|
};
|
|
4578
|
-
var
|
|
4614
|
+
var logPrefix18 = "deploy vercel";
|
|
4579
4615
|
var makeCommand = /* @__PURE__ */ __name((cmds) => {
|
|
4580
4616
|
return cmds.filter((cmd) => {
|
|
4581
4617
|
return cmd !== void 0 && cmd !== null && cmd !== "";
|
|
@@ -4583,7 +4619,7 @@ var makeCommand = /* @__PURE__ */ __name((cmds) => {
|
|
|
4583
4619
|
}, "makeCommand");
|
|
4584
4620
|
var deployVercel = /* @__PURE__ */ __name(async ({ token }) => {
|
|
4585
4621
|
try {
|
|
4586
|
-
|
|
4622
|
+
log6.info(logPrefix18, "Deploying on Vercel...");
|
|
4587
4623
|
const environment = getEnvironment();
|
|
4588
4624
|
const finalToken = token || process.env.VERCEL_TOKEN;
|
|
4589
4625
|
if (!finalToken) {
|
|
@@ -4618,12 +4654,12 @@ var deployVercel = /* @__PURE__ */ __name(async ({ token }) => {
|
|
|
4618
4654
|
} catch (error) {
|
|
4619
4655
|
handleDeployError({
|
|
4620
4656
|
error,
|
|
4621
|
-
logPrefix:
|
|
4657
|
+
logPrefix: logPrefix18
|
|
4622
4658
|
});
|
|
4623
4659
|
}
|
|
4624
4660
|
}, "deployVercel");
|
|
4625
|
-
var
|
|
4626
|
-
var
|
|
4661
|
+
var logPrefix19 = "deploy vercel";
|
|
4662
|
+
var options5 = {
|
|
4627
4663
|
token: {
|
|
4628
4664
|
describe: "Vercel authorization token.",
|
|
4629
4665
|
type: "string"
|
|
@@ -4633,11 +4669,11 @@ var deployVercelCommand = {
|
|
|
4633
4669
|
command: "vercel",
|
|
4634
4670
|
describe: "Deploy on Vercel.",
|
|
4635
4671
|
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
4636
|
-
return yargs3.options(addGroupToOptions(
|
|
4672
|
+
return yargs3.options(addGroupToOptions(options5, "Deploy on Vercel Options"));
|
|
4637
4673
|
}, "builder"),
|
|
4638
4674
|
handler: /* @__PURE__ */ __name(({ destroy: destroy2, ...rest }) => {
|
|
4639
4675
|
if (destroy2) {
|
|
4640
|
-
|
|
4676
|
+
log6.info(logPrefix19, "Destroy Vercel deployment not implemented yet.");
|
|
4641
4677
|
} else {
|
|
4642
4678
|
deployVercel(rest);
|
|
4643
4679
|
}
|
|
@@ -4645,7 +4681,7 @@ var deployVercelCommand = {
|
|
|
4645
4681
|
};
|
|
4646
4682
|
|
|
4647
4683
|
// src/deploy/vm/command.options.ts
|
|
4648
|
-
var
|
|
4684
|
+
var options6 = {
|
|
4649
4685
|
"user-name": {
|
|
4650
4686
|
demandOption: true,
|
|
4651
4687
|
describe: "SSH user name to connect to the VM (e.g., ec2-user, ubuntu)",
|
|
@@ -4715,7 +4751,7 @@ var generateSSHCommandWithPwd = /* @__PURE__ */ __name(({ userName, host, passwo
|
|
|
4715
4751
|
}, "generateSSHCommandWithPwd");
|
|
4716
4752
|
|
|
4717
4753
|
// src/deploy/vm/deployVM.ts
|
|
4718
|
-
var
|
|
4754
|
+
var logPrefix20 = "deploy-vm";
|
|
4719
4755
|
var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPath, password, port, fixPermissions = false }) => {
|
|
4720
4756
|
if (!userName || !host || !scriptPath) {
|
|
4721
4757
|
throw new Error("Missing required parameters: userName, host, scriptPath");
|
|
@@ -4736,27 +4772,27 @@ var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPa
|
|
|
4736
4772
|
const permissionStr = permissions.toString(8);
|
|
4737
4773
|
const fixCommand = `chmod 400 ${keyPath}`;
|
|
4738
4774
|
if (fixPermissions) {
|
|
4739
|
-
|
|
4775
|
+
log6.info(logPrefix20, `Fixing SSH key permissions: ${keyPath} (${permissionStr} \u2192 400)`);
|
|
4740
4776
|
chmodSync(keyPath, 256);
|
|
4741
|
-
|
|
4777
|
+
log6.info(logPrefix20, `Permissions set to 400 (read-only by owner)`);
|
|
4742
4778
|
} else {
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4779
|
+
log6.error(logPrefix20, `SSH key permissions too open: ${permissionStr} (octal)`);
|
|
4780
|
+
log6.error(logPrefix20, `SSH requires permissions 400 or 600`);
|
|
4781
|
+
log6.error(logPrefix20, `Fix manually: ${fixCommand}`);
|
|
4782
|
+
log6.error(logPrefix20, `Or run with: --fix-permissions`);
|
|
4747
4783
|
throw new Error(`Invalid SSH key permissions: ${permissionStr}. Expected 400 or 600.`);
|
|
4748
4784
|
}
|
|
4749
4785
|
} else {
|
|
4750
|
-
|
|
4786
|
+
log6.info(logPrefix20, `SSH key permissions OK: ${permissions.toString(8)}`);
|
|
4751
4787
|
}
|
|
4752
4788
|
} catch (error) {
|
|
4753
4789
|
if (error instanceof Error) {
|
|
4754
4790
|
if (error.message.includes("Invalid SSH key permissions")) {
|
|
4755
4791
|
throw error;
|
|
4756
4792
|
}
|
|
4757
|
-
|
|
4793
|
+
log6.warn(logPrefix20, `Warning: Could not check key permissions: ${error.message}`);
|
|
4758
4794
|
} else {
|
|
4759
|
-
|
|
4795
|
+
log6.warn(logPrefix20, "Warning: Could not check key permissions: Unknown error");
|
|
4760
4796
|
}
|
|
4761
4797
|
}
|
|
4762
4798
|
}
|
|
@@ -4791,15 +4827,15 @@ var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPa
|
|
|
4791
4827
|
});
|
|
4792
4828
|
const validateStdin = /* @__PURE__ */ __name((stdin) => {
|
|
4793
4829
|
if (!stdin) {
|
|
4794
|
-
|
|
4830
|
+
log6.error(logPrefix20, "SSH process stdin is null or undefined");
|
|
4795
4831
|
return false;
|
|
4796
4832
|
}
|
|
4797
4833
|
if (stdin.destroyed) {
|
|
4798
|
-
|
|
4834
|
+
log6.error(logPrefix20, "SSH process stdin has been destroyed");
|
|
4799
4835
|
return false;
|
|
4800
4836
|
}
|
|
4801
4837
|
if (!stdin.writable) {
|
|
4802
|
-
|
|
4838
|
+
log6.error(logPrefix20, "SSH process stdin is not writable");
|
|
4803
4839
|
return false;
|
|
4804
4840
|
}
|
|
4805
4841
|
return true;
|
|
@@ -4810,7 +4846,7 @@ var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPa
|
|
|
4810
4846
|
}
|
|
4811
4847
|
if (!existsSync(scriptPath)) {
|
|
4812
4848
|
const message = `Deployment script not found at path: ${scriptPath}`;
|
|
4813
|
-
|
|
4849
|
+
log6.error(logPrefix20, message);
|
|
4814
4850
|
reject(new Error(message));
|
|
4815
4851
|
return;
|
|
4816
4852
|
}
|
|
@@ -4820,7 +4856,7 @@ var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPa
|
|
|
4820
4856
|
}
|
|
4821
4857
|
deployScript.pipe(sshProcess.stdin);
|
|
4822
4858
|
const sigintHandler = /* @__PURE__ */ __name(() => {
|
|
4823
|
-
|
|
4859
|
+
log6.info(logPrefix20, "Interrupting deployment...");
|
|
4824
4860
|
sshProcess.kill("SIGINT");
|
|
4825
4861
|
process.exit(130);
|
|
4826
4862
|
}, "sigintHandler");
|
|
@@ -4844,12 +4880,12 @@ var deployVM = /* @__PURE__ */ __name(async ({ userName, host, scriptPath, keyPa
|
|
|
4844
4880
|
}, "deployVM");
|
|
4845
4881
|
|
|
4846
4882
|
// src/deploy/vm/command.ts
|
|
4847
|
-
var
|
|
4883
|
+
var logPrefix21 = "deploy-vm";
|
|
4848
4884
|
var deployVMCommand = {
|
|
4849
4885
|
command: "vm",
|
|
4850
4886
|
describe: "Deploy to a VM via SSH by executing a deployment script",
|
|
4851
4887
|
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
4852
|
-
return yargs3.options(addGroupToOptions(
|
|
4888
|
+
return yargs3.options(addGroupToOptions(options6, "Deploy VM Options"));
|
|
4853
4889
|
}, "builder"),
|
|
4854
4890
|
handler: /* @__PURE__ */ __name(async ({ userName, host, port, keyPath, scriptPath, password, fixPermissions }) => {
|
|
4855
4891
|
try {
|
|
@@ -4862,16 +4898,16 @@ var deployVMCommand = {
|
|
|
4862
4898
|
port,
|
|
4863
4899
|
fixPermissions
|
|
4864
4900
|
});
|
|
4865
|
-
|
|
4901
|
+
log6.info(logPrefix21, "Deployment completed successfully!");
|
|
4866
4902
|
} catch (error) {
|
|
4867
|
-
|
|
4903
|
+
log6.error(logPrefix21, "Deployment failed: %s", error.message);
|
|
4868
4904
|
process.exit(1);
|
|
4869
4905
|
}
|
|
4870
4906
|
}, "handler")
|
|
4871
4907
|
};
|
|
4872
4908
|
|
|
4873
4909
|
// src/deploy/command.ts
|
|
4874
|
-
var
|
|
4910
|
+
var logPrefix22 = "deploy";
|
|
4875
4911
|
var checkAwsAccountId = /* @__PURE__ */ __name(async (awsAccountId) => {
|
|
4876
4912
|
try {
|
|
4877
4913
|
const currentAwsAccountId = await getAwsAccountId();
|
|
@@ -4882,7 +4918,7 @@ var checkAwsAccountId = /* @__PURE__ */ __name(async (awsAccountId) => {
|
|
|
4882
4918
|
if (error.code === "CredentialsError") {
|
|
4883
4919
|
return;
|
|
4884
4920
|
}
|
|
4885
|
-
|
|
4921
|
+
log6.error(logPrefix22, error.message);
|
|
4886
4922
|
process.exit();
|
|
4887
4923
|
}
|
|
4888
4924
|
}, "checkAwsAccountId");
|
|
@@ -4911,11 +4947,11 @@ var reportDeployCommand = {
|
|
|
4911
4947
|
stackName: newStackName
|
|
4912
4948
|
});
|
|
4913
4949
|
} catch (error) {
|
|
4914
|
-
|
|
4950
|
+
log6.info(logPrefix22, "Cannot report stack. Message: %s", error.message);
|
|
4915
4951
|
}
|
|
4916
4952
|
}, "handler")
|
|
4917
4953
|
};
|
|
4918
|
-
var
|
|
4954
|
+
var options7 = {
|
|
4919
4955
|
"aws-account-id": {
|
|
4920
4956
|
describe: "AWS account id associated with the deployment.",
|
|
4921
4957
|
type: "string"
|
|
@@ -4963,7 +4999,7 @@ var options6 = {
|
|
|
4963
4999
|
type: "string"
|
|
4964
5000
|
},
|
|
4965
5001
|
"lambda-outdir": {
|
|
4966
|
-
default: "
|
|
5002
|
+
default: "out",
|
|
4967
5003
|
describe: "Output directory for built Lambda code.",
|
|
4968
5004
|
type: "string"
|
|
4969
5005
|
},
|
|
@@ -5074,7 +5110,7 @@ var deployCommand = {
|
|
|
5074
5110
|
command: "deploy [deploy]",
|
|
5075
5111
|
describe: "Deploy cloud resources.",
|
|
5076
5112
|
builder: /* @__PURE__ */ __name((yargsBuilder) => {
|
|
5077
|
-
yargsBuilder.example(examples).options(addGroupToOptions(
|
|
5113
|
+
yargsBuilder.example(examples).options(addGroupToOptions(options7, "Deploy Options")).middleware(({ stackName }) => {
|
|
5078
5114
|
if (stackName) {
|
|
5079
5115
|
setPreDefinedStackName(stackName);
|
|
5080
5116
|
}
|
|
@@ -5096,7 +5132,7 @@ var deployCommand = {
|
|
|
5096
5132
|
}
|
|
5097
5133
|
}).middleware(({ skipDeploy }) => {
|
|
5098
5134
|
if (skipDeploy) {
|
|
5099
|
-
|
|
5135
|
+
log6.warn(logPrefix22, "Skip deploy flag is true, then the deploy command wasn't executed.");
|
|
5100
5136
|
process.exit(0);
|
|
5101
5137
|
}
|
|
5102
5138
|
}).middleware(({ lambdaExternals, lambdaInput }) => {
|
|
@@ -5137,71 +5173,28 @@ var deployCommand = {
|
|
|
5137
5173
|
}
|
|
5138
5174
|
}, "handler")
|
|
5139
5175
|
};
|
|
5140
|
-
var logPrefix22 = "cicd-ecs-task-report";
|
|
5141
|
-
var sendEcsTaskReport = /* @__PURE__ */ __name(async ({ status }) => {
|
|
5142
|
-
if (!process.env.ECS_TASK_REPORT_HANDLER_NAME) {
|
|
5143
|
-
log5.info(logPrefix22, "ECS_TASK_REPORT_HANDLER_NAME not defined.");
|
|
5144
|
-
return;
|
|
5145
|
-
}
|
|
5146
|
-
const lambda = new AWS.Lambda();
|
|
5147
|
-
const payload = {
|
|
5148
|
-
status
|
|
5149
|
-
};
|
|
5150
|
-
if (process.env.ECS_TASK_ARN) {
|
|
5151
|
-
payload.ecsTaskArn = process.env.ECS_TASK_ARN;
|
|
5152
|
-
}
|
|
5153
|
-
if (process.env.PIPELINE_NAME) {
|
|
5154
|
-
payload.pipelineName = process.env.PIPELINE_NAME;
|
|
5155
|
-
}
|
|
5156
|
-
await lambda.invokeAsync({
|
|
5157
|
-
FunctionName: process.env.ECS_TASK_REPORT_HANDLER_NAME,
|
|
5158
|
-
InvokeArgs: JSON.stringify(payload)
|
|
5159
|
-
}).promise();
|
|
5160
|
-
log5.info(logPrefix22, "Report sent.");
|
|
5161
|
-
}, "sendEcsTaskReport");
|
|
5162
|
-
var options7 = {
|
|
5163
|
-
status: {
|
|
5164
|
-
choices: [
|
|
5165
|
-
"Approved",
|
|
5166
|
-
"Rejected",
|
|
5167
|
-
"MainTagFound"
|
|
5168
|
-
],
|
|
5169
|
-
demandOption: true,
|
|
5170
|
-
type: "string"
|
|
5171
|
-
}
|
|
5172
|
-
};
|
|
5173
|
-
var ecsTaskReportCommand = {
|
|
5174
|
-
command: "cicd-ecs-task-report",
|
|
5175
|
-
describe: false,
|
|
5176
|
-
builder: /* @__PURE__ */ __name((yargs3) => {
|
|
5177
|
-
return yargs3.options(options7);
|
|
5178
|
-
}, "builder"),
|
|
5179
|
-
handler: /* @__PURE__ */ __name(async (args) => {
|
|
5180
|
-
return sendEcsTaskReport(args);
|
|
5181
|
-
}, "handler")
|
|
5182
|
-
};
|
|
5183
5176
|
var logPrefix23 = "generate-env";
|
|
5184
5177
|
var readEnvFile = /* @__PURE__ */ __name(async ({ envFileName, envsPath }) => {
|
|
5185
5178
|
try {
|
|
5186
|
-
const content = await
|
|
5179
|
+
const content = await fs4.promises.readFile(path2.resolve(process.cwd(), envsPath, envFileName), "utf8");
|
|
5187
5180
|
return content;
|
|
5188
5181
|
} catch {
|
|
5189
5182
|
return void 0;
|
|
5190
5183
|
}
|
|
5191
5184
|
}, "readEnvFile");
|
|
5192
5185
|
var writeEnvFile = /* @__PURE__ */ __name(async ({ envFileName, content }) => {
|
|
5193
|
-
return
|
|
5186
|
+
return fs4.promises.writeFile(path2.resolve(process.cwd(), envFileName), content);
|
|
5194
5187
|
}, "writeEnvFile");
|
|
5195
5188
|
var readDeployOutputLines = /* @__PURE__ */ __name(async ({ envFromDeployOutputs }) => {
|
|
5196
5189
|
const lines = [];
|
|
5197
5190
|
for (const { dir, variables } of envFromDeployOutputs) {
|
|
5198
|
-
const latestDeployPath =
|
|
5191
|
+
const latestDeployPath = path2.resolve(process.cwd(), dir, ".carlin", LATEST_DEPLOY_OUTPUTS_FILENAME);
|
|
5199
5192
|
let latestDeploy;
|
|
5200
5193
|
try {
|
|
5201
|
-
const raw = await
|
|
5194
|
+
const raw = await fs4.promises.readFile(latestDeployPath, "utf8");
|
|
5202
5195
|
latestDeploy = JSON.parse(raw);
|
|
5203
5196
|
} catch {
|
|
5204
|
-
|
|
5197
|
+
log6.warn(logPrefix23, "Could not read latest-deploy.json from %s. Skipping.", latestDeployPath);
|
|
5205
5198
|
continue;
|
|
5206
5199
|
}
|
|
5207
5200
|
const outputs = latestDeploy.outputs ?? {};
|
|
@@ -5211,7 +5204,7 @@ var readDeployOutputLines = /* @__PURE__ */ __name(async ({ envFromDeployOutputs
|
|
|
5211
5204
|
const field = dotIndex === -1 ? "OutputValue" : outputPath.slice(dotIndex + 1);
|
|
5212
5205
|
const outputValue = outputs[outputKey]?.[field];
|
|
5213
5206
|
if (outputValue === void 0) {
|
|
5214
|
-
|
|
5207
|
+
log6.warn(logPrefix23, 'Output path "%s" not found in %s. Skipping %s.', outputPath, latestDeployPath, envVarName);
|
|
5215
5208
|
continue;
|
|
5216
5209
|
}
|
|
5217
5210
|
lines.push(`${envVarName}=${outputValue}`);
|
|
@@ -5227,7 +5220,7 @@ var generateEnv = /* @__PURE__ */ __name(async ({ defaultEnvironment, envFromDep
|
|
|
5227
5220
|
envsPath
|
|
5228
5221
|
});
|
|
5229
5222
|
if (!envFile) {
|
|
5230
|
-
|
|
5223
|
+
log6.info(logPrefix23, "Env file %s doesn't exist. Skip generating env file.", envFileName);
|
|
5231
5224
|
return;
|
|
5232
5225
|
}
|
|
5233
5226
|
const deployOutputLines = envFromDeployOutputs && envFromDeployOutputs.length > 0 ? await readDeployOutputLines({
|
|
@@ -5251,7 +5244,7 @@ ${deployOutputLines.join("\n")}
|
|
|
5251
5244
|
content,
|
|
5252
5245
|
envFileName: ".env"
|
|
5253
5246
|
});
|
|
5254
|
-
|
|
5247
|
+
log6.info(logPrefix23, "Generate env file %s from %s successfully.", ".env", envFileName);
|
|
5255
5248
|
}, "generateEnv");
|
|
5256
5249
|
|
|
5257
5250
|
// src/generateEnv/generateEnvCommand.ts
|
|
@@ -5284,6 +5277,8 @@ var generateEnvCommand = {
|
|
|
5284
5277
|
return generateEnv(args);
|
|
5285
5278
|
}, "handler")
|
|
5286
5279
|
};
|
|
5280
|
+
|
|
5281
|
+
// src/cli.ts
|
|
5287
5282
|
var coerceSetEnvVar = /* @__PURE__ */ __name((env) => {
|
|
5288
5283
|
return (value) => {
|
|
5289
5284
|
setEnvVar(env, value);
|
|
@@ -5329,42 +5324,99 @@ var getPkgConfig = /* @__PURE__ */ __name(() => {
|
|
|
5329
5324
|
var getEnv = /* @__PURE__ */ __name(() => {
|
|
5330
5325
|
return constantCase(NAME);
|
|
5331
5326
|
}, "getEnv");
|
|
5332
|
-
var
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
return `${NAME}.${ext}`;
|
|
5327
|
+
var normalizeConfigOptionValue = /* @__PURE__ */ __name(({ value }) => {
|
|
5328
|
+
if (!value || value === "undefined") {
|
|
5329
|
+
return void 0;
|
|
5330
|
+
}
|
|
5331
|
+
return value;
|
|
5332
|
+
}, "normalizeConfigOptionValue");
|
|
5333
|
+
var getArgValue = /* @__PURE__ */ __name(({ args, names }) => {
|
|
5334
|
+
for (const [index, arg] of args.entries()) {
|
|
5335
|
+
const equalSignName = names.find((name) => {
|
|
5336
|
+
return arg.startsWith(`${name}=`);
|
|
5343
5337
|
});
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
do {
|
|
5348
|
-
findUpPath = findUpSync(names, {
|
|
5349
|
-
cwd: currentPath
|
|
5338
|
+
if (equalSignName) {
|
|
5339
|
+
return normalizeConfigOptionValue({
|
|
5340
|
+
value: arg.slice(equalSignName.length + 1)
|
|
5350
5341
|
});
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5342
|
+
}
|
|
5343
|
+
if (names.includes(arg)) {
|
|
5344
|
+
return normalizeConfigOptionValue({
|
|
5345
|
+
value: args[index + 1]
|
|
5346
|
+
});
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
return void 0;
|
|
5350
|
+
}, "getArgValue");
|
|
5351
|
+
var getConfigFileOptions = /* @__PURE__ */ __name(({ args = hideBin(process.argv) } = {}) => {
|
|
5352
|
+
return {
|
|
5353
|
+
branch: getArgValue({
|
|
5354
|
+
args,
|
|
5355
|
+
names: [
|
|
5356
|
+
"--branch"
|
|
5357
|
+
]
|
|
5358
|
+
}) || process.env.CARLIN_BRANCH,
|
|
5359
|
+
environment: getArgValue({
|
|
5360
|
+
args,
|
|
5361
|
+
names: [
|
|
5362
|
+
"--environment",
|
|
5363
|
+
"--env",
|
|
5364
|
+
"-e"
|
|
5365
|
+
]
|
|
5366
|
+
}) || process.env.CARLIN_ENVIRONMENT || process.env.ENVIRONMENT,
|
|
5367
|
+
project: getArgValue({
|
|
5368
|
+
args,
|
|
5369
|
+
names: [
|
|
5370
|
+
"--project"
|
|
5371
|
+
]
|
|
5372
|
+
}) || process.env.CARLIN_PROJECT
|
|
5373
|
+
};
|
|
5374
|
+
}, "getConfigFileOptions");
|
|
5375
|
+
var getConfigFileNames = /* @__PURE__ */ __name(() => {
|
|
5376
|
+
return [
|
|
5377
|
+
"ts",
|
|
5378
|
+
"js",
|
|
5379
|
+
"yml",
|
|
5380
|
+
"yaml",
|
|
5381
|
+
"json"
|
|
5382
|
+
].map((ext) => {
|
|
5383
|
+
return `${NAME}.${ext}`;
|
|
5384
|
+
});
|
|
5385
|
+
}, "getConfigFileNames");
|
|
5386
|
+
var findConfigFilePaths = /* @__PURE__ */ __name(() => {
|
|
5387
|
+
const names = getConfigFileNames();
|
|
5388
|
+
const paths = [];
|
|
5389
|
+
let currentPath = process.cwd();
|
|
5390
|
+
let findUpPath;
|
|
5391
|
+
do {
|
|
5392
|
+
findUpPath = findUpSync(names, {
|
|
5393
|
+
cwd: currentPath
|
|
5360
5394
|
});
|
|
5361
|
-
|
|
5362
|
-
|
|
5395
|
+
if (findUpPath) {
|
|
5396
|
+
currentPath = path2__default.resolve(findUpPath, "../..");
|
|
5397
|
+
paths.push(findUpPath);
|
|
5398
|
+
}
|
|
5399
|
+
} while (findUpPath);
|
|
5400
|
+
return paths;
|
|
5401
|
+
}, "findConfigFilePaths");
|
|
5402
|
+
var readConfigFiles = /* @__PURE__ */ __name(() => {
|
|
5403
|
+
const configs = findConfigFilePaths().map((configFilePath) => {
|
|
5404
|
+
return readConfigFileSync({
|
|
5405
|
+
configFilePath,
|
|
5406
|
+
options: getConfigFileOptions()
|
|
5407
|
+
}) || {};
|
|
5408
|
+
});
|
|
5409
|
+
return deepmerge.all(configs.reverse());
|
|
5410
|
+
}, "readConfigFiles");
|
|
5411
|
+
var cli = /* @__PURE__ */ __name(() => {
|
|
5412
|
+
let finalConfig;
|
|
5413
|
+
const getConfig = /* @__PURE__ */ __name(() => {
|
|
5414
|
+
return finalConfig = readConfigFiles();
|
|
5363
5415
|
}, "getConfig");
|
|
5364
5416
|
const handleEnvironments = /* @__PURE__ */ __name((argv, { parsed }) => {
|
|
5365
5417
|
const { environment, environments } = argv;
|
|
5366
5418
|
if (environment && environments && environments[environment]) {
|
|
5367
|
-
Object.entries(environments[environment])
|
|
5419
|
+
for (const [key, value] of Object.entries(environments[environment])) {
|
|
5368
5420
|
const isKeyFromCli = (() => {
|
|
5369
5421
|
const kebabCaseKey = kebabCase(key);
|
|
5370
5422
|
if (parsed?.defaulted?.[kebabCaseKey]) {
|
|
@@ -5378,7 +5430,7 @@ var cli = /* @__PURE__ */ __name(() => {
|
|
|
5378
5430
|
if (!isKeyFromCli) {
|
|
5379
5431
|
argv[key] = value;
|
|
5380
5432
|
}
|
|
5381
|
-
}
|
|
5433
|
+
}
|
|
5382
5434
|
}
|
|
5383
5435
|
}, "handleEnvironments");
|
|
5384
5436
|
return yargs(hideBin(process.argv)).strictCommands().scriptName(NAME).env(getEnv()).options(addGroupToOptions(options9, "Common Options")).middleware((argv) => {
|
|
@@ -5405,11 +5457,12 @@ var cli = /* @__PURE__ */ __name(() => {
|
|
|
5405
5457
|
throw new Error(`environment type is invalid. The value: ${JSON.stringify(environment)}`);
|
|
5406
5458
|
}
|
|
5407
5459
|
}).middleware(({ region }) => {
|
|
5408
|
-
|
|
5460
|
+
AWS2.config.region = region;
|
|
5409
5461
|
setEnvVar("REGION", region);
|
|
5410
5462
|
}).pkgConf(getPkgConfig()).config(getConfig()).config("config", (configFilePath) => {
|
|
5411
5463
|
return readConfigFileSync({
|
|
5412
|
-
configFilePath
|
|
5464
|
+
configFilePath,
|
|
5465
|
+
options: getConfigFileOptions()
|
|
5413
5466
|
});
|
|
5414
5467
|
}).command({
|
|
5415
5468
|
command: "print-args",
|