@dxtmisha/scripts 0.11.8 → 1.0.0
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/CHANGELOG.md +57 -0
- package/ai-resources/componentMaterials.md +19 -0
- package/ai-resources/componentPrompt.md +381 -0
- package/ai-resources/componentWiki.md +13 -0
- package/bin/arguments.ts +168 -0
- package/bin/build-packages.ts +12 -2
- package/bin/build-publish-packages.ts +12 -2
- package/bin/design-component.ts +7 -1
- package/bin/design-constructor.ts +22 -3
- package/bin/design-figma.ts +26 -4
- package/bin/design-flags.ts +14 -2
- package/bin/design-library.ts +7 -1
- package/bin/design-package.ts +29 -5
- package/bin/design-prompt.ts +22 -3
- package/bin/design-screenshot.ts +12 -2
- package/bin/design-types-save.ts +32 -5
- package/bin/design-types.ts +32 -6
- package/bin/design-ui.ts +21 -3
- package/bin/design-wiki-storm.ts +11 -3
- package/dist/AiZAi-x3CInynJ.js +232 -0
- package/dist/PropertiesConfig-ChizwW5y.js +250 -0
- package/{src/config.ts → dist/config.d.ts} +179 -158
- package/dist/config.js +20 -0
- package/dist/figmaApiTypes-CArSsNW8.js +6 -0
- package/dist/library-ai.d.ts +482 -0
- package/dist/library-ai.js +2 -0
- package/dist/library-figma.d.ts +462 -0
- package/dist/library-figma.js +75 -0
- package/dist/library-ui.d.ts +586 -0
- package/dist/library-ui.js +3760 -0
- package/dist/library.d.ts +4677 -0
- package/dist/library.js +1436 -0
- package/dist/propertyTypes-DflziKuR.js +236 -0
- package/package.json +69 -20
- package/bin/ai-doc.ts +0 -7
- package/bin/build-functional.ts +0 -5
- package/bin/design-component-wiki.ts +0 -11
- package/src/classes/Ai/AiAbstract.ts +0 -242
- package/src/classes/Ai/AiClaude.ts +0 -26
- package/src/classes/Ai/AiClaudeAgent.ts +0 -16
- package/src/classes/Ai/AiClaudeAgentLite.ts +0 -86
- package/src/classes/Ai/AiClaudeCli.ts +0 -24
- package/src/classes/Ai/AiClaudeCliLite.ts +0 -108
- package/src/classes/Ai/AiClaudeLite.ts +0 -112
- package/src/classes/Ai/AiDoc.ts +0 -81
- package/src/classes/Ai/AiDocItem.ts +0 -27
- package/src/classes/Ai/AiDocItemAbstract.ts +0 -209
- package/src/classes/Ai/AiDocItemClasses.ts +0 -27
- package/src/classes/Ai/AiDocItemComposables.ts +0 -20
- package/src/classes/Ai/AiDocType.ts +0 -45
- package/src/classes/Ai/AiGoogle.ts +0 -26
- package/src/classes/Ai/AiGoogleCli.ts +0 -24
- package/src/classes/Ai/AiGoogleCliLite.ts +0 -108
- package/src/classes/Ai/AiGoogleLite.ts +0 -78
- package/src/classes/Ai/AiOpenAi.ts +0 -26
- package/src/classes/Ai/AiOpenAiLite.ts +0 -107
- package/src/classes/Ai/AiZAi.ts +0 -17
- package/src/classes/Ai/AiZAiLite.ts +0 -77
- package/src/classes/Ai/ApiTmp.ts +0 -43
- package/src/classes/BrowserItem.ts +0 -408
- package/src/classes/Build/BuildFunctional.ts +0 -54
- package/src/classes/Build/BuildPackages.ts +0 -137
- package/src/classes/Build/BuildPublishPackages.ts +0 -105
- package/src/classes/BuildItem.ts +0 -187
- package/src/classes/Component/ComponentCreator.ts +0 -45
- package/src/classes/Component/ComponentItem.ts +0 -161
- package/src/classes/Component/ComponentWiki.ts +0 -258
- package/src/classes/Component/ComponentWikiFile.ts +0 -138
- package/src/classes/Design/DesignCommand.ts +0 -243
- package/src/classes/Design/DesignComponent.ts +0 -824
- package/src/classes/Design/DesignConstructor.ts +0 -222
- package/src/classes/Design/DesignConstructors.ts +0 -101
- package/src/classes/Design/DesignFigma.ts +0 -61
- package/src/classes/Design/DesignFlags.ts +0 -215
- package/src/classes/Design/DesignReplace.ts +0 -672
- package/src/classes/Design/DesignScreenshot.ts +0 -140
- package/src/classes/Design/DesignStructure.ts +0 -201
- package/src/classes/Design/DesignStructureClasses.ts +0 -105
- package/src/classes/Design/DesignStructureItemAbstract.ts +0 -52
- package/src/classes/Design/DesignStructureRead.ts +0 -349
- package/src/classes/Design/DesignStructureStyles.ts +0 -45
- package/src/classes/Design/DesignTypes.ts +0 -94
- package/src/classes/Design/DesignTypesAi.ts +0 -135
- package/src/classes/Design/DesignTypesDescription.ts +0 -121
- package/src/classes/Design/DesignTypesMake.ts +0 -460
- package/src/classes/Design/DesignTypesMcp.ts +0 -90
- package/src/classes/Design/DesignTypesPrompts.ts +0 -332
- package/src/classes/Design/DesignTypescript.ts +0 -244
- package/src/classes/Design/DesignUi.ts +0 -143
- package/src/classes/Design/DesignWiki.ts +0 -52
- package/src/classes/Design/DesignWikiStorm.ts +0 -95
- package/src/classes/Design/DesignWikiStormItem.ts +0 -316
- package/src/classes/FigmaApi.ts +0 -190
- package/src/classes/Git/GitRead.ts +0 -261
- package/src/classes/Library/LibraryAiMcpItem.ts +0 -67
- package/src/classes/Library/LibraryAiPrompt.ts +0 -268
- package/src/classes/Library/LibraryAiPromptItem.ts +0 -331
- package/src/classes/Library/LibraryAiWiki.ts +0 -127
- package/src/classes/Library/LibraryAiWikiItem.ts +0 -79
- package/src/classes/Library/LibraryExport.ts +0 -167
- package/src/classes/Library/LibraryFlags.ts +0 -62
- package/src/classes/Library/LibraryItems.ts +0 -138
- package/src/classes/Library/LibraryList.ts +0 -189
- package/src/classes/Library/LibraryMedia.ts +0 -139
- package/src/classes/Library/LibraryPlugin.ts +0 -73
- package/src/classes/Library/LibraryTypes.ts +0 -130
- package/src/classes/Package/PackageFile.ts +0 -154
- package/src/classes/Package/PackageInit.ts +0 -54
- package/src/classes/Package/PackageItem.ts +0 -329
- package/src/classes/Properties/Properties.ts +0 -175
- package/src/classes/Properties/PropertiesCache.ts +0 -248
- package/src/classes/Properties/PropertiesConfig.ts +0 -213
- package/src/classes/Properties/PropertiesConvector.ts +0 -52
- package/src/classes/Properties/PropertiesFile.ts +0 -522
- package/src/classes/Properties/PropertiesImport.ts +0 -182
- package/src/classes/Properties/PropertiesItems.ts +0 -605
- package/src/classes/Properties/PropertiesKeys.ts +0 -121
- package/src/classes/Properties/PropertiesMain.ts +0 -138
- package/src/classes/Properties/PropertiesPalette.ts +0 -149
- package/src/classes/Properties/PropertiesPath.ts +0 -193
- package/src/classes/Properties/PropertiesScss.ts +0 -261
- package/src/classes/Properties/PropertiesSeparator.ts +0 -118
- package/src/classes/Properties/PropertiesSettings.ts +0 -104
- package/src/classes/Properties/PropertiesStandard.ts +0 -180
- package/src/classes/Properties/PropertiesTool.ts +0 -80
- package/src/classes/Properties/PropertiesTypes.ts +0 -147
- package/src/classes/Properties/PropertiesValues.ts +0 -75
- package/src/classes/Properties/PropertiesWrap.ts +0 -187
- package/src/classes/Properties/convector/convectorColor.ts +0 -27
- package/src/classes/Properties/convector/convectorFontFamilies.ts +0 -18
- package/src/classes/Properties/convector/convectorShadow.ts +0 -61
- package/src/classes/Properties/convector/convectorTypography.ts +0 -19
- package/src/classes/Properties/to/PropertiesToAbstract.ts +0 -51
- package/src/classes/Properties/to/PropertiesToAnimate.ts +0 -59
- package/src/classes/Properties/to/PropertiesToClass.ts +0 -49
- package/src/classes/Properties/to/PropertiesToClone.ts +0 -114
- package/src/classes/Properties/to/PropertiesToComponent.ts +0 -52
- package/src/classes/Properties/to/PropertiesToDrag.ts +0 -231
- package/src/classes/Properties/to/PropertiesToDuplicate.ts +0 -165
- package/src/classes/Properties/to/PropertiesToFull.ts +0 -36
- package/src/classes/Properties/to/PropertiesToLink.ts +0 -259
- package/src/classes/Properties/to/PropertiesToMedia.ts +0 -187
- package/src/classes/Properties/to/PropertiesToMulti.ts +0 -101
- package/src/classes/Properties/to/PropertiesToNone.ts +0 -46
- package/src/classes/Properties/to/PropertiesToPalette.ts +0 -241
- package/src/classes/Properties/to/PropertiesToProperty.ts +0 -31
- package/src/classes/Properties/to/PropertiesToRemove.ts +0 -33
- package/src/classes/Properties/to/PropertiesToReplace.ts +0 -77
- package/src/classes/Properties/to/PropertiesToRoot.ts +0 -40
- package/src/classes/Properties/to/PropertiesToSimilar.ts +0 -128
- package/src/classes/Properties/to/PropertiesToSort.ts +0 -146
- package/src/classes/Properties/to/PropertiesToState.ts +0 -65
- package/src/classes/Properties/to/PropertiesToStyle.ts +0 -52
- package/src/classes/Properties/to/PropertiesToSub.ts +0 -95
- package/src/classes/Properties/to/PropertiesToSubclass.ts +0 -76
- package/src/classes/Properties/to/PropertiesToVar.ts +0 -194
- package/src/classes/Properties/to/PropertiesToVariable.ts +0 -176
- package/src/classes/Styles/Styles.ts +0 -247
- package/src/classes/Styles/StylesClasses.ts +0 -86
- package/src/classes/Styles/StylesProperties.ts +0 -197
- package/src/classes/Styles/StylesRoot.ts +0 -103
- package/src/classes/Styles/StylesTool.ts +0 -112
- package/src/classes/Styles/to/StylesToAbstract.ts +0 -93
- package/src/classes/Styles/to/StylesToAnimate.ts +0 -19
- package/src/classes/Styles/to/StylesToClass.ts +0 -25
- package/src/classes/Styles/to/StylesToClassFull.ts +0 -19
- package/src/classes/Styles/to/StylesToContainer.ts +0 -24
- package/src/classes/Styles/to/StylesToMedia.ts +0 -19
- package/src/classes/Styles/to/StylesToProperty.ts +0 -123
- package/src/classes/Styles/to/StylesToRoot.ts +0 -14
- package/src/classes/Styles/to/StylesToSelector.ts +0 -71
- package/src/classes/Styles/to/StylesToVar.ts +0 -105
- package/src/classes/Styles/to/StylesToVirtual.ts +0 -33
- package/src/composables/useAi.ts +0 -38
- package/src/demo/ai.ts +0 -10
- package/src/functions/getComponentPaths.ts +0 -13
- package/src/functions/getConfigAi.ts +0 -14
- package/src/functions/getConstructorProperties.ts +0 -54
- package/src/functions/getDirname.ts +0 -17
- package/src/functions/getNameDirByPaths.ts +0 -16
- package/src/functions/getPackageJson.ts +0 -19
- package/src/functions/hasNativeDirname.ts +0 -8
- package/src/functions/run.ts +0 -47
- package/src/functions/toPathStandardSep.ts +0 -14
- package/src/library-ai.ts +0 -10
- package/src/library.ts +0 -73
- package/src/media/ai/ai-doc-types.ts +0 -21
- package/src/media/properties/css.ts +0 -634
- package/src/media/properties/cssSelector.ts +0 -74
- package/src/media/properties/cssVirtual.ts +0 -12
- package/src/media/properties/listSort.ts +0 -113
- package/src/media/properties/style.ts +0 -81
- package/src/media/templates/component/DesignComponent.mdx +0 -30
- package/src/media/templates/component/DesignComponent.stories.ts +0 -34
- package/src/media/templates/component/DesignComponent.vue +0 -54
- package/src/media/templates/component/DesignComponentAiWiki.vue +0 -25
- package/src/media/templates/component/index.ts +0 -13
- package/src/media/templates/component/props.ts +0 -27
- package/src/media/templates/component/styleToken.scss +0 -17
- package/src/media/templates/component/wiki.ts +0 -13
- package/src/media/templates/component/wikiData.ts +0 -28
- package/src/media/templates/componentDoc/ComponentDoc.vue +0 -26
- package/src/media/templates/componentDoc/index.ts +0 -12
- package/src/media/templates/componentDoc/materials/README.md +0 -8
- package/src/media/templates/componentDoc/materials/prompt.md +0 -38
- package/src/media/templates/componentDoc/subcomponents/_.gitignore.txt +0 -0
- package/src/media/templates/componentDoc/types.ts +0 -15
- package/src/media/templates/componentDoc/wiki/ComponentDoc.mdx +0 -13
- package/src/media/templates/componentDoc/wiki/ComponentDoc.stories.ts +0 -24
- package/src/media/templates/componentDoc/wiki/prompt.md +0 -41
- package/src/media/templates/constructors/Constructors.ts +0 -33
- package/src/media/templates/constructors/ConstructorsDesign.tsx +0 -129
- package/src/media/templates/constructors/basicTypes.ts +0 -0
- package/src/media/templates/constructors/index.ts +0 -5
- package/src/media/templates/constructors/props.ts +0 -28
- package/src/media/templates/constructors/style.scss +0 -5
- package/src/media/templates/constructors/types.ts +0 -47
- package/src/media/templates/packages/figma/README.md +0 -1
- package/src/media/templates/packages/figma/_.gitignore.txt +0 -29
- package/src/media/templates/packages/figma/ai.sample.config.ts +0 -2
- package/src/media/templates/packages/figma/design.config.json +0 -3
- package/src/media/templates/packages/figma/index.html +0 -12
- package/src/media/templates/packages/figma/manifest.json +0 -25
- package/src/media/templates/packages/figma/package.json +0 -37
- package/src/media/templates/packages/figma/src/App.vue +0 -9
- package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/code.ts +0 -16
- package/src/media/templates/packages/figma/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/config.ts +0 -0
- package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/library.ts +0 -0
- package/src/media/templates/packages/figma/src/main.ts +0 -4
- package/src/media/templates/packages/figma/src/media/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/figma/tsconfig.app.json +0 -12
- package/src/media/templates/packages/figma/tsconfig.json +0 -7
- package/src/media/templates/packages/figma/tsconfig.node.json +0 -8
- package/src/media/templates/packages/figma/vite.config.ts +0 -7
- package/src/media/templates/packages/library/README.md +0 -1
- package/src/media/templates/packages/library/_.gitignore.txt +0 -27
- package/src/media/templates/packages/library/ai-description.md +0 -15
- package/src/media/templates/packages/library/design.config.json +0 -3
- package/src/media/templates/packages/library/index.html +0 -12
- package/src/media/templates/packages/library/materials/README.md +0 -8
- package/src/media/templates/packages/library/materials/prompt.md +0 -45
- package/src/media/templates/packages/library/package.json +0 -46
- package/src/media/templates/packages/library/src/App.vue +0 -8
- package/src/media/templates/packages/library/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/library.ts +0 -0
- package/src/media/templates/packages/library/src/main.ts +0 -6
- package/src/media/templates/packages/library/src/style.scss +0 -0
- package/src/media/templates/packages/library/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/library/tsconfig.app.json +0 -11
- package/src/media/templates/packages/library/tsconfig.json +0 -7
- package/src/media/templates/packages/library/tsconfig.node.json +0 -7
- package/src/media/templates/packages/library/vite.config.ts +0 -14
- package/src/media/templates/packages/nitro/README.md +0 -1
- package/src/media/templates/packages/nitro/_.gitignore.txt +0 -28
- package/src/media/templates/packages/nitro/index.html +0 -2
- package/src/media/templates/packages/nitro/package.json +0 -25
- package/src/media/templates/packages/nitro/server/plugins/ui-plugin.ts +0 -7
- package/src/media/templates/packages/nitro/server/routes/api/hello.ts +0 -13
- package/src/media/templates/packages/nitro/src/App.vue +0 -10
- package/src/media/templates/packages/nitro/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/entry-client.ts +0 -13
- package/src/media/templates/packages/nitro/src/entry-server.ts +0 -29
- package/src/media/templates/packages/nitro/src/main.ts +0 -14
- package/src/media/templates/packages/nitro/src/pages/HomePage.vue +0 -8
- package/src/media/templates/packages/nitro/src/router.ts +0 -11
- package/src/media/templates/packages/nitro/src/style.scss +0 -0
- package/src/media/templates/packages/nitro/src/templates/main.html +0 -21
- package/src/media/templates/packages/nitro/src/vite-env.d.ts +0 -11
- package/src/media/templates/packages/nitro/tsconfig.app.json +0 -14
- package/src/media/templates/packages/nitro/tsconfig.json +0 -7
- package/src/media/templates/packages/nitro/tsconfig.node.json +0 -12
- package/src/media/templates/packages/nitro/vite.config.ts +0 -17
- package/src/media/templates/packages/project/README.md +0 -1
- package/src/media/templates/packages/project/_.gitignore.txt +0 -28
- package/src/media/templates/packages/project/design.config.json +0 -3
- package/src/media/templates/packages/project/index.html +0 -12
- package/src/media/templates/packages/project/materials/README.md +0 -8
- package/src/media/templates/packages/project/materials/prompt.md +0 -41
- package/src/media/templates/packages/project/package.json +0 -13
- package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/App.vue +0 -12
- package/src/media/templates/packages/project/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/main.ts +0 -6
- package/src/media/templates/packages/project/src/style.scss +0 -0
- package/src/media/templates/packages/project/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/project/tsconfig.app.json +0 -11
- package/src/media/templates/packages/project/tsconfig.json +0 -7
- package/src/media/templates/packages/project/tsconfig.node.json +0 -7
- package/src/media/templates/packages/project/vite.config.ts +0 -7
- package/src/media/templates/prompts/aiCodeGlobalPrompt.en.md +0 -22
- package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.md +0 -21
- package/src/media/templates/prompts/aiCodeVuePrompt.en.md +0 -17
- package/src/media/templates/prompts/aiCodeVuePrompt.ru.md +0 -17
- package/src/media/templates/prompts/aiDocClassPrompt.en.txt +0 -63
- package/src/media/templates/prompts/aiDocClassPrompt.ru.txt +0 -63
- package/src/media/templates/prompts/aiDocComposablePrompt.en.txt +0 -67
- package/src/media/templates/prompts/aiDocComposablePrompt.ru.txt +0 -67
- package/src/media/templates/prompts/aiDocFunctionPrompt.en.txt +0 -57
- package/src/media/templates/prompts/aiDocFunctionPrompt.ru.txt +0 -57
- package/src/media/templates/prompts/componentPrompt.en.txt +0 -182
- package/src/media/templates/prompts/componentPrompt.ru.txt +0 -182
- package/src/media/templates/prompts/demoClassEn.mdx +0 -111
- package/src/media/templates/prompts/demoClassRu.mdx +0 -111
- package/src/media/templates/prompts/demoComponentEn.mdx +0 -282
- package/src/media/templates/prompts/demoComponentRu.mdx +0 -282
- package/src/media/templates/prompts/demoComposableEn.mdx +0 -103
- package/src/media/templates/prompts/demoComposableRu.mdx +0 -103
- package/src/media/templates/prompts/demoDocEn.mdx +0 -30
- package/src/media/templates/prompts/demoDocRu.mdx +0 -30
- package/src/media/templates/viteComponentTemplateConfig.ts +0 -14
- package/src/types/aiTypes.ts +0 -19
- package/src/types/configTypes.ts +0 -69
- package/src/types/designTypes.ts +0 -167
- package/src/types/figmaApiTypes.ts +0 -337
- package/src/types/gitTypes.ts +0 -59
- package/src/types/libraryTypes.ts +0 -49
- package/src/types/propertyTypes.ts +0 -586
- package/src/types/screenshotTypes.ts +0 -55
- package/src/types/webTypes.ts +0 -134
- package/src/vite-env.d.ts +0 -1
|
@@ -1,824 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
forEach,
|
|
5
|
-
isObjectNotArray,
|
|
6
|
-
replaceComponentName,
|
|
7
|
-
toArray,
|
|
8
|
-
toCamelCase
|
|
9
|
-
} from '@dxtmisha/functional-basic'
|
|
10
|
-
import { wikiDescriptions } from '@dxtmisha/wiki/media'
|
|
11
|
-
import type { StorybookComponentsDescriptionItem } from '@dxtmisha/wiki'
|
|
12
|
-
|
|
13
|
-
import { PropertiesConfig } from '../Properties/PropertiesConfig'
|
|
14
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
15
|
-
import { DesignCommand } from './DesignCommand'
|
|
16
|
-
|
|
17
|
-
import { DesignTypescript } from './DesignTypescript'
|
|
18
|
-
import type { DesignReplace } from './DesignReplace'
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
UI_DIR_COMPONENTS,
|
|
22
|
-
UI_DIR_CONSTRUCTOR,
|
|
23
|
-
UI_DIR_DIST,
|
|
24
|
-
UI_DIR_IN,
|
|
25
|
-
UI_DIRS_COMPONENTS,
|
|
26
|
-
UI_DIRS_LIBRARY,
|
|
27
|
-
UI_PROJECT_CONSTRUCTOR_FULL_NAME,
|
|
28
|
-
UI_PROJECT_CONSTRUCTOR_NAME
|
|
29
|
-
} from '../../config'
|
|
30
|
-
import type { DesignTypescriptProp } from '../../types/designTypes'
|
|
31
|
-
|
|
32
|
-
const FILE_PROPERTIES = 'properties.json'
|
|
33
|
-
const FILE_PROPS = 'props.ts'
|
|
34
|
-
const FILE_STYLE = 'styleToken.scss'
|
|
35
|
-
const FILE_CLASS = 'DesignComponent.vue'
|
|
36
|
-
const FILE_CLASS_AI = 'DesignComponentAiWiki.vue'
|
|
37
|
-
const FILE_INDEX = 'index.ts'
|
|
38
|
-
const FILE_INDEX_DTS = 'index.d.ts'
|
|
39
|
-
const FILE_WIKI = 'wiki.ts'
|
|
40
|
-
const FILE_WIKI_DATA = 'wikiData.ts'
|
|
41
|
-
const FILE_STORIES = 'DesignComponent.stories.ts'
|
|
42
|
-
const FILE_STORIES_DOCUMENTATION = 'DesignComponent.mdx'
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Class for generating and updating all files and configurations associated with a design system component.
|
|
46
|
-
* It manages the lifecycle of properties, styles, Vue components, stories, and wiki documentation.
|
|
47
|
-
*
|
|
48
|
-
* Класс для генерации и обновления всех файлов и конфигураций, связанных с компонентом дизайн-системы.
|
|
49
|
-
* Управляет жизненным циклом свойств, стилей, компонентов Vue, историй и вики-документации.
|
|
50
|
-
*/
|
|
51
|
-
export class DesignComponent extends DesignCommand {
|
|
52
|
-
protected DIR_SAMPLE: string = 'component'
|
|
53
|
-
protected dir: string[]
|
|
54
|
-
protected propsType: DesignTypescriptProp[] | undefined
|
|
55
|
-
protected slotsType: DesignTypescriptProp[] | undefined
|
|
56
|
-
protected eventsType: DesignTypescriptProp[] | undefined
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Constructor for DesignComponent.
|
|
60
|
-
*
|
|
61
|
-
* Конструктор для DesignComponent.
|
|
62
|
-
* @param command component name or command identifier / название компонента или идентификатор команды
|
|
63
|
-
* @param options additional key-value parameters / дополнительные параметры ключ-значение
|
|
64
|
-
*/
|
|
65
|
-
constructor(
|
|
66
|
-
command: string,
|
|
67
|
-
options: Record<string, string> = {}
|
|
68
|
-
) {
|
|
69
|
-
super(command, options)
|
|
70
|
-
|
|
71
|
-
const structure = this.getStructure()
|
|
72
|
-
|
|
73
|
-
this.dir = [
|
|
74
|
-
PropertiesFile.getRoot(),
|
|
75
|
-
...UI_DIRS_COMPONENTS,
|
|
76
|
-
PropertiesConfig.getProjectName(),
|
|
77
|
-
structure.getComponentNameFirst()
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Initializes the creation of all files for the current team.
|
|
83
|
-
*
|
|
84
|
-
* Инициализирует создание всех файлов для текущей команды.
|
|
85
|
-
*/
|
|
86
|
-
protected initMain(): void {
|
|
87
|
-
this
|
|
88
|
-
.makeProperties()
|
|
89
|
-
.makeProps()
|
|
90
|
-
.makeStyle()
|
|
91
|
-
.makeMain()
|
|
92
|
-
.makeMainAi()
|
|
93
|
-
.makeIndex()
|
|
94
|
-
.makeWiki()
|
|
95
|
-
.makeWikiData()
|
|
96
|
-
.makeStories()
|
|
97
|
-
.makeStoriesDocumentation()
|
|
98
|
-
.makeFilePackage()
|
|
99
|
-
.makeLibrary()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* This code generates the properties.json.
|
|
104
|
-
*
|
|
105
|
-
* Генерация файла properties.json.
|
|
106
|
-
*/
|
|
107
|
-
protected makeProperties(): this {
|
|
108
|
-
const file = FILE_PROPERTIES
|
|
109
|
-
|
|
110
|
-
if (!this.isFile(file)) {
|
|
111
|
-
this.write(file, `{\r\n "main": "{d.${this.getStructure().getComponentName()}}"\r\n}\r\n`)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return this
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* This code generates the props.ts.
|
|
119
|
-
*
|
|
120
|
-
* Генерация файла props.ts.
|
|
121
|
-
*/
|
|
122
|
-
protected makeProps(): this {
|
|
123
|
-
const file = FILE_PROPS
|
|
124
|
-
const sample = this.readDefinable(file)
|
|
125
|
-
const constructor = this.getFileConstructor(file)
|
|
126
|
-
|
|
127
|
-
sample
|
|
128
|
-
.replaceType(constructor)
|
|
129
|
-
.replaceDefault()
|
|
130
|
-
.replaceProps()
|
|
131
|
-
.replacePropsValues()
|
|
132
|
-
|
|
133
|
-
this.write(file, sample.get())
|
|
134
|
-
return this
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* This code generates the style.scss.
|
|
139
|
-
*
|
|
140
|
-
* Генерация файла style.scss.
|
|
141
|
-
*/
|
|
142
|
-
protected makeStyle(): this {
|
|
143
|
-
const file = FILE_STYLE
|
|
144
|
-
const sample = this.readDefinable(file)
|
|
145
|
-
const styles = this.getStructure().getStyles()
|
|
146
|
-
|
|
147
|
-
sample.replaceMark('style', styles)
|
|
148
|
-
|
|
149
|
-
this.write(file, sample.get())
|
|
150
|
-
return this
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* This code generates the style.scss.
|
|
155
|
-
*
|
|
156
|
-
* Генерация файла style.scss.
|
|
157
|
-
*/
|
|
158
|
-
protected makeMain(): this {
|
|
159
|
-
const file = FILE_CLASS
|
|
160
|
-
const sample = this.readDefinable(file)
|
|
161
|
-
|
|
162
|
-
sample.replaceClassesValues()
|
|
163
|
-
sample.replaceStylesValues()
|
|
164
|
-
|
|
165
|
-
this.write(sample.getNameFile(file), sample.get())
|
|
166
|
-
return this
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* This code generates the DesignComponentWikiAi.vue.
|
|
171
|
-
*
|
|
172
|
-
* Генерация файла DesignComponentWikiAi.vue.
|
|
173
|
-
*/
|
|
174
|
-
protected makeMainAi(): this {
|
|
175
|
-
const file = FILE_CLASS_AI
|
|
176
|
-
const sample = this.readDefinable(file)
|
|
177
|
-
const design = this.getStructure().getDesignFirst()
|
|
178
|
-
const componentName = this.getStructure().getComponentNameFirst()
|
|
179
|
-
const fullComponentName = this.getStructure().getFullComponentName()
|
|
180
|
-
const item = this.getWikiDescription()
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
item?.ai
|
|
184
|
-
) {
|
|
185
|
-
const imports: string[] = []
|
|
186
|
-
|
|
187
|
-
if (item.ai.render) {
|
|
188
|
-
let render = replaceComponentName(
|
|
189
|
-
item.ai.render,
|
|
190
|
-
componentName,
|
|
191
|
-
fullComponentName
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
if (item.ai.render.includes('<button')) {
|
|
195
|
-
imports.push(`import { DxtTestButton } from '@dxtmisha/test'`)
|
|
196
|
-
render = replaceComponentName(render, 'button', 'DxtTestButton')
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (render) {
|
|
200
|
-
sample.replaceMark('component-render', [
|
|
201
|
-
'<template #render="{ args, classDemo }">',
|
|
202
|
-
render,
|
|
203
|
-
'</template>'
|
|
204
|
-
])
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (item.ai.import) {
|
|
209
|
-
imports.push(...item.ai.import)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (imports.length > 0) {
|
|
213
|
-
sample.replaceMark('component-import', imports)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
this.write(
|
|
218
|
-
sample.getNameFile(file),
|
|
219
|
-
sample.get()
|
|
220
|
-
.replace('design="Design"', `design="${design}"`)
|
|
221
|
-
)
|
|
222
|
-
|
|
223
|
-
return this
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* This code generates the index.ts.
|
|
228
|
-
*
|
|
229
|
-
* Генерация файла index.ts.
|
|
230
|
-
*/
|
|
231
|
-
protected makeIndex(): this {
|
|
232
|
-
const file = FILE_INDEX
|
|
233
|
-
const sample = this.readDefinable(file)
|
|
234
|
-
|
|
235
|
-
this.write(file, sample.get())
|
|
236
|
-
return this
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* This code generates the wiki.ts.
|
|
241
|
-
*
|
|
242
|
-
* Генерация файла wiki.ts.
|
|
243
|
-
*/
|
|
244
|
-
protected makeWiki(): this {
|
|
245
|
-
const file = FILE_WIKI
|
|
246
|
-
const sample = this.readDefinable(file)
|
|
247
|
-
|
|
248
|
-
this.write(file, sample.get())
|
|
249
|
-
return this
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* This code generates the wikiData.ts.
|
|
254
|
-
*
|
|
255
|
-
* Генерация файла wikiData.ts.
|
|
256
|
-
*/
|
|
257
|
-
protected makeWikiData(): this {
|
|
258
|
-
const file = FILE_WIKI_DATA
|
|
259
|
-
const typeInfo = this.getPropsList()
|
|
260
|
-
const slotsInfo = this.getSlotsList()
|
|
261
|
-
const eventsInfo = this.getEventsList()
|
|
262
|
-
const sample = this.readDefinable(file)
|
|
263
|
-
|
|
264
|
-
if (typeInfo) {
|
|
265
|
-
const props: string[] = []
|
|
266
|
-
|
|
267
|
-
typeInfo
|
|
268
|
-
.sort((a, b) => a.name.localeCompare(b.name))
|
|
269
|
-
.forEach((prop) => {
|
|
270
|
-
const option = prop.option
|
|
271
|
-
let item: string = ''
|
|
272
|
-
|
|
273
|
-
item += `{ name: '${prop.name}', type: '${prop.type.replace('| undefined', '').trim()}'`
|
|
274
|
-
|
|
275
|
-
if (
|
|
276
|
-
option
|
|
277
|
-
&& option.length > 0
|
|
278
|
-
) {
|
|
279
|
-
item += `, option: [${option.map(item => `'${item}'`).join(', ')}]`
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
item += ` }`
|
|
283
|
-
props.push(item)
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
sample.replaceMark('propsList', props, ',')
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (slotsInfo) {
|
|
290
|
-
const slots: string[] = []
|
|
291
|
-
|
|
292
|
-
slotsInfo
|
|
293
|
-
.sort((a, b) => a.name.localeCompare(b.name))
|
|
294
|
-
.forEach((slot) => {
|
|
295
|
-
const description = slot.description
|
|
296
|
-
const type = slot.type
|
|
297
|
-
.replace(/\(props: ([^)]+)\) => any/i, '$1')
|
|
298
|
-
.trim()
|
|
299
|
-
|
|
300
|
-
let item: string = ''
|
|
301
|
-
|
|
302
|
-
item += `{ name: '${slot.name}'`
|
|
303
|
-
|
|
304
|
-
if (description) {
|
|
305
|
-
item += `, description: \`${description}\``
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
type
|
|
310
|
-
&& type !== 'any'
|
|
311
|
-
) {
|
|
312
|
-
item += `, properties: [{ name: 'props', type: '${type}' }]`
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
item += ` }`
|
|
316
|
-
slots.push(item)
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
sample.replaceMark('slotsList', slots, ',')
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (eventsInfo) {
|
|
323
|
-
const events: string[] = []
|
|
324
|
-
|
|
325
|
-
eventsInfo
|
|
326
|
-
.sort((a, b) => a.name.localeCompare(b.name))
|
|
327
|
-
.forEach((event) => {
|
|
328
|
-
const description = event.description
|
|
329
|
-
const type = event.type
|
|
330
|
-
|
|
331
|
-
let item: string = ''
|
|
332
|
-
|
|
333
|
-
item += `{ name: '${event.name}'`
|
|
334
|
-
|
|
335
|
-
if (description) {
|
|
336
|
-
item += `, description: \`${description}\``
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
type
|
|
341
|
-
&& type !== '[]'
|
|
342
|
-
) {
|
|
343
|
-
item += `, properties: ${type}`
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
item += ` }`
|
|
347
|
-
events.push(item)
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
sample.replaceMark('eventsList', events, ',')
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
this.write(file, sample.get())
|
|
354
|
-
return this
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* This code generates the stories.ts.
|
|
359
|
-
*
|
|
360
|
-
* Генерация файла stories.ts.
|
|
361
|
-
*/
|
|
362
|
-
protected makeStories(): this {
|
|
363
|
-
const file = FILE_STORIES
|
|
364
|
-
const sample = this.readDefinable(file)
|
|
365
|
-
const description = this.getWikiDescription()
|
|
366
|
-
|
|
367
|
-
if (description) {
|
|
368
|
-
this.replaceMarkStoriesRender(sample, description)
|
|
369
|
-
.replaceMarkStoriesStories(sample, description)
|
|
370
|
-
.replaceMarkStoriesImport(sample, description)
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
this.write(sample.getNameFile(file), sample.get())
|
|
374
|
-
return this
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* This code generates the mdx.
|
|
379
|
-
*
|
|
380
|
-
* Генерация файла mdx.
|
|
381
|
-
*/
|
|
382
|
-
protected makeStoriesDocumentation(): this {
|
|
383
|
-
const file = FILE_STORIES_DOCUMENTATION
|
|
384
|
-
const sample = this.readDefinable(file)
|
|
385
|
-
const documentation = this.getWikiDescription()?.documentation
|
|
386
|
-
|
|
387
|
-
if (documentation) {
|
|
388
|
-
this
|
|
389
|
-
.replaceMarkDocumentation(sample, 'import', documentation.import)
|
|
390
|
-
.replaceMarkDocumentation(sample, 'body', documentation.body)
|
|
391
|
-
.replaceMarkDocumentation(sample, 'events', documentation.events, 'Events')
|
|
392
|
-
.replaceMarkDocumentation(sample, 'expose', documentation.expose, 'Expose')
|
|
393
|
-
.replaceMarkDocumentation(sample, 'slots', documentation.slots, 'Slots')
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
this.write(sample.getNameFile(file), sample.get())
|
|
397
|
-
return this
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Getting the contents of a file from a constructor.
|
|
402
|
-
*
|
|
403
|
-
* Получение содержимого файла из конструктора.
|
|
404
|
-
* @param file file name/ имя файла
|
|
405
|
-
*/
|
|
406
|
-
private getFileConstructor(file: string): string {
|
|
407
|
-
const path: string[] = ['..', '..', UI_DIR_CONSTRUCTOR, this.getStructure().getComponentNameFirst(), file]
|
|
408
|
-
const constructor = this.read(path)
|
|
409
|
-
|
|
410
|
-
return constructor ?? ''
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Getting the paths for the typescript compiler.
|
|
415
|
-
*
|
|
416
|
-
* Получение путей для компилятора typescript.
|
|
417
|
-
* @returns paths for the typescript compiler/ пути для компилятора typescript
|
|
418
|
-
*/
|
|
419
|
-
private getTypescriptPaths(): string[] | undefined {
|
|
420
|
-
const root = PropertiesFile.getRootProject()
|
|
421
|
-
const componentName = this.getStructure().getComponentNameFirst()
|
|
422
|
-
|
|
423
|
-
if (root) {
|
|
424
|
-
return [
|
|
425
|
-
root,
|
|
426
|
-
UI_PROJECT_CONSTRUCTOR_NAME,
|
|
427
|
-
UI_DIR_DIST,
|
|
428
|
-
UI_DIR_CONSTRUCTOR,
|
|
429
|
-
componentName
|
|
430
|
-
]
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return undefined
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Getting the path to the index file.
|
|
438
|
-
*
|
|
439
|
-
* Получение пути к файлу index.
|
|
440
|
-
*/
|
|
441
|
-
private getTypescriptPathsIndex(): string | undefined {
|
|
442
|
-
const paths = this.getTypescriptPaths()
|
|
443
|
-
|
|
444
|
-
if (paths) {
|
|
445
|
-
return PropertiesFile.joinPath([
|
|
446
|
-
...paths,
|
|
447
|
-
FILE_INDEX_DTS
|
|
448
|
-
])
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return undefined
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Getting the path to the type file.
|
|
456
|
-
*
|
|
457
|
-
* Получение пути к файлу type.
|
|
458
|
-
*/
|
|
459
|
-
private getTypescriptPathsType(): string | undefined {
|
|
460
|
-
const paths = this.getTypescriptPaths()
|
|
461
|
-
|
|
462
|
-
if (paths) {
|
|
463
|
-
return PropertiesFile.joinPath([
|
|
464
|
-
...paths,
|
|
465
|
-
'types.d.ts'
|
|
466
|
-
])
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return undefined
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Getting a list of all properties of a component.
|
|
474
|
-
*
|
|
475
|
-
* Получение списка всех свойств компонента.
|
|
476
|
-
*/
|
|
477
|
-
private getPropsList(): DesignTypescriptProp[] | undefined {
|
|
478
|
-
if (!this.propsType) {
|
|
479
|
-
const paths = this.getTypescriptPathsIndex()
|
|
480
|
-
const componentName = this.getStructure().getComponentNameFirst()
|
|
481
|
-
|
|
482
|
-
if (paths) {
|
|
483
|
-
const tsRead = new DesignTypescript(
|
|
484
|
-
PropertiesFile.joinPath([
|
|
485
|
-
PropertiesFile.getRoot(),
|
|
486
|
-
UI_DIR_IN,
|
|
487
|
-
UI_DIR_COMPONENTS,
|
|
488
|
-
PropertiesConfig.getProjectName(),
|
|
489
|
-
componentName,
|
|
490
|
-
FILE_PROPS
|
|
491
|
-
]),
|
|
492
|
-
{
|
|
493
|
-
paths: {
|
|
494
|
-
[`${UI_PROJECT_CONSTRUCTOR_FULL_NAME}/${componentName}`]: [paths]
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
)
|
|
498
|
-
|
|
499
|
-
this.propsType = tsRead.getType(`${componentName}Props`)?.props
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
return this.propsType
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Getting a list of all slots of a component.
|
|
508
|
-
*
|
|
509
|
-
* Получение списка всех слотов компонента.
|
|
510
|
-
*/
|
|
511
|
-
private getSlotsList(): DesignTypescriptProp[] | undefined {
|
|
512
|
-
if (!this.slotsType) {
|
|
513
|
-
const types = this.getTypesFromConstructor('Slots')
|
|
514
|
-
|
|
515
|
-
if (types) {
|
|
516
|
-
this.slotsType = types
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
return this.slotsType
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Getting a list of all events of a component.
|
|
525
|
-
*
|
|
526
|
-
* Получение списка всех событий компонента.
|
|
527
|
-
*/
|
|
528
|
-
private getEventsList(): DesignTypescriptProp[] | undefined {
|
|
529
|
-
if (!this.eventsType) {
|
|
530
|
-
const types = this.getTypesFromConstructor('Emits')
|
|
531
|
-
|
|
532
|
-
if (types) {
|
|
533
|
-
this.eventsType = forEach(
|
|
534
|
-
types,
|
|
535
|
-
(item) => {
|
|
536
|
-
return {
|
|
537
|
-
name: item.name,
|
|
538
|
-
type: String(item.type)
|
|
539
|
-
.replace(/([^:,[\] ]+): ([^:,[\]]+)/gi, `{ name: '$1', type: '$2' }`)
|
|
540
|
-
.replace(/,{/gi, ', {'),
|
|
541
|
-
description: item.description
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
)
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
return this.eventsType
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Returns the description of the component from the wiki
|
|
553
|
-
*
|
|
554
|
-
* Возвращает описание компонента из вики
|
|
555
|
-
*/
|
|
556
|
-
private getWikiDescription(): StorybookComponentsDescriptionItem | undefined {
|
|
557
|
-
const name = this.getStructure().getComponentNameFirst()
|
|
558
|
-
return wikiDescriptions.find(item => item.name === name)
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Returns the import of components for stories.
|
|
563
|
-
*
|
|
564
|
-
* Возвращает импорт компонентов для сториз.
|
|
565
|
-
* @param description description of the component/ описание компонента
|
|
566
|
-
*/
|
|
567
|
-
private getStoriesComponentsImport(description: StorybookComponentsDescriptionItem): string[] {
|
|
568
|
-
if (description.stories) {
|
|
569
|
-
const components: string[] = []
|
|
570
|
-
|
|
571
|
-
description.stories.forEach((story) => {
|
|
572
|
-
if (story.components) {
|
|
573
|
-
story.components.forEach((component) => {
|
|
574
|
-
components.push(component)
|
|
575
|
-
})
|
|
576
|
-
}
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
return components
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
return []
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Getting the types from the constructor.
|
|
587
|
-
*
|
|
588
|
-
* Получение типов из конструктора.
|
|
589
|
-
* @param name name of the type/ имя типа
|
|
590
|
-
*/
|
|
591
|
-
private getTypesFromConstructor(name: string): DesignTypescriptProp[] | undefined {
|
|
592
|
-
const paths = this.getTypescriptPathsType()
|
|
593
|
-
const componentName = this.getStructure().getComponentNameFirst()
|
|
594
|
-
|
|
595
|
-
if (paths) {
|
|
596
|
-
const tsRead = new DesignTypescript(paths)
|
|
597
|
-
return tsRead.getType(`${componentName}${name}`)?.props
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
return undefined
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Converts the code to the component name.
|
|
605
|
-
*
|
|
606
|
-
* Преобразует код в название компонента.
|
|
607
|
-
* @param code code to convert/ код для преобразования
|
|
608
|
-
*/
|
|
609
|
-
private toComponentName(code: string): string {
|
|
610
|
-
const design = this.getStructure().getDesignFirst()
|
|
611
|
-
const name = this.getStructure().getComponentName()
|
|
612
|
-
const fullName = this.getStructure().getFullComponentName()
|
|
613
|
-
|
|
614
|
-
return code
|
|
615
|
-
.replace(/DesignComponent/g, fullName).trim()
|
|
616
|
-
.replace(/design-component/g, `${toCamelCase(design)}-${toCamelCase(name)}`).trim()
|
|
617
|
-
.replace(/<(\/?)Design/g, `<$1${design}`)
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Replaces the render in the sample.
|
|
622
|
-
*
|
|
623
|
-
* Заменяет рендер в сэмпле.
|
|
624
|
-
* @param sample sample for replacement/ сэмпл для замены
|
|
625
|
-
* @param description description of the component/ описание компонента
|
|
626
|
-
*/
|
|
627
|
-
private replaceMarkStoriesRender(
|
|
628
|
-
sample: DesignReplace,
|
|
629
|
-
description: StorybookComponentsDescriptionItem
|
|
630
|
-
): this {
|
|
631
|
-
if (description.render) {
|
|
632
|
-
const name = this.getStructure().getFullComponentName()
|
|
633
|
-
|
|
634
|
-
sample.replaceMark(
|
|
635
|
-
'story-main',
|
|
636
|
-
[
|
|
637
|
-
'render: (args: any) => ({',
|
|
638
|
-
` components: { ${name} },`,
|
|
639
|
-
' setup: () => ({ args }),',
|
|
640
|
-
' template: `',
|
|
641
|
-
` ${this.toComponentName(description.render.trim())}`,
|
|
642
|
-
' `',
|
|
643
|
-
'})'
|
|
644
|
-
]
|
|
645
|
-
)
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
return this
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Replaces the import in the sample.
|
|
653
|
-
*
|
|
654
|
-
* Заменяет импорт в сэмпле.
|
|
655
|
-
* @param sample sample for replacement/ сэмпл для замены
|
|
656
|
-
* @param description description of the component/ описание компонента
|
|
657
|
-
*/
|
|
658
|
-
private replaceMarkStoriesImport(
|
|
659
|
-
sample: DesignReplace,
|
|
660
|
-
description: StorybookComponentsDescriptionItem
|
|
661
|
-
): this {
|
|
662
|
-
const design = this.getStructure().getDesignFirst()
|
|
663
|
-
const imports: string[] = []
|
|
664
|
-
|
|
665
|
-
this.getStoriesComponentsImport(description).forEach((component) => {
|
|
666
|
-
const name = `${design}${component}`
|
|
667
|
-
imports.push(`import ${name} from '../${component}/${name}.vue'`)
|
|
668
|
-
})
|
|
669
|
-
|
|
670
|
-
if (description.import) {
|
|
671
|
-
imports.push(...description.import)
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
sample.replaceMark('story-import', imports)
|
|
675
|
-
return this
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* Replaces the stories in the sample.
|
|
680
|
-
*
|
|
681
|
-
* Заменяет истории в сэмпле.
|
|
682
|
-
* @param sample sample for replacement/ сэмпл для замены
|
|
683
|
-
* @param description description of the component/ описание компонента
|
|
684
|
-
*/
|
|
685
|
-
private replaceMarkStoriesStories(
|
|
686
|
-
sample: DesignReplace,
|
|
687
|
-
description: StorybookComponentsDescriptionItem
|
|
688
|
-
): this {
|
|
689
|
-
if (description.stories) {
|
|
690
|
-
const wikiLanguage = PropertiesConfig.getWikiLanguage()
|
|
691
|
-
const design = this.getStructure().getDesignFirst()
|
|
692
|
-
const name = this.getStructure().getFullComponentName()
|
|
693
|
-
const stories: string[] = []
|
|
694
|
-
const propsType = this.getPropsList()
|
|
695
|
-
|
|
696
|
-
description.stories.forEach((story) => {
|
|
697
|
-
if (
|
|
698
|
-
propsType
|
|
699
|
-
&& story.propsName
|
|
700
|
-
&& !toArray(story.propsName as string).every(
|
|
701
|
-
name => propsType.some(prop => prop.name === name)
|
|
702
|
-
)
|
|
703
|
-
) {
|
|
704
|
-
return
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
const components = story.components && forEach(story.components, component => `${design}${component}`)
|
|
708
|
-
const template = this.toComponentName(story.template)
|
|
709
|
-
|
|
710
|
-
stories.push(`export const ${story.id}: Story = {`)
|
|
711
|
-
|
|
712
|
-
if (isObjectNotArray(story.name) && story.name?.[wikiLanguage]) {
|
|
713
|
-
stories.push(` name: '${story.name?.[wikiLanguage]}',`)
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
stories.push(` render: () => ({`)
|
|
717
|
-
stories.push(` components: { ${name}${components ? `, ${components.join(', ')}` : ''} },`)
|
|
718
|
-
|
|
719
|
-
if (story.setup) {
|
|
720
|
-
stories.push(` setup() {`)
|
|
721
|
-
stories.push(` ${story.setup.trim()}`)
|
|
722
|
-
stories.push(` },`)
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
stories.push(` template: \``)
|
|
726
|
-
stories.push(` ${template}`)
|
|
727
|
-
stories.push(` \``)
|
|
728
|
-
stories.push(` })`)
|
|
729
|
-
stories.push(`}`)
|
|
730
|
-
})
|
|
731
|
-
|
|
732
|
-
sample.replaceMark('story-items', stories)
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
return this
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* Replaces the documentation in the sample.
|
|
740
|
-
*
|
|
741
|
-
* Заменяет документацию в сэмпле.
|
|
742
|
-
* @param sample sample for replacement/ сэмпл для замены
|
|
743
|
-
* @param type type of the documentation to replace/ тип документации для замены
|
|
744
|
-
* @param documentation documentation text/ текст документации
|
|
745
|
-
* @param name name of the documentation section/ название секции документации
|
|
746
|
-
*/
|
|
747
|
-
private replaceMarkDocumentation(
|
|
748
|
-
sample: DesignReplace,
|
|
749
|
-
type: string,
|
|
750
|
-
documentation?: string,
|
|
751
|
-
name?: string
|
|
752
|
-
): this {
|
|
753
|
-
if (documentation) {
|
|
754
|
-
const component = this.getStructure().getComponentNameFirst()
|
|
755
|
-
const componentFull = this.getStructure().getFullComponentName()
|
|
756
|
-
const data = []
|
|
757
|
-
const propsType = this.getPropsList()
|
|
758
|
-
|
|
759
|
-
if (name) {
|
|
760
|
-
data.push(`## ${name}`)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
data.push(
|
|
764
|
-
documentation
|
|
765
|
-
.replace(/<template prop="([^"]+)">([\S\s]*?)<\/template>/ig, (
|
|
766
|
-
_,
|
|
767
|
-
name: string,
|
|
768
|
-
code: string
|
|
769
|
-
) => {
|
|
770
|
-
if (propsType?.some(prop => prop.name === name)) {
|
|
771
|
-
return code.trim()
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
return ''
|
|
775
|
-
})
|
|
776
|
-
.replace(new RegExp('DesignComponent', 'g'), componentFull)
|
|
777
|
-
.replace(new RegExp('Component', 'g'), component)
|
|
778
|
-
)
|
|
779
|
-
sample.replaceMark(`documentation-${type}`, data)
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
return this
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Updates the package.json file.
|
|
787
|
-
*
|
|
788
|
-
* Обновляет файл package.json.
|
|
789
|
-
*/
|
|
790
|
-
protected makeFilePackage(): this {
|
|
791
|
-
const name = `./${this.getFullName()}`
|
|
792
|
-
|
|
793
|
-
this.updatePackage(
|
|
794
|
-
`exports|${name}`,
|
|
795
|
-
{
|
|
796
|
-
types: `./dist/library/${this.getFullName()}.d.ts`,
|
|
797
|
-
default: `./dist/${this.getFullName()}.js`
|
|
798
|
-
}
|
|
799
|
-
)
|
|
800
|
-
|
|
801
|
-
return this
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Generates a library file.
|
|
806
|
-
*
|
|
807
|
-
* Генерирует файл библиотеки.
|
|
808
|
-
*/
|
|
809
|
-
protected makeLibrary(): this {
|
|
810
|
-
const dir: string = `../${UI_DIR_COMPONENTS}/${this.getProjectName()}/${this.getName()}/`
|
|
811
|
-
const name = this.getFullName()
|
|
812
|
-
|
|
813
|
-
PropertiesFile.writeByPath(
|
|
814
|
-
[...UI_DIRS_LIBRARY, `${name}.ts`],
|
|
815
|
-
`// This file is generated by a script, do not edit.
|
|
816
|
-
// Этот файл генерируется скриптом, не редактировать.
|
|
817
|
-
|
|
818
|
-
export * from '${dir}index.js'
|
|
819
|
-
`
|
|
820
|
-
)
|
|
821
|
-
|
|
822
|
-
return this
|
|
823
|
-
}
|
|
824
|
-
}
|