chore: add engineering improvements
- Configure Prettier with unified code style rules - Add husky + lint-staged for automated pre-commit checks - Add commitlint to enforce conventional commit messages - Add PR check workflow for CI automation - Auto-format all files with Prettier - Fix TypeScript any types in field-crypto.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
21
.commitlintrc.json
Normal file
21
.commitlintrc.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@commitlint/config-conventional"],
|
||||||
|
"rules": {
|
||||||
|
"type-enum": [
|
||||||
|
2,
|
||||||
|
"always",
|
||||||
|
[
|
||||||
|
"feat",
|
||||||
|
"fix",
|
||||||
|
"docs",
|
||||||
|
"style",
|
||||||
|
"refactor",
|
||||||
|
"perf",
|
||||||
|
"test",
|
||||||
|
"chore",
|
||||||
|
"revert"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"subject-case": [0]
|
||||||
|
}
|
||||||
|
}
|
||||||
34
.github/workflows/pr-check.yml
vendored
Normal file
34
.github/workflows/pr-check.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: PR Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main, dev-*]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-and-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
cache: "npm"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run ESLint
|
||||||
|
run: npx eslint .
|
||||||
|
|
||||||
|
- name: Run Prettier check
|
||||||
|
run: npx prettier --check .
|
||||||
|
|
||||||
|
- name: Type check
|
||||||
|
run: npx tsc --noEmit
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
1
.husky/commit-msg
Normal file
1
.husky/commit-msg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npx --no -- commitlint --edit $1
|
||||||
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npx lint-staged
|
||||||
@@ -1,3 +1,23 @@
|
|||||||
# Ignore artifacts:
|
# Ignore artifacts:
|
||||||
build
|
build
|
||||||
coverage
|
coverage
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
release
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
pnpm-lock.yaml
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
# Database
|
||||||
|
db
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
*.min.js
|
||||||
|
*.min.css
|
||||||
|
openapi.json
|
||||||
|
|||||||
10
.prettierrc
10
.prettierrc
@@ -1 +1,9 @@
|
|||||||
{}
|
{
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": false,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"printWidth": 80,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"endOfLine": "lf"
|
||||||
|
}
|
||||||
|
|||||||
1506
package-lock.json
generated
1506
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -20,7 +20,8 @@
|
|||||||
"build:linux-appimage": "npm run build && electron-builder --linux AppImage",
|
"build:linux-appimage": "npm run build && electron-builder --linux AppImage",
|
||||||
"build:linux-targz": "npm run build && electron-builder --linux tar.gz",
|
"build:linux-targz": "npm run build && electron-builder --linux tar.gz",
|
||||||
"test:encryption": "tsc -p tsconfig.node.json && node ./dist/backend/backend/utils/encryption-test.js",
|
"test:encryption": "tsc -p tsconfig.node.json && node ./dist/backend/backend/utils/encryption-test.js",
|
||||||
"migrate:encryption": "tsc -p tsconfig.node.json && node ./dist/backend/backend/utils/encryption-migration.js"
|
"migrate:encryption": "tsc -p tsconfig.node.json && node ./dist/backend/backend/utils/encryption-migration.js",
|
||||||
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/autocomplete": "^6.18.7",
|
"@codemirror/autocomplete": "^6.18.7",
|
||||||
@@ -105,6 +106,8 @@
|
|||||||
"zod": "^4.0.5"
|
"zod": "^4.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@commitlint/cli": "^20.1.0",
|
||||||
|
"@commitlint/config-conventional": "^20.0.0",
|
||||||
"@eslint/js": "^9.34.0",
|
"@eslint/js": "^9.34.0",
|
||||||
"@types/better-sqlite3": "^7.6.13",
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
"@types/cors": "^2.8.19",
|
"@types/cors": "^2.8.19",
|
||||||
@@ -123,9 +126,20 @@
|
|||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.20",
|
"eslint-plugin-react-refresh": "^0.4.20",
|
||||||
"globals": "^16.3.0",
|
"globals": "^16.3.0",
|
||||||
|
"husky": "^9.1.7",
|
||||||
|
"lint-staged": "^16.2.3",
|
||||||
"prettier": "3.6.2",
|
"prettier": "3.6.2",
|
||||||
"typescript": "~5.9.2",
|
"typescript": "~5.9.2",
|
||||||
"typescript-eslint": "^8.40.0",
|
"typescript-eslint": "^8.40.0",
|
||||||
"vite": "^7.1.5"
|
"vite": "^7.1.5"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,jsx,ts,tsx}": [
|
||||||
|
"eslint --fix",
|
||||||
|
"prettier --write"
|
||||||
|
],
|
||||||
|
"*.{json,css,md}": [
|
||||||
|
"prettier --write"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,7 @@ class FieldCrypto {
|
|||||||
"oidc_identifier",
|
"oidc_identifier",
|
||||||
"oidcIdentifier",
|
"oidcIdentifier",
|
||||||
]),
|
]),
|
||||||
ssh_data: new Set([
|
ssh_data: new Set(["password", "key", "key_password", "keyPassword"]),
|
||||||
"password",
|
|
||||||
"key",
|
|
||||||
"key_password",
|
|
||||||
"keyPassword",
|
|
||||||
]),
|
|
||||||
ssh_credentials: new Set([
|
ssh_credentials: new Set([
|
||||||
"password",
|
"password",
|
||||||
"private_key",
|
"private_key",
|
||||||
@@ -60,7 +55,11 @@ class FieldCrypto {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const iv = crypto.randomBytes(this.IV_LENGTH);
|
const iv = crypto.randomBytes(this.IV_LENGTH);
|
||||||
const cipher = crypto.createCipheriv(this.ALGORITHM, fieldKey, iv) as any;
|
const cipher = crypto.createCipheriv(
|
||||||
|
this.ALGORITHM,
|
||||||
|
fieldKey,
|
||||||
|
iv,
|
||||||
|
) as crypto.CipherGCM;
|
||||||
|
|
||||||
let encrypted = cipher.update(plaintext, "utf8", "hex");
|
let encrypted = cipher.update(plaintext, "utf8", "hex");
|
||||||
encrypted += cipher.final("hex");
|
encrypted += cipher.final("hex");
|
||||||
@@ -102,7 +101,7 @@ class FieldCrypto {
|
|||||||
this.ALGORITHM,
|
this.ALGORITHM,
|
||||||
fieldKey,
|
fieldKey,
|
||||||
Buffer.from(encrypted.iv, "hex"),
|
Buffer.from(encrypted.iv, "hex"),
|
||||||
) as any;
|
) as crypto.DecipherGCM;
|
||||||
decipher.setAuthTag(Buffer.from(encrypted.tag, "hex"));
|
decipher.setAuthTag(Buffer.from(encrypted.tag, "hex"));
|
||||||
|
|
||||||
let decrypted = decipher.update(encrypted.data, "hex", "utf8");
|
let decrypted = decipher.update(encrypted.data, "hex", "utf8");
|
||||||
|
|||||||
Reference in New Issue
Block a user