Skip to content

Commit

Permalink
Merge pull request #64 from lumpinif/main
Browse files Browse the repository at this point in the history
build(chrome): Add extension version sync check between package.json and manifest.json in case forgetting to update version accidentally in pre-commit
  • Loading branch information
lumpinif authored Jan 9, 2025
2 parents d734671 + fa60eb6 commit dff4e83
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ if ! bun run lint:staged; then
exit 1
fi

if ! bun run check-version-sync; then
echo "Version sync check failed"
exit 1
fi

# TODO: config this for other extensions too
152 changes: 78 additions & 74 deletions extensions/chrome/package.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,80 @@
{
"name": "thinking-claude",
"version": "3.2.2",
"description": "Chrome extension for letting Claude think like a real human",
"type": "module",
"scripts": {
"watch": "webpack --config webpack/webpack.dev.js --watch",
"build": "webpack --config webpack/webpack.prod.js",
"start": "webpack serve --config webpack/webpack.dev.js",
"test": "bun test",
"test:watch": "bun test --watch",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint:staged": "lint-staged",
"lint:types": "tsc --noEmit",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,css,md}\"",
"fix": "bun run format && bun run lint:fix",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-scroll-area": "^1.2.1",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.460.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^1.14.0"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",
"@types/chrome": "^0.0.246",
"@types/node": "^20.8.2",
"@types/react": "^18.2.24",
"@types/react-dom": "^18.2.8",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vitest/runner": "^2.1.5",
"autoprefixer": "^10.4.16",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"husky": "^9.1.7",
"identity-obj-proxy": "^3.0.0",
"lint-staged": "^14.0.1",
"markdownlint-cli2": "^0.15.0",
"mini-css-extract-plugin": "^2.9.2",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",
"postcss-nesting": "^12.0.1",
"style-loader": "^3.3.3",
"tailwindcss": "^3.3.3",
"tailwindcss-animate": "^1.0.7",
"ts-loader": "^9.4.4",
"typescript": "^5.2.2",
"vitest": "^2.1.5",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0"
},
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.md": "markdownlint-cli2 --config .markdownlint-cli2.jsonc --fix"
}
"name": "thinking-claude",
"version": "3.2.3",
"description": "Chrome extension for letting Claude think like a real human",
"type": "module",
"scripts": {
"watch": "webpack --config webpack/webpack.dev.js --watch",
"build": "webpack --config webpack/webpack.prod.js",
"start": "webpack serve --config webpack/webpack.dev.js",
"test": "bun test",
"test:watch": "bun test --watch",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint:staged": "lint-staged",
"lint:types": "tsc --noEmit",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,css,md}\"",
"fix": "bun run format && bun run lint:fix",
"type-check": "tsc --noEmit",
"check-version-sync": "bun ./scripts/check-version-sync.ts"
},
"dependencies": {
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-scroll-area": "^1.2.1",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.460.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^1.14.0"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",
"@types/chrome": "^0.0.246",
"@types/node": "^20.8.2",
"@types/react": "^18.2.24",
"@types/react-dom": "^18.2.8",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vitest/runner": "^2.1.5",
"autoprefixer": "^10.4.16",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"husky": "^9.1.7",
"identity-obj-proxy": "^3.0.0",
"lint-staged": "^14.0.1",
"markdownlint-cli2": "^0.15.0",
"mini-css-extract-plugin": "^2.9.2",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",
"postcss-nesting": "^12.0.1",
"style-loader": "^3.3.3",
"tailwindcss": "^3.3.3",
"tailwindcss-animate": "^1.0.7",
"ts-loader": "^9.4.4",
"typescript": "^5.2.2",
"vitest": "^2.1.5",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0"
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.md": "markdownlint-cli2 --config .markdownlint-cli2.jsonc --fix"
}
}
2 changes: 1 addition & 1 deletion extensions/chrome/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Thinking Claude",
"version": "3.2.1",
"version": "3.2.3",
"description": "Chrome extension for letting Claude think like a real human",
"background": {
"service_worker": "background.js"
Expand Down
56 changes: 56 additions & 0 deletions extensions/chrome/scripts/check-version-sync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node
import fs from "fs"
import path from "path"
import { fileURLToPath } from "url"

interface PackageJson {
version: string
[key: string]: unknown
}

interface ManifestJson {
manifest_version: number
name: string
version: string
description: string
[key: string]: unknown
}

const __filename: string = fileURLToPath(import.meta.url)
const __dirname: string = path.dirname(__filename)

const packageJsonPath: string = path.resolve(__dirname, "..", "package.json")
const manifestJsonPath: string = path.resolve(
__dirname,
"..",
"public",
"manifest.json"
)

try {
const packageJson: PackageJson = JSON.parse(
fs.readFileSync(packageJsonPath, "utf8")
)
const manifestJson: ManifestJson = JSON.parse(
fs.readFileSync(manifestJsonPath, "utf8")
)

if (packageJson.version !== manifestJson.version) {
console.error("\x1b[31mError: Version mismatch!\x1b[0m")
console.error(`package.json version: ${packageJson.version}`)
console.error(`manifest.json version: ${manifestJson.version}`)
console.error(
"\nPlease update the version in public/manifest.json to match package.json"
)
process.exit(1)
}

console.log("\x1b[32mVersions are in sync ✓\x1b[0m")
process.exit(0)
} catch (error: unknown) {
console.error(
"\x1b[31mError checking version sync:\x1b[0m",
error instanceof Error ? error.message : error
)
process.exit(1)
}

0 comments on commit dff4e83

Please sign in to comment.