@dxtmisha/scripts 0.6.3 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/bin/ai-doc.ts +1 -3
  2. package/bin/build-functional.ts +5 -0
  3. package/bin/design-flags.ts +5 -0
  4. package/package.json +10 -6
  5. package/src/classes/Build/buildFunctional.ts +39 -0
  6. package/src/classes/Design/DesignCommand.ts +52 -2
  7. package/src/classes/Design/DesignComponent.ts +73 -16
  8. package/src/classes/Design/DesignConstructor.ts +40 -15
  9. package/src/classes/Design/DesignConstructors.ts +57 -2
  10. package/src/classes/Design/DesignFlags.ts +199 -0
  11. package/src/classes/Design/DesignReplace.ts +1 -1
  12. package/src/classes/Design/DesignUi.ts +41 -2
  13. package/src/classes/Library/LibraryAiWiki.ts +126 -0
  14. package/src/classes/Library/LibraryAiWikiItem.ts +79 -0
  15. package/src/classes/Library/LibraryExport.ts +0 -2
  16. package/src/classes/Library/LibraryItems.ts +13 -4
  17. package/src/classes/Library/LibraryList.ts +184 -0
  18. package/src/classes/Library/LibraryMedia.ts +1 -2
  19. package/src/classes/Library/LibraryPlugin.ts +70 -0
  20. package/src/classes/Library/LibraryTypes.ts +106 -0
  21. package/src/classes/Package/PackageItem.ts +3 -1
  22. package/src/classes/Properties/PropertiesConfig.ts +9 -0
  23. package/src/classes/Properties/PropertiesFile.ts +5 -3
  24. package/src/classes/Styles/Styles.ts +1 -0
  25. package/src/config.ts +7 -0
  26. package/src/library.ts +4 -0
  27. package/src/media/templates/component/{DesignComponentWikiAi.vue → DesignComponentAiWiki.vue} +2 -2
  28. package/src/media/templates/component/props.ts +2 -3
  29. package/src/media/templates/component/styleToken.scss +1 -1
  30. package/src/media/templates/constructors/props.ts +3 -4
  31. package/src/media/templates/packages/library/src/main.ts +1 -1
  32. package/src/media/templates/packages/project/design.config.json +3 -0
  33. package/src/media/templates/packages/project/index.html +1 -2
  34. package/src/media/templates/packages/project/src/main.ts +2 -1
  35. package/src/media/templates/packages/project/src/vite-env.d.ts +1 -0
  36. package/src/types/configTypes.ts +3 -0
  37. package/src/types/designTypes.ts +12 -0
  38. package/src/types/libraryTypes.ts +1 -1
  39. /package/src/media/templates/packages/{library → project}/public/_.gitignore.txt +0 -0
package/bin/ai-doc.ts CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  import { AiDoc } from '../src/classes/Ai/AiDoc'
4
4
 
5
- const name: string = process.argv?.[2] ?? 'src/storybook'
6
-
7
- new AiDoc(name)
5
+ new AiDoc()
8
6
  .make()
9
7
  .then()
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env vite-node
2
+
3
+ import { BuildFunctional } from '../src/classes/Build/buildFunctional'
4
+
5
+ new BuildFunctional().make()
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env vite-node
2
+
3
+ import { DesignFlags } from '../src/classes/Design/DesignFlags'
4
+
5
+ new DesignFlags().make()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/scripts",
3
3
  "private": false,
4
- "version": "0.6.3",
4
+ "version": "0.7.2",
5
5
  "type": "module",
6
6
  "description": "Development scripts and CLI tools for DXT UI projects - automated component generation, library building and project management tools",
7
7
  "keywords": [
@@ -31,8 +31,8 @@
31
31
  "library": "dxt-library"
32
32
  },
