@stacksjs/storage 0.49.3 → 0.51.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.
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ export declare function deleteFiles(dir: string, exclude?: string[]): void;
36
36
  export declare function deleteEmptyFolders(dir: string): void;
37
37
  export declare function doesFolderExist(path: string): any;
38
38
  export declare function createFolder(dir: string): Promise<void>;
39
+ export declare function updateConfigFile(filePath: string, newConfig: Array<string>): Promise<void>;
39
40
  export declare const filesystem: {
40
41
  _dirname: any;
41
42
  readJsonFile: typeof readJsonFile;
@@ -52,6 +53,7 @@ export declare const filesystem: {
52
53
  deleteFiles: typeof deleteFiles;
53
54
  deleteEmptyFolders: typeof deleteEmptyFolders;
54
55
  doesFolderExist: typeof doesFolderExist;
56
+ updateConfigFile: typeof updateConfigFile;
55
57
  fs: any;
56
58
  };
57
59
  export default filesystem;
package/dist/index.mjs CHANGED
@@ -126,6 +126,16 @@ export function createFolder(dir) {
126
126
  });
127
127
  });
128
128
  }
129
+ export function updateConfigFile(filePath, newConfig) {
130
+ return new Promise((resolve, reject) => {
131
+ let config = JSON.parse(fs.readFileSync(filePath, "utf8"));
132
+ for (const key in newConfig) {
133
+ config[key] = newConfig[key];
134
+ }
135
+ fs.writeFileSync(filePath, JSON.stringify(config, null, 2));
136
+ return config;
137
+ });
138
+ }
129
139
  export const filesystem = {
130
140
  _dirname,
131
141
  readJsonFile,
@@ -142,6 +152,7 @@ export const filesystem = {
142
152
  deleteFiles,
143
153
  deleteEmptyFolders,
144
154
  doesFolderExist,
155
+ updateConfigFile,
145
156
  fs
146
157
  // potentially refactor to `...fs` but, currently, there is an issues when building @stacksjs/config
147
158
  // the problem is relating to https://github.com/microsoft/TypeScript/issues/5711#issuecomment-157793294
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@stacksjs/storage",
3
3
  "type": "module",
4
- "version": "0.49.3",
5
- "packageManager": "pnpm@7.25.1",
4
+ "version": "0.51.0",
5
+ "packageManager": "pnpm@7.26.3",
6
6
  "description": "The Stacks file system.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -37,21 +37,21 @@
37
37
  "README.md"
38
38
  ],
39
39
  "engines": {
40
- "node": ">=v18.13.0",
41
- "pnpm": ">=7.25.1"
40
+ "node": ">=v18.14.0",
41
+ "pnpm": ">=7.26.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "fs-extra": "^11.1.0",
45
45
  "unstorage": "^1.0.1",
46
- "@stacksjs/arrays": "0.49.3",
47
- "@stacksjs/types": "0.49.3",
48
- "@stacksjs/utils": "0.49.3"
46
+ "@stacksjs/arrays": "0.51.0",
47
+ "@stacksjs/types": "0.51.0",
48
+ "@stacksjs/utils": "0.51.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "mkdist": "^1.1.0",
52
- "typescript": "^4.9.4",
53
- "@stacksjs/path": "0.49.3",
54
- "@stacksjs/testing": "0.49.3"
52
+ "typescript": "^4.9.5",
53
+ "@stacksjs/path": "0.51.0",
54
+ "@stacksjs/testing": "0.51.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "mkdist -d",