-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateObjectsArrayScript.ts
More file actions
55 lines (44 loc) · 1.64 KB
/
generateObjectsArrayScript.ts
File metadata and controls
55 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//// <reference path="./deno.d.ts" />
import { walk } from 'jsr:@std/fs';
const dir = 'src/lib/components/models/Ultimate-Stylized-Nature/';
const names = [];
let outputString = '';
let outputStringPart2 = '';
for await (const entry of walk(dir)) {
if (entry.isFile && entry.name.endsWith('.svelte')) {
names.push(entry);
}
}
const importPath = dir.replace('../src/', '$');
for (let i = 0; i < names.length; i++) {
const path = names[i].path.replace(/\\/g, '/').replace(dir, '');
const name = names[i].name.split('.')[0];
console.log(path);
outputString += `import ${name} from '${importPath}${path}'\n`;
outputString += `import ${name}SRC from '${importPath}${path}?raw'\n`;
outputStringPart2 += `{ id: ${i}, el: undefined, obj: ${name}, src: ${name}SRC },\n`;
}
const output =
'// This is a generated list of imports and exports from generateObjectsScript.ts\n' +
outputString +
'\n\nexport default [\n' +
outputStringPart2 +
`] as {
id: number;
el: HTMLElement | undefined;
obj: any;
src: string;
}[];`;
Deno.writeTextFileSync('ObjectsArray.ts', output);
// import Object1 from '$lib/components/models/Ultimate-Stylized-Nature/BirchTree_1.svelte';
// import Object1SRC from '$lib/components/models/Ultimate-Stylized-Nature/BirchTree_1.svelte?raw';
// import Object2 from '$lib/components/models/Ultimate-Stylized-Nature/BirchTree_2.svelte';
// import Object2SRC from '$lib/components/models/Ultimate-Stylized-Nature/BirchTree_2.svelte?raw';
// export default [
// { el: undefined, obj: Object1, src: Object1SRC },
// { el: undefined, obj: Object2, src: Object2SRC }
// ] as {
// el: HTMLElement | undefined;
// obj: any;
// src: string;
// }[];