@salty-css/core 0.0.1-alpha.326 → 0.0.1-alpha.328
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.
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const promises = require("fs/promises");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const compiler_helpers = require("../compiler/helpers.cjs");
|
|
6
5
|
const resolveDynamicConfigCache = async () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const currentDir = process.cwd();
|
|
7
|
+
const filename = "config-cache.json";
|
|
8
|
+
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "src/saltygen/cache"];
|
|
9
|
+
let contents = "";
|
|
10
|
+
for (const pattern of patterns) {
|
|
11
|
+
const potentialPath = path.join(currentDir, pattern, filename);
|
|
12
|
+
console.log(`Trying to read config cache from: ${potentialPath}`);
|
|
13
|
+
try {
|
|
14
|
+
contents = await promises.readFile(potentialPath, "utf8");
|
|
15
|
+
break;
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!contents) throw new Error(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
12
20
|
return JSON.parse(contents);
|
|
13
21
|
};
|
|
14
22
|
exports.resolveDynamicConfigCache = resolveDynamicConfigCache;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { readFile } from "fs/promises";
|
|
2
2
|
import { join } from "path";
|
|
3
|
-
import { getCorePackageRoot } from "../compiler/helpers.js";
|
|
4
3
|
const resolveDynamicConfigCache = async () => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const currentDir = process.cwd();
|
|
5
|
+
const filename = "config-cache.json";
|
|
6
|
+
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "src/saltygen/cache"];
|
|
7
|
+
let contents = "";
|
|
8
|
+
for (const pattern of patterns) {
|
|
9
|
+
const potentialPath = join(currentDir, pattern, filename);
|
|
10
|
+
console.log(`Trying to read config cache from: ${potentialPath}`);
|
|
11
|
+
try {
|
|
12
|
+
contents = await readFile(potentialPath, "utf8");
|
|
13
|
+
break;
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (!contents) throw new Error(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
10
18
|
return JSON.parse(contents);
|
|
11
19
|
};
|
|
12
20
|
export {
|
package/compiler/helpers.cjs
CHANGED
|
@@ -3,18 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
5
5
|
const getCorePackageRoot = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
console.log("getCorePackageRoot pathname start:", pathname);
|
|
10
|
-
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
11
|
-
pathname = path.join(pathname, "../");
|
|
12
|
-
}
|
|
13
|
-
return pathname;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.error("Error in getCorePackageRoot:", error);
|
|
16
|
-
return void 0;
|
|
6
|
+
let { pathname } = new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/helpers.cjs", document.baseURI).href);
|
|
7
|
+
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
8
|
+
pathname = path.join(pathname, "../");
|
|
17
9
|
}
|
|
10
|
+
return pathname;
|
|
18
11
|
};
|
|
19
12
|
const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
20
13
|
if (_level >= maxLevel) return value;
|
package/compiler/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getCorePackageRoot: () => string
|
|
1
|
+
export declare const getCorePackageRoot: () => string;
|
|
2
2
|
export declare const resolveExportValue: <T>(value: unknown, maxLevel?: number, _level?: number) => Promise<T>;
|
|
3
3
|
export declare const saltyFileExtensions: string[];
|
|
4
4
|
export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
|
package/compiler/helpers.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
const getCorePackageRoot = () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
console.log("getCorePackageRoot pathname start:", pathname);
|
|
7
|
-
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
8
|
-
pathname = join(pathname, "../");
|
|
9
|
-
}
|
|
10
|
-
return pathname;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.error("Error in getCorePackageRoot:", error);
|
|
13
|
-
return void 0;
|
|
3
|
+
let { pathname } = new URL(import.meta.url);
|
|
4
|
+
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
5
|
+
pathname = join(pathname, "../");
|
|
14
6
|
}
|
|
7
|
+
return pathname;
|
|
15
8
|
};
|
|
16
9
|
const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
17
10
|
if (_level >= maxLevel) return value;
|