@stackbit/cms-core 1.0.0-develop.0 → 1.0.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.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class FileCache {
|
|
2
|
+
private readonly dirPath;
|
|
3
|
+
private readonly keyPrefix;
|
|
4
|
+
constructor({ dirPath, keyPrefix }: {
|
|
5
|
+
dirPath: string;
|
|
6
|
+
keyPrefix?: string;
|
|
7
|
+
});
|
|
8
|
+
get(key: string): Promise<unknown>;
|
|
9
|
+
set(key: string, value: unknown): Promise<void>;
|
|
10
|
+
remove(key: string): Promise<void>;
|
|
11
|
+
private filePathKey;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=file-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-cache.d.ts","sourceRoot":"","sources":["../../src/utils/file-cache.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBACvB,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAIrE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYlC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASxC,OAAO,CAAC,WAAW;CAGtB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.FileCache = void 0;
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const fse = __importStar(require("fs-extra"));
|
|
28
|
+
class FileCache {
|
|
29
|
+
constructor({ dirPath, keyPrefix }) {
|
|
30
|
+
this.dirPath = dirPath;
|
|
31
|
+
this.keyPrefix = keyPrefix !== null && keyPrefix !== void 0 ? keyPrefix : '';
|
|
32
|
+
}
|
|
33
|
+
async get(key) {
|
|
34
|
+
const fileName = this.filePathKey(key);
|
|
35
|
+
try {
|
|
36
|
+
const exists = await fse.pathExists(fileName);
|
|
37
|
+
if (!exists) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return fse.readJson(fileName);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async set(key, value) {
|
|
47
|
+
const fileName = this.filePathKey(key);
|
|
48
|
+
try {
|
|
49
|
+
return fse.outputJson(fileName, value);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async remove(key) {
|
|
56
|
+
const fileName = this.filePathKey(key);
|
|
57
|
+
try {
|
|
58
|
+
return await fse.remove(fileName);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
filePathKey(key) {
|
|
65
|
+
return path_1.default.join(this.dirPath, '.stackbit/cache', `${this.keyPrefix}${key}.json`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FileCache = FileCache;
|
|
69
|
+
//# sourceMappingURL=file-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-cache.js","sourceRoot":"","sources":["../../src/utils/file-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,8CAAgC;AAEhC,MAAa,SAAS;IAGlB,YAAY,EAAE,OAAO,EAAE,SAAS,EAA2C;QACvE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;IACrC,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI;YACA,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO;aACV;YACD,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACjC;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO;SACV;IACL,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAc;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI;YACA,OAAO,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC1C;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO;SACV;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,GAAW;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI;YACA,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACrC;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO;SACV;IACL,CAAC;IAEO,WAAW,CAAC,GAAW;QAC3B,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,OAAO,CAAC,CAAC;IACtF,CAAC;CACJ;AAvCD,8BAuCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackbit/cms-core",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "stackbit-dev",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@babel/parser": "^7.11.5",
|
|
26
26
|
"@babel/traverse": "^7.11.5",
|
|
27
27
|
"@iarna/toml": "^2.2.3",
|
|
28
|
-
"@stackbit/sdk": "1.0.0
|
|
29
|
-
"@stackbit/types": "0.10.14
|
|
30
|
-
"@stackbit/utils": "0.3.18
|
|
28
|
+
"@stackbit/sdk": "1.0.0",
|
|
29
|
+
"@stackbit/types": "0.10.14",
|
|
30
|
+
"@stackbit/utils": "0.3.18",
|
|
31
31
|
"chalk": "^4.0.1",
|
|
32
32
|
"content-engine": "0.0.19",
|
|
33
33
|
"esm": "^3.2.25",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"slugify": "^1.6.5",
|
|
44
44
|
"uuid": "^9.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "feac11d6542a64807536ff8a2768cfa62ca15d07"
|
|
47
47
|
}
|