更新readme文档,删除应用api解析旧版工具和sdk差异比较旧版工具

Signed-off-by: fanjiaojiao <fanjiaojiao@huawei.com>
This commit is contained in:
fanjiaojiao 2023-07-19 15:11:50 +08:00
parent d6f8d429cc
commit e514591e9b
42 changed files with 439 additions and 1300 deletions

View File

@ -6,7 +6,7 @@ JS/TS API 公共仓,用来提交 API d.ts 声明文件以及API相关工具。
## 目录
```
```|
├─api
| ├─@internal
│ | ├─component
@ -18,11 +18,35 @@ JS/TS API 公共仓,用来提交 API d.ts 声明文件以及API相关工具。
| └─@system.×××.d.ts #标记为停止维护的接口
├─build-tools
├─api_check_plugin #检查API规范的工具
| ├─config
| ├─plugin
| ├─src
| └─test
└─collect_application_api #解析应用到的API的工具
└─src
└─cllect_application_api #解析应用到的API的工具(旧)
| ├─deps
| └─src
└─api_collector #解析应用到的API的工具的工具(新)
| ├─scripts
| ├─src
| └─test
└─api_diff #比较两个版本sdk差异的工具(旧)
| ├─src
| └─version_diff_collection
└─collect_api #解析d.ts文件接口的基本信息的工具
| └─collect_base_api.js
└─diff_api #比较两个版本sdk差异工具(新)
| └─src
└─dts_parser #解析d.ts文件的工具
| ├─src
| └─test
└─jsdoc_format_plugin #检查并修复jsdoc规范错误的工具
| ├─loader
| ├─src
| └─test
└─permissions_converter #从config文件提取权限信息为DevEco Studio提供权限的联想和校验
| └─convert.js
└─sdk_upgrade_assistance_plugin #SDK升级辅助工具帮助开发者快速解决SDK升级导致的API不兼容问题
| └─src
```
## 相关仓

View File

@ -30,7 +30,7 @@ function checkEntry(prId) {
const execSync = require('child_process').execSync;
do {
try {
buffer = execSync('cd interface/sdk-js/build-tools/diff_api && npm install && cd ../api_check_plugin && npm install', {
buffer = execSync('cd interface/sdk-js/build-tools/api_diff && npm install && cd ../api_check_plugin && npm install', {
timeout: 120000,
});
execute = true;
@ -42,7 +42,7 @@ function checkEntry(prId) {
const { scanEntry, reqGitApi } = require(path.resolve(__dirname, './src/api_check_plugin'));
result = scanEntry(mdFilesPath, prId);
result = reqGitApi(result, prId);
removeDir(path.resolve(__dirname, '../diff_api/node_modules'));
removeDir(path.resolve(__dirname, '../api_diff/node_modules'));
removeDir(path.resolve(__dirname, 'node_modules'));
} catch (error) {
// catch error

View File

@ -15,8 +15,8 @@
const fs = require('fs');
const path = require('path');
const { exportDiffInfo } = require('../../diff_api/src/api_diff');
const { StatusCode } = require('../../diff_api/src/reporter');
const { exportDiffInfo } = require('../../api_diff/src/api_diff');
const { StatusCode } = require('../../api_diff/src/reporter');
const { parseJsDoc, requireTypescriptModule, ErrorType, LogType, ErrorLevel, ErrorValueInfo, getCheckApiVersion,
FUNCTION_TYPES } = require('./utils');
const ts = requireTypescriptModule();

View File

@ -17,15 +17,15 @@ function checkEntryLocalText(url, prId) {
const path = require('path');
let result = [];
try {
let execSync = require('child_process').execSync;
execSync('cd ../../diff_api && npm install && cd ../api_check_plugin && npm install');
let execSync = require("child_process").execSync;
execSync("cd ../../api_diff && npm install && cd ../api_check_plugin && npm install");
const { excelApiCheckResult, apiCheckArr, removeDir } =
require(path.resolve(__dirname, '../src/utils'));
const { scanEntry } = require('../src/api_check_plugin');
result = scanEntry(url, prId);
excelApiCheckResult(apiCheckArr);
removeDir(path.resolve(__dirname, '../../diff_api/node_modules'));
removeDir(path.resolve(__dirname, '../node_modules'));
removeDir(path.resolve(__dirname, "../../api_diff/node_modules"));
removeDir(path.resolve(__dirname, "../node_modules"));
} catch (error) {
result.push(`API_CHECK_ERROR :${error}`);
console.error(`API_CHECK_ERROR :${error}`);

View File

@ -1,31 +0,0 @@
{
"name": "api_collector",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"type": "commonjs",
"scripts": {
"build": "webpack --mode=production",
"postinstall": "node scripts/copylibs.js",
"test": "mocha ./test/testCase/*.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"commander": "^10.0.0",
"exceljs": "^4.3.0",
"fs": "^0.0.1-security",
"json5": "^2.2.3",
"path": "^0.12.7",
"typescript": "file:./deps/ohos-typescript-4.2.3-r2.tgz"
},
"devDependencies": {
"archiver": "^5.3.1",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1",
"@types/node": "^18.11.9",
"@types/chai": "^4.2.11",
"chai": "^4.2.0",
"mocha": "^7.0.2"
}
}

View File

@ -1,606 +0,0 @@
{
"compileOnSave": false,
"compilerOptions": {
"ets": {
"render": {
"method": ["build", "pageTransition"],
"decorator": "Builder"
},
"components": [
"AbilityComponent",
"AlphabetIndexer",
"Animator",
"Badge",
"Blank",
"Button",
"Calendar",
"Camera",
"Canvas",
"Checkbox",
"CheckboxGroup",
"Circle",
"ColorPicker",
"ColorPickerDialog",
"Column",
"ColumnSplit",
"Counter",
"DataPanel",
"DatePicker",
"Divider",
"Ellipse",
"Flex",
"FormComponent",
"Gauge",
"GeometryView",
"Grid",
"GridItem",
"GridContainer",
"Hyperlink",
"Image",
"ImageAnimator",
"Line",
"List",
"ListItem",
"ListItemGroup",
"LoadingProgress",
"Marquee",
"Menu",
"MenuItem",
"MenuItemGroup",
"Navigation",
"Navigator",
"Option",
"PageTransitionEnter",
"PageTransitionExit",
"Panel",
"Path",
"PatternLock",
"Piece",
"PluginComponent",
"Polygon",
"Polyline",
"Progress",
"QRCode",
"Radio",
"Rating",
"Rect",
"Refresh",
"RelativeContainer",
"RemoteWindow",
"Row",
"RowSplit",
"RichText",
"Scroll",
"ScrollBar",
"Search",
"Section",
"Select",
"Shape",
"Sheet",
"SideBarContainer",
"Slider",
"Span",
"Stack",
"Stepper",
"StepperItem",
"Swiper",
"TabContent",
"Tabs",
"Text",
"TextPicker",
"TextClock",
"TextArea",
"TextInput",
"TextTimer",
"TimePicker",
"Toggle",
"Video",
"Web",
"XComponent",
"GridRow",
"GridCol"
],
"extend": {
"decorator": "Extend",
"components": [
{
"name": "AbilityComponent",
"type": "AbilityComponentAttribute",
"instance": "AbilityComponentInstance"
},
{
"name": "AlphabetIndexer",
"type": "AlphabetIndexerAttribute",
"instance": "AlphabetIndexerInstance"
},
{
"name": "Animator",
"type": "AnimatorAttribute",
"instance": "AnimatorInstance"
},
{
"name": "Badge",
"type": "BadgeAttribute",
"instance": "BadgeInstance"
},
{
"name": "Blank",
"type": "BlankAttribute",
"instance": "BlankInstance"
},
{
"name": "Button",
"type": "ButtonAttribute",
"instance": "ButtonInstance"
},
{
"name": "Calendar",
"type": "CalendarAttribute",
"instance": "CalendarInstance"
},
{
"name": "Camera",
"type": "CameraAttribute",
"instance": "CameraInstance"
},
{
"name": "Canvas",
"type": "CanvasAttribute",
"instance": "CanvasInstance"
},
{
"name": "Checkbox",
"type": "CheckboxAttribute",
"instance": "CheckboxInstance"
},
{
"name": "CheckboxGroup",
"type": "CheckboxGroupAttribute",
"instance": "CheckboxGroupInstance"
},
{
"name": "Circle",
"type": "CircleAttribute",
"instance": "CircleInstance"
},
{
"name": "ColorPicker",
"type": "ColorPickerAttribute",
"instance": "ColorPickerInstance"
},
{
"name": "ColorPickerDialog",
"type": "ColorPickerDialogAttribute",
"instance": "ColorPickerDialogInstance"
},
{
"name": "Column",
"type": "ColumnAttribute",
"instance": "ColumnInstance"
},
{
"name": "ColumnSplit",
"type": "ColumnSplitAttribute",
"instance": "ColumnSplitInstance"
},
{
"name": "Counter",
"type": "CounterAttribute",
"instance": "CounterInstance"
},
{
"name": "DataPanel",
"type": "DataPanelAttribute",
"instance": "DataPanelInstance"
},
{
"name": "DatePicker",
"type": "DatePickerAttribute",
"instance": "DatePickerInstance"
},
{
"name": "Divider",
"type": "DividerAttribute",
"instance": "DividerInstance"
},
{
"name": "Ellipse",
"type": "EllipseAttribute",
"instance": "EllipseInstance"
},
{
"name": "Flex",
"type": "FlexAttribute",
"instance": "FlexInstance"
},
{
"name": "FormComponent",
"type": "FormComponentAttribute",
"instance": "FormComponentInstance"
},
{
"name": "Gauge",
"type": "GaugeAttribute",
"instance": "GaugeInstance"
},
{
"name": "GeometryView",
"type": "GeometryViewAttribute",
"instance": "GeometryViewInstance"
},
{
"name": "Grid",
"type": "GridAttribute",
"instance": "GridInstance"
},
{
"name": "GridItem",
"type": "GridItemAttribute",
"instance": "GridItemInstance"
},
{
"name": "GridContainer",
"type": "GridContainerAttribute",
"instance": "GridContainerInstance"
},
{
"name": "Hyperlink",
"type": "HyperlinkAttribute",
"instance": "HyperlinkInstance"
},
{
"name": "Image",
"type": "ImageAttribute",
"instance": "ImageInstance"
},
{
"name": "ImageAnimator",
"type": "ImageAnimatorAttribute",
"instance": "ImageAnimatorInstance"
},
{
"name": "Line",
"type": "LineAttribute",
"instance": "LineInstance"
},
{
"name": "List",
"type": "ListAttribute",
"instance": "ListInstance"
},
{
"name": "ListItem",
"type": "ListItemAttribute",
"instance": "ListItemInstance"
},
{
"name": "ListItemGroup",
"type": "ListItemGroupAttribute",
"instance": "ListItemGroupInstance"
},
{
"name": "LoadingProgress",
"type": "LoadingProgressAttribute",
"instance": "LoadingProgressInstance"
},
{
"name": "Marquee",
"type": "MarqueeAttribute",
"instance": "MarqueeInstance"
},
{
"name": "Menu",
"type": "MenuAttribute",
"instance": "MenuInstance"
},
{
"name": "MenuItem",
"type": "MenuItemAttribute",
"instance": "MenuItemInstance"
},
{
"name": "MenuItemGroup",
"type": "MenuItemGroupAttribute",
"instance": "MenuItemGroupInstance"
},
{
"name": "Navigation",
"type": "NavigationAttribute",
"instance": "NavigationInstance"
},
{
"name": "Navigator",
"type": "NavigatorAttribute",
"instance": "NavigatorInstance"
},
{
"name": "Option",
"type": "OptionAttribute",
"instance": "OptionInstance"
},
{
"name": "PageTransitionEnter",
"type": "PageTransitionEnterAttribute",
"instance": "PageTransitionEnterInstance"
},
{
"name": "PageTransitionExit",
"type": "PageTransitionExitAttribute",
"instance": "PageTransitionExitInstance"
},
{
"name": "Panel",
"type": "PanelAttribute",
"instance": "PanelInstance"
},
{
"name": "Path",
"type": "PathAttribute",
"instance": "PathInstance"
},
{
"name": "PatternLock",
"type": "PatternLockAttribute",
"instance": "PatternLockInstance"
},
{
"name": "Piece",
"type": "PieceAttribute",
"instance": "PieceInstance"
},
{
"name": "PluginComponent",
"type": "PluginComponentAttribute",
"instance": "PluginComponentInstance"
},
{
"name": "Polygon",
"type": "PolygonAttribute",
"instance": "PolygonInstance"
},
{
"name": "Polyline",
"type": "PolylineAttribute",
"instance": "PolylineInstance"
},
{
"name": "Progress",
"type": "ProgressAttribute",
"instance": "ProgressInstance"
},
{
"name": "QRCode",
"type": "QRCodeAttribute",
"instance": "QRCodeInstance"
},
{
"name": "Radio",
"type": "RadioAttribute",
"instance": "RadioInstance"
},
{
"name": "Rating",
"type": "RatingAttribute",
"instance": "RatingInstance"
},
{
"name": "Rect",
"type": "RectAttribute",
"instance": "RectInstance"
},
{
"name": "RelativeContainer",
"type": "RelativeContainerAttribute",
"instance": "RelativeContainerInstance"
},
{
"name": "Refresh",
"type": "RefreshAttribute",
"instance": "RefreshInstance"
},
{
"name": "RemoteWindow",
"type": "RemoteWindowAttribute",
"instance": "RemoteWindowInstance"
},
{
"name": "Row",
"type": "RowAttribute",
"instance": "RowInstance"
},
{
"name": "RowSplit",
"type": "RowSplitAttribute",
"instance": "RowSplitInstance"
},
{
"name": "RichText",
"type": "RichTextAttribute",
"instance": "RichTextInstance"
},
{
"name": "Scroll",
"type": "ScrollAttribute",
"instance": "ScrollInstance"
},
{
"name": "ScrollBar",
"type": "ScrollBarAttribute",
"instance": "ScrollBarInstance"
},
{
"name": "Search",
"type": "SearchAttribute",
"instance": "SearchInstance"
},
{
"name": "Section",
"type": "SectionAttribute",
"instance": "SectionInstance"
},
{
"name": "Select",
"type": "SelectAttribute",
"instance": "SelectInstance"
},
{
"name": "Shape",
"type": "ShapeAttribute",
"instance": "ShapeInstance"
},
{
"name": "Sheet",
"type": "SheetAttribute",
"instance": "SheetInstance"
},
{
"name": "SideBarContainer",
"type": "SideBarContainerAttribute",
"instance": "SideBarContainerInstance"
},
{
"name": "Slider",
"type": "SliderAttribute",
"instance": "SliderInstance"
},
{
"name": "Span",
"type": "SpanAttribute",
"instance": "SpanInstance"
},
{
"name": "Stack",
"type": "StackAttribute",
"instance": "StackInstance"
},
{
"name": "Stepper",
"type": "StepperAttribute",
"instance": "StepperInstance"
},
{
"name": "StepperItem",
"type": "StepperItemAttribute",
"instance": "StepperItemInstance"
},
{
"name": "Swiper",
"type": "SwiperAttribute",
"instance": "SwiperInstance"
},
{
"name": "TabContent",
"type": "TabContentAttribute",
"instance": "TabContentInstance"
},
{
"name": "Tabs",
"type": "TabsAttribute",
"instance": "TabsInstance"
},
{
"name": "Text",
"type": "TextAttribute",
"instance": "TextInstance"
},
{
"name": "TextPicker",
"type": "TextPickerAttribute",
"instance": "TextPickerInstance"
},
{
"name": "TextClock",
"type": "TextClockAttribute",
"instance": "TextClockInstance"
},
{
"name": "TextArea",
"type": "TextAreaAttribute",
"instance": "TextAreaInstance"
},
{
"name": "TextInput",
"type": "TextInputAttribute",
"instance": "TextInputInstance"
},
{
"name": "TextTimer",
"type": "TextTimerAttribute",
"instance": "TextTimerInstance"
},
{
"name": "TimePicker",
"type": "TimePickerAttribute",
"instance": "TimePickerInstance"
},
{
"name": "Toggle",
"type": "ToggleAttribute",
"instance": "ToggleInstance"
},
{
"name": "Video",
"type": "VideoAttribute",
"instance": "VideoInstance"
},
{
"name": "Web",
"type": "WebAttribute",
"instance": "WebInstance"
},
{
"name": "XComponent",
"type": "XComponentAttribute",
"instance": "XComponentInstance"
},
{
"name": "GridRow",
"type": "GridRowAttribute",
"instance": "GridRowInterface"
},
{
"name": "GridCol",
"type": "GridColAttribute",
"instance": "GridColInterface"
}
]
},
"styles": {
"decorator": "Styles",
"component": {
"name": "Common",
"type": "T",
"instance": "CommonInstance"
},
"property": "stateStyles"
},
"customComponent": "CustomComponent",
"propertyDecorators": [],
"emitDecorators": [],
"libs": []
},
"allowJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"importsNotUsedAsValues": "preserve",
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"module": "commonjs",
"target": "es2017",
"types": [],
"typeRoots": [],
"lib": [
"es2020"
],
"alwaysStrict": true
},
"exclude": [
"node_modules"
]
}

View File

@ -2,36 +2,61 @@
## 简介
该工具可用于对比两个版本SDK里的API差异并汇总成表格提供给应用开发者
该工具可用于对比两个版本SDK里的API差异并汇总成表格提供给应用开发者
## 目录
```
├─diff合集 #存放md文档形式的diff报告
├─版本迭代合集 #存放由子系统自行填写的API变更
├─url.json #SDK路径和新旧版本的配置文件
└─src #存放源码以及生成的表格
├─test #测试用例存放路径
└─src #源码存放路径
```
## 使用方法
### 目录配置
新建名为"diff合集"的文件夹存放md文档形式的diff报告。
### 填写路径
1. 在url.json文件中将新旧SDK的本地路径分别赋给oldDir和newDir变量路径写到windows即可例如D:ohos-sdk-windows_linux-full.tar_beta4*\\*ohos-sdk*\\*windows
2. 在url.json文件中分别将新旧SDK的版本分别赋给oldVersion和newVersion变量例如3.2.5.6
### 安装
需要安装npm依赖环境在package.json同级目录下执行npm install。
### 使用工具
在package.json同级目录下执行npm run diff。
查看工具命令行参数在package.json同级目录下运行
## 相关文件夹
```
node .\src\entry\main.js diff -h
Usage: diff [options]
[api_diff](https://gitee.com/openharmony/interface_sdk-js/tree/master/build-tools/api_diff)
Compare the differences between the two SDKS
Options:
-V, --version output the version number
--old <string> old sdk path
--new <string> new sdk path
--oldVersion <string> old sdk version
--newVersion <string> new sdk version
--output <string> output file path
--format <json, excel, changelog> output file format
--newPath <string> new interface_sdk-js path
--oldPath <string> old interface_sdk-js path
--changelogUrl <string> changelog url
-h, --help display help for command
```
生成diff报告在package.json同级目录下运行
```
node .\src\entry\main.js diff --old 旧版本sdk根目录/windows/ets --new 新版本sdk根目录/windows/ets --oldVersion 旧版本SDK版本号 --newVersion 新版本SDK版本号 --output 输出路径 --format 报告格式报告格式可选择excel或者json
```
如果需要跟每个版本的changelog进行合并命令行中还需添加参数changelogUrl
获取changelogUrl在gitee中打开changelog文件夹下名为allVersion.json的文件点击查看原始数据此时的网址链接即为changelogUrl。
```
node .\src\entry\main.js diff --old 旧版本sdk根目录/windows/ets --new 新版本sdk根目录/windows/ets --oldVersion 旧版本SDK版本号 --newVersion 新版本SDK版本号 --output 输出路径 --format 报告格式报告格式可选择excel或者json--changelogUrl 网址链接
```
生成changelog配置文件在package.json同级目录下运行
```
node .\src\entry\main.js diff --oldPath 旧版本interface_sdk-js根目录 --new 新版本旧版本interface_sdk-js根目录 --oldVersion 旧版本号 --newVersion 新版本号 --output 输出路径 --format changelog
```

View File

@ -1,10 +1,12 @@
{
"name": "test",
"name": "api_diff",
"version": "1.0.0",
"description": "",
"main": "index.js",
"description": "Compare two SDKS and print the difference",
"main": "src/index.js",
"scripts": {
"diff": "cd src && node collect_api.js"
"diff": "cd src && node collect_api.js",
"test": "mocha ./test/testCase/*.js",
"build": "webpack --mode=production"
},
"author": "",
"license": "ISC",
@ -14,9 +16,16 @@
"fs": "0.0.1-security",
"node-xlsx": "^0.21.0",
"path": "^0.12.7",
"typescript": "^4.8.2"
"typescript": "^4.8.2",
"comment-parser": "1.3.1",
"commander": "^10.0.0"
},
"devDependencies": {
"@types/node": "^18.11.9"
"@types/node": "^18.11.9",
"@types/chai": "^4.2.11",
"chai": "^4.2.0",
"mocha": "^7.0.2",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1"
}
}

View File

@ -13,19 +13,24 @@
* limitations under the License.
*/
const fs = require('fs');
const path = require('path');
const url = `${__dirname.replace('src', '')}\\version_diff_collection`;
const urlObject = fs.readFileSync(__dirname.replace('\\src', '') + '\\url.json', 'utf-8');
const https = require('https');
const { StatusCode, StatusMessages } = require('./reporter');
const oldVersion = JSON.parse(urlObject).oldVersion;
const newVersion = JSON.parse(urlObject).newVersion;
filiterVersion(oldVersion, newVersion, url);
function filiterVersion(oldVersion, newVersion, url) {
let versionArr = fs.readdirSync(url);
async function mergeDataBetweenVersion(oldVersion, newVersion, allVersionUrl) {
const oldVersionNumber = oldVersion.replace(/\./g, '');
const newVersionNumber = newVersion.replace(/\./g, '');
const url = allVersionUrl.replace('allVersion.json', '');
let versionArr = [];
await downloadFiles(allVersionUrl).then((versionNumbers) => {
versionArr = JSON.parse(versionNumbers);
}).catch(err => {
console.log('ERROR CODE:', err.code);
})
if (versionArr.length === 0) {
return [];
}
for (let i = 0; i < versionArr.length; i++) {
const version = versionArr[i].replace(/\./g, '');
if (version < oldVersionNumber || version > newVersionNumber) {
@ -33,137 +38,298 @@ function filiterVersion(oldVersion, newVersion, url) {
i--;
}
}
let orderVersionArr = versionArr.sort((a, b) => {
return a.replace(/\./g, '') - b.replace(/\./g, '');
return a.replace(/\.|.json/g, '') - b.replace(/\.|.json/g, '');
});
formatExcelData(orderVersionArr);
return formatExcelData(orderVersionArr, url);
}
// 合并前两个版本的数据,作为初始数据
function formatExcelData(orderVersionArr) {
let initialData = [];
function downloadFiles(allVersionUrl) {
return new Promise((resolve, reject) => {
getVersionsData(allVersionUrl, (versions) => {
if (versions) {
resolve(versions);
} else {
reject({ code: -1 });
}
})
})
}
function getLink(url, fileName) {
return `${url}${fileName}.json`;
}
function getVersionsData(versionUrl, callback) {
let json = '';
const SUCCESS_CODE =200;
const request = https.get(versionUrl, { timeout: 2000 }, function (res) {
if (res.statusCode !== SUCCESS_CODE) {
return;
}
res.on('data', function (d) {
json += d;
})
}).on('error', function (e) {
console.log('ERROR:', e.message);
}).on('close', () => {
callback(json);
}).on('timeout', () => {
request.destroy();
});
}
/**
* 将最老版本changelog中函数有变化的数据作为初始数据去跟其他版本的changelog数据进行合并
* @param {Array} orderVersionArr
* @param {String} url
* @returns {Array}
*/
async function formatExcelData(orderVersionArr, url) {
let allMergeData = [];
if (orderVersionArr.length === 1) {
let versionUrl = `${url}\\${orderVersionArr[0]}`;
allMergeData = getSingleVersionData(versionUrl);
} else if (orderVersionArr.length > 1) {
let oldestVersionUrl = `${url}\\${orderVersionArr[0]}`;
let nearOldVersionUrl = `${url}\\${orderVersionArr[1]}`;
let oldestData = getSingleVersionData(oldestVersionUrl);
let nearOldVersionData = getSingleVersionData(nearOldVersionUrl);
const dataObject = compareDiffApi(oldestData, nearOldVersionData);
initialData = dataObject.initialData;
oldestData = dataObject.oldestData;
nearOldVersionData = dataObject.nearOldVersionData;
initialData = initialData.concat(oldestData, nearOldVersionData);
allMergeData = mergeAllData(initialData, orderVersionArr);
}
exports.allMergeData = allMergeData;
}
function compareDiffApi(oldestData, nearOldVersionData) {
let initialData = [];
let oldestVersionIndexes = [];
let nearOldestVersionIndexes = [];
for (let i = 0; i < oldestData.length; i++) {
for (let j = 0; j < nearOldVersionData.length; j++) {
let oldData = oldestData[i];
let newData = nearOldVersionData[j];
if (oldData.subsystem === newData.subsystem && oldData.diffNew === newData.diffOld &&
oldData.packageName === newData.packageName) {
initialData.push(collectData(oldData.diffOld, newData.diffNew, oldData.subsystem, oldData.packageName));
oldestVersionIndexes.push(i);
nearOldestVersionIndexes.push(j);
}
}
}
oldestVersionIndexes.forEach(index => {
oldestData.splice(index, 1);
const versionUrl = getLink(url, orderVersionArr[0]);
let oldestVersionData = [];
const MAX_LENGTH =2;
await downloadFiles(versionUrl).then(versionData => {
oldestVersionData = JSON.parse(versionData);
}).catch(err => {
console.log('ERROR CODE:', err.code);
});
nearOldestVersionIndexes.forEach(index => {
nearOldestVersionIndexes.splice(index, 1);
if (orderVersionArr.length < MAX_LENGTH) {
return allMergeData;
}
oldestVersionData.forEach(oldestData => {
if (oldestData.newApi !== oldestData.oldApi) {
oldestData.version = orderVersionArr[0];
allMergeData.push(oldestData);
}
})
await mergeAllData(orderVersionArr, url, allMergeData);
return allMergeData;
}
/**
* 将初始数据挨个跟下一个版本的changelog数据进行比较合并
*
* @param {Array} orderVersionArr
* @param {String} url
* @param {Array} allMergeData
*/
async function mergeAllData(orderVersionArr, url, allMergeData) {
let index = 1;
while (index < orderVersionArr.length) {
const versionUrl = getLink(url, orderVersionArr[index]);
let newVersionData = [];
await downloadFiles(versionUrl).then(versionData => {
newVersionData = JSON.parse(versionData);
}).catch(err => {
console.log('ERROR CODE:', err.code);
});
return { initialData, oldestData, nearOldVersionData };
mergeTwoVersionData(allMergeData, newVersionData, orderVersionArr[index]);
index++;
}
}
// 收集一个版本的所有API变更数据
function getSingleVersionData(versionUrl) {
let singleVersionFiles = fs.readdirSync(versionUrl);
let oneVersionData = [];
singleVersionFiles.forEach(file => {
let filePath = path.join(versionUrl, file);
let subsystem = file.replace('.md', '');
let fileContent = fs.readFileSync(filePath, 'utf-8');
let oneSubsystemDataArr = fileContent.split('\r\n');
let index = oneSubsystemDataArr.length;
while (index--) {
if (oneSubsystemDataArr[index] === '') {
oneSubsystemDataArr.splice(index, 1);
/**
* 跟下一个版本的数据进行合并
*
* @param {Array} allMergeData
* @param {Array} newVersionData
*/
function mergeTwoVersionData(allMergeData, newVersionData, currentVersion) {
let indexListSet = new Set();
for (let i = 0; i < allMergeData.length; i++) {
const data = allMergeData[i];
for (let j = 0; j < newVersionData.length; j++) {
if (!indexListSet.has(j) && data.newDtsName === newVersionData[j].oldDtsName &&
compareApiText(data.newApi, newVersionData[j].oldApi,) && data.newApi !== data.oldApi) {
allMergeData[i].newApi = newVersionData[j].newApi;
allMergeData[i].version = currentVersion;
indexListSet.add(j);
}
}
}
// 用 | 分隔开表格里的一行数据,得到新旧版本以及文件名
for (let i = 2; i < oneSubsystemDataArr.length; i++) {
const regx = /(?<!\\)\|/g;
let oneDataArr = oneSubsystemDataArr[i].split(regx);
const OLD_INDEX = 1;
const NEW_INDEX = 2;
const PACKAGE_INDEX = 3;
const diffOld = oneDataArr[OLD_INDEX].replace(/\\/g, '').trim();
const diffNew = oneDataArr[NEW_INDEX].replace(/\\/g, '').trim();
const packageName = oneDataArr[PACKAGE_INDEX].trim();
if (oneDataArr.length === 5) {
oneVersionData.push(collectData(diffOld, diffNew, subsystem, packageName));
newVersionData.forEach((data, index) => {
if (!indexListSet.has(index)) {
data.version = currentVersion;
allMergeData.push(data);
}
}
});
return oneVersionData;
})
}
// 用初始数据跟其他版本的数据比较合并
function mergeAllData(initialData, orderVersionArr) {
let number = 2;
while (number < orderVersionArr.length) {
let versionUrl = `${url}\\${orderVersionArr[number]}`;
let oneVersionData = getSingleVersionData(versionUrl);
initialData = mergeData(initialData, oneVersionData);
number++;
/**
* 比较旧版本的newApi和新版本的oldApi,判断是否一样
*
* @param {string} oldApiText
* @param {string} newApiText
* @returns {Boolean}
*/
function compareApiText(oldApiText, newApiText) {
if (formatApi(oldApiText) === formatApi(newApiText) && formatApi(oldApiText) !== undefined) {
return true;
}
return initialData;
return false;
}
// 合并初始数据和邻近版本的数据
function mergeData(initialData, oneVersionData) {
let indexList = [];
for (let i = 0; i < initialData.length; i++) {
const data = initialData[i];
for (let j = 0; j < oneVersionData.length; j++) {
if (data.subsystem === oneVersionData[j].subsystem && data.packageName === oneVersionData[j].packageName &&
data.diffNew === oneVersionData[j].diffOld) {
initialData[i].diffNew = oneVersionData[j].diffNew;
indexList.push(j);
}
}
/**
* 格式化API定义内容排除空格换行符号对比较API的影响
*
* @param {string} apiText
* @returns {string}
*/
function formatApi(apiText) {
if (!apiText) {
return;
}
return apiText.replace(/\r|\n|\s+|\,|\;/g, '');
}
indexList.forEach(index => {
oneVersionData.splice(index, 1);
/**
* 将数组形式的changelog数据转换成Map
*
* @param {Array} dataInChangelogs
* @returns {Map}
*/
function covertToMap(dataInChangelogs) {
let dataMap = new Map();
dataInChangelogs.forEach(data => {
const dataSignature = getSignature(data.newDtsName, data.oldApi);
if (!dataMap.get(dataSignature)) {
dataMap.set(dataSignature, [data]);
} else {
const dataArr = dataMap.get(dataSignature);
dataArr.push(data);
dataMap.set(dataSignature, dataArr);
}
})
return dataMap;
}
function getSignature(dtsName, apiText) {
const handledDtsName = handleDtsName(dtsName).dtsPath;
return `${handledDtsName}#${formatApi(apiText)}`;
}
function addChangelogLink(changelogsData, diffsData, diffs) {
diffsData.forEach(diffData => {
changelogsData.forEach(changelogData => {
diffData.changelogs.add({
version: changelogData.version,
url: changelogData.changelog
});
return initialData.concat(oneVersionData);
if (changelogData.oldType !== changelogData.newType) {
diffData.status = StatusMessages[StatusCode.CLASS_CHANGES];
diffData.StatusCode = StatusCode.CLASS_CHANGES;
diffData.oldMessage = changelogData.oldApi;
diffData.newMessage = changelogData.newApi;
}
if (changelogData.oldDtsName !== changelogData.newDtsName) {
diffData.status = StatusMessages[StatusCode.DTS_CHANGED];
diffData.StatusCode = StatusCode.DTS_CHANGED;
diffData.oldMessage = changelogData.oldDtsName;
diffData.newMessage = changelogData.newDtsName;
}
if (changelogData.newApi === changelogData.oldApi || changelogData.newApi === 'N/A') {
return;
}
if (diffData.statusCode === StatusCode.DELETE) {
const newApiSignature = getSignature(changelogData.newDtsName, changelogData.newApi);
diffs.delete(newApiSignature);
diffData.status = StatusMessages[StatusCode.FUNCTION_CHANGES];
diffData.StatusCode = StatusCode.FUNCTION_CHANGES;
diffData.oldMessage = changelogData.oldApi;
diffData.newMessage = changelogData.newApi;
} else if (diffData.statusCode === StatusCode.DELETE_CLASS) {
diffData.status = StatusMessages[StatusCode.CLASS_CHANGES];
diffData.StatusCode = StatusCode.CLASS_CHANGES;
diffData.oldMessage = changelogData.oldApi;
diffData.newMessage = changelogData.newApi;
}
})
})
return diffsData;
}
function collectData(oldData, newData, subsystem, fileName) {
function mergeDiffsAndChangelogs(changelogs, diffs) {
changelogs.forEach((data, dataSignature) => {
const diffsData = diffs.get(dataSignature);
if (diffsData) {
diffs.set(dataSignature, addChangelogLink(data, diffsData, diffs));
changelogs.delete(dataSignature);
} else {
data.forEach(changelogData => {
const newApiSignature = getSignature(changelogData.newDtsName, changelogData.newApi);
const diffsData = diffs.get(newApiSignature);
if (!diffsData) {
return;
}
diffsData.forEach(diffData => {
diffData.changelog.add(changelogData.changelog);
})
changelogs.delete(dataSignature);
});
}
})
changelogs.forEach((changelogData, signature) => {
changelogData.forEach(changelogApi => {
if (diffs.get(signature)) {
diffs.get(signature).push(formatChangelogApi(changelogApi));
} else {
diffs.set(signature, [formatChangelogApi(changelogApi)]);
}
})
})
return diffs;
}
function formatChangelogApi(changelogApi) {
const filePathObj = handleDtsName(changelogApi.newDtsName);
return {
flag: '函数有变化',
diffOld: oldData,
diffNew: newData,
subsystem: subsystem,
packageName: fileName,
};
packageName: '',
className: changelogApi.newType,
rawText: changelogApi.newApi,
dtsName: filePathObj.dtsPath,
hint: "",
changelogs: [{
version: changelogApi.version,
url: changelogApi.changelog
}],
statusCode: StatusCode.CHANGELOG,
status: StatusMessages[StatusCode.CHANGELOG],
oldMessage: changelogApi.oldApi,
newMessage: changelogApi.newApi
}
}
function handleDtsName(dtsName) {
let packageName = dtsName;
let dtsPath = dtsName;
if (dtsName.indexOf('api/@internal/component/ets') > -1) {
packageName === 'ArkUI';
dtsPath.replace('api/@internal/component/ets', 'component')
} else if (dtsName.indexOf('api/@internal/ets') > -1) {
packageName = dtsName.replace('api/@internal/ets', 'api/@internal/full');
dtsPath = packageName;
}
return { packageName, dtsPath };
}
async function mergeDiffWithChangeLog(diffs, oldVersion, newVersion, allVersionUrl) {
const dataInChangelogs = await mergeDataBetweenVersion(oldVersion, newVersion, allVersionUrl);
const dataMapInChangelogs = covertToMap(dataInChangelogs);
return mergeDiffsAndChangelogs(dataMapInChangelogs, diffs);
}
exports.applyChangeLogs = mergeDiffWithChangeLog;

