@lumeland/core 1.0.0 → 1.0.2
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/CHANGELOG.md +14 -0
- package/build/src/archetypes.d.ts +1 -1
- package/build/src/archetypes.js +19 -13
- package/build/src/utils/cdn.js +4 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## 1.0.2 - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Archetypes: Download URLs as binary files.
|
|
13
|
+
- Archetypes: Allow to run unregistered archetypes.
|
|
14
|
+
- Archetypes: Print relative paths of the created files.
|
|
15
|
+
|
|
16
|
+
## 1.0.1 - 2026-10-31
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- `getFsFiles()` cdn util returns wrong `file:` urls.
|
|
21
|
+
|
|
8
22
|
## 1.0.0 - 2026-10-30
|
|
9
23
|
|
|
10
24
|
First version
|
|
@@ -8,7 +8,7 @@ export default class Archetypes {
|
|
|
8
8
|
root: string;
|
|
9
9
|
constructor(options: Options);
|
|
10
10
|
register(name: string, archetype: string | Archetype): void;
|
|
11
|
-
run(name: string, args?: string[]): Promise<void>;
|
|
11
|
+
run(name: string | Archetype, args?: string[]): Promise<void>;
|
|
12
12
|
save(file: ArchetypeFile | ArchetypeRemote): Promise<void>;
|
|
13
13
|
load(name: string): Promise<Archetype>;
|
|
14
14
|
}
|
package/build/src/archetypes.js
CHANGED
|
@@ -9,7 +9,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
9
9
|
import { parse, stringify } from "../deps/yaml.js";
|
|
10
10
|
import { extract, test } from "../deps/front-matter.js";
|
|
11
11
|
import { ensureDir } from "./utils/fs.js";
|
|
12
|
-
import { dirname, join, toFileUrl } from "../deps/path.js";
|
|
12
|
+
import { dirname, join, toFileUrl, relative } from "../deps/path.js";
|
|
13
13
|
import { isGenerator } from "./utils/generator.js";
|
|
14
14
|
import { log } from "./utils/log.js";
|
|
15
15
|
import { isUrl } from "./utils/path.js";
|
|
@@ -30,16 +30,21 @@ export default class Archetypes {
|
|
|
30
30
|
}
|
|
31
31
|
async run(name, args = []) {
|
|
32
32
|
let archetype;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
if (typeof name === "string") {
|
|
34
|
+
try {
|
|
35
|
+
archetype = await this.load(name);
|
|
36
|
+
}
|
|
37
|
+
catch (cause) {
|
|
38
|
+
log.fatal(`[archetype] Archetype "${name}" not found or is errored.: ${cause.message}`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (typeof archetype !== "function") {
|
|
42
|
+
log.fatal(`[archetype] Archetype "${name}" is not a valid function.`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return;
|
|
46
|
+
else {
|
|
47
|
+
archetype = name;
|
|
43
48
|
}
|
|
44
49
|
if (isGenerator(archetype)) {
|
|
45
50
|
for await (const file of archetype(...args)) {
|
|
@@ -70,7 +75,7 @@ export default class Archetypes {
|
|
|
70
75
|
}
|
|
71
76
|
const fullPath = join(base === "root" ? this.root : this.src, path);
|
|
72
77
|
if (content instanceof URL) {
|
|
73
|
-
return await saveFile(fullPath, await read(content.href), overwrite);
|
|
78
|
+
return await saveFile(fullPath, await read(content.href, true), overwrite);
|
|
74
79
|
}
|
|
75
80
|
if (typeof content === "string" || content instanceof Uint8Array) {
|
|
76
81
|
return await saveFile(fullPath, content, overwrite);
|
|
@@ -121,11 +126,12 @@ async function saveFile(path, content, overwrite = false) {
|
|
|
121
126
|
else {
|
|
122
127
|
await writeTextFile(path, content, !overwrite);
|
|
123
128
|
}
|
|
129
|
+
const relPath = relative(cwd(), path);
|
|
124
130
|
if (overwrite) {
|
|
125
|
-
log.info(`✔️ Updated file: <gray>${
|
|
131
|
+
log.info(`✔️ Updated file: <gray>${relPath}</gray>`);
|
|
126
132
|
}
|
|
127
133
|
else {
|
|
128
|
-
log.info(`✔️ Created file: <gray>${
|
|
134
|
+
log.info(`✔️ Created file: <gray>${relPath}</gray>`);
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
137
|
catch (error) {
|
package/build/src/utils/cdn.js
CHANGED
|
@@ -41,11 +41,12 @@ function getFsFiles(specifier, patterns) {
|
|
|
41
41
|
const fileMap = new Map();
|
|
42
42
|
const regexps = patterns.map((pattern) => globToRegExp(posix.join("/", pattern), { globstar: true, extended: true }));
|
|
43
43
|
for (const path of walk(basePath)) {
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const from = Path.create(path);
|
|
45
|
+
const to = from.clone().removeBase(basePath).toString();
|
|
46
|
+
if (!regexps.some((regexp) => regexp.test(to))) {
|
|
46
47
|
continue;
|
|
47
48
|
}
|
|
48
|
-
fileMap.set(
|
|
49
|
+
fileMap.set(to, from.url.href);
|
|
49
50
|
}
|
|
50
51
|
return fileMap;
|
|
51
52
|
}
|