Skip to content

Commit 7e35eaa

Browse files
committed
2 parents afd942b + 4246c3b commit 7e35eaa

File tree

5 files changed

+195
-4
lines changed

5 files changed

+195
-4
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
GITHUB_TOKEN: ${{github.token}}
8181
run: yarn --frozen-lockfile --prefer-offline
8282

83+
- name: Check copyright
84+
run: yarn copyright:check
85+
8386
- name: Test
8487
run: yarn test
8588

@@ -208,11 +211,19 @@ jobs:
208211
with:
209212
pattern: test-report
210213

214+
- name: Zip test report
215+
run: zip -r test-report.zip *
216+
working-directory: test-report
217+
218+
- name: Zip test coverage
219+
run: zip -r test-coverage.zip *
220+
working-directory: test-coverage
221+
211222
- name: Attach packages
212223
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
213224
with:
214225
files: |
215226
**/*.vsix
216-
test-report.html
217-
coverage/*
227+
test-coverage/test-coverage.zip
228+
test-report/test-report.zip
218229

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ under the following licenses:
1212
The full license text of applicable licenses is provided below.
1313

1414
=============================================================================
15+
1516
Apache License
1617
Version 2.0, January 2004
1718
http://www.apache.org/licenses/
@@ -215,6 +216,7 @@ The full license text of applicable licenses is provided below.
215216
limitations under the License.
216217

217218
=============================================================================
219+
218220
GNU GENERAL PUBLIC LICENSE
219221
Version 3, 29 June 2007
220222

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
"package": "vsce package --yarn",
9797
"tpip:report": "ts-node scripts/tpip-reporter --header docs/tpip-header.md docs/third-party-licenses.json TPIP.md",
9898
"lint:md": "markdownlint **/*.md -c ./.github/markdownlint.jsonc -i ./node_modules ./dist ./coverage ./tools",
99-
"check:links": "ts-node scripts/check-links.ts -i ./node_modules/** -i ./.github/** -c ./.github/markdown-link-check.jsonc"
99+
"check:links": "ts-node scripts/check-links.ts -i ./node_modules/** -i ./.github/** -c ./.github/markdown-link-check.jsonc",
100+
"copyright:check": "ts-node scripts/copyright-manager.ts --mode=check --include=src/**/*.ts,scripts/**/*.ts --exclude=**/node_modules/**,coverage/**,dist/**,tools/**",
101+
"copyright:fix": "ts-node scripts/copyright-manager.ts --mode=fix --include=src/**/*.ts,scripts/**/*.ts --exclude=**/node_modules/**,coverage/**,dist/**,tools/**"
100102
},
101103
"vsce": {
102104
"yarn": true,
@@ -106,7 +108,9 @@
106108
"yaml": "^2.8.0"
107109
},
108110
"devDependencies": {
111+
"@types/fs-extra": "^11.0.4",
109112
"@types/jest": "^30.0.0",
113+
"@types/minimist": "^1.2.5",
110114
"@types/node": "^20.19.7",
111115
"@types/node-fetch": "^2.6.12",
112116
"@types/vscode": "^1.63.0",
@@ -121,12 +125,15 @@
121125
"extract-zip": "^2.0.1",
122126
"fast-extract": "^1.7.2",
123127
"file-type": "^21.0.0",
128+
"fs-extra": "^11.3.0",
129+
"glob": "^11.0.3",
124130
"globby": "^14.1.0",
125131
"jest": "^30.0.4",
126132
"jest-html-reporter": "^4.3.0",
127133
"lzma-native": "8.0.6",
128134
"markdown-link-check": "^3.13.7",
129135
"markdownlint-cli": "^0.45.0",
136+
"minimist": "^1.2.8",
130137
"node-fetch": "^3.3.2",
131138
"octokit": "^5.0.3",
132139
"tempfile": "^5.0.0",

scripts/copyright-manager.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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 fs from 'fs-extra';
20+
import * as glob from 'glob';
21+
import minimist from 'minimist';
22+
23+
const args = minimist(process.argv.slice(2));
24+
const mode = args.mode || 'check';
25+
const includeGlobs: string[] = args.include ? args.include.split(',') : ['src/**/*.ts', 'scripts/**/*.ts'];
26+
const excludeGlobs: string[] = args.exclude ? args.exclude.split(',') : ['**/node_modules/**,coverage/**,dist/**,tools/**'];
27+
28+
const COPYRIGHT_TEXT = `/**
29+
* Copyright 2025 Arm Limited
30+
*
31+
* Licensed under the Apache License, Version 2.0 (the "License");
32+
* you may not use this file except in compliance with the License.
33+
* You may obtain a copy of the License at
34+
*
35+
* http://www.apache.org/licenses/LICENSE-2.0
36+
*
37+
* Unless required by applicable law or agreed to in writing, software
38+
* distributed under the License is distributed on an "AS IS" BASIS,
39+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40+
* See the License for the specific language governing permissions and
41+
* limitations under the License.
42+
*/`;
43+
44+
// Regular expression to match the copyright notice
45+
const COPYRIGHT_REGEX = /\/\*\*\n \* Copyright 2025(?:-(?:20\d{2}))? Arm Limited[\s\S]*?\*\//;
46+
47+
48+
function getFiles(): string[] {
49+
const allFiles: string[] = [];
50+
for (const pattern of includeGlobs) {
51+
try {
52+
const matchedFiles = glob.sync(pattern, {
53+
ignore: excludeGlobs,
54+
absolute: true,
55+
cwd: process.cwd(),
56+
});
57+
allFiles.push(...matchedFiles);
58+
} catch (err) {
59+
console.error(`Error processing pattern "${pattern}":`, err);
60+
}
61+
}
62+
return allFiles;
63+
}
64+
65+
function hasCopyrightNotice(content: string): boolean {
66+
return COPYRIGHT_REGEX.test(content);
67+
}
68+
69+
function checkFiles(files: string[]) {
70+
const violations = files.filter(file => {
71+
const content = fs.readFileSync(file, 'utf-8');
72+
return !hasCopyrightNotice(content);
73+
});
74+
75+
if (violations.length > 0) {
76+
console.error('error: Missing copyright notice:');
77+
violations.forEach(f => console.error(` - ${f}`));
78+
process.exit(1);
79+
} else {
80+
console.log('All files are compliant.');
81+
}
82+
}
83+
84+
function fixFiles(files: string[]) {
85+
files.forEach(file => {
86+
const content = fs.readFileSync(file, 'utf-8');
87+
if (!hasCopyrightNotice(content)) {
88+
const newContent = `${COPYRIGHT_TEXT}\n\n${content}`;
89+
fs.writeFileSync(file, newContent, 'utf-8');
90+
console.log(`Fixed: ${file}`);
91+
}
92+
});
93+
console.log('Fix completed.');
94+
}
95+
96+
function main() {
97+
const files = getFiles();
98+
if (mode === 'fix') {
99+
fixFiles(files);
100+
} else {
101+
checkFiles(files);
102+
}
103+
}
104+
105+
main();

yarn.lock

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,18 @@
575575
resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.2.tgz#1860473de7dfa1546767448f333db80cb0ff2161"
576576
integrity sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ==
577577

578+
"@isaacs/balanced-match@^4.0.1":
579+
version "4.0.1"
580+
resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29"
581+
integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==
582+
583+
"@isaacs/brace-expansion@^5.0.0":
584+
version "5.0.0"
585+
resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz#4b3dabab7d8e75a429414a96bd67bf4c1d13e0f3"
586+
integrity sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==
587+
dependencies:
588+
"@isaacs/balanced-match" "^4.0.1"
589+
578590
"@isaacs/cliui@^8.0.2":
579591
version "8.0.2"
580592
resolved "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz"
@@ -1443,6 +1455,14 @@
14431455
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e"
14441456
integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==
14451457

1458+
"@types/fs-extra@^11.0.4":
1459+
version "11.0.4"
1460+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.4.tgz#e16a863bb8843fba8c5004362b5a73e17becca45"
1461+
integrity sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==
1462+
dependencies:
1463+
"@types/jsonfile" "*"
1464+
"@types/node" "*"
1465+
14461466
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.1", "@types/istanbul-lib-coverage@^2.0.6":
14471467
version "2.0.6"
14481468
resolved "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz"
@@ -1475,11 +1495,23 @@
14751495
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz"
14761496
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
14771497

1498+
"@types/jsonfile@*":
1499+
version "6.1.4"
1500+
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.4.tgz#614afec1a1164e7d670b4a7ad64df3e7beb7b702"
1501+
integrity sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==
1502+
dependencies:
1503+
"@types/node" "*"
1504+
14781505
"@types/katex@^0.16.0":
14791506
version "0.16.7"
14801507
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.16.7.tgz#03ab680ab4fa4fbc6cb46ecf987ecad5d8019868"
14811508
integrity sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==
14821509

1510+
"@types/minimist@^1.2.5":
1511+
version "1.2.5"
1512+
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.5.tgz#ec10755e871497bcd83efe927e43ec46e8c0747e"
1513+
integrity sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==
1514+
14831515
"@types/ms@*":
14841516
version "2.1.0"
14851517
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-2.1.0.tgz#052aa67a48eccc4309d7f0191b7e41434b90bb78"
@@ -3472,6 +3504,14 @@ foreground-child@^3.1.0:
34723504
cross-spawn "^7.0.0"
34733505
signal-exit "^4.0.1"
34743506

3507+
foreground-child@^3.3.1:
3508+
version "3.3.1"
3509+
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.1.tgz#32e8e9ed1b68a3497befb9ac2b6adf92a638576f"
3510+
integrity sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==
3511+
dependencies:
3512+
cross-spawn "^7.0.6"
3513+
signal-exit "^4.0.1"
3514+
34753515
form-data@^4.0.0:
34763516
version "4.0.1"
34773517
resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz"
@@ -3493,7 +3533,7 @@ fs-constants@^1.0.0:
34933533
resolved "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz"
34943534
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
34953535

3496-
fs-extra@^11.1.1:
3536+
fs-extra@^11.1.1, fs-extra@^11.3.0:
34973537
version "11.3.0"
34983538
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.3.0.tgz#0daced136bbaf65a555a326719af931adc7a314d"
34993539
integrity sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==
@@ -3630,6 +3670,18 @@ glob@^11.0.0, glob@~11.0.2:
36303670
package-json-from-dist "^1.0.0"
36313671
path-scurry "^2.0.0"
36323672

3673+
glob@^11.0.3:
3674+
version "11.0.3"
3675+
resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.3.tgz#9d8087e6d72ddb3c4707b1d2778f80ea3eaefcd6"
3676+
integrity sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==
3677+
dependencies:
3678+
foreground-child "^3.3.1"
3679+
jackspeak "^4.1.1"
3680+
minimatch "^10.0.3"
3681+
minipass "^7.1.2"
3682+
package-json-from-dist "^1.0.0"
3683+
path-scurry "^2.0.0"
3684+
36333685
glob@^7.1.4:
36343686
version "7.2.3"
36353687
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
@@ -4071,6 +4123,13 @@ jackspeak@^4.0.1:
40714123
dependencies:
40724124
"@isaacs/cliui" "^8.0.2"
40734125

4126+
jackspeak@^4.1.1:
4127+
version "4.1.1"
4128+
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.1.1.tgz#96876030f450502047fc7e8c7fcf8ce8124e43ae"
4129+
integrity sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==
4130+
dependencies:
4131+
"@isaacs/cliui" "^8.0.2"
4132+
40744133
jake@^10.8.5:
40754134
version "10.9.2"
40764135
resolved "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz"
@@ -5203,6 +5262,13 @@ minimatch@^10.0.0, minimatch@~10.0.1:
52035262
dependencies:
52045263
brace-expansion "^2.0.1"
52055264

5265+
minimatch@^10.0.3:
5266+
version "10.0.3"
5267+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.3.tgz#cf7a0314a16c4d9ab73a7730a0e8e3c3502d47aa"
5268+
integrity sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==
5269+
dependencies:
5270+
"@isaacs/brace-expansion" "^5.0.0"
5271+
52065272
minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
52075273
version "3.1.2"
52085274
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"

0 commit comments

Comments
 (0)