carlin 1.31.2 → 1.31.4
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/dist/cli.js +4 -27
- package/dist/deploy/addDefaults.cloudFormation.js +1 -2
- package/dist/deploy/cicd/command.options.js +3 -1
- package/dist/deploy/cicd/lambdas/ecsTaskReport.handler.js +1 -1
- package/dist/deploy/cicd/lambdas/pipelines.handler.js +1 -2
- package/dist/deploy/cicd/lambdas/putApprovalResultManualTask.js +1 -2
- package/dist/deploy/cloudFormation.core.js +1 -1
- package/dist/deploy/cloudFormation.js +4 -5
- package/dist/deploy/command.js +2 -1
- package/dist/deploy/lambda/uploadCodeToECR.js +1 -1
- package/dist/deploy/lambdaLayer/deployLambdaLayer.js +3 -4
- package/dist/deploy/staticApp/getStaticAppBucket.js +1 -1
- package/dist/deploy/staticApp/invalidateCloudFront.js +1 -1
- package/dist/deploy/staticApp/removeOldVersions.js +6 -4
- package/dist/deploy/utils.js +1 -1
- package/dist/generateEnv/generateEnvCommand.js +1 -1
- package/dist/utils/codeBuild.js +2 -2
- package/package.json +8 -8
package/dist/cli.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -29,19 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
6
|
exports.cli = exports.options = void 0;
|
|
30
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
31
8
|
/* eslint-disable no-param-reassign */
|
|
32
|
-
const yargs = __importStar(require("yargs"));
|
|
33
9
|
const config_1 = require("./config");
|
|
34
10
|
const utils_1 = require("./utils");
|
|
35
11
|
const change_case_1 = require("change-case");
|
|
36
12
|
const command_1 = require("./deploy/command");
|
|
37
13
|
const ecsTaskReportCommand_1 = require("./deploy/cicd/ecsTaskReportCommand");
|
|
38
14
|
const generateEnvCommand_1 = require("./generateEnv/generateEnvCommand");
|
|
15
|
+
const helpers_1 = require("yargs/helpers");
|
|
39
16
|
const cloudformation_1 = require("@ttoss/cloudformation");
|
|
40
17
|
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
41
18
|
const deep_equal_1 = __importDefault(require("deep-equal"));
|
|
42
19
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
43
20
|
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
44
21
|
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
45
23
|
const coerceSetEnvVar = (env) => {
|
|
46
24
|
return (value) => {
|
|
47
25
|
(0, utils_1.setEnvVar)(env, value);
|
|
@@ -167,7 +145,7 @@ const cli = () => {
|
|
|
167
145
|
finalConfig = deepmerge_1.default.all(configs.reverse());
|
|
168
146
|
return finalConfig;
|
|
169
147
|
};
|
|
170
|
-
return (
|
|
148
|
+
return ((0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
171
149
|
/**
|
|
172
150
|
* It can't be full strict because options may overlap among carlin config
|
|
173
151
|
* files.
|
|
@@ -205,13 +183,12 @@ const cli = () => {
|
|
|
205
183
|
* - Case 3 if the two above are falsy.
|
|
206
184
|
*/
|
|
207
185
|
const isKeyFromCli = (() => {
|
|
208
|
-
var _a;
|
|
209
186
|
const paramCaseKey = (0, change_case_1.paramCase)(key);
|
|
210
187
|
/**
|
|
211
188
|
* Case 1.
|
|
212
189
|
* Fixes #16 https://github.com/ttoss/carlin/issues/16
|
|
213
190
|
*/
|
|
214
|
-
if (
|
|
191
|
+
if (parsed?.defaulted?.[paramCaseKey]) {
|
|
215
192
|
return false;
|
|
216
193
|
}
|
|
217
194
|
/**
|
|
@@ -54,8 +54,7 @@ const addLogGroupToResources = (template) => {
|
|
|
54
54
|
* Properties includes the Lambda logical id.
|
|
55
55
|
*/
|
|
56
56
|
const logGroup = resourcesEntries.find(([, resource2]) => {
|
|
57
|
-
|
|
58
|
-
const logGroupNameStr = JSON.stringify(((_b = (_a = resource2.Properties) === null || _a === void 0 ? void 0 : _a.LogGroupName) === null || _b === void 0 ? void 0 : _b['Fn::Join']) || '');
|
|
57
|
+
const logGroupNameStr = JSON.stringify(resource2.Properties?.LogGroupName?.['Fn::Join'] || '');
|
|
59
58
|
return logGroupNameStr.includes(key);
|
|
60
59
|
});
|
|
61
60
|
if (!logGroup) {
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCicdConfig = exports.options = void 0;
|
|
7
7
|
const change_case_1 = require("change-case");
|
|
8
|
+
const helpers_1 = require("yargs/helpers");
|
|
8
9
|
const pipelines_1 = require("./pipelines");
|
|
9
10
|
const yargs_1 = __importDefault(require("yargs"));
|
|
10
11
|
exports.options = {
|
|
@@ -60,7 +61,7 @@ exports.options = {
|
|
|
60
61
|
},
|
|
61
62
|
};
|
|
62
63
|
const getCicdConfig = () => {
|
|
63
|
-
const { parsed } = yargs_1.default.config();
|
|
64
|
+
const { parsed } = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).config();
|
|
64
65
|
if (!parsed) {
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
@@ -71,6 +72,7 @@ const getCicdConfig = () => {
|
|
|
71
72
|
acc[key] = value;
|
|
72
73
|
}
|
|
73
74
|
return acc;
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
76
|
}, {});
|
|
75
77
|
return config;
|
|
76
78
|
};
|
|
@@ -52,7 +52,7 @@ const getEcsTaskTags = async ({ ecsTaskArn, }) => {
|
|
|
52
52
|
const { tasks } = await ecs
|
|
53
53
|
.describeTasks({ cluster, include: ['TAGS'], tasks: [ecsTaskArn] })
|
|
54
54
|
.promise();
|
|
55
|
-
const task = tasks
|
|
55
|
+
const task = tasks?.[0];
|
|
56
56
|
if (!task) {
|
|
57
57
|
return undefined;
|
|
58
58
|
}
|
|
@@ -68,7 +68,6 @@ const getJobDetails = async (event) => {
|
|
|
68
68
|
};
|
|
69
69
|
exports.getJobDetails = getJobDetails;
|
|
70
70
|
const pipelinesHandler = async (event) => {
|
|
71
|
-
var _a, _b;
|
|
72
71
|
const jobId = event['CodePipeline.job'].id;
|
|
73
72
|
let pipelineName;
|
|
74
73
|
try {
|
|
@@ -77,7 +76,7 @@ const pipelinesHandler = async (event) => {
|
|
|
77
76
|
const { jobDetails } = await codepipeline
|
|
78
77
|
.getJobDetails({ jobId })
|
|
79
78
|
.promise();
|
|
80
|
-
pipelineName =
|
|
79
|
+
pipelineName = jobDetails?.data?.pipelineContext?.pipelineName;
|
|
81
80
|
const executeTasksInput = (() => {
|
|
82
81
|
const tags = [
|
|
83
82
|
{
|
|
@@ -8,7 +8,6 @@ const FIVE_SECONDS = 5 * 1000;
|
|
|
8
8
|
const getApprovalActionToken = ({ actionName, stageName, pipelineName, }) => new Promise((resolve, reject) => {
|
|
9
9
|
setTimeout(() => {
|
|
10
10
|
codepipeline.getPipelineState({ name: pipelineName }, async (err, { stageStates = [] }) => {
|
|
11
|
-
var _a;
|
|
12
11
|
if (err) {
|
|
13
12
|
return reject(err);
|
|
14
13
|
}
|
|
@@ -16,7 +15,7 @@ const getApprovalActionToken = ({ actionName, stageName, pipelineName, }) => new
|
|
|
16
15
|
if (!approvalStageState) {
|
|
17
16
|
throw new Error('ApprovalStageStateIsUndefined');
|
|
18
17
|
}
|
|
19
|
-
const approvalActionState =
|
|
18
|
+
const approvalActionState = approvalStageState.actionStates?.find((a) => a.actionName === actionName);
|
|
20
19
|
if (!approvalActionState) {
|
|
21
20
|
throw new Error('ApprovalActionStateIsUndefined');
|
|
22
21
|
}
|
|
@@ -132,7 +132,7 @@ const describeStack = async ({ stackName }) => {
|
|
|
132
132
|
exports.describeStack = describeStack;
|
|
133
133
|
const getStackOutput = async ({ stackName, outputKey, }) => {
|
|
134
134
|
const { Outputs = [] } = await (0, exports.describeStack)({ stackName });
|
|
135
|
-
const output = Outputs
|
|
135
|
+
const output = Outputs?.find(({ OutputKey }) => {
|
|
136
136
|
return OutputKey === outputKey;
|
|
137
137
|
});
|
|
138
138
|
if (!output) {
|
|
@@ -31,9 +31,8 @@ const deployCloudFormation = async ({ lambdaDockerfile, lambdaInput, lambdaImage
|
|
|
31
31
|
* Add Parameters passed on CLI to CloudFormation template if they don't exist.
|
|
32
32
|
* Also, automatically add the Type of the parameter.
|
|
33
33
|
*/
|
|
34
|
-
parameters
|
|
35
|
-
|
|
36
|
-
if ((_a = cloudFormationTemplate.Parameters) === null || _a === void 0 ? void 0 : _a[parameter.key]) {
|
|
34
|
+
parameters?.forEach((parameter) => {
|
|
35
|
+
if (cloudFormationTemplate.Parameters?.[parameter.key]) {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
38
|
if (!cloudFormationTemplate.Parameters) {
|
|
@@ -59,14 +58,14 @@ const deployCloudFormation = async ({ lambdaDockerfile, lambdaInput, lambdaImage
|
|
|
59
58
|
.promise();
|
|
60
59
|
const params = {
|
|
61
60
|
StackName: stackName,
|
|
62
|
-
Parameters:
|
|
61
|
+
Parameters: parameters?.map((parameter) => {
|
|
63
62
|
return {
|
|
64
63
|
ParameterKey: parameter.key,
|
|
65
64
|
ParameterValue: parameter.value,
|
|
66
65
|
UsePreviousValue: parameter.usePreviousValue,
|
|
67
66
|
ResolvedValue: parameter.resolvedValue,
|
|
68
67
|
};
|
|
69
|
-
})
|
|
68
|
+
}) || [],
|
|
70
69
|
};
|
|
71
70
|
const deployCloudFormationDeployLambdaCode = async () => {
|
|
72
71
|
const response = await (0, deployLambdaCode_1.deployLambdaCode)({
|
package/dist/deploy/command.js
CHANGED
|
@@ -138,8 +138,9 @@ exports.deployCommand = {
|
|
|
138
138
|
* Set stack name.
|
|
139
139
|
*/
|
|
140
140
|
.middleware(({ stackName }) => {
|
|
141
|
-
if (stackName)
|
|
141
|
+
if (stackName) {
|
|
142
142
|
(0, stackName_1.setPreDefinedStackName)(stackName);
|
|
143
|
+
}
|
|
143
144
|
})
|
|
144
145
|
/**
|
|
145
146
|
* Set lambdaImage if lambdaDockerfile exists.
|
|
@@ -43,7 +43,7 @@ const uploadCodeToECR = async ({ bucket, key, lambdaExternals, lambdaDockerfile,
|
|
|
43
43
|
sourceTypeOverride: 'S3',
|
|
44
44
|
})
|
|
45
45
|
.promise();
|
|
46
|
-
if (!
|
|
46
|
+
if (!build?.id) {
|
|
47
47
|
throw new Error('Cannot start build.');
|
|
48
48
|
}
|
|
49
49
|
await (0, utils_1.waitCodeBuildFinish)({ buildId: build.id, name: 'lambda-builder' });
|
|
@@ -14,7 +14,6 @@ const utils_2 = require("../utils");
|
|
|
14
14
|
const npmlog_1 = __importDefault(require("npmlog"));
|
|
15
15
|
const logPrefix = 'lambda-layer';
|
|
16
16
|
const createLambdaLayerZipFile = async ({ codeBuildProjectName, packageName, }) => {
|
|
17
|
-
var _a, _b;
|
|
18
17
|
npmlog_1.default.info(logPrefix, `Creating zip file for package ${packageName}...`);
|
|
19
18
|
const codeBuild = new aws_sdk_1.CodeBuild();
|
|
20
19
|
const { build } = await codeBuild
|
|
@@ -28,16 +27,16 @@ const createLambdaLayerZipFile = async ({ codeBuildProjectName, packageName, })
|
|
|
28
27
|
projectName: codeBuildProjectName,
|
|
29
28
|
})
|
|
30
29
|
.promise();
|
|
31
|
-
if (!
|
|
30
|
+
if (!build?.id) {
|
|
32
31
|
throw new Error('Cannot start build.');
|
|
33
32
|
}
|
|
34
33
|
const result = await (0, utils_1.waitCodeBuildFinish)({
|
|
35
34
|
buildId: build.id,
|
|
36
35
|
name: packageName,
|
|
37
36
|
});
|
|
38
|
-
if (
|
|
37
|
+
if (result.artifacts?.location) {
|
|
39
38
|
const location = result.artifacts.location.split('/');
|
|
40
|
-
const bucket =
|
|
39
|
+
const bucket = location.shift()?.replace('arn:aws:s3:::', '');
|
|
41
40
|
if (!bucket) {
|
|
42
41
|
throw new Error('Cannot retrieve bucket name.');
|
|
43
42
|
}
|
|
@@ -10,7 +10,7 @@ const getStaticAppBucket = async ({ stackName, }) => {
|
|
|
10
10
|
};
|
|
11
11
|
try {
|
|
12
12
|
const { StackResourceDetail } = await (0, cloudFormation_core_1.describeStackResource)(params);
|
|
13
|
-
return StackResourceDetail
|
|
13
|
+
return StackResourceDetail?.PhysicalResourceId;
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
16
|
return undefined;
|
|
@@ -15,7 +15,7 @@ const invalidateCloudFront = async ({ outputs, }) => {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const cloudFrontDistributionIDOutput = outputs.find((output) => output.OutputKey === CLOUDFRONT_DISTRIBUTION_ID);
|
|
18
|
-
if (cloudFrontDistributionIDOutput
|
|
18
|
+
if (cloudFrontDistributionIDOutput?.OutputValue) {
|
|
19
19
|
const distributionId = cloudFrontDistributionIDOutput.OutputValue;
|
|
20
20
|
const params = {
|
|
21
21
|
DistributionId: distributionId,
|
|
@@ -29,11 +29,13 @@ const removeOldVersions = async ({ bucket }) => {
|
|
|
29
29
|
const { CommonPrefixes = [] } = await s3_1.s3
|
|
30
30
|
.listObjectsV2({ Bucket: bucket, Delimiter: '/' })
|
|
31
31
|
.promise();
|
|
32
|
-
const versions = CommonPrefixes
|
|
33
|
-
return Prefix
|
|
34
|
-
})
|
|
32
|
+
const versions = CommonPrefixes?.map(({ Prefix }) => {
|
|
33
|
+
return Prefix?.replace('/', '');
|
|
34
|
+
})
|
|
35
|
+
.filter((version) => {
|
|
35
36
|
return semver_1.default.valid(version);
|
|
36
|
-
})
|
|
37
|
+
})
|
|
38
|
+
.sort((a, b) => {
|
|
37
39
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
40
|
return semver_1.default.gt(a, b) ? -1 : 1;
|
|
39
41
|
});
|
package/dist/deploy/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ const stackName_1 = require("./stackName");
|
|
|
8
8
|
const npmlog_1 = __importDefault(require("npmlog"));
|
|
9
9
|
const deployErrorLogs = ({ error, logPrefix, }) => {
|
|
10
10
|
npmlog_1.default.error(logPrefix, `An error occurred. Cannot deploy ${logPrefix}.`);
|
|
11
|
-
npmlog_1.default.error(logPrefix, 'Error message: %j', error
|
|
11
|
+
npmlog_1.default.error(logPrefix, 'Error message: %j', error?.message);
|
|
12
12
|
};
|
|
13
13
|
exports.deployErrorLogs = deployErrorLogs;
|
|
14
14
|
const handleDeployError = ({ error, logPrefix, }) => {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateEnvCommand = void 0;
|
|
4
4
|
const generateEnv_1 = require("./generateEnv");
|
|
5
5
|
exports.generateEnvCommand = {
|
|
6
|
-
command: 'generate-env',
|
|
6
|
+
command: ['generate-env', 'ge', 'env'],
|
|
7
7
|
describe: 'Generate environment files.',
|
|
8
8
|
handler: generateEnv_1.generateEnv,
|
|
9
9
|
};
|
package/dist/utils/codeBuild.js
CHANGED
|
@@ -20,8 +20,8 @@ const waitCodeBuildFinish = async ({ buildId, name, }) => {
|
|
|
20
20
|
.promise();
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
setTimeout(() => {
|
|
23
|
-
const executedBuild = builds
|
|
24
|
-
npmlog_1.default.info(logPrefix, `Build status of ${name || buildId}: ${executedBuild
|
|
23
|
+
const executedBuild = builds?.find(({ id }) => id === buildId);
|
|
24
|
+
npmlog_1.default.info(logPrefix, `Build status of ${name || buildId}: ${executedBuild?.buildStatus}`);
|
|
25
25
|
if (executedBuild && executedBuild.currentPhase === 'COMPLETED') {
|
|
26
26
|
if (executedBuild.buildStatus === 'SUCCEEDED') {
|
|
27
27
|
resolve(executedBuild);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carlin",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"author": "Pedro Arantes <arantespp@gmail.com> (https://twitter.com/arantespp)",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"dist/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
25
|
+
"@aws-sdk/client-cloudformation": "^3.460.0",
|
|
26
26
|
"@octokit/webhooks": "^12.0.8",
|
|
27
27
|
"@slack/webhook": "^7.0.1",
|
|
28
28
|
"adm-zip": "^0.5.10",
|
|
29
|
-
"aws-sdk": "^2.
|
|
29
|
+
"aws-sdk": "^2.1505.0",
|
|
30
30
|
"builtin-modules": "^3.3.0",
|
|
31
31
|
"change-case": "^4.1.2",
|
|
32
32
|
"deep-equal": "^2.2.3",
|
|
33
33
|
"deepmerge": "^4.3.1",
|
|
34
34
|
"dotenv": "^16.3.1",
|
|
35
|
-
"esbuild": "^0.19.
|
|
35
|
+
"esbuild": "^0.19.8",
|
|
36
36
|
"findup-sync": "^5.0.0",
|
|
37
37
|
"glob": "^10.3.10",
|
|
38
38
|
"js-yaml": "^4.1.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"uglify-js": "^3.17.4",
|
|
46
46
|
"vercel": "^32.5.6",
|
|
47
47
|
"yargs": "^17.7.2",
|
|
48
|
-
"@ttoss/cloudformation": "^0.8.
|
|
48
|
+
"@ttoss/cloudformation": "^0.8.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/adm-zip": "^0.5.5",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"@types/jest": "^29.5.10",
|
|
57
57
|
"@types/js-yaml": "^4.0.9",
|
|
58
58
|
"@types/mime-types": "^2.1.4",
|
|
59
|
-
"@types/node": "^20.
|
|
60
|
-
"@types/npmlog": "^
|
|
59
|
+
"@types/node": "^20.10.0",
|
|
60
|
+
"@types/npmlog": "^7.0.0",
|
|
61
61
|
"@types/semver": "^7.5.6",
|
|
62
62
|
"@types/uglify-js": "^3.17.4",
|
|
63
63
|
"@types/yargs": "^17.0.32",
|
|
64
64
|
"jest": "^29.7.0",
|
|
65
65
|
"typescript": "~5.2.2",
|
|
66
|
-
"@ttoss/test-utils": "^2.0.
|
|
66
|
+
"@ttoss/test-utils": "^2.0.2"
|
|
67
67
|
},
|
|
68
68
|
"keywords": [],
|
|
69
69
|
"publishConfig": {
|