This is an automated email from the ASF dual-hosted git repository. ovilia pushed a commit to branch release-dev in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 771c523e4263f018f94b838b54fa4aeade7fa2ec Author: Ovilia <zwl.s...@gmail.com> AuthorDate: Thu Jul 24 16:41:46 2025 +0800 chore: add license headers and a script of pre-commit --- .husky/pre-commit | 1 + build/addHeader.js | 61 +---------------------- build/checkHeader.js | 46 +++++++++++++++++ build/headerUtil.js | 82 +++++++++++++++++++++++++++++++ build/preamble.js | 3 +- package.json | 1 + src/chart/chord/ChordEdge.ts | 19 +++++++ src/chart/chord/ChordPiece.ts | 19 +++++++ src/chart/custom/customSeriesRegister.ts | 19 +++++++ src/chart/scatter/jitterLayout.ts | 19 +++++++ src/coord/cartesian/legacyContainLabel.ts | 19 +++++++ src/coord/matrix/MatrixDim.ts | 19 +++++++ src/core/ExtendedElement.ts | 19 +++++++ src/util/jitter.ts | 19 +++++++ src/visual/tokens.ts | 19 +++++++ test/axis-layout-0-quick-cases.js | 19 +++++++ test/bar-stack-reverse.html | 20 ++++++++ test/graph-thumbnail.html | 20 ++++++++ 18 files changed, 363 insertions(+), 61 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index e7e681f4b..ec9dcd8d8 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,3 +3,4 @@ npm run lint npm run checktype +npm run checkheader diff --git a/build/addHeader.js b/build/addHeader.js index ac948adfa..417a0d246 100644 --- a/build/addHeader.js +++ b/build/addHeader.js @@ -17,17 +17,10 @@ * under the License. */ - const fs = require('fs'); -const preamble = require('./preamble'); -const pathTool = require('path'); const chalk = require('chalk'); - -// In the `.headerignore`, each line is a pattern in RegExp. -// all relative path (based on the echarts base directory) is tested. -// The pattern should match the relative path completely. -const excludesPath = pathTool.join(__dirname, '../.headerignore'); -const ecBasePath = pathTool.join(__dirname, '../'); +const preamble = require('./preamble'); +const eachFile = require('./headerUtil').eachFile; const isVerbose = process.argv[2] === '--verbose'; @@ -128,56 +121,6 @@ function run() { console.log('\nDone.'); } -function eachFile(visit) { - - const excludePatterns = []; - const extReg = /\.([a-zA-Z0-9_-]+)$/; - - prepareExcludePatterns(); - travel('./'); - - function travel(relativePath) { - if (isExclude(relativePath)) { - return; - } - - const absolutePath = pathTool.join(ecBasePath, relativePath); - const stat = fs.statSync(absolutePath); - - if (stat.isFile()) { - visit(absolutePath, getExt(absolutePath)); - } - else if (stat.isDirectory()) { - fs.readdirSync(relativePath).forEach(function (file) { - travel(pathTool.join(relativePath, file)); - }); - } - } - - function prepareExcludePatterns() { - const content = fs.readFileSync(excludesPath, {encoding: 'utf-8'}); - content.replace(/\r/g, '\n').split('\n').forEach(function (line) { - line = line.trim(); - if (line && line.charAt(0) !== '#') { - excludePatterns.push(new RegExp(line)); - } - }); - } - - function isExclude(relativePath) { - for (let i = 0; i < excludePatterns.length; i++) { - if (excludePatterns[i].test(relativePath)) { - return true; - } - } - } - function getExt(path) { - if (path) { - const mathResult = path.match(extReg); - return mathResult && mathResult[1]; - } - } -} run(); diff --git a/build/checkHeader.js b/build/checkHeader.js new file mode 100644 index 000000000..65e5434d1 --- /dev/null +++ b/build/checkHeader.js @@ -0,0 +1,46 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +const fs = require('fs'); +const preamble = require('./preamble'); +const eachFile = require('./headerUtil').eachFile; + +function run() { + const missingFiles = []; + + eachFile(function (absolutePath, fileExt) { + const fileStr = fs.readFileSync(absolutePath, 'utf-8'); + const existLicense = preamble.extractLicense(fileStr, fileExt); + + if (!existLicense && preamble.hasPreamble(fileExt)) { + missingFiles.push(absolutePath); + } + }); + + if (missingFiles.length) { + console.error('Files missing license header:'); + missingFiles.forEach(function (path) { + console.error(path); + }); + console.error('\nPlease run `node build/addHeader.js` before commit.'); + process.exit(1); + } +} + +run(); diff --git a/build/headerUtil.js b/build/headerUtil.js new file mode 100644 index 000000000..e83f6a9d5 --- /dev/null +++ b/build/headerUtil.js @@ -0,0 +1,82 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +const pathTool = require('path'); +const fs = require('fs'); + +// In the `.headerignore`, each line is a pattern in RegExp. +// all relative path (based on the echarts base directory) is tested. +// The pattern should match the relative path completely. +const excludesPath = pathTool.join(__dirname, '../.headerignore'); +const ecBasePath = pathTool.join(__dirname, '../'); + +function eachFile(visit) { + const excludePatterns = []; + const extReg = /\.([a-zA-Z0-9_-]+)$/; + + prepareExcludePatterns(); + travel('./'); + + function travel(relativePath) { + if (isExclude(relativePath)) { + return; + } + + const absolutePath = pathTool.join(ecBasePath, relativePath); + const stat = fs.statSync(absolutePath); + + if (stat.isFile()) { + visit(absolutePath, getExt(absolutePath)); + } + else if (stat.isDirectory()) { + fs.readdirSync(relativePath).forEach(function (file) { + travel(pathTool.join(relativePath, file)); + }); + } + } + + function prepareExcludePatterns() { + const content = fs.readFileSync(excludesPath, {encoding: 'utf-8'}); + content.replace(/\r/g, '\n').split('\n').forEach(function (line) { + line = line.trim(); + if (line && line.charAt(0) !== '#') { + excludePatterns.push(new RegExp(line)); + } + }); + } + + function isExclude(relativePath) { + for (let i = 0; i < excludePatterns.length; i++) { + if (excludePatterns[i].test(relativePath)) { + return true; + } + } + } + + function getExt(path) { + if (path) { + const mathResult = path.match(extReg); + return mathResult && mathResult[1]; + } + } +} + +module.exports = { + eachFile: eachFile +}; diff --git a/build/preamble.js b/build/preamble.js index d1bd0d296..93d916af7 100644 --- a/build/preamble.js +++ b/build/preamble.js @@ -17,8 +17,7 @@ * under the License. */ -const cStyleComment = ` -/* +const cStyleComment = `/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information diff --git a/package.json b/package.json index 8d6ffd99c..1eb8814f6 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "mktest": "node test/build/mktest.js", "mktest:help": "node test/build/mktest.js -h", "checktype": "tsc --noEmit", + "checkheader": "node build/checkHeader.js", "lint": "npx eslint --cache --cache-location node_modules/.cache/eslint src/**/*.ts ssr/client/src/**/*.ts extension-src/**/*.ts", "lint:fix": "npx eslint --fix src/**/*.ts extension-src/**/*.ts", "lint:dist": "echo 'It might take a while. Please wait ...' && npx jshint --config .jshintrc-dist dist/echarts.js" diff --git a/src/chart/chord/ChordEdge.ts b/src/chart/chord/ChordEdge.ts index 25001ddfb..74bb3f6e4 100644 --- a/src/chart/chord/ChordEdge.ts +++ b/src/chart/chord/ChordEdge.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import type { PathProps, PathStyleProps } from 'zrender/src/graphic/Path'; import type PathProxy from 'zrender/src/core/PathProxy'; import { extend, isString } from 'zrender/src/core/util'; diff --git a/src/chart/chord/ChordPiece.ts b/src/chart/chord/ChordPiece.ts index 0c502eb1c..8844a41f7 100644 --- a/src/chart/chord/ChordPiece.ts +++ b/src/chart/chord/ChordPiece.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import { extend, retrieve3 } from 'zrender/src/core/util'; import * as graphic from '../../util/graphic'; import SeriesData from '../../data/SeriesData'; diff --git a/src/chart/custom/customSeriesRegister.ts b/src/chart/custom/customSeriesRegister.ts index 3edfe64f2..8df1f0e38 100644 --- a/src/chart/custom/customSeriesRegister.ts +++ b/src/chart/custom/customSeriesRegister.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import type { CustomSeriesRenderItem } from './CustomSeries'; const customRenderers: {[type: string]: CustomSeriesRenderItem} = {}; diff --git a/src/chart/scatter/jitterLayout.ts b/src/chart/scatter/jitterLayout.ts index a01a9ce0b..b3f88284b 100644 --- a/src/chart/scatter/jitterLayout.ts +++ b/src/chart/scatter/jitterLayout.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import type GlobalModel from '../../model/Global'; import type ScatterSeriesModel from './ScatterSeries'; import { needFixJitter, fixJitter } from '../../util/jitter'; diff --git a/src/coord/cartesian/legacyContainLabel.ts b/src/coord/cartesian/legacyContainLabel.ts index cb4d184e9..679048745 100644 --- a/src/coord/cartesian/legacyContainLabel.ts +++ b/src/coord/cartesian/legacyContainLabel.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import BoundingRect from 'zrender/src/core/BoundingRect'; import Axis from '../Axis'; import { LayoutRect } from '../../util/layout'; diff --git a/src/coord/matrix/MatrixDim.ts b/src/coord/matrix/MatrixDim.ts index a9609fb7c..764d762c5 100644 --- a/src/coord/matrix/MatrixDim.ts +++ b/src/coord/matrix/MatrixDim.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import { createHashMap, defaults, diff --git a/src/core/ExtendedElement.ts b/src/core/ExtendedElement.ts index 97ceb01c2..150505c0f 100644 --- a/src/core/ExtendedElement.ts +++ b/src/core/ExtendedElement.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import Element, { ElementProps } from 'zrender/src/Element'; export interface ExtendedElement extends Element { diff --git a/src/util/jitter.ts b/src/util/jitter.ts index d3e1aa83a..42690c1dd 100644 --- a/src/util/jitter.ts +++ b/src/util/jitter.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import type Axis from '../coord/Axis'; import type { AxisBaseModel } from '../coord/AxisBaseModel'; import Axis2D from '../coord/cartesian/Axis2D'; diff --git a/src/visual/tokens.ts b/src/visual/tokens.ts index dbe942b59..87bfba64b 100644 --- a/src/visual/tokens.ts +++ b/src/visual/tokens.ts @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + import { extend } from 'zrender/src/core/util'; import { modifyHSL } from 'zrender/src/tool/color'; diff --git a/test/axis-layout-0-quick-cases.js b/test/axis-layout-0-quick-cases.js index 9f71e8da9..95cad5b04 100644 --- a/test/axis-layout-0-quick-cases.js +++ b/test/axis-layout-0-quick-cases.js @@ -1,3 +1,22 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + var __AXIS_LAYOUT_0_TEST_CASE_LIST = [ { diff --git a/test/bar-stack-reverse.html b/test/bar-stack-reverse.html index ea1e2d42a..28fefe3a7 100644 --- a/test/bar-stack-reverse.html +++ b/test/bar-stack-reverse.html @@ -1,4 +1,24 @@ <!DOCTYPE html> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + + <html> <head> <meta charset="utf-8"> diff --git a/test/graph-thumbnail.html b/test/graph-thumbnail.html index 3f109b982..3e586b3a4 100644 --- a/test/graph-thumbnail.html +++ b/test/graph-thumbnail.html @@ -1,3 +1,23 @@ + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + <html lang="en"> <head> <meta charset="UTF-8"> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org