@dxtmisha/scripts 0.5.21 → 0.5.23

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.
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env vite-node
2
2
 
3
3
  import { PackageInit } from '../src/classes/Package/PackageInit'
4
+ import { UI_DIR_PACKAGES } from '../src/config'
4
5
 
5
6
  const type: string = process.argv?.[2] ?? 'library'
6
7
  const templates: string | undefined = process.argv?.[3]
8
+ const dir: string | undefined = process.argv?.[4] ?? UI_DIR_PACKAGES
7
9
 
8
- new PackageInit(type, templates).make()
10
+ new PackageInit(type, templates, dir).make()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/scripts",
3
3
  "private": false,
4
- "version": "0.5.21",
4
+ "version": "0.5.23",
5
5
  "type": "module",
6
6
  "description": "Development scripts and CLI tools for DXT UI projects - automated component generation, library building and project management tools",
7
7
  "keywords": [
@@ -25,6 +25,7 @@ const FILE_PROPERTIES = 'properties.json'
25
25
  const FILE_PROPS = 'props.ts'
26
26
  const FILE_STYLE = 'styleToken.scss'
27
27
  const FILE_CLASS = 'DesignComponent.vue'
28
+ const FILE_CLASS_AI = 'DesignComponentWikiAi.vue'
28
29
  const FILE_INDEX = 'index.ts'
29
30
  const FILE_WIKI = 'wiki.ts'
30
31
  const FILE_STORIES = 'DesignComponent.stories.ts'
@@ -72,6 +73,7 @@ export class DesignComponent extends DesignCommand {
72
73
  .makeProps()
73
74
  .makeStyle()
74
75
  .makeMain()
76
+ .makeMainAi()
75
77
  .makeIndex()
76
78
  .makeWiki()
77
79
  .makeStories()
@@ -145,6 +147,52 @@ export class DesignComponent extends DesignCommand {
145
147
  return this
146
148
  }
147
149
 
150
+ /**
151
+ * This code generates the DesignComponentWikiAi.vue.
152
+ *
153
+ * Генерация файла DesignComponentWikiAi.vue.
154
+ */
155
+ protected makeMainAi(): this {
156
+ const file = FILE_CLASS_AI
157
+ const sample = this.readDefinable(file)
158
+ const design = this.getStructure().getDesignFirst()
159
+ const componentName = this.getStructure().getComponentNameFirst()
160
+ const fullComponentName = this.getStructure().getFullComponentName()
161
+ const item = this.getWikiDescription()
162
+
163
+ if (
164
+ item?.ai
165
+ ) {
166
+ if (item.ai.render) {
167
+ const render = item.ai.render
168
+ .replace(`<${componentName}`, `<${fullComponentName}`)
169
+ .trim()
170
+
171
+ sample.replaceMark('component-render', [
172
+ '<template #render="{ args, classDemo }">',
173
+ render,
174
+ '</template>'
175
+ ])
176
+ }
177
+
178
+ if (item.ai.import) {
179
+ sample.replaceMark('component-import', [
180
+ '<template #render="{ args, classDemo }">',
181
+ ...item.ai.import,
182
+ '</template>'
183
+ ])
184
+ }
185
+ }
186
+
187
+ this.write(
188
+ sample.getNameFile(file),
189
+ sample.get()
190
+ .replace('design="Design"', `design="${design}"`)
191
+ )
192
+
193
+ return this
194
+ }
195
+
148
196
  /**
149
197
  * This code generates the index.ts.
150
198
  *
@@ -112,8 +112,16 @@ export class DesignReplace {
112
112
  data: string[],
113
113
  end = ''
114
114
  ): this {
115
- const regName = `\\[?\\/\\/[\\]: #\\(]+:${name} `
116
- const space = this.sample.match(new RegExp(`^( *)(${regName})`, 'm'))?.[1]
115
+ let regName = `\\[?\\/\\/[\\]: #\\(]+:${name} `
116
+ let space = this.sample.match(new RegExp(`^( *)(${regName})`, 'm'))?.[1]
117
+
118
+ if (
119
+ !space
120
+ && this.sample.match(name)
121
+ ) {
122
+ regName = `<!-- :${name} `
123
+ space = this.sample.match(new RegExp(`^( *)(${regName})`, 'm'))?.[1]
124
+ }
117
125
 
118
126
  if (typeof space === 'string') {
119
127
  const inString = `\r\n${space}`
@@ -13,7 +13,8 @@ import { UI_DIR_PACKAGES } from '../../config'
13
13
  export class PackageInit {
14
14
  constructor(
15
15
  protected readonly type: string,
16
- protected readonly templates?: string
16
+ protected readonly templates?: string,
17
+ protected readonly dir: string = UI_DIR_PACKAGES
17
18
  ) {
18
19
  }
19
20
 
@@ -27,7 +28,7 @@ export class PackageInit {
27
28
 
28
29
  this.getDirs()
29
30
  .forEach((dir) => {
30
- new PackageInitItem(dir, [UI_DIR_PACKAGES, dir], this.type, this.templates).make()
31
+ new PackageInitItem(dir, [this.dir, dir], this.type, this.templates).make()
31
32
  })
32
33
  }
33
34
 
@@ -37,9 +38,9 @@ export class PackageInit {
37
38
  * Возвращает массив имен директорий для инициализации пакета.
38
39
  */
39
40
  protected getDirs(): string[] {
40
- return PropertiesFile.readDir(UI_DIR_PACKAGES)
41
+ return PropertiesFile.readDir(this.dir)
41
42
  .filter(
42
- path => PropertiesFile.readDir([UI_DIR_PACKAGES, path]).length === 0
43
+ path => PropertiesFile.readDir([this.dir, path]).length === 0
43
44
  )
44
45
  }
45
46
  }
@@ -235,13 +235,13 @@ export class PackageInitItem {
235
235
  let edit = false
236
236
 
237
237
  if (
238
- packageFile.match(/["']devDependencies["']/)
238
+ packageFile.match(/["']dependencies["']/)
239
239
  ) {
240
- console.log('Update package.json: devDependencies...')
240
+ console.log('Update package.json: dependencies...')
241
241
 
242
242
  edit = true
243
243
  packageFile = packageFile.replace(
244
- /(["']devDependencies["']:[^{]+{)/,
244
+ /(["']dependencies["']:[^{]+{)/,
245
245
  `$1
246
246
  "${this.getProjectName()}": "workspace:*",`
247
247
  )
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ // :component.once import { DxtTestWiki } from '@dxtmisha/test'
3
+ // :component.once import { DesignComponent } from './index'
4
+ // :component.once import { ComponentWikiStorybook } from './wiki'
5
+
6
+ // :component-import [!] System label / Системная метка
7
+ // :component-import [!] System label / Системная метка
8
+
9
+ defineOptions({
10
+ name: 'DesignComponentWikiAi'
11
+ })
12
+ </script>
13
+
14
+ <!-- :component.once <template> -->
15
+ <!-- :component.once <DxtTestWiki -->
16
+ <!-- :component.once design="Design" -->
17
+ <!-- :component.once :wiki="ImageWikiStorybook" -->
18
+ <!-- :component.once :component="DesignComponent" -->
19
+ <!-- :component.once > -->
20
+ <!-- :component-render [!] System label / Системная метка -->
21
+ <!-- :component-render [!] System label / Системная метка -->
22
+ <!-- :component.once </DxtTestWiki> -->
23
+ <!-- :component.once </template> -->
24
+
25
+ <style lang="scss"></style>
@@ -1,4 +1,14 @@
1
- import { viteBasic } from '@dxtmisha/configuration/viteBasic'
1
+ import { viteBasicFunction } from '@dxtmisha/configuration/viteBasicFunction'
2
2
 
3
3
  // https://vite.dev/config/
4
- export default viteBasic
4
+ export default viteBasicFunction(
5
+ undefined,
6
+ undefined,
7
+ undefined,
8
+ undefined,
9
+ undefined,
10
+ undefined,
11
+ undefined,
12
+ undefined,
13
+ true
14
+ )