Skip to content

Commit 05927dc

Browse files
committed
Create tpip report and commit on main
1 parent b3c0512 commit 05927dc

File tree

6 files changed

+130
-1
lines changed

6 files changed

+130
-1
lines changed

.github/workflows/tpip.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/tpip.yml'
7+
- docs/third-party-licenses.json
8+
- docs/tpip-header.md
9+
- scripts/tpip-reporter.ts
10+
branches:
11+
- main
12+
13+
workflow_dispatch:
14+
15+
jobs:
16+
report:
17+
name: Generate Third-Party licenses report
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.ref_name }}
23+
24+
- uses: actions/setup-node@v2
25+
with:
26+
node-version: '20'
27+
cache: 'yarn'
28+
29+
- name: Install dependencies
30+
run: yarn --frozen-lockfile --prefer-offline
31+
32+
- name: Generate third-party licenses report
33+
run: yarn run tpip:report
34+
35+
- name: Commit changes
36+
run: |
37+
git config --local user.email "[email protected]
38+
git config --local user.name "GitHub Action"
39+
git add TPIP.md
40+
git commit -m "Update third-party licenses report [skip ci]"
41+
git push

TPIP.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TPIP Report for vscode-cmsis-debugger
2+
3+
Report prepared at : 26/02/2025, 16:50:28
4+
5+
| *Package* | *Version* | *Repository* | *License* |
6+
|---|---|---|---|
7+
| pyocd | 0.36.0 | https://github.com/pyocd/pyOCD | https://github.com/pyocd/pyOCD/blob/v0.36.0/LICENSE |

docs/third-party-licenses.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"name": "pyocd",
4+
"version": "0.36.0",
5+
"spdx": "Apache-2.0",
6+
"url": "https://github.com/pyocd/pyOCD",
7+
"license": "https://github.com/pyocd/pyOCD/blob/v0.36.0/LICENSE"
8+
}
9+
]

docs/tpip-header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TPIP Report for vscode-cmsis-debugger
2+

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@
228228
"watch": "webpack -w",
229229
"lint": "eslint .",
230230
"test": "jest",
231-
"package": "vsce package --yarn"
231+
"package": "vsce package --yarn",
232+
"tpip:report": "ts-node scripts/tpip-reporter --header docs/tpip-header.md docs/third-party-licenses.json TPIP.md"
232233
},
233234
"vsce": {
234235
"yarn": true,

scripts/tpip-reporter.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!npx ts-node
2+
3+
/**
4+
* Copyright 2025 Arm Limited
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import yargs from "yargs";
20+
import { hideBin } from "yargs/helpers";
21+
import fs from "fs";
22+
23+
async function main() {
24+
25+
const { json, report, header } = yargs(hideBin(process.argv))
26+
.usage('Usage: $0 <json> <report> [--header <header>]')
27+
.options('header', {
28+
describe: 'Header to add to the report',
29+
type: 'string'
30+
})
31+
.command('$0 <json> <report>', '', y => {
32+
y.positional('json', {
33+
describe: 'JSON file to parse',
34+
type: 'string'
35+
});
36+
y.positional('report', {
37+
describe: 'Report file to generate',
38+
type: 'string'
39+
});
40+
})
41+
.help('h')
42+
.version(false)
43+
.strict()
44+
.parseSync();
45+
46+
const tpipJson = JSON.parse(fs.readFileSync(json as string, "utf8"));
47+
48+
var data: string = '';
49+
if (header && fs.existsSync(header as string)) {
50+
data += fs.readFileSync(header as string, "utf8");
51+
} else {
52+
data += "# TPIP Report\n\n";
53+
}
54+
55+
data += `Report prepared at: ${new Date().toLocaleString('en-GB')}\n\n`;
56+
data += '| *Package* | *Version* | *Repository* | *License* |\n';
57+
data += '|---|---|---|---|\n';
58+
59+
for(const value of tpipJson) {
60+
data += `| ${value.name} | ${value.version} | ${value.url} | ${value.license} |\n`;
61+
}
62+
63+
fs.writeFileSync(report as string, data);
64+
}
65+
66+
main().catch(error => {
67+
console.error(error);
68+
process.exit(1);
69+
});

0 commit comments

Comments
 (0)