@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,522 +0,0 @@
|
|
|
1
|
-
import requireFs from 'node:fs'
|
|
2
|
-
import requirePath from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { Datetime, forEach, toArray, toKebabCase, transformation } from '@dxtmisha/functional-basic'
|
|
5
|
-
import { hasNativeDirname } from '../../functions/hasNativeDirname'
|
|
6
|
-
|
|
7
|
-
import { UI_FILE_INDEX, UI_MODULES, UI_PROJECT_NAME } from '../../config'
|
|
8
|
-
|
|
9
|
-
export type PropertiesFilePath = string | string[]
|
|
10
|
-
export type PropertiesFileValue<T = any> = string | Record<string, T> | Buffer
|
|
11
|
-
|
|
12
|
-
const dirnamePath = hasNativeDirname() ? __dirname : requirePath.dirname(fileURLToPath(import.meta.url))
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Universal static utility for filesystem orchestration.
|
|
16
|
-
* This class provides a standardized interface for all IO operations within the design system, including path normalization, recursive directory traversal, synchronized file reading/writing, and metadata retrieval. It abstracts platform-specific path differences and ensures consistent data handling across the toolchain.
|
|
17
|
-
*
|
|
18
|
-
* Универсальная статическая утилита для оркестрации файловой системы.
|
|
19
|
-
* Этот класс предоставляет стандартизированный интерфейс для всех операций ввода-вывода в рамках дизайн-системы, включая нормализацию путей, рекурсивный обход директорий, синхронное чтение/запись файлов и получение метаданных. Он абстрагирует различия путей в разных ОС и обеспечивает согласованную обработку данных во всей цепочке инструментов.
|
|
20
|
-
*/
|
|
21
|
-
export class PropertiesFile {
|
|
22
|
-
protected static root: string
|
|
23
|
-
protected static module: boolean
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously checks for the existence of a file or directory at the specified path.
|
|
27
|
-
*
|
|
28
|
-
* Синхронно проверяет существование файла или директории по указанному пути.
|
|
29
|
-
* @param path target filesystem path to verify / целевой путь в файловой системе для проверки
|
|
30
|
-
*/
|
|
31
|
-
static is(path: PropertiesFilePath): boolean {
|
|
32
|
-
return requireFs.existsSync(this.joinPath(path))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Determines if the specified path points to a directory.
|
|
37
|
-
*
|
|
38
|
-
* Определяет, указывает ли указанный путь на директорию.
|
|
39
|
-
* @param path path to the filesystem element / путь к элементу файловой системы
|
|
40
|
-
*/
|
|
41
|
-
static isDir(path: PropertiesFilePath): boolean {
|
|
42
|
-
if (this.is(path)) {
|
|
43
|
-
return requireFs.statSync(this.joinPath(path))?.isDirectory() ?? false
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return !this.joinPath(path).match(/\.\w+$/)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Determines whether the package is connected as a module.
|
|
51
|
-
*
|
|
52
|
-
* Определяет, является ли пакет подключенным как модуль.
|
|
53
|
-
*/
|
|
54
|
-
static isModule(): boolean {
|
|
55
|
-
return this.module
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Joins multiple path segments into a single normalized path string using the OS separator.
|
|
60
|
-
*
|
|
61
|
-
* Объединяет несколько сегментов пути в одну нормализованную строку пути, используя разделитель ОС.
|
|
62
|
-
* @param path array or string of path segments / массив или строка сегментов пути
|
|
63
|
-
*/
|
|
64
|
-
static joinPath(path: PropertiesFilePath): string {
|
|
65
|
-
const pathArray = forEach(
|
|
66
|
-
toArray(path),
|
|
67
|
-
item => this.toSep(item)
|
|
68
|
-
) as string[]
|
|
69
|
-
|
|
70
|
-
return requirePath.join(...pathArray)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Getting the path to the file by its name and the path to the directory.
|
|
75
|
-
*
|
|
76
|
-
* Получение пути к файлу по его названию и пути к директории.
|
|
77
|
-
* @param path path to the file/ путь к файлу
|
|
78
|
-
* @param name file name/ название файла
|
|
79
|
-
* @param extension file extension by default is json/ расширение файла по умолчанию - json
|
|
80
|
-
*/
|
|
81
|
-
static joinPathByName(
|
|
82
|
-
path: PropertiesFilePath,
|
|
83
|
-
name: string,
|
|
84
|
-
extension = 'json'
|
|
85
|
-
): string {
|
|
86
|
-
return this.joinPath([...toArray(path), this.getFileName(name, extension)])
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Returns the root path.
|
|
91
|
-
*
|
|
92
|
-
* Возвращает корневой путь.
|
|
93
|
-
*/
|
|
94
|
-
static getRoot(): string {
|
|
95
|
-
return this.root
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Returns the root project path
|
|
100
|
-
*
|
|
101
|
-
* Возвращает корневой путь проекта
|
|
102
|
-
* @param rootProject root project path/ путь к корневому проекту
|
|
103
|
-
* @param maxDepth maximum depth of search for the root project/ максимальная глубина поиска корневого проекта
|
|
104
|
-
*/
|
|
105
|
-
static getRootProject(
|
|
106
|
-
rootProject: string = this.root,
|
|
107
|
-
maxDepth: number = 10
|
|
108
|
-
): string | undefined {
|
|
109
|
-
const path = this.joinPath([rootProject, UI_MODULES, UI_PROJECT_NAME])
|
|
110
|
-
|
|
111
|
-
if (this.readDir(path).length > 0) {
|
|
112
|
-
return path
|
|
113
|
-
} else if (
|
|
114
|
-
rootProject.match(requirePath.sep)
|
|
115
|
-
&& maxDepth > 0
|
|
116
|
-
) {
|
|
117
|
-
return this.getRootProject(
|
|
118
|
-
rootProject.replace(/\/[^/]+$/, ''),
|
|
119
|
-
maxDepth - 1
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return undefined
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
static getDirname(): string {
|
|
127
|
-
return dirnamePath
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Returns the file name.
|
|
132
|
-
*
|
|
133
|
-
* Возвращает имя файла.
|
|
134
|
-
* @param name element name/ название элемента
|
|
135
|
-
* @param extension file extension by default is json/ расширение файла по умолчанию - json
|
|
136
|
-
*/
|
|
137
|
-
static getFileName(
|
|
138
|
-
name: string,
|
|
139
|
-
extension = 'json'
|
|
140
|
-
): string {
|
|
141
|
-
if (extension && extension !== '') {
|
|
142
|
-
return `${toKebabCase(name)}.${extension}`
|
|
143
|
-
} else {
|
|
144
|
-
return name
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns the path to the directory, removing the file name from the path.
|
|
150
|
-
*
|
|
151
|
-
* Возвращает путь к директории, убрав название файла из пути.
|
|
152
|
-
* @param path path to the file/ путь к файлу
|
|
153
|
-
*/
|
|
154
|
-
static getPathDir(path: PropertiesFilePath): string {
|
|
155
|
-
if (this.isDir(path)) {
|
|
156
|
-
return this.joinPath(path)
|
|
157
|
-
} else {
|
|
158
|
-
return requirePath.dirname(this.joinPath(path))
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Returns the path to the file.
|
|
164
|
-
*
|
|
165
|
-
* Возвращает путь к файлу.
|
|
166
|
-
* @param path path to the file/ путь к файлу
|
|
167
|
-
* @param name element name/ название элемента
|
|
168
|
-
* @param extension file extension by default is json/ расширение файла по умолчанию - json
|
|
169
|
-
*/
|
|
170
|
-
static getPathFile(
|
|
171
|
-
path: PropertiesFilePath,
|
|
172
|
-
name: string,
|
|
173
|
-
extension = 'json'
|
|
174
|
-
): string[] {
|
|
175
|
-
return [...toArray(path), this.getFileName(name, extension)]
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* The method splits the path into an array of components.
|
|
180
|
-
*
|
|
181
|
-
* Метод разбивает путь на массив компонентов.
|
|
182
|
-
* @param path path to the directory/ путь к директории
|
|
183
|
-
*/
|
|
184
|
-
static splitForDir(path: PropertiesFilePath): string[] {
|
|
185
|
-
const dir = this.isDir(path) ? path : this.parse(path)?.dir
|
|
186
|
-
return (this.joinPath(dir || '')).split(requirePath.sep)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Method returns an object whose properties represent significant elements of the path.
|
|
191
|
-
*
|
|
192
|
-
* Метод возвращает объект, свойства которого представляют существенные элементы пути.
|
|
193
|
-
* @param path filename/ имя файла
|
|
194
|
-
*/
|
|
195
|
-
static parse(path: PropertiesFilePath): requirePath.ParsedPath {
|
|
196
|
-
return requirePath.parse(this.joinPath(path))
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Returns the directory separator symbol.
|
|
201
|
-
*
|
|
202
|
-
* Возвращает символ разделителя директории.
|
|
203
|
-
*/
|
|
204
|
-
static sep(): string {
|
|
205
|
-
return requirePath.sep
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Getting information about the file.
|
|
210
|
-
*
|
|
211
|
-
* Получение информации о файле.
|
|
212
|
-
* @param path path to the file/ путь к файлу
|
|
213
|
-
*/
|
|
214
|
-
static stat(path: PropertiesFilePath): requireFs.Stats | undefined {
|
|
215
|
-
if (this.is(path)) {
|
|
216
|
-
return { ...requireFs.statSync(this.joinPath(path)) }
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return undefined
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Returns the time the file was last modified.
|
|
224
|
-
*
|
|
225
|
-
* Возвращает время последнего изменения файла.
|
|
226
|
-
* @param path path to the file/ путь к файлу
|
|
227
|
-
*/
|
|
228
|
-
static getTime(path: PropertiesFilePath): string | undefined {
|
|
229
|
-
return new Datetime(this.stat(path)?.mtimeMs, 'full').standard()
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Converts the path to use the current OS separator.
|
|
234
|
-
*
|
|
235
|
-
* Преобразует путь для использования текущего разделителя ОС.
|
|
236
|
-
* @param path path to the directory/ путь к директории
|
|
237
|
-
*/
|
|
238
|
-
static toSep(path: string): PropertiesFilePath {
|
|
239
|
-
const sep = this.sep()
|
|
240
|
-
|
|
241
|
-
if (sep === '/') {
|
|
242
|
-
return path
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return path.replace('/', this.sep())
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Reads the contents of the directory.
|
|
250
|
-
*
|
|
251
|
-
* Читает содержимое директории.
|
|
252
|
-
* @param path path to the directory/ путь к директории
|
|
253
|
-
*/
|
|
254
|
-
static readDir(path: PropertiesFilePath): string[] {
|
|
255
|
-
return this.is(path) ? requireFs.readdirSync(this.joinPath(path)) : []
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Reads the contents of the directory recursively.
|
|
260
|
-
*
|
|
261
|
-
* Читает содержимое директории рекурсивно.
|
|
262
|
-
* @param path path to the directory/ путь к директории
|
|
263
|
-
*/
|
|
264
|
-
static readDirRecursive(
|
|
265
|
-
path: PropertiesFilePath
|
|
266
|
-
): string[] {
|
|
267
|
-
return this
|
|
268
|
-
.readDirAndFileRecursive(path)
|
|
269
|
-
.filter(paths => !this.isDir(paths))
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Reads the contents of the directory recursively.
|
|
274
|
-
*
|
|
275
|
-
* Читает содержимое директории рекурсивно.
|
|
276
|
-
* @param path path to the directory/ путь к директории
|
|
277
|
-
*/
|
|
278
|
-
static readDirRecursiveWithIndex(
|
|
279
|
-
path: PropertiesFilePath
|
|
280
|
-
): string[] {
|
|
281
|
-
return this
|
|
282
|
-
.readDirAndFileRecursive(path, undefined, true)
|
|
283
|
-
.filter(paths => !this.isDir(paths))
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Reads only directories recursively.
|
|
288
|
-
*
|
|
289
|
-
* Читает только директории рекурсивно.
|
|
290
|
-
* @param path path to the directory/ путь к директории
|
|
291
|
-
*/
|
|
292
|
-
static readDirOnlyRecursive(
|
|
293
|
-
path: PropertiesFilePath
|
|
294
|
-
): string[] {
|
|
295
|
-
return this
|
|
296
|
-
.readDirAndFileRecursive(path)
|
|
297
|
-
.filter(paths => this.isDir(paths))
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Reads the contents of the directory and files recursively.
|
|
302
|
-
*
|
|
303
|
-
* Читает содержимое директории и файлы рекурсивно.
|
|
304
|
-
* @param path path to the directory/ путь к директории
|
|
305
|
-
* @param fullPath full path for recursion/ полный путь для рекурсии
|
|
306
|
-
* @param isIndex whether to include the root directory in the list/ включать ли корневую директорию в список
|
|
307
|
-
*/
|
|
308
|
-
static readDirAndFileRecursive(
|
|
309
|
-
path: PropertiesFilePath,
|
|
310
|
-
fullPath: PropertiesFilePath = [],
|
|
311
|
-
isIndex: boolean = false
|
|
312
|
-
): string[] {
|
|
313
|
-
const dirs = this.readDir(path)
|
|
314
|
-
const data: string[] = []
|
|
315
|
-
|
|
316
|
-
dirs.forEach((dir) => {
|
|
317
|
-
const paths = [...toArray(path), dir]
|
|
318
|
-
const fullPaths = [...fullPath, dir]
|
|
319
|
-
|
|
320
|
-
data.push(this.joinPath(fullPaths))
|
|
321
|
-
|
|
322
|
-
if (this.isDir(paths)) {
|
|
323
|
-
if (
|
|
324
|
-
isIndex
|
|
325
|
-
&& this.is([...paths, UI_FILE_INDEX])
|
|
326
|
-
) {
|
|
327
|
-
data.push(this.joinPath([...fullPaths, UI_FILE_INDEX]))
|
|
328
|
-
} else {
|
|
329
|
-
data.push(...this.readDirAndFileRecursive(
|
|
330
|
-
paths,
|
|
331
|
-
[...fullPath, dir]
|
|
332
|
-
))
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
return data
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Synchronously reads and parses the contents of a file (JSON or raw text).
|
|
342
|
-
*
|
|
343
|
-
* Синхронно читает и парсит содержимое файла (JSON или обычный текст).
|
|
344
|
-
* @param path path to the target file / путь к целевому файлу
|
|
345
|
-
*/
|
|
346
|
-
static readFile<R>(path: PropertiesFilePath): R | undefined {
|
|
347
|
-
if (this.is(path)) {
|
|
348
|
-
return transformation(
|
|
349
|
-
requireFs.readFileSync(this.joinPath(path)).toString()
|
|
350
|
-
)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return undefined
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Returns the content of the file, without converting the value.
|
|
358
|
-
*
|
|
359
|
-
* Возвращает содержимое файла, без преобразования значения.
|
|
360
|
-
* @param path filename/ имя файла
|
|
361
|
-
*/
|
|
362
|
-
static readFileOnly(path: PropertiesFilePath): string | undefined {
|
|
363
|
-
if (this.is(path)) {
|
|
364
|
-
return requireFs.readFileSync(this.joinPath(path)).toString()
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return undefined
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Synchronously creates a directory.
|
|
372
|
-
*
|
|
373
|
-
* Синхронно создает директорию.
|
|
374
|
-
* @param path path to the directory/ путь к директории
|
|
375
|
-
*/
|
|
376
|
-
static createDir(path: PropertiesFilePath): void {
|
|
377
|
-
const dir: string[] = [this.root]
|
|
378
|
-
|
|
379
|
-
this.splitForDir(this.removeRootInPath(path)).forEach((name) => {
|
|
380
|
-
dir.push(name)
|
|
381
|
-
if (!this.is(dir)) {
|
|
382
|
-
requireFs.mkdirSync(this.joinPath(dir))
|
|
383
|
-
}
|
|
384
|
-
})
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Writes data to a file at the specified location, automatically creating directories and formatting objects as JSON by default.
|
|
389
|
-
*
|
|
390
|
-
* Записывает данные в файл по указанному адресу, автоматически создавая директории и форматируя объекты в JSON по умолчанию.
|
|
391
|
-
* @param path base directory path / путь к базовой директории
|
|
392
|
-
* @param name target filename (without extension if extension provided) / имя целевого файла
|
|
393
|
-
* @param value data to be stored / данные для хранения
|
|
394
|
-
* @param extension file extension (defaults to 'json') / расширение файла (по умолчанию 'json')
|
|
395
|
-
*/
|
|
396
|
-
static write<T extends PropertiesFileValue>(
|
|
397
|
-
path: PropertiesFilePath,
|
|
398
|
-
name: string,
|
|
399
|
-
value: T,
|
|
400
|
-
extension = 'json'
|
|
401
|
-
): void {
|
|
402
|
-
this.writeByPath(
|
|
403
|
-
this.joinPathByName(path, name, extension),
|
|
404
|
-
value
|
|
405
|
-
)
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Writes to the selected path.
|
|
410
|
-
*
|
|
411
|
-
* Записывает по выбранному пути.
|
|
412
|
-
* @param path path to the file/ путь к файлу
|
|
413
|
-
* @param value values for storage/ значения для хранения
|
|
414
|
-
* @param transform whether to transform the value/ преобразовывать ли значение
|
|
415
|
-
*/
|
|
416
|
-
static writeByPath<T extends PropertiesFileValue>(
|
|
417
|
-
path: PropertiesFilePath,
|
|
418
|
-
value: T,
|
|
419
|
-
transform: boolean = true
|
|
420
|
-
): void {
|
|
421
|
-
this.createDir(path)
|
|
422
|
-
|
|
423
|
-
requireFs.writeFileSync(
|
|
424
|
-
this.joinPath(path),
|
|
425
|
-
transform && typeof value === 'object' ? JSON.stringify(value, undefined, 2) : value as any
|
|
426
|
-
)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Copy a file from the source path to the destination path.
|
|
431
|
-
*
|
|
432
|
-
* Копирования файла из исходного пути в целевой путь.
|
|
433
|
-
* @param path path to the file/ путь к файлу
|
|
434
|
-
* @param pathsSrc source filename to copy/ исходное имя файла для копирования
|
|
435
|
-
*/
|
|
436
|
-
static copy(
|
|
437
|
-
path: PropertiesFilePath,
|
|
438
|
-
pathsSrc: PropertiesFilePath
|
|
439
|
-
): void {
|
|
440
|
-
this.createDir(path)
|
|
441
|
-
|
|
442
|
-
requireFs.copyFileSync(
|
|
443
|
-
this.joinPath(pathsSrc),
|
|
444
|
-
this.joinPath(path)
|
|
445
|
-
)
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Directory deletion.
|
|
450
|
-
*
|
|
451
|
-
* Удаление директории.
|
|
452
|
-
* @param path path to the directory/ путь к директории
|
|
453
|
-
*/
|
|
454
|
-
static removeDir(
|
|
455
|
-
path: PropertiesFilePath
|
|
456
|
-
): void {
|
|
457
|
-
if (this.isDir(path)) {
|
|
458
|
-
requireFs.rmSync(this.joinPath(path), {
|
|
459
|
-
recursive: true,
|
|
460
|
-
force: true
|
|
461
|
-
})
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* File deletion.
|
|
467
|
-
*
|
|
468
|
-
* Удаление файла.
|
|
469
|
-
* @param path path to the file/ путь к файлу
|
|
470
|
-
*/
|
|
471
|
-
static removeFile(
|
|
472
|
-
path: PropertiesFilePath
|
|
473
|
-
): void {
|
|
474
|
-
if (this.is(path)) {
|
|
475
|
-
requireFs.unlinkSync(this.joinPath(path))
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
static rename(
|
|
480
|
-
path: PropertiesFilePath,
|
|
481
|
-
newPath: PropertiesFilePath
|
|
482
|
-
): void {
|
|
483
|
-
requireFs.renameSync(
|
|
484
|
-
this.joinPath(path),
|
|
485
|
-
this.joinPath(newPath)
|
|
486
|
-
)
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Changing file permissions.
|
|
491
|
-
*
|
|
492
|
-
* Изменение прав доступа к файлу.
|
|
493
|
-
* @param path path to the file/ путь к файлу
|
|
494
|
-
* @param mode file permissions/ права доступа к файлу
|
|
495
|
-
*/
|
|
496
|
-
static chmod(
|
|
497
|
-
path: PropertiesFilePath,
|
|
498
|
-
mode: string | number = 0o755
|
|
499
|
-
): void {
|
|
500
|
-
requireFs.chmodSync(
|
|
501
|
-
this.joinPath(path),
|
|
502
|
-
mode
|
|
503
|
-
)
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Removing root from the path.
|
|
508
|
-
*
|
|
509
|
-
* Удаление root из пути.
|
|
510
|
-
* @param path path to the directory/ путь к директории
|
|
511
|
-
*/
|
|
512
|
-
private static removeRootInPath(path: PropertiesFilePath): string {
|
|
513
|
-
return this.joinPath(path)
|
|
514
|
-
.replace(`${this.root}${requirePath.sep}`, '')
|
|
515
|
-
.replace(`${this.root}`, '')
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
static {
|
|
519
|
-
this.module = Boolean(dirnamePath.match('node_modules'))
|
|
520
|
-
this.root = process.cwd()
|
|
521
|
-
}
|
|
522
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { forEach, isFilled, isObjectNotArray, replaceRecursive } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
PropertiesFile,
|
|
7
|
-
type PropertiesFilePath
|
|
8
|
-
} from './PropertiesFile'
|
|
9
|
-
import { PropertiesCache } from './PropertiesCache'
|
|
10
|
-
import { PropertiesTypes } from './PropertiesTypes'
|
|
11
|
-
|
|
12
|
-
import { PropertiesConvector } from './PropertiesConvector'
|
|
13
|
-
import { PropertiesStandard } from './PropertiesStandard'
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
PropertyKey,
|
|
17
|
-
type PropertyList,
|
|
18
|
-
type PropertyListOrData,
|
|
19
|
-
PropertyType
|
|
20
|
-
} from '../../types/propertyTypes'
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Resolver for external property references.
|
|
24
|
-
* This class orchestrates the inclusion of external design tokens into the primary property tree. It identifies file references, resolves paths (including nested directory imports and specific object path deep-linking via hashes), and merges the external data into the current configuration cluster.
|
|
25
|
-
*
|
|
26
|
-
* Резолвер внешних ссылок на свойства.
|
|
27
|
-
* Этот класс координирует включение внешних токенов дизайна в основное дерево свойств. Он идентифицирует ссылки на файлы, разрешает пути (включая импорт вложенных директорий и глубокие ссылки на конкретные объекты через хеш) и объединяет внешние данные с текущим кластером конфигурации.
|
|
28
|
-
*/
|
|
29
|
-
export class PropertiesImport {
|
|
30
|
-
/**
|
|
31
|
-
* Constructor
|
|
32
|
-
* @param properties array with all property records/ массив со всеми записями свойств
|
|
33
|
-
* @param root path to the directory/ путь к директории
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
constructor(
|
|
37
|
-
private properties: PropertyList,
|
|
38
|
-
private root: string[]
|
|
39
|
-
) {
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Resolves and merges external file references within a property cluster.
|
|
44
|
-
* Iterates through the properties, looks for items of type 'file', and recursively imports their content, supporting deep-linking (e.g., 'file.json#path.to.data').
|
|
45
|
-
*
|
|
46
|
-
* Разрешает и объединяет ссылки на внешние файлы внутри кластера свойств.
|
|
47
|
-
* Итерирует по свойствам, ищет элементы типа 'file' и рекурсивно импортирует их содержимое, поддерживая глубокие ссылки (например, 'file.json#path.to.data').
|
|
48
|
-
* @param properties the property list to process / список свойств для обработки
|
|
49
|
-
* @param root the base path segments for resolution / базовые сегменты пути для разрешения
|
|
50
|
-
*/
|
|
51
|
-
to(
|
|
52
|
-
properties = this.properties,
|
|
53
|
-
root = this.root
|
|
54
|
-
) {
|
|
55
|
-
let data: PropertyList = {}
|
|
56
|
-
|
|
57
|
-
forEach(properties, (item, name) => {
|
|
58
|
-
if (
|
|
59
|
-
typeof item.value === 'string'
|
|
60
|
-
&& PropertiesTypes.isInType(item[PropertyKey.type], [PropertyType.file])
|
|
61
|
-
) {
|
|
62
|
-
const {
|
|
63
|
-
path,
|
|
64
|
-
link
|
|
65
|
-
} = this.initLink(root, item.value)
|
|
66
|
-
const read = this.readByLink(this.read(path), link)
|
|
67
|
-
|
|
68
|
-
if (isFilled(read)) {
|
|
69
|
-
PropertiesConvector.to(read)
|
|
70
|
-
|
|
71
|
-
data = replaceRecursive(data, this.to(
|
|
72
|
-
PropertiesStandard.to(read),
|
|
73
|
-
[PropertiesFile.getPathDir(path)]
|
|
74
|
-
))
|
|
75
|
-
}
|
|
76
|
-
} else if (isObjectNotArray(item.value)) {
|
|
77
|
-
data = replaceRecursive(data, {
|
|
78
|
-
[name]: {
|
|
79
|
-
...item,
|
|
80
|
-
value: this.to(item.value, root)
|
|
81
|
-
}
|
|
82
|
-
} as PropertyList)
|
|
83
|
-
} else {
|
|
84
|
-
data = replaceRecursive(data, { [name]: item })
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
return data
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Returns the path to the file.
|
|
93
|
-
*
|
|
94
|
-
* Возвращает путь к файлу.
|
|
95
|
-
* @param root path to the directory/ путь к директории
|
|
96
|
-
* @param value object with data/ объект с данными
|
|
97
|
-
*/
|
|
98
|
-
private getPath(root: string[], value: string): string[] {
|
|
99
|
-
return [
|
|
100
|
-
...root,
|
|
101
|
-
...value.split('/')
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Generates the path to the file and prepares entries in the tree to go through.
|
|
107
|
-
*
|
|
108
|
-
* Генерирует путь к файлу и подготавливает записи в дереве, по которому надо пройтись.
|
|
109
|
-
* @param root path to the directory/ путь к директории
|
|
110
|
-
* @param value object with data/ объект с данными
|
|
111
|
-
*/
|
|
112
|
-
private initLink(root: string[], value: string) {
|
|
113
|
-
const link = value.split('#', 2)
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
path: this.getPath(root, link[0] as string),
|
|
117
|
-
link: link?.[1]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Reads a file or an entire directory.
|
|
123
|
-
*
|
|
124
|
-
* Читает файл или всю директорию.
|
|
125
|
-
* @param path path to file/ путь к файлу
|
|
126
|
-
*/
|
|
127
|
-
private read(path: PropertiesFilePath): PropertyListOrData | undefined {
|
|
128
|
-
if (PropertiesFile.isDir(path)) {
|
|
129
|
-
return this.readByDir(path)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return PropertiesCache.read<PropertyListOrData>(path) ?? {}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Reads the file and leaves the data only along the selected path.
|
|
137
|
-
*
|
|
138
|
-
* Читает файл и оставляет данные только по выделенному пути.
|
|
139
|
-
* @param read read data/ прочитанные данные
|
|
140
|
-
* @param link the path to the entry that needs to be used/ путь к записи, который надо использовать
|
|
141
|
-
*/
|
|
142
|
-
private readByLink(
|
|
143
|
-
read: PropertyListOrData | undefined,
|
|
144
|
-
link?: string
|
|
145
|
-
): PropertyListOrData | undefined {
|
|
146
|
-
let data = read
|
|
147
|
-
|
|
148
|
-
if (link) {
|
|
149
|
-
for (const name of link.split('.')) {
|
|
150
|
-
if (data && (name in data)) {
|
|
151
|
-
data = data[name]
|
|
152
|
-
} else {
|
|
153
|
-
return undefined
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return data
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Reads a directory.
|
|
163
|
-
*
|
|
164
|
-
* Читает директорию.
|
|
165
|
-
* @param path path to file/ путь к файлу
|
|
166
|
-
*/
|
|
167
|
-
private readByDir(path: PropertiesFilePath): PropertyListOrData {
|
|
168
|
-
const files = PropertiesFile.readDir(path)
|
|
169
|
-
const data: PropertyListOrData = {}
|
|
170
|
-
|
|
171
|
-
files?.sort()
|
|
172
|
-
files?.forEach((file) => {
|
|
173
|
-
const parse = PropertiesFile.parse(file)
|
|
174
|
-
|
|
175
|
-
if (parse.ext === '.json') {
|
|
176
|
-
data[parse.name] = PropertiesCache.read<PropertyListOrData>([...path, file]) ?? {}
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
return data
|
|
181
|
-
}
|
|
182
|
-
}
|