@dxtmisha/scripts 0.5.18 → 0.5.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/scripts",
3
3
  "private": false,
4
- "version": "0.5.18",
4
+ "version": "0.5.20",
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": [
@@ -1,8 +1,14 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
1
4
  import { AiDocItemAbstract } from './AiDocItemAbstract'
2
- import { getDirname } from '../../functions/getDirname'
5
+
6
+ const dirnamePath = hasNativeDirname()
7
+ ? __dirname
8
+ : dirname(fileURLToPath(import.meta.url))
3
9
 
4
10
  /** Sample prompt template path / Путь к шаблону промпта */
5
- const FILE_PROMPT_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'prompts']
11
+ const FILE_PROMPT_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'prompts']
6
12
 
7
13
  /** Sample prompt template path for functions / Путь к шаблону промпта для функций */
8
14
  const FILE_PROMPT_SAMPLE_ITEM = [...FILE_PROMPT_SAMPLE, 'aiDocFunctionPrompt.en.txt']
@@ -1,8 +1,14 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
1
4
  import { AiDocItemAbstract } from './AiDocItemAbstract'
2
- import { getDirname } from '../../functions/getDirname'
5
+
6
+ const dirnamePath = hasNativeDirname()
7
+ ? __dirname
8
+ : dirname(fileURLToPath(import.meta.url))
3
9
 
4
10
  /** Sample prompt template path / Путь к шаблону промпта */
5
- const FILE_PROMPT_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'prompts']
11
+ const FILE_PROMPT_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'prompts']
6
12
 
7
13
  /** Sample prompt template for classes / Шаблон промпта для классов */
8
14
  const FILE_PROMPT_SAMPLE_CLASS = [...FILE_PROMPT_SAMPLE, 'aiDocClassPrompt.en.txt']
@@ -1,8 +1,14 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
1
4
  import { AiDocItemAbstract } from './AiDocItemAbstract'
2
- import { getDirname } from '../../functions/getDirname'
5
+
6
+ const dirnamePath = hasNativeDirname()
7
+ ? __dirname
8
+ : dirname(fileURLToPath(import.meta.url))
3
9
 
4
10
  /** Sample prompt template path / Путь к шаблону промпта */
5
- const FILE_PROMPT_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'prompts']
11
+ const FILE_PROMPT_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'prompts']
6
12
 
7
13
  const FILE_PROMPT_SAMPLE_COMPOSABLE = [...FILE_PROMPT_SAMPLE, 'aiDocComposablePrompt.en.txt']
8
14
 
@@ -1,14 +1,20 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
1
3
  import { promisify } from 'node:util'
2
4
  import { exec } from 'node:child_process'
3
- import { getDirname } from '../functions/getDirname'
5
+ import { hasNativeDirname } from '../functions/hasNativeDirname'
4
6
 
5
7
  import { PropertiesFile } from './Properties/PropertiesFile'
6
8
  import { ComponentWikiFile } from './Component/ComponentWikiFile'
7
9
 
8
10
  import { UI_DIR_DIST_TEMPORARY, UI_FILE_NAME_VITE, UI_FILE_NAME_VITE_WORKERS } from '../config'
9
11
 
12
+ const dirnamePath = hasNativeDirname()
13
+ ? __dirname
14
+ : dirname(fileURLToPath(import.meta.url))
15
+
10
16
  /** Template vite config file path / Путь к файлу шаблона vite-конфига */
11
- const FILE_VITE_SAMPLE = [getDirname(), '..', 'media', 'templates', 'viteComponentTemplateConfig.ts']
17
+ const FILE_VITE_SAMPLE = [dirnamePath, '..', 'media', 'templates', 'viteComponentTemplateConfig.ts']
12
18
 
13
19
  /** Async exec wrapper / Обёртка для асинхронного exec */
14
20
  const execAsync = promisify(exec)
@@ -1,14 +1,20 @@
1
1
  // export:none
2
2
 
