@wpnuxt/core 1.0.0-edge.18 → 1.0.0-edge.20
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.d.mts +3 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +64 -49
- package/dist/runtime/components/ContentRenderer.vue +1 -3
- package/dist/runtime/server/api/config.d.ts +2 -0
- package/dist/runtime/server/api/config.js +6 -0
- package/package.json +6 -6
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolveFiles, defineNuxtModule, createResolver, addPlugin, addImports, addComponentsDir, addServerHandler, installModule, hasNuxtModule, addTemplate, addTypeTemplate } from '@nuxt/kit';
|
|
3
|
-
import { join } from 'pathe';
|
|
1
|
+
import { createResolver, hasNuxtModule, addTemplate, resolveFiles, defineNuxtModule, addPlugin, addImports, addComponentsDir, addServerHandler, installModule, addTypeTemplate } from '@nuxt/kit';
|
|
4
2
|
import consola, { createConsola } from 'consola';
|
|
3
|
+
import { promises, existsSync, cpSync, statSync } from 'node:fs';
|
|
5
4
|
import { ref } from 'vue';
|
|
5
|
+
import { join } from 'pathe';
|
|
6
6
|
import { upperFirst } from 'scule';
|
|
7
7
|
import { parse } from 'graphql';
|
|
8
8
|
|
|
9
9
|
const name = "@wpnuxt/core";
|
|
10
|
-
const version = "1.0.0-edge.
|
|
10
|
+
const version = "1.0.0-edge.20";
|
|
11
11
|
|
|
12
12
|
const loggerRef = ref();
|
|
13
13
|
const initLogger = (logLevel) => {
|
|
@@ -37,6 +37,51 @@ function validateConfig(options) {
|
|
|
37
37
|
throw new Error("WPNuxt error: frontend url should not have a trailing slash: " + options.frontendUrl);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
async function mergeQueries(nuxt) {
|
|
41
|
+
const { resolve } = createResolver(import.meta.url);
|
|
42
|
+
const resolveRuntimeModule = (path) => resolve("./runtime", path);
|
|
43
|
+
const logger = getLogger();
|
|
44
|
+
const queryOutputPath = resolve((nuxt.options.srcDir || nuxt.options.rootDir) + "/.queries/");
|
|
45
|
+
await promises.rm(queryOutputPath, { recursive: true, force: true });
|
|
46
|
+
const userQueryPath = "~/extend/queries/".replace(/^(~~|@@)/, nuxt.options.rootDir).replace(/^(~|@)/, nuxt.options.srcDir);
|
|
47
|
+
const userQueryPathExists = existsSync(userQueryPath);
|
|
48
|
+
cpSync(resolveRuntimeModule("./queries/"), queryOutputPath, { recursive: true });
|
|
49
|
+
addQueriesFromAddOnModule("@wpnuxt/blocks", queryOutputPath, nuxt, resolve);
|
|
50
|
+
addQueriesFromAddOnModule("@wpnuxt/auth", queryOutputPath, nuxt, resolve);
|
|
51
|
+
if (userQueryPathExists) {
|
|
52
|
+
logger.debug("Extending queries:", userQueryPath);
|
|
53
|
+
cpSync(resolve(userQueryPath), queryOutputPath, { recursive: true });
|
|
54
|
+
}
|
|
55
|
+
logger.debug("Copied merged queries in folder:", queryOutputPath);
|
|
56
|
+
return queryOutputPath;
|
|
57
|
+
}
|
|
58
|
+
function addQueriesFromAddOnModule(addOnModuleName, queryOutputPath, nuxt, resolve) {
|
|
59
|
+
const logger = getLogger();
|
|
60
|
+
if (hasNuxtModule(addOnModuleName)) {
|
|
61
|
+
for (const m of nuxt.options._installedModules) {
|
|
62
|
+
if (m.meta.name === addOnModuleName && m.entryPath) {
|
|
63
|
+
logger.debug("Loading queries from " + addOnModuleName);
|
|
64
|
+
let blocksQueriesPath;
|
|
65
|
+
if (m.entryPath == "../src/module") {
|
|
66
|
+
blocksQueriesPath = join(nuxt.options.rootDir, "../src/runtime/queries/");
|
|
67
|
+
} else if (m.entryPath.startsWith("../")) {
|
|
68
|
+
blocksQueriesPath = join(nuxt.options.rootDir, "../", m.entryPath, "./runtime/queries/");
|
|
69
|
+
} else {
|
|
70
|
+
blocksQueriesPath = join("./node_modules", m.entryPath, "dist/runtime/queries/");
|
|
71
|
+
}
|
|
72
|
+
cpSync(blocksQueriesPath, queryOutputPath, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
const moduleName = addOnModuleName.replace("@", "");
|
|
77
|
+
addTemplate({
|
|
78
|
+
write: true,
|
|
79
|
+
filename: moduleName + ".mjs",
|
|
80
|
+
getContents: () => `export { }`
|
|
81
|
+
});
|
|
82
|
+
nuxt.options.alias["#" + moduleName] = resolve(nuxt.options.buildDir, moduleName);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
40
85
|
|
|
41
86
|
const _parseDoc = async (doc) => {
|
|
42
87
|
const { definitions } = parse(doc);
|
|
@@ -148,7 +193,9 @@ const defaultConfigs = {
|
|
|
148
193
|
enableCache: true,
|
|
149
194
|
staging: false,
|
|
150
195
|
logLevel: 3,
|
|
151
|
-
composablesPrefix: "useWP"
|
|
196
|
+
composablesPrefix: "useWP",
|
|
197
|
+
hasBlocksModule: false,
|
|
198
|
+
hasAuthModule: false
|
|
152
199
|
};
|
|
153
200
|
const module = defineNuxtModule({
|
|
154
201
|
meta: {
|
|
@@ -170,11 +217,14 @@ const module = defineNuxtModule({
|
|
|
170
217
|
staging: process.env.WPNUXT_STAGING === "true" || options.staging,
|
|
171
218
|
downloadSchema: process.env.WPNUXT_DOWNLOAD_SCHEMA === "true" || options.downloadSchema,
|
|
172
219
|
logLevel: process.env.WPNUXT_LOG_LEVEL ? Number.parseInt(process.env.WPNUXT_LOG_LEVEL) : options.logLevel,
|
|
173
|
-
composablesPrefix: process.env.WPNUXT_COMPOSABLES_PREFIX || options.composablesPrefix
|
|
220
|
+
composablesPrefix: process.env.WPNUXT_COMPOSABLES_PREFIX || options.composablesPrefix,
|
|
221
|
+
hasBlocksModule: hasNuxtModule("@wpnuxt/blocks"),
|
|
222
|
+
hasAuthModule: hasNuxtModule("@wpnuxt/auth")
|
|
174
223
|
};
|
|
175
224
|
nuxt.options.runtimeConfig.public.wpNuxt = publicWPNuxtConfig;
|
|
176
225
|
validateConfig(publicWPNuxtConfig);
|
|
177
226
|
const logger = initLogger(publicWPNuxtConfig.logLevel);
|
|
227
|
+
logger.info("config:", publicWPNuxtConfig);
|
|
178
228
|
logger.info("Connecting GraphQL to", publicWPNuxtConfig.wordpressUrl);
|
|
179
229
|
logger.info("frontendUrl:", publicWPNuxtConfig.frontendUrl);
|
|
180
230
|
if (publicWPNuxtConfig.enableCache)
|
|
@@ -218,47 +268,17 @@ const module = defineNuxtModule({
|
|
|
218
268
|
route: "/api/wpContent",
|
|
219
269
|
handler: resolveRuntimeModule("./server/api/wpContent.post")
|
|
220
270
|
});
|
|
271
|
+
addServerHandler({
|
|
272
|
+
route: "/api/config",
|
|
273
|
+
handler: resolveRuntimeModule("./server/api/config")
|
|
274
|
+
});
|
|
221
275
|
await installModule("@vueuse/nuxt", {});
|
|
222
|
-
const
|
|
223
|
-
await promises.rm(queryOutputPath, { recursive: true, force: true });
|
|
224
|
-
const userQueryPath = "~/extend/queries/".replace(/^(~~|@@)/, nuxt.options.rootDir).replace(/^(~|@)/, nuxt.options.srcDir);
|
|
225
|
-
const userQueryPathExists = existsSync(userQueryPath);
|
|
226
|
-
cpSync(resolveRuntimeModule("./queries/"), queryOutputPath, { recursive: true });
|
|
227
|
-
if (hasNuxtModule("@wpnuxt/blocks")) {
|
|
228
|
-
for (const m of nuxt.options._installedModules) {
|
|
229
|
-
if (m.meta.name === "@wpnuxt/blocks" && m.entryPath) {
|
|
230
|
-
logger.debug("Loading queries from @wpnuxt/blocks");
|
|
231
|
-
let blocksQueriesPath;
|
|
232
|
-
if (m.entryPath == "../src/module") {
|
|
233
|
-
blocksQueriesPath = join(nuxt.options.rootDir, "../src/runtime/queries/");
|
|
234
|
-
} else if (m.entryPath.startsWith("../")) {
|
|
235
|
-
blocksQueriesPath = join(nuxt.options.rootDir, "../", m.entryPath, "./runtime/queries/");
|
|
236
|
-
} else {
|
|
237
|
-
blocksQueriesPath = join("./node_modules", m.entryPath, "dist/runtime/queries/");
|
|
238
|
-
}
|
|
239
|
-
cpSync(blocksQueriesPath, queryOutputPath, { recursive: true });
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
logger.debug("Tip: Install the @wpnuxt/blocks module if you want to render Gutenberg blocks with separate vue components");
|
|
244
|
-
addTemplate({
|
|
245
|
-
write: true,
|
|
246
|
-
filename: "wpnuxt/blocks.mjs",
|
|
247
|
-
getContents: () => `export { }`
|
|
248
|
-
});
|
|
249
|
-
nuxt.options.alias["#wpnuxt/blocks"] = resolve(nuxt.options.buildDir, "wpnuxt/blocks");
|
|
250
|
-
}
|
|
251
|
-
if (userQueryPathExists) {
|
|
252
|
-
logger.debug("Extending queries:", userQueryPath);
|
|
253
|
-
cpSync(resolve(userQueryPath), queryOutputPath, { recursive: true });
|
|
254
|
-
}
|
|
255
|
-
logger.debug("Copied merged queries in folder:", queryOutputPath);
|
|
276
|
+
const mergedQueriesFolder = await mergeQueries(nuxt);
|
|
256
277
|
await installModule("nuxt-graphql-middleware", {
|
|
257
278
|
debug: publicWPNuxtConfig.logLevel ? publicWPNuxtConfig.logLevel > 3 : false,
|
|
258
279
|
graphqlEndpoint: `${publicWPNuxtConfig.wordpressUrl}/graphql`,
|
|
259
280
|
downloadSchema: publicWPNuxtConfig.downloadSchema,
|
|
260
281
|
codegenConfig: {
|
|
261
|
-
silent: false,
|
|
262
282
|
skipTypename: true,
|
|
263
283
|
useTypeImports: true,
|
|
264
284
|
// inlineFragmentTypes: 'combine',
|
|
@@ -266,14 +286,9 @@ const module = defineNuxtModule({
|
|
|
266
286
|
onlyOperationTypes: true,
|
|
267
287
|
avoidOptionals: false,
|
|
268
288
|
maybeValue: "T | undefined",
|
|
269
|
-
disableOnBuild: false,
|
|
270
|
-
gqlImport: "graphql-request#wpnuxt",
|
|
271
289
|
namingConvention: {
|
|
272
290
|
enumValues: "change-case-all#upperCaseFirst"
|
|
273
|
-
}
|
|
274
|
-
documents: [
|
|
275
|
-
resolve("!./graphql/**/*")
|
|
276
|
-
]
|
|
291
|
+
}
|
|
277
292
|
},
|
|
278
293
|
codegenSchemaConfig: {
|
|
279
294
|
urlSchemaOptions: {
|
|
@@ -283,7 +298,7 @@ const module = defineNuxtModule({
|
|
|
283
298
|
}
|
|
284
299
|
},
|
|
285
300
|
outputDocuments: true,
|
|
286
|
-
autoImportPatterns:
|
|
301
|
+
autoImportPatterns: [mergedQueriesFolder],
|
|
287
302
|
includeComposables: true,
|
|
288
303
|
devtools: true
|
|
289
304
|
});
|
|
@@ -315,7 +330,7 @@ const module = defineNuxtModule({
|
|
|
315
330
|
fnImports: [],
|
|
316
331
|
composablesPrefix: publicWPNuxtConfig.composablesPrefix
|
|
317
332
|
};
|
|
318
|
-
await generateWPNuxtComposables(ctx,
|
|
333
|
+
await generateWPNuxtComposables(ctx, mergedQueriesFolder, srcResolver);
|
|
319
334
|
addTemplate({
|
|
320
335
|
write: true,
|
|
321
336
|
filename: "wpnuxt/index.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wpnuxt/core",
|
|
3
|
-
"version": "1.0.0-edge.
|
|
3
|
+
"version": "1.0.0-edge.20",
|
|
4
4
|
"description": "WPNuxt",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"@graphql-codegen/client-preset": "^4.3.3",
|
|
67
67
|
"@graphql-codegen/typescript-operations": "^4.2.3",
|
|
68
68
|
"@nuxt/devtools": "^1.4.1",
|
|
69
|
-
"@nuxt/eslint-config": "^0.5.
|
|
69
|
+
"@nuxt/eslint-config": "^0.5.4",
|
|
70
70
|
"@nuxt/module-builder": "^0.8.3",
|
|
71
71
|
"@nuxt/schema": "3.13.0",
|
|
72
72
|
"@nuxt/test-utils": "^3.14.1",
|
|
73
|
-
"@rollup/rollup-linux-arm64-gnu": "^4.21.
|
|
74
|
-
"@rollup/rollup-linux-arm64-musl": "^4.21.
|
|
73
|
+
"@rollup/rollup-linux-arm64-gnu": "^4.21.2",
|
|
74
|
+
"@rollup/rollup-linux-arm64-musl": "^4.21.2",
|
|
75
75
|
"@types/node": "22.5.1",
|
|
76
76
|
"@vitest/coverage-v8": "^2.0.5",
|
|
77
77
|
"@vue/test-utils": "^2.4.6",
|
|
@@ -81,14 +81,14 @@
|
|
|
81
81
|
"nuxt": "^3.13.0",
|
|
82
82
|
"nuxt-content-twoslash": "^0.1.1",
|
|
83
83
|
"release-it": "^17.6.0",
|
|
84
|
-
"shiki": "^1.
|
|
84
|
+
"shiki": "^1.15.0",
|
|
85
85
|
"twoslash": "^0.2.9",
|
|
86
86
|
"typescript": "^5.5.4",
|
|
87
87
|
"untyped": "1.4.2",
|
|
88
88
|
"vite": "^5.4.2",
|
|
89
89
|
"vitest": "^2.0.5",
|
|
90
90
|
"vue-docgen-web-types": "^0.1.8",
|
|
91
|
-
"vue-tsc": "2.1.
|
|
91
|
+
"vue-tsc": "2.1.2"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"consola": "^3.2.3",
|