@lumeland/core 1.0.0-beta-7 → 1.0.0-beta-8
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.
|
@@ -16,5 +16,6 @@ export type Archetype = (...args: string[]) => void | ArchetypeFile | Generator<
|
|
|
16
16
|
export interface ArchetypeFile<T = unknown> {
|
|
17
17
|
base?: "src" | "root";
|
|
18
18
|
path: string;
|
|
19
|
-
|
|
19
|
+
overwrite?: boolean;
|
|
20
|
+
content: T | URL | ((prev?: T) => T | Promise<T>);
|
|
20
21
|
}
|
package/build/src/archetypes.js
CHANGED
|
@@ -15,6 +15,7 @@ import { log } from "./utils/log.js";
|
|
|
15
15
|
import { isUrl } from "./utils/path.js";
|
|
16
16
|
import { cwd } from "./services/process.js";
|
|
17
17
|
import { readTextFile, writeFile, writeTextFile } from "./services/fs.js";
|
|
18
|
+
import { read } from "./utils/read.js";
|
|
18
19
|
export default class Archetypes {
|
|
19
20
|
archetypes = new Map();
|
|
20
21
|
src;
|
|
@@ -52,16 +53,19 @@ export default class Archetypes {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
async save(file) {
|
|
55
|
-
const { path, base = "src", content } = file;
|
|
56
|
+
const { path, base = "src", content, overwrite } = file;
|
|
56
57
|
if (!path) {
|
|
57
58
|
throw new Error("Archetype path is required.");
|
|
58
59
|
}
|
|
59
|
-
if (
|
|
60
|
+
if (content === undefined || content === null) {
|
|
60
61
|
throw new Error("Archetype content is required.");
|
|
61
62
|
}
|
|
62
63
|
const fullPath = join(base === "root" ? this.root : this.src, path);
|
|
64
|
+
if (content instanceof URL) {
|
|
65
|
+
return await saveFile(fullPath, await read(content.href), overwrite);
|
|
66
|
+
}
|
|
63
67
|
if (typeof content === "string" || content instanceof Uint8Array) {
|
|
64
|
-
return await saveFile(fullPath, content);
|
|
68
|
+
return await saveFile(fullPath, content, overwrite);
|
|
65
69
|
}
|
|
66
70
|
if (path.endsWith(".json")) {
|
|
67
71
|
return await runObjectArchetype(fullPath, content, JSON.parse, (o) => JSON.stringify(o, null, 2));
|
package/build/src/services/fs.js
CHANGED
|
@@ -99,8 +99,8 @@ export class FsError extends Error {
|
|
|
99
99
|
get code() {
|
|
100
100
|
if (this.cause.code === "ENOENT")
|
|
101
101
|
return "not-found";
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
if (this.cause.code === "EEXIST")
|
|
103
|
+
return "exists";
|
|
104
104
|
return "other";
|
|
105
105
|
}
|
|
106
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumeland/core",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-8",
|
|
4
4
|
"description": "The core of Lume SSG",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Óscar Otero",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@lumeland/dom": "^0.1.56",
|
|
24
|
-
"@lumeland/plugin-esbuild": "^1.0.0-beta-
|
|
25
|
-
"@lumeland/plugin-lightningcss": "^1.0.0-beta-
|
|
24
|
+
"@lumeland/plugin-esbuild": "^1.0.0-beta-8",
|
|
25
|
+
"@lumeland/plugin-lightningcss": "^1.0.0-beta-8",
|
|
26
26
|
"deno-std": "1.5.1",
|
|
27
27
|
"remove-markdown": "0.8.0",
|
|
28
28
|
"temporal-polyfill": "^1.0.6",
|