bmdl-sdk 0.0.2 → 1.1.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 +136 -2
- package/bmdl-sdk-1.1.0.tgz +0 -0
- package/package.json +20 -39
- package/templates/App.tsx +11 -0
- package/templates/config.ts +13 -0
- package/templates/dataOptions.ts +5 -0
- package/templates/viewOptions.ts +5 -0
- package/{src/types → types}/index.ts +7 -12
- package/bmdl-sdk-0.0.2.tgz +0 -0
- package/dist/config.json +0 -13
- package/dist/index.js +0 -2
- package/dist/sdk.zip +0 -0
- package/dist/viewOptions.json +0 -57
- package/scripts/postbuild.js +0 -81
- package/src/app/App.js +0 -79
- package/src/app/App.tsx +0 -124
- package/src/config.js +0 -17
- package/src/config.ts +0 -13
- package/src/dataOptions.js +0 -42
- package/src/dataOptions.ts +0 -45
- package/src/index.js +0 -79
- package/src/index.ts +0 -101
- package/src/main.js +0 -7
- package/src/main.tsx +0 -4
- package/src/types/custom.js +0 -20
- package/src/types/custom.ts +0 -17
- package/src/types/index.js +0 -21
- package/src/viewOptions.js +0 -79
- package/src/viewOptions.ts +0 -68
- package/vite.config.js +0 -46
- package/vite.config.ts +0 -44
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
|
-
|
|
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,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bmdl-sdk",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
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.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"react": "^19.2.7",
|
|
14
|
+
"react-dom": "^19.2.7"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/react": "^19.2.17",
|
|
18
|
+
"@types/react-dom": "^19.2.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
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
|
-
|
|
84
|
-
[key: string]: any
|
|
85
|
-
}
|
|
83
|
+
////////////////////////
|
|
86
84
|
|
|
87
85
|
export interface ComponentProps {
|
|
88
|
-
dataOptions
|
|
89
|
-
viewOptions
|
|
90
|
-
data?: ChartData[]
|
|
91
|
-
locale?: Locale
|
|
92
|
-
onError?: (error: Error) => void
|
|
86
|
+
dataOptions: DataOptions
|
|
87
|
+
viewOptions: ViewOptions
|
|
93
88
|
}
|
package/bmdl-sdk-0.0.2.tgz
DELETED
|
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
|
-
}
|