Skip to content

Commit be1beb1

Browse files
authored
add license banner for ui packages (#184)
* feat: add license banner for translators/dashboard/terminal/xterm-addon-overlay/xterm-addon-zmodem Signed-off-by: warjiang <[email protected]> * chore: ignore license check for node_modules、husky Signed-off-by: warjiang <[email protected]> * ci: switch to turbo build Signed-off-by: warjiang <[email protected]> --------- Signed-off-by: warjiang <[email protected]>
1 parent a69df28 commit be1beb1

File tree

21 files changed

+245
-21
lines changed

21 files changed

+245
-21
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
echo "Start build"
4949
pnpm --version
5050
cd ui
51-
pnpm install --filter @karmada/dashboard
52-
pnpm run dashboard:build
51+
pnpm install
52+
pnpm turbo build
5353
build-bin:
5454
name: build-bin
5555
runs-on: ubuntu-22.04

hack/karmada-license.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Copyright {{year}} The Karmada Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/

hack/verify-license.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ missing_license_header_files="$($ADDLICENSE_BIN \
4040
-ignore "**/*.yml" \
4141
-ignore "**/*.json" \
4242
-ignore ".idea/**" \
43+
-ignore "**/*/node_modules/**" \
44+
-ignore "ui/.husky/**" \
4345
.)" || true
4446

4547
if [[ "$missing_license_header_files" ]]; then

ui/apps/dashboard/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
]
2727
},
2828
"dependencies": {
29-
"@karmada/dashboard": "link:",
30-
"@karmada/i18n-tool": "link:",
29+
"@karmada/i18n-tool": "workspace:*",
30+
"@karmada/utils": "workspace:*",
3131
"@monaco-editor/react": "^4.6.0",
3232
"@tanstack/react-query": "^5.59.8",
3333
"@uidotdev/usehooks": "^2.4.1",
@@ -65,6 +65,7 @@
6565
"tailwindcss": "^3.4.13",
6666
"typescript": "^5.6.3",
6767
"vite": "^5.4.8",
68+
"vite-plugin-banner": "^0.8.0",
6869
"vite-plugin-dynamic-base": "^1.1.0",
6970
"vite-plugin-svgr": "^4.2.0"
7071
}

ui/apps/dashboard/vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import react from '@vitejs/plugin-react';
1919
import svgr from 'vite-plugin-svgr';
2020
import path from 'path';
2121
import { dynamicBase } from 'vite-plugin-dynamic-base';
22+
import banner from 'vite-plugin-banner';
23+
import { getLicense } from '@karmada/utils';
2224