View File

@ -16,111 +16,37 @@
const path = require('path');
const fs = require('fs');
function readFile(dir, utFiles) {
try {
function listApiDeclarationFiles(dir) {
const allFiles = [];
const apiSubDirs = ['api', 'component'];
apiSubDirs.forEach((subdir) => {
internalListFiles(path.resolve(dir, subdir),
(filePath) => path.basename(filePath).endsWith('.d.ts'), allFiles);
});
return allFiles;
}
function internalListFiles(dir, filter, output) {
if (!fs.existsSync(dir)) {
return;
}
const files = fs.readdirSync(dir);
files.forEach((element) => {
const filePath = path.join(dir, element);
const status = fs.statSync(filePath);
if (status.isDirectory()) {
readFile(filePath, utFiles);
} else if (filePath.indexOf('\\component\\') > 0 || filePath.indexOf('\\api\\') >= 0) {
if (/\.d\.ts/.test(filePath)) {
utFiles.push(filePath);
}
internalListFiles(filePath, filter, output);
} else if (filter(filePath)) {
output.push(filePath);
}
});
} catch (error) {
console.error('ETS ERROR: ' + error);
}
}
function getFilePath(filePath) {
if (filePath.indexOf('\\component\\') > 0 || filePath.indexOf('\\api\\') >= 0) {
if (/\.d\.ts/.test(filePath)) {
return filePath;
}
}
return '';
function isInDirectory(parentDir, subPath) {
const relative = path.relative(parentDir, subPath);
return relative === '' || !relative.startsWith('..');
}
function getSubsystemBySyscap(baseApi, syscap) {
let syscapInfo = '';
let filePath = __dirname.replace('\\src', '') + '\\subsystem.json';
let subsystemArr = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
let subsystemSet = new Set([]);
subsystemArr.forEach(subsystem => {
subsystemSet.add(subsystem.subsystem);
});
if (syscap !== 'N/A' && syscap.new !== 'N/A') {
let syscapArr = syscap instanceof Object ? syscap.new.split('.') : syscap.split('.');
syscapInfo = syscapArr[1];
} else if (baseApi.dtsPath.indexOf('component') > 0) {
syscapInfo = 'ArkUI';
} else {
let fileContent = fs.readFileSync(baseApi.dtsPath, 'utf-8');
if (/\@[S|s][Y|y][S|s][C|c][A|a][P|p]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g.test(fileContent)) {
fileContent.replace(/\@[S|s][Y|y][S|s][C|c][A|a][P|p]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g, sysCapInfo => {
syscapInfo = sysCapInfo.replace(/\@[S|s][Y|y][S|s][C|c][A|a][P|p]/g, '').trim().split('.')[1];
});
}
}
return syscapInfo;
}
// 给api信息添加flag标记
function getApiInfoWithFlag(baseApi, flag, diffOld, diffNew, subsystemMap, syscap, note, fileNameMap) {
return {
packageName: baseApi.packageName,
className: baseApi.className,
methodName: baseApi.methodName,
methodText: baseApi.methodText,
isSystemApi: baseApi.isSystemApi,
version: baseApi.version,
deprecated: baseApi.deprecated,
apiType: baseApi.apiType,
sysCap: baseApi.sysCap,
permission: baseApi.permission,
model: baseApi.model,
useinsteadInfo: baseApi.useinsteadInfo,
errorCode: baseApi.errorCode,
subsystem: subsystemMap.get(syscap),
fileName: fileNameMap.get(syscap),
headimport: baseApi.headimport,
endexport: baseApi.endexport,
dtsPath: baseApi.dtsPath,
flag: flag,
diffOld: diffOld,
diffNew: diffNew,
note: note,
typeInfo: baseApi.typeInfo,
};
}
// 给api信息添加去掉dtsPath
function getApiInfoDeleteDtsPath(baseApi) {
return {
packageName: baseApi.packageName,
className: baseApi.className,
methodName: baseApi.methodName,
methodText: baseApi.methodText,
isSystemApi: baseApi.isSystemApi,
version: baseApi.version,
deprecated: baseApi.deprecated,
apiType: baseApi.apiType,
sysCap: baseApi.sysCap,
permission: baseApi.permission,
model: baseApi.model,
headimport: baseApi.headimport,
endexport: baseApi.endexport,
errorCode: baseApi.errorCode,
typeInfo: baseApi.typeInfo,
};
}
exports.readFile = readFile;
exports.getSubsystemBySyscap = getSubsystemBySyscap;
exports.getApiInfoWithFlag = getApiInfoWithFlag;
exports.getApiInfoDeleteDtsPath = getApiInfoDeleteDtsPath;
exports.listApiDeclarationFiles = listApiDeclarationFiles;
exports.isInDirectory = isInDirectory;

View File

@ -131,5 +131,9 @@
"syscap":"Test",
"subsystem":"测试框架",
"fileName":"unitest"
},{
"syscap":"Base",
"subsystem":"SDK",
"fileName":"sdk"
}
]

