updating-secrets 0.1.0 → 0.2.0

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.
@@ -19,6 +19,10 @@ export type SecretsJsonFileAdapterOptions<Secrets extends SecretDefinitions = an
19
19
  readFile: (filePath: string) => Promise<string | Buffer>;
20
20
  /** `writeFile` from `'node:fs/promises'` */
21
21
  writeFile: (filePath: string, contents: string | Buffer) => Promise<void>;
22
+ /** `mkdir` from `'node:fs/promises'` */
23
+ mkdir: (filePath: string, options?: {
24
+ recursive: boolean;
25
+ }) => Promise<void | string>;
22
26
  };
23
27
  /** `existsSync` from `'node:fs'` */
24
28
  existsSync: (filePath: string) => boolean;
@@ -1,6 +1,7 @@
1
1
  import { mergeDefinedProperties, parseWithJson5, } from '@augment-vir/common';
2
2
  import { existsSync as existsSyncImport } from 'node:fs';
3
- import { readFile as readFileImport, writeFile as writeFileImport } from 'node:fs/promises';
3
+ import { mkdir as mkDirImport, readFile as readFileImport, writeFile as writeFileImport, } from 'node:fs/promises';
4
+ import { dirname } from 'node:path';
4
5
  import { BaseSecretsAdapter } from './base.adapter.js';
5
6
  const defaultSecretsJsonFileAdapterOptions = {
6
7
  fsOverride: {
@@ -8,6 +9,7 @@ const defaultSecretsJsonFileAdapterOptions = {
8
9
  promises: {
9
10
  readFile: readFileImport,
10
11
  writeFile: writeFileImport,
12
+ mkdir: mkDirImport,
11
13
  },
12
14
  },
13
15
  generateValues: undefined,
@@ -37,6 +39,9 @@ export class SecretsJsonFileAdapter extends BaseSecretsAdapter {
37
39
  if (!this.options.fsOverride.existsSync(this.jsonFilePath)) {
38
40
  if (this.options.generateValues) {
39
41
  const newSecrets = await this.options.generateValues();
42
+ await this.options.fsOverride.promises.mkdir(dirname(this.jsonFilePath), {
43
+ recursive: true,
44
+ });
40
45
  await this.options.fsOverride.promises.writeFile(this.jsonFilePath, JSON.stringify(newSecrets));
41
46
  }
42
47
  else {
@@ -8,6 +8,9 @@ export function createMockFs(mockFiles, writeFileMockCallback) {
8
8
  const writtenFiles = {};
9
9
  return {
10
10
  promises: {
11
+ mkdir() {
12
+ return Promise.resolve();
13
+ },
11
14
  readFile(filePath) {
12
15
  if ('contents' in mockFiles) {
13
16
  return Promise.resolve(mockFiles.contents);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "updating-secrets",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Automatically update secrets on an interval with support for seamless secret rotation.",
5
5
  "keywords": [
6
6
  "secrets",