@dxtmisha/scripts 0.5.0 → 0.5.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.
- package/package.json +1 -1
- package/src/classes/Package/PackageItem.ts +144 -2
- package/src/classes/Properties/PropertiesConfig.ts +9 -0
- package/src/library-ai.ts +1 -0
- package/src/library.ts +30 -18
- package/src/media/templates/packages/library/design.config.json +3 -0
- package/src/types/configTypes.ts +3 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/scripts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.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": [
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
import requirePath from 'path'
|
|
4
4
|
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
5
5
|
|
|
6
|
-
import { UI_FILE_PACKAGE } from '../../config'
|
|
6
|
+
import { UI_DIR_PACKAGES, UI_DIRS_LIBRARY, UI_FILE_PACKAGE } from '../../config'
|
|
7
|
+
import { PropertiesConfig } from '../Properties/PropertiesConfig.ts'
|
|
7
8
|
|
|
8
9
|
const DIR_SAMPLE = [__dirname, '..', '..', 'media', 'templates', 'packages']
|
|
10
|
+
const DIR_STORYBOOK = [
|
|
11
|
+
UI_DIR_PACKAGES,
|
|
12
|
+
'storybook',
|
|
13
|
+
'.storybook',
|
|
14
|
+
'main.ts'
|
|
15
|
+
]
|
|
9
16
|
|
|
10
17
|
type PackageInitItemFile = {
|
|
11
18
|
file: string
|
|
@@ -41,6 +48,12 @@ export class PackageInitItem {
|
|
|
41
48
|
]
|
|
42
49
|
.forEach((item) => {
|
|
43
50
|
this.writeFile(item.file, item.content)
|
|
51
|
+
|
|
52
|
+
if (item.path.endsWith('library.ts')) {
|
|
53
|
+
this.makeLibrary()
|
|
54
|
+
.makePackage()
|
|
55
|
+
.makeStorybook()
|
|
56
|
+
}
|
|
44
57
|
})
|
|
45
58
|
}
|
|
46
59
|
|
|
@@ -101,15 +114,39 @@ export class PackageInitItem {
|
|
|
101
114
|
return data
|
|
102
115
|
}
|
|
103
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Gets normalized package name by replacing path separators.
|
|
119
|
+
*
|
|
120
|
+
* Получает нормализованное имя пакета, заменяя разделители путей.
|
|
121
|
+
*/
|
|
122
|
+
protected getName(): string {
|
|
123
|
+
return this.name.replace(requirePath.sep, '/')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Gets package code by replacing path separators with hyphens.
|
|
128
|
+
*
|
|
129
|
+
* Получает код пакета, заменяя разделители путей на дефисы.
|
|
130
|
+
*/
|
|
131
|
+
protected getCode(): string {
|
|
132
|
+
return this.getName().replace('/', '-')
|
|
133
|
+
}
|
|
134
|
+
|
|
104
135
|
/**
|
|
105
136
|
* Reads project name from package.json.
|
|
106
137
|
*
|
|
107
138
|
* Читает имя проекта из package.json.
|
|
108
139
|
*/
|
|
109
140
|
protected getProjectName(): string {
|
|
141
|
+
const name = this.getName()
|
|
142
|
+
const packagePrefix = PropertiesConfig.getPackagePrefix()
|
|
143
|
+
|
|
144
|
+
if (packagePrefix) {
|
|
145
|
+
return `${packagePrefix}/${name}`
|
|
146
|
+
}
|
|
147
|
+
|
|
110
148
|
const mainName = String(this.readPackage()?.name)
|
|
111
149
|
const code = mainName.split('/')?.[0] ?? mainName
|
|
112
|
-
const name = this.name.replace(requirePath.sep, '/')
|
|
113
150
|
|
|
114
151
|
return `${code}/${name}`
|
|
115
152
|
}
|
|
@@ -137,4 +174,109 @@ export class PackageInitItem {
|
|
|
137
174
|
PropertiesFile.writeByPath(path, contentEdit)
|
|
138
175
|
PropertiesFile.chmod(path)
|
|
139
176
|
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generates a library file for the package.
|
|
180
|
+
*
|
|
181
|
+
* Генерирует файл библиотеки для пакета.
|
|
182
|
+
*/
|
|
183
|
+
protected makeLibrary(): this {
|
|
184
|
+
const name = this.getCode() + '.ts'
|
|
185
|
+
const path: string[] = [...UI_DIRS_LIBRARY, name]
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
PropertiesFile.is(UI_DIRS_LIBRARY)
|
|
189
|
+
&& !PropertiesFile.is(path)
|
|
190
|
+
) {
|
|
191
|
+
console.log('Generate library...')
|
|
192
|
+
|
|
193
|
+
PropertiesFile.writeByPath(path, `export * from '${this.getProjectName()}'
|
|
194
|
+
`
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Updates package.json to include the new package.
|
|
203
|
+
*
|
|
204
|
+
* Обновляет package.json для включения нового пакета.
|
|
205
|
+
*/
|
|
206
|
+
protected makePackage(): this {
|
|
207
|
+
let packageFile = PropertiesFile.readFileOnly(UI_FILE_PACKAGE)
|
|
208
|
+
const name = this.getCode()
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
packageFile
|
|
212
|
+
&& !packageFile.match(new RegExp(`["']${this.getProjectName()}["']`))
|
|
213
|
+
) {
|
|
214
|
+
let edit = false
|
|
215
|
+
|
|
216
|
+
if (
|
|
217
|
+
packageFile.match(/["']devDependencies["']/)
|
|
218
|
+
) {
|
|
219
|
+
console.log('Update package.json: devDependencies...')
|
|
220
|
+
|
|
221
|
+
edit = true
|
|
222
|
+
packageFile = packageFile.replace(
|
|
223
|
+
/(["']devDependencies["']:[^{]+{)/,
|
|
224
|
+
`$1
|
|
225
|
+
"${this.getProjectName()}": "workspace:*",`
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (
|
|
230
|
+
packageFile.match(/["']exports["']/)
|
|
231
|
+
) {
|
|
232
|
+
console.log('Update package.json: exports...')
|
|
233
|
+
|
|
234
|
+
edit = true
|
|
235
|
+
packageFile = packageFile.replace(
|
|
236
|
+
/(["']exports["']:[^{]+{)/,
|
|
237
|
+
`$1
|
|
238
|
+
"./${name}": {
|
|
239
|
+
"import": "./dist/${name}.js",
|
|
240
|
+
"types": "./dist/${name}.d.ts"
|
|
241
|
+
},`
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (edit) {
|
|
246
|
+
PropertiesFile.writeByPath(UI_FILE_PACKAGE, packageFile)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Updates Storybook configuration to include the new package stories.
|
|
255
|
+
*
|
|
256
|
+
* Обновляет конфигурацию Storybook для включения историй нового пакета.
|
|
257
|
+
*/
|
|
258
|
+
makeStorybook(): this {
|
|
259
|
+
if (PropertiesFile.is(DIR_STORYBOOK)) {
|
|
260
|
+
let storybook = PropertiesFile.readFileOnly(DIR_STORYBOOK)
|
|
261
|
+
const name = this.getCode()
|
|
262
|
+
|
|
263
|
+
if (
|
|
264
|
+
storybook
|
|
265
|
+
&& !storybook.match(`/${name}/src/`)
|
|
266
|
+
) {
|
|
267
|
+
console.log('Update storybook...')
|
|
268
|
+
|
|
269
|
+
storybook = storybook.replace(
|
|
270
|
+
/(stories: \[)/,
|
|
271
|
+
`$1
|
|
272
|
+
'../../${name}/src/**/*.mdx',
|
|
273
|
+
'../../${name}/src/**/*.stories.@(js|jsx|mjs|ts|tsx)',`
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
PropertiesFile.writeByPath(DIR_STORYBOOK, storybook)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return this
|
|
281
|
+
}
|
|
140
282
|
}
|
|
@@ -73,6 +73,15 @@ export class PropertiesConfig {
|
|
|
73
73
|
return this.config.wikiLanguage ?? 'en'
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Returns the package prefix.
|
|
78
|
+
*
|
|
79
|
+
* Возвращает префикс пакета.
|
|
80
|
+
*/
|
|
81
|
+
static getPackagePrefix(): string | undefined {
|
|
82
|
+
return this.config.packagePrefix ?? undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
76
85
|
/**
|
|
77
86
|
* Returns the AI type.
|
|
78
87
|
*
|
package/src/library-ai.ts
CHANGED
package/src/library.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
// Classes
|
|
2
|
-
export * from './classes/Ai/AiAbstract'
|
|
3
|
-
export * from './classes/Ai/
|
|
4
|
-
export * from './classes/Ai/
|
|
5
|
-
export * from './classes/
|
|
6
|
-
export * from './classes/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export * from './
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export * from './
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
// Classes
|
|
2
|
+
export * from './classes/Ai/AiAbstract'
|
|
3
|
+
export * from './classes/Ai/AiDoc'
|
|
4
|
+
export * from './classes/Ai/AiDocItem'
|
|
5
|
+
export * from './classes/Ai/AiDocItemAbstract'
|
|
6
|
+
export * from './classes/Ai/AiDocItemClasses'
|
|
7
|
+
export * from './classes/Ai/AiDocItemComposables'
|
|
8
|
+
export * from './classes/Ai/AiDocType'
|
|
9
|
+
export * from './classes/Ai/AiGoogle'
|
|
10
|
+
export * from './classes/Ai/AiGoogleCli'
|
|
11
|
+
export * from './classes/Ai/AiGoogleCliLite'
|
|
12
|
+
export * from './classes/Ai/AiGoogleLite'
|
|
13
|
+
export * from './classes/BuildItem'
|
|
14
|
+
export * from './classes/Design/DesignTypescript'
|
|
15
|
+
export * from './classes/Git/GitRead'
|
|
16
|
+
export * from './classes/Properties/PropertiesFile'
|
|
17
|
+
|
|
18
|
+
// Composables
|
|
19
|
+
export * from './composables/useAi'
|
|
20
|
+
|
|
21
|
+
// Functions
|
|
22
|
+
export * from './functions/getConfigAi'
|
|
23
|
+
|
|
24
|
+
// Types
|
|
25
|
+
export * from './types/aiTypes'
|
|
26
|
+
export * from './types/configTypes'
|
|
27
|
+
export * from './types/designTypes'
|
|
28
|
+
export * from './types/gitTypes'
|
|
29
|
+
export * from './types/libraryTypes'
|
|
30
|
+
export * from './types/propertyTypes'
|
package/src/types/configTypes.ts
CHANGED
|
@@ -33,6 +33,9 @@ export type DesignUiConfig = {
|
|
|
33
33
|
/** Wiki language / Язык wiki */
|
|
34
34
|
wikiLanguage?: string
|
|
35
35
|
|
|
36
|
+
/** Package prefix for generating package names / Префикс пакета для генерации названий пакетов */
|
|
37
|
+
packagePrefix?: string
|
|
38
|
+
|
|
36
39
|
/** AI type for generating content / Тип ИИ для генерации контента */
|
|
37
40
|
aiType?: 'gemini'
|
|
38
41
|
|