@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.
Files changed (104) hide show
  1. package/bin/design-wiki-storm.ts +9 -0
  2. package/package.json +5 -3
  3. package/src/classes/Ai/AiAbstract.ts +14 -1
  4. package/src/classes/Ai/AiGoogleLite.ts +2 -1
  5. package/src/classes/Build/__tests__/buildFunctional.test.ts +43 -0
  6. package/src/classes/Build/buildFunctional.ts +15 -0
  7. package/src/classes/Component/ComponentCreator.ts +1 -0
  8. package/src/classes/Component/ComponentItem.ts +15 -0
  9. package/src/classes/Component/ComponentWiki.ts +8 -0
  10. package/src/classes/Component/ComponentWikiFile.ts +2 -0
  11. package/src/classes/Component/__tests__/ComponentCreator.test.ts +71 -0
  12. package/src/classes/Component/__tests__/ComponentItem.test.ts +71 -0
  13. package/src/classes/Design/DesignCommand.ts +13 -8
  14. package/src/classes/Design/DesignComponent.ts +235 -28
  15. package/src/classes/Design/DesignConstructor.ts +9 -5
  16. package/src/classes/Design/DesignConstructors.ts +8 -4
  17. package/src/classes/Design/DesignFlags.ts +16 -0
  18. package/src/classes/Design/DesignReplace.ts +10 -6
  19. package/src/classes/Design/DesignStructure.ts +8 -6
  20. package/src/classes/Design/DesignStructureClasses.ts +8 -4
  21. package/src/classes/Design/DesignStructureItemAbstract.ts +11 -2
  22. package/src/classes/Design/DesignStructureRead.ts +8 -4
  23. package/src/classes/Design/DesignStructureStyles.ts +8 -4
  24. package/src/classes/Design/DesignTypes.ts +53 -28
  25. package/src/classes/Design/DesignTypescript.ts +11 -2
  26. package/src/classes/Design/DesignUi.ts +42 -11
  27. package/src/classes/Design/DesignWiki.ts +4 -6
  28. package/src/classes/Design/DesignWikiStorm.ts +94 -0
  29. package/src/classes/Design/DesignWikiStormItem.ts +246 -0
  30. package/src/classes/Git/GitRead.ts +1 -0
  31. package/src/classes/Git/__tests__/GitRead.test.ts +70 -0
  32. package/src/classes/Library/LibraryAiWiki.ts +2 -1
  33. package/src/classes/Library/LibraryFlags.ts +9 -7
  34. package/src/classes/Library/LibraryItems.ts +9 -9
  35. package/src/classes/Library/LibraryList.ts +10 -5
  36. package/src/classes/Library/LibraryMedia.ts +21 -6
  37. package/src/classes/Library/LibraryPlugin.ts +8 -5
  38. package/src/classes/Library/LibraryTypes.ts +34 -10
  39. package/src/classes/Package/PackageInit.ts +12 -4
  40. package/src/classes/Package/PackageItem.ts +13 -4
  41. package/src/classes/Properties/Properties.ts +14 -3
  42. package/src/classes/Properties/PropertiesCache.ts +19 -20
  43. package/src/classes/Properties/PropertiesConfig.ts +39 -28
  44. package/src/classes/Properties/PropertiesConvector.ts +10 -6
  45. package/src/classes/Properties/PropertiesFile.ts +22 -28
  46. package/src/classes/Properties/PropertiesImport.ts +10 -7
  47. package/src/classes/Properties/PropertiesItems.ts +19 -12
  48. package/src/classes/Properties/PropertiesKeys.ts +15 -9
  49. package/src/classes/Properties/PropertiesMain.ts +13 -7
  50. package/src/classes/Properties/PropertiesPalette.ts +12 -6
  51. package/src/classes/Properties/PropertiesPath.ts +17 -11
  52. package/src/classes/Properties/PropertiesScss.ts +10 -8
  53. package/src/classes/Properties/PropertiesSeparator.ts +9 -11
  54. package/src/classes/Properties/PropertiesSettings.ts +8 -6
  55. package/src/classes/Properties/PropertiesStandard.ts +5 -6
  56. package/src/classes/Properties/PropertiesTool.ts +16 -9
  57. package/src/classes/Properties/PropertiesTypes.ts +12 -12
  58. package/src/classes/Properties/PropertiesValues.ts +14 -14
  59. package/src/classes/Properties/PropertiesWrap.ts +5 -6
  60. package/src/classes/Properties/convector/convectorColor.ts +5 -3
  61. package/src/classes/Properties/to/PropertiesToAbstract.ts +18 -4
  62. package/src/composables/__tests__/useAi.test.ts +75 -0
  63. package/src/config.ts +2 -0
  64. package/src/functions/__tests__/getComponentPaths.test.ts +19 -0
  65. package/src/functions/__tests__/getConfigAi.test.ts +26 -0
  66. package/src/functions/__tests__/getConstructorProperties.test.ts +51 -0
  67. package/src/functions/__tests__/getDirname.test.ts +31 -0
  68. package/src/functions/__tests__/getNameDirByPaths.test.ts +40 -0
  69. package/src/functions/__tests__/getPackageJson.test.ts +34 -0
  70. package/src/functions/__tests__/hasNativeDirname.test.ts +18 -0
  71. package/src/functions/__tests__/toPathStandardSep.test.ts +31 -0
  72. package/src/functions/getConfigAi.ts +3 -2
  73. package/src/functions/toPathStandardSep.ts +1 -1
  74. package/src/library-ai.ts +0 -1
  75. package/src/library.ts +6 -0
  76. package/src/media/properties/css.ts +3 -1
  77. package/src/media/templates/component/props.ts +1 -1
  78. package/src/media/templates/component/wiki.ts +6 -12
  79. package/src/media/templates/component/wikiData.ts +28 -0
  80. package/src/media/templates/packages/figma/README.md +1 -0
  81. package/src/media/templates/packages/figma/ai.sample.config.ts +2 -0
  82. package/src/media/templates/packages/figma/design.config.json +3 -0
  83. package/src/media/templates/packages/figma/index.html +12 -0
  84. package/src/media/templates/packages/figma/manifest.json +25 -0
  85. package/src/media/templates/packages/figma/package.json +37 -0
  86. package/src/media/templates/packages/figma/src/App.vue +9 -0
  87. package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +1 -0
  88. package/src/media/templates/packages/figma/src/code.ts +16 -0
  89. package/src/media/templates/packages/figma/src/components/_.gitignore.txt +1 -0
  90. package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +1 -0
  91. package/src/media/templates/packages/figma/src/config.ts +0 -0
  92. package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +1 -0
  93. package/src/media/templates/packages/figma/src/library.ts +0 -0
  94. package/src/media/templates/packages/figma/src/main.ts +4 -0
  95. package/src/media/templates/packages/figma/src/media/_.gitignore.txt +1 -0
  96. package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +1 -0
  97. package/src/media/templates/packages/figma/src/types/_.gitignore.txt +1 -0
  98. package/src/media/templates/packages/figma/src/vite-env.d.ts +1 -0
  99. package/src/media/templates/packages/figma/tsconfig.app.json +12 -0
  100. package/src/media/templates/packages/figma/tsconfig.json +7 -0
  101. package/src/media/templates/packages/figma/tsconfig.node.json +8 -0
  102. package/src/media/templates/packages/figma/vite.config.ts +7 -0
  103. package/src/types/configTypes.ts +3 -0
  104. 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 working with SCSS.
