@spinajs/fs 2.0.481 → 2.0.482
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/lib/cjs/cli/cat.d.ts +11 -0
- package/lib/cjs/cli/cat.d.ts.map +1 -0
- package/lib/cjs/cli/cat.js +40 -0
- package/lib/cjs/cli/cat.js.map +1 -0
- package/lib/cjs/cli/cp.d.ts +11 -0
- package/lib/cjs/cli/cp.d.ts.map +1 -0
- package/lib/cjs/cli/cp.js +41 -0
- package/lib/cjs/cli/cp.js.map +1 -0
- package/lib/cjs/cli/download.d.ts +7 -0
- package/lib/cjs/cli/download.d.ts.map +1 -0
- package/lib/cjs/cli/download.js +39 -0
- package/lib/cjs/cli/download.js.map +1 -0
- package/lib/cjs/cli/exists.d.ts +7 -0
- package/lib/cjs/cli/exists.d.ts.map +1 -0
- package/lib/cjs/cli/exists.js +39 -0
- package/lib/cjs/cli/exists.js.map +1 -0
- package/lib/cjs/cli/fs.d.ts +11 -0
- package/lib/cjs/cli/fs.d.ts.map +1 -1
- package/lib/cjs/cli/fs.js +47 -21
- package/lib/cjs/cli/fs.js.map +1 -1
- package/lib/cjs/cli/hash.d.ts +11 -0
- package/lib/cjs/cli/hash.d.ts.map +1 -0
- package/lib/cjs/cli/hash.js +40 -0
- package/lib/cjs/cli/hash.js.map +1 -0
- package/lib/cjs/cli/info.d.ts +7 -0
- package/lib/cjs/cli/info.d.ts.map +1 -0
- package/lib/cjs/cli/info.js +45 -0
- package/lib/cjs/cli/info.js.map +1 -0
- package/lib/cjs/cli/ls.d.ts +7 -0
- package/lib/cjs/cli/ls.d.ts.map +1 -0
- package/lib/cjs/cli/ls.js +40 -0
- package/lib/cjs/cli/ls.js.map +1 -0
- package/lib/cjs/cli/mkdir.d.ts +7 -0
- package/lib/cjs/cli/mkdir.d.ts.map +1 -0
- package/lib/cjs/cli/mkdir.js +39 -0
- package/lib/cjs/cli/mkdir.js.map +1 -0
- package/lib/cjs/cli/mv.d.ts +11 -0
- package/lib/cjs/cli/mv.d.ts.map +1 -0
- package/lib/cjs/cli/mv.js +41 -0
- package/lib/cjs/cli/mv.js.map +1 -0
- package/lib/cjs/cli/rm.d.ts +1 -6
- package/lib/cjs/cli/rm.d.ts.map +1 -1
- package/lib/cjs/cli/rm.js +14 -4
- package/lib/cjs/cli/rm.js.map +1 -1
- package/lib/cjs/cli/stat.d.ts +1 -5
- package/lib/cjs/cli/stat.d.ts.map +1 -1
- package/lib/cjs/cli/stat.js +20 -3
- package/lib/cjs/cli/stat.js.map +1 -1
- package/lib/cjs/cli/unzip.d.ts +11 -0
- package/lib/cjs/cli/unzip.d.ts.map +1 -0
- package/lib/cjs/cli/unzip.js +47 -0
- package/lib/cjs/cli/unzip.js.map +1 -0
- package/lib/cjs/cli/upload.d.ts +7 -0
- package/lib/cjs/cli/upload.d.ts.map +1 -0
- package/lib/cjs/cli/upload.js +40 -0
- package/lib/cjs/cli/upload.js.map +1 -0
- package/lib/cjs/cli/write.d.ts +13 -0
- package/lib/cjs/cli/write.d.ts.map +1 -0
- package/lib/cjs/cli/write.js +54 -0
- package/lib/cjs/cli/write.js.map +1 -0
- package/lib/cjs/cli/zip.d.ts +12 -0
- package/lib/cjs/cli/zip.d.ts.map +1 -0
- package/lib/cjs/cli/zip.js +51 -0
- package/lib/cjs/cli/zip.js.map +1 -0
- package/lib/cjs/config/fs.d.ts +9 -0
- package/lib/cjs/config/fs.d.ts.map +1 -0
- package/lib/cjs/config/fs.js +22 -0
- package/lib/cjs/config/fs.js.map +1 -0
- package/lib/cjs/file-hasher.d.ts +85 -5
- package/lib/cjs/file-hasher.d.ts.map +1 -1
- package/lib/cjs/file-hasher.js +106 -14
- package/lib/cjs/file-hasher.js.map +1 -1
- package/lib/cjs/file-info.d.ts +94 -5
- package/lib/cjs/file-info.d.ts.map +1 -1
- package/lib/cjs/file-info.js +267 -73
- package/lib/cjs/file-info.js.map +1 -1
- package/lib/cjs/fp.d.ts +80 -2
- package/lib/cjs/fp.d.ts.map +1 -1
- package/lib/cjs/fp.js +149 -3
- package/lib/cjs/fp.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +7 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +89 -12
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js +13 -13
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/local-provider.d.ts +51 -6
- package/lib/cjs/local-provider.d.ts.map +1 -1
- package/lib/cjs/local-provider.js +254 -76
- package/lib/cjs/local-provider.js.map +1 -1
- package/lib/cjs/temp-cleanup-strategy.d.ts +70 -0
- package/lib/cjs/temp-cleanup-strategy.d.ts.map +1 -0
- package/lib/cjs/temp-cleanup-strategy.js +157 -0
- package/lib/cjs/temp-cleanup-strategy.js.map +1 -0
- package/lib/cjs/temp-provider.d.ts +59 -0
- package/lib/cjs/temp-provider.d.ts.map +1 -0
- package/lib/cjs/temp-provider.js +150 -0
- package/lib/cjs/temp-provider.js.map +1 -0
- package/lib/mjs/cli/cat.d.ts +11 -0
- package/lib/mjs/cli/cat.d.ts.map +1 -0
- package/lib/mjs/cli/cat.js +37 -0
- package/lib/mjs/cli/cat.js.map +1 -0
- package/lib/mjs/cli/cp.d.ts +11 -0
- package/lib/mjs/cli/cp.d.ts.map +1 -0
- package/lib/mjs/cli/cp.js +38 -0
- package/lib/mjs/cli/cp.js.map +1 -0
- package/lib/mjs/cli/download.d.ts +7 -0
- package/lib/mjs/cli/download.d.ts.map +1 -0
- package/lib/mjs/cli/download.js +36 -0
- package/lib/mjs/cli/download.js.map +1 -0
- package/lib/mjs/cli/exists.d.ts +7 -0
- package/lib/mjs/cli/exists.d.ts.map +1 -0
- package/lib/mjs/cli/exists.js +36 -0
- package/lib/mjs/cli/exists.js.map +1 -0
- package/lib/mjs/cli/fs.d.ts +11 -1
- package/lib/mjs/cli/fs.d.ts.map +1 -1
- package/lib/mjs/cli/fs.js +43 -22
- package/lib/mjs/cli/fs.js.map +1 -1
- package/lib/mjs/cli/hash.d.ts +11 -0
- package/lib/mjs/cli/hash.d.ts.map +1 -0
- package/lib/mjs/cli/hash.js +37 -0
- package/lib/mjs/cli/hash.js.map +1 -0
- package/lib/mjs/cli/info.d.ts +7 -0
- package/lib/mjs/cli/info.d.ts.map +1 -0
- package/lib/mjs/cli/info.js +42 -0
- package/lib/mjs/cli/info.js.map +1 -0
- package/lib/mjs/cli/ls.d.ts +7 -0
- package/lib/mjs/cli/ls.d.ts.map +1 -0
- package/lib/mjs/cli/ls.js +37 -0
- package/lib/mjs/cli/ls.js.map +1 -0
- package/lib/mjs/cli/mkdir.d.ts +7 -0
- package/lib/mjs/cli/mkdir.d.ts.map +1 -0
- package/lib/mjs/cli/mkdir.js +36 -0
- package/lib/mjs/cli/mkdir.js.map +1 -0
- package/lib/mjs/cli/mv.d.ts +11 -0
- package/lib/mjs/cli/mv.d.ts.map +1 -0
- package/lib/mjs/cli/mv.js +38 -0
- package/lib/mjs/cli/mv.js.map +1 -0
- package/lib/mjs/cli/rm.d.ts +1 -6
- package/lib/mjs/cli/rm.d.ts.map +1 -1
- package/lib/mjs/cli/rm.js +15 -5
- package/lib/mjs/cli/rm.js.map +1 -1
- package/lib/mjs/cli/stat.d.ts +1 -5
- package/lib/mjs/cli/stat.d.ts.map +1 -1
- package/lib/mjs/cli/stat.js +21 -4
- package/lib/mjs/cli/stat.js.map +1 -1
- package/lib/mjs/cli/unzip.d.ts +11 -0
- package/lib/mjs/cli/unzip.d.ts.map +1 -0
- package/lib/mjs/cli/unzip.js +44 -0
- package/lib/mjs/cli/unzip.js.map +1 -0
- package/lib/mjs/cli/upload.d.ts +7 -0
- package/lib/mjs/cli/upload.d.ts.map +1 -0
- package/lib/mjs/cli/upload.js +37 -0
- package/lib/mjs/cli/upload.js.map +1 -0
- package/lib/mjs/cli/write.d.ts +13 -0
- package/lib/mjs/cli/write.d.ts.map +1 -0
- package/lib/mjs/cli/write.js +51 -0
- package/lib/mjs/cli/write.js.map +1 -0
- package/lib/mjs/cli/zip.d.ts +12 -0
- package/lib/mjs/cli/zip.d.ts.map +1 -0
- package/lib/mjs/cli/zip.js +48 -0
- package/lib/mjs/cli/zip.js.map +1 -0
- package/lib/mjs/config/fs.d.ts +9 -0
- package/lib/mjs/config/fs.d.ts.map +1 -0
- package/lib/mjs/config/fs.js +20 -0
- package/lib/mjs/config/fs.js.map +1 -0
- package/lib/mjs/file-hasher.d.ts +85 -5
- package/lib/mjs/file-hasher.d.ts.map +1 -1
- package/lib/mjs/file-hasher.js +106 -14
- package/lib/mjs/file-hasher.js.map +1 -1
- package/lib/mjs/file-info.d.ts +94 -5
- package/lib/mjs/file-info.d.ts.map +1 -1
- package/lib/mjs/file-info.js +233 -73
- package/lib/mjs/file-info.js.map +1 -1
- package/lib/mjs/fp.d.ts +80 -2
- package/lib/mjs/fp.d.ts.map +1 -1
- package/lib/mjs/fp.js +135 -4
- package/lib/mjs/fp.js.map +1 -1
- package/lib/mjs/index.d.ts +2 -1
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +8 -3
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +89 -12
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js +13 -13
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/local-provider.d.ts +51 -6
- package/lib/mjs/local-provider.d.ts.map +1 -1
- package/lib/mjs/local-provider.js +257 -79
- package/lib/mjs/local-provider.js.map +1 -1
- package/lib/mjs/temp-cleanup-strategy.d.ts +70 -0
- package/lib/mjs/temp-cleanup-strategy.d.ts.map +1 -0
- package/lib/mjs/temp-cleanup-strategy.js +153 -0
- package/lib/mjs/temp-cleanup-strategy.js.map +1 -0
- package/lib/mjs/temp-provider.d.ts +59 -0
- package/lib/mjs/temp-provider.d.ts.map +1 -0
- package/lib/mjs/temp-provider.js +147 -0
- package/lib/mjs/temp-provider.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +11 -6
- package/lib/cjs/local-temp-provider.d.ts +0 -18
- package/lib/cjs/local-temp-provider.d.ts.map +0 -1
- package/lib/cjs/local-temp-provider.js +0 -63
- package/lib/cjs/local-temp-provider.js.map +0 -1
- package/lib/mjs/local-temp-provider.d.ts +0 -18
- package/lib/mjs/local-temp-provider.d.ts.map +0 -1
- package/lib/mjs/local-temp-provider.js +0 -60
- package/lib/mjs/local-temp-provider.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsMvCommand = void 0;
|
|
13
|
+
const cli_1 = require("@spinajs/cli");
|
|
14
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const fs_js_1 = require("./fs.js");
|
|
17
|
+
let FsMvCommand = class FsMvCommand extends cli_1.CliCommand {
|
|
18
|
+
async execute(fsName, src, dst, options) {
|
|
19
|
+
await (0, fs_js_1.ensureProviders)();
|
|
20
|
+
try {
|
|
21
|
+
await (0, fp_js_1._move)(src, dst, fsName, options.dstFs);
|
|
22
|
+
this.Log.success(`Moved ${src} ( ${fsName} ) -> ${dst} ( ${options.dstFs ?? fsName} )`);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
this.Log.error(`Cannot move ${src}: ${err.message}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.FsMvCommand = FsMvCommand;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, log_common_1.Logger)('fs'),
|
|
32
|
+
__metadata("design:type", log_common_1.Log)
|
|
33
|
+
], FsMvCommand.prototype, "Log", void 0);
|
|
34
|
+
exports.FsMvCommand = FsMvCommand = __decorate([
|
|
35
|
+
(0, cli_1.Command)('fs-mv', 'Moves a file or directory, optionally between filesystems'),
|
|
36
|
+
(0, cli_1.Argument)('fs', true, 'Source filesystem name'),
|
|
37
|
+
(0, cli_1.Argument)('src', true, 'Source path ( relative to source fs )'),
|
|
38
|
+
(0, cli_1.Argument)('dst', true, 'Destination path'),
|
|
39
|
+
(0, cli_1.Option)('-d, --dst-fs <dstFs>', false, 'Destination filesystem name ( defaults to source fs )')
|
|
40
|
+
], FsMvCommand);
|
|
41
|
+
//# sourceMappingURL=mv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mv.js","sourceRoot":"","sources":["../../../src/cli/mv.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAqE;AACrE,oDAAkD;AAClD,oCAAiC;AACjC,mCAA0C;AAWnC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,gBAAU;IAIlC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,GAAW,EAAE,OAAkB;QAC/E,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,IAAA,aAAK,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7C,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC;QAC1F,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,GAAG,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF,CAAA;AAdY,kCAAW;AAEZ;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;wCAAC;sBAFR,WAAW;IALvB,IAAA,aAAO,EAAC,OAAO,EAAE,2DAA2D,CAAC;IAC7E,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,wBAAwB,CAAC;IAC9C,IAAA,cAAQ,EAAC,KAAK,EAAE,IAAI,EAAE,uCAAuC,CAAC;IAC9D,IAAA,cAAQ,EAAC,KAAK,EAAE,IAAI,EAAE,kBAAkB,CAAC;IACzC,IAAA,YAAM,EAAC,sBAAsB,EAAE,KAAK,EAAE,uDAAuD,CAAC;GAClF,WAAW,CAcvB"}
|
package/lib/cjs/cli/rm.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { CliCommand } from '@spinajs/cli';
|
|
2
2
|
import { Log } from '@spinajs/log-common';
|
|
3
|
-
interface EmailOptions {
|
|
4
|
-
name: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
7
3
|
export declare class FsRmCommand extends CliCommand {
|
|
8
4
|
protected Log: Log;
|
|
9
|
-
execute(
|
|
5
|
+
execute(fsName: string, path: string): Promise<void>;
|
|
10
6
|
}
|
|
11
|
-
export {};
|
|
12
7
|
//# sourceMappingURL=rm.d.ts.map
|
package/lib/cjs/cli/rm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../src/cli/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../src/cli/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAIlD,qBAGa,WAAY,SAAQ,UAAU;IAEzC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlE"}
|
package/lib/cjs/cli/rm.js
CHANGED
|
@@ -12,8 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FsRmCommand = void 0;
|
|
13
13
|
const cli_1 = require("@spinajs/cli");
|
|
14
14
|
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const fs_js_1 = require("./fs.js");
|
|
15
17
|
let FsRmCommand = class FsRmCommand extends cli_1.CliCommand {
|
|
16
|
-
async execute(
|
|
18
|
+
async execute(fsName, path) {
|
|
19
|
+
await (0, fs_js_1.ensureProviders)();
|
|
20
|
+
try {
|
|
21
|
+
await (0, fp_js_1._rm)(path, fsName);
|
|
22
|
+
this.Log.success(`Removed ${path} from filesystem ${fsName}`);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
this.Log.error(`Cannot remove ${path} from ${fsName}: ${err.message}`);
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
};
|
|
19
29
|
exports.FsRmCommand = FsRmCommand;
|
|
@@ -22,8 +32,8 @@ __decorate([
|
|
|
22
32
|
__metadata("design:type", log_common_1.Log)
|
|
23
33
|
], FsRmCommand.prototype, "Log", void 0);
|
|
24
34
|
exports.FsRmCommand = FsRmCommand = __decorate([
|
|
25
|
-
(0, cli_1.Command)('fs-
|
|
26
|
-
(0, cli_1.
|
|
27
|
-
(0, cli_1.
|
|
35
|
+
(0, cli_1.Command)('fs-rm', 'Deletes a file or directory ( recursively ) from a filesystem'),
|
|
36
|
+
(0, cli_1.Argument)('fs', true, 'Name of filesystem to use'),
|
|
37
|
+
(0, cli_1.Argument)('path', true, 'Path to remove ( relative to selected fs base dir )')
|
|
28
38
|
], FsRmCommand);
|
|
29
39
|
//# sourceMappingURL=rm.js.map
|
package/lib/cjs/cli/rm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rm.js","sourceRoot":"","sources":["../../../src/cli/rm.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"rm.js","sourceRoot":"","sources":["../../../src/cli/rm.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAA6D;AAC7D,oDAAkD;AAClD,oCAA+B;AAC/B,mCAA0C;AAKnC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,gBAAU;IAIlC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY;QAC/C,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,IAAA,WAAG,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,oBAAoB,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,IAAI,SAAS,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF,CAAA;AAdY,kCAAW;AAEZ;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;wCAAC;sBAFR,WAAW;IAHvB,IAAA,aAAO,EAAC,OAAO,EAAE,+DAA+D,CAAC;IACjF,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,2BAA2B,CAAC;IACjD,IAAA,cAAQ,EAAC,MAAM,EAAE,IAAI,EAAE,qDAAqD,CAAC;GACjE,WAAW,CAcvB"}
|
package/lib/cjs/cli/stat.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { CliCommand } from '@spinajs/cli';
|
|
2
2
|
import { Log } from '@spinajs/log-common';
|
|
3
|
-
interface FsStatOptions {
|
|
4
|
-
name?: string;
|
|
5
|
-
}
|
|
6
3
|
export declare class FsStatCommand extends CliCommand {
|
|
7
4
|
protected Log: Log;
|
|
8
|
-
execute(
|
|
5
|
+
execute(fsName: string, path: string): Promise<void>;
|
|
9
6
|
}
|
|
10
|
-
export {};
|
|
11
7
|
//# sourceMappingURL=stat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat.d.ts","sourceRoot":"","sources":["../../../src/cli/stat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"stat.d.ts","sourceRoot":"","sources":["../../../src/cli/stat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAIlD,qBAGa,aAAc,SAAQ,UAAU;IAE3C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAelE"}
|
package/lib/cjs/cli/stat.js
CHANGED
|
@@ -12,8 +12,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FsStatCommand = void 0;
|
|
13
13
|
const cli_1 = require("@spinajs/cli");
|
|
14
14
|
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const fs_js_1 = require("./fs.js");
|
|
15
17
|
let FsStatCommand = class FsStatCommand extends cli_1.CliCommand {
|
|
16
|
-
async execute(
|
|
18
|
+
async execute(fsName, path) {
|
|
19
|
+
await (0, fs_js_1.ensureProviders)();
|
|
20
|
+
try {
|
|
21
|
+
const stat = await (0, fp_js_1._stat)(path, fsName);
|
|
22
|
+
this.Log.info(`Stat for ${path} ( fs: ${fsName} ):`);
|
|
23
|
+
this.Log.info(` type: ${stat.IsDirectory ? 'directory' : 'file'}`);
|
|
24
|
+
this.Log.info(` size: ${stat.Size ?? 'n/a'} bytes`);
|
|
25
|
+
this.Log.info(` created: ${stat.CreationTime?.toISO() ?? 'n/a'}`);
|
|
26
|
+
this.Log.info(` modified: ${stat.ModifiedTime?.toISO() ?? 'n/a'}`);
|
|
27
|
+
this.Log.info(` accessed: ${stat.AccessTime?.toISO() ?? 'n/a'}`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
this.Log.error(`Cannot stat ${path} on ${fsName}: ${err.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
17
33
|
};
|
|
18
34
|
exports.FsStatCommand = FsStatCommand;
|
|
19
35
|
__decorate([
|
|
@@ -21,7 +37,8 @@ __decorate([
|
|
|
21
37
|
__metadata("design:type", log_common_1.Log)
|
|
22
38
|
], FsStatCommand.prototype, "Log", void 0);
|
|
23
39
|
exports.FsStatCommand = FsStatCommand = __decorate([
|
|
24
|
-
(0, cli_1.Command)('fs-stat', '
|
|
25
|
-
(0, cli_1.
|
|
40
|
+
(0, cli_1.Command)('fs-stat', 'Prints statistics for a file or directory'),
|
|
41
|
+
(0, cli_1.Argument)('fs', true, 'Name of filesystem to use'),
|
|
42
|
+
(0, cli_1.Argument)('path', true, 'Path to stat ( relative to selected fs base dir )')
|
|
26
43
|
], FsStatCommand);
|
|
27
44
|
//# sourceMappingURL=stat.js.map
|
package/lib/cjs/cli/stat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/cli/stat.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/cli/stat.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAA6D;AAC7D,oDAAkD;AAClD,oCAAiC;AACjC,mCAA0C;AAKnC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,gBAAU;IAIpC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY;QAC/C,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAA,aAAK,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,UAAU,MAAM,KAAK,CAAC,CAAC;YACrD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,IAAI,KAAK,QAAQ,CAAC,CAAC;YACrD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;QACpE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF,CAAA;AAnBY,sCAAa;AAEd;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;0CAAC;wBAFR,aAAa;IAHzB,IAAA,aAAO,EAAC,SAAS,EAAE,2CAA2C,CAAC;IAC/D,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,2BAA2B,CAAC;IACjD,IAAA,cAAQ,EAAC,MAAM,EAAE,IAAI,EAAE,mDAAmD,CAAC;GAC/D,aAAa,CAmBzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
interface UnzipOptions {
|
|
4
|
+
dstFs?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class FsUnzipCommand extends CliCommand {
|
|
7
|
+
protected Log: Log;
|
|
8
|
+
execute(fsName: string, src: string, dst: string | undefined, options: UnzipOptions): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=unzip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unzip.d.ts","sourceRoot":"","sources":["../../../src/cli/unzip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAC;AACrE,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAKlD,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAKa,cAAe,SAAQ,UAAU;IAE5C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjH"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsUnzipCommand = void 0;
|
|
13
|
+
const cli_1 = require("@spinajs/cli");
|
|
14
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
17
|
+
const fs_js_1 = require("./fs.js");
|
|
18
|
+
let FsUnzipCommand = class FsUnzipCommand extends cli_1.CliCommand {
|
|
19
|
+
async execute(fsName, src, dst, options) {
|
|
20
|
+
await (0, fs_js_1.ensureProviders)();
|
|
21
|
+
try {
|
|
22
|
+
const provider = (0, fp_js_1._fs)(fsName)();
|
|
23
|
+
if (!provider) {
|
|
24
|
+
throw new exceptions_1.IOFail(`Filesystem ${fsName} not found`);
|
|
25
|
+
}
|
|
26
|
+
const dstFs = options.dstFs ? (0, fp_js_1._fs)(options.dstFs)() : undefined;
|
|
27
|
+
const out = await provider.unzip(src, dst, dstFs);
|
|
28
|
+
this.Log.success(`Extracted ${src} -> ${out} ( fs: ${options.dstFs ?? fsName} )`);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
this.Log.error(`Cannot unzip ${src} on ${fsName}: ${err.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.FsUnzipCommand = FsUnzipCommand;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, log_common_1.Logger)('fs'),
|
|
38
|
+
__metadata("design:type", log_common_1.Log)
|
|
39
|
+
], FsUnzipCommand.prototype, "Log", void 0);
|
|
40
|
+
exports.FsUnzipCommand = FsUnzipCommand = __decorate([
|
|
41
|
+
(0, cli_1.Command)('fs-unzip', 'Extracts a zip archive'),
|
|
42
|
+
(0, cli_1.Argument)('fs', true, 'Filesystem that contains the archive'),
|
|
43
|
+
(0, cli_1.Argument)('src', true, 'Path to the zip file ( relative to source fs )'),
|
|
44
|
+
(0, cli_1.Argument)('dst', false, 'Destination directory ( relative to destination fs )'),
|
|
45
|
+
(0, cli_1.Option)('-d, --dst-fs <dstFs>', false, 'Destination filesystem to extract into ( defaults to source fs )')
|
|
46
|
+
], FsUnzipCommand);
|
|
47
|
+
//# sourceMappingURL=unzip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unzip.js","sourceRoot":"","sources":["../../../src/cli/unzip.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAqE;AACrE,oDAAkD;AAClD,oCAA+B;AAC/B,oDAA6C;AAC7C,mCAA0C;AAWnC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,gBAAU;IAIrC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,GAAuB,EAAE,OAAqB;QAC9F,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,CAAC;YAE/B,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,mBAAM,CAAC,cAAc,MAAM,YAAY,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,WAAG,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAElD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,GAAG,OAAO,GAAG,UAAU,OAAO,CAAC,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,GAAG,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF,CAAA;AAtBY,wCAAc;AAEf;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;2CAAC;yBAFR,cAAc;IAL1B,IAAA,aAAO,EAAC,UAAU,EAAE,wBAAwB,CAAC;IAC7C,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,sCAAsC,CAAC;IAC5D,IAAA,cAAQ,EAAC,KAAK,EAAE,IAAI,EAAE,gDAAgD,CAAC;IACvE,IAAA,cAAQ,EAAC,KAAK,EAAE,KAAK,EAAE,sDAAsD,CAAC;IAC9E,IAAA,YAAM,EAAC,sBAAsB,EAAE,KAAK,EAAE,kEAAkE,CAAC;GAC7F,cAAc,CAsB1B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
export declare class FsUploadCommand extends CliCommand {
|
|
4
|
+
protected Log: Log;
|
|
5
|
+
execute(fsName: string, src: string, dst?: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/cli/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAIlD,qBAIa,eAAgB,SAAQ,UAAU;IAE7C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAU/E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsUploadCommand = void 0;
|
|
13
|
+
const cli_1 = require("@spinajs/cli");
|
|
14
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const fs_js_1 = require("./fs.js");
|
|
17
|
+
let FsUploadCommand = class FsUploadCommand extends cli_1.CliCommand {
|
|
18
|
+
async execute(fsName, src, dst) {
|
|
19
|
+
await (0, fs_js_1.ensureProviders)();
|
|
20
|
+
try {
|
|
21
|
+
await (0, fp_js_1._upload)(src, dst, fsName);
|
|
22
|
+
this.Log.success(`Uploaded ${src} -> ${dst ?? '( basename )'} ( fs: ${fsName} )`);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
this.Log.error(`Cannot upload ${src} to ${fsName}: ${err.message}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.FsUploadCommand = FsUploadCommand;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, log_common_1.Logger)('fs'),
|
|
32
|
+
__metadata("design:type", log_common_1.Log)
|
|
33
|
+
], FsUploadCommand.prototype, "Log", void 0);
|
|
34
|
+
exports.FsUploadCommand = FsUploadCommand = __decorate([
|
|
35
|
+
(0, cli_1.Command)('fs-upload', 'Uploads a local file into a filesystem'),
|
|
36
|
+
(0, cli_1.Argument)('fs', true, 'Destination filesystem name'),
|
|
37
|
+
(0, cli_1.Argument)('src', true, 'Local source file ( absolute path )'),
|
|
38
|
+
(0, cli_1.Argument)('dst', false, 'Destination path ( defaults to source file name )')
|
|
39
|
+
], FsUploadCommand);
|
|
40
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/cli/upload.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAA6D;AAC7D,oDAAkD;AAClD,oCAAmC;AACnC,mCAA0C;AAMnC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,gBAAU;IAItC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,GAAY;QAC5D,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,OAAO,GAAG,IAAI,cAAc,UAAU,MAAM,IAAI,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,GAAG,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF,CAAA;AAdY,0CAAe;AAEhB;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;4CAAC;0BAFR,eAAe;IAJ3B,IAAA,aAAO,EAAC,WAAW,EAAE,wCAAwC,CAAC;IAC9D,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,6BAA6B,CAAC;IACnD,IAAA,cAAQ,EAAC,KAAK,EAAE,IAAI,EAAE,qCAAqC,CAAC;IAC5D,IAAA,cAAQ,EAAC,KAAK,EAAE,KAAK,EAAE,mDAAmD,CAAC;GAC/D,eAAe,CAc3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
interface WriteOptions {
|
|
4
|
+
content?: string;
|
|
5
|
+
fromFile?: string;
|
|
6
|
+
encoding: BufferEncoding;
|
|
7
|
+
}
|
|
8
|
+
export declare class FsWriteCommand extends CliCommand {
|
|
9
|
+
protected Log: Log;
|
|
10
|
+
execute(fsName: string, path: string, options: WriteOptions): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/cli/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAC;AACrE,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAMlD,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,qBAMa,cAAe,SAAQ,UAAU;IAE5C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsWriteCommand = void 0;
|
|
13
|
+
const cli_1 = require("@spinajs/cli");
|
|
14
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
17
|
+
const fp_js_1 = require("../fp.js");
|
|
18
|
+
const fs_js_1 = require("./fs.js");
|
|
19
|
+
let FsWriteCommand = class FsWriteCommand extends cli_1.CliCommand {
|
|
20
|
+
async execute(fsName, path, options) {
|
|
21
|
+
await (0, fs_js_1.ensureProviders)();
|
|
22
|
+
try {
|
|
23
|
+
if (options.fromFile) {
|
|
24
|
+
// binary-safe: read as buffer and write without re-encoding
|
|
25
|
+
const data = (0, fs_1.readFileSync)(options.fromFile);
|
|
26
|
+
await (0, fp_js_1._write)(path, data, undefined, fsName);
|
|
27
|
+
}
|
|
28
|
+
else if (options.content !== undefined) {
|
|
29
|
+
await (0, fp_js_1._write)(path, options.content, options.encoding, fsName);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new exceptions_1.InvalidArgument('Provide content with --content or --from-file');
|
|
33
|
+
}
|
|
34
|
+
this.Log.success(`Wrote ${path} ( fs: ${fsName} )`);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
this.Log.error(`Cannot write ${path} on ${fsName}: ${err.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.FsWriteCommand = FsWriteCommand;
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, log_common_1.Logger)('fs'),
|
|
44
|
+
__metadata("design:type", log_common_1.Log)
|
|
45
|
+
], FsWriteCommand.prototype, "Log", void 0);
|
|
46
|
+
exports.FsWriteCommand = FsWriteCommand = __decorate([
|
|
47
|
+
(0, cli_1.Command)('fs-write', 'Writes content to a file ( from inline text or a local file )'),
|
|
48
|
+
(0, cli_1.Argument)('fs', true, 'Destination filesystem name'),
|
|
49
|
+
(0, cli_1.Argument)('path', true, 'Path to file ( relative to selected fs base dir )'),
|
|
50
|
+
(0, cli_1.Option)('-c, --content <content>', false, 'Inline text content to write'),
|
|
51
|
+
(0, cli_1.Option)('-f, --from-file <fromFile>', false, 'Local file whose content will be written'),
|
|
52
|
+
(0, cli_1.Option)('-e, --encoding <encoding>', false, 'Encoding used for inline content', 'utf-8')
|
|
53
|
+
], FsWriteCommand);
|
|
54
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/cli/write.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAqE;AACrE,oDAAkD;AAClD,2BAAkC;AAClC,oDAAsD;AACtD,oCAAkC;AAClC,mCAA0C;AAcnC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,gBAAU;IAIrC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY,EAAE,OAAqB;QACtE,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,4DAA4D;gBAC5D,MAAM,IAAI,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC5C,MAAM,IAAA,cAAM,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAC9C,CAAC;iBAAM,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACzC,MAAM,IAAA,cAAM,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,4BAAe,CAAC,+CAA+C,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,UAAU,MAAM,IAAI,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,IAAI,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,wCAAc;AAEf;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;2CAAC;yBAFR,cAAc;IAN1B,IAAA,aAAO,EAAC,UAAU,EAAE,+DAA+D,CAAC;IACpF,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,6BAA6B,CAAC;IACnD,IAAA,cAAQ,EAAC,MAAM,EAAE,IAAI,EAAE,mDAAmD,CAAC;IAC3E,IAAA,YAAM,EAAC,yBAAyB,EAAE,KAAK,EAAE,8BAA8B,CAAC;IACxE,IAAA,YAAM,EAAC,4BAA4B,EAAE,KAAK,EAAE,0CAA0C,CAAC;IACvF,IAAA,YAAM,EAAC,2BAA2B,EAAE,KAAK,EAAE,kCAAkC,EAAE,OAAO,CAAC;GAC3E,cAAc,CAuB1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
interface ZipOptions {
|
|
4
|
+
out?: string;
|
|
5
|
+
dstFs?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class FsZipCommand extends CliCommand {
|
|
8
|
+
protected Log: Log;
|
|
9
|
+
execute(fsName: string, paths: string, options: ZipOptions): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../../src/cli/zip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAC;AACrE,OAAO,EAAU,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAKlD,UAAU,UAAU;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAKa,YAAa,SAAQ,UAAU;IAE1C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEN,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBxF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsZipCommand = void 0;
|
|
13
|
+
const cli_1 = require("@spinajs/cli");
|
|
14
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
15
|
+
const fp_js_1 = require("../fp.js");
|
|
16
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
17
|
+
const fs_js_1 = require("./fs.js");
|
|
18
|
+
let FsZipCommand = class FsZipCommand extends cli_1.CliCommand {
|
|
19
|
+
async execute(fsName, paths, options) {
|
|
20
|
+
await (0, fs_js_1.ensureProviders)();
|
|
21
|
+
try {
|
|
22
|
+
const provider = (0, fp_js_1._fs)(fsName)();
|
|
23
|
+
if (!provider) {
|
|
24
|
+
throw new exceptions_1.IOFail(`Filesystem ${fsName} not found`);
|
|
25
|
+
}
|
|
26
|
+
const list = paths
|
|
27
|
+
.split(',')
|
|
28
|
+
.map((p) => p.trim())
|
|
29
|
+
.filter((p) => p.length > 0);
|
|
30
|
+
const dstFs = options.dstFs ? (0, fp_js_1._fs)(options.dstFs)() : undefined;
|
|
31
|
+
const result = await provider.zip(list, dstFs, options.out);
|
|
32
|
+
this.Log.success(`Zipped ${list.length} path(s) -> ${result.asFilePath()} ( fs: ${result.fs.Name} )`);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
this.Log.error(`Cannot zip on ${fsName}: ${err.message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.FsZipCommand = FsZipCommand;
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, log_common_1.Logger)('fs'),
|
|
42
|
+
__metadata("design:type", log_common_1.Log)
|
|
43
|
+
], FsZipCommand.prototype, "Log", void 0);
|
|
44
|
+
exports.FsZipCommand = FsZipCommand = __decorate([
|
|
45
|
+
(0, cli_1.Command)('fs-zip', 'Compresses files / directories into a zip archive'),
|
|
46
|
+
(0, cli_1.Argument)('fs', true, 'Source filesystem name'),
|
|
47
|
+
(0, cli_1.Argument)('paths', true, 'Comma separated paths to compress ( relative to source fs )'),
|
|
48
|
+
(0, cli_1.Option)('-o, --out <out>', false, 'Output zip file name ( relative to destination fs )'),
|
|
49
|
+
(0, cli_1.Option)('-d, --dst-fs <dstFs>', false, 'Destination filesystem for the archive ( default fs-temp )')
|
|
50
|
+
], FsZipCommand);
|
|
51
|
+
//# sourceMappingURL=zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../src/cli/zip.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAqE;AACrE,oDAAkD;AAClD,oCAA+B;AAC/B,oDAA6C;AAC7C,mCAA0C;AAYnC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,gBAAU;IAInC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,KAAa,EAAE,OAAmB;QACrE,MAAM,IAAA,uBAAe,GAAE,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,WAAG,EAAC,MAAM,CAAC,EAAE,CAAC;YAE/B,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,mBAAM,CAAC,cAAc,MAAM,YAAY,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,IAAI,GAAG,KAAK;iBACf,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;iBACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,WAAG,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/D,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,MAAM,eAAe,MAAM,CAAC,UAAU,EAAE,UAAU,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;QACxG,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF,CAAA;AA3BY,oCAAY;AAEb;IADT,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACE,gBAAG;yCAAC;uBAFR,YAAY;IALxB,IAAA,aAAO,EAAC,QAAQ,EAAE,mDAAmD,CAAC;IACtE,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,wBAAwB,CAAC;IAC9C,IAAA,cAAQ,EAAC,OAAO,EAAE,IAAI,EAAE,6DAA6D,CAAC;IACtF,IAAA,YAAM,EAAC,iBAAiB,EAAE,KAAK,EAAE,qDAAqD,CAAC;IACvF,IAAA,YAAM,EAAC,sBAAsB,EAAE,KAAK,EAAE,4DAA4D,CAAC;GACvF,YAAY,CA2BxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/config/fs.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,EAAE;;;;;;CAOP,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
function dir(path) {
|
|
5
|
+
const inCommonJs = typeof module !== 'undefined';
|
|
6
|
+
return [
|
|
7
|
+
// installed as a dependency
|
|
8
|
+
(0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(process.env.WORKSPACE_ROOT_PATH ?? process.cwd(), 'node_modules', '@spinajs', 'fs', 'lib', inCommonJs ? 'cjs' : 'mjs', path))),
|
|
9
|
+
// one up if we run from app or build folder
|
|
10
|
+
(0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(process.env.WORKSPACE_ROOT_PATH ?? process.cwd(), '../', 'node_modules', '@spinajs', 'fs', 'lib', inCommonJs ? 'cjs' : 'mjs', path))),
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
const fs = {
|
|
14
|
+
system: {
|
|
15
|
+
dirs: {
|
|
16
|
+
// register fs cli commands so they are discovered by @spinajs/cli
|
|
17
|
+
cli: [...dir('cli')],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
exports.default = fs;
|
|
22
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/config/fs.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IACjD,OAAO;QACL,4BAA4B;QAC5B,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAErJ,4CAA4C;QAC5C,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;KAC7J,CAAC;AACJ,CAAC;AAED,MAAM,EAAE,GAAG;IACT,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,kEAAkE;YAClE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;SACrB;KACF;CACF,CAAC;AAEF,kBAAe,EAAE,CAAC"}
|
package/lib/cjs/file-hasher.d.ts
CHANGED
|
@@ -1,11 +1,91 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
1
|
+
import crypto, { BinaryToTextEncoding } from 'crypto';
|
|
2
|
+
import { IOFail } from '@spinajs/exceptions';
|
|
2
3
|
import { FileHasher } from './interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Default {@link FileHasher} implementation backed by node's `crypto` module.
|
|
6
|
+
*
|
|
7
|
+
* The algorithm is fixed per instance and provided as the first constructor
|
|
8
|
+
* argument ( eg. `DI.resolve(FileHasher, ['md5'])` ). When no algorithm is
|
|
9
|
+
* given it falls back to the value configured under `fs.hasher.defaultAlgorithm`,
|
|
10
|
+
* and finally to {@link DEFAULT_ALGORITHM} ( sha256 ).
|
|
11
|
+
*
|
|
12
|
+
* Instances are cached per algorithm via {@link PerInstanceCheck} /
|
|
13
|
+
* {@link __checkInstance__}, so resolving the same algorithm twice reuses the
|
|
14
|
+
* same hasher while different algorithms get distinct instances.
|
|
15
|
+
*/
|
|
3
16
|
export declare class DefaultFileHasher extends FileHasher {
|
|
4
|
-
|
|
17
|
+
Algorithm?: string | undefined;
|
|
5
18
|
HashOptions?: crypto.HashOptions | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Default algorithm read from configuration ( `fs.hasher.defaultAlgorithm` ),
|
|
21
|
+
* falling back to {@link DEFAULT_ALGORITHM} when the key is not set.
|
|
22
|
+
*
|
|
23
|
+
* Exposed as a lazily evaluated config property so both the constructor and
|
|
24
|
+
* {@link __checkInstance__} resolve the default the same way.
|
|
25
|
+
*/
|
|
26
|
+
protected ConfiguredAlgorithm: string;
|
|
27
|
+
/**
|
|
28
|
+
* Per-instance cache predicate used by {@link PerInstanceCheck}.
|
|
29
|
+
*
|
|
30
|
+
* Returns `true` when this instance was created for the algorithm requested in
|
|
31
|
+
* `creationOptions`. The requested algorithm is resolved exactly like the
|
|
32
|
+
* constructor does ( explicit arg, else the configured default ), so cached
|
|
33
|
+
* instances match reliably.
|
|
34
|
+
*
|
|
35
|
+
* @param creationOptions constructor arguments the container is resolving with
|
|
36
|
+
*/
|
|
6
37
|
__checkInstance__(creationOptions: any): boolean;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
38
|
+
/**
|
|
39
|
+
* @param Algorithm hash algorithm to use ( eg. `sha256`, `md5` ). When omitted,
|
|
40
|
+
* the configured default ( `fs.hasher.defaultAlgorithm` ) or
|
|
41
|
+
* sha256 is used.
|
|
42
|
+
* @param HashOptions optional node `crypto` hash options ( eg. `outputLength`
|
|
43
|
+
* for XOF algorithms such as shake256 )
|
|
44
|
+
*/
|
|
45
|
+
constructor(Algorithm?: string | undefined, HashOptions?: crypto.HashOptions | undefined);
|
|
46
|
+
/**
|
|
47
|
+
* Creates a `crypto.Hash` for the configured algorithm.
|
|
48
|
+
*
|
|
49
|
+
* The algorithm is validated against the platform's supported hashes first so
|
|
50
|
+
* an unsupported/typo'd algorithm produces a clear {@link IOFail} instead of a
|
|
51
|
+
* cryptic native crypto error.
|
|
52
|
+
*
|
|
53
|
+
* @throws {IOFail} when the configured algorithm is not supported
|
|
54
|
+
*/
|
|
55
|
+
protected createHasher(): crypto.Hash;
|
|
56
|
+
/**
|
|
57
|
+
* Hashes the content of a file by streaming it through the hash.
|
|
58
|
+
*
|
|
59
|
+
* @param pathToFile absolute path to the file to hash
|
|
60
|
+
* @param encoding digest output encoding ( default `hex` )
|
|
61
|
+
* @returns the digest string in the requested encoding
|
|
62
|
+
* @throws {IOFail} when the file does not exist, the algorithm is unsupported,
|
|
63
|
+
* or the file cannot be read
|
|
64
|
+
*/
|
|
65
|
+
hash(pathToFile: string, encoding?: BinaryToTextEncoding): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Consumes a readable stream through a fresh hasher and resolves with the
|
|
68
|
+
* digest. Stream errors are wrapped by `wrapError` so file and raw-stream
|
|
69
|
+
* callers surface their own context.
|
|
70
|
+
*/
|
|
71
|
+
protected digestStream(stream: NodeJS.ReadableStream, encoding: BinaryToTextEncoding, wrapError: (err: Error) => IOFail): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Hashes raw in-memory data.
|
|
74
|
+
*
|
|
75
|
+
* @param data string or binary data to hash
|
|
76
|
+
* @param encoding digest output encoding ( default `hex` )
|
|
77
|
+
* @returns the digest string in the requested encoding
|
|
78
|
+
* @throws {IOFail} when the configured algorithm is unsupported
|
|
79
|
+
*/
|
|
80
|
+
hashData(data: string | Uint8Array, encoding?: BinaryToTextEncoding): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Hashes the content of a readable stream by consuming it to the end.
|
|
83
|
+
*
|
|
84
|
+
* @param stream readable stream to consume
|
|
85
|
+
* @param encoding digest output encoding ( default `hex` )
|
|
86
|
+
* @returns the digest string in the requested encoding
|
|
87
|
+
* @throws {IOFail} when the configured algorithm is unsupported or the stream errors
|
|
88
|
+
*/
|
|
89
|
+
hashStream(stream: NodeJS.ReadableStream, encoding?: BinaryToTextEncoding): Promise<string>;
|
|
10
90
|
}
|
|
11
91
|
//# sourceMappingURL=file-hasher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-hasher.d.ts","sourceRoot":"","sources":["../../src/file-hasher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-hasher.d.ts","sourceRoot":"","sources":["../../src/file-hasher.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C;;;;;;;;;;;GAWG;AACH,qBAEa,iBAAkB,SAAQ,UAAU;IAmC5B,SAAS,CAAC,EAAE,MAAM;IAAS,WAAW,CAAC,EAAE,MAAM,CAAC,WAAW;IAlC9E;;;;;;OAMG;IAEH,SAAS,CAAC,mBAAmB,EAAG,MAAM,CAAC;IAEvC;;;;;;;;;OASG;IAEI,iBAAiB,CAAC,eAAe,EAAE,GAAG,GAAG,OAAO;IAMvD;;;;;;OAMG;gBACgB,SAAS,CAAC,EAAE,MAAM,YAAA,EAAS,WAAW,CAAC,EAAE,MAAM,CAAC,WAAW,YAAA;IAM9E;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI;IAUrC;;;;;;;;OAQG;IACU,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAE,oBAA4B,GAAG,OAAO,CAAC,MAAM,CAAC;IAY9F;;;;OAIG;IACH,SAAS,CAAC,YAAY,CACpB,MAAM,EAAE,MAAM,CAAC,cAAc,EAC7B,QAAQ,EAAE,oBAAoB,EAC9B,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,MAAM,GAChC,OAAO,CAAC,MAAM,CAAC;IAWlB;;;;;;;OAOG;IACU,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,GAAE,oBAA4B,GAAG,OAAO,CAAC,MAAM,CAAC;IAMzG;;;;;;;OAOG;IACU,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,QAAQ,GAAE,oBAA4B,GAAG,OAAO,CAAC,MAAM,CAAC;CAGhH"}
|