33
33
  "files": [
34
- "src/",
35
34
  "bin/",
35
+ "src/",
36
36
  "README.md",
37
37
  "package.json",
38
38
  "LICENSE"
@@ -41,9 +41,11 @@
41
41
  "module": "./src/library.ts",
42
42
  "bin": {
43
43
  "dxt-ai-doc": "bin/ai-doc.ts",
44
+ "dxt-build-functional": "bin/build-functional.ts",
44
45
  "dxt-component": "bin/design-component.ts",
45
46
  "dxt-component-wiki": "bin/design-component-wiki.ts",
46
47
  "dxt-constructor": "bin/design-constructor.ts",
48
+ "dxt-flags": "bin/design-flags.ts",
47
49
  "dxt-library": "bin/design-library.ts",
48
50
  "dxt-package": "bin/design-package.ts",
49
51
  "dxt-types": "bin/design-types.ts",
@@ -52,19 +54,21 @@
52
54
  "exports": {
53
55
  ".": "./src/library.ts",
54
56
  "./ai": "./src/library-ai.ts",
57
+ "./plugin": "./src/library-plugin.ts",
55
58
  "./config": "./src/config.ts",
56
59
  "./properties.json": "./src/media/properties.json"
57
60
  },
58
61
  "engines": {
59
- "node": ">=18.0.0"
62
+ "node": ">=20.0.0"
60
63
  },
61
64
  "peerDependencies": {
62
65
  "@dxtmisha/configuration": "*",
66
+ "@dxtmisha/media": "*",
63
67
  "@dxtmisha/functional": "*",
64
- "@dxtmisha/styles": "*",
68
+ "@dxtmisha/functional-basic": "*",
65
69
  "@dxtmisha/wiki": "*",
66
- "typescript": "*",
67
- "vue": "*"
70
+ "typescript": "^5.0.0",
71
+ "vue": "^3.0.0"
68
72
  },
69
73
  "dependencies": {}
70
74
  }
@@ -0,0 +1,39 @@
1
+ import * as functional from '@dxtmisha/functional'
2
+
3
+ import { PropertiesFile } from '../Properties/PropertiesFile'
4
+
5
+ import { UI_DIRS_LIBRARY } from '../../config'
6
+
7
+ export class BuildFunctional {
8
+ constructor() {
9
+ }
10
+
11
+ make(): void {
12
+ console.log('Build functional...')
13
+
14
+ const list = this.getList()
15
+ const code: string[] = [
16
+ 'export type * from \'@dxtmisha/functional\'',
17
+ ''
18
+ ]
19
+
20
+ list.sort()
21
+ list.forEach((item) => {
22
+ console.log(`-- ${item}`)
23
+
24
+ code.push(`export { ${item} } from '@dxtmisha/functional'`)
25
+ })
26
+
27
+ code.push('')
28
+ PropertiesFile.writeByPath(
29
+ [...UI_DIRS_LIBRARY, 'functional.ts'],
30
+ code.join('\n')
31
+ )
32
+
33
+ console.log('...end')
34
+ }
35
+
36
+ getList(): string[] {
37
+ return Object.keys(functional)
38
+ }
39
+ }
@@ -2,15 +2,16 @@
2
2
 
3
3
  import { dirname } from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
- import { toArray } from '@dxtmisha/functional-basic'
5
+ import { toArray, toCamelCase, toCamelCaseFirst, toKebabCase } from '@dxtmisha/functional-basic'
6
6
  import { hasNativeDirname } from '../../functions/hasNativeDirname'
7
+ import { getPackageJson } from '../../functions/getPackageJson'
7
8
 
8
9
  import { PropertiesConfig } from '../Properties/PropertiesConfig'
9
10
  import { PropertiesFile } from '../Properties/PropertiesFile'
10
11
  import { DesignStructure } from './DesignStructure'
11
12
  import { DesignReplace } from './DesignReplace'
12
13
 
13
- import { UI_KEY_CONSTRUCTOR } from '../../config'
14
+ import { UI_FILE_PACKAGE, UI_KEY_CONSTRUCTOR } from '../../config'
14
15
 
15
16
  const dirnamePath = hasNativeDirname()
16
17
  ? __dirname
@@ -84,6 +85,26 @@ export abstract class DesignCommand {
84
85
  return this.command
85
86
  }
86
87
 
88
+ protected getName(): string {
89
+ return toCamelCaseFirst(this.getCommand())
90
+ }
91
+
92
+ protected getNameMin(): string {
93
+ return toCamelCase(this.getCommand())
94
+ }
95
+
96
+ protected getCode(): string {
97
+ return toKebabCase(this.getCommand())
98
+ }
99
+
100
+ protected getFullName(): string {
101
+ return toCamelCaseFirst(`${PropertiesConfig.getDesignName()}-${this.getCommand()}`)
102
+ }
103
+
104
+ protected getProjectName(): string {
105
+ return toCamelCaseFirst(PropertiesConfig.getProjectName())
106
+ }
107
+
87
108
  /**
88
109
  * Returns a structure object.
89
110
  *
@@ -180,6 +201,35 @@ export abstract class DesignCommand {
180
201
  )
181
202
  }
182
203
 
204
+ protected updatePackage(
205
+ namePath: string,
206
+ value: any
207
+ ): this {
208
+ const packageFile = getPackageJson()
209
+ let focus: Record<string, any> | any | undefined = packageFile
210
+
211
+ if (packageFile && focus) {
212
+ const names = namePath.split('|')
213
+ const key = names.pop()
214
+
215
+ for (const name of names) {
216
+ if (!(name in focus)) {
217
+ focus[name] = {}
218
+ }
219
+
220
+ focus = focus[name]
221
+ }
222
+
223
+ if (key) {
224
+ focus[key] = value
225
+ }
226
+
227
+ PropertiesFile.writeByPath(UI_FILE_PACKAGE, packageFile)
228
+ }
229
+
230
+ return this
231
+ }
232
+
183
233
  /**
184
234
  * Outputting data to the console.
185
235
  *
@@ -1,6 +1,11 @@
1
1
  // export:none
2
2
 
3
- import { forEach, isObjectNotArray, toArray, toKebabCase } from '@dxtmisha/functional-basic'
3
+ import {
4
+ forEach,
5
+ isObjectNotArray, replaceComponentName,
6
+ toArray,
7
+ toKebabCase
8
+ } from '@dxtmisha/functional-basic'
4
9
  import { wikiDescriptions } from '@dxtmisha/wiki/media'
5
10
  import type { StorybookComponentsDescriptionItem } from '@dxtmisha/wiki'
6
11
 
@@ -16,6 +21,7 @@ import {
16
21
  UI_DIR_CONSTRUCTOR,
17
22
  UI_DIR_IN,
18
23
  UI_DIRS_COMPONENTS,
24
+ UI_DIRS_LIBRARY,
19
25
  UI_PROJECT_CONSTRUCTOR_FULL_NAME,
20
26
  UI_PROJECT_CONSTRUCTOR_NAME
21
27
  } from '../../config'
@@ -25,7 +31,7 @@ const FILE_PROPERTIES = 'properties.json'
25
31
  const FILE_PROPS = 'props.ts'
26
32
  const FILE_STYLE = 'styleToken.scss'
27
33
  const FILE_CLASS = 'DesignComponent.vue'
28
- const FILE_CLASS_AI = 'DesignComponentWikiAi.vue'
34
+ const FILE_CLASS_AI = 'DesignComponentAiWiki.vue'
29
35
  const FILE_INDEX = 'index.ts'
30
36
  const FILE_WIKI = 'wiki.ts'
31
37
  const FILE_STORIES = 'DesignComponent.stories.ts'
@@ -78,6 +84,8 @@ export class DesignComponent extends DesignCommand {
78
84
  .makeWiki()
79
85
  .makeStories()
80
86
  .makeStoriesDocumentation()
87
+ .makeFilePackage()
88
+ .makeLibrary()
81
89
  }
82
90
 
83
91
  /**
@@ -163,24 +171,35 @@ export class DesignComponent extends DesignCommand {
163
171
  if (
164
172
  item?.ai
165
173
  ) {
174
+ const imports: string[] = []
175
+
166
176
  if (item.ai.render) {
167
- const render = item.ai.render
168
- .replace(`<${componentName}`, `<${fullComponentName}`)
169
- .trim()
170
-
171
- sample.replaceMark('component-render', [
172
- '<template #render="{ args, classDemo }">',
173
- render,
174
- '</template>'
175
- ])
177
+ let render = replaceComponentName(
178
+ item.ai.render,
179
+ componentName,
180
+ fullComponentName
181
+ )
182
+
183
+ if (item.ai.render.includes('<button')) {
184
+ imports.push(`import { DxtTestButton } from '@dxtmisha/test'`)
185
+ render = replaceComponentName(render, 'button', 'DxtTestButton')
186
+ }
187
+
188
+ if (render) {
189
+ sample.replaceMark('component-render', [
190
+ '<template #render="{ args, classDemo }">',
191
+ render,
192
+ '</template>'
193
+ ])
194
+ }
176
195
  }
177
196
 
178
197
  if (item.ai.import) {
179
- sample.replaceMark('component-import', [
180
- '<template #render="{ args, classDemo }">',
181
- ...item.ai.import,
182
- '</template>'
183
- ])
198
+ imports.push(...item.ai.import)
199
+ }
200
+
201
+ if (imports.length > 0) {
202
+ sample.replaceMark('component-import', imports)
184
203
  }
185
204
  }
186
205
 
@@ -557,4 +576,42 @@ export class DesignComponent extends DesignCommand {
557
576
 
558
577
  return this
559
578
  }
579
+
580
+ /**
581
+ * Updates the package.json file.
582
+ *
583
+ * Обновляет файл package.json.
584
+ */
585
+ protected makeFilePackage(): this {
586
+ const name = `./${this.getFullName()}`
587
+
588
+ this.updatePackage(
589
+ `exports|${name}`,
590
+ {
591
+ types: `./dist/${this.getFullName()}.d.ts`,
592
+ default: `./dist/${this.getFullName()}.js`
593
+ }
594
+ )
595
+
596
+ return this
597
+ }
598
+
599
+ /**
600
+ * Generates a library file.
601
+ *
602
+ * Генерирует файл библиотеки.
603
+ */
604
+ protected makeLibrary(): this {
605
+ const dir: string = `../${UI_DIR_COMPONENTS}/${this.getProjectName()}/${this.getName()}/`
606
+ const name = this.getFullName()
607
+
608
+ PropertiesFile.writeByPath(
609
+ [...UI_DIRS_LIBRARY, `${name}.ts`],
610
+ `export { default as ${name} } from '${dir}${name}.vue'
611
+ export type { ${this.getName()}Props as ${name}Props } from '${dir}props'
612
+ `
613
+ )
614
+
615
+ return this
616
+ }
560
617
  }
