@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
|
@@ -5,7 +5,7 @@ import { toCamelCaseFirst, toKebabCase } from '@dxtmisha/functional-basic'
|
|
|
5
5
|
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
6
6
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
7
7
|
|
|
8
|
-
import type { LibraryData,
|
|
8
|
+
import type { LibraryData, LibraryAll } from '../../types/libraryTypes'
|
|
9
9
|
|
|
10
10
|
import { UI_DIRS_LIBRARY, UI_DIRS_COMPONENTS } from '../../config'
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ import { UI_DIRS_LIBRARY, UI_DIRS_COMPONENTS } from '../../config'
|
|
|
15
15
|
* Класс для работы со списком компонентов.
|
|
16
16
|
*/
|
|
17
17
|
export class LibraryItems {
|
|
18
|
-
protected readonly items:
|
|
18
|
+
protected readonly items: LibraryAll
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Constructor
|
|
@@ -29,7 +29,7 @@ export class LibraryItems {
|
|
|
29
29
|
*
|
|
30
30
|
* Возвращает список компонентов, разделенных по группам дизайна.
|
|
31
31
|
*/
|
|
32
|
-
get():
|
|
32
|
+
get(): LibraryAll {
|
|
33
33
|
return this.items
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -46,6 +46,24 @@ export class LibraryItems {
|
|
|
46
46
|
return list
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Returns the number of components.
|
|
51
|
+
*
|
|
52
|
+
* Возвращает количество компонентов.
|
|
53
|
+
*/
|
|
54
|
+
getCount(): number {
|
|
55
|
+
return this.getComponentList().length
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns the path to the design system components directory
|
|
60
|
+
*
|
|
61
|
+
* Возвращает путь к директории компонентов дизайн-системы
|
|
62
|
+
*/
|
|
63
|
+
getComponentsPath(): string[] {
|
|
64
|
+
return [...UI_DIRS_COMPONENTS, PropertiesConfig.getProjectName()]
|
|
65
|
+
}
|
|
66
|
+
|
|
49
67
|
/**
|
|
50
68
|
* Writes data in the file.
|
|
51
69
|
*
|
|
@@ -104,21 +122,12 @@ export class LibraryItems {
|
|
|
104
122
|
return list
|
|
105
123
|
}
|
|
106
124
|
|
|
107
|
-
/**
|
|
108
|
-
* Returns the path to the design system components directory
|
|
109
|
-
*
|
|
110
|
-
* Возвращает путь к директории компонентов дизайн-системы
|
|
111
|
-
*/
|
|
112
|
-
protected getComponentsPath(): string[] {
|
|
113
|
-
return [...UI_DIRS_COMPONENTS, PropertiesConfig.getProjectName()]
|
|
114
|
-
}
|
|
115
|
-
|
|
116
125
|
/**
|
|
117
126
|
* Initializes data about the component.
|
|
118
127
|
*
|
|
119
128
|
* Инициализирует данные о компоненте.
|
|
120
129
|
*/
|
|
121
|
-
protected initItems():
|
|
130
|
+
protected initItems(): LibraryAll {
|
|
122
131
|
return [
|
|
123
132
|
{
|
|
124
133
|
name: PropertiesConfig.getDesignName(),
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { LibraryItems } from './LibraryItems'
|
|
2
|
+
|
|
3
|
+
import { forEach, toCamelCase, toKebabCase, uniqueArray } from '@dxtmisha/functional-basic'
|
|
4
|
+
import { getPackageJson } from '../../functions/getPackageJson'
|
|
5
|
+
|
|
6
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
7
|
+
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
8
|
+
|
|
9
|
+
import { UI_DIRS_STYLES, UI_FILE_NAME_DESIGN } from '../../config'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Class for generating the design system overview file, including component imports and regular expressions.
|
|
13
|
+
*
|
|
14
|
+
* Класс для создания обзорного файла дизайн-системы, включая импорты компонентов и регулярные выражения.
|
|
15
|
+
*/
|
|
16
|
+
export class LibraryList {
|
|
17
|
+
protected readonly packageName: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Constructor for LibraryList.
|
|
21
|
+
*
|
|
22
|
+
* Конструктор для LibraryList.
|
|
23
|
+
* @param items object for working with the list of components / объект для работы со списком компонентов
|
|
24
|
+
*/
|
|
25
|
+
constructor(
|
|
26
|
+
protected readonly items: LibraryItems
|
|
27
|
+
) {
|
|
28
|
+
this.packageName = getPackageJson()?.name
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates the design system overview file (`design.ts`) with metadata and component lists.
|
|
33
|
+
*
|
|
34
|
+
* Создает обзорный файл дизайн-системы (`design.ts`) с метаданными и списками компонентов.
|
|
35
|
+
* @returns this
|
|
36
|
+
*/
|
|
37
|
+
make(): this {
|
|
38
|
+
const list = this.getComponents()
|
|
39
|
+
const listReg = this.getComponentsReg()
|
|
40
|
+
|
|
41
|
+
this.items.write(
|
|
42
|
+
UI_FILE_NAME_DESIGN,
|
|
43
|
+
[
|
|
44
|
+
'import type { PluginComponentImports } from \'@dxtmisha/constructor/plugin\'',
|
|
45
|
+
'',
|
|
46
|
+
`// count: ${this.items.getCount()}`,
|
|
47
|
+
`export const designName: string = '${PropertiesConfig.getDesignName()}'`,
|
|
48
|
+
`export const packageName: string = '${this.packageName}'`,
|
|
49
|
+
`export const componentsReg: RegExp = ${listReg}`,
|
|
50
|
+
`export const styleVarsReg: RegExp = ${this.getVarsReg()}`,
|
|
51
|
+
'',
|
|
52
|
+
'export const componentsList: PluginComponentImports = [',
|
|
53
|
+
list.join(',\r\n'),
|
|
54
|
+
']'
|
|
55
|
+
]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return this
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns a list of components for the file.
|
|
63
|
+
*
|
|
64
|
+
* Возвращает список компонентов для файла.
|
|
65
|
+
*/
|
|
66
|
+
protected getComponents(): string[] {
|
|
67
|
+
const list: string[] = []
|
|
68
|
+
|
|
69
|
+
if (this.packageName) {
|
|
70
|
+
forEach(
|
|
71
|
+
this.items.getComponentList(),
|
|
72
|
+
(item) => {
|
|
73
|
+
list.push(` {
|
|
74
|
+
name: '${item.codeFull}',
|
|
75
|
+
reg: ${this.getReg([item.name], true)}
|
|
76
|
+
}`
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return list
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns a regular expression for all components.
|
|
86
|
+
*
|
|
87
|
+
* Возвращает регулярное выражение для всех компонентов.
|
|
88
|
+
*/
|
|
89
|
+
protected getComponentsReg(): string {
|
|
90
|
+
const names: string[] = forEach(
|
|
91
|
+
this.items.getComponentList(),
|
|
92
|
+
item => item.name
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return this.getReg(names)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns a list of design names.
|
|
100
|
+
*
|
|
101
|
+
* Возвращает список названий дизайнов.
|
|
102
|
+
*/
|
|
103
|
+
protected getDesigns(): string[] {
|
|
104
|
+
return [
|
|
105
|
+
PropertiesConfig.getDesignName(),
|
|
106
|
+
...(PropertiesConfig.getDesignAlternativeName() ?? [])
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Generates a regular expression for the list of names.
|
|
112
|
+
*
|
|
113
|
+
* Генерирует регулярное выражение для списка имен.
|
|
114
|
+
* @param names list of names / список имен
|
|
115
|
+
* @param only exact match / точное совпадение
|
|
116
|
+
*/
|
|
117
|
+
protected getReg(
|
|
118
|
+
names: string[],
|
|
119
|
+
only: boolean = false
|
|
120
|
+
): string {
|
|
121
|
+
const designs = this.getDesigns().join('|')
|
|
122
|
+
const namesReg = this.getRegName(names)
|
|
123
|
+
let code = `((${designs})-?(${namesReg}))`
|
|
124
|
+
|
|
125
|
+
if (only) {
|
|
126
|
+
code = `^${code}$`
|
|
127
|
+
} else {
|
|
128
|
+
code = `${code}(?![\\w-])`
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return `/${code}/ig`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Formats names for regular expression.
|
|
136
|
+
*
|
|
137
|
+
* Форматирует имена для регулярного выражения.
|
|
138
|
+
* @param names list of names / список имен
|
|
139
|
+
*/
|
|
140
|
+
protected getRegName(names: string[]): string {
|
|
141
|
+
return forEach(
|
|
142
|
+
names,
|
|
143
|
+
name => toKebabCase(name)
|
|
144
|
+
.replace('-', '-?')
|
|
145
|
+
).join('|')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns a list of CSS variables.
|
|
150
|
+
*
|
|
151
|
+
* Возвращает список CSS переменных.
|
|
152
|
+
*/
|
|
153
|
+
protected getVars(): string[] {
|
|
154
|
+
const design: string = toCamelCase(PropertiesConfig.getDesignName())
|
|
155
|
+
const path = [...UI_DIRS_STYLES, PropertiesConfig.getProjectName(), 'vars.scss']
|
|
156
|
+
const context = PropertiesFile.readFileOnly(path)
|
|
157
|
+
const data: string[] = []
|
|
158
|
+
|
|
159
|
+
if (context) {
|
|
160
|
+
const vars = context.match(/(?<=--)[^: ]+(?=:)/g)
|
|
161
|
+
|
|
162
|
+
if (vars) {
|
|
163
|
+
vars.forEach((varName) => {
|
|
164
|
+
const value = varName.match(/^([^-]+)-(.*?)$/)
|
|
165
|
+
|
|
166
|
+
if (
|
|
167
|
+
value
|
|
168
|
+
&& value?.[1] === design
|
|
169
|
+
&& value?.[2]
|
|
170
|
+
) {
|
|
171
|
+
const varName = value[2].split('-')
|
|
172
|
+
|
|
173
|
+
if (varName.length > 2) {
|
|
174
|
+
varName.pop()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
data.push(varName.join('-'))
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return uniqueArray(data)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
protected getVarsReg(): string {
|
|
187
|
+
return `/(?<=var\\(--)(${this.getVars().join('|')})/ig`
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
// export:none
|
|
2
2
|
|
|
3
|
-
import { toCamelCase } from '@dxtmisha/functional-basic'
|
|
3
|
+
import { toCamelCase, toCamelCaseFirst } from '@dxtmisha/functional-basic'
|
|
4
4
|
|
|
5
5
|
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
6
6
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
7
7
|
|
|
8
8
|
import { LibraryItems } from './LibraryItems'
|
|
9
9
|
|
|
10
|
-
import { UI_DIRS_ICONS, UI_FILE_NAME_MEDIA } from '../../config'
|
|
10
|
+
import { UI_DIRS_ICONS, UI_FILE_NAME_MEDIA, UI_FILE_NAME_STYLE } from '../../config'
|
|
11
11
|
import type { LibraryIconItem } from '../../types/libraryTypes'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Class for generating
|
|
14
|
+
* Class for generating connection files for media data (primarily icons) and style entry points.
|
|
15
15
|
*
|
|
16
|
-
* Класс для формирования
|
|
16
|
+
* Класс для формирования файлов подключения медиа-данных (прежде всего иконок) и точек входа стилей.
|
|
17
17
|
*/
|
|
18
18
|
export class LibraryMedia {
|
|
19
19
|
/**
|
|
20
|
-
* Constructor
|
|
21
|
-
*
|
|
20
|
+
* Constructor for LibraryMedia.
|
|
21
|
+
*
|
|
22
|
+
* Конструктор для LibraryMedia.
|
|
23
|
+
* @param items object for working with the list of components / объект для работы со списком компонентов
|
|
22
24
|
*/
|
|
23
|
-
|
|
24
25
|
constructor(
|
|
25
26
|
protected readonly items: LibraryItems
|
|
26
27
|
) {
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Generates media connection files and style entries.
|
|
32
|
+
*
|
|
33
|
+
* Генерирует файлы подключения медиа и записи стилей.
|
|
34
|
+
*/
|
|
29
35
|
make(): void {
|
|
36
|
+
const projectName = toCamelCaseFirst(PropertiesConfig.getProjectName())
|
|
30
37
|
const name = toCamelCase(PropertiesConfig.getDesignName())
|
|
31
38
|
const isIcons = this.getIconImport().length > 0
|
|
32
39
|
|
|
@@ -44,6 +51,13 @@ export class LibraryMedia {
|
|
|
44
51
|
]
|
|
45
52
|
)
|
|
46
53
|
}
|
|
54
|
+
|
|
55
|
+
this.items.write(
|
|
56
|
+
UI_FILE_NAME_STYLE,
|
|
57
|
+
[
|
|
58
|
+
`import '../styles/${projectName}/main.scss'`
|
|
59
|
+
]
|
|
60
|
+
)
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
/**
|
|
@@ -117,7 +131,7 @@ export class LibraryMedia {
|
|
|
117
131
|
const data: string[] = []
|
|
118
132
|
|
|
119
133
|
this.getIconImport().forEach((item) => {
|
|
120
|
-
data.push(`
|
|
134
|
+
data.push(`const ${item.name} = async () => (await import('${item.path}'))?.default`)
|
|
121
135
|
})
|
|
122
136
|
|
|
123
137
|
return data
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { toCamelCaseFirst, toKebabCase } from '@dxtmisha/functional-basic'
|
|
2
|
+
|
|
3
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
4
|
+
import { LibraryItems } from './LibraryItems'
|
|
5
|
+
|
|
6
|
+
import { UI_FILE_NAME_PLUGIN } from '../../config'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Class for creating a plugin file for the design system.
|
|
10
|
+
*
|
|
11
|
+
* Класс для создания файла плагина для дизайн-системы.
|
|
12
|
+
*/
|
|
13
|
+
export class LibraryPlugin {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor for LibraryPlugin.
|
|
16
|
+
*
|
|
17
|
+
* Конструктор для LibraryPlugin.
|
|
18
|
+
* @param items object for working with the list of components / объект для работы со списком компонентов
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
protected readonly items: LibraryItems
|
|
22
|
+
) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates a plugin file that initializes the Vite plugin for the library.
|
|
27
|
+
*
|
|
28
|
+
* Создает файл плагина, который инициализирует плагин Vite для библиотеки.
|
|
29
|
+
* @returns this
|
|
30
|
+
*/
|
|
31
|
+
make(): this {
|
|
32
|
+
const design = PropertiesConfig.getDesignName()
|
|
33
|
+
|
|
34
|
+
this.items.write(
|
|
35
|
+
UI_FILE_NAME_PLUGIN,
|
|
36
|
+
[
|
|
37
|
+
'import type { Plugin as VitePlugin } from \'vite\'',
|
|
38
|
+
'import { type PluginOptions, Plugin } from \'@dxtmisha/constructor/plugin\'',
|
|
39
|
+
'',
|
|
40
|
+
'import {',
|
|
41
|
+
' componentsList,',
|
|
42
|
+
' componentsReg,',
|
|
43
|
+
' designName,',
|
|
44
|
+
' packageName,',
|
|
45
|
+
' styleVarsReg',
|
|
46
|
+
'} from \'./design\'',
|
|
47
|
+
'',
|
|
48
|
+
'/**',
|
|
49
|
+
' * Initializes the Vite plugin for the design system.',
|
|
50
|
+
' *',
|
|
51
|
+
' * Инициализирует плагин Vite для дизайн-системы.',
|
|
52
|
+
' * @param options plugin options / настройки плагина',
|
|
53
|
+
' */',
|
|
54
|
+
`export function ui${toCamelCaseFirst(design)}VitePlugin(`,
|
|
55
|
+
' options: PluginOptions = {}',
|
|
56
|
+
'): VitePlugin {',
|
|
57
|
+
' return new Plugin(',
|
|
58
|
+
' designName,',
|
|
59
|
+
' packageName,',
|
|
60
|
+
' componentsReg,',
|
|
61
|
+
' styleVarsReg,',
|
|
62
|
+
' componentsList,',
|
|
63
|
+
` 'vite-plugin-${toKebabCase(design)}-ui',`,
|
|
64
|
+
' options',
|
|
65
|
+
' )',
|
|
66
|
+
' .init()',
|
|
67
|
+
'}'
|
|
68
|
+
]
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return this
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
2
|
+
import { LibraryItems } from './LibraryItems'
|
|
3
|
+
|
|
4
|
+
import type { LibraryData } from '../../types/libraryTypes'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class for generating global type definitions for Vue components.
|
|
8
|
+
*
|
|
9
|
+
* Класс для создания глобальных определений типов для компонентов Vue.
|
|
10
|
+
*/
|
|
11
|
+
export class LibraryTypes {
|
|
12
|
+
/**
|
|
13
|
+
* Constructor for LibraryTypes.
|
|
14
|
+
*
|
|
15
|
+
* Конструктор для LibraryTypes.
|
|
16
|
+
* @param items object for working with the list of components / объект для работы со списком компонентов
|
|
17
|
+
*/
|
|
18
|
+
constructor(
|
|
19
|
+
protected readonly items: LibraryItems
|
|
20
|
+
) {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates the type definition file (`types.d.ts`) for global Vue components.
|
|
25
|
+
*
|
|
26
|
+
* Создает файл определений типов (`types.d.ts`) для глобальных компонентов Vue.
|
|
27
|
+
*/
|
|
28
|
+
make(): void {
|
|
29
|
+
this.items.write(
|
|
30
|
+
'types',
|
|
31
|
+
[
|
|
32
|
+
// 'import { type App } from \'vue\'',
|
|
33
|
+
...this.initImports(),
|
|
34
|
+
// '',
|
|
35
|
+
// 'export const components = {',
|
|
36
|
+
// this.initExports(),
|
|
37
|
+
// '}',
|
|
38
|
+
// '',
|
|
39
|
+
// 'export const useVueComponentsPlugin = {',
|
|
40
|
+
// ' install: async (app: App) => {',
|
|
41
|
+
// ...this.initIncludeVueComponents(),
|
|
42
|
+
// ' }',
|
|
43
|
+
// '}',
|
|
44
|
+
'',
|
|
45
|
+
'declare module \'@vue/runtime-core\' {',
|
|
46
|
+
' export interface GlobalComponents {',
|
|
47
|
+
...this.initGlobalComponentsVue(),
|
|
48
|
+
' }',
|
|
49
|
+
'}'
|
|
50
|
+
]
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the path to the component.
|
|
56
|
+
*
|
|
57
|
+
* Возвращает путь к компоненту.
|
|
58
|
+
* @param component component data / данные компонента
|
|
59
|
+
*/
|
|
60
|
+
protected getPathComponent(component: LibraryData): string {
|
|
61
|
+
return `../components/${PropertiesConfig.getProjectName()}/${component.dir}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Returns a list of imports for the file.
|
|
66
|
+
*
|
|
67
|
+
* Возвращает список импортов для файла.
|
|
68
|
+
*/
|
|
69
|
+
protected initImports(): string[] {
|
|
70
|
+
const list: string[] = []
|
|
71
|
+
|
|
72
|
+
this.items.getComponentList()
|
|
73
|
+
.forEach((component) => {
|
|
74
|
+
list.push(
|
|
75
|
+
`import _${component.codeFull} from '${this.getPathComponent(component)}/${component.codeFull}.vue'`
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
return list
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns a list of exports for the file.
|
|
84
|
+
*
|
|
85
|
+
* Возвращает список экспортов для файла.
|
|
86
|
+
*/
|
|
87
|
+
protected initExports(): string {
|
|
88
|
+
const list: string[] = []
|
|
89
|
+
|
|
90
|
+
this.items.getComponentList()
|
|
91
|
+
.forEach((component) => {
|
|
92
|
+
list.push(
|
|
93
|
+
` ${component.codeFull}: _${component.codeFull}`
|
|
94
|
+
)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
return list.join(',\r\n')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected initIncludeVueComponents(): string[] {
|
|
101
|
+
const list: string[] = []
|
|
102
|
+
|
|
103
|
+
this.items.getComponentList()
|
|
104
|
+
.forEach((component) => {
|
|
105
|
+
list.push(
|
|
106
|
+
` app.component('${component.codeFull}', _${component.codeFull})`
|
|
107
|
+
)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
return list
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a list of global components for Vue.
|
|
115
|
+
*
|
|
116
|
+
* Возвращает список глобальных компонентов для Vue.
|
|
117
|
+
*/
|
|
118
|
+
protected initGlobalComponentsVue(): string[] {
|
|
119
|
+
const list: string[] = []
|
|
120
|
+
|
|
121
|
+
this.items.getComponentList()
|
|
122
|
+
.forEach((component) => {
|
|
123
|
+
list.push(
|
|
124
|
+
` ${component.codeFull}: typeof _${component.codeFull}`
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return list
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -6,11 +6,19 @@ import { PackageInitItem } from './PackageItem'
|
|
|
6
6
|
import { UI_DIR_PACKAGES } from '../../config'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Class for initializing the package structure and development environment based on templates.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Класс для инициализации структуры пакета и среды разработки на основе шаблонов.
|
|
12
12
|
*/
|
|
13
13
|
export class PackageInit {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor for PackageInit.
|
|
16
|
+
*
|
|
17
|
+
* Конструктор для PackageInit.
|
|
18
|
+
* @param type package type identifier / идентификатор типа пакета
|
|
19
|
+
* @param templates optional list of templates to apply / необязательный список шаблонов для применения
|
|
20
|
+
* @param dir base directory for packages / базовая директория для пакетов
|
|
21
|
+
*/
|
|
14
22
|
constructor(
|
|
15
23
|
protected readonly type: string,
|
|
16
24
|
protected readonly templates?: string,
|
|
@@ -19,9 +27,9 @@ export class PackageInit {
|
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Triggers the package creation process and initializes required files.
|
|
23
31
|
*
|
|
24
|
-
*
|
|
32
|
+
* Запускает процесс создания пакета и инициализирует необходимые файлы.
|
|
25
33
|
*/
|
|
26
34
|
make() {
|
|
27
35
|
console.log(`Initializing package of type: ${this.type} with templates: ${this.templates}`)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import requirePath from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { isFilled } from '@dxtmisha/functional-basic'
|
|
5
6
|
import { hasNativeDirname } from '../../functions/hasNativeDirname'
|
|
6
7
|
|
|
7
8
|
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
@@ -28,11 +29,20 @@ type PackageInitItemFile = {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Class for initializing a single package component, managing its files, dependencies, and integration.
|
|
32
33
|
*
|
|
33
|
-
*
|
|
34
|
+
* Класс для инициализации отдельного компонента пакета, управления его файлами, зависимостями и интеграцией.
|
|
34
35
|
*/
|
|
35
36
|
export class PackageInitItem {
|
|
37
|
+
/**
|
|
38
|
+
* Constructor for PackageInitItem.
|
|
39
|
+
*
|
|
40
|
+
* Конструктор для PackageInitItem.
|
|
41
|
+
* @param name unique name of the component / уникальное имя компонента
|
|
42
|
+
* @param dir path to the component directory / путь к директории компонента
|
|
43
|
+
* @param type package type identifier / идентификатор типа пакета
|
|
44
|
+
* @param templates optional list of templates to apply / необязательный список шаблонов для применения
|
|
45
|
+
*/
|
|
36
46
|
constructor(
|
|
37
47
|
protected readonly name: string,
|
|
38
48
|
protected readonly dir: string[],
|
|
@@ -42,9 +52,9 @@ export class PackageInitItem {
|
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
/**
|
|
45
|
-
*
|
|
55
|
+
* Performs the full initialization cycle for the package item, including file creation and integration updates.
|
|
46
56
|
*
|
|
47
|
-
*
|
|
57
|
+
* Выполняет полный цикл инициализации элемента пакета, включая создание файлов и обновление интеграций.
|
|
48
58
|
*/
|
|
49
59
|
make() {
|
|
50
60
|
console.log('Package init in:', this.dir)
|
|
@@ -92,7 +102,7 @@ export class PackageInitItem {
|
|
|
92
102
|
* Получает файлы шаблонов, если указан путь к шаблонам.
|
|
93
103
|
*/
|
|
94
104
|
protected getTemplates(): PackageInitItemFile[] {
|
|
95
|
-
if (this.templates) {
|
|
105
|
+
if (isFilled(this.templates)) {
|
|
96
106
|
return this.getFileByList([this.templates])
|
|
97
107
|
}
|
|
98
108
|
|
|
@@ -191,6 +201,7 @@ export class PackageInitItem {
|
|
|
191
201
|
protected writeFile(path: string, content: string): void {
|
|
192
202
|
const contentEdit = content
|
|
193
203
|
.replace(/@packages\/library/g, this.getProjectName())
|
|
204
|
+
.replace(/\[name]/g, this.getName())
|
|
194
205
|
|
|
195
206
|
PropertiesFile.writeByPath(path, contentEdit)
|
|
196
207
|
PropertiesFile.chmod(path)
|
|
@@ -45,22 +45,33 @@ import { type PropertyList } from '../../types/propertyTypes'
|
|
|
45
45
|
const FILE_CACHE = 'properties'
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Central orchestrator for the design system's token management.
|
|
49
|
+
* Responsible for loading, merging, and executing a multi-stage transformation pipeline to convert raw property definitions into structured, resolved data for various output formats.
|
|
49
50
|
*
|
|
50
|
-
*
|
|
51
|
+
* Центральный оркестратор для управления токенами дизайн-системы.
|
|
52
|
+
* Отвечает за загрузку, слияние и выполнение многоэтапного конвейера преобразований для конвертации необработанных определений свойств в структурированные, разрешенные данные для различных выходных форматов.
|
|
51
53
|
*/
|
|
52
54
|
export class Properties {
|
|
53
55
|
private readonly designs: string[]
|
|
54
56
|
private readonly items: PropertiesItems
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
|
-
* Constructor
|
|
59
|
+
* Constructor for Properties.
|
|
60
|
+
* Initializes the list of designs and triggers the token processing pipeline.
|
|
61
|
+
*
|
|
62
|
+
* Конструктор для Properties.
|
|
63
|
+
* Инициализирует список дизайнов и запускает конвейер обработки токенов.
|
|
58
64
|
*/
|
|
59
65
|
constructor() {
|
|
60
66
|
this.designs = PropertiesTool.getDesigns()
|
|
61
67
|
this.items = new PropertiesItems(this.read())
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Returns the processed collection of design tokens.
|
|
72
|
+
*
|
|
73
|
+
* Возвращает обработанную коллекцию токенов дизайна.
|
|
74
|
+
*/
|
|
64
75
|
get() {
|
|
65
76
|
return this.items
|
|
66
77
|
}
|