3
+ import { dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
3
5
  import { toKebabCase } from '@dxtmisha/functional-basic'
4
6
  import { getComponentPaths } from '../../functions/getComponentPaths'
5
- import { getDirname } from '../../functions/getDirname'
7
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
6
8
 
7
9
  import { PropertiesFile } from '../Properties/PropertiesFile'
8
10
 
9
11
  import { UI_FILE_PACKAGE } from '../../config'
10
12
 
11
- const DIR_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'componentDoc']
13
+ const dirnamePath = hasNativeDirname()
14
+ ? __dirname
15
+ : dirname(fileURLToPath(import.meta.url))
16
+
17
+ const DIR_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'componentDoc']
12
18
 
13
19
  /**
14
20
  * Class for creating component files from templates.
@@ -1,9 +1,12 @@
1
1
  // export:none
2
2
 
3
- import { getDirname } from '../../functions/getDirname'
4
3
  import { getNameDirByPaths } from '../../functions/getNameDirByPaths'
5
4
  import { useAi } from '../../composables/useAi'
6
5
 
6
+ import { dirname } from 'node:path'
7
+ import { fileURLToPath } from 'node:url'
8
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
9
+
7
10
  import { PropertiesConfig } from '../Properties/PropertiesConfig'
8
11
  import { BuildItem } from '../BuildItem'
9
12
  import { ComponentWikiFile } from './ComponentWikiFile'
@@ -16,8 +19,12 @@ import {
16
19
  UI_DIRS_COMPONENTS
17
20
  } from '../../config'
18
21
 
22
+ const dirnamePath = hasNativeDirname()
23
+ ? __dirname
24
+ : dirname(fileURLToPath(import.meta.url))
25
+
19
26
  /** Sample templates directory / Директория с шаблонами */
20
- const DIR_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'prompts']
27
+ const DIR_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'prompts']
21
28
  /** Sample AI prompt template path / Путь к шаблону AI-промпта */
22
29
  const FILE_PROMPT_SAMPLE = [...DIR_SAMPLE, 'componentPrompt.en.txt']
23
30
  /** Sample demo component MDX path / Путь к MDX демо-компоненту */
@@ -1,7 +1,9 @@
1
1
  // export:none
2
2
 
