carlin 1.48.4 → 1.49.1
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/index.js +46 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5178,7 +5178,34 @@ var readEnvFile = /* @__PURE__ */ __name(async ({ envFileName, envsPath }) => {
|
|
|
5178
5178
|
var writeEnvFile = /* @__PURE__ */ __name(async ({ envFileName, content }) => {
|
|
5179
5179
|
return fs3.promises.writeFile(path.resolve(process.cwd(), envFileName), content);
|
|
5180
5180
|
}, "writeEnvFile");
|
|
5181
|
-
var
|
|
5181
|
+
var readDeployOutputLines = /* @__PURE__ */ __name(async ({ envFromDeployOutputs }) => {
|
|
5182
|
+
const lines = [];
|
|
5183
|
+
for (const { dir, variables } of envFromDeployOutputs) {
|
|
5184
|
+
const latestDeployPath = path.resolve(process.cwd(), dir, ".carlin", LATEST_DEPLOY_OUTPUTS_FILENAME);
|
|
5185
|
+
let latestDeploy;
|
|
5186
|
+
try {
|
|
5187
|
+
const raw = await fs3.promises.readFile(latestDeployPath, "utf8");
|
|
5188
|
+
latestDeploy = JSON.parse(raw);
|
|
5189
|
+
} catch {
|
|
5190
|
+
log5.warn(logPrefix23, "Could not read latest-deploy.json from %s. Skipping.", latestDeployPath);
|
|
5191
|
+
continue;
|
|
5192
|
+
}
|
|
5193
|
+
const outputs = latestDeploy.outputs ?? {};
|
|
5194
|
+
for (const [envVarName, outputPath] of Object.entries(variables)) {
|
|
5195
|
+
const dotIndex = outputPath.indexOf(".");
|
|
5196
|
+
const outputKey = dotIndex === -1 ? outputPath : outputPath.slice(0, dotIndex);
|
|
5197
|
+
const field = dotIndex === -1 ? "OutputValue" : outputPath.slice(dotIndex + 1);
|
|
5198
|
+
const outputValue = outputs[outputKey]?.[field];
|
|
5199
|
+
if (outputValue === void 0) {
|
|
5200
|
+
log5.warn(logPrefix23, 'Output path "%s" not found in %s. Skipping %s.', outputPath, latestDeployPath, envVarName);
|
|
5201
|
+
continue;
|
|
5202
|
+
}
|
|
5203
|
+
lines.push(`${envVarName}=${outputValue}`);
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
return lines;
|
|
5207
|
+
}, "readDeployOutputLines");
|
|
5208
|
+
var generateEnv = /* @__PURE__ */ __name(async ({ defaultEnvironment, envFromDeployOutputs, path: envsPath }) => {
|
|
5182
5209
|
const environment = getEnvironment() || defaultEnvironment;
|
|
5183
5210
|
const envFileName = `.env.${environment}`;
|
|
5184
5211
|
const envFile = await readEnvFile({
|
|
@@ -5189,8 +5216,25 @@ var generateEnv = /* @__PURE__ */ __name(async ({ defaultEnvironment, path: envs
|
|
|
5189
5216
|
log5.info(logPrefix23, "Env file %s doesn't exist. Skip generating env file.", envFileName);
|
|
5190
5217
|
return;
|
|
5191
5218
|
}
|
|
5219
|
+
const deployOutputLines = envFromDeployOutputs && envFromDeployOutputs.length > 0 ? await readDeployOutputLines({
|
|
5220
|
+
envFromDeployOutputs
|
|
5221
|
+
}) : [];
|
|
5222
|
+
const deployOutputKeys = new Set(deployOutputLines.map((line) => {
|
|
5223
|
+
return line.split("=")[0];
|
|
5224
|
+
}));
|
|
5225
|
+
const filteredEnvFile = envFile.split("\n").filter((line) => {
|
|
5226
|
+
const trimmed = line.trim();
|
|
5227
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
5228
|
+
return true;
|
|
5229
|
+
}
|
|
5230
|
+
const key = trimmed.split("=")[0].trim();
|
|
5231
|
+
return !deployOutputKeys.has(key);
|
|
5232
|
+
}).join("\n");
|
|
5233
|
+
const content = deployOutputLines.length > 0 ? `${filteredEnvFile}
|
|
5234
|
+
${deployOutputLines.join("\n")}
|
|
5235
|
+
` : envFile;
|
|
5192
5236
|
await writeEnvFile({
|
|
5193
|
-
content
|
|
5237
|
+
content,
|
|
5194
5238
|
envFileName: ".env"
|
|
5195
5239
|
});
|
|
5196
5240
|
log5.info(logPrefix23, "Generate env file %s from %s successfully.", ".env", envFileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carlin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pedro Arantes <arantespp@gmail.com> (https://twitter.com/arantespp)",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"vercel": "^39.1.1",
|
|
49
49
|
"yargs": "^17.7.2",
|
|
50
50
|
"@ttoss/cloudformation": "^0.12.10",
|
|
51
|
-
"@ttoss/
|
|
52
|
-
"@ttoss/config": "^
|
|
51
|
+
"@ttoss/config": "^1.37.8",
|
|
52
|
+
"@ttoss/read-config-file": "^2.2.8"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/adm-zip": "^0.5.6",
|