@catladder/pipeline 1.170.0 → 1.170.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.
@@ -0,0 +1,11 @@
1
+ import { createYamlLocalPipeline } from "./__utils__/helpers";
2
+ import config from "./referencing-other-vars";
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 referencing-other-vars local pipeline YAML", async () => {
10
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
11
+ });
@@ -0,0 +1,83 @@
1
+ import type { Config } from "../src";
2
+
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ app1: {
8
+ dir: "app1",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ vars: {
13
+ secret: ["SECRET1"],
14
+ public: {
15
+ foo: "foo-value",
16
+ bar: "bar-value",
17
+ foo3: "from app3: ${app3:foo3}",
18
+ circle:
19
+ 'this is from app3 that has reference to app1: "${app3:transitive}"', // not officially recommended, but may work in some cases
20
+ },
21
+ },
22
+ deploy: {
23
+ type: "google-cloudrun",
24
+ projectId: "asdf",
25
+ region: "asia-east1",
26
+ },
27
+ },
28
+ app2: {
29
+ dir: "app2",
30
+ build: {
31
+ type: "node",
32
+ },
33
+ vars: {
34
+ secret: ["SECRET2"],
35
+ public: {
36
+ foo2: "foo-value-2",
37
+ referencingSecret: "secret1: ${app1:SECRET1}, secret2: ${SECRET2}",
38
+ foo1: "this is from app1: ${app1:foo}",
39
+ selfReference: "this is from self: ${foo2}",
40
+ selfReference2: "this is from self: ${foo1}",
41
+ app1Api: "${app1:ROOT_URL}/graphql",
42
+ },
43
+ },
44
+ deploy: {
45
+ type: "google-cloudrun",
46
+ projectId: "asdf",
47
+ region: "asia-east1",
48
+ },
49
+ },
50
+ app3: {
51
+ dir: "kube",
52
+ build: {
53
+ type: "node",
54
+ },
55
+ vars: {
56
+ public: {
57
+ foo3: "foo-value-3",
58
+ foo2: "this is from app2: ${app2:foo2}",
59
+ transitive: "this is from app2: ${app2:foo1}",
60
+ transitiveWithSecret: "this is from app2: ${app2:referencingSecret}",
61
+ someJson:
62
+ '[{"name": "app1", "url": "${app1:ROOT_URL}"}, {"name": "app2", "url": "${app2:ROOT_URL}"}, {"name": "app3", "url": "${ROOT_URL}"}]',
63
+ },
64
+ },
65
+ deploy: {
66
+ type: "kubernetes",
67
+ cluster: {
68
+ name: "some-cluster-name",
69
+ region: "europe-west6",
70
+ projectId: "some-project-id",
71
+ type: "gcloud",
72
+ domainCanonical: "panter.cloud",
73
+ },
74
+ },
75
+ },
76
+ },
77
+ };
78
+
79
+ export default config;
80
+
81
+ export const information = {
82
+ title: "Multiline Environment Variables",
83
+ };
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "1.170.0",
56
+ "version": "1.170.1",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -12,6 +12,16 @@ export class BashExpression {
12
12
  return this.value.toString();
13
13
  }
14
14
 
15
+ public replace(
16
+ searchValue: any,
17
+
18
+ replacer: (substring: string, ...args: any[]) => string,
19
+ ) {
20
+ return new BashExpression(
21
+ this.value.toString().replace(searchValue, replacer),
22
+ );
23
+ }
24
+
15
25
  /**
16
26
  *
17
27
  * @returns a bash expression to lowercase the string
@@ -12,16 +12,13 @@ export default async function replaceAsync(
12
12
  ) {
13
13
  const wasBashExpression = string instanceof BashExpression;
14
14
 
15
- const stringRepresentation = wasBashExpression
16
- ? string.toString()
17
- : bashEscape(string);
18
15
  try {
19
16
  // 1. Run fake pass of `replace`, collect values from `replacer` calls
20
17
  // 2. Resolve them with `Promise.all`
21
18
  // 3. Run `replace` with resolved values
22
19
  const values: Array<Promise<string | BashExpression>> = [];
23
20
  String.prototype.replace.call(
24
- stringRepresentation,
21
+ string instanceof BashExpression ? string : bashEscape(string),
25
22
  searchValue,
26
23
  function (...args) {
27
24
  // eslint-disable-next-line prefer-spread
@@ -35,14 +32,12 @@ export default async function replaceAsync(
35
32
  const containsBashExpression = resolvedValues.some(
36
33
  (value) => value instanceof BashExpression,
37
34
  );
35
+ const result = (
36
+ string instanceof BashExpression ? string : bashEscape(string)
37
+ ).replace(searchValue, function () {
38
+ return resolvedValues.shift()?.toString() ?? "";
39
+ });
38
40
 
39
- const result = String.prototype.replace.call(
40
- stringRepresentation,
41
- searchValue,
42
- function () {
43
- return resolvedValues.shift()?.toString() ?? "";
44
- },
45
- );
46
41
  if (wasBashExpression || containsBashExpression) {
47
42
  return new BashExpression(result);
48
43
  } else {