Skip to content

Commit de05605

Browse files
committed
chore(lint): add license header
1 parent 097b74c commit de05605

File tree

11 files changed

+212
-48
lines changed

11 files changed

+212
-48
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
module.exports = {
220
extends: ['@tencent/eslint-config-tencent'],
21+
plugins: ['header'],
22+
rules: {
23+
'header/header': [2, 'resources/license-header.js'],
24+
},
325
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"conventional-changelog-cli": "^2.0.34",
2626
"cz-conventional-changelog": "^3.2.0",
2727
"eslint": "^7.12.1",
28+
"eslint-plugin-header": "^3.1.0",
2829
"lerna": "^3.20.2",
2930
"license-checker": "^25.0.1",
3031
"typescript": "^4.0.5"

resources/license-header.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/

scripts/build-runner/build.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const spawnPromise = require('../spawn');
220
const path = require('path');
321
const glob = require('glob');
422
const { promisify } = require('util');
523
const { writeFileSync } = require('fs');
624

725
const coreVersion = require('../../lerna.json').version;
8-
const tagName = `binggg/cloudbase-framework-runner:latest`;
26+
const tagName = 'binggg/cloudbase-framework-runner:latest';
927

1028
const promisifyGlob = promisify(glob);
1129

scripts/build-runner/src/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const http = require('http');
220

321
const hostname = '127.0.0.1';

scripts/license-checker.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const fs = require('fs');
220
const path = require('path');
321
const { promisify } = require('util');
@@ -8,9 +26,9 @@ async function main() {
826

927
let files = await promisify(fs.readdir)(path.join(process.cwd(), 'packages'));
1028

11-
files = files.filter((file) => !/^\./.test(file));
29+
files = files.filter(file => !/^\./.test(file));
1230

13-
for (let file of files) {
31+
for (const file of files) {
1432
await licenseCheck(file, path.join(process.cwd(), 'packages', file));
1533
}
1634
}

scripts/link-packages.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const link = require('./link');
220

321
link();

scripts/link.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const os = require('os');
220
const fs = require('fs');
321
const del = require('del');
@@ -43,15 +61,13 @@ function initRegistry() {
4361
}
4462

4563
async function linkPlugins() {
46-
const files = await promisify(fs.readdir)(
47-
path.join(process.cwd(), 'packages')
48-
);
64+
const files = await promisify(fs.readdir)(path.join(process.cwd(), 'packages'));
4965

50-
const plugins = files.filter((file) => file.includes('plugin'));
66+
const plugins = files.filter(file => file.includes('plugin'));
5167
// 插件列表
5268
console.log(plugins);
5369

54-
for (let plugin of plugins) {
70+
for (const plugin of plugins) {
5571
console.log('\n', 'Link Plugin', plugin, '\n');
5672
// 创建软连接
5773
await link(

scripts/local-e2e.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const path = require('path');
220
const os = require('os');
321
const https = require('https');
@@ -20,7 +38,7 @@ async function main() {
2038
const templates = await getTemplates();
2139
console.log(templates);
2240

23-
for (let template of templates) {
41+
for (const template of templates) {
2442
if (template.path !== 'taro-starter') {
2543
await installTemplate(template);
2644
}

scripts/markdown-render.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
*
3+
* Copyright 2020 Tencent
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
const spawnPromise = require('./spawn');
220
const path = require('path');
321
const { readFileSync } = require('fs');
@@ -11,19 +29,15 @@ const config = {
1129
// 渲染用户案例
1230
usercases: {
1331
async get() {
14-
const data = JSON.parse(
15-
readFileSync(path.join(__dirname, '../community/usercases/index.json'))
16-
);
17-
const renderCell = (item) => {
18-
return `<td align="center"><a target="_blank" href="${
19-
item.repo || item.link
20-
}"><img width="100px;" src="${
21-
item.logo ||
22-
'https://main.qcloudimg.com/raw/d56f7877c8fec451718459a3aa8bbc9a.png'
23-
}"><br /><sub><b>${
24-
item.name
25-
}</b></sub></a><br/><a target="_blank" href="${item.link}">🌐</a></td>`;
26-
};
32+
const data = JSON.parse(readFileSync(path.join(__dirname, '../community/usercases/index.json')));
33+
const renderCell = item => `<td align="center"><a target="_blank" href="${
34+
item.repo || item.link
35+
}"><img width="100px;" src="${
36+
item.logo
37+
|| 'https://main.qcloudimg.com/raw/d56f7877c8fec451718459a3aa8bbc9a.png'
38+
}"><br /><sub><b>${
39+
item.name
40+
}</b></sub></a><br/><a target="_blank" href="${item.link}">🌐</a></td>`;
2741
const maxWidth = 5;
2842
return `
2943
${renderTable(data, renderCell, maxWidth)}
@@ -35,31 +49,25 @@ ${renderTable(data, renderCell, maxWidth)}
3549
// 渲染插件
3650
plugins: {
3751
async get() {
38-
const data = JSON.parse(
39-
readFileSync(path.join(__dirname, '../community/plugins/index.json'))
40-
);
52+
const data = JSON.parse(readFileSync(path.join(__dirname, '../community/plugins/index.json')));
4153

4254
return `
4355
| 插件链接 | 插件 | 最新版本 | 插件介绍 |
4456
| -------- | ---- | -------- | -------- |
4557
${data
46-
.map((item) => {
47-
return (
48-
`| <a href="${item.link}"><img width="200" src="${item.cover}"></a> | [${item.npmPackageName}](${item.link}) ` +
49-
`|[![Npm version](https://img.shields.io/npm/v/${item.npmPackageName})]` +
50-
`(https://www.npmjs.com/package/${item.npmPackageName})` +
51-
` | ${item.description}|`
52-
);
53-
})
54-
.join('\n')}
58+
.map(item => `| <a href="${item.link}"><img width="200" src="${item.cover}"></a> | [${item.npmPackageName}](${item.link}) `
59+
+ `|[![Npm version](https://img.shields.io/npm/v/${item.npmPackageName})]`
60+
+ `(https://www.npmjs.com/package/${item.npmPackageName})`
61+
+ ` | ${item.description}|`)
62+
.join('\n')}
5563
<!-- 新增/删除/修改插件信息,请修改 community/plugins/index.json,然后执行 npm run build:markdown-->
5664
`;
5765
},
5866
},
5967
};
6068

6169
function renderTable(data, renderCell, maxWidth = 10) {
62-
let rowsCount = Math.ceil(data.length / maxWidth);
70+
const rowsCount = Math.ceil(data.length / maxWidth);
6371
let content = '';
6472
for (let i = 0; i < rowsCount; i++) {
6573
content += `
@@ -81,18 +89,10 @@ ${content}
8189

8290
(async () => {
8391
const defines = (
84-
await Promise.all(
85-
Object.entries(config).map(async ([define, defineConfig]) => {
86-
return `--define.${define} '${await defineConfig.get()}'`;
87-
})
88-
)
92+
await Promise.all(Object.entries(config).map(async ([define, defineConfig]) => `--define.${define} '${await defineConfig.get()}'`))
8993
).join(' ');
9094

91-
await Promise.all(
92-
markdownFiles.map((mdFile) =>
93-
spawnPromise(`npx mdmod ${mdFile} ${defines}`, {
94-
cwd: path.join(__dirname, '../'),
95-
})
96-
)
97-
);
95+
await Promise.all(markdownFiles.map(mdFile => spawnPromise(`npx mdmod ${mdFile} ${defines}`, {
96+
cwd: path.join(__dirname, '../'),
97+
})));
9898
})();

0 commit comments

Comments
 (0)