Skip to content

Commit 50a7808

Browse files
committed
Merge remote-tracking branch 'origin/master' into v3
2 parents d819852 + c17d97e commit 50a7808

File tree

10 files changed

+48
-13
lines changed

10 files changed

+48
-13
lines changed

app-config-cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"yargs": "16"
5454
},
5555
"devDependencies": {
56+
"@app-config/test-utils": "^3.0.0-alpha.4",
5657
"@types/common-tags": "1",
5758
"@types/fs-extra": "9"
5859
},

app-config-cli/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
{ "path": "../app-config-core" },
1111
{ "path": "../app-config-config" },
1212
{ "path": "../app-config-node" },
13-
{ "path": "../app-config-generate" }
13+
{ "path": "../app-config-generate" },
14+
{ "path": "../app-config-utils" },
15+
{ "path": "../app-config-test-utils" }
1416
]
1517
}

app-config-encryption/src/encryption.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,17 @@ export async function loadKey(contents: string | Buffer): Promise<Key> {
140140
return keys[0];
141141
}
142142

143-
export async function loadPrivateKey(
144-
override: string | Buffer | undefined = process.env.APP_CONFIG_SECRETS_KEY,
145-
): Promise<Key> {
143+
export async function loadPrivateKey(override?: string | Buffer): Promise<Key> {
144+
if (override === undefined) {
145+
if (process.env.APP_CONFIG_SECRETS_KEY) {
146+
// eslint-disable-next-line no-param-reassign
147+
override = process.env.APP_CONFIG_SECRETS_KEY;
148+
} else if (process.env.APP_CONFIG_SECRETS_KEY_FILE) {
149+
// eslint-disable-next-line no-param-reassign
150+
override = (await fs.readFile(process.env.APP_CONFIG_SECRETS_KEY_FILE)).toString();
151+
}
152+
}
153+
146154
let key: Key;
147155

148156
if (override) {
@@ -176,9 +184,17 @@ export async function loadPrivateKey(
176184
return key;
177185
}
178186

179-
export async function loadPublicKey(
180-
override: string | Buffer | undefined = process.env.APP_CONFIG_SECRETS_PUBLIC_KEY,
181-
): Promise<Key> {
187+
export async function loadPublicKey(override?: string | Buffer): Promise<Key> {
188+
if (override === undefined) {
189+
if (process.env.APP_CONFIG_SECRETS_PUBLIC_KEY) {
190+
// eslint-disable-next-line no-param-reassign
191+
override = process.env.APP_CONFIG_SECRETS_PUBLIC_KEY;
192+
} else if (process.env.APP_CONFIG_SECRETS_PUBLIC_KEY_FILE) {
193+
// eslint-disable-next-line no-param-reassign
194+
override = (await fs.readFile(process.env.APP_CONFIG_SECRETS_PUBLIC_KEY_FILE)).toString();
195+
}
196+
}
197+
182198
let key: Key;
183199

184200
if (override) {

app-config-exec/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"@app-config/utils": "^3.0.0-alpha.4"
3737
},
3838
"devDependencies": {
39-
"@app-config/main": "^3.0.0-alpha.4"
39+
"@app-config/main": "^3.0.0-alpha.4",
40+
"@app-config/test-utils": "^3.0.0-alpha.4"
4041
},
4142
"prettier": "@lcdev/prettier",
4243
"jest": {

app-config-exec/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{ "path": "../app-config-utils" },
1313
{ "path": "../app-config-core" },
1414
{ "path": "../app-config-node" },
15-
{ "path": "../app-config-extension-utils" }
15+
{ "path": "../app-config-extension-utils" },
16+
{ "path": "../app-config-test-utils" }
1617
]
1718
}

app-config-extensions/src/extends-directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function fileReferenceDirective(keyName: string, meta: ParsedValueMetadata): Par
3333

3434
return SchemaBuilder.oneOf(reference, SchemaBuilder.arraySchema(reference));
3535
},
36-
(value, _, __, context) => async (_, __, source, extensions) => {
36+
(value, _, __, context) => async (_, ___, source, extensions) => {
3737
const retrieveFile = async (
3838
filepath: string,
3939
subselector?: string,

app-config-main/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
"@app-config/utils": "^3.0.0-alpha.4",
4848
"ajv": "8"
4949
},
50-
"devDependencies": {},
50+
"devDependencies": {
51+
"@app-config/test-utils": "^3.0.0-alpha.4"
52+
},
5153
"prettier": "@lcdev/prettier",
5254
"jest": {
5355
"preset": "@lcdev/jest",

app-config-main/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
{ "path": "../app-config-test-utils" },
1212
{ "path": "../app-config-core" },
1313
{ "path": "../app-config-node" },
14-
{ "path": "../app-config-cli" }
14+
{ "path": "../app-config-cli" },
15+
{ "path": "../app-config-utils" },
16+
{ "path": "../app-config-test-utils" }
1517
]
1618
}

app-config-test-utils/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ export async function withTempFiles(
3434
await callback((filename) => join(folder, filename), folder);
3535
} finally {
3636
await remove(folder).catch((error) => {
37+
// eslint-disable-next-line no-console
3738
console.warn(error);
3839

3940
// we'll just ignore this, it's spurious in CI
40-
if (isWindows && error.code !== 'EBUSY') {
41+
if (
42+
isWindows &&
43+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
44+
error.code !== 'EBUSY'
45+
) {
4146
throw error;
4247
}
4348
});

docs/guide/intro/encryption.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ This key (public + private) can be added as protected environment variables in y
105105
- `APP_CONFIG_SECRETS_KEY`
106106
- `APP_CONFIG_SECRETS_PUBLIC_KEY`
107107

108+
Or, in files referenced by:
109+
110+
- `APP_CONFIG_SECRETS_KEY_FILE`
111+
- `APP_CONFIG_SECRETS_PUBLIC_KEY_FILE`
112+
108113
The CLI will output both of these with instructions.
109114

110115
## Implementation Details

0 commit comments

Comments
 (0)