@@ -1,12 +1,12 @@
1
1
  // export:none
2
2
 
3
- import { toCamelCaseFirst } from '@dxtmisha/functional-basic'
3
+ import { toCamelCase, toCamelCaseFirst } from '@dxtmisha/functional-basic'
4
4
 
5
5
  import { PropertiesFile } from '../Properties/PropertiesFile'
6
6
 
7
7
  import { DesignCommand } from './DesignCommand'
8
8
 
9
- import { UI_FILE_PACKAGE, UI_DIR_IN, UI_DIR_CONSTRUCTOR } from '../../config'
9
+ import { UI_DIR_IN, UI_DIR_CONSTRUCTOR, UI_DIRS_LIBRARY } from '../../config'
10
10
 
11
11
  const FILE_PROPERTIES = 'properties.json'
12
12
  const FILE_PROPS = 'props.ts'
@@ -61,6 +61,7 @@ export class DesignConstructor extends DesignCommand {
61
61
  .makeMain()
62
62
  .makeIndex()
63
63
  .makeFilePackage()
64
+ .makeLibrary()
64
65
  }
65
66
 
66
67
  /**
@@ -112,9 +113,9 @@ export class DesignConstructor extends DesignCommand {
112
113
  }
113
114
 
114
115
  /**
115
- * This code generates the properties.json.
116
+ * This code generates the basicTypes.ts.
116
117
  *
117
- * Генерация файла properties.json.
118
+ * Генерация файла basicTypes.ts.
118
119
  */
