diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afcdfb92..8b454f90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,9 @@ on: push: branches: - master - tags: - - "v*" jobs: - checkout: + release: + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest env: CI: false diff --git a/adapter-fs-bridge/package-lock.json b/adapter-fs-bridge/package-lock.json index cd8a67ed..1a8084ef 100644 --- a/adapter-fs-bridge/package-lock.json +++ b/adapter-fs-bridge/package-lock.json @@ -23,7 +23,6 @@ "memoizee": "^0.4.15", "node-emoji": "^2.1.0", "protocol": "file:../protocol", - "push-code-generator": "file:../push-code-generator", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3", "typed-emitter": "^2.1.0", @@ -48,6 +47,7 @@ }, "../push-code-generator": { "version": "1.0.5", + "extraneous": true, "license": "ISC", "dependencies": { "lodash": "^4.17.21" @@ -2044,10 +2044,6 @@ "node": ">= 0.10" } }, - "node_modules/push-code-generator": { - "resolved": "../push-code-generator", - "link": true - }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", diff --git a/adapter-fs-bridge/package.json b/adapter-fs-bridge/package.json index ae62b1bb..5d6ad69f 100644 --- a/adapter-fs-bridge/package.json +++ b/adapter-fs-bridge/package.json @@ -26,7 +26,6 @@ "memoizee": "^0.4.15", "node-emoji": "^2.1.0", "protocol": "file:../protocol", - "push-code-generator": "file:../push-code-generator", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3", "typed-emitter": "^2.1.0", diff --git a/client/package-lock.json b/client/package-lock.json index cd40145b..8705ee9f 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -40,7 +40,6 @@ "pluralize": "^8.0.0", "promise-tools": "^2.1.0", "protocol": "file:../protocol", - "push-code-generator": "file:../push-code-generator", "react": "^18.2.0", "react-async-hook": "^4.0.0", "react-beautiful-dnd": "^13.1.1", @@ -139,6 +138,7 @@ }, "../push-code-generator": { "version": "1.0.5", + "extraneous": true, "license": "ISC", "dependencies": { "lodash": "^4.17.21" @@ -8170,10 +8170,6 @@ "node": ">=6" } }, - "node_modules/push-code-generator": { - "resolved": "../push-code-generator", - "link": true - }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", diff --git a/client/package.json b/client/package.json index 67e0b781..c184c460 100644 --- a/client/package.json +++ b/client/package.json @@ -35,7 +35,6 @@ "pluralize": "^8.0.0", "promise-tools": "^2.1.0", "protocol": "file:../protocol", - "push-code-generator": "file:../push-code-generator", "react": "^18.2.0", "react-async-hook": "^4.0.0", "react-beautiful-dnd": "^13.1.1", diff --git a/client/tsconfig.json b/client/tsconfig.json index 9c569968..ec35d4fe 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -19,9 +19,5 @@ "baseUrl": "src", "downlevelIteration": true }, - "include": [ - "src", - "src/components/app-bar/Title.test.tsx", - "../push-code-generator/index.ts" - ] + "include": ["src", "src/components/app-bar/Title.test.tsx"] } diff --git a/push-code-generator/index.ts b/push-code-generator/index.ts deleted file mode 100644 index c31bf2d1..00000000 --- a/push-code-generator/index.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { sumBy } from "lodash"; - -export function encode( - port: number, - id: number -): { error?: string; code?: string } { - if (port < 0 || port > 65535 || id < 0 || id > 255) { - return { error: "Invalid port or ID number." }; - } - - // Combine port and ID - const combined = (port << 8) | id; - - // Convert to a base-36 string - const base36 = combined.toString(36).toUpperCase(); - - // Calculate checksum - const checksum = calculateChecksum(base36); - - // Return encoded string with checksum - return { code: base36.padStart(5, "0") + checksum }; -} - -export function decode(code: string): { - error?: string; - port?: number; - id?: number; -} { - if (!/^[0-9A-Z]{6}$/.test(code)) { - return { error: "Invalid code format." }; - } - - // Extract checksum - const checksumChar = code.slice(-1); - const base36 = code.slice(0, 5); - - // Convert back from base-36 - const combined = parseInt(base36, 36); - - // Validate checksum - if (checksumChar !== calculateChecksum(base36)) { - return { error: "Invalid checksum." }; - } - - // Extract port and ID - const port = combined >> 8; - const id = combined & 0xff; - - return { port, id }; -} - -function calculateChecksum(input: string) { - const sum = sumBy(input, (c) => - c.match(/[0-9]/) ? parseInt(c, 10) : c.charCodeAt(0) - 55 - ); - - const checksumValue = sum % 36; - return checksumValue < 10 - ? checksumValue.toString() - : String.fromCharCode(checksumValue + 55); -} diff --git a/push-code-generator/package-lock.json b/push-code-generator/package-lock.json deleted file mode 100644 index 6f12783e..00000000 --- a/push-code-generator/package-lock.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "push-code-generator", - "version": "1.0.5", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "push-code-generator", - "version": "1.0.5", - "license": "ISC", - "dependencies": { - "lodash": "^4.17.21" - }, - "devDependencies": { - "@types/lodash": "^4.14.202" - } - }, - "node_modules/@types/lodash": { - "version": "4.14.202", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz", - "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==", - "dev": true - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - } - } -} diff --git a/push-code-generator/package.json b/push-code-generator/package.json deleted file mode 100644 index 461f5663..00000000 --- a/push-code-generator/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "push-code-generator", - "version": "1.0.5", - "description": "", - "main": "index.ts", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "lodash": "^4.17.21" - }, - "devDependencies": { - "@types/lodash": "^4.14.202" - } -}