@stacksjs/storage 0.59.10 → 0.61.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.js +67 -70
- package/package.json +4 -4
- package/src/copy.ts +6 -14
- package/src/delete.ts +20 -32
- package/src/drivers/aws.ts +8 -11
- package/src/files.ts +18 -32
- package/src/folders.ts +3 -7
- package/src/hash.ts +2 -4
- package/src/helpers.ts +3 -7
- package/src/move.ts +14 -20
- package/src/zip.ts +3 -5
- package/dist/copy.d.ts +0 -3
- package/dist/delete.d.ts +0 -8
- package/dist/files.d.ts +0 -56
- package/dist/folders.d.ts +0 -15
- package/dist/fs.d.ts +0 -4
- package/dist/glob.d.ts +0 -1
- package/dist/hash.d.ts +0 -6
- package/dist/helpers.d.ts +0 -6
- package/dist/index.d.ts +0 -10
- package/dist/move.d.ts +0 -11
- package/dist/storage.d.ts +0 -9
- package/dist/visibility.d.ts +0 -1
- package/dist/zip.d.ts +0 -17
package/dist/index.js
CHANGED
|
@@ -11,9 +11,9 @@ var __export = (target, all) => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// src/files.ts
|
|
14
|
-
import {detectIndent, detectNewline} from "@stacksjs/strings";
|
|
15
|
-
import {dirname, join as join2, path as p} from "@stacksjs/path";
|
|
16
14
|
import {contains} from "@stacksjs/arrays";
|
|
15
|
+
import {dirname, join, path as p} from "@stacksjs/path";
|
|
16
|
+
import {detectIndent, detectNewline} from "@stacksjs/strings";
|
|
17
17
|
|
|
18
18
|
// src/fs.ts
|
|
19
19
|
import * as fs from "fs-extra";
|
|
@@ -53,7 +53,7 @@ function readTextFile(name, cwd) {
|
|
|
53
53
|
return new Promise((resolve, reject) => {
|
|
54
54
|
let filePath;
|
|
55
55
|
if (cwd)
|
|
56
|
-
filePath =
|
|
56
|
+
filePath = join(cwd, name);
|
|
57
57
|
else
|
|
58
58
|
filePath = name;
|
|
59
59
|
fs.readFile(filePath, "utf8", (err, text) => {
|
|
@@ -96,7 +96,7 @@ function hasFunctions() {
|
|
|
96
96
|
function deleteFiles(dir, exclude = []) {
|
|
97
97
|
if (fs.existsSync(dir)) {
|
|
98
98
|
fs.readdirSync(dir).forEach((file) => {
|
|
99
|
-
const p2 =
|
|
99
|
+
const p2 = join(dir, file);
|
|
100
100
|
if (fs.statSync(p2).isDirectory()) {
|
|
101
101
|
if (fs.readdirSync(p2).length === 0)
|
|
102
102
|
fs.rmSync(p2, { recursive: true, force: true });
|
|
@@ -112,9 +112,9 @@ function getFiles(dir, exclude = []) {
|
|
|
112
112
|
let results = [];
|
|
113
113
|
const list = fs.readdirSync(dir);
|
|
114
114
|
list.forEach((file) => {
|
|
115
|
-
file =
|
|
115
|
+
file = join(dir, file);
|
|
116
116
|
const stat = fs.statSync(file);
|
|
117
|
-
if (stat
|
|
117
|
+
if (stat.isDirectory())
|
|
118
118
|
results = results.concat(getFiles(file, exclude));
|
|
119
119
|
else if (!contains(file, exclude))
|
|
120
120
|
results.push(file);
|
|
@@ -146,8 +146,8 @@ var files = {
|
|
|
146
146
|
get
|
|
147
147
|
};
|
|
148
148
|
// src/folders.ts
|
|
149
|
-
import {join as
|
|
150
|
-
function
|
|
149
|
+
import {join as join2} from "@stacksjs/path";
|
|
150
|
+
function isFolder(path3) {
|
|
151
151
|
try {
|
|
152
152
|
return fs.statSync(path3).isDirectory();
|
|
153
153
|
} catch {
|
|
@@ -155,15 +155,15 @@ function isFolder2(path3) {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
function isDirectory(path3) {
|
|
158
|
-
return
|
|
158
|
+
return isFolder(path3);
|
|
159
159
|
}
|
|
160
160
|
function isDir(path3) {
|
|
161
|
-
return
|
|
161
|
+
return isFolder(path3);
|
|
162
162
|
}
|
|
163
163
|
function doesFolderExist(path3) {
|
|
164
164
|
return fs.existsSync(path3);
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function createFolder(dir) {
|
|
167
167
|
return new Promise((resolve, reject) => {
|
|
168
168
|
fs.mkdirs(dir, (err) => {
|
|
169
169
|
if (err)
|
|
@@ -175,13 +175,13 @@ function createFolder2(dir) {
|
|
|
175
175
|
}
|
|
176
176
|
function getFolders(dir) {
|
|
177
177
|
return fs.readdirSync(dir).filter((file) => {
|
|
178
|
-
return fs.statSync(
|
|
178
|
+
return fs.statSync(join2(dir, file)).isDirectory();
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
var folders = {
|
|
182
|
-
isFolder
|
|
182
|
+
isFolder,
|
|
183
183
|
doesFolderExist,
|
|
184
|
-
createFolder
|
|
184
|
+
createFolder,
|
|
185
185
|
getFolders
|
|
186
186
|
};
|
|
187
187
|
// src/hash.ts
|
|
@@ -243,7 +243,7 @@ var helpers = {
|
|
|
243
243
|
};
|
|
244
244
|
// src/copy.ts
|
|
245
245
|
import {contains as contains2} from "@stacksjs/arrays";
|
|
246
|
-
import {join as
|
|
246
|
+
import {join as join3} from "@stacksjs/path";
|
|
247
247
|
function copy(src, dest, exclude = []) {
|
|
248
248
|
if (Array.isArray(src)) {
|
|
249
249
|
src.forEach((file) => {
|
|
@@ -264,9 +264,9 @@ function copyFolder(src, dest, exclude = []) {
|
|
|
264
264
|
fs.mkdirSync(dest, { recursive: true });
|
|
265
265
|
if (fs.existsSync(src)) {
|
|
266
266
|
fs.readdirSync(src).forEach((file) => {
|
|
267
|
-
if (!contains2(
|
|
268
|
-
const srcPath =
|
|
269
|
-
const destPath =
|
|
267
|
+
if (!contains2(join3(src, file), exclude)) {
|
|
268
|
+
const srcPath = join3(src, file);
|
|
269
|
+
const destPath = join3(dest, file);
|
|
270
270
|
if (fs.statSync(srcPath).isDirectory())
|
|
271
271
|
copyFolder(srcPath, destPath, exclude);
|
|
272
272
|
else
|
|
@@ -278,29 +278,29 @@ function copyFolder(src, dest, exclude = []) {
|
|
|
278
278
|
// src/glob.ts
|
|
279
279
|
import {default as default2} from "fast-glob";
|
|
280
280
|
// src/delete.ts
|
|
281
|
-
import {err, ok} from "@stacksjs/error-handling";
|
|
282
281
|
import {italic, log} from "@stacksjs/cli";
|
|
283
|
-
|
|
282
|
+
import {err, handleError, ok} from "@stacksjs/error-handling";
|
|
283
|
+
import {join as join4} from "@stacksjs/path";
|
|
284
|
+
function deleteFolder(path7) {
|
|
284
285
|
return new Promise((resolve, reject) => {
|
|
285
286
|
try {
|
|
286
|
-
if (
|
|
287
|
-
fs.rmSync(
|
|
288
|
-
return resolve(ok(`Deleted ${
|
|
287
|
+
if (isFolder(path7)) {
|
|
288
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
289
|
+
return resolve(ok(`Deleted ${path7}`));
|
|
289
290
|
}
|
|
290
|
-
return resolve(ok(`Path ${
|
|
291
|
+
return resolve(ok(`Path ${path7} was not a directory`));
|
|
291
292
|
} catch (error) {
|
|
292
293
|
return reject(err(error));
|
|
293
294
|
}
|
|
294
295
|
});
|
|
295
296
|
}
|
|
296
|
-
async function isDirectoryEmpty(
|
|
297
|
+
async function isDirectoryEmpty(path7) {
|
|
297
298
|
return new Promise((resolve, reject) => {
|
|
298
299
|
try {
|
|
299
|
-
if (fs.statSync(
|
|
300
|
-
if (fs.readdirSync(
|
|
300
|
+
if (fs.statSync(path7).isDirectory()) {
|
|
301
|
+
if (fs.readdirSync(path7).length === 0)
|
|
301
302
|
return resolve(ok(true));
|
|
302
|
-
|
|
303
|
-
return resolve(ok(false));
|
|
303
|
+
return resolve(ok(false));
|
|
304
304
|
}
|
|
305
305
|
return resolve(ok(false));
|
|
306
306
|
} catch (error) {
|
|
@@ -308,18 +308,17 @@ async function isDirectoryEmpty(path6) {
|
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
async function deleteEmptyFolder(
|
|
311
|
+
async function deleteEmptyFolder(path7) {
|
|
312
312
|
return new Promise((resolve, reject) => {
|
|
313
313
|
try {
|
|
314
|
-
if (fs.statSync(
|
|
315
|
-
if (fs.readdirSync(
|
|
316
|
-
fs.rmSync(
|
|
317
|
-
return resolve(ok(`Deleted ${
|
|
318
|
-
} else {
|
|
319
|
-
return resolve(ok(`Path ${path6} was not empty`));
|
|
314
|
+
if (fs.statSync(path7).isDirectory()) {
|
|
315
|
+
if (fs.readdirSync(path7).length === 0) {
|
|
316
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
317
|
+
return resolve(ok(`Deleted ${path7}`));
|
|
320
318
|
}
|
|
319
|
+
return resolve(ok(`Path ${path7} was not empty`));
|
|
321
320
|
}
|
|
322
|
-
return resolve(ok(`Path ${
|
|
321
|
+
return resolve(ok(`Path ${path7} was not a directory`));
|
|
323
322
|
} catch (error) {
|
|
324
323
|
return reject(err(error));
|
|
325
324
|
}
|
|
@@ -331,8 +330,8 @@ async function deleteEmptyFolders(dir) {
|
|
|
331
330
|
return ok(`Path ${dir} does not exist`);
|
|
332
331
|
const files3 = fs.readdirSync(dir);
|
|
333
332
|
for (const file of files3) {
|
|
334
|
-
const p3 =
|
|
335
|
-
if (
|
|
333
|
+
const p3 = join4(dir, file);
|
|
334
|
+
if (isFolder(p3)) {
|
|
336
335
|
if (fs.readdirSync(p3).length === 0)
|
|
337
336
|
fs.rmSync(p3, { recursive: true, force: true });
|
|
338
337
|
else
|
|
@@ -344,23 +343,23 @@ async function deleteEmptyFolders(dir) {
|
|
|
344
343
|
return err(error);
|
|
345
344
|
}
|
|
346
345
|
}
|
|
347
|
-
function deleteFile(
|
|
346
|
+
function deleteFile(path7) {
|
|
348
347
|
return new Promise((resolve, reject) => {
|
|
349
348
|
try {
|
|
350
|
-
if (isFile(
|
|
351
|
-
fs.rmSync(
|
|
352
|
-
return resolve(ok(`Deleted ${
|
|
349
|
+
if (isFile(path7)) {
|
|
350
|
+
fs.rmSync(path7, { recursive: true, force: true });
|
|
351
|
+
return resolve(ok(`Deleted ${path7}`));
|
|
353
352
|
}
|
|
354
|
-
return resolve(ok(`Path ${
|
|
353
|
+
return resolve(ok(`Path ${path7} was not a file`));
|
|
355
354
|
} catch (error) {
|
|
356
355
|
return reject(err(error));
|
|
357
356
|
}
|
|
358
357
|
});
|
|
359
358
|
}
|
|
360
|
-
async function deleteGlob(
|
|
361
|
-
if (!
|
|
362
|
-
return err(handleError(`Path ${
|
|
363
|
-
const directories = await default2([
|
|
359
|
+
async function deleteGlob(path7) {
|
|
360
|
+
if (!path7.includes("*"))
|
|
361
|
+
return err(handleError(`Path ${path7} does not contain a glob`));
|
|
362
|
+
const directories = await default2([path7], { onlyDirectories: true });
|
|
364
363
|
for (const directory of directories) {
|
|
365
364
|
const result = await deleteFolder(directory);
|
|
366
365
|
if (result.isErr()) {
|
|
@@ -371,14 +370,14 @@ async function deleteGlob(path6) {
|
|
|
371
370
|
}
|
|
372
371
|
return ok(`Deleted ${directories.length} directories`);
|
|
373
372
|
}
|
|
374
|
-
async function del(
|
|
375
|
-
if (isFile(
|
|
376
|
-
return await deleteFile(
|
|
377
|
-
if (
|
|
378
|
-
return await deleteFolder(
|
|
379
|
-
if (
|
|
380
|
-
return await deleteGlob(
|
|
381
|
-
return err(handleError(`Path ${
|
|
373
|
+
async function del(path7) {
|
|
374
|
+
if (isFile(path7))
|
|
375
|
+
return await deleteFile(path7);
|
|
376
|
+
if (isFolder(path7))
|
|
377
|
+
return await deleteFolder(path7);
|
|
378
|
+
if (path7.includes("*"))
|
|
379
|
+
return await deleteGlob(path7);
|
|
380
|
+
return err(handleError(`Path ${path7} cannot be deleted due to an unhandled condition. Please report this issue.`));
|
|
382
381
|
}
|
|
383
382
|
// src/zip.ts
|
|
384
383
|
import {runCommand} from "@stacksjs/cli";
|
|
@@ -508,7 +507,7 @@ __export(exports_storage, {
|
|
|
508
507
|
},
|
|
509
508
|
isFolder: () => {
|
|
510
509
|
{
|
|
511
|
-
return
|
|
510
|
+
return isFolder;
|
|
512
511
|
}
|
|
513
512
|
},
|
|
514
513
|
isFile: () => {
|
|
@@ -668,7 +667,7 @@ __export(exports_storage, {
|
|
|
668
667
|
},
|
|
669
668
|
createFolder: () => {
|
|
670
669
|
{
|
|
671
|
-
return
|
|
670
|
+
return createFolder;
|
|
672
671
|
}
|
|
673
672
|
},
|
|
674
673
|
copyFolder: () => {
|
|
@@ -704,20 +703,18 @@ __export(exports_storage, {
|
|
|
704
703
|
});
|
|
705
704
|
|
|
706
705
|
// src/move.ts
|
|
707
|
-
import {err as err2, ok as ok2} from "@stacksjs/error-handling";
|
|
706
|
+
import {err as err2, handleError as handleError2, ok as ok2} from "@stacksjs/error-handling";
|
|
708
707
|
import {log as log2} from "@stacksjs/logging";
|
|
709
|
-
import {path as
|
|
708
|
+
import {path as path8} from "@stacksjs/path";
|
|
710
709
|
async function move(src, dest, options) {
|
|
711
710
|
try {
|
|
712
711
|
if (Array.isArray(src)) {
|
|
713
712
|
const operations = src.map(async (file) => {
|
|
714
713
|
const from2 = file;
|
|
715
|
-
const to2 =
|
|
714
|
+
const to2 = path8.resolve(dest, path8.basename(file));
|
|
716
715
|
const result2 = await rename(from2, to2, options);
|
|
717
|
-
if (result2.isErr())
|
|
718
|
-
log2.error(result2.error);
|
|
719
|
-
return err2(handleError(result2.error.message, result2.error));
|
|
720
|
-
}
|
|
716
|
+
if (result2.isErr())
|
|
717
|
+
return log2.error(result2.error);
|
|
721
718
|
});
|
|
722
719
|
await Promise.all(operations);
|
|
723
720
|
return ok2({ message: "Files moved successfully" });
|
|
@@ -727,17 +724,17 @@ async function move(src, dest, options) {
|
|
|
727
724
|
const result = await rename(from, to, options);
|
|
728
725
|
if (result.isErr()) {
|
|
729
726
|
log2.error(result.error);
|
|
730
|
-
return err2(
|
|
727
|
+
return err2(handleError2(result.error));
|
|
731
728
|
}
|
|
732
729
|
return ok2({ message: "File moved successfully" });
|
|
733
730
|
} catch (error) {
|
|
734
|
-
return err2(
|
|
731
|
+
return err2(handleError2(error));
|
|
735
732
|
}
|
|
736
733
|
}
|
|
737
734
|
async function rename(from, to, options) {
|
|
738
735
|
return new Promise((resolve, reject) => {
|
|
739
736
|
try {
|
|
740
|
-
const dir =
|
|
737
|
+
const dir = path8.dirname(to);
|
|
741
738
|
if (!fs.existsSync(dir))
|
|
742
739
|
fs.mkdirSync(dir, { recursive: true });
|
|
743
740
|
if (!fs.existsSync(from))
|
|
@@ -778,7 +775,7 @@ export {
|
|
|
778
775
|
readFileSync,
|
|
779
776
|
put,
|
|
780
777
|
mkdirSync,
|
|
781
|
-
|
|
778
|
+
isFolder,
|
|
782
779
|
isFile,
|
|
783
780
|
isDirectoryEmpty,
|
|
784
781
|
isDirectory,
|
|
@@ -815,7 +812,7 @@ export {
|
|
|
815
812
|
del,
|
|
816
813
|
deflateSync,
|
|
817
814
|
decompress,
|
|
818
|
-
|
|
815
|
+
createFolder,
|
|
819
816
|
copyFolder,
|
|
820
817
|
copyFile,
|
|
821
818
|
copy,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/storage",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.61.0",
|
|
5
5
|
"description": "The Stacks file system.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@stacksjs/strings": "latest",
|
|
59
59
|
"@stacksjs/types": "latest",
|
|
60
60
|
"@types/archiver": "^6.0.2",
|
|
61
|
-
"archiver": "^7.0.
|
|
61
|
+
"archiver": "^7.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@stacksjs/arrays": "latest",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"@stacksjs/strings": "latest",
|
|
68
68
|
"@stacksjs/types": "latest",
|
|
69
69
|
"@types/archiver": "^6.0.2",
|
|
70
|
-
"archiver": "^7.0.
|
|
70
|
+
"archiver": "^7.0.1",
|
|
71
71
|
"fast-glob": "^3.3.2",
|
|
72
72
|
"fs-extra": "^11.2.0",
|
|
73
|
-
"unstorage": "^1.10.
|
|
73
|
+
"unstorage": "^1.10.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@stacksjs/development": "latest"
|
package/src/copy.ts
CHANGED
|
@@ -7,13 +7,9 @@ export function copy(src: string | string[], dest: string, exclude: string[] = [
|
|
|
7
7
|
src.forEach((file) => {
|
|
8
8
|
copy(file, dest, exclude)
|
|
9
9
|
})
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
copyFolder(src, dest, exclude)
|
|
14
|
-
|
|
15
|
-
else
|
|
16
|
-
copyFile(src, dest)
|
|
10
|
+
} else {
|
|
11
|
+
if (fs.statSync(src).isDirectory()) copyFolder(src, dest, exclude)
|
|
12
|
+
else copyFile(src, dest)
|
|
17
13
|
}
|
|
18
14
|
}
|
|
19
15
|
|
|
@@ -22,8 +18,7 @@ export function copyFile(src: string, dest: string): void {
|
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export function copyFolder(src: string, dest: string, exclude: string[] = []): void {
|
|
25
|
-
if (!fs.existsSync(dest))
|
|
26
|
-
fs.mkdirSync(dest, { recursive: true })
|
|
21
|
+
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true })
|
|
27
22
|
|
|
28
23
|
if (fs.existsSync(src)) {
|
|
29
24
|
fs.readdirSync(src).forEach((file) => {
|
|
@@ -31,11 +26,8 @@ export function copyFolder(src: string, dest: string, exclude: string[] = []): v
|
|
|
31
26
|
const srcPath = join(src, file)
|
|
32
27
|
const destPath = join(dest, file)
|
|
33
28
|
|
|
34
|
-
if (fs.statSync(srcPath).isDirectory())
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
else
|
|
38
|
-
fs.copyFileSync(srcPath, destPath)
|
|
29
|
+
if (fs.statSync(srcPath).isDirectory()) copyFolder(srcPath, destPath, exclude)
|
|
30
|
+
else fs.copyFileSync(srcPath, destPath)
|
|
39
31
|
}
|
|
40
32
|
})
|
|
41
33
|
}
|
package/src/delete.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { Result } from '@stacksjs/error-handling'
|
|
2
|
-
import { err, ok } from '@stacksjs/error-handling'
|
|
3
1
|
import { italic, log } from '@stacksjs/cli'
|
|
2
|
+
import type { Result } from '@stacksjs/error-handling'
|
|
3
|
+
import { err, handleError, ok } from '@stacksjs/error-handling'
|
|
4
|
+
import { join } from '@stacksjs/path'
|
|
4
5
|
import { isFile } from './files'
|
|
5
6
|
import { isFolder } from './folders'
|
|
6
|
-
import { glob } from './glob'
|
|
7
7
|
import { fs } from './fs'
|
|
8
|
+
import { glob } from './glob'
|
|
8
9
|
|
|
9
10
|
export function deleteFolder(path: string): Promise<Result<string, Error>> {
|
|
10
11
|
return new Promise((resolve, reject) => {
|
|
@@ -15,8 +16,7 @@ export function deleteFolder(path: string): Promise<Result<string, Error>> {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
return resolve(ok(`Path ${path} was not a directory`))
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
19
|
+
} catch (error) {
|
|
20
20
|
return reject(err(error))
|
|
21
21
|
}
|
|
22
22
|
})
|
|
@@ -26,15 +26,12 @@ export async function isDirectoryEmpty(path: string): Promise<Result<boolean, Er
|
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
27
|
try {
|
|
28
28
|
if (fs.statSync(path).isDirectory()) {
|
|
29
|
-
if (fs.readdirSync(path).length === 0)
|
|
30
|
-
|
|
31
|
-
else
|
|
32
|
-
return resolve(ok(false))
|
|
29
|
+
if (fs.readdirSync(path).length === 0) return resolve(ok(true))
|
|
30
|
+
return resolve(ok(false))
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
return resolve(ok(false))
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
34
|
+
} catch (error) {
|
|
38
35
|
return reject(err(error))
|
|
39
36
|
}
|
|
40
37
|
})
|
|
@@ -48,12 +45,12 @@ export async function deleteEmptyFolder(path: string): Promise<Result<string, Er
|
|
|
48
45
|
fs.rmSync(path, { recursive: true, force: true })
|
|
49
46
|
return resolve(ok(`Deleted ${path}`))
|
|
50
47
|
}
|
|
51
|
-
|
|
48
|
+
|
|
49
|
+
return resolve(ok(`Path ${path} was not empty`))
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
return resolve(ok(`Path ${path} was not a directory`))
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
53
|
+
} catch (error) {
|
|
57
54
|
return reject(err(error))
|
|
58
55
|
}
|
|
59
56
|
})
|
|
@@ -61,23 +58,19 @@ export async function deleteEmptyFolder(path: string): Promise<Result<string, Er
|
|
|
61
58
|
|
|
62
59
|
export async function deleteEmptyFolders(dir: string): Promise<Result<string, Error>> {
|
|
63
60
|
try {
|
|
64
|
-
if (!fs.existsSync(dir))
|
|
65
|
-
return ok(`Path ${dir} does not exist`)
|
|
61
|
+
if (!fs.existsSync(dir)) return ok(`Path ${dir} does not exist`)
|
|
66
62
|
|
|
67
63
|
const files = fs.readdirSync(dir)
|
|
68
64
|
for (const file of files) {
|
|
69
65
|
const p = join(dir, file)
|
|
70
66
|
if (isFolder(p)) {
|
|
71
|
-
if (fs.readdirSync(p).length === 0)
|
|
72
|
-
|
|
73
|
-
else
|
|
74
|
-
await deleteEmptyFolders(p)
|
|
67
|
+
if (fs.readdirSync(p).length === 0) fs.rmSync(p, { recursive: true, force: true })
|
|
68
|
+
else await deleteEmptyFolders(p)
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
|
|
78
72
|
return ok(`Deleted empty folders located in ${dir}`)
|
|
79
|
-
}
|
|
80
|
-
catch (error: any) {
|
|
73
|
+
} catch (error: any) {
|
|
81
74
|
return err(error)
|
|
82
75
|
}
|
|
83
76
|
}
|
|
@@ -91,16 +84,14 @@ export function deleteFile(path: string): Promise<Result<string, Error>> {
|
|
|
91
84
|
}
|
|
92
85
|
|
|
93
86
|
return resolve(ok(`Path ${path} was not a file`))
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
87
|
+
} catch (error) {
|
|
96
88
|
return reject(err(error))
|
|
97
89
|
}
|
|
98
90
|
})
|
|
99
91
|
}
|
|
100
92
|
|
|
101
93
|
export async function deleteGlob(path: string): Promise<Result<string, Error>> {
|
|
102
|
-
if (!path.includes('*'))
|
|
103
|
-
return err(handleError(`Path ${path} does not contain a glob`))
|
|
94
|
+
if (!path.includes('*')) return err(handleError(`Path ${path} does not contain a glob`))
|
|
104
95
|
|
|
105
96
|
const directories = await glob([path], { onlyDirectories: true })
|
|
106
97
|
|
|
@@ -118,14 +109,11 @@ export async function deleteGlob(path: string): Promise<Result<string, Error>> {
|
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
export async function del(path: string): Promise<Result<string, Error>> {
|
|
121
|
-
if (isFile(path))
|
|
122
|
-
return await deleteFile(path)
|
|
112
|
+
if (isFile(path)) return await deleteFile(path)
|
|
123
113
|
|
|
124
|
-
if (isFolder(path))
|
|
125
|
-
return await deleteFolder(path)
|
|
114
|
+
if (isFolder(path)) return await deleteFolder(path)
|
|
126
115
|
|
|
127
|
-
if (path.includes('*'))
|
|
128
|
-
return await deleteGlob(path)
|
|
116
|
+
if (path.includes('*')) return await deleteGlob(path)
|
|
129
117
|
|
|
130
118
|
return err(handleError(`Path ${path} cannot be deleted due to an unhandled condition. Please report this issue.`))
|
|
131
119
|
}
|
package/src/drivers/aws.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type { NestedStackProps } from 'aws-cdk-lib'
|
|
1
|
+
// import type { NestedStackProps } from 'aws-cdk-lib'
|
|
2
2
|
import { NestedStack } from 'aws-cdk-lib'
|
|
3
|
-
import type { Construct } from 'constructs'
|
|
3
|
+
// import type { Construct } from 'constructs'
|
|
4
4
|
|
|
5
5
|
export class StorageStack extends NestedStack {
|
|
6
|
-
constructor(scope: Construct, id: string, props?: NestedStackProps) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// // eslint-disable-next-line no-new
|
|
13
|
-
// new s3.Bucket(this, storage.name)
|
|
14
|
-
}
|
|
6
|
+
// constructor(scope: Construct, id: string, props?: NestedStackProps) {
|
|
7
|
+
// super(scope, id, props)
|
|
8
|
+
// if (!storage.name)
|
|
9
|
+
// throw new Error('./config storage.name is not defined')
|
|
10
|
+
// new s3.Bucket(this, storage.name)
|
|
11
|
+
// }
|
|
15
12
|
}
|
package/src/files.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { JsonFile, PackageJson, TextFile } from '@stacksjs/types'
|
|
2
|
-
import { detectIndent, detectNewline } from '@stacksjs/strings'
|
|
3
|
-
import { dirname, join, path as p } from '@stacksjs/path'
|
|
4
1
|
import { contains } from '@stacksjs/arrays'
|
|
5
|
-
import {
|
|
2
|
+
import { dirname, join, path as p } from '@stacksjs/path'
|
|
3
|
+
import { createFolder, isFolder } from '@stacksjs/storage'
|
|
4
|
+
import { detectIndent, detectNewline } from '@stacksjs/strings'
|
|
5
|
+
import type { JsonFile, PackageJson, TextFile } from '@stacksjs/types'
|
|
6
|
+
import { fs, existsSync } from './fs'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Reads a JSON file and returns the parsed data.
|
|
@@ -28,11 +29,10 @@ export async function readPackageJson(name: string, cwd?: string) {
|
|
|
28
29
|
* Writes the given text to the specified file.
|
|
29
30
|
*/
|
|
30
31
|
export async function writeFile(path: string, data: any): Promise<number> {
|
|
31
|
-
// export async function writeFile(path: Path, data: Data): Promise<number> {
|
|
32
|
+
// export async function writeFile(path: Path, data: Data): Promise<number> {
|
|
32
33
|
if (typeof path === 'string') {
|
|
33
34
|
const dirPath = dirname(path)
|
|
34
|
-
if (!await existsSync(dirPath))
|
|
35
|
-
await createFolder(dirPath)
|
|
35
|
+
if (!(await existsSync(dirPath))) await createFolder(dirPath)
|
|
36
36
|
|
|
37
37
|
return await Bun.write(Bun.file(path), data)
|
|
38
38
|
}
|
|
@@ -46,8 +46,7 @@ export async function writeFile(path: string, data: any): Promise<number> {
|
|
|
46
46
|
export async function writeJsonFile(file: JsonFile): Promise<number> {
|
|
47
47
|
let json = JSON.stringify(file.data, undefined, file.indent)
|
|
48
48
|
|
|
49
|
-
if (file.newline)
|
|
50
|
-
json += file.newline
|
|
49
|
+
if (file.newline) json += file.newline
|
|
51
50
|
|
|
52
51
|
return writeTextFile({ ...file, data: json })
|
|
53
52
|
}
|
|
@@ -59,16 +58,13 @@ export function readTextFile(name: string, cwd?: string): Promise<TextFile> {
|
|
|
59
58
|
return new Promise((resolve, reject) => {
|
|
60
59
|
let filePath: string
|
|
61
60
|
|
|
62
|
-
if (cwd)
|
|
63
|
-
|
|
64
|
-
else
|
|
65
|
-
filePath = name
|
|
61
|
+
if (cwd) filePath = join(cwd, name)
|
|
62
|
+
else filePath = name
|
|
66
63
|
|
|
67
64
|
fs.readFile(filePath, 'utf8', (err, text) => {
|
|
68
65
|
if (err) {
|
|
69
66
|
reject(err)
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
67
|
+
} else {
|
|
72
68
|
resolve({
|
|
73
69
|
path: filePath,
|
|
74
70
|
data: text,
|
|
@@ -106,8 +102,7 @@ export function doesNotExist(path: string): boolean {
|
|
|
106
102
|
export function hasFiles(folder: string): boolean {
|
|
107
103
|
try {
|
|
108
104
|
return fs.readdirSync(folder).length > 0
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
105
|
+
} catch (err) {
|
|
111
106
|
return false
|
|
112
107
|
}
|
|
113
108
|
}
|
|
@@ -125,14 +120,9 @@ export function deleteFiles(dir: string, exclude: string[] = []) {
|
|
|
125
120
|
fs.readdirSync(dir).forEach((file) => {
|
|
126
121
|
const p = join(dir, file)
|
|
127
122
|
if (fs.statSync(p).isDirectory()) {
|
|
128
|
-
if (fs.readdirSync(p).length === 0)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
else
|
|
132
|
-
deleteFiles(p, exclude)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
else if (!contains(p, exclude)) {
|
|
123
|
+
if (fs.readdirSync(p).length === 0) fs.rmSync(p, { recursive: true, force: true })
|
|
124
|
+
else deleteFiles(p, exclude)
|
|
125
|
+
} else if (!contains(p, exclude)) {
|
|
136
126
|
fs.rmSync(p)
|
|
137
127
|
}
|
|
138
128
|
})
|
|
@@ -147,11 +137,8 @@ export function getFiles(dir: string, exclude: string[] = []): string[] {
|
|
|
147
137
|
file = join(dir, file)
|
|
148
138
|
const stat = fs.statSync(file)
|
|
149
139
|
|
|
150
|
-
if (stat
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
else if (!contains(file, exclude))
|
|
154
|
-
results.push(file)
|
|
140
|
+
if (stat.isDirectory()) results = results.concat(getFiles(file, exclude))
|
|
141
|
+
else if (!contains(file, exclude)) results.push(file)
|
|
155
142
|
})
|
|
156
143
|
|
|
157
144
|
return results
|
|
@@ -160,8 +147,7 @@ export function getFiles(dir: string, exclude: string[] = []): string[] {
|
|
|
160
147
|
export function put(path: string, contents: string) {
|
|
161
148
|
const dirPath = dirname(path)
|
|
162
149
|
|
|
163
|
-
if (!fs.existsSync(dirPath))
|
|
164
|
-
fs.mkdirSync(dirPath, { recursive: true })
|
|
150
|
+
if (!fs.existsSync(dirPath)) fs.mkdirSync(dirPath, { recursive: true })
|
|
165
151
|
|
|
166
152
|
fs.writeFileSync(path, contents, 'utf-8')
|
|
167
153
|
}
|
package/src/folders.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { fs } from './fs'
|
|
|
7
7
|
export function isFolder(path: string): boolean {
|
|
8
8
|
try {
|
|
9
9
|
return fs.statSync(path).isDirectory()
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
10
|
+
} catch {
|
|
12
11
|
return false
|
|
13
12
|
}
|
|
14
13
|
}
|
|
@@ -28,11 +27,8 @@ export function doesFolderExist(path: string) {
|
|
|
28
27
|
export function createFolder(dir: string): Promise<void> {
|
|
29
28
|
return new Promise((resolve, reject) => {
|
|
30
29
|
fs.mkdirs(dir, (err: any) => {
|
|
31
|
-
if (err)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
else
|
|
35
|
-
resolve()
|
|
30
|
+
if (err) reject(err)
|
|
31
|
+
else resolve()
|
|
36
32
|
})
|
|
37
33
|
})
|
|
38
34
|
}
|
package/src/hash.ts
CHANGED
|
@@ -17,8 +17,7 @@ export function hashFileOrDirectory(path: string, hash: Hash): void {
|
|
|
17
17
|
const filePath = p.join(path, file)
|
|
18
18
|
hashFileOrDirectory(filePath, hash)
|
|
19
19
|
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
20
|
+
} else {
|
|
22
21
|
hash.update(fs.readFileSync(path))
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -39,8 +38,7 @@ export function hashPaths(paths: string | string[]): string {
|
|
|
39
38
|
const hash = createHash('sha256')
|
|
40
39
|
const pathsArray = Array.isArray(paths) ? paths : [paths]
|
|
41
40
|
|
|
42
|
-
for (const path of pathsArray)
|
|
43
|
-
hashFileOrDirectory(path, hash)
|
|
41
|
+
for (const path of pathsArray) hashFileOrDirectory(path, hash)
|
|
44
42
|
|
|
45
43
|
return hash.digest('hex')
|
|
46
44
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -2,22 +2,18 @@ import { fileURLToPath } from 'node:url'
|
|
|
2
2
|
import { dirname } from '@stacksjs/path'
|
|
3
3
|
import { fs } from './fs'
|
|
4
4
|
|
|
5
|
-
export const _dirname = typeof __dirname !== 'undefined'
|
|
6
|
-
? __dirname
|
|
7
|
-
: dirname(fileURLToPath(import.meta.url))
|
|
5
|
+
export const _dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(import.meta.url))
|
|
8
6
|
|
|
9
7
|
export function updateConfigFile(filePath: string, newConfig: Record<string, unknown>): Promise<void> {
|
|
10
8
|
return new Promise((resolve, reject) => {
|
|
11
9
|
const config = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Record<string, unknown>
|
|
12
10
|
|
|
13
|
-
for (const key in newConfig)
|
|
14
|
-
config[key] = newConfig[key]
|
|
11
|
+
for (const key in newConfig) config[key] = newConfig[key]
|
|
15
12
|
|
|
16
13
|
try {
|
|
17
14
|
fs.writeFileSync(filePath, JSON.stringify(config, null, 2))
|
|
18
15
|
resolve()
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
16
|
+
} catch (error) {
|
|
21
17
|
reject(error)
|
|
22
18
|
}
|
|
23
19
|
})
|
package/src/move.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Result, err, ok } from '@stacksjs/error-handling'
|
|
1
|
+
import { type Result, err, handleError, ok } from '@stacksjs/error-handling'
|
|
2
2
|
import { log } from '@stacksjs/logging'
|
|
3
3
|
import { path } from '@stacksjs/path'
|
|
4
4
|
import { fs } from './fs'
|
|
@@ -20,10 +20,7 @@ export async function move(
|
|
|
20
20
|
const to = path.resolve(dest, path.basename(file))
|
|
21
21
|
const result = await rename(from, to, options)
|
|
22
22
|
|
|
23
|
-
if (result.isErr())
|
|
24
|
-
log.error(result.error)
|
|
25
|
-
return err(handleError(result.error.message, result.error))
|
|
26
|
-
}
|
|
23
|
+
if (result.isErr()) return log.error(result.error)
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
await Promise.all(operations)
|
|
@@ -41,28 +38,28 @@ export async function move(
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
return ok({ message: 'File moved successfully' })
|
|
44
|
-
}
|
|
45
|
-
catch (error: any) {
|
|
41
|
+
} catch (error: any) {
|
|
46
42
|
return err(handleError(error))
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
export async function rename(
|
|
46
|
+
export async function rename(
|
|
47
|
+
from: string,
|
|
48
|
+
to: string,
|
|
49
|
+
options?: MoveOptions,
|
|
50
|
+
): Promise<Result<{ message: string }, Error>> {
|
|
51
51
|
return new Promise((resolve, reject) => {
|
|
52
52
|
try {
|
|
53
53
|
// Check if the "to" directory exists
|
|
54
54
|
const dir = path.dirname(to)
|
|
55
|
-
if (!fs.existsSync(dir))
|
|
56
|
-
fs.mkdirSync(dir, { recursive: true })
|
|
55
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
|
|
57
56
|
|
|
58
57
|
// Ensure the "from" file exists
|
|
59
|
-
if (!fs.existsSync(from))
|
|
60
|
-
return reject(err(new Error(`File or directory does not exist: ${from}`)))
|
|
58
|
+
if (!fs.existsSync(from)) return reject(err(new Error(`File or directory does not exist: ${from}`)))
|
|
61
59
|
|
|
62
60
|
// Ensure the "to" file does not exist
|
|
63
61
|
if (fs.existsSync(to)) {
|
|
64
|
-
if (!options?.overwrite)
|
|
65
|
-
return reject(err(new Error(`File or directory already exists: ${to}`)))
|
|
62
|
+
if (!options?.overwrite) return reject(err(new Error(`File or directory already exists: ${to}`)))
|
|
66
63
|
|
|
67
64
|
fs.unlinkSync(to)
|
|
68
65
|
}
|
|
@@ -71,12 +68,9 @@ export async function rename(from: string, to: string, options?: MoveOptions): P
|
|
|
71
68
|
fs.renameSync(from, to)
|
|
72
69
|
|
|
73
70
|
return resolve(ok({ message: 'File moved successfully' }))
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
log.error('File or directory does not exist\n\n', error)
|
|
78
|
-
else
|
|
79
|
-
log.error(error)
|
|
71
|
+
} catch (error: any) {
|
|
72
|
+
if (error.code === 'ENOENT') log.error('File or directory does not exist\n\n', error)
|
|
73
|
+
else log.error(error)
|
|
80
74
|
|
|
81
75
|
return reject(err(new Error(error)))
|
|
82
76
|
}
|
package/src/zip.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ZlibCompressionOptions } from 'bun'
|
|
2
1
|
import { runCommand } from '@stacksjs/cli'
|
|
2
|
+
import type { ZlibCompressionOptions } from 'bun'
|
|
3
3
|
|
|
4
4
|
interface ZipOptions {
|
|
5
5
|
cwd?: string
|
|
@@ -9,15 +9,13 @@ export async function zip(from: string | string[], to?: string, options?: ZipOpt
|
|
|
9
9
|
const toPath = to || 'archive.zip'
|
|
10
10
|
const fromPath = Array.isArray(from) ? from.join(' ') : from
|
|
11
11
|
|
|
12
|
-
if (Array.isArray(from))
|
|
13
|
-
return runCommand(`zip -r ${toPath} ${fromPath}`, options)
|
|
12
|
+
if (Array.isArray(from)) return runCommand(`zip -r ${toPath} ${fromPath}`, options)
|
|
14
13
|
|
|
15
14
|
return runCommand(`zip -r ${to} ${from}`, options)
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export async function unzip(paths: string | string[]) {
|
|
19
|
-
if (Array.isArray(paths))
|
|
20
|
-
return runCommand(`unzip ${paths.join(' ')}`)
|
|
18
|
+
if (Array.isArray(paths)) return runCommand(`unzip ${paths.join(' ')}`)
|
|
21
19
|
|
|
22
20
|
return runCommand(`unzip ${paths}`)
|
|
23
21
|
}
|
package/dist/copy.d.ts
DELETED
package/dist/delete.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Result } from '@stacksjs/error-handling';
|
|
2
|
-
export declare function deleteFolder(path: string): Promise<Result<string, Error>>;
|
|
3
|
-
export declare function isDirectoryEmpty(path: string): Promise<Result<boolean, Error>>;
|
|
4
|
-
export declare function deleteEmptyFolder(path: string): Promise<Result<string, Error>>;
|
|
5
|
-
export declare function deleteEmptyFolders(dir: string): Promise<Result<string, Error>>;
|
|
6
|
-
export declare function deleteFile(path: string): Promise<Result<string, Error>>;
|
|
7
|
-
export declare function deleteGlob(path: string): Promise<Result<string, Error>>;
|
|
8
|
-
export declare function del(path: string): Promise<Result<string, Error>>;
|
package/dist/files.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { JsonFile, TextFile } from '@stacksjs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Reads a JSON file and returns the parsed data.
|
|
4
|
-
*/
|
|
5
|
-
export declare function readJsonFile(name: string, cwd?: string): Promise<JsonFile>;
|
|
6
|
-
/**
|
|
7
|
-
* Reads a package.json file and returns the parsed data.
|
|
8
|
-
*/
|
|
9
|
-
export declare function readPackageJson(name: string, cwd?: string): Promise<PackageJson>;
|
|
10
|
-
/**
|
|
11
|
-
* Writes the given text to the specified file.
|
|
12
|
-
*/
|
|
13
|
-
export declare function writeFile(path: string, data: any): Promise<number>;
|
|
14
|
-
/**
|
|
15
|
-
* Writes the given data to the specified JSON file.
|
|
16
|
-
*/
|
|
17
|
-
export declare function writeJsonFile(file: JsonFile): Promise<number>;
|
|
18
|
-
/**
|
|
19
|
-
* Reads a text file and returns its contents.
|
|
20
|
-
*/
|
|
21
|
-
export declare function readTextFile(name: string, cwd?: string): Promise<TextFile>;
|
|
22
|
-
/**
|
|
23
|
-
* Writes the given text to the specified file.
|
|
24
|
-
*/
|
|
25
|
-
export declare function writeTextFile(file: TextFile): Promise<number>;
|
|
26
|
-
/**
|
|
27
|
-
* Determine whether a path exists.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isFile(path: string): boolean;
|
|
30
|
-
export declare function doesExist(path: string): boolean;
|
|
31
|
-
export declare function doesNotExist(path: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Determine whether a folder has any files in it.
|
|
34
|
-
*/
|
|
35
|
-
export declare function hasFiles(folder: string): boolean;
|
|
36
|
-
export declare function hasComponents(): boolean;
|
|
37
|
-
export declare function hasFunctions(): boolean;
|
|
38
|
-
export declare function deleteFiles(dir: string, exclude?: string[]): void;
|
|
39
|
-
export declare function getFiles(dir: string, exclude?: string[]): string[];
|
|
40
|
-
export declare function put(path: string, contents: string): void;
|
|
41
|
-
export declare function get(path: string): Promise<string>;
|
|
42
|
-
export declare const files: {
|
|
43
|
-
readJsonFile: typeof readJsonFile;
|
|
44
|
-
readPackageJson: typeof readPackageJson;
|
|
45
|
-
readTextFile: typeof readTextFile;
|
|
46
|
-
writeJsonFile: typeof writeJsonFile;
|
|
47
|
-
writeTextFile: typeof writeTextFile;
|
|
48
|
-
isFile: typeof isFile;
|
|
49
|
-
hasFiles: typeof hasFiles;
|
|
50
|
-
hasComponents: typeof hasComponents;
|
|
51
|
-
hasFunctions: typeof hasFunctions;
|
|
52
|
-
deleteFiles: typeof deleteFiles;
|
|
53
|
-
getFiles: typeof getFiles;
|
|
54
|
-
put: typeof put;
|
|
55
|
-
get: typeof get;
|
|
56
|
-
};
|
package/dist/folders.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determine whether a path is a folder.
|
|
3
|
-
*/
|
|
4
|
-
export declare function isFolder(path: string): boolean;
|
|
5
|
-
export declare function isDirectory(path: string): boolean;
|
|
6
|
-
export declare function isDir(path: string): boolean;
|
|
7
|
-
export declare function doesFolderExist(path: string): boolean;
|
|
8
|
-
export declare function createFolder(dir: string): Promise<void>;
|
|
9
|
-
export declare function getFolders(dir: string): string[];
|
|
10
|
-
export declare const folders: {
|
|
11
|
-
isFolder: typeof isFolder;
|
|
12
|
-
doesFolderExist: typeof doesFolderExist;
|
|
13
|
-
createFolder: typeof createFolder;
|
|
14
|
-
getFolders: typeof getFolders;
|
|
15
|
-
};
|
package/dist/fs.d.ts
DELETED
package/dist/glob.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as glob } from 'fast-glob';
|
package/dist/hash.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Hash } from 'node:crypto';
|
|
3
|
-
export declare function hashFileOrDirectory(path: string, hash: Hash): void;
|
|
4
|
-
export declare function hashDirectory(directory: string): string;
|
|
5
|
-
export declare function hashPath(path: string): string;
|
|
6
|
-
export declare function hashPaths(paths: string | string[]): string;
|
package/dist/helpers.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './files';
|
|
2
|
-
export * from './folders';
|
|
3
|
-
export * from './hash';
|
|
4
|
-
export * from './helpers';
|
|
5
|
-
export * from './fs';
|
|
6
|
-
export * from './copy';
|
|
7
|
-
export * from './glob';
|
|
8
|
-
export * from './delete';
|
|
9
|
-
export * from './zip';
|
|
10
|
-
export * as storage from './storage';
|
package/dist/move.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Result } from '@stacksjs/error-handling';
|
|
2
|
-
interface MoveOptions {
|
|
3
|
-
overwrite?: boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare function move(src: string | string[], dest: string, options?: MoveOptions): Promise<Result<{
|
|
6
|
-
message: string;
|
|
7
|
-
}, Error>>;
|
|
8
|
-
export declare function rename(from: string, to: string, options?: MoveOptions): Promise<Result<{
|
|
9
|
-
message: string;
|
|
10
|
-
}, Error>>;
|
|
11
|
-
export {};
|
package/dist/storage.d.ts
DELETED
package/dist/visibility.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setVisibility(): string;
|
package/dist/zip.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="bun-types" />
|
|
2
|
-
/// <reference types="bun-types" />
|
|
3
|
-
import type { ZlibCompressionOptions } from 'bun';
|
|
4
|
-
interface ZipOptions {
|
|
5
|
-
cwd?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function zip(from: string | string[], to?: string, options?: ZipOptions): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
8
|
-
export declare function unzip(paths: string | string[]): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
9
|
-
export declare function archive(paths: string | string[]): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
10
|
-
export declare function unarchive(paths: string | string[]): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
11
|
-
export declare function compress(paths: string[]): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
12
|
-
export declare function decompress(paths: string | string[]): Promise<import("neverthrow").Result<Subprocess, CommandError>>;
|
|
13
|
-
export declare function gzipSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
|
|
14
|
-
export declare function gunzipSync(data: Uint8Array): Uint8Array;
|
|
15
|
-
export declare function deflateSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
|
|
16
|
-
export declare function inflateSync(data: Uint8Array): Uint8Array;
|
|
17
|
-
export {};
|