2325
const replacePathPrefixPlugin = (): Plugin => {
2426
return {
@@ -34,10 +36,13 @@ const replacePathPrefixPlugin = (): Plugin => {
3436

3537
// https://vitejs.dev/config/
3638
export default defineConfig(({ mode }) => {
39+
const license = getLicense();
40+
3741
const env = loadEnv(mode, process.cwd(), '');
3842
return {
3943
base: process.env.NODE_ENV === 'development' ? '' : '/static',
4044
plugins: [
45+
banner(license) as Plugin,
4146
react(),
4247
svgr(),
4348
replacePathPrefixPlugin(),

ui/packages/terminal/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"dependencies": {
3232
"@karmada/xterm-addon-overlay": "workspace:*",
3333
"@karmada/xterm-addon-zmodem": "workspace:*",
34+
"@karmada/utils": "workspace:*",
3435
"@xterm/addon-canvas": "^0.7.0",
3536
"@xterm/addon-clipboard": "^0.1.0",
3637
"@xterm/addon-fit": "^0.10.0",

ui/packages/terminal/tsup.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ limitations under the License.
1515
*/
1616

1717
import { defineConfig } from 'tsup';
18+
import { getLicense } from '@karmada/utils';
19+
20+
const license = getLicense();
1821

1922
export default defineConfig({
2023
entry: ['src/index.tsx'],
@@ -23,5 +26,10 @@ export default defineConfig({
2326
clean: true,
2427
format: ['cjs', 'esm'],
2528
// external: ['react'],
26-
dts: true,
29+
dts: {
30+
banner: license,
31+
},
32+
banner: {
33+
js: license,
34+
},
2735
});

ui/packages/translators/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
},
2424
"dependencies": {
2525
"got": "^14.4.2",
26-
"openai": "^4.63.0"
26+
"openai": "^4.63.0",
27+
"@karmada/utils": "workspace:*"
2728
}
2829
}

ui/packages/translators/tsup.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ limitations under the License.
1515
*/
1616

1717
import { defineConfig } from 'tsup';
18+
import {getLicense} from '@karmada/utils';
1819

20+
const license = getLicense()
1921
export default defineConfig({
2022
entry: ['src/index.ts'],
2123
splitting: false,
2224
sourcemap: true,
2325
clean: true,
2426
format: ['cjs', 'esm'],
2527
dts: false,
28+
banner: {
29+
js: license
30+
}
2631
});

ui/packages/utils/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build
3+
coverage
4+
dist
5+
pnpm-*

ui/packages/utils/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true,
4+
"printWidth": 80,
5+
"tabWidth": 2,
6+
"endOfLine": "auto"
7+
}

ui/packages/utils/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@karmada/utils",
3+
"version": "1.0.0",
4+
"publishConfig": {
5+
"access": "public"
6+
},
7+
"description": "",
8+
"exports": {
9+
".": {
10+
"require": "./dist/index.js",
11+
"import": "./dist/index.mjs"
12+
}
13+
},
14+
"types": "dist/index.d.ts",
15+
"scripts": {
16+
"prepublish": "tsup --config ./tsup.config.ts",
17+
"build": "tsup --config ./tsup.config.ts"
18+
},
19+
"lint-staged": {
20+
"**/*.{js,jsx,ts,tsx,json,css,md}": [
21+
"prettier --write"
22+
]
23+
},
24+
"keywords": [],
25+
"author": "",
26+
"license": "ISC"
27+
}

ui/packages/utils/src/index.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2025 The Karmada Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import * as path from 'path';
18+
import * as fs from 'fs';
19+
import { fileURLToPath } from 'url';
20+
21+
/**
22+
* return karmada license content according to year.
23+
* @param year optional, if not set year, use currentYear instead
24+
*/
25+
export function getLicense(year: string = ''): string {
26+
const __filename = fileURLToPath(import.meta.url);
27+
const currentDir = path.dirname(__filename);
28+
// __filename in dist dir
29+
const workspaceRootDir = path.resolve(currentDir, '../../../../');
30+
const licenseTplPath = path.join(
31+
workspaceRootDir,
32+
'./hack/karmada-license.tpl',
33+
);
34+
const tplContent = fs.readFileSync(licenseTplPath).toString();
35+
36+
let _year = year;
37+
if (_year === '') {
38+
_year = new Date().getFullYear().toString();
39+
}
40+
return tplContent.replace(/\{\{year\}\}/g, _year);
41+
}

ui/packages/utils/tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"module": "ESNext",
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"noEmit": true,
15+
"jsx": "react-jsx",
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true
22+
},
23+
"include": ["src"],
24+
"references": [{ "path": "./tsconfig.node.json" }]
25+
}

ui/packages/utils/tsconfig.node.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true,
8+
"strict": true
9+
},
10+
"include": ["vite.config.ts"]
11+
}

ui/packages/utils/tsup.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2025 The Karmada Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { defineConfig } from 'tsup';
18+
19+
export default defineConfig({
20+
entry: ['src/index.ts'],
21+
splitting: false,
22+
sourcemap: true,
23+
clean: true,
24+
dts: true,
25+
format: ['cjs', 'esm'],
26+
});

ui/packages/xterm-addon-overlay/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
],
2929
"author": "",
3030
"license": "ISC",
31+
"dependencies": {
32+
"@karmada/utils": "workspace:*"
33+
},
3134
"peerDependencies": {
3235
"@xterm/xterm": "^5.0.0"
3336
}

ui/packages/xterm-addon-overlay/tsup.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ limitations under the License.
1515
*/
1616

1717
import { defineConfig } from 'tsup';
18+
import { getLicense } from '@karmada/utils';
1819

20+
const license = getLicense();
1921
export default defineConfig({
2022
entry: ['src/index.ts'],
2123
splitting: false,
2224
sourcemap: true,
2325
clean: true,
2426
format: ['cjs', 'esm'],
25-
dts: true,
27+
dts: {
28+
banner: license,
29+
},
30+
banner: {
31+
js: license,
32+
},
2633
});

ui/packages/xterm-addon-zmodem/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"author": "",
3030
"license": "ISC",
3131
"dependencies": {
32-
"@karmada/xterm-addon-zmodem": "link:",
32+
"@karmada/utils": "workspace:*",
3333
"file-saver": "^2.0.5",
3434
"trzsz": "^1.1.5",
3535
"zmodem.js": "^0.1.10"

ui/packages/xterm-addon-zmodem/tsup.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ limitations under the License.
1515
*/
1616

1717
import { defineConfig } from 'tsup';
18+
import { getLicense } from '@karmada/utils';
19+
20+
const license = getLicense();
1821

1922
export default defineConfig({
2023
entry: ['src/index.ts'],
2124
splitting: false,
2225
sourcemap: true,
2326
clean: true,
2427
format: ['cjs', 'esm'],
25-
dts: true,
28+
dts: {
29+
banner: license,
30+
},
31+
banner: {
32+
js: license,
33+
},
2634
});

0 commit comments

Comments
 (0)