@hywax/cms 1.2.1 → 1.3.0

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.
@@ -0,0 +1,7 @@
1
+ const cmsConfig = {
2
+ "name": "cms",
3
+ "uploraUrl": "http://uplora.ru",
4
+ "fluxorUrl": "https://fluxor.uplora.ru"
5
+ } as const
6
+
7
+ export const getCmsConfig = () => cmsConfig
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "configKey": "cms",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -6,7 +6,7 @@ import { snakeCase, kebabCase } from 'scule';
6
6
  import { readFile, writeFile } from 'node:fs/promises';
7
7
 
8
8
  const name = "@hywax/cms";
9
- const version = "1.2.1";
9
+ const version = "1.3.0";
10
10
 
11
11
  function createContext(options, nuxt) {
12
12
  const { resolve } = createResolver(import.meta.url);
@@ -53,6 +53,7 @@ function transformHttpCodes(httpCodes) {
53
53
  }
54
54
 
55
55
  function prepareAutoImports({ resolve, options, nuxt }) {
56
+ const cmsConfigPath = resolve(nuxt.options.buildDir, "cms/config");
56
57
  const httpCodesPath = resolve(nuxt.options.buildDir, "cms/http-codes");
57
58
  const httpCodesImports = transformHttpCodes(options.httpCodes).map(({ code }) => ({ name: code, from: httpCodesPath }));
58
59
  addComponentsDir({
@@ -70,7 +71,8 @@ function prepareAutoImports({ resolve, options, nuxt }) {
70
71
  addPlugin(resolve("./runtime/plugins/api"));
71
72
  addPlugin(resolve("./runtime/plugins/zod"));
72
73
  addImports([
73
- ...httpCodesImports
74
+ ...httpCodesImports,
75
+ { name: "getCmsConfig", from: cmsConfigPath }
74
76
  // { name: 'docToMarkdown', from: resolve('./runtime/editor/markdown') },
75
77
  // { name: 'markdownToDoc', from: resolve('./runtime/editor/markdown') },
76
78
  ]);
@@ -79,7 +81,8 @@ function prepareAutoImports({ resolve, options, nuxt }) {
79
81
  resolve("./runtime/composables")
80
82
  ]);
81
83
  addServerImports([
82
- ...httpCodesImports
84
+ ...httpCodesImports,
85
+ { name: "getCmsConfig", from: cmsConfigPath }
83
86
  // { name: 'docToMarkdown', from: resolve('./runtime/editor/markdown') },
84
87
  // { name: 'markdownToDoc', from: resolve('./runtime/editor/markdown') },
85
88
  ]);
@@ -146,6 +149,9 @@ function prepareMergeConfigs({ nuxt, options }) {
146
149
  nuxt.options.experimental = defu(nuxt.options.experimental || {}, {
147
150
  typedPages: true
148
151
  });
152
+ nuxt.options.future = defu(nuxt.options.future || {}, {
153
+ compatibilityVersion: 5
154
+ });
149
155
  nuxt.options.runtimeConfig.public = defu(nuxt.options.runtimeConfig.public || {}, {
150
156
  fluxorUrl: options.fluxorUrl,
151
157
  version: "develop"
@@ -193,7 +199,7 @@ function prepareMergeConfigs({ nuxt, options }) {
193
199
  fonts: true
194
200
  });
195
201
  nuxt.options.colorMode = defu(nuxt.options.colorMode || {}, {
196
- storageKey: `${options.name}-color-mode`
202
+ storageKey: `${options.name}:color-mode`
197
203
  });
198
204
  nuxt.options.mdc = defu(nuxt.options.mdc || {}, {
199
205
  components: {
@@ -202,7 +208,7 @@ function prepareMergeConfigs({ nuxt, options }) {
202
208
  }
203
209
  }
204
210
  });
205
- nuxt.options.auth = defu(nuxt.options.auth || {}, {
211
+ nuxt.options.runtimeConfig.session = defu(nuxt.options.runtimeConfig.session || {}, {
206
212
  name: `${options.name}-session`
207
213
  });
208
214
  nuxt.options.runtimeConfig.uplora = defu(nuxt.options.runtimeConfig.uplora || {}, {
@@ -437,6 +443,20 @@ export {}
437
443
  `;
438
444
  }
439
445
  });
446
+ templates.push({
447
+ filename: "cms/config.ts",
448
+ write: true,
449
+ getContents: () => {
450
+ const config = {
451
+ name: options.name,
452
+ uploraUrl: options.uploraUrl,
453
+ fluxorUrl: options.fluxorUrl
454
+ };
455
+ return `const cmsConfig = ${JSON.stringify(config, null, 2)} as const
456
+
457
+ export const getCmsConfig = () => cmsConfig`;
458
+ }
459
+ });
440
460
  return templates;
441
461
  }
442
462
  function getServerTemplates(_context) {
@@ -1,5 +1,6 @@
1
+ import { getCmsConfig } from "#imports";
1
2
  import { kebabCase } from "scule";
2
- const storagePrefix = "cms:";
3
+ const storagePrefix = `${getCmsConfig().name}:`;
3
4
  export const getCmsStorageKey = (key) => `${storagePrefix}${kebabCase(key)}`;
4
5
  export function clearCmsStorage() {
5
6
  for (const key in localStorage) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
6
6
  "repository": {
7
7
  "type": "git",