@yassidev/nuxt-directus 0.0.10 → 0.0.11

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.10",
4
+ "version": "0.0.11",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, useLogger, updateRuntimeConfig, hasNuxtModule, createResolver, addImports, addServerImports, addTemplate, addTypeTemplate } from 'nuxt/kit';
2
2
  import { generateDirectusTypes } from 'directus-sdk-typegen';
3
3
  import { fetchTranslations, syncTranslations } from '../dist/runtime/server.js';
4
- import { readFileSync } from 'node:fs';
4
+ import { readFileSync, existsSync } from 'node:fs';
5
5
  import { NAME } from '../dist/runtime/constants.js';
6
6
  import { resolve, join, relative, sep } from 'node:path';
7
7
  import { unwatchFile, watchFile, watch as watch$1, stat as stat$2 } from 'fs';
@@ -1850,21 +1850,21 @@ function setupI18n(config, nuxt, logger) {
1850
1850
  };
1851
1851
  const path = "directus/locales";
1852
1852
  const result = codes.map((code) => {
1853
- const { dst } = addTemplate({
1853
+ const { filename } = addTemplate({
1854
1854
  write: true,
1855
1855
  filename: join(path, `${code}.json`),
1856
1856
  getContents: () => fetchTranslations(code, runtimeConfig).then((translations) => {
1857
1857
  return JSON.stringify(Object.fromEntries(translations.map((translation) => [translation.key, translation.value])), null, 2);
1858
1858
  })
1859
1859
  });
1860
- return { code, dst };
1860
+ return { code, filename };
1861
1861
  });
1862
1862
  if (nuxt.options.dev && !nuxt.options._prepare) {
1863
- const watcher = chokidar.watch(resolve(nuxt.options.buildDir, path, "*.json"), { ignoreInitial: true });
1863
+ const watcher = chokidar.watch(path, { cwd: nuxt.options.buildDir, ignoreInitial: true });
1864
1864
  watcher.on("change", async (filePath) => {
1865
- const code = result.find((i) => i.dst === filePath)?.code;
1865
+ const code = result.find((i) => i.filename === filePath)?.code;
1866
1866
  if (!code) return;
1867
- const translations = JSON.parse(readFileSync(filePath, "utf-8"));
1867
+ const translations = JSON.parse(readFileSync(resolve(nuxt.options.buildDir, filePath), "utf-8"));
1868
1868
  const done = await syncTranslations(code, translations, runtimeConfig);
1869
1869
  if (!done) return;
1870
1870
  logger.info(`Synced translations for locale: ${code}`);
@@ -1872,11 +1872,12 @@ function setupI18n(config, nuxt, logger) {
1872
1872
  }
1873
1873
  }
1874
1874
  nuxt.hook("i18n:registerModule", (register) => {
1875
+ const isStubbing = existsSync(resolve("./runtime/lang/index.ts"));
1875
1876
  const locales = codes.map((code) => ({
1876
1877
  code,
1877
- file: resolve("./runtime/lang/index")
1878
+ file: isStubbing ? "index.ts" : "index.js"
1878
1879
  }));
1879
- register({ langDir: "", locales });
1880
+ register({ langDir: resolve("./runtime/lang"), locales });
1880
1881
  logger.success("Locales have been registered: " + codes.join(", "));
1881
1882
  });
1882
1883
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yassidev/nuxt-directus",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "A Nuxt module for better integration with Directus CMS.",
5
5
  "repository": "yassilah/nuxt-directus",
6
6
  "license": "MIT",