@miniflare/storage-file
Advanced tools
Comparing version 2.0.0-rc.3 to 2.0.0-rc.4
@@ -0,15 +1,38 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
__markAsModule(target); | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
// packages/storage-file/src/index.ts | ||
import { existsSync } from "fs"; | ||
import path2 from "path"; | ||
import { | ||
MiniflareError, | ||
defaultClock, | ||
sanitisePath, | ||
viewToArray | ||
} from "@miniflare/shared"; | ||
import { LocalStorage } from "@miniflare/storage-memory"; | ||
__export(exports, { | ||
FileStorage: () => FileStorage, | ||
FileStorageError: () => FileStorageError | ||
}); | ||
var import_fs = __toModule(require("fs")); | ||
var import_path2 = __toModule(require("path")); | ||
var import_shared = __toModule(require("@miniflare/shared")); | ||
var import_storage_memory = __toModule(require("@miniflare/storage-memory")); | ||
// packages/storage-file/src/helpers.ts | ||
import fs from "fs/promises"; | ||
import path from "path"; | ||
var import_promises = __toModule(require("fs/promises")); | ||
var import_path = __toModule(require("path")); | ||
function onNotFound(promise, value) { | ||
@@ -23,13 +46,13 @@ return promise.catch((e) => { | ||
function readFile(filePath, decode) { | ||
return onNotFound(fs.readFile(filePath, decode && "utf8"), void 0); | ||
return onNotFound(import_promises.default.readFile(filePath, decode && "utf8"), void 0); | ||
} | ||
async function writeFile(filePath, data) { | ||
await fs.mkdir(path.dirname(filePath), { recursive: true }); | ||
await fs.writeFile(filePath, data, typeof data === "string" ? "utf8" : void 0); | ||
await import_promises.default.mkdir(import_path.default.dirname(filePath), { recursive: true }); | ||
await import_promises.default.writeFile(filePath, data, typeof data === "string" ? "utf8" : void 0); | ||
} | ||
function deleteFile(filePath) { | ||
return onNotFound(fs.unlink(filePath).then(() => true), false); | ||
return onNotFound(import_promises.default.unlink(filePath).then(() => true), false); | ||
} | ||
function readDir(filePath) { | ||
return onNotFound(fs.readdir(filePath), []); | ||
return onNotFound(import_promises.default.readdir(filePath), []); | ||
} | ||
@@ -39,4 +62,4 @@ async function* walk(rootPath) { | ||
for (const fileName of fileNames) { | ||
const filePath = path.join(rootPath, fileName); | ||
if ((await fs.stat(filePath)).isDirectory()) { | ||
const filePath = import_path.default.join(rootPath, fileName); | ||
if ((await import_promises.default.stat(filePath)).isDirectory()) { | ||
yield* walk(filePath); | ||
@@ -51,14 +74,14 @@ } else { | ||
var metaSuffix = ".meta.json"; | ||
var FileStorageError = class extends MiniflareError { | ||
var FileStorageError = class extends import_shared.MiniflareError { | ||
}; | ||
var FileStorage = class extends LocalStorage { | ||
constructor(root, sanitise = true, clock = defaultClock) { | ||
var FileStorage = class extends import_storage_memory.LocalStorage { | ||
constructor(root, sanitise = true, clock = import_shared.defaultClock) { | ||
super(clock); | ||
this.sanitise = sanitise; | ||
this.root = path2.resolve(root); | ||
this.root = import_path2.default.resolve(root); | ||
} | ||
root; | ||
keyPath(key) { | ||
const sanitisedKey = this.sanitise ? sanitisePath(key) : key; | ||
const filePath = path2.join(this.root, sanitisedKey); | ||
const sanitisedKey = this.sanitise ? (0, import_shared.sanitisePath)(key) : key; | ||
const filePath = import_path2.default.join(this.root, sanitisedKey); | ||
return [ | ||
@@ -77,3 +100,3 @@ filePath.startsWith(this.root) ? filePath : void 0, | ||
return; | ||
if (!existsSync(filePath)) | ||
if (!(0, import_fs.existsSync)(filePath)) | ||
return; | ||
@@ -93,3 +116,3 @@ const meta = await this.meta(filePath); | ||
return { | ||
value: viewToArray(value), | ||
value: (0, import_shared.viewToArray)(value), | ||
expiration: meta.expiration, | ||
@@ -155,6 +178,7 @@ metadata: meta.metadata | ||
}; | ||
export { | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
FileStorage, | ||
FileStorageError | ||
}; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@miniflare/storage-file", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0-rc.4", | ||
"description": "File-system storage module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -14,4 +14,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": "./dist/src/index.js", | ||
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
@@ -40,8 +39,8 @@ "files": [ | ||
"dependencies": { | ||
"@miniflare/shared": "2.0.0-rc.3", | ||
"@miniflare/storage-memory": "2.0.0-rc.3" | ||
"@miniflare/shared": "2.0.0-rc.4", | ||
"@miniflare/storage-memory": "2.0.0-rc.4" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0-rc.3" | ||
"@miniflare/shared-test": "2.0.0-rc.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11579
197
No
+ Added@miniflare/shared@2.0.0-rc.4(transitive)
+ Added@miniflare/storage-memory@2.0.0-rc.4(transitive)
- Removed@miniflare/shared@2.0.0-rc.3(transitive)
- Removed@miniflare/storage-memory@2.0.0-rc.3(transitive)
Updated@miniflare/shared@2.0.0-rc.4