View File

@ -1,7 +0,0 @@
{
"oldDir":"D:\\ChromeCoreDownloads\\beta3-beta4\\ohos-sdk-full\\ohos-sdk\\windows",
"newDir":"D:\\ChromeCoreDownloads\\beta3-beta4\\ohos-sdk-windows_linux-full.tar_beta4\\ohos-sdk\\windows",
"oldVersion":"3.2.6.3",
"newVersion":"3.2.7.6"
}

View File

@ -1,50 +0,0 @@
# 差异报告填写说明
1. 每一个版本的差异放在一个文件夹下,文件夹以版本号命名;
2. 文件夹内放置子系统自己填写的md文件一个版本里每个子系统的变更放在一个md文件里md文件以子系统名字命名子系统名字请参照表1
3. 填写API变更时请填写完整的API填写示例请参照表2。
**表1** md文件命名对照表
| 子系统 |
| ---------------- |
| ACE开发框架 |
| 包管理 |
| 图形图像 |
| 窗口管理 |
| 事件通知 |
| 基础通信 |
| 位置服务 |
| 多模输入 |
| 电源服务 |
| OS媒体软件 |
| 电话服务 |
| 全球化 |
| 定制 |
| 无障碍软件服务 |
| 资源调度 |
| 公共基础类库 |
| DFX |
| 升级服务 |
| 分布式硬件 |
| 安全基础能力 |
| 账号 |
| 用户IAM |
| Misc软件服务 |
| 文件管理 |
| USB服务 |
| 泛sensor服务 |
| 启动服务 |
| 分布式数据管理 |
| 元能力 |
| 网络 |
| 应用 |
| 综合传感处理平台 |
| 测试框架 |
**表2** 填写模板
| 旧版本 | 新版本 | 文件 |
| ----------------------------------------------------- | ------------------------------------------------------------ | ------------------- |
| delete(predicates: RdbPredicatesV9): Promise<number>; | delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>; | @ohos.data.rdb.d.ts |

