1
- import * as g2plot from '@antv/g2plot'
2
- import path from 'path'
3
- import fs from 'fs'
4
- import { promisify } from 'util'
5
- import { ESLint } from 'eslint'
6
- import { kebabCase } from 'lodash'
7
- import eslintConfig from '../.eslintrc.js'
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const path = require ( 'path' )
3
+ const fs = require ( 'fs' )
4
+ const { promisify } = require ( 'util' )
5
+ const { ESLint } = require ( 'eslint' )
6
+ const { kebabCase, camelCase , upperFirst } = require ( 'lodash' )
7
+ const eslintConfig = require ( '../.eslintrc' )
8
8
9
9
const mkdir = promisify ( fs . mkdir )
10
10
const writeFile = promisify ( fs . writeFile )
11
11
const readFile = promisify ( fs . readFile )
12
12
13
13
const eslint = new ESLint ( {
14
14
extensions : [ '.tsx' ] ,
15
- baseConfig : eslintConfig as any ,
15
+ baseConfig : eslintConfig ,
16
16
fix : true ,
17
17
} )
18
18
19
+ const g2PlotDir = path . resolve (
20
+ process . cwd ( ) ,
21
+ 'node_modules/@antv/g2plot/src/plots'
22
+ )
19
23
const plotDir = path . resolve ( process . cwd ( ) , 'src/plots' )
20
24
const testDir = path . resolve ( process . cwd ( ) , '__tests__/plots' )
21
25
const exportPath = path . resolve ( process . cwd ( ) , 'src/index.ts' )
22
26
23
- const { Plot } = g2plot
27
+ const plotNames = fs
28
+ . readdirSync ( g2PlotDir )
29
+ . filter ( ( dir ) => ! dir . startsWith ( '_' ) )
30
+ . map ( ( dir ) => upperFirst ( camelCase ( dir ) ) )
24
31
25
- const newCharts : string [ ] = [ ]
32
+ const newCharts = [ ]
26
33
27
- Object . entries ( g2plot ) . forEach ( ( [ chartName , module ] : [ string , any ] ) => {
34
+ plotNames . forEach ( ( chartName ) => {
28
35
try {
29
- if ( module . prototype instanceof Plot && chartName !== 'P' ) {
30
- if (
31
- ! fs . existsSync (
32
- path . resolve ( plotDir , `${ kebabCase ( chartName ) } /index.tsx` )
33
- )
34
- ) {
35
- newCharts . push ( chartName )
36
- }
36
+ if (
37
+ ! fs . existsSync ( path . resolve ( plotDir , `${ kebabCase ( chartName ) } /index.tsx` ) )
38
+ ) {
39
+ newCharts . push ( chartName )
37
40
}
38
41
} catch ( error ) { }
39
42
} )
40
43
41
- const lintAndFixFileContent = async ( fileContent : string , filePath : string ) => {
44
+ const lintAndFixFileContent = async ( fileContent , filePath ) => {
42
45
const lintResult = await eslint . lintText ( fileContent , {
43
46
filePath,
44
47
} )
@@ -48,7 +51,7 @@ const lintAndFixFileContent = async (fileContent: string, filePath: string) => {
48
51
return output || fileContent
49
52
}
50
53
51
- const getChartConfig = ( chart : string ) => {
54
+ const getChartConfig = ( chart ) => {
52
55
return {
53
56
cmpName : `${ chart } Chart` ,
54
57
cmpPath : kebabCase ( chart ) ,
1 commit comments
vercel[bot] commentedon Jan 29, 2023
Successfully deployed to the following URLs:
g2plot-vue – ./
g2plot-vue-opd.vercel.app
g2plot-vue.vercel.app
g2plot-vue-git-master-opd.vercel.app
g2plot-vue.opd.cool