@stacksjs/storage 0.59.3 → 0.59.5

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/files.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { JsonFile, PackageJson, TextFile } from '@stacksjs/types';
1
+ import type { JsonFile, TextFile } from '@stacksjs/types';
2
2
  /**
3
3
  * Reads a JSON file and returns the parsed data.
4
4
  */
package/dist/fs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import * as fs from 'fs-extra';
2
- import { pathExists as existsSync, mkdirSync, writeFileSync } from 'fs-extra';
2
+ import { pathExists as existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra';
3
3
  export declare function exists(path: string): Promise<boolean>;
4
- export { fs, existsSync, mkdirSync, writeFileSync };
4
+ export { fs, existsSync, mkdirSync, writeFileSync, readFileSync };
package/dist/index.js CHANGED
@@ -17,9 +17,9 @@ import {contains} from "@stacksjs/arrays";
17
17
 
18
18
  // src/fs.ts
19
19
  import * as fs from "fs-extra";
20
- import {pathExists as existsSync, mkdirSync, writeFileSync} from "fs-extra";
20
+ import {pathExists as existsSync2, mkdirSync, readFileSync, writeFileSync} from "fs-extra";
21
21
  async function exists(path) {
22
- return await existsSync(path);
22
+ return await existsSync2(path);
23
23
  }
24
24
 
25
25
  // src/files.ts
@@ -37,7 +37,7 @@ async function readPackageJson(name, cwd) {
37
37
  async function writeFile(path2, data) {
38
38
  if (typeof path2 === "string") {
39
39
  const dirPath = dirname(path2);
40
- if (!await existsSync(dirPath))
40
+ if (!await existsSync2(dirPath))
41
41
  await createFolder(dirPath);
42
42
  return await Bun.write(Bun.file(path2), data);
43
43
  }
@@ -188,6 +188,10 @@ var folders = {
188
188
  import {createHash} from "crypto";
189
189
  import {path as p2} from "@stacksjs/path";
190
190
  function hashFileOrDirectory(path4, hash) {
191
+ if (!existsSync(path4)) {
192
+ console.error(`Path does not exist: ${path4}`);
193
+ return;
194
+ }
191
195
  if (fs.statSync(path4).isDirectory()) {
192
196
  const files2 = fs.readdirSync(path4);
193
197
  for (const file of files2) {
@@ -482,6 +486,11 @@ __export(exports_storage, {
482
486
  return readJsonFile;
483
487
  }
484
488
  },
489
+ readFileSync: () => {
490
+ {
491
+ return readFileSync;
492
+ }
493
+ },
485
494
  put: () => {
486
495
  {
487
496
  return put;
@@ -589,7 +598,7 @@ __export(exports_storage, {
589
598
  },
590
599
  existsSync: () => {
591
600
  {
592
- return existsSync;
601
+ return existsSync2;
593
602
  }
594
603
  },
595
604
  exists: () => {
@@ -766,6 +775,7 @@ export {
766
775
  readTextFile,
767
776
  readPackageJson,
768
777
  readJsonFile,
778
+ readFileSync,
769
779
  put,
770
780
  mkdirSync,
771
781
  isFolder2 as isFolder,
@@ -791,7 +801,7 @@ export {
791
801
  fs,
792
802
  folders,
793
803
  files,
794
- existsSync,
804
+ existsSync2 as existsSync,
795
805
  exists,
796
806
  doesNotExist,
797
807
  doesFolderExist,
package/dist/zip.d.ts CHANGED
@@ -4,12 +4,12 @@ import type { ZlibCompressionOptions } from 'bun';
4
4
  interface ZipOptions {
5
5
  cwd?: string;
6
6
  }
7
- export declare function zip(from: string | string[], to?: string, options?: ZipOptions): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
8
- export declare function unzip(paths: string | string[]): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
9
- export declare function archive(paths: string | string[]): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
10
- export declare function unarchive(paths: string | string[]): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
11
- export declare function compress(paths: string[]): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
12
- export declare function decompress(paths: string | string[]): Promise<import("neverthrow").Result<import("bun").Subprocess<import("bun").SpawnOptions.Writable, import("bun").SpawnOptions.Readable, import("bun").SpawnOptions.Readable>, Error>>;
7
+ export declare function zip(from: string | string[], to?: string, options?: ZipOptions): Promise<any>;
8
+ export declare function unzip(paths: string | string[]): Promise<any>;
9
+ export declare function archive(paths: string | string[]): Promise<any>;
10
+ export declare function unarchive(paths: string | string[]): Promise<any>;
11
+ export declare function compress(paths: string[]): Promise<any>;
12
+ export declare function decompress(paths: string | string[]): Promise<any>;
13
13
  export declare function gzipSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
14
14
  export declare function gunzipSync(data: Uint8Array): Uint8Array;
15
15
  export declare function deflateSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/storage",
3
3
  "type": "module",
4
- "version": "0.59.3",
4
+ "version": "0.59.5",
5
5
  "description": "The Stacks file system.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "scripts": {
49
49
  "build": "bun --bun build.ts",
50
50
  "typecheck": "bun --bun tsc --noEmit",
51
- "prepublishOnly": "bun --bun run build"
51
+ "prepublishOnly": "bun run build"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@stacksjs/arrays": "latest",
package/src/fs.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as fs from 'fs-extra'
2
- import { pathExists as existsSync, mkdirSync, writeFileSync } from 'fs-extra'
2
+ import { pathExists as existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra'
3
3
 
4
4
  export async function exists(path: string): Promise<boolean> {
5
5
  return await existsSync(path)
6
6
  }
7
7
 
8
- export { fs, existsSync, mkdirSync, writeFileSync }
8
+ export { fs, existsSync, mkdirSync, writeFileSync, readFileSync }
package/src/hash.ts CHANGED
@@ -4,6 +4,13 @@ import { path as p } from '@stacksjs/path'
4
4
  import { fs } from './fs'
5
5
 
6
6
  export function hashFileOrDirectory(path: string, hash: Hash): void {
7
+ // Check if the path exists before proceeding
8
+ if (!existsSync(path)) {
9
+ console.error(`Path does not exist: ${path}`)
10
+ // Handle the non-existent path as needed (e.g., skip or log)
11
+ return
12
+ }
13
+
7
14
  if (fs.statSync(path).isDirectory()) {
8
15
  const files = fs.readdirSync(path)
9
16
  for (const file of files) {