View File

@ -1,39 +0,0 @@
# 应用API解析工具
## 简介
该工具可用于解析应用中使用的API并汇总成表格提供给应用开发者
## 目录
```
├─sdk #存放API文件的目录sdk中ets目录下的api文件夹和build-tools文件夹
├─application #存放被解析的应用源码
├─deps #存放typescript源码
└─src #存放脚本以及生成的表格
```
## 使用方法
### 目录配置
在package.json同级目录下执行npm run pre会新增sdk文件夹和application文件夹
在每日构建上下载full-sdk下载后解压sdk压缩包打开windows文件夹解压ets压缩包将ets文件夹下的api文件夹和build-tools文件夹放到sdk文件夹下
在application文件夹下放置被解析的应用源码
在deps文件夹放置[typescript源码](https://gitee.com/openharmony/third_party_typescript/tree/master/build_package)(如果是在一整个openHarmony仓下运行可直接进行下一步:安装)。
### 安装
需要安装npm依赖环境在package.json同级目录下执行npm install。
### 使用工具
在package.json同级目录下执行npm run collect运行完成后会生成一个表格。
## 相关文件夹
[collect_application_api](https://gitee.com/openharmony/interface_sdk-js/tree/master/build-tools/collect_application_api)

View File

@ -1,20 +1,31 @@
{
"name": "test",
"name": "api_collector",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"type": "commonjs",
"scripts": {
"test": "",
"pre": "mkdir application sdk && echo 'Please add application and sdk package to ./application and ./sdk'",
"collect": "cd src && node collect_application_api.js"
"build": "webpack --mode=production",
"postinstall": "node scripts/copylibs.js",
"test": "mocha ./test/testCase/*.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"commander": "^10.0.0",
"exceljs": "^4.3.0",
"fs": "^0.0.1-security",
"json5": "^2.2.3",
"path": "^0.12.7",
"typescript": "file:./deps/ohos-typescript-4.2.3-r2.tgz",
"@ohos/hvigor":"1.4.0",
"@ohos/hvigor-ohos-plugin":"1.4.0"
"typescript": "file:./deps/ohos-typescript-4.2.3-r2.tgz"
},
"devDependencies": {
"archiver": "^5.3.1",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1",
"@types/node": "^18.11.9",
"@types/chai": "^4.2.11",
"chai": "^4.2.0",
"mocha": "^7.0.2"
}
}

View File

@ -27,11 +27,9 @@
"DataPanel",
"DatePicker",
"Divider",
"EffectComponent",
"Ellipse",
"Flex",
"FormComponent",
"FormLink",
"Gauge",
"GeometryView",
"Grid",
@ -205,11 +203,6 @@
"type": "DividerAttribute",
"instance": "DividerInstance"
},
{
"name": "EffectComponent",
"type": "EffectComponentAttribute",
"instance": "EffectComponentInstance"
},
{
"name": "Ellipse",
"type": "EllipseAttribute",
@ -225,11 +218,6 @@
"type": "FormComponentAttribute",
"instance": "FormComponentInstance"
},
{
"name": "FormLink",
"type": "FormLinkAttribute",
"instance": "FormLinkInstance"
},
{
"name": "Gauge",
"type": "GaugeAttribute",
@ -587,8 +575,11 @@
"property": "stateStyles"
},
"customComponent": "CustomComponent",
"propertyDecorators": [],
"emitDecorators": [],
"libs": []
},
"allowJs": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"importsNotUsedAsValues": "preserve",

