bfg-common 1.0.97 → 1.0.98

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.
@@ -30,8 +30,8 @@
30
30
  import type { UI_I_Localization } from '~/models/interfaces'
31
31
  import type { UI_T_ShowType } from '~/components/common/accordion/models/types'
32
32
  import type { UI_I_AccordionRecursion } from '~/components/common/accordion/models/interfaces'
33
- import type { UI_I_ContentNavigation } from '~/components/common/content/navbar/left/models/interfaces'
34
- import { constructItems } from '~/components/common/content/navbar/left/utils/constructAccordion'
33
+ import type { UI_I_ContentNavigation } from '~/components/common/help/navbar/left/models/interfaces'
34
+ import { constructItems } from '~/components/common/help/navbar/left/utils/constructAccordion'
35
35
 
36
36
  const props = defineProps<{
37
37
  items: UI_I_ContentNavigation[] | null
@@ -1,4 +1,4 @@
1
- import type { UI_I_ContentNavigation } from '~/components/common/content/navbar/left/models/interfaces'
1
+ import type { UI_I_ContentNavigation } from '~/components/common/help/navbar/left/models/interfaces'
2
2
  import type { UI_I_AccordionRecursion } from '~/components/common/accordion/models/interfaces'
3
3
 
4
4
  export const constructItems = (
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script setup lang="ts">
27
- import type { UI_I_ContentNavbarItem } from '~/components/common/content/navbar/right/models/interfaces'
27
+ import type { UI_I_ContentNavbarItem } from '~/components/common/help/navbar/right/models/interfaces'
28
28
 
29
29
  const props = defineProps<{
30
30
  title: string
@@ -8,110 +8,58 @@ import {
8
8
  updateImagesPath,
9
9
  } from './utils/methods'
10
10
 
11
- // export default defineNuxtModule({
12
- // meta: {
13
- // name: 'fix-content-build',
14
- // configKey: 'fixContentBuild'
15
- // },
16
- // setup () {
17
- // if (
18
- // process.env.NODE_ENV === 'development' ||
19
- // process.env.npm_command !== 'exec'
20
- // )
21
- // return
22
- //
23
- // // Правим путь к файлу
24
- // const filePath = path.join(
25
- // __dirname.replace('/modules/fixContentBuild', ''),
26
- // 'node_modules',
27
- // '@nuxt',
28
- // 'content',
29
- // 'dist',
30
- // 'runtime',
31
- // 'legacy',
32
- // 'composables',
33
- // 'query.mjs'
34
- // )
35
- // const searchString = '/query/${hash(params)}'
36
- // const replacementString = 'cache'
37
- // replaceFileContent(filePath, searchString, replacementString)
38
- // // End block
39
- //
40
- // // Переносим весь контент и удаляем все файлы кроме картинок
41
- // const contentPath = path.join(
42
- // __dirname.replace('/modules/fixContentBuild', ''),
43
- // 'content',
44
- // 'help'
45
- // )
46
- // if (!fs.existsSync(contentPath)) return;
47
- //
48
- // const publicPath = path.join(
49
- // __dirname.replace('/modules/fixContentBuild', ''),
50
- // 'public',
51
- // 'help',
52
- // 'images'
53
- // )
54
- // fs.cp(contentPath, publicPath, { recursive: true }, () => {
55
- // // Удаляем все файлы кроме картинок
56
- // removeNonImageFiles(publicPath)
57
- //
58
- // // Удаляем картинки из папки content
59
- // removeImagesFromContent(contentPath)
60
- // })
61
- // // End block
62
- //
63
- // // Правим путь к картинкам
64
- // updateImagesPath(contentPath)
65
- // }
66
- // })
67
- // @ts-ignore
68
- export default defineNuxtModule(() => {
69
- if (
70
- process.env.NODE_ENV === 'development' ||
71
- process.env.npm_command !== 'exec'
72
- )
73
- return
11
+ export default defineNuxtModule({
12
+ meta: {
13
+ name: 'fix-content-build',
14
+ configKey: 'fixContentBuild',
15
+ },
16
+ setup() {
17
+ if (
18
+ process.env.NODE_ENV === 'development' ||
19
+ process.env.npm_command !== 'exec'
20
+ )
21
+ return
74
22
 
75
- // Правим путь к файлу
76
- const filePath = path.join(
77
- __dirname.replace('/modules/fixContentBuild', ''),
78
- 'node_modules',
79
- '@nuxt',
80
- 'content',
81
- 'dist',
82
- 'runtime',
83
- 'legacy',
84
- 'composables',
85
- 'query.mjs'
86
- )
87
- const searchString = '/query/${hash(params)}'
88
- const replacementString = 'cache'
89
- replaceFileContent(filePath, searchString, replacementString)
90
- // End block
23
+ // Правим путь к файлу
24
+ const filePath = path.join(
25
+ __dirname.replace('/bfg-common/modules/fixContentBuild', ''),
26
+ '@nuxt',
27
+ 'content',
28
+ 'dist',
29
+ 'runtime',
30
+ 'legacy',
31
+ 'composables',
32
+ 'query.mjs'
33
+ )
34
+ const searchString = '/query/${hash(params)}'
35
+ const replacementString = 'cache'
36
+ replaceFileContent(filePath, searchString, replacementString)
37
+ // End block
91
38
 
92
- // Переносим весь контент и удаляем все файлы кроме картинок
93
- const contentPath = path.join(
94
- __dirname.replace('/modules/fixContentBuild', ''),
95
- 'content',
96
- 'help'
97
- )
98
- if (!fs.existsSync(contentPath)) return;
39
+ // Переносим весь контент и удаляем все файлы кроме картинок
40
+ const contentPath = path.join(
41
+ __dirname.replace('/node_modules/bfg-common/modules/fixContentBuild', ''),
42
+ 'content',
43
+ 'help'
44
+ )
45
+ if (!fs.existsSync(contentPath)) return
99
46
 
100
- const publicPath = path.join(
101
- __dirname.replace('/modules/fixContentBuild', ''),
102
- 'public',
103
- 'help',
104
- 'images'
105
- )
106
- fs.cp(contentPath, publicPath, { recursive: true }, () => {
107
- // Удаляем все файлы кроме картинок
108
- removeNonImageFiles(publicPath)
47
+ const publicPath = path.join(
48
+ __dirname.replace('/node_modules/bfg-common/modules/fixContentBuild', ''),
49
+ 'public',
50
+ 'help',
51
+ 'images'
52
+ )
53
+ fs.cp(contentPath, publicPath, { recursive: true }, () => {
54
+ // Удаляем все файлы кроме картинок
55
+ removeNonImageFiles(publicPath)
109
56
 
110
- // Удаляем картинки из папки content
111
- removeImagesFromContent(contentPath)
112
- })
113
- // End block
57
+ // Удаляем картинки из папки content
58
+ removeImagesFromContent(contentPath)
59
+ })
60
+ // End block
114
61
 
115
- // Правим путь к картинкам
116
- updateImagesPath(contentPath)
62
+ // Правим путь к картинкам
63
+ updateImagesPath(contentPath)
64
+ },
117
65
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.0.97",
4
+ "version": "1.0.98",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -0,0 +1,34 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ import type{ NuxtPage } from '@nuxt/schema'
4
+
5
+ export const getMaxDepth = (dirPath: string, currentDepth = 0) => {
6
+ let maxDepth = currentDepth
7
+
8
+ const contents = fs.readdirSync(dirPath)
9
+ for (const item of contents) {
10
+ const itemPath = path.join(dirPath, item)
11
+ if (fs.statSync(itemPath).isDirectory()) {
12
+ const depth = getMaxDepth(itemPath, currentDepth + 1)
13
+ maxDepth = Math.max(maxDepth, depth)
14
+ }
15
+ }
16
+
17
+ return maxDepth
18
+ }
19
+
20
+ export const addContentPageRecursion = (
21
+ pages?: NuxtPage[],
22
+ length?: number
23
+ ): void => {
24
+ if (!pages || !length) return
25
+
26
+ pages.push({
27
+ name: `help-slug-${length}`,
28
+ path: `:slug${length}()`,
29
+ file: '~/pages/help/[slug].vue',
30
+ children: [],
31
+ })
32
+
33
+ addContentPageRecursion(pages[0].children, length - 1)
34
+ }