119
120
  protected makeTypesBasic(): this {
120
121
  return this.makeFileStandard(FILE_TYPES_BASIC)
@@ -163,6 +164,12 @@ export class DesignConstructor extends DesignCommand {
163
164
  return this.makeFileStandard(FILE_INDEX)
164
165
  }
165
166
 
167
+ /**
168
+ * Generates a standard file based on a template.
169
+ *
170
+ * Генерирует стандартный файл на основе шаблона.
171
+ * @param file file name/ имя файла
172
+ */
166
173
  protected makeFileStandard(file: string): this {
167
174
  const sample = this.readDefinable(file)
168
175
 
@@ -172,21 +179,39 @@ export class DesignConstructor extends DesignCommand {
172
179
  return this
173
180
  }
174
181
 
182
+ /**
183
+ * Updates the package.json file.
184
+ *
185
+ * Обновляет файл package.json.
186
+ */
175
187
  protected makeFilePackage(): this {
176
- const packageFile = PropertiesFile.readFile<Record<string, any>>(UI_FILE_PACKAGE)
177
- const command = toCamelCaseFirst(this.getCommand())
188
+ const command = this.getName()
178
189
  const name = `./${command}`
179
190
 
180
- if (
181
- packageFile
182
- && packageFile.exports
183
- && !(name in packageFile.exports)
184
- ) {
185
- packageFile.exports[name] = `./src/constructors/${command}/index.ts`
186
- packageFile.exports[`${name}/style`] = `./src/constructors/${command}/style.scss`
191
+ this.updatePackage(
192
+ `exports|${name}`,
193
+ {
194
+ types: `./dist/constructors/${command}/index.d.ts`,
195
+ default: `./dist/${this.getNameMin()}.js`
196
+ }
197
+ )
187
198
 
188
- PropertiesFile.writeByPath(UI_FILE_PACKAGE, packageFile)
189
- }
199
+ return this
200
+ }
201
+
202
+ /**
203
+ * Generates a library file.
204
+ *
205
+ * Генерирует файл библиотеки.
206
+ */
207
+ protected makeLibrary(): this {
208
+ const name = toCamelCase(this.getCommand())
209
+
210
+ PropertiesFile.writeByPath(
211
+ [...UI_DIRS_LIBRARY, `${name}.ts`],
212
+ `export * from '../${UI_DIR_CONSTRUCTOR}/${toCamelCaseFirst(this.getCommand())}/index'
213
+ `
214
+ )
190
215
 
191
216
  return this
192
217
  }
@@ -1,19 +1,33 @@
1
1
  // export:none
2
2
 
3
- import { isFilled } from '@dxtmisha/functional-basic'
3
+ import { isFilled, toCamelCaseFirst } from '@dxtmisha/functional-basic'
4
4
 
5
5
  import { PropertiesFile } from '../Properties/PropertiesFile'
6
6
  import { PropertiesCache } from '../Properties/PropertiesCache'
7
7
  import { DesignConstructor } from './DesignConstructor'
8
8
 
9
- import { UI_DIR_CONSTRUCTOR, UI_DIR_IN } from '../../config'
9
+ import { UI_DIR_CONSTRUCTOR, UI_DIR_IN, UI_DIRS_LIBRARY, UI_FILE_STYLE_SCSS } from '../../config'
10
10
 
11
+ /**
12
+ * Class for managing design constructors.
13
+ *
14
+ * Класс для управления конструкторами дизайна.
15
+ */
11
16
  export class DesignConstructors {
17
+ /**
18
+ * Constructor
19
+ * @param name component name/ название компонента
20
+ */
12
21
  constructor(
13
22
  protected readonly name?: string
14
23
  ) {
15
24
  }
16
25
 
26
+ /**
27
+ * Starts the process of creating or updating constructors.
28
+ *
29
+ * Запускает процесс создания или обновления конструкторов.
30
+ */
17
31
  make(): void {
18
32
  PropertiesCache.clear()
19
33
 
@@ -26,12 +40,41 @@ export class DesignConstructors {
26
40
  new DesignConstructor(component).make()
27
41
  })
28
42
  }
43
+
44
+ this.makeStyle()
29
45
  }
30
46
 
47
+ /**
48
+ * Returns a list of components.
49
+ *
50
+ * Возвращает список компонентов.
51
+ */
31
52
  getComponents(): string[] {
32
53
  return PropertiesFile.readDir(this.getDir())
33
54
  }
34
55
 
56
+ /**
57
+ * Returns a list of component styles.
58
+ *
59
+ * Возвращает список стилей компонентов.
60
+ */
61
+ getComponentsStyle(): string[] {
62
+ const list: string[] = []
63
+
64
+ this.getComponents()
65
+ .forEach((component) => {
66
+ const name = toCamelCaseFirst(component)
67
+ list.push(`@forward "../constructors/${name}/style";`)
68
+ })
69
+
70
+ return list
71
+ }
72
+
73
+ /**
74
+ * Returns the directory path for constructors.
75
+ *
76
+ * Возвращает путь к директории конструкторов.
77
+ */
35
78
  protected getDir(): string[] {
36
79
  return [
37
80
  PropertiesFile.getRoot(),
@@ -39,4 +82,16 @@ export class DesignConstructors {
39
82
  UI_DIR_CONSTRUCTOR
40
83
  ]
41
84
  }
85
+
86
+ /**
87
+ * Generates a common style file.
88
+ *
89
+ * Генерирует общий файл стилей.
90
+ */
91
+ protected makeStyle(): void {
92
+ const path: string[] = [...UI_DIRS_LIBRARY, UI_FILE_STYLE_SCSS]
93
+ const styles = this.getComponentsStyle()
94
+
95
+ PropertiesFile.writeByPath(path, styles.join('\r\n'))
96
+ }
42
97
  }