@dxtmisha/scripts 0.6.3 → 0.7.6
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/bin/ai-doc.ts +1 -3
- package/bin/build-functional.ts +5 -0
- package/bin/design-flags.ts +5 -0
- package/bin/design-wiki-storm.ts +9 -0
- package/package.json +14 -8
- package/src/classes/Ai/AiAbstract.ts +14 -1
- package/src/classes/Ai/AiGoogleLite.ts +2 -1
- package/src/classes/Build/__tests__/buildFunctional.test.ts +43 -0
- package/src/classes/Build/buildFunctional.ts +54 -0
- package/src/classes/Component/ComponentCreator.ts +1 -0
- package/src/classes/Component/ComponentItem.ts +15 -0
- package/src/classes/Component/ComponentWiki.ts +8 -0
- package/src/classes/Component/ComponentWikiFile.ts +2 -0
- package/src/classes/Component/__tests__/ComponentCreator.test.ts +71 -0
- package/src/classes/Component/__tests__/ComponentItem.test.ts +71 -0
- package/src/classes/Design/DesignCommand.ts +65 -10
- package/src/classes/Design/DesignComponent.ts +303 -39
- package/src/classes/Design/DesignConstructor.ts +49 -20
- package/src/classes/Design/DesignConstructors.ts +61 -2
- package/src/classes/Design/DesignFlags.ts +215 -0
- package/src/classes/Design/DesignReplace.ts +11 -7
- package/src/classes/Design/DesignStructure.ts +8 -6
- package/src/classes/Design/DesignStructureClasses.ts +8 -4
- package/src/classes/Design/DesignStructureItemAbstract.ts +11 -2
- package/src/classes/Design/DesignStructureRead.ts +8 -4
- package/src/classes/Design/DesignStructureStyles.ts +8 -4
- package/src/classes/Design/DesignTypes.ts +53 -28
- package/src/classes/Design/DesignTypescript.ts +11 -2
- package/src/classes/Design/DesignUi.ts +74 -4
- package/src/classes/Design/DesignWiki.ts +4 -6
- package/src/classes/Design/DesignWikiStorm.ts +94 -0
- package/src/classes/Design/DesignWikiStormItem.ts +246 -0
- package/src/classes/Git/GitRead.ts +1 -0
- package/src/classes/Git/__tests__/GitRead.test.ts +70 -0
- package/src/classes/Library/LibraryAiWiki.ts +127 -0
- package/src/classes/Library/LibraryAiWikiItem.ts +79 -0
- package/src/classes/Library/LibraryExport.ts +0 -2
- package/src/classes/Library/LibraryFlags.ts +9 -7
- package/src/classes/Library/LibraryItems.ts +22 -13
- package/src/classes/Library/LibraryList.ts +189 -0
- package/src/classes/Library/LibraryMedia.ts +22 -8
- package/src/classes/Library/LibraryPlugin.ts +73 -0
- package/src/classes/Library/LibraryTypes.ts +130 -0
- package/src/classes/Package/PackageInit.ts +12 -4
- package/src/classes/Package/PackageItem.ts +16 -5
- package/src/classes/Properties/Properties.ts +14 -3
- package/src/classes/Properties/PropertiesCache.ts +19 -20
- package/src/classes/Properties/PropertiesConfig.ts +46 -26
- package/src/classes/Properties/PropertiesConvector.ts +10 -6
- package/src/classes/Properties/PropertiesFile.ts +27 -31
- package/src/classes/Properties/PropertiesImport.ts +10 -7
- package/src/classes/Properties/PropertiesItems.ts +19 -12
- package/src/classes/Properties/PropertiesKeys.ts +15 -9
- package/src/classes/Properties/PropertiesMain.ts +13 -7
- package/src/classes/Properties/PropertiesPalette.ts +12 -6
- package/src/classes/Properties/PropertiesPath.ts +17 -11
- package/src/classes/Properties/PropertiesScss.ts +10 -8
- package/src/classes/Properties/PropertiesSeparator.ts +9 -11
- package/src/classes/Properties/PropertiesSettings.ts +8 -6
- package/src/classes/Properties/PropertiesStandard.ts +5 -6
- package/src/classes/Properties/PropertiesTool.ts +16 -9
- package/src/classes/Properties/PropertiesTypes.ts +12 -12
- package/src/classes/Properties/PropertiesValues.ts +14 -14
- package/src/classes/Properties/PropertiesWrap.ts +5 -6
- package/src/classes/Properties/convector/convectorColor.ts +5 -3
- package/src/classes/Properties/to/PropertiesToAbstract.ts +18 -4
- package/src/classes/Styles/Styles.ts +1 -0
- package/src/composables/__tests__/useAi.test.ts +75 -0
- package/src/config.ts +9 -0
- package/src/functions/__tests__/getComponentPaths.test.ts +19 -0
- package/src/functions/__tests__/getConfigAi.test.ts +26 -0
- package/src/functions/__tests__/getConstructorProperties.test.ts +51 -0
- package/src/functions/__tests__/getDirname.test.ts +31 -0
- package/src/functions/__tests__/getNameDirByPaths.test.ts +40 -0
- package/src/functions/__tests__/getPackageJson.test.ts +34 -0
- package/src/functions/__tests__/hasNativeDirname.test.ts +18 -0
- package/src/functions/__tests__/toPathStandardSep.test.ts +31 -0
- package/src/functions/getConfigAi.ts +3 -2
- package/src/functions/toPathStandardSep.ts +1 -1
- package/src/library-ai.ts +0 -1
- package/src/library.ts +10 -0
- package/src/media/properties/css.ts +3 -1
- package/src/media/templates/component/{DesignComponentWikiAi.vue → DesignComponentAiWiki.vue} +2 -2
- package/src/media/templates/component/props.ts +2 -3
- package/src/media/templates/component/styleToken.scss +1 -1
- package/src/media/templates/component/wiki.ts +6 -12
- package/src/media/templates/component/wikiData.ts +28 -0
- package/src/media/templates/constructors/props.ts +3 -4
- package/src/media/templates/packages/figma/README.md +1 -0
- package/src/media/templates/packages/figma/ai.sample.config.ts +2 -0
- package/src/media/templates/packages/figma/design.config.json +3 -0
- package/src/media/templates/packages/figma/index.html +12 -0
- package/src/media/templates/packages/figma/manifest.json +25 -0
- package/src/media/templates/packages/figma/package.json +37 -0
- package/src/media/templates/packages/figma/src/App.vue +9 -0
- package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/code.ts +16 -0
- package/src/media/templates/packages/figma/src/components/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/library.ts +0 -0
- package/src/media/templates/packages/figma/src/main.ts +4 -0
- package/src/media/templates/packages/figma/src/media/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/types/_.gitignore.txt +1 -0
- package/src/media/templates/packages/figma/src/vite-env.d.ts +1 -0
- package/src/media/templates/packages/figma/tsconfig.app.json +12 -0
- package/src/media/templates/packages/figma/tsconfig.json +7 -0
- package/src/media/templates/packages/figma/tsconfig.node.json +8 -0
- package/src/media/templates/packages/figma/vite.config.ts +7 -0
- package/src/media/templates/packages/library/src/main.ts +1 -1
- package/src/media/templates/packages/project/design.config.json +3 -0
- package/src/media/templates/packages/project/index.html +1 -2
- package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/main.ts +2 -1
- package/src/media/templates/packages/project/src/vite-env.d.ts +1 -0
- package/src/types/configTypes.ts +6 -0
- package/src/types/designTypes.ts +12 -0
- package/src/types/libraryTypes.ts +1 -1
- package/src/types/webTypes.ts +105 -0
- /package/src/media/templates/packages/{library/public/_.gitignore.txt → figma/src/config.ts} +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// export:none
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
forEach,
|
|
5
|
+
isObjectNotArray,
|
|
6
|
+
replaceComponentName,
|
|
7
|
+
toArray,
|
|
8
|
+
toCamelCase
|
|
9
|
+
} from '@dxtmisha/functional-basic'
|
|
4
10
|
import { wikiDescriptions } from '@dxtmisha/wiki/media'
|
|
5
11
|
import type { StorybookComponentsDescriptionItem } from '@dxtmisha/wiki'
|
|
6
12
|
|
|
@@ -14,8 +20,10 @@ import type { DesignReplace } from './DesignReplace'
|
|
|
14
20
|
import {
|
|
15
21
|
UI_DIR_COMPONENTS,
|
|
16
22
|
UI_DIR_CONSTRUCTOR,
|
|
23
|
+
UI_DIR_DIST,
|
|
17
24
|
UI_DIR_IN,
|
|
18
25
|
UI_DIRS_COMPONENTS,
|
|
26
|
+
UI_DIRS_LIBRARY,
|
|
19
27
|
UI_PROJECT_CONSTRUCTOR_FULL_NAME,
|
|
20
28
|
UI_PROJECT_CONSTRUCTOR_NAME
|
|
21
29
|
} from '../../config'
|
|
@@ -25,26 +33,34 @@ const FILE_PROPERTIES = 'properties.json'
|
|
|
25
33
|
const FILE_PROPS = 'props.ts'
|
|
26
34
|
const FILE_STYLE = 'styleToken.scss'
|
|
27
35
|
const FILE_CLASS = 'DesignComponent.vue'
|
|
28
|
-
const FILE_CLASS_AI = '
|
|
36
|
+
const FILE_CLASS_AI = 'DesignComponentAiWiki.vue'
|
|
29
37
|
const FILE_INDEX = 'index.ts'
|
|
38
|
+
const FILE_INDEX_DTS = 'index.d.ts'
|
|
30
39
|
const FILE_WIKI = 'wiki.ts'
|
|
40
|
+
const FILE_WIKI_DATA = 'wikiData.ts'
|
|
31
41
|
const FILE_STORIES = 'DesignComponent.stories.ts'
|
|
32
42
|
const FILE_STORIES_DOCUMENTATION = 'DesignComponent.mdx'
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
|
-
* Class for
|
|
45
|
+
* Class for generating and updating all files and configurations associated with a design system component.
|
|
46
|
+
* It manages the lifecycle of properties, styles, Vue components, stories, and wiki documentation.
|
|
36
47
|
*
|
|
37
|
-
* Класс для
|
|
48
|
+
* Класс для генерации и обновления всех файлов и конфигураций, связанных с компонентом дизайн-системы.
|
|
49
|
+
* Управляет жизненным циклом свойств, стилей, компонентов Vue, историй и вики-документации.
|
|
38
50
|
*/
|
|
39
51
|
export class DesignComponent extends DesignCommand {
|
|
40
52
|
protected DIR_SAMPLE: string = 'component'
|
|
41
53
|
protected dir: string[]
|
|
42
54
|
protected propsType: DesignTypescriptProp[] | undefined
|
|
55
|
+
protected slotsType: DesignTypescriptProp[] | undefined
|
|
56
|
+
protected eventsType: DesignTypescriptProp[] | undefined
|
|
43
57
|
|
|
44
58
|
/**
|
|
45
|
-
* Constructor
|
|
46
|
-
*
|
|
47
|
-
*
|
|
59
|
+
* Constructor for DesignComponent.
|
|
60
|
+
*
|
|
61
|
+
* Конструктор для DesignComponent.
|
|
62
|
+
* @param command component name or command identifier / название компонента или идентификатор команды
|
|
63
|
+
* @param options additional key-value parameters / дополнительные параметры ключ-значение
|
|
48
64
|
*/
|
|
49
65
|
constructor(
|
|
50
66
|
command: string,
|
|
@@ -76,8 +92,11 @@ export class DesignComponent extends DesignCommand {
|
|
|
76
92
|
.makeMainAi()
|
|
77
93
|
.makeIndex()
|
|
78
94
|
.makeWiki()
|
|
95
|
+
.makeWikiData()
|
|
79
96
|
.makeStories()
|
|
80
97
|
.makeStoriesDocumentation()
|
|
98
|
+
.makeFilePackage()
|
|
99
|
+
.makeLibrary()
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
/**
|
|
@@ -163,24 +182,35 @@ export class DesignComponent extends DesignCommand {
|
|
|
163
182
|
if (
|
|
164
183
|
item?.ai
|
|
165
184
|
) {
|
|
185
|
+
const imports: string[] = []
|
|
186
|
+
|
|
166
187
|
if (item.ai.render) {
|
|
167
|
-
|
|
168
|
-
.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'
|
|
175
|
-
|
|
188
|
+
let render = replaceComponentName(
|
|
189
|
+
item.ai.render,
|
|
190
|
+
componentName,
|
|
191
|
+
fullComponentName
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
if (item.ai.render.includes('<button')) {
|
|
195
|
+
imports.push(`import { DxtTestButton } from '@dxtmisha/test'`)
|
|
196
|
+
render = replaceComponentName(render, 'button', 'DxtTestButton')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (render) {
|
|
200
|
+
sample.replaceMark('component-render', [
|
|
201
|
+
'<template #render="{ args, classDemo }">',
|
|
202
|
+
render,
|
|
203
|
+
'</template>'
|
|
204
|
+
])
|
|
205
|
+
}
|
|
176
206
|
}
|
|
177
207
|
|
|
178
208
|
if (item.ai.import) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
imports.push(...item.ai.import)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (imports.length > 0) {
|
|
213
|
+
sample.replaceMark('component-import', imports)
|
|
184
214
|
}
|
|
185
215
|
}
|
|
186
216
|
|
|
@@ -213,11 +243,27 @@ export class DesignComponent extends DesignCommand {
|
|
|
213
243
|
*/
|
|
214
244
|
protected makeWiki(): this {
|
|
215
245
|
const file = FILE_WIKI
|
|
246
|
+
const sample = this.readDefinable(file)
|
|
247
|
+
|
|
248
|
+
this.write(file, sample.get())
|
|
249
|
+
return this
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* This code generates the wikiData.ts.
|
|
254
|
+
*
|
|
255
|
+
* Генерация файла wikiData.ts.
|
|
256
|
+
*/
|
|
257
|
+
protected makeWikiData(): this {
|
|
258
|
+
const file = FILE_WIKI_DATA
|
|
216
259
|
const typeInfo = this.getPropsList()
|
|
260
|
+
const slotsInfo = this.getSlotsList()
|
|
261
|
+
const eventsInfo = this.getEventsList()
|
|
217
262
|
const sample = this.readDefinable(file)
|
|
218
|
-
const props: string[] = []
|
|
219
263
|
|
|
220
264
|
if (typeInfo) {
|
|
265
|
+
const props: string[] = []
|
|
266
|
+
|
|
221
267
|
typeInfo
|
|
222
268
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
223
269
|
.forEach((prop) => {
|
|
@@ -240,6 +286,70 @@ export class DesignComponent extends DesignCommand {
|
|
|
240
286
|
sample.replaceMark('propsList', props, ',')
|
|
241
287
|
}
|
|
242
288
|
|
|
289
|
+
if (slotsInfo) {
|
|
290
|
+
const slots: string[] = []
|
|
291
|
+
|
|
292
|
+
slotsInfo
|
|
293
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
294
|
+
.forEach((slot) => {
|
|
295
|
+
const description = slot.description
|
|
296
|
+
const type = slot.type
|
|
297
|
+
.replace(/\(props: ([^)]+)\) => any/i, '$1')
|
|
298
|
+
.trim()
|
|
299
|
+
|
|
300
|
+
let item: string = ''
|
|
301
|
+
|
|
302
|
+
item += `{ name: '${slot.name}'`
|
|
303
|
+
|
|
304
|
+
if (description) {
|
|
305
|
+
item += `, description: \`${description}\``
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (
|
|
309
|
+
type
|
|
310
|
+
&& type !== 'any'
|
|
311
|
+
) {
|
|
312
|
+
item += `, properties: [{ name: 'props', type: '${type}' }]`
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
item += ` }`
|
|
316
|
+
slots.push(item)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
sample.replaceMark('slotsList', slots, ',')
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (eventsInfo) {
|
|
323
|
+
const events: string[] = []
|
|
324
|
+
|
|
325
|
+
eventsInfo
|
|
326
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
327
|
+
.forEach((event) => {
|
|
328
|
+
const description = event.description
|
|
329
|
+
const type = event.type
|
|
330
|
+
|
|
331
|
+
let item: string = ''
|
|
332
|
+
|
|
333
|
+
item += `{ name: '${event.name}'`
|
|
334
|
+
|
|
335
|
+
if (description) {
|
|
336
|
+
item += `, description: \`${description}\``
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (
|
|
340
|
+
type
|
|
341
|
+
&& type !== '[]'
|
|
342
|
+
) {
|
|
343
|
+
item += `, properties: ${type}`
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
item += ` }`
|
|
347
|
+
events.push(item)
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
sample.replaceMark('eventsList', events, ',')
|
|
351
|
+
}
|
|
352
|
+
|
|
243
353
|
this.write(file, sample.get())
|
|
244
354
|
return this
|
|
245
355
|
}
|
|
@@ -300,6 +410,65 @@ export class DesignComponent extends DesignCommand {
|
|
|
300
410
|
return constructor ?? ''
|
|
301
411
|
}
|
|
302
412
|
|
|
413
|
+
/**
|
|
414
|
+
* Getting the paths for the typescript compiler.
|
|
415
|
+
*
|
|
416
|
+
* Получение путей для компилятора typescript.
|
|
417
|
+
* @returns paths for the typescript compiler/ пути для компилятора typescript
|
|
418
|
+
*/
|
|
419
|
+
private getTypescriptPaths(): string[] | undefined {
|
|
420
|
+
const root = PropertiesFile.getRootProject()
|
|
421
|
+
const componentName = this.getStructure().getComponentNameFirst()
|
|
422
|
+
|
|
423
|
+
if (root) {
|
|
424
|
+
return [
|
|
425
|
+
root,
|
|
426
|
+
UI_PROJECT_CONSTRUCTOR_NAME,
|
|
427
|
+
UI_DIR_DIST,
|
|
428
|
+
UI_DIR_CONSTRUCTOR,
|
|
429
|
+
componentName
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return undefined
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Getting the path to the index file.
|
|
438
|
+
*
|
|
439
|
+
* Получение пути к файлу index.
|
|
440
|
+
*/
|
|
441
|
+
private getTypescriptPathsIndex(): string | undefined {
|
|
442
|
+
const paths = this.getTypescriptPaths()
|
|
443
|
+
|
|
444
|
+
if (paths) {
|
|
445
|
+
return PropertiesFile.joinPath([
|
|
446
|
+
...paths,
|
|
447
|
+
FILE_INDEX_DTS
|
|
448
|
+
])
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return undefined
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Getting the path to the type file.
|
|
456
|
+
*
|
|
457
|
+
* Получение пути к файлу type.
|
|
458
|
+
*/
|
|
459
|
+
private getTypescriptPathsType(): string | undefined {
|
|
460
|
+
const paths = this.getTypescriptPaths()
|
|
461
|
+
|
|
462
|
+
if (paths) {
|
|
463
|
+
return PropertiesFile.joinPath([
|
|
464
|
+
...paths,
|
|
465
|
+
'types.d.ts'
|
|
466
|
+
])
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return undefined
|
|
470
|
+
}
|
|
471
|
+
|
|
303
472
|
/**
|
|
304
473
|
* Getting a list of all properties of a component.
|
|
305
474
|
*
|
|
@@ -307,11 +476,11 @@ export class DesignComponent extends DesignCommand {
|
|
|
307
476
|
*/
|
|
308
477
|
private getPropsList(): DesignTypescriptProp[] | undefined {
|
|
309
478
|
if (!this.propsType) {
|
|
310
|
-
const
|
|
479
|
+
const paths = this.getTypescriptPathsIndex()
|
|
311
480
|
const componentName = this.getStructure().getComponentNameFirst()
|
|
312
481
|
|
|
313
|
-
if (
|
|
314
|
-
const
|
|
482
|
+
if (paths) {
|
|
483
|
+
const tsRead = new DesignTypescript(
|
|
315
484
|
PropertiesFile.joinPath([
|
|
316
485
|
PropertiesFile.getRoot(),
|
|
317
486
|
UI_DIR_IN,
|
|
@@ -322,27 +491,63 @@ export class DesignComponent extends DesignCommand {
|
|
|
322
491
|
]),
|
|
323
492
|
{
|
|
324
493
|
paths: {
|
|
325
|
-
[`${UI_PROJECT_CONSTRUCTOR_FULL_NAME}/${componentName}`]: [
|
|
326
|
-
PropertiesFile.joinPath([
|
|
327
|
-
root,
|
|
328
|
-
UI_PROJECT_CONSTRUCTOR_NAME,
|
|
329
|
-
UI_DIR_IN,
|
|
330
|
-
UI_DIR_CONSTRUCTOR,
|
|
331
|
-
componentName,
|
|
332
|
-
FILE_INDEX
|
|
333
|
-
])
|
|
334
|
-
]
|
|
494
|
+
[`${UI_PROJECT_CONSTRUCTOR_FULL_NAME}/${componentName}`]: [paths]
|
|
335
495
|
}
|
|
336
496
|
}
|
|
337
497
|
)
|
|
338
498
|
|
|
339
|
-
this.propsType =
|
|
499
|
+
this.propsType = tsRead.getType(`${componentName}Props`)?.props
|
|
340
500
|
}
|
|
341
501
|
}
|
|
342
502
|
|
|
343
503
|
return this.propsType
|
|
344
504
|
}
|
|
345
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Getting a list of all slots of a component.
|
|
508
|
+
*
|
|
509
|
+
* Получение списка всех слотов компонента.
|
|
510
|
+
*/
|
|
511
|
+
private getSlotsList(): DesignTypescriptProp[] | undefined {
|
|
512
|
+
if (!this.slotsType) {
|
|
513
|
+
const types = this.getTypesFromConstructor('Slots')
|
|
514
|
+
|
|
515
|
+
if (types) {
|
|
516
|
+
this.slotsType = types
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return this.slotsType
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Getting a list of all events of a component.
|
|
525
|
+
*
|
|
526
|
+
* Получение списка всех событий компонента.
|
|
527
|
+
*/
|
|
528
|
+
private getEventsList(): DesignTypescriptProp[] | undefined {
|
|
529
|
+
if (!this.eventsType) {
|
|
530
|
+
const types = this.getTypesFromConstructor('Emits')
|
|
531
|
+
|
|
532
|
+
if (types) {
|
|
533
|
+
this.eventsType = forEach(
|
|
534
|
+
types,
|
|
535
|
+
(item) => {
|
|
536
|
+
return {
|
|
537
|
+
name: item.name,
|
|
538
|
+
type: String(item.type)
|
|
539
|
+
.replace(/([^:,[\] ]+): ([^:,[\]]+)/gi, `{ name: '$1', type: '$2' }`)
|
|
540
|
+
.replace(/,{/gi, ', {'),
|
|
541
|
+
description: item.description
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return this.eventsType
|
|
549
|
+
}
|
|
550
|
+
|
|
346
551
|
/**
|
|
347
552
|
* Returns the description of the component from the wiki
|
|
348
553
|
*
|
|
@@ -377,6 +582,24 @@ export class DesignComponent extends DesignCommand {
|
|
|
377
582
|
return []
|
|
378
583
|
}
|
|
379
584
|
|
|
585
|
+
/**
|
|
586
|
+
* Getting the types from the constructor.
|
|
587
|
+
*
|
|
588
|
+
* Получение типов из конструктора.
|
|
589
|
+
* @param name name of the type/ имя типа
|
|
590
|
+
*/
|
|
591
|
+
private getTypesFromConstructor(name: string): DesignTypescriptProp[] | undefined {
|
|
592
|
+
const paths = this.getTypescriptPathsType()
|
|
593
|
+
const componentName = this.getStructure().getComponentNameFirst()
|
|
594
|
+
|
|
595
|
+
if (paths) {
|
|
596
|
+
const tsRead = new DesignTypescript(paths)
|
|
597
|
+
return tsRead.getType(`${componentName}${name}`)?.props
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return undefined
|
|
601
|
+
}
|
|
602
|
+
|
|
380
603
|
/**
|
|
381
604
|
* Converts the code to the component name.
|
|
382
605
|
*
|
|
@@ -385,11 +608,12 @@ export class DesignComponent extends DesignCommand {
|
|
|
385
608
|
*/
|
|
386
609
|
private toComponentName(code: string): string {
|
|
387
610
|
const design = this.getStructure().getDesignFirst()
|
|
388
|
-
const name = this.getStructure().
|
|
611
|
+
const name = this.getStructure().getComponentName()
|
|
612
|
+
const fullName = this.getStructure().getFullComponentName()
|
|
389
613
|
|
|
390
614
|
return code
|
|
391
|
-
.replace(/DesignComponent/g,
|
|
392
|
-
.replace(/design-component/g,
|
|
615
|
+
.replace(/DesignComponent/g, fullName).trim()
|
|
616
|
+
.replace(/design-component/g, `${toCamelCase(design)}-${toCamelCase(name)}`).trim()
|
|
393
617
|
.replace(/<(\/?)Design/g, `<$1${design}`)
|
|
394
618
|
}
|
|
395
619
|
|
|
@@ -557,4 +781,44 @@ export class DesignComponent extends DesignCommand {
|
|
|
557
781
|
|
|
558
782
|
return this
|
|
559
783
|
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Updates the package.json file.
|
|
787
|
+
*
|
|
788
|
+
* Обновляет файл package.json.
|
|
789
|
+
*/
|
|
790
|
+
protected makeFilePackage(): this {
|
|
791
|
+
const name = `./${this.getFullName()}`
|
|
792
|
+
|
|
793
|
+
this.updatePackage(
|
|
794
|
+
`exports|${name}`,
|
|
795
|
+
{
|
|
796
|
+
types: `./dist/library/${this.getFullName()}.d.ts`,
|
|
797
|
+
default: `./dist/${this.getFullName()}.js`
|
|
798
|
+
}
|
|
799
|
+
)
|
|
800
|
+
|
|
801
|
+
return this
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Generates a library file.
|
|
806
|
+
*
|
|
807
|
+
* Генерирует файл библиотеки.
|
|
808
|
+
*/
|
|
809
|
+
protected makeLibrary(): this {
|
|
810
|
+
const dir: string = `../${UI_DIR_COMPONENTS}/${this.getProjectName()}/${this.getName()}/`
|
|
811
|
+
const name = this.getFullName()
|
|
812
|
+
|
|
813
|
+
PropertiesFile.writeByPath(
|
|
814
|
+
[...UI_DIRS_LIBRARY, `${name}.ts`],
|
|
815
|
+
`// This file is generated by a script, do not edit.
|
|
816
|
+
// Этот файл генерируется скриптом, не редактировать.
|
|
817
|
+
|
|
818
|
+
export * from '${dir}index.js'
|
|
819
|
+
`
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
return this
|
|
823
|
+
}
|
|
560
824
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// export:none
|
|
2
2
|
|
|
3
|
-
import { toCamelCaseFirst } from '@dxtmisha/functional-basic'
|
|
3
|
+
import { toCamelCase, toCamelCaseFirst } from '@dxtmisha/functional-basic'
|
|
4
4
|
|
|
5
5
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
6
6
|
|
|
7
7
|
import { DesignCommand } from './DesignCommand'
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { UI_DIR_IN, UI_DIR_CONSTRUCTOR, UI_DIRS_LIBRARY } from '../../config'
|
|
10
10
|
|
|
11
11
|
const FILE_PROPERTIES = 'properties.json'
|
|
12
12
|
const FILE_PROPS = 'props.ts'
|
|
@@ -18,18 +18,22 @@ const FILE_CLASS = 'ConstructorsDesign.tsx'
|
|
|
18
18
|
const FILE_INDEX = 'index.ts'
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Class for generating files based on a constructor.
|
|
21
|
+
* Class for generating files and configurations based on a component's constructor.
|
|
22
|
+
* It automates the creation of property definitions, type files, styles, and integration logic for constructors.
|
|
22
23
|
*
|
|
23
|
-
* Класс для генерации файлов
|
|
24
|
+
* Класс для генерации файлов и конфигураций на основе конструктора компонента.
|
|
25
|
+
* Автоматизирует создание определений свойств, файлов типов, стилей и логики интеграции для конструкторов.
|
|
24
26
|
*/
|
|
25
27
|
export class DesignConstructor extends DesignCommand {
|
|
26
28
|
protected DIR_SAMPLE: string = UI_DIR_CONSTRUCTOR
|
|
27
29
|
protected dir: string[]
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
|
-
* Constructor
|
|
31
|
-
*
|
|
32
|
-
*
|
|
32
|
+
* Constructor for DesignConstructor.
|
|
33
|
+
*
|
|
34
|
+
* Конструктор для DesignConstructor.
|
|
35
|
+
* @param command component name or command identifier / название компонента или идентификатор команды
|
|
36
|
+
* @param options additional key-value parameters / дополнительные параметры ключ-значение
|
|
33
37
|
*/
|
|
34
38
|
constructor(
|
|
35
39
|
command: string,
|
|
@@ -61,6 +65,7 @@ export class DesignConstructor extends DesignCommand {
|
|
|
61
65
|
.makeMain()
|
|
62
66
|
.makeIndex()
|
|
63
67
|
.makeFilePackage()
|
|
68
|
+
.makeLibrary()
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
/**
|
|
@@ -112,9 +117,9 @@ export class DesignConstructor extends DesignCommand {
|
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
/**
|
|
115
|
-
* This code generates the
|
|
120
|
+
* This code generates the basicTypes.ts.
|
|
116
121
|
*
|
|
117
|
-
* Генерация файла
|
|
122
|
+
* Генерация файла basicTypes.ts.
|
|
118
123
|
*/
|
|
119
124
|
protected makeTypesBasic(): this {
|
|
120
125
|
return this.makeFileStandard(FILE_TYPES_BASIC)
|
|
@@ -163,6 +168,12 @@ export class DesignConstructor extends DesignCommand {
|
|
|
163
168
|
return this.makeFileStandard(FILE_INDEX)
|
|
164
169
|
}
|
|
165
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Generates a standard file based on a template.
|
|
173
|
+
*
|
|
174
|
+
* Генерирует стандартный файл на основе шаблона.
|
|
175
|
+
* @param file file name/ имя файла
|
|
176
|
+
*/
|
|
166
177
|
protected makeFileStandard(file: string): this {
|
|
167
178
|
const sample = this.readDefinable(file)
|
|
168
179
|
|
|
@@ -172,21 +183,39 @@ export class DesignConstructor extends DesignCommand {
|
|
|
172
183
|
return this
|
|
173
184
|
}
|
|
174
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Updates the package.json file.
|
|
188
|
+
*
|
|
189
|
+
* Обновляет файл package.json.
|
|
190
|
+
*/
|
|
175
191
|
protected makeFilePackage(): this {
|
|
176
|
-
const
|
|
177
|
-
const command = toCamelCaseFirst(this.getCommand())
|
|
192
|
+
const command = this.getName()
|
|
178
193
|
const name = `./${command}`
|
|
179
194
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
this.updatePackage(
|
|
196
|
+
`exports|${name}`,
|
|
197
|
+
{
|
|
198
|
+
types: `./dist/constructors/${command}/index.d.ts`,
|
|
199
|
+
default: `./dist/${this.getNameMin()}.js`
|
|
200
|
+
}
|
|
201
|
+
)
|
|
187
202
|
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
return this
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Generates a library file.
|
|
208
|
+
*
|
|
209
|
+
* Генерирует файл библиотеки.
|
|
210
|
+
*/
|
|
211
|
+
protected makeLibrary(): this {
|
|
212
|
+
const name = toCamelCase(this.getCommand())
|
|
213
|
+
|
|
214
|
+
PropertiesFile.writeByPath(
|
|
215
|
+
[...UI_DIRS_LIBRARY, `${name}.ts`],
|
|
216
|
+
`export * from '../${UI_DIR_CONSTRUCTOR}/${toCamelCaseFirst(this.getCommand())}/index'
|
|
217
|
+
`
|
|
218
|
+
)
|
|
190
219
|
|
|
191
220
|
return this
|
|
192
221
|
}
|
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
// export:none
|
|
2
2
|
|
|
3
|
-
import { isFilled } from '@dxtmisha/functional-basic'
|
|
3
|
+
import { isFilled, toCamelCaseFirst } from '@dxtmisha/functional-basic'
|
|
4
4
|
|
|
5
5
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
6
6
|
import { PropertiesCache } from '../Properties/PropertiesCache'
|
|
7
7
|
import { DesignConstructor } from './DesignConstructor'
|
|
8
8
|
|
|
9
|
-
import { UI_DIR_CONSTRUCTOR, UI_DIR_IN } from '../../config'
|
|
9
|
+
import { UI_DIR_CONSTRUCTOR, UI_DIR_IN, UI_DIRS_LIBRARY, UI_FILE_STYLE_SCSS } from '../../config'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Class for orchestrating the generation and update of multiple design constructors.
|
|
13
|
+
* It manages the collective lifecycle of component constructors, including bulk updates and shared style generation.
|
|
14
|
+
*
|
|
15
|
+
* Класс для управления генерацией и обновлением нескольких конструкторов дизайна.
|
|
16
|
+
* Управляет коллективным жизненным циклом конструкторов компонентов, включая массовые обновления и генерацию общих стилей.
|
|
17
|
+
*/
|
|
11
18
|
export class DesignConstructors {
|
|
19
|
+
/**
|
|
20
|
+
* Constructor for DesignConstructors.
|
|
21
|
+
*
|
|
22
|
+
* Конструктор для DesignConstructors.
|
|
23
|
+
* @param name optional specific component name to process / необязательное имя конкретного компонента для обработки
|
|
24
|
+
*/
|
|
12
25
|
constructor(
|
|
13
26
|
protected readonly name?: string
|
|
14
27
|
) {
|
|
15
28
|
}
|
|
16
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Starts the process of creating or updating constructors.
|
|
32
|
+
*
|
|
33
|
+
* Запускает процесс создания или обновления конструкторов.
|
|
34
|
+
*/
|
|
17
35
|
make(): void {
|
|
18
36
|
PropertiesCache.clear()
|
|
19
37
|
|
|
@@ -26,12 +44,41 @@ export class DesignConstructors {
|
|
|
26
44
|
new DesignConstructor(component).make()
|
|
27
45
|
})
|
|
28
46
|
}
|
|
47
|
+
|
|
48
|
+
this.makeStyle()
|
|
29
49
|
}
|
|
30
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Returns a list of components.
|
|
53
|
+
*
|
|
54
|
+
* Возвращает список компонентов.
|
|
55
|
+
*/
|
|
31
56
|
getComponents(): string[] {
|
|
32
57
|
return PropertiesFile.readDir(this.getDir())
|
|
33
58
|
}
|
|
34
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Returns a list of component styles.
|
|
62
|
+
*
|
|
63
|
+
* Возвращает список стилей компонентов.
|
|
64
|
+
*/
|
|
65
|
+
getComponentsStyle(): string[] {
|
|
66
|
+
const list: string[] = []
|
|
67
|
+
|
|
68
|
+
this.getComponents()
|
|
69
|
+
.forEach((component) => {
|
|
70
|
+
const name = toCamelCaseFirst(component)
|
|
71
|
+
list.push(`@forward "../constructors/${name}/style";`)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return list
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the directory path for constructors.
|
|
79
|
+
*
|
|
80
|
+
* Возвращает путь к директории конструкторов.
|
|
81
|
+
*/
|
|
35
82
|
protected getDir(): string[] {
|
|
36
83
|
return [
|
|
37
84
|
PropertiesFile.getRoot(),
|
|
@@ -39,4 +86,16 @@ export class DesignConstructors {
|
|
|
39
86
|
UI_DIR_CONSTRUCTOR
|
|
40
87
|
]
|
|
41
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Generates a common style file.
|
|
92
|
+
*
|
|
93
|
+
* Генерирует общий файл стилей.
|
|
94
|
+
*/
|
|
95
|
+
protected makeStyle(): void {
|
|
96
|
+
const path: string[] = [...UI_DIRS_LIBRARY, UI_FILE_STYLE_SCSS]
|
|
97
|
+
const styles = this.getComponentsStyle()
|
|
98
|
+
|
|
99
|
+
PropertiesFile.writeByPath(path, styles.join('\r\n'))
|
|
100
|
+
}
|
|
42
101
|
}
|