Skip to content

Commit 1e6fa02

Browse files
authored
Merge pull request #1 from corneliouzbett/OZ-338
OZ-338: Substitute client UUID at deployment time.
2 parents 945d61e + ae0a107 commit 1e6fa02

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
demo/
22
example/
3+
.idea

cmd.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ const processDirs = (dirPath) => {
1616
processDirs(itemAbsPath);
1717
} else {
1818
if (allowedExtensions.includes(path.extname(itemAbsPath))) {
19-
fileEnvsubst(itemAbsPath);
19+
fileEnvSubstitution(itemAbsPath);
2020
}
2121
}
2222
});
2323
};
2424

25-
const fileEnvsubst = (itemAbsPath) => {
25+
const fileEnvSubstitution = (itemAbsPath) => {
2626
let hydratedTemplate = fs.readFileSync(itemAbsPath, 'utf8');
2727

2828
Object.entries(process.env).forEach(([name, value]) => {
2929
if (typeof value !== 'string') {
30-
// stringifying strings adds surrounding dquotes; we don't want that
30+
// stringify strings adds surrounding quotes; we don't want that
3131
value = JSON.stringify(value)
3232
}
3333

@@ -41,17 +41,21 @@ const fileEnvsubst = (itemAbsPath) => {
4141
fs.writeFileSync(itemAbsPath, hydratedTemplate);
4242
};
4343

44-
const generateClientSecrets = (clients) => {
44+
const generateClientUuidAndSecrets = (clients) => {
4545
for (let client of clients) {
4646

4747
const key = `${client.toUpperCase()}_CLIENT_SECRET`;
4848
if(!(key in process.env)){
4949
process.env[key] = randomUUID();
5050
}
51-
51+
52+
const clientUuidKey = `${client.toUpperCase()}_CLIENT_UUID`;
53+
if(!(clientUuidKey in process.env)){
54+
process.env[clientUuidKey] = randomUUID();
55+
}
5256
}
5357
}
5458

55-
generateClientSecrets(clients)
59+
generateClientUuidAndSecrets(clients);
5660

57-
processDirs(process.env.FILE_PATH);
61+
processDirs(process.env.FILE_PATH);

0 commit comments

Comments
 (0)