3
+ import { dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
3
5
  import { toArray } from '@dxtmisha/functional-basic'
4
- import { getDirname } from '../../functions/getDirname'
6
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
5
7
 
6
8
  import { PropertiesConfig } from '../Properties/PropertiesConfig'
7
9
  import { PropertiesFile } from '../Properties/PropertiesFile'
@@ -10,7 +12,11 @@ import { DesignReplace } from './DesignReplace'
10
12
 
11
13
  import { UI_KEY_CONSTRUCTOR } from '../../config'
12
14
 
13
- const DIR_SAMPLE = [getDirname(), '..', '..', 'media', 'templates']
15
+ const dirnamePath = hasNativeDirname()
16
+ ? __dirname
17
+ : dirname(fileURLToPath(import.meta.url))
18
+
19
+ const DIR_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates']
14
20
 
15
21
  /**
16
22
  * Base abstract class for generating script files.
@@ -37,7 +37,7 @@ export class PackageInit {
37
37
  * Возвращает массив имен директорий для инициализации пакета.
38
38
  */
39
39
  protected getDirs(): string[] {
40
- return PropertiesFile.readDirOnlyRecursive(UI_DIR_PACKAGES)
40
+ return PropertiesFile.readDir(UI_DIR_PACKAGES)
41
41
  .filter(
42
42
  path => PropertiesFile.readDir([UI_DIR_PACKAGES, path]).length === 0
43
43
  )
@@ -1,13 +1,19 @@
1
1
  // export:none
2
2
 
3
3
  import requirePath from 'node:path'
4
- import { getDirname } from '../../functions/getDirname'
4
+ import { fileURLToPath } from 'node:url'
5
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
6
+
5
7
  import { PropertiesConfig } from '../Properties/PropertiesConfig'
6
8
  import { PropertiesFile } from '../Properties/PropertiesFile'
7
9
 
8
10
  import { UI_DIR_PACKAGES, UI_DIRS_LIBRARY, UI_FILE_PACKAGE } from '../../config'
9
11
 
10
- const DIR_SAMPLE = [getDirname(), '..', '..', 'media', 'templates', 'packages']
12
+ const dirnamePath = hasNativeDirname()
13
+ ? __dirname
14
+ : requirePath.dirname(fileURLToPath(import.meta.url))
15
+
16
+ const DIR_SAMPLE = [dirnamePath, '..', '..', 'media', 'templates', 'packages']
11
17
  const DIR_STORYBOOK = [
12
18
  UI_DIR_PACKAGES,
13
19
  'storybook',
@@ -119,6 +125,7 @@ export class PackageInitItem {
119
125
  */
120
126
  protected getFileByList(dir: string[]): PackageInitItemFile[] {
121
127
  const list = PropertiesFile.readDirRecursive(dir)
128
+
122
129
  const data: PackageInitItemFile[] = []
123
130
 
124
131
  list.forEach((item) => {
@@ -1,13 +1,16 @@
1
+ import requireFs from 'node:fs'
2
+ import requirePath from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
1
4
  import { Datetime, forEach, toArray, toKebabCase, transformation } from '@dxtmisha/functional-basic'
2
- import { getDirname } from '../../functions/getDirname'
5
+ import { hasNativeDirname } from '../../functions/hasNativeDirname'
3
6
 
4
- import requireFs from 'fs'
5
- import requirePath from 'path'
6
7
  import { UI_FILE_INDEX, UI_MODULES, UI_PROJECT_NAME } from '../../config'
7
8
 
8
9
  export type PropertiesFilePath = string | string[]
9
10
  export type PropertiesFileValue<T = any> = string | Record<string, T>
10
11
 
12
+ const dirnamePath = hasNativeDirname() ? __dirname : requirePath.dirname(fileURLToPath(import.meta.url))
13
+
11
14
  /**
12
15
  * A class for working with files.
13
16
  *
@@ -127,7 +130,7 @@ export class PropertiesFile {
127
130
  }
128
131
 
129
132
  static getDirname(): string {
130
- return getDirname()
133
+ return dirnamePath
131
134
  }
132
135
 
133
136
  /**
@@ -317,7 +320,7 @@ export class PropertiesFile {
317
320
  const data: string[] = []
318
321
 
319
322
  dirs.forEach((dir) => {
320
- const paths = [...path, dir]
323
+ const paths = [...toArray(path), dir]
321
324
  const fullPaths = [...fullPath, dir]
322
325
 
323
326
  data.push(this.joinPath(fullPaths))
@@ -517,7 +520,7 @@ export class PropertiesFile {
517
520
  }
518
521
 
519
522
  static {
520
- this.module = Boolean(getDirname().match('node_modules'))
523
+ this.module = Boolean(dirnamePath.match('node_modules'))
521
524
  this.root = process.cwd()
522
525
  }
523
526
  }
@@ -1,7 +1,9 @@
1
1
  // export:none
2
2
 
3
+ import { dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
3
5
  import { forEach } from '@dxtmisha/functional-basic'
4
- import { getDirname } from './getDirname'
6
+ import { hasNativeDirname } from './hasNativeDirname'
5
7
 
6
8
  import { PropertiesFile } from '../classes/Properties/PropertiesFile'
7
9
  import type { PropertyItem, PropertyList } from '../types/propertyTypes'
@@ -18,7 +20,9 @@ export const getConstructorProperties = (names: string[]): PropertyList => {
18
20
  const data: PropertyList = {}
19
21
 
20
22
  try {
21
- const dir = getDirname()
23
+ const dir = hasNativeDirname()
24
+ ? __dirname
25
+ : dirname(fileURLToPath(import.meta.url))
22
26
 
23
27
  forEach(
24
28
  names,