carlin 1.48.4 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -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,14 @@ 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 content = deployOutputLines.length > 0 ? `${envFile}
|
|
5223
|
+
${deployOutputLines.join("\n")}
|
|
5224
|
+
` : envFile;
|
|
5192
5225
|
await writeEnvFile({
|
|
5193
|
-
content
|
|
5226
|
+
content,
|
|
5194
5227
|
envFileName: ".env"
|
|
5195
5228
|
});
|
|
5196
5229
|
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.0",
|
|
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",
|