@dxtmisha/scripts 0.7.2 → 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/design-wiki-storm.ts +9 -0
- package/package.json +5 -3
- 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 +15 -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 +13 -8
- package/src/classes/Design/DesignComponent.ts +235 -28
- package/src/classes/Design/DesignConstructor.ts +9 -5
- package/src/classes/Design/DesignConstructors.ts +8 -4
- package/src/classes/Design/DesignFlags.ts +16 -0
- package/src/classes/Design/DesignReplace.ts +10 -6
- 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 +42 -11
- 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 +2 -1
- package/src/classes/Library/LibraryFlags.ts +9 -7
- package/src/classes/Library/LibraryItems.ts +9 -9
- package/src/classes/Library/LibraryList.ts +10 -5
- package/src/classes/Library/LibraryMedia.ts +21 -6
- package/src/classes/Library/LibraryPlugin.ts +8 -5
- package/src/classes/Library/LibraryTypes.ts +34 -10
- package/src/classes/Package/PackageInit.ts +12 -4
- package/src/classes/Package/PackageItem.ts +13 -4
- package/src/classes/Properties/Properties.ts +14 -3
- package/src/classes/Properties/PropertiesCache.ts +19 -20
- package/src/classes/Properties/PropertiesConfig.ts +39 -28
- package/src/classes/Properties/PropertiesConvector.ts +10 -6
- package/src/classes/Properties/PropertiesFile.ts +22 -28
- 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/composables/__tests__/useAi.test.ts +75 -0
- package/src/config.ts +2 -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 +6 -0
- package/src/media/properties/css.ts +3 -1
- package/src/media/templates/component/props.ts +1 -1
- package/src/media/templates/component/wiki.ts +6 -12
- package/src/media/templates/component/wikiData.ts +28 -0
- 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/config.ts +0 -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/types/configTypes.ts +3 -0
- package/src/types/webTypes.ts +105 -0
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { forEach } from '@dxtmisha/functional-basic'
|
|
2
|
+
import { getPackageJson } from '../../functions/getPackageJson'
|
|
2
3
|
import { useAi } from '../../composables/useAi'
|
|
3
4
|
|
|
4
5
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
5
6
|
|
|
6
7
|
import type { DesignTypesList } from '../../types/designTypes'
|
|
7
8
|
|
|
8
|
-
import { UI_FILE_AI_TYPES } from '../../config'
|
|
9
|
+
import { UI_DIR_CONSTRUCTOR, UI_FILE_AI_TYPES } from '../../config'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Engine for generating compressed and AI-optimized TypeScript type definitions.
|
|
13
|
+
* It scans the build output for declaration files, sanitizes them, and uses AI to produce a minimal, context-rich type library for use in automated coding assistants.
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* Движок для генерации сжатых и оптимизированных для ИИ определений типов TypeScript.
|
|
16
|
+
* Сканирует выходные данные сборки на наличие файлов деклараций, очищает их и использует ИИ для создания минимальной, насыщенной контекстом библиотеки типов для использования в автоматизированных помощниках по кодированию.
|
|
14
17
|
*/
|
|
15
18
|
export class DesignTypes {
|
|
16
19
|
/**
|
|
@@ -21,8 +24,10 @@ export class DesignTypes {
|
|
|
21
24
|
protected readonly dirArray: string[]
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
|
-
* Constructor
|
|
25
|
-
*
|
|
27
|
+
* Constructor for DesignTypes.
|
|
28
|
+
*
|
|
29
|
+
* Конструктор для DesignTypes.
|
|
30
|
+
* @param dir input directory path containing declaration files / входной путь к директории, содержащей файлы деклараций
|
|
26
31
|
*/
|
|
27
32
|
constructor(
|
|
28
33
|
protected readonly dir: string = 'dist'
|
|
@@ -58,12 +63,14 @@ export class DesignTypes {
|
|
|
58
63
|
*/
|
|
59
64
|
protected isFile(file: string): boolean {
|
|
60
65
|
return file.endsWith('.d.ts')
|
|
66
|
+
&& !file.endsWith('.vue.d.ts')
|
|
67
|
+
&& !file.endsWith('wiki.d.ts')
|
|
68
|
+
&& !file.endsWith('wikiData.d.ts')
|
|
61
69
|
&& (
|
|
62
|
-
!file.includes(
|
|
63
|
-
|| (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
70
|
+
!file.includes(`${UI_DIR_CONSTRUCTOR}/`)
|
|
71
|
+
|| file.endsWith('/basicTypes.d.ts')
|
|
72
|
+
|| file.endsWith('/types.d.ts')
|
|
73
|
+
|| file.endsWith('/props.d.ts')
|
|
67
74
|
)
|
|
68
75
|
}
|
|
69
76
|
|
|
@@ -75,11 +82,9 @@ export class DesignTypes {
|
|
|
75
82
|
*/
|
|
76
83
|
protected isContent(content?: string): content is string {
|
|
77
84
|
return Boolean(
|
|
78
|
-
content
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|| content.includes('export enum')
|
|
82
|
-
))
|
|
85
|
+
content
|
|
86
|
+
&& content.includes('export')
|
|
87
|
+
)
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/**
|
|
@@ -143,10 +148,23 @@ export class DesignTypes {
|
|
|
143
148
|
* @param content content to save / контент для сохранения
|
|
144
149
|
*/
|
|
145
150
|
protected save(content: string) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
const packageJson = getPackageJson()
|
|
152
|
+
|
|
153
|
+
if (packageJson) {
|
|
154
|
+
PropertiesFile.writeByPath(
|
|
155
|
+
UI_FILE_AI_TYPES,
|
|
156
|
+
[
|
|
157
|
+
`1) All these methods are in the ${packageJson.name} library.`,
|
|
158
|
+
'2) Everything that is exported can be used.',
|
|
159
|
+
'3) Use what is in this library if it exists; do not use other libraries if there is an analogue here. Do not create new ones if an analogue already exists here.',
|
|
160
|
+
'',
|
|
161
|
+
'The following is the content of "exports" from package.json:',
|
|
162
|
+
JSON.stringify(packageJson.exports, null, 2),
|
|
163
|
+
'',
|
|
164
|
+
content
|
|
165
|
+
].join('\n')
|
|
166
|
+
)
|
|
167
|
+
}
|
|
150
168
|
}
|
|
151
169
|
|
|
152
170
|
/**
|
|
@@ -173,18 +191,25 @@ export class DesignTypes {
|
|
|
173
191
|
const ai = useAi()
|
|
174
192
|
|
|
175
193
|
if (ai) {
|
|
176
|
-
ai.addPrompt(
|
|
177
|
-
|
|
178
|
-
const generate = await ai.generate(
|
|
194
|
+
ai.addPrompt(
|
|
179
195
|
'Remove all Russian comments from this code. '
|
|
180
|
-
+ '
|
|
196
|
+
+ 'Simplify and shorten all English comments for AI readability while maintaining a clear balance between brevity and context. Do not delete them even if the code seems obvious. '
|
|
197
|
+
+ 'Always keep All JSDoc "@example", "@remarks", "@note", and any other notes or warnings. '
|
|
181
198
|
+ 'Remove all imports. '
|
|
182
|
-
+ 'Remove
|
|
183
|
-
+ 'Remove
|
|
184
|
-
+ '
|
|
185
|
-
+ '
|
|
186
|
-
+ '
|
|
199
|
+
+ 'Remove all non-public content: delete all private and protected class methods and properties, and any non-exported elements. The final output must contain only the members and entities that are accessible from outside. '
|
|
200
|
+
+ 'Remove any code segments or data that do not provide useful information for an AI assistant. '
|
|
201
|
+
+ 'You may remove abstract classes or other structures that provide no practical value for code generation, but do so with extreme caution. Maintain a strict balance: if there is even a 5% chance the item might be relevant for understanding the API or generating code, keep it. Think carefully before every deletion. '
|
|
202
|
+
+ 'Remove any large Enums that add excessive length without providing critical context. '
|
|
203
|
+
+ 'Your goal is to create a compact, context-rich file that enables any AI coding assistant to generate high-quality code for a developer. '
|
|
204
|
+
+ 'Ensure that no public API surface, essential data types, or required logic is lost. '
|
|
205
|
+
+ 'Do not delete any "type" definitions; they are strictly required. '
|
|
206
|
+
+ 'Do not delete file paths (labels starting with "// File:"). '
|
|
207
|
+
+ 'All instructions are mandatory and must be executed perfectly. '
|
|
208
|
+
+ 'Return ONLY the resulting code. No markdown code blocks, no tags, no explanations, and no additional comments from the AI. NOTHING but the pure code.'
|
|
187
209
|
)
|
|
210
|
+
ai.addPrompt(`File Content: ${content}`)
|
|
211
|
+
|
|
212
|
+
const generate = await ai.generate('go!')
|
|
188
213
|
|
|
189
214
|
if (generate) {
|
|
190
215
|
return generate
|
|
@@ -9,9 +9,11 @@ import type {
|
|
|
9
9
|
} from '../../types/designTypes'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Utility for interacting with the TypeScript Compiler API to analyze and extract type metadata from source files.
|
|
13
|
+
* It parses interfaces and type aliases to retrieve property details, including types, literal unions, and documentation comments.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
+
* Утилита для взаимодействия с TypeScript Compiler API для анализа и извлечения метаданных типов из исходных файлов.
|
|
16
|
+
* Анализирует интерфейсы и псевдонимы типов для получения сведений о свойствах, включая типы, литеральные объединения и комментарии к документации.
|
|
15
17
|
*/
|
|
16
18
|
export class DesignTypescript {
|
|
17
19
|
protected readonly program: ts.Program
|
|
@@ -19,6 +21,13 @@ export class DesignTypescript {
|
|
|
19
21
|
protected readonly sourceFile?: ts.SourceFile
|
|
20
22
|
protected types?: DesignTypescriptList
|
|
21
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Constructor for DesignTypescript.
|
|
26
|
+
*
|
|
27
|
+
* Конструктор для DesignTypescript.
|
|
28
|
+
* @param path path to the TypeScript source file to analyze / путь к исходному файлу TypeScript для анализа
|
|
29
|
+
* @param options compiler options for the TypeScript program / опции компилятора для программы TypeScript
|
|
30
|
+
*/
|
|
22
31
|
constructor(
|
|
23
32
|
path: string = '',
|
|
24
33
|
options: ts.CompilerOptions = {}
|
|
@@ -18,14 +18,23 @@ import { LibraryList } from '../Library/LibraryList'
|
|
|
18
18
|
import { LibraryPlugin } from '../Library/LibraryPlugin'
|
|
19
19
|
import { LibraryTypes } from '../Library/LibraryTypes'
|
|
20
20
|
|
|
21
|
-
import { UI_FILE_PACKAGE } from '../../config'
|
|
22
|
-
|
|
21
|
+
import { UI_FILE_PACKAGE, UI_FILE_STYLE_PROPERTIES } from '../../config'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Orchestrator class for managing and initializing the Design System UI.
|
|
25
|
+
* It coordinates the generation of styles, documentation, component structures, and library-level exports (media, plugins, types).
|
|
26
|
+
*
|
|
27
|
+
* Класс-оркестратор для управления и инициализации пользовательского интерфейса дизайн-системы.
|
|
28
|
+
* Координирует генерацию стилей, документации, структур компонентов и экспортов на уровне библиотеки (медиа, плагины, типы).
|
|
29
|
+
*/
|
|
23
30
|
export class DesignUi {
|
|
24
31
|
protected readonly components: LibraryItems
|
|
25
32
|
|
|
26
33
|
/**
|
|
27
|
-
* Constructor
|
|
28
|
-
*
|
|
34
|
+
* Constructor for DesignUi.
|
|
35
|
+
*
|
|
36
|
+
* Конструктор для DesignUi.
|
|
37
|
+
* @param name specific component name to initialize, or empty for all / название конкретного компонента для инициализации или пусто для всех
|
|
29
38
|
*/
|
|
30
39
|
constructor(
|
|
31
40
|
protected readonly name: string = ''
|
|
@@ -54,7 +63,8 @@ export class DesignUi {
|
|
|
54
63
|
new DesignWiki().make()
|
|
55
64
|
|
|
56
65
|
this.makeConstructorComponent()
|
|
57
|
-
|
|
66
|
+
.makePackage()
|
|
67
|
+
.makeUiProperties()
|
|
58
68
|
|
|
59
69
|
new LibraryMedia(this.components).make()
|
|
60
70
|
new LibraryList(this.components).make()
|
|
@@ -90,23 +100,44 @@ export class DesignUi {
|
|
|
90
100
|
*
|
|
91
101
|
* Обновляет файл package.json, добавляя пути экспорта для стилей UI, и сохраняет изменения.
|
|
92
102
|
*/
|
|
93
|
-
protected makePackage():
|
|
103
|
+
protected makePackage(): this {
|
|
94
104
|
const packageJson = getPackageJson()
|
|
95
105
|
const projectName = toCamelCaseFirst(PropertiesConfig.getProjectName())
|
|
96
106
|
|
|
97
107
|
if (packageJson?.exports) {
|
|
108
|
+
packageJson.exports['.'] = {
|
|
109
|
+
types: './dist/library/types.d.ts',
|
|
110
|
+
default: './dist/types.js'
|
|
111
|
+
}
|
|
98
112
|
packageJson.exports['./plugin'] = {
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
types: './dist/library/plugin.d.ts',
|
|
114
|
+
default: './dist/plugin.js'
|
|
115
|
+
}
|
|
116
|
+
packageJson.exports['./media'] = {
|
|
117
|
+
types: './dist/library/media.d.ts',
|
|
118
|
+
default: './dist/media.js'
|
|
101
119
|
}
|
|
102
120
|
packageJson.exports['./style.css'] = './dist/style.css'
|
|
103
121
|
packageJson.exports['./style/ui.scss'] = `./src/styles/${projectName}/main.scss`
|
|
104
|
-
packageJson.exports['./
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
packageJson.exports['./ui-properties'] = {
|
|
123
|
+
sass: './ui-properties.scss',
|
|
124
|
+
default: './ui-properties.scss'
|
|
107
125
|
}
|
|
126
|
+
packageJson.exports['./types.d.ts'] = './dist/library/types.d.ts'
|
|
127
|
+
packageJson['web-types'] = './dist/web-types.json'
|
|
108
128
|
|
|
109
129
|
PropertiesFile.writeByPath(UI_FILE_PACKAGE, packageJson)
|
|
110
130
|
}
|
|
131
|
+
|
|
132
|
+
return this
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
protected makeUiProperties(): this {
|
|
136
|
+
PropertiesFile.writeByPath(
|
|
137
|
+
UI_FILE_STYLE_PROPERTIES,
|
|
138
|
+
'@forward "./src/styles/Ui/style.scss";'
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return this
|
|
111
142
|
}
|
|
112
143
|
}
|
|
@@ -11,13 +11,11 @@ import {
|
|
|
11
11
|
} from '../../config'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* that
|
|
16
|
-
* the necessary files are created and initialized properly.
|
|
14
|
+
* Utility for managing and generating the central wiki configuration for the design system.
|
|
15
|
+
* It ensures that the primary registry for storybook arguments and component descriptions is correctly initialized and synchronized with the project's design configuration.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* необходимые файлы создаются и инициализируются должным образом.
|
|
17
|
+
* Утилита для управления и генерации центральной конфигурации вики для дизайн-системы.
|
|
18
|
+
* Гарантирует, что основной реестр аргументов Storybook и описаний компонентов правильно инициализирован и синхронизирован с конфигурацией дизайна проекта.
|
|
21
19
|
*/
|
|
22
20
|
export class DesignWiki {
|
|
23
21
|
/**
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { toCamelCaseFirst } from '@dxtmisha/functional-basic'
|
|
2
|
+
import { getPackageJson } from '../../functions/getPackageJson'
|
|
3
|
+
|
|
4
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
5
|
+
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
6
|
+
import { LibraryItems } from '../Library/LibraryItems'
|
|
7
|
+
import { DesignWikiStormItem } from './DesignWikiStormItem'
|
|
8
|
+
|
|
9
|
+
import type { WebTypesTags, WebTypesVueJson } from '../../types/webTypes'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Engine for generating `web-types.json` to provide rich metadata and IDE support (IntelliSense) for the design system components in JetBrains editors (IntelliJ IDEA, WebStorm).
|
|
13
|
+
* It aggregates component tags, attributes, and events from the entire library and formats them into the standard Web-Types schema.
|
|
14
|
+
*
|
|
15
|
+
* Движок для генерации `web-types.json`, обеспечивающий расширенные метаданные и поддержку IDE (IntelliSense) для компонентов дизайн-системы в редакторах JetBrains (IntelliJ IDEA, WebStorm).
|
|
16
|
+
* Он агрегирует теги компонентов, атрибуты и события из всей библиотеки и форматирует их в стандартную схему Web-Types.
|
|
17
|
+
*/
|
|
18
|
+
export class DesignWikiStorm {
|
|
19
|
+
protected readonly components: LibraryItems
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constructor for DesignWikiStorm.
|
|
23
|
+
*
|
|
24
|
+
* Конструктор для DesignWikiStorm.
|
|
25
|
+
* @param dir target directory for saving the `web-types.json` file / целевая директория для сохранения файла `web-types.json`
|
|
26
|
+
*/
|
|
27
|
+
constructor(
|
|
28
|
+
protected dir: string = 'dist'
|
|
29
|
+
) {
|
|
30
|
+
this.components = new LibraryItems()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Generates the web-types.json file.
|
|
35
|
+
*
|
|
36
|
+
* Генерирует файл web-types.json.
|
|
37
|
+
*/
|
|
38
|
+
async make(): Promise<void> {
|
|
39
|
+
const packageFile = getPackageJson()
|
|
40
|
+
|
|
41
|
+
console.log('[DesignWikiStorm] make')
|
|
42
|
+
|
|
43
|
+
if (packageFile) {
|
|
44
|
+
const data: WebTypesVueJson = {
|
|
45
|
+
$schema: 'https://json.schemastore.org/web-types',
|
|
46
|
+
framework: 'vue',
|
|
47
|
+
name: toCamelCaseFirst(PropertiesConfig.getDesignName()),
|
|
48
|
+
version: packageFile.version,
|
|
49
|
+
contributions: {
|
|
50
|
+
html: {
|
|
51
|
+
'types-syntax': 'typescript',
|
|
52
|
+
'description-markup': 'markdown',
|
|
53
|
+
'tags': await this.getComponents()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
PropertiesFile.writeByPath(
|
|
59
|
+
[this.dir, 'web-types.json'],
|
|
60
|
+
data
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates or updates the list of components.
|
|
67
|
+
*
|
|
68
|
+
* Создает или обновляет список компонентов.
|
|
69
|
+
*/
|
|
70
|
+
protected async getComponents(): Promise<WebTypesTags> {
|
|
71
|
+
const packageFile = getPackageJson()
|
|
72
|
+
const tags: WebTypesTags = []
|
|
73
|
+
|
|
74
|
+
if (packageFile) {
|
|
75
|
+
for (const component of this.components.getComponentList()) {
|
|
76
|
+
const item = new DesignWikiStormItem(
|
|
77
|
+
packageFile.name,
|
|
78
|
+
this.components.getComponentsPath(),
|
|
79
|
+
component
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
await item.init()
|
|
83
|
+
|
|
84
|
+
const tag = await item.get()
|
|
85
|
+
|
|
86
|
+
if (tag) {
|
|
87
|
+
tags.push(tag)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return tags
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { toCamelCaseFirst } from '@dxtmisha/functional'
|
|
2
|
+
import { type WikiDataItem, WikiStorybook, WikiStorybookProp } from '@dxtmisha/wiki'
|
|
3
|
+
import { wiki, wikiDescriptions } from '@dxtmisha/wiki/media'
|
|
4
|
+
|
|
5
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
6
|
+
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
7
|
+
|
|
8
|
+
import type { LibraryData } from '../../types/libraryTypes'
|
|
9
|
+
import type { WebTypesAttributeItem, WebTypesAttributes, WebTypesEvents, WebTypesSlots, WebTypesTagItem } from '../../types/webTypes'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolver for extracting and formatting IDE metadata for a specific component.
|
|
13
|
+
* It coordinates the transformation of Storybook-specific wiki data into JetBrains Web-Types tag and attribute definitions.
|
|
14
|
+
*
|
|
15
|
+
* Резолвер для извлечения и форматирования метаданных IDE для конкретного компонента.
|
|
16
|
+
* Координирует преобразование данных вики для Storybook в определения тегов и атрибутов JetBrains Web-Types.
|
|
17
|
+
*/
|
|
18
|
+
export class DesignWikiStormItem {
|
|
19
|
+
protected wiki?: WikiStorybook
|
|
20
|
+
protected dataComponent?: WikiDataItem
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for DesignWikiStormItem.
|
|
24
|
+
*
|
|
25
|
+
* Конструктор для DesignWikiStormItem.
|
|
26
|
+
* @param project name of the project for module mapping / имя проекта для маппинга модулей
|
|
27
|
+
* @param path array of directory path segments to the component / массив сегментов пути к директории компонента
|
|
28
|
+
* @param data component metadata from the library / метаданные компонента из библиотеки
|
|
29
|
+
*/
|
|
30
|
+
constructor(
|
|
31
|
+
protected readonly project: string,
|
|
32
|
+
protected readonly path: string[],
|
|
33
|
+
protected readonly data: LibraryData
|
|
34
|
+
) {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns the tag definition for web-types.
|
|
39
|
+
*
|
|
40
|
+
* Возвращает определение тега для web-types.
|
|
41
|
+
*/
|
|
42
|
+
async get(): Promise<WebTypesTagItem | undefined> {
|
|
43
|
+
if (this.wiki) {
|
|
44
|
+
const name = `${toCamelCaseFirst(PropertiesConfig.getDesignName())}${this.wiki.getName()}`
|
|
45
|
+
|
|
46
|
+
const tag: WebTypesTagItem = {
|
|
47
|
+
name,
|
|
48
|
+
description: this.wiki.getDescription(),
|
|
49
|
+
source: {
|
|
50
|
+
module: `${this.project}/${name}`,
|
|
51
|
+
symbol: name
|
|
52
|
+
},
|
|
53
|
+
attributes: this.getAttributes()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const slots = await this.getSlots()
|
|
57
|
+
|
|
58
|
+
if (slots) {
|
|
59
|
+
tag.slots = slots
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const events = await this.getEvents()
|
|
63
|
+
|
|
64
|
+
if (events) {
|
|
65
|
+
tag.events = events
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return tag
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns the attribute definition.
|
|
76
|
+
*
|
|
77
|
+
* Возвращает определение атрибута.
|
|
78
|
+
* @param item prop item / элемент свойства
|
|
79
|
+
*/
|
|
80
|
+
getAttribute(item: WikiStorybookProp): WebTypesAttributeItem {
|
|
81
|
+
return {
|
|
82
|
+
name: item.getName(),
|
|
83
|
+
description: item.getDescription(),
|
|
84
|
+
default: item.getDefaultValue(),
|
|
85
|
+
value: {
|
|
86
|
+
kind: 'expression',
|
|
87
|
+
type: item.getType()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns a list of attributes.
|
|
94
|
+
*
|
|
95
|
+
* Возвращает список атрибутов.
|
|
96
|
+
*/
|
|
97
|
+
getAttributes(): WebTypesAttributes {
|
|
98
|
+
const attributes: WebTypesAttributes = []
|
|
99
|
+
|
|
100
|
+
if (this.wiki) {
|
|
101
|
+
this.wiki.getWikiObject()
|
|
102
|
+
.forEach(
|
|
103
|
+
props => attributes.push(this.getAttribute(props))
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return attributes
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns a list of slots.
|
|
112
|
+
*
|
|
113
|
+
* Возвращает список слотов.
|
|
114
|
+
*/
|
|
115
|
+
async getSlots(): Promise<WebTypesSlots | undefined> {
|
|
116
|
+
const data = await this.getData()
|
|
117
|
+
|
|
118
|
+
if (data && data.slots) {
|
|
119
|
+
const slots: WebTypesSlots = []
|
|
120
|
+
|
|
121
|
+
data.slots.forEach(
|
|
122
|
+
props => slots.push({
|
|
123
|
+
name: props.name,
|
|
124
|
+
description: props.description,
|
|
125
|
+
'vue-properties': props.properties ?? []
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return slots
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return undefined
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns a list of events.
|
|
137
|
+
*
|
|
138
|
+
* Возвращает список событий.
|
|
139
|
+
*/
|
|
140
|
+
async getEvents(): Promise<WebTypesEvents | undefined> {
|
|
141
|
+
const data = await this.getData()
|
|
142
|
+
|
|
143
|
+
if (data && data.events) {
|
|
144
|
+
const events: WebTypesEvents = []
|
|
145
|
+
|
|
146
|
+
data.events.forEach(
|
|
147
|
+
event => events.push({
|
|
148
|
+
name: event.name,
|
|
149
|
+
description: event.description,
|
|
150
|
+
arguments: event.properties ?? []
|
|
151
|
+
})
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
return events
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return undefined
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the directory name.
|
|
162
|
+
*
|
|
163
|
+
* Возвращает имя директории.
|
|
164
|
+
*/
|
|
165
|
+
getDirName() {
|
|
166
|
+
return this.data.dir
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Initializes the class.
|
|
171
|
+
*
|
|
172
|
+
* Инициализирует класс.
|
|
173
|
+
*/
|
|
174
|
+
async init(): Promise<this> {
|
|
175
|
+
this.wiki = await this.initWiki()
|
|
176
|
+
return this
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Gets data from wikiData.ts.
|
|
181
|
+
*
|
|
182
|
+
* Получает данные из wikiData.ts.
|
|
183
|
+
*/
|
|
184
|
+
protected async getData(): Promise<WikiDataItem | undefined> {
|
|
185
|
+
if (!this.dataComponent) {
|
|
186
|
+
const filePath = this.getPaths(['wikiData.ts'])
|
|
187
|
+
|
|
188
|
+
if (PropertiesFile.is(filePath)) {
|
|
189
|
+
const wiki: Record<string, any> = await import(filePath.join('/'))
|
|
190
|
+
const data: WikiDataItem | undefined = Object.values(wiki).find(item => 'component' in item)
|
|
191
|
+
|
|
192
|
+
this.dataComponent = data
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return this.dataComponent
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Returns the list of directories.
|
|
201
|
+
*
|
|
202
|
+
* Возвращает список директорий.
|
|
203
|
+
*/
|
|
204
|
+
protected getDirs(): string[] {
|
|
205
|
+
return [
|
|
206
|
+
'.',
|
|
207
|
+
...this.path,
|
|
208
|
+
this.getDirName()
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Returns the full path to the file.
|
|
214
|
+
*
|
|
215
|
+
* Возвращает полный путь к файлу.
|
|
216
|
+
* @param paths path segments / сегменты пути
|
|
217
|
+
*/
|
|
218
|
+
protected getPaths(paths: string[]): string[] {
|
|
219
|
+
return [
|
|
220
|
+
...this.getDirs(),
|
|
221
|
+
...paths
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Initializes the wiki object.
|
|
227
|
+
*
|
|
228
|
+
* Инициализирует объект wiki.
|
|
229
|
+
*/
|
|
230
|
+
protected async initWiki(): Promise<WikiStorybook | undefined> {
|
|
231
|
+
const data = await this.getData()
|
|
232
|
+
|
|
233
|
+
if (data) {
|
|
234
|
+
return new WikiStorybook(
|
|
235
|
+
data.component,
|
|
236
|
+
data.props,
|
|
237
|
+
data.defaults,
|
|
238
|
+
data.wikiDesign,
|
|
239
|
+
wiki,
|
|
240
|
+
wikiDescriptions
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return undefined
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -253,6 +253,7 @@ export class GitRead {
|
|
|
253
253
|
*
|
|
254
254
|
* Выполняет Git команду и возвращает результат.
|
|
255
255
|
* @param command - command to execute / команда для выполнения
|
|
256
|
+
* @protected
|
|
256
257
|
*/
|
|
257
258
|
protected static exec(command: string): string {
|
|
258
259
|
return execSync(command, { encoding: 'utf8' }).trim()
|