Skip to content

Commit 795f64b

Browse files
committedJan 29, 2023
chore: update sync scripts
·
v4.0.1v3.6.5
1 parent 9a758d2 commit 795f64b

File tree

4 files changed

+1738
-13472
lines changed

4 files changed

+1738
-13472
lines changed
 

‎jest.config.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
module.exports = {
1+
/** @type {import('jest').Config} */
2+
const config = {
23
preset: '@opd/jest-preset-pangu',
34
setupFiles: [
45
'jest-canvas-mock',
56
'./__tests__/setups/worker.js',
67
'./__tests__/setups/url.js',
78
],
8-
transformIgnorePatterns: ['/node_modules/'],
9+
transformIgnorePatterns: ['/node_modules/!d3-*'],
910
collectCoverageFrom: ['./src/**/*.{ts,tsx}', '!./**/*.d.ts'],
1011
testEnvironment: 'jsdom',
1112
}
13+
14+
module.exports = config

‎package-lock.json‎

Lines changed: 1707 additions & 13447 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"preversion": "npm run build",
4242
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
4343
"postversion": "npm publish",
44-
"sync": "ts-node --project tsconfig.sync.json ./scripts/sync.ts",
44+
"sync": "node ./scripts/sync.js",
4545
"postinstall": "node ./scripts/postinstall.js",
4646
"prepare": "husky install"
4747
},
@@ -92,7 +92,7 @@
9292
"eslint-plugin-prettier": "^4.0.0",
9393
"eslint-plugin-promise": "^6.0.0",
9494
"eslint-plugin-vue": "^9.0.0",
95-
"husky": "8.0.2",
95+
"husky": "^8.0.3",
9696
"jest-canvas-mock": "^2.3.0",
9797
"lint-staged": "^13.0.0",
9898
"lodash": "^4.17.20",

‎scripts/sync.ts‎ renamed to ‎scripts/sync.js‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
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')
88

99
const mkdir = promisify(fs.mkdir)
1010
const writeFile = promisify(fs.writeFile)
1111
const readFile = promisify(fs.readFile)
1212

1313
const eslint = new ESLint({
1414
extensions: ['.tsx'],
15-
baseConfig: eslintConfig as any,
15+
baseConfig: eslintConfig,
1616
fix: true,
1717
})
1818

19+
const g2PlotDir = path.resolve(
20+
process.cwd(),
21+
'node_modules/@antv/g2plot/src/plots'
22+
)
1923
const plotDir = path.resolve(process.cwd(), 'src/plots')
2024
const testDir = path.resolve(process.cwd(), '__tests__/plots')
2125
const exportPath = path.resolve(process.cwd(), 'src/index.ts')
2226

23-
const { Plot } = g2plot
27+
const plotNames = fs
28+
.readdirSync(g2PlotDir)
29+
.filter((dir) => !dir.startsWith('_'))
30+
.map((dir) => upperFirst(camelCase(dir)))
2431

25-
const newCharts: string[] = []
32+
const newCharts = []
2633

27-
Object.entries(g2plot).forEach(([chartName, module]: [string, any]) => {
34+
plotNames.forEach((chartName) => {
2835
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)
3740
}
3841
} catch (error) {}
3942
})
4043

41-
const lintAndFixFileContent = async (fileContent: string, filePath: string) => {
44+
const lintAndFixFileContent = async (fileContent, filePath) => {
4245
const lintResult = await eslint.lintText(fileContent, {
4346
filePath,
4447
})
@@ -48,7 +51,7 @@ const lintAndFixFileContent = async (fileContent: string, filePath: string) => {
4851
return output || fileContent
4952
}
5053

51-
const getChartConfig = (chart: string) => {
54+
const getChartConfig = (chart) => {
5255
return {
5356
cmpName: `${chart}Chart`,
5457
cmpPath: kebabCase(chart),

1 commit comments

Comments
 (1)

vercel[bot] commented on Jan 29, 2023

@vercel[bot]
Please sign in to comment.