View File

@ -1,62 +0,0 @@
# Api-Diff对比工具
## 简介
该工具可用于对比两个版本SDK里的API差异并汇总成表格提供给应用开发者。
## 目录
```
├─test #测试用例存放路径
└─src #源码存放路径
```
## 使用方法
### 安装
需要安装npm依赖环境在package.json同级目录下执行npm install。
### 使用工具
查看工具命令行参数在package.json同级目录下运行
```
node .\src\entry\main.js diff -h
Usage: diff [options]
Compare the differences between the two SDKS
Options:
-V, --version output the version number
--old <string> old sdk path
--new <string> new sdk path
--oldVersion <string> old sdk version
--newVersion <string> new sdk version
--output <string> output file path
--format <json, excel, changelog> output file format
--newPath <string> new interface_sdk-js path
--oldPath <string> old interface_sdk-js path
--changelogUrl <string> changelog url
-h, --help display help for command
```
生成diff报告在package.json同级目录下运行
```
node .\src\entry\main.js diff --old 旧版本sdk根目录/windows/ets --new 新版本sdk根目录/windows/ets --oldVersion 旧版本SDK版本号 --newVersion 新版本SDK版本号 --output 输出路径 --format 报告格式报告格式可选择excel或者json
```
如果需要跟每个版本的changelog进行合并命令行中还需添加参数changelogUrl
获取changelogUrl在gitee中打开changelog文件夹下名为allVersion.json的文件点击查看原始数据此时的网址链接即为changelogUrl。
```
node .\src\entry\main.js diff --old 旧版本sdk根目录/windows/ets --new 新版本sdk根目录/windows/ets --oldVersion 旧版本SDK版本号 --newVersion 新版本SDK版本号 --output 输出路径 --format 报告格式报告格式可选择excel或者json--changelogUrl 网址链接
```
生成changelog配置文件在package.json同级目录下运行
```
node .\src\entry\main.js diff --oldPath 旧版本interface_sdk-js根目录 --new 新版本旧版本interface_sdk-js根目录 --oldVersion 旧版本号 --newVersion 新版本号 --output 输出路径 --format changelog
```