23
+ * Class for generating SCSS structures from design tokens.
24
24
  *
25
- * Класс для работы с SCSS.
25
+ * Класс для генерации структур SCSS из токенов дизайна.
26
26
  */
27
27
  export class PropertiesScss {
28
28
  /**
29
- * Constructor
30
- * @param items
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 for SCSS.
38
+ * Returns a complete SCSS formatted string containing all configuration mixins.
37
39
  *
38
- * Возвращает отформатированную строку для SCSS.
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
- * Returns a list of properties.
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 working with property splitting into multiple sub-properties.
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 structure has grouped records.
21
+ * Checks if the property list contains any keys that require splitting (contain separators).
22
22
  *
23
- * Проверяет, есть ли у структуры сгруппированные записи.
24
- * @param properties an array that needs to be transformed/
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
- * Transforming a property with long names with separators into a set of sub-properties.
53
+ * Transforms properties with separator-containing keys into a nested object structure.
56
54
  *
57
- * Преобразование свойства с длинными названиями с разделителями на множество под-свойств.
58
- * @param properties an array that needs to be transformed/ массив, который нужно преобразовать
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 all components.
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
- * @param path object of the class for working with paths/ объект класса для работы с путями
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 the basic settings of the component.
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
- * A class for transforming a property into a basic structure for work.
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 an array into the required data structure.
25
+ * Transforms a property list or raw data into a standardized PropertyList structure.
26
26
  *
27
- * Преобразует массив в нужную структуру.
28
- * @param properties an array that needs to be transformed/
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
- * A class for static methods of obtaining various data.
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 names of the design relate to the construction.
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
- * Return a list of component names.
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
- * Class with a list of available types.
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 contains such a type.
30
+ * Checks if the property type matches the specified list of allowed types.
31
31
  *
32
- * Проверяет, входит ли в список такой тип.
33
- * @param type property type/ тип свойства
34
- * @param name key 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
- * Checks if there is a type in the name of the property.
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
- * Returns the variable type name from the property name.
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
- * Class for working with the values.
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 values are complete.
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
- * Checks if the value is a color value.
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
- * Checks if the value is a color with transparency.
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
- * Removes unnecessary values from the values.
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
- * A class for moving data up the level, if the property is used in all records at the same level.
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
- * Drag the duplicate properties to the top level to reduce the record.
20
+ * Analyzes the property list and moves duplicate properties to the parent level to reduce redundancy.
21
21
  *
22
- * Перетаскивает дублирующиеся свойства на верхний уровень для уменьшения записи.
23
- * @param properties an array that needs to be transformed/
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
- * Data conversion into colors.
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
- * @param item values for conversion/ значения для преобразования
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 conversion.
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
- * @param items data for processing/ данные для обработки
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
+ })