-
Notifications
You must be signed in to change notification settings - Fork 946
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
/* ! | ||
* Tencent is pleased to support the open source community by making | ||
* Hippy available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
export * from './view-node'; | ||
export { default as DocumentNode } from './document-node'; | ||
export { default as ElementNode } from './element-node'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const fs = require('fs-extra'); | ||
const chalk = require('chalk'); | ||
const yargs = require('yargs'); | ||
const glob = require('glob'); | ||
const { banner } = require('./utils'); | ||
|
||
let packages = glob.sync('packages/[!global]*').map(o => o.replace('packages/', '')); | ||
|
||
if (yargs.argv._) { | ||
const filters = yargs.argv._.map(o => o.trim()); | ||
packages = packages.filter(p => filters.includes(p)); | ||
} | ||
const updateList = []; | ||
const updatedList = []; | ||
const needUpdateList = []; | ||
/** update file */ | ||
const updateFile = (file, content) => updateList.push(new Promise(r => fs.writeFile(file, `${banner(undefined, undefined, undefined, undefined, false)}\n${content}`, 'utf8', (err) => { | ||
if (err) return console.error(err); | ||
updatedList.push(file); | ||
r(); | ||
}))); | ||
|
||
/** | ||
* @example node scripts/copyright.js hippy-react hippy-react-web | ||
*/ | ||
console.log('choise packages', packages); | ||
packages.forEach((pkg) => { | ||
const files = glob.sync(`packages/${pkg}/src/**/*.ts`, { | ||
ignore: ['**/node_modules/**', '**/dist/**'], | ||
}); | ||
files.forEach((file) => { | ||
const content = fs.readFileSync(file, 'utf-8'); | ||
if (!content.includes('* Copyright (C) 2017-') || !content.includes('THL A29 Limited, a Tencent company')) { | ||
// not found copyright, add it. | ||
updateFile(file, content); | ||
} else if (!content.includes(banner(undefined, undefined, undefined, undefined, false))) { | ||
if (yargs.argv.force) { | ||
updateFile(file, content); | ||
} else { | ||
needUpdateList.push(file); | ||
} | ||
} | ||
}); | ||
|
||
|
||
Promise.all(updateList).then(() => { | ||
if (updatedList.length) { | ||
console.log(chalk.cyan('\nauto add copyright header:')); | ||
console.log(chalk.green(updatedList.join('\n'))); | ||
} else { | ||
console.log(chalk.green('all files check copyright is ok.')); | ||
} | ||
}) | ||
.catch((e) => { | ||
console.log(chalk.yellow('add copyright found err'), e); | ||
}) | ||
.finally(() => { | ||
console.log(chalk.yellow('\nneed to update copyright:')); | ||
console.log(chalk.grey(needUpdateList.join('\n'))); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters