@catladder/pipeline 2.10.0 → 2.10.2
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/bash/bashEscape.d.ts +4 -1
- package/dist/bash/bashEscape.js +7 -2
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/override-secrets.test.ts.snap +1407 -0
- package/examples/override-secrets.test.ts +11 -0
- package/examples/override-secrets.ts +40 -0
- package/package.json +1 -1
- package/src/bash/bashEscape.ts +7 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createYamlLocalPipeline } from "./__utils__/helpers";
|
|
2
|
+
import config from "./override-secrets";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
it("matches snapshot for override-secrets local pipeline YAML", async () => {
|
|
10
|
+
expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
|
|
11
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
["my-app"]: {
|
|
8
|
+
dir: "app",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
vars: {
|
|
13
|
+
secret: ["MY_SECRET"],
|
|
14
|
+
},
|
|
15
|
+
deploy: {
|
|
16
|
+
type: "google-cloudrun",
|
|
17
|
+
projectId: "my-project-id",
|
|
18
|
+
region: "europe-west6",
|
|
19
|
+
},
|
|
20
|
+
env: {
|
|
21
|
+
local: {
|
|
22
|
+
vars: {
|
|
23
|
+
secret: ["MY_LOCAL_SECRET"],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
review: {
|
|
27
|
+
vars: {
|
|
28
|
+
secret: ["MY_REVIEW_SECRET"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default config;
|
|
37
|
+
|
|
38
|
+
export const information = {
|
|
39
|
+
title: "Multiline Environment Variables",
|
|
40
|
+
};
|
package/package.json
CHANGED
package/src/bash/bashEscape.ts
CHANGED
|
@@ -57,6 +57,9 @@ export const escapeDoubleQuotes = (value: string | null | undefined) =>
|
|
|
57
57
|
export const escapeSingleQuotes = (value: string | null | undefined) =>
|
|
58
58
|
value?.toString().replace(/'/g, "\\'");
|
|
59
59
|
|
|
60
|
+
export type EscapeForDotEnvOptions = {
|
|
61
|
+
quoteMode: "auto" | "always";
|
|
62
|
+
};
|
|
60
63
|
/**
|
|
61
64
|
*
|
|
62
65
|
* escape env vars for .env files.
|
|
@@ -75,6 +78,9 @@ export const escapeSingleQuotes = (value: string | null | undefined) =>
|
|
|
75
78
|
*/
|
|
76
79
|
export const escapeForDotEnv = (
|
|
77
80
|
value: VariableValue | undefined | null,
|
|
81
|
+
options: EscapeForDotEnvOptions = {
|
|
82
|
+
quoteMode: "auto",
|
|
83
|
+
},
|
|
78
84
|
): string => {
|
|
79
85
|
if (value === undefined || value === null) {
|
|
80
86
|
return "";
|
|
@@ -82,7 +88,7 @@ export const escapeForDotEnv = (
|
|
|
82
88
|
if (typeof value === "string") {
|
|
83
89
|
// if string contains newlines, we need to wrap it in quotes
|
|
84
90
|
// we additionaly escape newlines, that give best compatibility
|
|
85
|
-
if (value.includes("\n")) {
|
|
91
|
+
if (options.quoteMode === "always" || value.includes("\n")) {
|
|
86
92
|
const newlinesReplaces = value.replace(/\n/g, "\\n");
|
|
87
93
|
|
|
88
94
|
// default to ", but if this is not possible, we try to use ' or `
|