View File

@ -1,31 +0,0 @@
{
"name": "api_diff",
"version": "1.0.0",
"description": "Compare two SDKS and print the difference",
"main": "src/index.js",
"scripts": {
"diff": "cd src && node collect_api.js",
"test": "mocha ./test/testCase/*.js",
"build": "webpack --mode=production"
},
"author": "",
"license": "ISC",
"dependencies": {
"compressing": "^1.6.1",
"exceljs": "^4.3.0",
"fs": "0.0.1-security",
"node-xlsx": "^0.21.0",
"path": "^0.12.7",
"typescript": "^4.8.2",
"comment-parser": "1.3.1",
"commander": "^10.0.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
"@types/chai": "^4.2.11",
"chai": "^4.2.0",
"mocha": "^7.0.2",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1"
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* 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.
*/
const path = require('path');
const fs = require('fs');
function listApiDeclarationFiles(dir) {
const allFiles = [];
const apiSubDirs = ['api', 'component'];
apiSubDirs.forEach((subdir) => {
internalListFiles(path.resolve(dir, subdir),
(filePath) => path.basename(filePath).endsWith('.d.ts'), allFiles);
});
return allFiles;
}
function internalListFiles(dir, filter, output) {
if (!fs.existsSync(dir)) {
return;
}
const files = fs.readdirSync(dir);
files.forEach((element) => {
const filePath = path.join(dir, element);
const status = fs.statSync(filePath);
if (status.isDirectory()) {
internalListFiles(filePath, filter, output);
} else if (filter(filePath)) {
output.push(filePath);
}
});
}
function isInDirectory(parentDir, subPath) {
const relative = path.relative(parentDir, subPath);
return relative === '' || !relative.startsWith('..');
}
exports.listApiDeclarationFiles = listApiDeclarationFiles;
exports.isInDirectory = isInDirectory;

View File

@ -1,139 +0,0 @@
[
{
"syscap":"ArkUI",
"subsystem":"ACE开发框架",
"fileName":"arkui"
},{
"syscap":"BundleManager",
"subsystem":"包管理",
"fileName":"bundle"
},{
"syscap":"Graphic",
"subsystem":"图形图像",
"fileName":"graphic"
},{
"syscap":"WindowManager",
"subsystem":"窗口管理",
"fileName":"window"
},{
"syscap":"Notification",
"subsystem":"事件通知",
"fileName":"notification"
},{
"syscap":"Communication",
"subsystem":"基础通信",
"fileName":"communication"
},{
"syscap":"Location",
"subsystem":"位置服务",
"fileName":"geolocation"
},{
"syscap":"MultimodalInput",
"subsystem":"多模输入",
"fileName":"multi-modal-input"
},{
"syscap":"PowerManager",
"subsystem":"电源服务",
"fileName":"battery"
},{
"syscap":"Multimedia",
"subsystem":"OS媒体软件",
"fileName":"multimedia"
},{
"syscap":"Telephony",
"subsystem":"电话服务",
"fileName":"telephony"
},{
"syscap":"Global",
"subsystem":"全球化",
"fileName":"global"
},{
"syscap":"Customization",
"subsystem":"定制子系统",
"fileName":"customization"
},{
"syscap":"BarrierFree",
"subsystem":"无障碍软件服务",
"fileName":"accessibility"
},{
"syscap":"ResourceSchedule",
"subsystem":"资源调度",
"fileName":"resource-scheduler"
},{
"syscap":"Utils",
"subsystem":"公共基础类库",
"fileName":"compiler-and-runtime"
},{
"syscap":"HiviewDFX",
"subsystem":"DFX",
"fileName":"dfx"
},{
"syscap":"Update",
"subsystem":"升级服务子系统",
"fileName":"update"
},{
"syscap":"DistributedHardware",
"subsystem":"分布式硬件",
"fileName":"distributed-hardware"
},{
"syscap":"Security",
"subsystem":"安全基础能力",
"fileName":"security"
},{
"syscap":"Account",
"subsystem":"账号子系统",
"fileName":"account"
},{
"syscap":"UserIAM",
"subsystem":"用户IAM",
"fileName":"user-iam"
},{
"syscap":"MiscServices",
"subsystem":"Misc软件服务",
"fileName":"misc"
},{
"syscap":"FileManagement",
"subsystem":"文件管理",
"fileName":"file-management"
},{
"syscap":"USB",
"subsystem":"USB服务",
"fileName":"usb"
},{
"syscap":"Sensors",
"subsystem":"泛sensor服务",
"fileName":"sensor"
},{
"syscap":"Startup",
"subsystem":"启动服务",
"fileName":"start-up"
},{
"syscap":"DistributedDataManager",
"subsystem":"分布式数据管理",
"fileName":"distributed-data"
},{
"syscap":"Ability",
"subsystem":"元能力",
"fileName":"ability"
},{
"syscap":"Web",
"subsystem":"网络",
"fileName":"web"
},{
"syscap":"Applications",
"subsystem":"应用子系统",
"fileName":"application"
},{
"syscap":"Msdp",
"subsystem":"综合传感处理平台",
"fileName":"msdp"
},{
"syscap":"Test",
"subsystem":"测试框架",
"fileName":"unitest"
},{
"syscap":"Base",
"subsystem":"SDK",
"fileName":"sdk"
}
]