jinrai 1.0.1 → 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/lib/bin.js +6 -6
- package/lib/src/config/userConfig.d.ts +1 -6
- package/package.json +1 -1
- package/src/bin.ts +5 -5
- package/src/config/userConfig.ts +2 -12
package/lib/bin.js
CHANGED
|
@@ -16,7 +16,7 @@ var getUserConfig = async () => {
|
|
|
16
16
|
const jiti = createJiti(import.meta.url, {
|
|
17
17
|
debug: false
|
|
18
18
|
});
|
|
19
|
-
const configPath = pathToFileURL(resolve(process.cwd(), ".
|
|
19
|
+
const configPath = pathToFileURL(resolve(process.cwd(), "jinrai.config")).href;
|
|
20
20
|
const configModule = await jiti.import(configPath);
|
|
21
21
|
return configModule.default;
|
|
22
22
|
};
|
|
@@ -3329,10 +3329,10 @@ task.success();
|
|
|
3329
3329
|
var data = await getRawPageData(config.url, config.pages, config.dev);
|
|
3330
3330
|
task.do("Format");
|
|
3331
3331
|
var { routes, templates } = getRoutesAndTemplates(data.pages);
|
|
3332
|
-
task.next(`Export: ${config.
|
|
3333
|
-
await mkdir(config.
|
|
3334
|
-
await writeFile(path.join(config.
|
|
3335
|
-
await writeFile(path.join(config.
|
|
3332
|
+
task.next(`Export: ${config.outDir} (${templates.length})`);
|
|
3333
|
+
await mkdir(config.outDir, { recursive: true });
|
|
3334
|
+
await writeFile(path.join(config.outDir, "config.json"), JSON.stringify(routes, null, 2));
|
|
3335
|
+
await writeFile(path.join(config.outDir, "index.html"), data.indexHtml ?? defaultIndexHtml);
|
|
3336
3336
|
for await (let [index, template] of templates.entries()) {
|
|
3337
3337
|
try {
|
|
3338
3338
|
template = await prettier.format(template, {
|
|
@@ -3345,6 +3345,6 @@ for await (let [index, template] of templates.entries()) {
|
|
|
3345
3345
|
});
|
|
3346
3346
|
} catch (error2) {
|
|
3347
3347
|
}
|
|
3348
|
-
await writeFile(path.join(config.
|
|
3348
|
+
await writeFile(path.join(config.outDir, `${index}.html`), template);
|
|
3349
3349
|
}
|
|
3350
3350
|
task.success();
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
interface ExportHTML {
|
|
2
|
-
index: string;
|
|
3
|
-
outDir: string;
|
|
4
|
-
}
|
|
5
1
|
export interface Config {
|
|
6
2
|
url: string;
|
|
7
3
|
pages: string[];
|
|
8
4
|
api: string;
|
|
9
5
|
dev?: boolean;
|
|
10
6
|
meta: string;
|
|
11
|
-
|
|
7
|
+
outDir: string;
|
|
12
8
|
}
|
|
13
9
|
export declare const getUserConfig: () => Promise<Config>;
|
|
14
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jinrai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A powerful library that analyzes your modern web application and automatically generates a perfectly rendered, static snapshot of its pages. Experience unparalleled loading speed and SEO clarity without the complexity of traditional SSR setups. Simply point Jinrai at your SPA and witness divine speed.",
|
|
5
5
|
"main": "lib/index.ts",
|
|
6
6
|
"scripts": {
|
package/src/bin.ts
CHANGED
|
@@ -21,11 +21,11 @@ const data = await getRawPageData(config.url, config.pages, config.dev)
|
|
|
21
21
|
task.do("Format")
|
|
22
22
|
const { routes, templates } = getRoutesAndTemplates(data.pages)
|
|
23
23
|
|
|
24
|
-
task.next(`Export: ${config.
|
|
25
|
-
await mkdir(config.
|
|
24
|
+
task.next(`Export: ${config.outDir} (${templates.length})`)
|
|
25
|
+
await mkdir(config.outDir, { recursive: true })
|
|
26
26
|
|
|
27
|
-
await writeFile(path.join(config.
|
|
28
|
-
await writeFile(path.join(config.
|
|
27
|
+
await writeFile(path.join(config.outDir, "config.json"), JSON.stringify(routes, null, 2))
|
|
28
|
+
await writeFile(path.join(config.outDir, "index.html"), data.indexHtml ?? defaultIndexHtml)
|
|
29
29
|
|
|
30
30
|
for await (let [index, template] of templates.entries()) {
|
|
31
31
|
try {
|
|
@@ -39,7 +39,7 @@ for await (let [index, template] of templates.entries()) {
|
|
|
39
39
|
})
|
|
40
40
|
} catch (error) {}
|
|
41
41
|
|
|
42
|
-
await writeFile(path.join(config.
|
|
42
|
+
await writeFile(path.join(config.outDir, `${index}.html`), template)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
task.success()
|
package/src/config/userConfig.ts
CHANGED
|
@@ -2,23 +2,13 @@ import { createJiti } from "jiti"
|
|
|
2
2
|
import { pathToFileURL } from "url"
|
|
3
3
|
import { resolve } from "path"
|
|
4
4
|
|
|
5
|
-
interface ExportHTML {
|
|
6
|
-
// root: string
|
|
7
|
-
// assets: {
|
|
8
|
-
// root: string
|
|
9
|
-
// prefix: string
|
|
10
|
-
// }
|
|
11
|
-
index: string
|
|
12
|
-
outDir: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
5
|
export interface Config {
|
|
16
6
|
url: string
|
|
17
7
|
pages: string[]
|
|
18
8
|
api: string
|
|
19
9
|
dev?: boolean
|
|
20
10
|
meta: string
|
|
21
|
-
|
|
11
|
+
outDir: string
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
export const getUserConfig = async (): Promise<Config> => {
|
|
@@ -26,7 +16,7 @@ export const getUserConfig = async (): Promise<Config> => {
|
|
|
26
16
|
debug: false,
|
|
27
17
|
})
|
|
28
18
|
|
|
29
|
-
const configPath = pathToFileURL(resolve(process.cwd(), ".
|
|
19
|
+
const configPath = pathToFileURL(resolve(process.cwd(), "jinrai.config")).href
|
|
30
20
|
|
|
31
21
|
const configModule = (await jiti.import(configPath)) as { default: Config }
|
|
32
22
|
|