@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
|
@@ -20,22 +20,24 @@ const NAME_SHADE = 'setDesignShade'
|
|
|
20
20
|
const NAME_PROPERTIES = 'setDesignsProperties'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Class for
|
|
23
|
+
* Class for generating SCSS structures from design tokens.
|
|
24
24
|
*
|
|
25
|
-
* Класс для
|
|
25
|
+
* Класс для генерации структур SCSS из токенов дизайна.
|
|
26
26
|
*/
|
|
27
27
|
export class PropertiesScss {
|
|
28
28
|
/**
|
|
29
|
-
* Constructor
|
|
30
|
-
*
|
|
29
|
+
* Constructor for initializing the SCSS generator.
|
|
30
|
+
*
|
|
31
|
+
* Конструктор для инициализации генератора SCSS.
|
|
32
|
+
* @param items property management instance / экземпляр управления свойствами
|
|
31
33
|
*/
|
|
32
34
|
constructor(private items: PropertiesItems) {
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
|
-
* Returns a formatted string
|
|
38
|
+
* Returns a complete SCSS formatted string containing all configuration mixins.
|
|
37
39
|
*
|
|
38
|
-
* Возвращает отформатированную строку
|
|
40
|
+
* Возвращает полную отформатированную строку SCSS, содержащую все миксины конфигурации.
|
|
39
41
|
*/
|
|
40
42
|
get() {
|
|
41
43
|
let data = '@use "@dxtmisha/styles" as variables;\r\n\r\n'
|
|
@@ -145,9 +147,9 @@ export class PropertiesScss {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
/**
|
|
148
|
-
*
|
|
150
|
+
* Generates a SCSS map structure for all identified properties.
|
|
149
151
|
*
|
|
150
|
-
*
|
|
152
|
+
* Генерирует структуру карты SCSS для всех определенных свойств.
|
|
151
153
|
*/
|
|
152
154
|
getProperties(): string {
|
|
153
155
|
return this.getPropertiesValue(NAME_PROPERTIES, this.to())
|
|
@@ -12,19 +12,17 @@ import {
|
|
|
12
12
|
} from '../../types/propertyTypes'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Class for
|
|
15
|
+
* Class for handling the splitting of property names with separators into nested sub-properties.
|
|
16
16
|
*
|
|
17
|
-
* Класс для работы с разделением
|
|
17
|
+
* Класс для работы с разделением названий свойств с разделителями на вложенные под-свойства.
|
|
18
18
|
*/
|
|
19
19
|
export class PropertiesSeparator {
|
|
20
20
|
/**
|
|
21
|
-
* Checks if the
|
|
21
|
+
* Checks if the property list contains any keys that require splitting (contain separators).
|
|
22
22
|
*
|
|
23
|
-
* Проверяет,
|
|
24
|
-
* @param properties
|
|
25
|
-
*
|
|
26
|
-
* @param limit the maximum permissible level of verification/
|
|
27
|
-
* максимальный допустимый уровень проверки
|
|
23
|
+
* Проверяет, содержит ли список свойств ключи, требующие разделения (содержащие разделители).
|
|
24
|
+
* @param properties list of properties to check / список свойств для проверки
|
|
25
|
+
* @param limit maximum recursion depth for verification / максимальная глубина рекурсии для проверки
|
|
28
26
|
*/
|
|
29
27
|
static is(
|
|
30
28
|
properties: PropertyList,
|
|
@@ -52,10 +50,10 @@ export class PropertiesSeparator {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
53
|
+
* Transforms properties with separator-containing keys into a nested object structure.
|
|
56
54
|
*
|
|
57
|
-
*
|
|
58
|
-
* @param properties
|
|
55
|
+
* Преобразует свойства с ключами, содержащими разделители, во вложенную структуру объектов.
|
|
56
|
+
* @param properties the property list to transform / список свойств для преобразования
|
|
59
57
|
*/
|
|
60
58
|
static to(properties: PropertyList): PropertyList {
|
|
61
59
|
let data: PropertyList = {}
|
|
@@ -16,14 +16,16 @@ import { UI_DIRS_COMPONENTS, UI_DIRS_CONSTRUCTOR, UI_KEY_CONSTRUCTOR } from '../
|
|
|
16
16
|
const DIR_NAME = 'settings'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Class for searching
|
|
19
|
+
* Class for searching and loading global component settings.
|
|
20
20
|
*
|
|
21
|
-
* Класс для
|
|
21
|
+
* Класс для поиска и загрузки глобальных настроек компонентов.
|
|
22
22
|
*/
|
|
23
23
|
export class PropertiesSettings {
|
|
24
24
|
/**
|
|
25
|
-
* Constructor
|
|
26
|
-
*
|
|
25
|
+
* Constructor for initializing the settings resolver.
|
|
26
|
+
*
|
|
27
|
+
* Конструктор для инициализации резолвера настроек.
|
|
28
|
+
* @param path path handler instance / экземпляр обработчика путей
|
|
27
29
|
*/
|
|
28
30
|
constructor(
|
|
29
31
|
private readonly path: PropertiesPath
|
|
@@ -31,9 +33,9 @@ export class PropertiesSettings {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
|
-
* Returns
|
|
36
|
+
* Returns a unified list of settings for all identified components and constructors.
|
|
35
37
|
*
|
|
36
|
-
* Возвращает
|
|
38
|
+
* Возвращает унифицированный список настроек для всех определенных компонентов и конструкторов.
|
|
37
39
|
*/
|
|
38
40
|
get(): PropertyList {
|
|
39
41
|
return {
|
|
@@ -16,17 +16,16 @@ import {
|
|
|
16
16
|
} from '../../types/propertyTypes'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Class for transforming raw property data into a standardized structure for internal processing.
|
|
20
20
|
*
|
|
21
|
-
* Класс для преобразования
|
|
21
|
+
* Класс для преобразования сырых данных свойств в стандартизированную структуру для внутренней обработки.
|
|
22
22
|
*/
|
|
23
23
|
export class PropertiesStandard {
|
|
24
24
|
/**
|
|
25
|
-
* Transforms
|
|
25
|
+
* Transforms a property list or raw data into a standardized PropertyList structure.
|
|
26
26
|
*
|
|
27
|
-
* Преобразует
|
|
28
|
-
* @param properties
|
|
29
|
-
* массив, который нужно преобразовать
|
|
27
|
+
* Преобразует список свойств или сырые данные в стандартизированную структуру PropertyList.
|
|
28
|
+
* @param properties the property list or data to transform / список свойств или данные для преобразования
|
|
30
29
|
*/
|
|
31
30
|
static to(properties: PropertyListOrData): PropertyList {
|
|
32
31
|
const data: PropertyList = {}
|
|
@@ -12,16 +12,16 @@ import basicProperties from '../../media/properties.json'
|
|
|
12
12
|
import { UI_KEY_CONSTRUCTOR, UI_FILE_PROPERTY } from '../../config'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Utility class for naming components and reading design system property files.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Утилитарный класс для именования компонентов и чтения файлов свойств дизайн-системы.
|
|
18
18
|
*/
|
|
19
19
|
export class PropertiesTool {
|
|
20
20
|
/**
|
|
21
|
-
* Checks if the
|
|
21
|
+
* Checks if the design name identifies as a constructor.
|
|
22
22
|
*
|
|
23
|
-
* Проверяет,
|
|
24
|
-
* @param design design name/ название дизайна
|
|
23
|
+
* Проверяет, идентифицирует ли название дизайна конструктор.
|
|
24
|
+
* @param design design name / название дизайна
|
|
25
25
|
*/
|
|
26
26
|
static isConstructor(design: string): boolean {
|
|
27
27
|
return design === UI_KEY_CONSTRUCTOR
|
|
@@ -37,11 +37,11 @@ export class PropertiesTool {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Generates a camelCase component name string based on design and component name.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
* @param design design name/ название дизайна
|
|
44
|
-
* @param component component name/ название компонента
|
|
42
|
+
* Генерирует строку названия компонента в стиле camelCase на основе дизайна и названия компонента.
|
|
43
|
+
* @param design design name / название дизайна
|
|
44
|
+
* @param component component name / название компонента
|
|
45
45
|
*/
|
|
46
46
|
static getComponentName(design: string, component?: string): string {
|
|
47
47
|
return `${design}${component ? `-${toCamelCase(component)}` : ''}`
|
|
@@ -58,6 +58,13 @@ export class PropertiesTool {
|
|
|
58
58
|
return `.${this.getComponentName(design, component)}`
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Reads a property list from a specified path, with special handling for constructors.
|
|
63
|
+
*
|
|
64
|
+
* Считывает список свойств по указанному пути с особой обработкой для конструкторов.
|
|
65
|
+
* @param design design name / название дизайна
|
|
66
|
+
* @param path array representing the directory path / массив, представляющий путь к директории
|
|
67
|
+
*/
|
|
61
68
|
static readFile(
|
|
62
69
|
design: string,
|
|
63
70
|
path: string[] | undefined
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
} from '../../types/propertyTypes'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Utility class for identifying and managing property types based on naming conventions and symbols.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Утилитарный класс для идентификации и управления типами свойств на основе соглашений об именовании и символов.
|
|
14
14
|
*/
|
|
15
15
|
export class PropertiesTypes {
|
|
16
16
|
private static readonly SYMBOLS: Record<string, string> = {
|
|
@@ -27,11 +27,11 @@ export class PropertiesTypes {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Checks if the list
|
|
30
|
+
* Checks if the property type matches the specified list of allowed types.
|
|
31
31
|
*
|
|
32
|
-
* Проверяет,
|
|
33
|
-
* @param type property type/ тип свойства
|
|
34
|
-
* @param name
|
|
32
|
+
* Проверяет, соответствует ли тип свойства указанному списку разрешенных типов.
|
|
33
|
+
* @param type current property type / текущий тип свойства
|
|
34
|
+
* @param name list of allowed types / список разрешенных типов
|
|
35
35
|
*/
|
|
36
36
|
static isInType(
|
|
37
37
|
type?: PropertyItem['_type'],
|
|
@@ -48,10 +48,10 @@ export class PropertiesTypes {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Determines if the property name contains a type-identifying symbol or specific prefix.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
* @param name key name/ название ключа
|
|
53
|
+
* Определяет, содержит ли название свойства символ-идентификатор типа или специфический префикс.
|
|
54
|
+
* @param name property key name / название ключа свойства
|
|
55
55
|
*/
|
|
56
56
|
static isTypeInName(name: string): boolean {
|
|
57
57
|
return Boolean(name.match(this.getExpSymbols()))
|
|
@@ -98,10 +98,10 @@ export class PropertiesTypes {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
101
|
+
* Extracts and returns the property type identifier from its name string.
|
|
102
102
|
*
|
|
103
|
-
*
|
|
104
|
-
* @param name key name/ название ключа
|
|
103
|
+
* Извлекает и возвращает идентификатор типа свойства из строки его названия.
|
|
104
|
+
* @param name property key name / название ключа свойства
|
|
105
105
|
*/
|
|
106
106
|
static getTypeInName(name: string): PropertyItem['_type'] {
|
|
107
107
|
if (this.isTypeInName(name)) {
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
import { type PropertyItemPartial } from '../../types/propertyTypes'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Utility class for validating and normalizing design system property values.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Утилитарный класс для валидации и нормализации значений свойств дизайн-системы.
|
|
9
9
|
*/
|
|
10
10
|
export class PropertiesValues {
|
|
11
11
|
/**
|
|
12
|
-
* Checks if the
|
|
12
|
+
* Checks if the value is marked as "full" (starting with `=`), meaning it doesn't require further processing.
|
|
13
13
|
*
|
|
14
|
-
* Проверяет,
|
|
15
|
-
* @param value property value/ значение свойства
|
|
14
|
+
* Проверяет, помечено ли значение как «полное» (начинается с `=`), что означает отсутствие необходимости дальнейшей обработки.
|
|
15
|
+
* @param value property value / значение свойства
|
|
16
16
|
*/
|
|
17
17
|
static isFull(value: PropertyItemPartial['value']): value is string {
|
|
18
18
|
return typeof value === 'string' && Boolean(value.match(this.getExpFull()))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Identifies if the value is a hex color string.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
* @param value property value/ значение свойства
|
|
24
|
+
* Определяет, является ли значение строкой цвета в формате HEX.
|
|
25
|
+
* @param value property value / значение свойства
|
|
26
26
|
*/
|
|
27
27
|
static isColor(value: PropertyItemPartial['__c']): boolean {
|
|
28
28
|
return Boolean(
|
|
@@ -33,10 +33,10 @@ export class PropertiesValues {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Identifies if the value is a hex color string with an alpha channel (opacity).
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
* @param value property value/ значение свойства
|
|
38
|
+
* Определяет, является ли значение строкой цвета HEX с альфа-каналом (прозрачностью).
|
|
39
|
+
* @param value property value / значение свойства
|
|
40
40
|
*/
|
|
41
41
|
static isColorWithOpacity(value: PropertyItemPartial['__c']): boolean {
|
|
42
42
|
return Boolean(
|
|
@@ -47,10 +47,10 @@ export class PropertiesValues {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Cleans up the value by removing the "full" marker or converting numeric values to strings.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
* @param value property value/ значение свойства
|
|
52
|
+
* Очищает значение, удаляя маркер «полноты» или преобразовывая числовые значения в строки.
|
|
53
|
+
* @param value property value / значение свойства
|
|
54
54
|
*/
|
|
55
55
|
static reValue(value: PropertyItemPartial['value']): PropertyItemPartial['value'] {
|
|
56
56
|
if (this.isFull(value)) {
|
|
@@ -11,17 +11,16 @@ import {
|
|
|
11
11
|
} from '../../types/propertyTypes'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Utility class for optimizing the property structure by moving duplicated data to a higher level.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* Утилитарный класс для оптимизации структуры свойств путем переноса дублирующихся данных на более высокий уровень.
|
|
17
17
|
*/
|
|
18
18
|
export class PropertiesWrap {
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Analyzes the property list and moves duplicate properties to the parent level to reduce redundancy.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
* @param properties
|
|
24
|
-
* массив, который нужно преобразовать
|
|
22
|
+
* Анализирует список свойств и переносит дублирующиеся свойства на родительский уровень для уменьшения избыточности.
|
|
23
|
+
* @param properties property list to transform / список свойств для преобразования
|
|
25
24
|
*/
|
|
26
25
|
static to(properties: PropertyList): void {
|
|
27
26
|
forEach(properties, (item) => {
|
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
} from '../../../types/propertyTypes'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Convector for transforming design token color metadata into internal property structures.
|
|
10
|
+
* Supports opacity modification based on 'studio.tokens' extensions.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Конвектор для преобразования метаданных цвета токенов дизайна во внутренние структуры свойств.
|
|
13
|
+
* Поддерживает модификацию прозрачности на основе расширений 'studio.tokens'.
|
|
14
|
+
* @param item property input object for conversion / входной объект свойства для преобразования
|
|
13
15
|
*/
|
|
14
16
|
export function convectorColor(item: PropertyItemInput): void {
|
|
15
17
|
const type: string | undefined = item?.$extensions?.['studio.tokens']?.modify?.type
|
|
@@ -3,22 +3,36 @@
|
|
|
3
3
|
import { PropertiesItems } from '../PropertiesItems'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Abstract class for
|
|
6
|
+
* Abstract base class for data transformation processes.
|
|
7
|
+
* Provides the core orchestration for initializing and writing transformed property data.
|
|
7
8
|
*
|
|
8
|
-
* Абстрактный класс для
|
|
9
|
+
* Абстрактный базовый класс для процессов преобразования данных.
|
|
10
|
+
* Обеспечивает основную оркестровку инициализации и записи преобразованных данных свойств.
|
|
9
11
|
*/
|
|
10
12
|
export abstract class PropertiesToAbstract {
|
|
13
|
+
/**
|
|
14
|
+
* Abstract property defining the cache file path for the specific transformation.
|
|
15
|
+
*
|
|
16
|
+
* Абстрактное свойство, определяющее путь к файлу кэша для конкретного преобразования.
|
|
17
|
+
*/
|
|
11
18
|
protected readonly abstract FILE_CACHE: string
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
|
-
* Constructor
|
|
15
|
-
*
|
|
21
|
+
* Constructor that initializes the transformation with a set of property items.
|
|
22
|
+
*
|
|
23
|
+
* Конструктор, который инициализирует преобразование набором элементов свойств.
|
|
24
|
+
* @param items data for processing / данные для обработки
|
|
16
25
|
*/
|
|
17
26
|
constructor(
|
|
18
27
|
protected items: PropertiesItems
|
|
19
28
|
) {
|
|
20
29
|
}
|
|
21
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Executes the full transformation pipeline: initialization followed by writing the output.
|
|
33
|
+
*
|
|
34
|
+
* Выполняет полный конвейер преобразования: инициализацию с последующей записью результата.
|
|
35
|
+
*/
|
|
22
36
|
to(): void {
|
|
23
37
|
this.init()
|
|
24
38
|
this.write()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { useAi } from '../useAi'
|
|
3
|
+
import { PropertiesConfig } from '../../classes/Properties/PropertiesConfig'
|
|
4
|
+
import { AiGoogle } from '../../classes/Ai/AiGoogle'
|
|
5
|
+
import { AiGoogleCli } from '../../classes/Ai/AiGoogleCli'
|
|
6
|
+
|
|
7
|
+
vi.mock('../../classes/Properties/PropertiesConfig', () => ({
|
|
8
|
+
PropertiesConfig: {
|
|
9
|
+
getAiType: vi.fn()
|
|
10
|
+
}
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
vi.mock('../../classes/Ai/AiGoogle', () => {
|
|
14
|
+
return {
|
|
15
|
+
AiGoogle: vi.fn().mockImplementation(function () {
|
|
16
|
+
return { name: 'AiGoogleInstance' }
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
vi.mock('../../classes/Ai/AiGoogleCli', () => {
|
|
22
|
+
return {
|
|
23
|
+
AiGoogleCli: vi.fn().mockImplementation(function () {
|
|
24
|
+
return { name: 'AiGoogleCliInstance' }
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('useAi', () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.clearAllMocks()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should return an instance of AiGoogle when the type is gemini', () => {
|
|
35
|
+
vi.mocked(PropertiesConfig.getAiType).mockReturnValue('gemini')
|
|
36
|
+
const mockInstance = { name: 'AiGoogleInstance' }
|
|
37
|
+
vi.mocked(AiGoogle).mockImplementation(function () {
|
|
38
|
+
return mockInstance as any
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const result = useAi()
|
|
42
|
+
|
|
43
|
+
expect(result).toEqual(mockInstance)
|
|
44
|
+
expect(AiGoogle).toHaveBeenCalled()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('should return an instance of AiGoogleCli when the type is gemini-cli', () => {
|
|
48
|
+
vi.mocked(PropertiesConfig.getAiType).mockReturnValue('gemini-cli')
|
|
49
|
+
const mockInstance = { name: 'AiGoogleCliInstance' }
|
|
50
|
+
vi.mocked(AiGoogleCli).mockImplementation(function () {
|
|
51
|
+
return mockInstance as any
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const result = useAi()
|
|
55
|
+
|
|
56
|
+
expect(result).toEqual(mockInstance)
|
|
57
|
+
expect(AiGoogleCli).toHaveBeenCalled()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should return undefined for an unknown type', () => {
|
|
61
|
+
vi.mocked(PropertiesConfig.getAiType).mockReturnValue('unknown' as any)
|
|
62
|
+
|
|
63
|
+
const result = useAi()
|
|
64
|
+
|
|
65
|
+
expect(result).toBeUndefined()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('should return undefined if no type is configured', () => {
|
|
69
|
+
vi.mocked(PropertiesConfig.getAiType).mockReturnValue(undefined as any)
|
|
70
|
+
|
|
71
|
+
const result = useAi()
|
|
72
|
+
|
|
73
|
+
expect(result).toBeUndefined()
|
|
74
|
+
})
|
|
75
|
+
})
|
package/src/config.ts
CHANGED
|
@@ -79,6 +79,7 @@ export const UI_FILE_NAME_MEDIA = 'media'
|
|
|
79
79
|
/** File name for the list of component descriptions/ Название файла для список описаний компонентов */
|
|
80
80
|
export const UI_FILE_NAME_DESIGN = 'design'
|
|
81
81
|
export const UI_FILE_NAME_PLUGIN = 'plugin'
|
|
82
|
+
export const UI_FILE_NAME_STYLE = 'style'
|
|
82
83
|
|
|
83
84
|
/** File name for the list of component descriptions for the wiki/ Название файла для список описаний компонентов для wiki */
|
|
84
85
|
export const UI_FILE_NAME_WIKI = 'wiki'
|
|
@@ -91,6 +92,7 @@ export const UI_FILE_INDEX = 'index.ts'
|
|
|
91
92
|
|
|
92
93
|
export const UI_FILE_AI_TYPES = 'ai-types.txt'
|
|
93
94
|
export const UI_FILE_STYLE_SCSS = 'style.scss'
|
|
95
|
+
export const UI_FILE_STYLE_PROPERTIES = 'ui-properties.scss'
|
|
94
96
|
|
|
95
97
|
/** SCSS file extension/ Расширение файлов SCSS */
|
|
96
98
|
export const UI_EXTENSION_STYLE = 'scss'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { getComponentPaths } from '../getComponentPaths'
|
|
3
|
+
import { UI_DIRS_COMPONENTS } from '../../config'
|
|
4
|
+
|
|
5
|
+
describe('getComponentPaths', () => {
|
|
6
|
+
it('should return an array containing UI_DIRS_COMPONENTS and the given path', () => {
|
|
7
|
+
const path = 'test-component'
|
|
8
|
+
const result = getComponentPaths(path)
|
|
9
|
+
|
|
10
|
+
expect(result).toEqual([...UI_DIRS_COMPONENTS, path])
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('it should work with nested paths', () => {
|
|
14
|
+
const path = 'nested/test-component'
|
|
15
|
+
const result = getComponentPaths(path)
|
|
16
|
+
|
|
17
|
+
expect(result).toEqual([...UI_DIRS_COMPONENTS, path])
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { getConfigAi } from '../getConfigAi'
|
|
3
|
+
import { PropertiesConfig } from '../../classes/Properties/PropertiesConfig'
|
|
4
|
+
|
|
5
|
+
vi.mock('../../classes/Properties/PropertiesConfig', () => ({
|
|
6
|
+
PropertiesConfig: {
|
|
7
|
+
getAiKey: vi.fn(),
|
|
8
|
+
getAiModel: vi.fn()
|
|
9
|
+
}
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
describe('getConfigAi', () => {
|
|
13
|
+
it('should return AI key and model from PropertiesConfig', () => {
|
|
14
|
+
const mockKey = 'test-key'
|
|
15
|
+
const mockModel = 'test-model'
|
|
16
|
+
|
|
17
|
+
vi.mocked(PropertiesConfig.getAiKey).mockReturnValue(mockKey)
|
|
18
|
+
vi.mocked(PropertiesConfig.getAiModel).mockReturnValue(mockModel)
|
|
19
|
+
|
|
20
|
+
const result = getConfigAi()
|
|
21
|
+
|
|
22
|
+
expect(result).toEqual([mockKey, mockModel])
|
|
23
|
+
expect(PropertiesConfig.getAiKey).toHaveBeenCalled()
|
|
24
|
+
expect(PropertiesConfig.getAiModel).toHaveBeenCalled()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { getConstructorProperties } from '../getConstructorProperties'
|
|
3
|
+
import { PropertiesFile } from '../../classes/Properties/PropertiesFile'
|
|
4
|
+
import { hasNativeDirname } from '../hasNativeDirname'
|
|
5
|
+
|
|
6
|
+
vi.mock('../../classes/Properties/PropertiesFile', () => ({
|
|
7
|
+
PropertiesFile: {
|
|
8
|
+
readFile: vi.fn()
|
|
9
|
+
}
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
vi.mock('../hasNativeDirname', () => ({
|
|
13
|
+
hasNativeDirname: vi.fn()
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
describe('getConstructorProperties', () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
vi.clearAllMocks()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should return properties for given constructor names', () => {
|
|
22
|
+
const mockItem = { some: 'property' }
|
|
23
|
+
vi.mocked(hasNativeDirname).mockReturnValue(true)
|
|
24
|
+
vi.mocked(PropertiesFile.readFile).mockReturnValue(mockItem)
|
|
25
|
+
|
|
26
|
+
const result = getConstructorProperties(['Button', 'Input'])
|
|
27
|
+
|
|
28
|
+
expect(result).toEqual({
|
|
29
|
+
Button: mockItem,
|
|
30
|
+
Input: mockItem
|
|
31
|
+
})
|
|
32
|
+
expect(PropertiesFile.readFile).toHaveBeenCalledTimes(2)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should return an empty object if no constructors found or error occurs', () => {
|
|
36
|
+
vi.mocked(hasNativeDirname).mockReturnValue(true)
|
|
37
|
+
vi.mocked(PropertiesFile.readFile).mockReturnValue(undefined)
|
|
38
|
+
|
|
39
|
+
const result = getConstructorProperties(['NonExistent'])
|
|
40
|
+
|
|
41
|
+
expect(result).toEqual({})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should handles non-native dirname environment', () => {
|
|
45
|
+
vi.mocked(hasNativeDirname).mockReturnValue(false)
|
|
46
|
+
vi.mocked(PropertiesFile.readFile).mockReturnValue({ status: 'ok' })
|
|
47
|
+
|
|
48
|
+
const result = getConstructorProperties(['Button'])
|
|
49
|
+
expect(result).toEqual({ Button: { status: 'ok' } })
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { getDirname } from '../getDirname'
|
|
3
|
+
import { hasNativeDirname } from '../hasNativeDirname'
|
|
4
|
+
|
|
5
|
+
vi.mock('../hasNativeDirname', () => ({
|
|
6
|
+
hasNativeDirname: vi.fn()
|
|
7
|
+
}))
|
|
8
|
+
|
|
9
|
+
// We can't easily mock import.meta.url or __dirname globally in a way that affects the module internally without ESM tricks,
|
|
10
|
+
// but we can at least test that it calls the right path based on hasNativeDirname
|
|
11
|
+
describe('getDirname', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
vi.clearAllMocks()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should return __dirname when hasNativeDirname is true', () => {
|
|
17
|
+
vi.mocked(hasNativeDirname).mockReturnValue(true)
|
|
18
|
+
|
|
19
|
+
// In a vitest environment with native support, __dirname should be defined
|
|
20
|
+
// We expect it to not throw and return a string
|
|
21
|
+
const result = getDirname()
|
|
22
|
+
expect(typeof result).toBe('string')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should return a path via fileURLToPath when hasNativeDirname is false', () => {
|
|
26
|
+
vi.mocked(hasNativeDirname).mockReturnValue(false)
|
|
27
|
+
|
|
28
|
+
const result = getDirname()
|
|
29
|
+
expect(typeof result).toBe('string')
|
|
30
|
+
})
|
|
31
|
+
})
|