@dxtmisha/scripts 0.11.7 → 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 +67 -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 -133
- 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 -119
- 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,54 +0,0 @@
|
|
|
1
|
-
import * as functional from '@dxtmisha/functional'
|
|
2
|
-
|
|
3
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
4
|
-
|
|
5
|
-
import { UI_DIRS_LIBRARY } from '../../config'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A class for building the functional library exports.
|
|
9
|
-
*
|
|
10
|
-
* Класс для сборки экспортов функциональной библиотеки.
|
|
11
|
-
*/
|
|
12
|
-
export class BuildFunctional {
|
|
13
|
-
constructor() {
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generates the functional.ts file by re-exporting all members from @dxtmisha/functional.
|
|
18
|
-
*
|
|
19
|
-
* Генерирует файл functional.ts, повторно экспортируя все элементы из @dxtmisha/functional.
|
|
20
|
-
*/
|
|
21
|
-
make(): void {
|
|
22
|
-
console.log('Build functional...')
|
|
23
|
-
|
|
24
|
-
const list = this.getList()
|
|
25
|
-
const code: string[] = [
|
|
26
|
-
'export type * from \'@dxtmisha/functional\'',
|
|
27
|
-
''
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
list.sort()
|
|
31
|
-
list.forEach((item) => {
|
|
32
|
-
console.log(`-- ${item}`)
|
|
33
|
-
|
|
34
|
-
code.push(`export { ${item} } from '@dxtmisha/functional'`)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
code.push('')
|
|
38
|
-
PropertiesFile.writeByPath(
|
|
39
|
-
[...UI_DIRS_LIBRARY, 'functional.ts'],
|
|
40
|
-
code.join('\n')
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
console.log('...end')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Returns a list of all exported members from the @dxtmisha/functional package.
|
|
48
|
-
*
|
|
49
|
-
* Возвращает список всех экспортируемых элементов из пакета @dxtmisha/functional.
|
|
50
|
-
*/
|
|
51
|
-
getList(): string[] {
|
|
52
|
-
return Object.keys(functional)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { run } from '../../functions/run'
|
|
2
|
-
|
|
3
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
4
|
-
import { PackageFile } from '../Package/PackageFile'
|
|
5
|
-
|
|
6
|
-
import { UI_DIR_PACKAGES } from '../../config'
|
|
7
|
-
|
|
8
|
-
const UI_BUILD_LOG_FILE = ['.', 'logs', 'ui-build.log.json']
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Class for building all packages in the project.
|
|
12
|
-
*
|
|
13
|
-
* Класс для сборки всех пакетов в проекте.
|
|
14
|
-
*/
|
|
15
|
-
export class BuildPackages {
|
|
16
|
-
protected readonly log: Record<string, string>
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
* @param path packages directory path / путь к директории пакетов
|
|
21
|
-
*/
|
|
22
|
-
constructor(
|
|
23
|
-
protected readonly path: string = UI_DIR_PACKAGES
|
|
24
|
-
) {
|
|
25
|
-
this.log = PropertiesFile.readFile(UI_BUILD_LOG_FILE) ?? {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Scans the packages directory and builds each package that contains a package.json.
|
|
30
|
-
*
|
|
31
|
-
* Сканирует директорию пакетов и собирает каждый пакет, содержащий package.json.
|
|
32
|
-
*/
|
|
33
|
-
async make(): Promise<void> {
|
|
34
|
-
const list = this.getList()
|
|
35
|
-
let changed = 0
|
|
36
|
-
|
|
37
|
-
console.info(`Build packages(${list.length})...`)
|
|
38
|
-
|
|
39
|
-
for (const packageFile of list) {
|
|
40
|
-
if (
|
|
41
|
-
this.isUpdate(packageFile)
|
|
42
|
-
&& await this.build(packageFile)
|
|
43
|
-
) {
|
|
44
|
-
this.updateLog(packageFile)
|
|
45
|
-
changed++
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (changed > 0) {
|
|
50
|
-
this.saveLog()
|
|
51
|
-
console.info(`Build packages changed: ${changed}`)
|
|
52
|
-
} else {
|
|
53
|
-
console.info('Build packages - no changes')
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected async build(packageFile: PackageFile): Promise<boolean> {
|
|
58
|
-
const code = packageFile.getCodeBuildOrRecovery()
|
|
59
|
-
|
|
60
|
-
if (code) {
|
|
61
|
-
return await run(packageFile, `npm run ${code}`)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return false
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the package needs to be updated.
|
|
69
|
-
*
|
|
70
|
-
* Проверяет, нужно ли обновлять пакет.
|
|
71
|
-
* @param packageFile package file object / объект файла пакета
|
|
72
|
-
*/
|
|
73
|
-
protected isUpdate(packageFile: PackageFile): boolean {
|
|
74
|
-
return !packageFile.isVersionConsistency(
|
|
75
|
-
this.getVersionLog(packageFile.getName())
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Scans the packages directory and returns a list of packages sorted by the ui-priority property in package.json.
|
|
81
|
-
* If a package does not have a priority, it defaults to 500.
|
|
82
|
-
*
|
|
83
|
-
* Сканирует директорию пакетов и возвращает список пакетов, отсортированный по свойству ui-priority в package.json.
|
|
84
|
-
* Если у пакета нет приоритета, по умолчанию устанавливается значение 500.
|
|
85
|
-
* @returns sorted list of package files / отсортированный список файлов пакетов
|
|
86
|
-
*/
|
|
87
|
-
private getList(): PackageFile[] {
|
|
88
|
-
const list = PropertiesFile.readDir(this.path)
|
|
89
|
-
const packages: PackageFile[] = []
|
|
90
|
-
|
|
91
|
-
for (const folder of list) {
|
|
92
|
-
const packageFile = new PackageFile([this.path, folder])
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
packageFile.is()
|
|
96
|
-
&& !packageFile.isTest()
|
|
97
|
-
) {
|
|
98
|
-
packages.push(packageFile)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return packages.sort((a, b) => {
|
|
103
|
-
const priorityA = a.get()?.['ui-priority'] ?? 500
|
|
104
|
-
const priorityB = b.get()?.['ui-priority'] ?? 500
|
|
105
|
-
return priorityA - priorityB
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Returns the cached version of the package from the build log.
|
|
111
|
-
*
|
|
112
|
-
* Возвращает кэшированную версию пакета из лога сборки.
|
|
113
|
-
* @param name package name / имя пакета
|
|
114
|
-
*/
|
|
115
|
-
protected getVersionLog(name: string): string {
|
|
116
|
-
return this.log?.[name] ?? '0.0.0'
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Updates the build log with the current package version in memory.
|
|
121
|
-
*
|
|
122
|
-
* Обновляет лог сборки текущей версией пакета в памяти.
|
|
123
|
-
* @param packageFile package file object / объект файла пакета
|
|
124
|
-
*/
|
|
125
|
-
protected updateLog(packageFile: PackageFile): void {
|
|
126
|
-
this.log[packageFile.getName()] = packageFile.getVersion()
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Saves the build log to a file.
|
|
131
|
-
*
|
|
132
|
-
* Сохраняет лог сборки в файл.
|
|
133
|
-
*/
|
|
134
|
-
protected saveLog(): void {
|
|
135
|
-
PropertiesFile.writeByPath(UI_BUILD_LOG_FILE, this.log)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
2
|
-
import { PackageFile } from '../Package/PackageFile'
|
|
3
|
-
import { run } from '../../functions/run'
|
|
4
|
-
import { UI_DIR_PACKAGES } from '../../config'
|
|
5
|
-
|
|
6
|
-
const UI_PUBLISH_LOG_FILE = ['.', 'logs', 'ui-publish.log.json']
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Class for publishing all packages in the project.
|
|
10
|
-
*
|
|
11
|
-
* Класс для публикации всех пакетов в проекте.
|
|
12
|
-
*/
|
|
13
|
-
export class BuildPublishPackages {
|
|
14
|
-
protected readonly log: Record<string, string>
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Constructor
|
|
18
|
-
* @param path packages directory path / путь к директории пакетов
|
|
19
|
-
*/
|
|
20
|
-
constructor(
|
|
21
|
-
protected readonly path: string = UI_DIR_PACKAGES
|
|
22
|
-
) {
|
|
23
|
-
this.log = PropertiesFile.readFile(UI_PUBLISH_LOG_FILE) ?? {}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Scans the packages directory and publishes each package that has a new version.
|
|
28
|
-
*
|
|
29
|
-
* Сканирует директорию пакетов и публикует каждый пакет с новой версией.
|
|
30
|
-
*/
|
|
31
|
-
async make(): Promise<void> {
|
|
32
|
-
const list = PropertiesFile.readDir(this.path)
|
|
33
|
-
let changed = 0
|
|
34
|
-
|
|
35
|
-
console.info(`Publish packages(${list.length})...`)
|
|
36
|
-
|
|
37
|
-
for (const folder of list) {
|
|
38
|
-
const packageFile = new PackageFile([this.path, folder])
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
packageFile.is()
|
|
42
|
-
&& !packageFile.isNoPublish()
|
|
43
|
-
) {
|
|
44
|
-
if (
|
|
45
|
-
this.log[packageFile.getName()] === undefined
|
|
46
|
-
|| (
|
|
47
|
-
this.isUpdate(packageFile)
|
|
48
|
-
&& await run(packageFile, packageFile.getCodePublish(), true, true)
|
|
49
|
-
)
|
|
50
|
-
) {
|
|
51
|
-
this.updateLog(packageFile)
|
|
52
|
-
changed++
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (changed > 0) {
|
|
58
|
-
this.saveLog()
|
|
59
|
-
console.info(`Publish packages changed: ${changed}`)
|
|
60
|
-
} else {
|
|
61
|
-
console.info('Publish packages - no changes')
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Checks if the package needs to be published.
|
|
67
|
-
*
|
|
68
|
-
* Проверяет, нужно ли публиковать пакет.
|
|
69
|
-
* @param packageFile package file object / объект файла пакета
|
|
70
|
-
*/
|
|
71
|
-
protected isUpdate(packageFile: PackageFile): boolean {
|
|
72
|
-
return !packageFile.isVersionConsistency(
|
|
73
|
-
this.getVersionLog(packageFile.getName())
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns the cached version of the package from the publish log.
|
|
79
|
-
*
|
|
80
|
-
* Возвращает кэшированную версию пакета из лога публикации.
|
|
81
|
-
* @param name package name / имя пакета
|
|
82
|
-
*/
|
|
83
|
-
protected getVersionLog(name: string): string {
|
|
84
|
-
return this.log?.[name] ?? '0.0.0'
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Updates the publish log with the current package version in memory.
|
|
89
|
-
*
|
|
90
|
-
* Обновляет лог публикации текущей версией пакета в памяти.
|
|
91
|
-
* @param packageFile package file object / объект файла пакета
|
|
92
|
-
*/
|
|
93
|
-
protected updateLog(packageFile: PackageFile): void {
|
|
94
|
-
this.log[packageFile.getName()] = packageFile.getVersion()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Saves the publish log to a file.
|
|
99
|
-
*
|
|
100
|
-
* Сохраняет лог публикации в файл.
|
|
101
|
-
*/
|
|
102
|
-
protected saveLog(): void {
|
|
103
|
-
PropertiesFile.writeByPath(UI_PUBLISH_LOG_FILE, this.log)
|
|
104
|
-
}
|
|
105
|
-
}
|
package/src/classes/BuildItem.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { dirname } from 'node:path'
|
|
2
|
-
import { fileURLToPath } from 'node:url'
|
|
3
|
-
import { promisify } from 'node:util'
|
|
4
|
-
import { exec } from 'node:child_process'
|
|
5
|
-
import { hasNativeDirname } from '../functions/hasNativeDirname'
|
|
6
|
-
|
|
7
|
-
import { PropertiesFile } from './Properties/PropertiesFile'
|
|
8
|
-
import { ComponentWikiFile } from './Component/ComponentWikiFile'
|
|
9
|
-
|
|
10
|
-
import { UI_DIR_DIST_TEMPORARY, UI_FILE_NAME_VITE, UI_FILE_NAME_VITE_WORKERS } from '../config'
|
|
11
|
-
|
|
12
|
-
const dirnamePath = hasNativeDirname()
|
|
13
|
-
? __dirname
|
|
14
|
-
: dirname(fileURLToPath(import.meta.url))
|
|
15
|
-
|
|
16
|
-
/** Template vite config file path / Путь к файлу шаблона vite-конфига */
|
|
17
|
-
const FILE_VITE_SAMPLE = [dirnamePath, '..', 'media', 'templates', 'viteComponentTemplateConfig.ts']
|
|
18
|
-
|
|
19
|
-
/** Async exec wrapper / Обёртка для асинхронного exec */
|
|
20
|
-
const execAsync = promisify(exec)
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Builds a component using a temporary Vite config.
|
|
24
|
-
*
|
|
25
|
-
* Билдит компонент с использованием временного Vite-конфига.
|
|
26
|
-
*/
|
|
27
|
-
export class BuildItem {
|
|
28
|
-
/** Template vite config file / Файл шаблона vite-конфига */
|
|
29
|
-
protected readonly viteSample: ComponentWikiFile
|
|
30
|
-
|
|
31
|
-
/** Aggregated built code file / Файл агрегированного собранного кода */
|
|
32
|
-
protected readonly codeFile: ComponentWikiFile
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Constructor
|
|
36
|
-
* @param path component path / путь к компоненту
|
|
37
|
-
*/
|
|
38
|
-
constructor(
|
|
39
|
-
protected readonly path: string
|
|
40
|
-
) {
|
|
41
|
-
this.viteSample = new ComponentWikiFile(FILE_VITE_SAMPLE)
|
|
42
|
-
|
|
43
|
-
this.codeFile = new ComponentWikiFile([
|
|
44
|
-
...this.getPathTemporaryDist(),
|
|
45
|
-
'code.txt'
|
|
46
|
-
])
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Returns distribution temp directory path segments.
|
|
51
|
-
*
|
|
52
|
-
* Возвращает сегменты пути дистрибутива (temp).
|
|
53
|
-
*/
|
|
54
|
-
getPathTemporaryDist(): string[] {
|
|
55
|
-
return [
|
|
56
|
-
UI_DIR_DIST_TEMPORARY
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns aggregated built code content.
|
|
62
|
-
*
|
|
63
|
-
* Возвращает содержимое агрегированного собранного кода.
|
|
64
|
-
*/
|
|
65
|
-
getCode(): string {
|
|
66
|
-
return this.codeFile.read()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Removes temporary distribution directory.
|
|
71
|
-
*
|
|
72
|
-
* Удаляет временную директорию дистрибутива.
|
|
73
|
-
*/
|
|
74
|
-
removeDir(): void {
|
|
75
|
-
PropertiesFile.removeDir(this.getPathTemporaryDist())
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Prepares temporary vite config, triggers build, then restores original.
|
|
80
|
-
*
|
|
81
|
-
* Готовит временный vite-конфиг, запускает билд, затем восстанавливает оригинал.
|
|
82
|
-
*/
|
|
83
|
-
async make(): Promise<boolean> {
|
|
84
|
-
this.saveViteConfig()
|
|
85
|
-
|
|
86
|
-
const vite = this.viteSample
|
|
87
|
-
.read()
|
|
88
|
-
.replace('[path]', this.path)
|
|
89
|
-
|
|
90
|
-
PropertiesFile.writeByPath(UI_FILE_NAME_VITE, vite)
|
|
91
|
-
|
|
92
|
-
const status = await this.run()
|
|
93
|
-
|
|
94
|
-
this.resetViteConfig()
|
|
95
|
-
this.readAndWriteALlFiles()
|
|
96
|
-
|
|
97
|
-
if (!status) {
|
|
98
|
-
process.exit(601)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return status
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Saves existing vite config aside (rename) before custom build.
|
|
106
|
-
*
|
|
107
|
-
* Сохраняет существующий vite-конфиг (переименовывает) перед кастомным билдом.
|
|
108
|
-
*/
|
|
109
|
-
protected saveViteConfig() {
|
|
110
|
-
if (!PropertiesFile.is(UI_FILE_NAME_VITE_WORKERS)) {
|
|
111
|
-
PropertiesFile.rename(
|
|
112
|
-
UI_FILE_NAME_VITE,
|
|
113
|
-
UI_FILE_NAME_VITE_WORKERS
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Restores original vite config after build.
|
|
120
|
-
*
|
|
121
|
-
* Восстанавливает оригинальный vite-конфиг после билда.
|
|
122
|
-
*/
|
|
123
|
-
protected resetViteConfig() {
|
|
124
|
-
if (PropertiesFile.is(UI_FILE_NAME_VITE_WORKERS)) {
|
|
125
|
-
PropertiesFile.removeFile(UI_FILE_NAME_VITE)
|
|
126
|
-
PropertiesFile.rename(
|
|
127
|
-
UI_FILE_NAME_VITE_WORKERS,
|
|
128
|
-
UI_FILE_NAME_VITE
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Reads built file content and wraps with header comment (file name).
|
|
135
|
-
*
|
|
136
|
-
* Читает содержимое собранного файла и оборачивает заголовком с именем файла.
|
|
137
|
-
* @param path relative built file path / относительный путь собранного файла
|
|
138
|
-
*/
|
|
139
|
-
protected readFile(path: string): string {
|
|
140
|
-
const pathFull = PropertiesFile.joinPath([...this.getPathTemporaryDist(), path])
|
|
141
|
-
const content = PropertiesFile.readFileOnly(pathFull)
|
|
142
|
-
|
|
143
|
-
return `
|
|
144
|
-
// File: ${path}
|
|
145
|
-
${content}
|
|
146
|
-
`.trim()
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Aggregates all built files into a single code snapshot file.
|
|
151
|
-
*
|
|
152
|
-
* Агрегирует все собранные файлы в единый снимок кода.
|
|
153
|
-
*/
|
|
154
|
-
protected readAndWriteALlFiles(): void {
|
|
155
|
-
const list = PropertiesFile.readDirRecursive(this.getPathTemporaryDist())
|
|
156
|
-
const content: string[] = []
|
|
157
|
-
|
|
158
|
-
list.forEach((file) => {
|
|
159
|
-
content.push(this.readFile(file))
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
this.codeFile.write(content.join('\r\n'))
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Runs build command (npm run build) capturing stdout/stderr.
|
|
167
|
-
*
|
|
168
|
-
* Запускает команду билда (npm run build), перехватывая stdout/stderr.
|
|
169
|
-
*/
|
|
170
|
-
protected async run(): Promise<boolean> {
|
|
171
|
-
try {
|
|
172
|
-
const { stdout, stderr } = await execAsync('npm run build')
|
|
173
|
-
|
|
174
|
-
console.info(stdout)
|
|
175
|
-
|
|
176
|
-
if (stderr) {
|
|
177
|
-
console.error('STD error', stderr)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return true
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error('Error', error)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return false
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { getComponentPaths } from '../../functions/getComponentPaths'
|
|
4
|
-
|
|
5
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
6
|
-
import { ComponentItem } from './ComponentItem'
|
|
7
|
-
|
|
8
|
-
import { UI_DIRS_COMPONENTS } from '../../config'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Class for scaffolding components in empty directories.
|
|
12
|
-
*
|
|
13
|
-
* Класс для создания заготовок компонентов в пустых директориях.
|
|
14
|
-
*/
|
|
15
|
-
export class ComponentCreator {
|
|
16
|
-
/**
|
|
17
|
-
* Constructor
|
|
18
|
-
*/
|
|
19
|
-
constructor() {
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Scans directories and scaffolds component templates.
|
|
24
|
-
*
|
|
25
|
-
* Сканирует директории и создает шаблоны компонентов.
|
|
26
|
-
*/
|
|
27
|
-
make(): void {
|
|
28
|
-
this
|
|
29
|
-
.getDirs()
|
|
30
|
-
.forEach(path => new ComponentItem(path).make())
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Collects only empty component directories.
|
|
35
|
-
*
|
|
36
|
-
* Собирает только пустые директории компонентов.
|
|
37
|
-
* @protected
|
|
38
|
-
*/
|
|
39
|
-
protected getDirs(): string[] {
|
|
40
|
-
return PropertiesFile.readDirOnlyRecursive(UI_DIRS_COMPONENTS)
|
|
41
|
-
.filter(
|
|
42
|
-
path => PropertiesFile.readDir(getComponentPaths(path)).length === 0
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { dirname } from 'node:path'
|
|
4
|
-
import { fileURLToPath } from 'node:url'
|
|
5
|
-
import { toKebabCase } from '@dxtmisha/functional-basic'
|
|
6
|
-
import { getComponentPaths } from '../../functions/getComponentPaths'
|
|
7
|
-
import { hasNativeDirname } from '../../functions/hasNativeDirname'
|
|
8
|
-
|
|
9
|
-
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
10
|
-
|
|
11
|
-
import { UI_FILE_PACKAGE } from '../../config'
|
|
12
|
-
|
|
13
|
-
const dirnamePath = hasNativeDirname()
|
|
14
|
-
? __dirname
|
|
15
|
-
: dirname(fileURLToPath(import.meta.url))
|
|
16
|
-
|
|
17
|
-
const DIR_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'componentDoc']
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Class for creating component files from templates.
|
|
21
|
-
*
|
|
22
|
-
* Класс для создания файлов компонента из шаблонов.
|
|
23
|
-
*/
|
|
24
|
-
export class ComponentItem {
|
|
25
|
-
/**
|
|
26
|
-
* Constructor
|
|
27
|
-
* @param path component directory path/ путь к директории компонента
|
|
28
|
-
*/
|
|
29
|
-
constructor(
|
|
30
|
-
protected readonly path: string
|
|
31
|
-
) {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Generates component files from template.
|
|
36
|
-
*
|
|
37
|
-
* Генерирует файлы компонента из шаблона.
|
|
38
|
-
*/
|
|
39
|
-
make(): void {
|
|
40
|
-
console.info('Component create:', this.getName())
|
|
41
|
-
console.info('path:', this.path)
|
|
42
|
-
|
|
43
|
-
this
|
|
44
|
-
.getFilesSample()
|
|
45
|
-
.forEach((path) => {
|
|
46
|
-
this.writeFile(
|
|
47
|
-
path,
|
|
48
|
-
this.replacement(this.readFile(path))
|
|
49
|
-
)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
console.info('end')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Gets component name from directory path.
|
|
57
|
-
*
|
|
58
|
-
* Получает имя компонента из пути директории.
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
protected getName(): string {
|
|
62
|
-
const parts = PropertiesFile.splitForDir(this.path)
|
|
63
|
-
return String(parts[parts.length - 1])
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Reads project name from package.json.
|
|
68
|
-
*
|
|
69
|
-
* Читает имя проекта из package.json.
|
|
70
|
-
* @protected
|
|
71
|
-
*/
|
|
72
|
-
protected getProjectName(): string {
|
|
73
|
-
return this.readPackage()?.name ?? 'Project'
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Builds destination file path for output.
|
|
78
|
-
*
|
|
79
|
-
* Строит путь назначения для выходного файла.
|
|
80
|
-
* @param path filename/ имя файла
|
|
81
|
-
* @protected
|
|
82
|
-
*/
|
|
83
|
-
protected getFilePath(path: string): string[] {
|
|
84
|
-
return [
|
|
85
|
-
...getComponentPaths(this.path),
|
|
86
|
-
this.replacement(path)
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Builds template file path for reading.
|
|
92
|
-
*
|
|
93
|
-
* Строит путь к файлу шаблона для чтения.
|
|
94
|
-
* @param path filename/ имя файла
|
|
95
|
-
* @protected
|
|
96
|
-
*/
|
|
97
|
-
protected getSamplePath(path: string): string[] {
|
|
98
|
-
return [...DIR_SAMPLE, path]
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Lists all template files recursively.
|
|
103
|
-
*
|
|
104
|
-
* Получает список всех файлов шаблонов рекурсивно.
|
|
105
|
-
* @protected
|
|
106
|
-
*/
|
|
107
|
-
protected getFilesSample(): string[] {
|
|
108
|
-
return PropertiesFile.readDirRecursive(DIR_SAMPLE)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Reads template file content as string.
|
|
113
|
-
*
|
|
114
|
-
* Читает содержимое файла шаблона как строку.
|
|
115
|
-
* @param path filename/ имя файла
|
|
116
|
-
* @protected
|
|
117
|
-
*/
|
|
118
|
-
protected readFile(path: string): string {
|
|
119
|
-
return String(PropertiesFile.readFile(this.getSamplePath(path)))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Reads package.json data or returns empty object.
|
|
124
|
-
*
|
|
125
|
-
* Читает данные package.json или возвращает пустой объект.
|
|
126
|
-
* @protected
|
|
127
|
-
*/
|
|
128
|
-
protected readPackage(): Record<string, any> {
|
|
129
|
-
return PropertiesFile.readFile(UI_FILE_PACKAGE) ?? {}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Writes generated file to destination.
|
|
134
|
-
*
|
|
135
|
-
* Записывает сгенерированный файл в место назначения.
|
|
136
|
-
* @param path filename/ имя файла
|
|
137
|
-
* @param content file content/ содержимое файла
|
|
138
|
-
* @protected
|
|
139
|
-
*/
|
|
140
|
-
protected writeFile(path: string, content: string): void {
|
|
141
|
-
const paths = this.getFilePath(path)
|
|
142
|
-
|
|
143
|
-
PropertiesFile.writeByPath(paths, content)
|
|
144
|
-
PropertiesFile.chmod(paths)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Replaces template placeholders with actual values.
|
|
149
|
-
*
|
|
150
|
-
* Заменяет плейсхолдеры шаблона реальными значениями.
|
|
151
|
-
* @param contentOrPath content or path/ содержимое или путь
|
|
152
|
-
* @protected
|
|
153
|
-
*/
|
|
154
|
-
protected replacement(contentOrPath: string): string {
|
|
155
|
-
return contentOrPath
|
|
156
|
-
.replace(/ComponentDoc/g, this.getName())
|
|
157
|
-
.replace(/component-doc/g, toKebabCase(this.getName()))
|
|
158
|
-
.replace(/\[project]/g, this.getProjectName())
|
|
159
|
-
.replace(/\[path]/g, PropertiesFile.splitForDir(this.path).join('/'))
|
|
160
|
-
}
|
|
161
|
-
}
|