Skip to content

Commit 85b10ce

Browse files
authored
feat: adds file system-supported version and updates appropriate exports (#4)
Adds the `secrets-file` module to support places where the file system is supported and updates default export and `no-fs` export to support both environments. Additionally, makes formatting changes to tests files and adds appropriate Vitest mocks to mock the file system using `memfs`.
1 parent fd50268 commit 85b10ce

File tree

15 files changed

+505
-109
lines changed

15 files changed

+505
-109
lines changed

.secrets/.secrets.enc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file was auto-generated by @jacobwolf/gitops-secrets
2+
const CIPHER_TEXT = undefined;
3+
module.exports = { CIPHER_TEXT };

__mocks__/.secrets.enc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
loadSecrets: () => ({ key: 'loaded-value' }),
3+
};

__mocks__/fs.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { fs } = require('memfs');
2+
module.exports = { ...fs, default: fs };

__mocks__/fs/promises.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { fs } = require('memfs');
2+
module.exports = fs.promises;

__mocks__/secrets.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
encrypt: vi.fn().mockResolvedValue('encrypted-content'),
3+
decrypt: vi.fn().mockResolvedValue('{"key":"decrypted-value"}'),
4+
mergeSecrets: vi.fn(),
5+
};

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"files": {
1010
"ignoreUnknown": false,
11-
"include": ["src/**/*"]
11+
"include": ["src/**/*", "tests/**/*", "__mocks__/**/*"]
1212
},
1313
"formatter": {
1414
"enabled": true,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@types/node": "^22.13.11",
3838
"husky": "^9.1.7",
3939
"lint-staged": "^15.5.0",
40+
"memfs": "^4.17.0",
4041
"msw": "^2.7.3",
4142
"tsup": "^8.4.0",
4243
"typescript": "^5.8.2",

pnpm-lock.yaml

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
async function main() {
2-
console.log('Hello, world!');
3-
}
1+
import * as doppler from './providers/doppler';
2+
import * as secrets from './secrets';
3+
import * as secretsFiles from './secrets-files';
44

5-
main();
5+
export const providers = { doppler };
6+
7+
export default {
8+
...secrets,
9+
...secretsFiles,
10+
providers,
11+
};

src/no-fs.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as doppler from './providers/doppler';
2+
import * as secrets from './secrets';
3+
4+
const noFs = {
5+
...secrets,
6+
providers: {
7+
doppler,
8+
},
9+
};
10+
11+
export default noFs;
12+
13+
export * from './secrets';
14+
export const providers = { doppler };

0 commit comments

Comments
 (0)