@yassidev/nuxt-directus 0.0.7 → 0.0.8

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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "directus",
3
3
  "configKey": "directus",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -3,6 +3,7 @@ import { generateDirectusTypes } from 'directus-sdk-typegen';
3
3
  import { fetchTranslations, syncTranslations } from '../dist/runtime/server.js';
4
4
  import { readFileSync } from 'node:fs';
5
5
  import { NAME } from '../dist/runtime/constants.js';
6
+ import { join } from 'node:path';
6
7
 
7
8
  const JOIN_LEADING_SLASH_RE = /^\.?\//;
8
9
  function hasTrailingSlash(input = "", respectQueryAndFragment) {
@@ -183,30 +184,38 @@ function setupI18n(config, nuxt, logger) {
183
184
  accessToken: config.accessToken,
184
185
  i18nPrefix: config.i18n.prefix
185
186
  };
187
+ const path = "directus/locales";
188
+ const dirPath = resolve(nuxt.options.buildDir, path);
189
+ nuxt.options.watch.push(join(dirPath, "**"));
190
+ nuxt.options.vite.server = defu(nuxt.options.vite.server, {
191
+ watch: {
192
+ ignored: [`!${join(dirPath, "**")}`]
193
+ }
194
+ });
186
195
  codes.map((code) => {
187
196
  const { dst } = addTemplate({
188
197
  write: true,
189
- filename: `../.locales/${code}.json`,
198
+ filename: `${path}/${code}.json`,
190
199
  getContents: () => fetchTranslations(code, runtimeConfig).then((translations) => {
191
200
  return JSON.stringify(Object.fromEntries(translations.map((translation) => [translation.key, translation.value])), null, 2);
192
201
  })
193
202
  });
194
- nuxt.hook("builder:watch", async (event, filePath) => {
195
- if (filePath === dst) {
196
- const translations = JSON.parse(readFileSync(filePath, "utf-8"));
197
- const done = await syncTranslations(code, translations, runtimeConfig);
198
- if (!done) return;
199
- logger.info(`Synced translations for locale: ${code}`);
200
- }
203
+ nuxt.hook("builder:watch", async (_, filePath) => {
204
+ console.log("filePath", filePath, dst);
205
+ if (filePath !== dst) return;
206
+ const translations = JSON.parse(readFileSync(filePath, "utf-8"));
207
+ const done = await syncTranslations(code, translations, runtimeConfig);
208
+ if (!done) return;
209
+ logger.info(`Synced translations for locale: ${code}`);
201
210
  });
202
211
  });
203
212
  }
204
213
  nuxt.hook("i18n:registerModule", (register) => {
205
214
  const locales = codes.map((code) => ({
206
215
  code,
207
- file: "index.js"
216
+ file: resolve("./runtime/lang/index")
208
217
  }));
209
- register({ langDir: resolve("./runtime/lang"), locales });
218
+ register({ langDir: "", locales });
210
219
  logger.success("Locales have been registered: " + codes.join(", "));
211
220
  });
212
221
  }
@@ -1,4 +1,3 @@
1
- import type { Schema } from '#directus/types';
2
1
  /**
3
2
  * Create base directus instance.
4
3
  */
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Use directus (rest)
3
3
  */
4
- export declare function useDirectus(): import("@directus/sdk").DirectusClient<import("../../../.nuxt/directus/types.js").Schema> & import("@directus/sdk").GraphqlClient<import("../../../.nuxt/directus/types.js").Schema>;
4
+ export declare function useDirectus(): import("@directus/sdk").DirectusClient<Schema> & import("@directus/sdk").GraphqlClient<Schema>;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Use directus (rest)
3
3
  */
4
- export declare function useDirectus(): import("@directus/sdk").DirectusClient<import("../../../.nuxt/directus/types.js").Schema> & import("@directus/sdk").RestClient<import("../../../.nuxt/directus/types.js").Schema>;
4
+ export declare function useDirectus(): import("@directus/sdk").DirectusClient<Schema> & import("@directus/sdk").RestClient<Schema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yassidev/nuxt-directus",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A Nuxt module for better integration with Directus CMS.",
5
5
  "repository": "yassilah/nuxt-directus",
6
6
  "license": "MIT",