@tomsher/cms-theme-kit 0.0.0-stage → 0.1.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/bin.js +1078 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-6NVYKM2E.js +219 -0
- package/dist/chunk-6NVYKM2E.js.map +1 -0
- package/dist/chunk-ND62XRUU.js +1749 -0
- package/dist/chunk-ND62XRUU.js.map +1 -0
- package/dist/chunk-TN3DQWJE.js +439 -0
- package/dist/chunk-TN3DQWJE.js.map +1 -0
- package/dist/chunk-UDJL2R66.js +158 -0
- package/dist/chunk-UDJL2R66.js.map +1 -0
- package/dist/chunk-YAYCHT4W.js +56 -0
- package/dist/chunk-YAYCHT4W.js.map +1 -0
- package/dist/data-source-CKDBOWKF.js +16 -0
- package/dist/data-source-CKDBOWKF.js.map +1 -0
- package/dist/server-SWGQTMET.js +5600 -0
- package/dist/server-SWGQTMET.js.map +1 -0
- package/dist/static-server-BTUWXORJ.js +196 -0
- package/dist/static-server-BTUWXORJ.js.map +1 -0
- package/package.json +36 -5
- package/README.md +0 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
liquidThemeAllowedDirectories,
|
|
4
|
+
sha256Hex
|
|
5
|
+
} from "./chunk-TN3DQWJE.js";
|
|
6
|
+
|
|
7
|
+
// src/lib/theme-files.ts
|
|
8
|
+
import { readdir, readFile } from "fs/promises";
|
|
9
|
+
import { join, relative, sep } from "path";
|
|
10
|
+
var textExtensions = [".liquid", ".html", ".json", ".css", ".js", ".svg", ".txt"];
|
|
11
|
+
var isPushablePath = (relativePath) => {
|
|
12
|
+
const segments = relativePath.split("/");
|
|
13
|
+
if (segments.length < 2) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return liquidThemeAllowedDirectories.includes(segments[0]);
|
|
20
|
+
};
|
|
21
|
+
var isTextPath = (relativePath) => {
|
|
22
|
+
const lower = relativePath.toLowerCase();
|
|
23
|
+
return textExtensions.some((extension) => lower.endsWith(extension));
|
|
24
|
+
};
|
|
25
|
+
var readLocalTheme = async (rootDir) => {
|
|
26
|
+
const entries = await readdir(rootDir, { recursive: true, withFileTypes: true });
|
|
27
|
+
const files = [];
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (!entry.isFile()) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const absolutePath = join(entry.parentPath, entry.name);
|
|
33
|
+
const path = relative(rootDir, absolutePath).split(sep).join("/");
|
|
34
|
+
if (!isPushablePath(path)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const bytes = await readFile(absolutePath);
|
|
38
|
+
files.push({ path, bytes, hash: sha256Hex(bytes) });
|
|
39
|
+
}
|
|
40
|
+
return files.sort((a, b) => a.path.localeCompare(b.path));
|
|
41
|
+
};
|
|
42
|
+
var toHashMap = (files) => {
|
|
43
|
+
const hashes = {};
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
hashes[file.path] = file.hash;
|
|
46
|
+
}
|
|
47
|
+
return hashes;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
isPushablePath,
|
|
52
|
+
isTextPath,
|
|
53
|
+
readLocalTheme,
|
|
54
|
+
toHashMap
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-YAYCHT4W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/theme-files.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises';\nimport { join, relative, sep } from 'node:path';\nimport { liquidThemeAllowedDirectories } from '@tomsher/cms-core/constants';\nimport { sha256Hex } from './hash';\n\n// Extensions that can travel as UTF-8 text through the files/batch endpoint.\nconst textExtensions = ['.liquid', '.html', '.json', '.css', '.js', '.svg', '.txt'];\n\nexport interface LocalFile {\n path: string;\n bytes: Uint8Array;\n hash: string;\n}\n\nexport const isPushablePath = (relativePath: string): boolean => {\n const segments = relativePath.split('/');\n\n if (segments.length < 2) {\n return false;\n }\n\n if (segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {\n return false;\n }\n\n return (liquidThemeAllowedDirectories as readonly string[]).includes(segments[0]);\n};\n\nexport const isTextPath = (relativePath: string): boolean => {\n const lower = relativePath.toLowerCase();\n return textExtensions.some((extension) => lower.endsWith(extension));\n};\n\n// manifest.json, data/, files/ and the metadata folder are never inside a pushable directory, so they are skipped here.\nexport const readLocalTheme = async (rootDir: string): Promise<LocalFile[]> => {\n const entries = await readdir(rootDir, { recursive: true, withFileTypes: true });\n const files: LocalFile[] = [];\n\n for (const entry of entries) {\n if (!entry.isFile()) {\n continue;\n }\n\n const absolutePath = join(entry.parentPath, entry.name);\n const path = relative(rootDir, absolutePath).split(sep).join('/');\n\n if (!isPushablePath(path)) {\n continue;\n }\n\n const bytes = await readFile(absolutePath);\n files.push({ path, bytes, hash: sha256Hex(bytes) });\n }\n\n return files.sort((a, b) => a.path.localeCompare(b.path));\n};\n\nexport const toHashMap = (files: LocalFile[]): Record<string, string> => {\n const hashes: Record<string, string> = {};\n\n for (const file of files) {\n hashes[file.path] = file.hash;\n }\n\n return hashes;\n};\n"],"mappings":";;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,MAAM,UAAU,WAAW;AAKpC,IAAM,iBAAiB,CAAC,WAAW,SAAS,SAAS,QAAQ,OAAO,QAAQ,MAAM;AAQ3E,IAAM,iBAAiB,CAAC,iBAAkC;AAC7D,QAAM,WAAW,aAAa,MAAM,GAAG;AAEvC,MAAI,SAAS,SAAS,GAAG;AACrB,WAAO;AAAA,EACX;AAEA,MAAI,SAAS,KAAK,CAAC,YAAY,YAAY,MAAM,YAAY,OAAO,YAAY,IAAI,GAAG;AACnF,WAAO;AAAA,EACX;AAEA,SAAQ,8BAAoD,SAAS,SAAS,CAAC,CAAC;AACpF;AAEO,IAAM,aAAa,CAAC,iBAAkC;AACzD,QAAM,QAAQ,aAAa,YAAY;AACvC,SAAO,eAAe,KAAK,CAAC,cAAc,MAAM,SAAS,SAAS,CAAC;AACvE;AAGO,IAAM,iBAAiB,OAAO,YAA0C;AAC3E,QAAM,UAAU,MAAM,QAAQ,SAAS,EAAE,WAAW,MAAM,eAAe,KAAK,CAAC;AAC/E,QAAM,QAAqB,CAAC;AAE5B,aAAW,SAAS,SAAS;AACzB,QAAI,CAAC,MAAM,OAAO,GAAG;AACjB;AAAA,IACJ;AAEA,UAAM,eAAe,KAAK,MAAM,YAAY,MAAM,IAAI;AACtD,UAAM,OAAO,SAAS,SAAS,YAAY,EAAE,MAAM,GAAG,EAAE,KAAK,GAAG;AAEhE,QAAI,CAAC,eAAe,IAAI,GAAG;AACvB;AAAA,IACJ;AAEA,UAAM,QAAQ,MAAM,SAAS,YAAY;AACzC,UAAM,KAAK,EAAE,MAAM,OAAO,MAAM,UAAU,KAAK,EAAE,CAAC;AAAA,EACtD;AAEA,SAAO,MAAM,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC5D;AAEO,IAAM,YAAY,CAAC,UAA+C;AACrE,QAAM,SAAiC,CAAC;AAExC,aAAW,QAAQ,OAAO;AACtB,WAAO,KAAK,IAAI,IAAI,KAAK;AAAA,EAC7B;AAEA,SAAO;AACX;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildPreviewRequest,
|
|
4
|
+
createFixturesDataSource,
|
|
5
|
+
createLiveDataSource,
|
|
6
|
+
normalizePreviewData
|
|
7
|
+
} from "./chunk-ND62XRUU.js";
|
|
8
|
+
import "./chunk-6NVYKM2E.js";
|
|
9
|
+
import "./chunk-TN3DQWJE.js";
|
|
10
|
+
export {
|
|
11
|
+
buildPreviewRequest,
|
|
12
|
+
createFixturesDataSource,
|
|
13
|
+
createLiveDataSource,
|
|
14
|
+
normalizePreviewData
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=data-source-CKDBOWKF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|