@holo-js/adapter-nuxt 0.1.3 → 0.1.4
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/dist/module.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readdir, mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, extname, basename, relative } from 'node:path';
|
|
2
3
|
import { defineNuxtModule, createResolver, addServerPlugin, addImports, addServerImportsDir, addServerHandler } from '@nuxt/kit';
|
|
3
4
|
import { loadConfigDirectory } from '@holo-js/config';
|
|
4
5
|
|
|
6
|
+
const MODEL_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"]);
|
|
5
7
|
function escapeRegExp(value) {
|
|
6
8
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7
9
|
}
|
|
@@ -60,6 +62,31 @@ function toStorageModuleOptions(loaded) {
|
|
|
60
62
|
disks: { ...loaded.storage.disks }
|
|
61
63
|
};
|
|
62
64
|
}
|
|
65
|
+
async function createServerModelImports(sourceDir) {
|
|
66
|
+
const modelsDir = resolve(sourceDir, "server/models");
|
|
67
|
+
const modelImportDir = resolve(sourceDir, ".holo-js/generated/nuxt-server-imports");
|
|
68
|
+
const modelImportFile = resolve(modelImportDir, "models.ts");
|
|
69
|
+
let modelFiles;
|
|
70
|
+
try {
|
|
71
|
+
modelFiles = (await readdir(modelsDir)).filter((fileName) => MODEL_FILE_EXTENSIONS.has(extname(fileName))).sort((left, right) => left.localeCompare(right));
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
if (modelFiles.length === 0) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const lines = modelFiles.map((fileName) => {
|
|
79
|
+
const modelName = basename(fileName, extname(fileName));
|
|
80
|
+
const importPath = relative(modelImportDir, resolve(modelsDir, fileName)).replaceAll("\\", "/");
|
|
81
|
+
const normalizedImportPath = importPath.replace(/^(?!\.)/, "./");
|
|
82
|
+
const extension = extname(normalizedImportPath);
|
|
83
|
+
return `export { default as ${modelName} } from '${normalizedImportPath.slice(0, -extension.length)}'`;
|
|
84
|
+
});
|
|
85
|
+
await mkdir(modelImportDir, { recursive: true });
|
|
86
|
+
await writeFile(modelImportFile, `${lines.join("\n")}
|
|
87
|
+
`, "utf8");
|
|
88
|
+
return modelImportDir;
|
|
89
|
+
}
|
|
63
90
|
const module$1 = defineNuxtModule({
|
|
64
91
|
meta: {
|
|
65
92
|
name: "@holo-js/adapter-nuxt"
|
|
@@ -118,7 +145,10 @@ const module$1 = defineNuxtModule({
|
|
|
118
145
|
addServerPlugin(resolver.resolve("./runtime/plugins/init"));
|
|
119
146
|
addImports(imports);
|
|
120
147
|
addServerImportsDir(resolver.resolve("./runtime/server/imports"));
|
|
121
|
-
|
|
148
|
+
const serverModelImports = await createServerModelImports(sourceDir);
|
|
149
|
+
if (serverModelImports) {
|
|
150
|
+
addServerImportsDir(serverModelImports);
|
|
151
|
+
}
|
|
122
152
|
opts._holoCoreRuntimeRegistered = true;
|
|
123
153
|
}
|
|
124
154
|
if (storageModule && !opts._holoStorageRuntimeRegistered) {
|
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
configureHoloRuntimeConfig
|
|
3
3
|
} from "../composables/index.js";
|
|
4
4
|
import { initializeHoloAdapterProject } from "@holo-js/core";
|
|
5
|
+
import { useRuntimeConfig } from "nitropack/runtime/config";
|
|
6
|
+
import { defineNitroPlugin } from "nitropack/runtime/plugin";
|
|
5
7
|
export default defineNitroPlugin(async (nitroApp) => {
|
|
6
8
|
const config = useRuntimeConfig();
|
|
7
9
|
configureHoloRuntimeConfig(config);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { configureStorageRuntime } from "@holo-js/storage/runtime";
|
|
2
|
-
import { useRuntimeConfig
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime/config";
|
|
3
|
+
import { defineNitroPlugin } from "nitropack/runtime/plugin";
|
|
4
|
+
import { useStorage as useNitroStorage } from "nitropack/runtime/storage";
|
|
3
5
|
export default defineNitroPlugin(() => {
|
|
4
6
|
configureStorageRuntime({
|
|
5
7
|
getRuntimeConfig: () => useRuntimeConfig(),
|
package/dist/runtime/shims.d.ts
CHANGED
|
@@ -43,6 +43,18 @@ declare module '#imports' {
|
|
|
43
43
|
export function useStorage(base: string): unknown
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
declare module 'nitropack/runtime/config' {
|
|
47
|
+
export function useRuntimeConfig(): HoloRuntimeConfig
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare module 'nitropack/runtime/plugin' {
|
|
51
|
+
export function defineNitroPlugin<T>(plugin: T): T
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare module 'nitropack/runtime/storage' {
|
|
55
|
+
export function useStorage(base: string): unknown
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
declare global {
|
|
47
59
|
function createError(input: { statusCode: number, statusMessage: string }): Error
|
|
48
60
|
function defineNitroPlugin<T>(plugin: T): T
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/adapter-nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Holo-JS Framework - Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@nuxt/kit": "^4.0.0",
|
|
38
|
-
"@holo-js/config": "^0.1.
|
|
39
|
-
"@holo-js/core": "^0.1.
|
|
40
|
-
"@holo-js/db": "^0.1.
|
|
38
|
+
"@holo-js/config": "^0.1.4",
|
|
39
|
+
"@holo-js/core": "^0.1.4",
|
|
40
|
+
"@holo-js/db": "^0.1.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@holo-js/forms": "^0.1.
|
|
44
|
-
"@holo-js/storage": "^0.1.
|
|
45
|
-
"@holo-js/storage-s3": "^0.1.
|
|
43
|
+
"@holo-js/forms": "^0.1.4",
|
|
44
|
+
"@holo-js/storage": "^0.1.4",
|
|
45
|
+
"@holo-js/storage-s3": "^0.1.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"@holo-js/forms": {
|