bmdl-sdk 0.0.2 → 1.2.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/bin/cli.js CHANGED
@@ -1,4 +1,138 @@
1
1
  #!/usr/bin/env node
2
- import { cli } from '../dist/index.js'
3
2
 
4
- cli()
3
+ import {
4
+ copyFileSync,
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ writeFileSync,
9
+ } from 'fs'
10
+ import { dirname, resolve } from 'path'
11
+ import { fileURLToPath } from 'url'
12
+
13
+ const __dirname = dirname(fileURLToPath(import.meta.url))
14
+ const command = process.argv[2]
15
+
16
+ // Функция инициализации проекта
17
+ function initProject() {
18
+ console.log('📦 Initializing new component project...')
19
+
20
+ const projectRoot = process.cwd()
21
+ const templatesDir = resolve(__dirname, '../templates')
22
+
23
+ const packageJsonPath = resolve(projectRoot, 'package.json')
24
+ if (!existsSync(packageJsonPath)) {
25
+ console.error('❌ No package.json found. Run "npm init -y" first.')
26
+ process.exit(1)
27
+ }
28
+
29
+ const srcDir = resolve(projectRoot, 'src')
30
+ const appDir = resolve(srcDir, 'App')
31
+ const publicDir = resolve(projectRoot, 'public')
32
+
33
+ ;[srcDir, appDir, publicDir].forEach(dir => {
34
+ if (!existsSync(dir)) {
35
+ mkdirSync(dir, { recursive: true })
36
+ console.log(`📁 Created ${dir}`)
37
+ }
38
+ })
39
+
40
+ const templateFiles = {
41
+ 'src/App/App.tsx': 'App.tsx',
42
+ 'src/config.ts': 'config.ts',
43
+ 'src/dataOptions.ts': 'dataOptions.ts',
44
+ 'src/viewOptions.ts': 'viewOptions.ts',
45
+ 'public/icon.svg': 'icon.svg',
46
+ }
47
+
48
+ for (const [dest, template] of Object.entries(templateFiles)) {
49
+ const destPath = resolve(projectRoot, dest)
50
+ const templatePath = resolve(templatesDir, template)
51
+
52
+ if (existsSync(templatePath) && !existsSync(destPath)) {
53
+ copyFileSync(templatePath, destPath)
54
+ }
55
+ }
56
+
57
+ updatePackageJson(projectRoot)
58
+
59
+ console.log('✅ Project initialized successfully!')
60
+ console.log('\nNext steps:')
61
+ console.log(' 1. yarn install')
62
+ console.log(' 2. yarn run dev')
63
+ }
64
+
65
+ //////
66
+
67
+ function updatePackageJson(projectRoot) {
68
+ const packageJsonPath = resolve(projectRoot, 'package.json')
69
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
70
+
71
+ packageJson.scripts = {
72
+ dev: 'bmdl-sdk dev',
73
+ build: 'bmdl-sdk build',
74
+ }
75
+
76
+ // const devDependencies = {
77
+ // "@types/react": "^18.2.0",
78
+ // "@types/react-dom": "^18.2.0",
79
+ // "@vitejs/plugin-react": "^4.0.0",
80
+ // "typescript": "^5.0.0",
81
+ // "vite": "^4.0.0"
82
+ // }
83
+
84
+ // const dependencies = {
85
+ // "react": "^18.2.0",
86
+ // "react-dom": "^18.2.0"
87
+ // }
88
+
89
+ // packageJson.devDependencies = {
90
+ // ...packageJson.devDependencies,
91
+ // ...devDependencies
92
+ // }
93
+
94
+ // packageJson.dependencies = {
95
+ // ...packageJson.dependencies,
96
+ // ...dependencies
97
+ // }
98
+
99
+ // if (!packageJson.devDependencies?.['bmdl-sdk']) {
100
+ // packageJson.devDependencies = {
101
+ // ...packageJson.devDependencies,
102
+ // 'bmdl-sdk': 'latest'
103
+ // }
104
+ // }
105
+
106
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
107
+ }
108
+
109
+ async function runCommand(command) {
110
+ switch (command) {
111
+ case 'init':
112
+ initProject()
113
+ break
114
+ case 'dev':
115
+ await import('./dev.js')
116
+ break
117
+ case 'build':
118
+ await import('./build.js')
119
+ break
120
+ default:
121
+ console.log(`
122
+ Usage:
123
+ bmdl-sdk init - Initialize new widget project
124
+ bmdl-sdk dev - Start development server
125
+ bmdl-sdk build - Build widget for production
126
+
127
+ Example:
128
+ mkdir my-component
129
+ cd my-component
130
+ npm init -y
131
+ npx bmdl-sdk init
132
+ yarn install
133
+ yarn run dev
134
+ `)
135
+ }
136
+ }
137
+
138
+ runCommand(command)
Binary file
package/package.json CHANGED
@@ -1,39 +1,23 @@
1
- {
2
- "name": "bmdl-sdk",
3
- "private": false,
4
- "version": "0.0.2",
5
- "type": "module",
6
- "bin": {
7
- "bmdl-sdk": "./bin/cli.js"
8
- },
9
- "scripts": {
10
- "dev": "vite",
11
- "build": "tsc && vite build",
12
- "preview": "vite preview",
13
- "build:component": "vite build && tsx scripts/postbuild.js"
14
- },
15
- "dependencies": {
16
- "adm-zip": "^0.5.16",
17
- "echarts": "^6.0.0",
18
- "echarts-for-react": "^3.0.5",
19
- "react": "^19.2.0",
20
- "react-dom": "^19.2.0",
21
- "teaser": "^0.1.1",
22
- "tsx": "^4.22.4"
23
- },
24
- "devDependencies": {
25
- "@eslint/js": "^9.39.1",
26
- "@types/node": "^24.10.1",
27
- "@types/react": "^19.2.5",
28
- "@types/react-dom": "^19.2.3",
29
- "@types/terser": "^3.12.0",
30
- "@vitejs/plugin-react": "^5.1.1",
31
- "eslint": "^9.39.1",
32
- "eslint-plugin-react-hooks": "^7.0.1",
33
- "eslint-plugin-react-refresh": "^0.4.24",
34
- "globals": "^16.5.0",
35
- "typescript": "~5.9.3",
36
- "typescript-eslint": "^8.46.4",
37
- "vite": "^7.2.4"
38
- }
39
- }
1
+ {
2
+ "name": "bmdl-sdk",
3
+ "version": "1.2.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "bmdl-sdk": "./bin/cli.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "react": "^19.2.7",
17
+ "react-dom": "^19.2.7"
18
+ },
19
+ "devDependencies": {
20
+ "@types/react": "^19.2.17",
21
+ "@types/react-dom": "^19.2.3"
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { ComponentProps } from '../types'
3
+
4
+ const NameComponent: React.FC<ComponentProps> = ({
5
+ dataOptions,
6
+ viewOptions,
7
+ }) => {
8
+ return <div>NameComponent</div>
9
+ }
10
+
11
+ export default NameComponent
@@ -0,0 +1,13 @@
1
+ import packageJson from '../package.json'
2
+ import { Config } from '../types'
3
+
4
+ export const config: Config = {
5
+ label: {
6
+ ru: 'NameComponent',
7
+ en: 'NameComponent',
8
+ },
9
+ categories: [],
10
+ icon: 'icon.svg',
11
+ preview: 'preview.webp',
12
+ version: packageJson.version,
13
+ }
@@ -0,0 +1,5 @@
1
+ import { CreateDataOptions } from '../types'
2
+
3
+ export const createDataOptions: CreateDataOptions = () => {
4
+ return []
5
+ }
@@ -0,0 +1,5 @@
1
+ import { CreateViewOptions } from '../types'
2
+
3
+ export const createViewOptions: CreateViewOptions = () => {
4
+ return []
5
+ }
@@ -1,5 +1,3 @@
1
- export type Locale = 'ru' | 'en'
2
-
3
1
  export interface LocalizedText {
4
2
  ru: string
5
3
  en: string
@@ -9,10 +7,12 @@ export interface Config {
9
7
  label: LocalizedText
10
8
  categories: string[]
11
9
  icon: string
12
- preview: string
10
+ preview?: string
13
11
  version: string
14
12
  }
15
13
 
14
+ ////////////////////////
15
+
16
16
  export enum ColumnType {
17
17
  String = 'string',
18
18
  Number = 'number',
@@ -43,7 +43,7 @@ export interface DataBlock {
43
43
  export type DataOptions = DataBlock[]
44
44
  export type CreateDataOptions = () => DataOptions
45
45
 
46
- ///////////////////
46
+ ////////////////////////
47
47
 
48
48
  export interface ViewOptionBase {
49
49
  key: string
@@ -80,14 +80,9 @@ export type ViewOption = CheckboxOption | SelectOption | InputOption
80
80
  export type ViewOptions = Array<ViewOption | GroupOption>
81
81
  export type CreateViewOptions = () => ViewOptions
82
82
 
83
- export interface ChartData {
84
- [key: string]: any
85
- }
83
+ ////////////////////////
86
84
 
87
85
  export interface ComponentProps {
88
- dataOptions?: DataOptions
89
- viewOptions?: ViewOptions
90
- data?: ChartData[]
91
- locale?: Locale
92
- onError?: (error: Error) => void
86
+ dataOptions: DataOptions
87
+ viewOptions: ViewOptions
93
88
  }
Binary file
package/dist/config.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "label": {
3
- "ru": "Комбинированная диаграмма: Cтолбчатая и Линейная (UX)",
4
- "en": "Combo Chart: Bar and Line (UX)"
5
- },
6
- "categories": [
7
- "compare",
8
- "distribution"
9
- ],
10
- "icon": "icon.svg",
11
- "preview": "preview.webp",
12
- "version": "0.0.2"
13
- }