@ohos/hpm-cli-notice
Version:
Combining the notice files in the project into 'Third Party Open Source Notice' file.
46 lines (41 loc) • 1.56 kB
JavaScript
var { generateNotice } = require("./notice");
var bundleJson = require("../bundle.json");
module.exports = (hpmApi) => {
registI18nResource(hpmApi);
hpmApi.registerCmd(
'gen-notice',
{
description: hpmApi.i18n.getMessage(`${bundleJson.name}.description`),
options: {
"-d, --dirname <dirname>": hpmApi.i18n.getMessage(`${bundleJson.name}.outputDir`)
}
},
(options) => {
const cwd = options && options.dirname || hpmApi.cwd();
generateNotice(cwd, hpmApi);
}, true);
const config = hpmApi.getConfig()
if (!config.ignoreLicenseChecke) {
hpmApi.on(hpmApi.eventTypes.afterDist, () => {
generateNotice(hpmApi.cwd(), hpmApi);
})
}
}
function registI18nResource(hpmApi) {
const en = {
"description": "Generate third-party open-source notice",
"start": "Generating Third Party Open Source Notice...",
"success": "Third Party Open Source Notice generated.",
"notFoundOhos": "Error: Cannot find ohos_bundles folder in {{cwd}}",
"outputDir": "Generate notice by specific directory"
};
const zh = {
"description": "生成三方开源声明文件",
"start": "正在生成Third Party Open Source Notice...",
"success": "成功生成Third Party Open Source Notice",
"notFoundOhos": "错误:在{{cwd}}中找不到ohos_bundles文件夹",
"outputDir": "向指定的目录生成notice文件"
}
hpmApi.i18n.addLocalization("en", en, { pluginName: bundleJson.name });
hpmApi.i18n.addLocalization("zh", zh, { pluginName: bundleJson.name });
}