Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/extension/e2e/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test as base, chromium, type BrowserContext } from "@playwright/test"
import path from "path"
import { fileURLToPath } from "url"

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const pathToExtension = path.join(__dirname, "../dist")

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/e2e/generated-command-urls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Auto-generated by scripts/generate-e2e-urls.mjs from defaultSettings.ts.
* Auto-generated by scripts/generate-e2e-urls.ts from defaultSettings.ts.
* Do not edit manually. Run "yarn build:e2e" to regenerate.
*/

Expand Down
5 changes: 3 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
"private": true,
"author": "ujiro99",
"license": "MIT",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"build:e2e": "node scripts/generate-e2e-urls.mjs && tsc -b && vite build --mode e2e",
"build:e2e": "vite-node --config scripts/vite.config.ts scripts/generate-e2e-urls.ts && tsc -b && vite build --mode e2e",
"lint": "eslint .",
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"test:coverage": "vitest --coverage",
"pretty-quick": "pretty-quick",
"precommit": "pretty-quick --staged",
"check-ids": "tsx scripts/check-command-ids.mjs",
"check-ids": "vite-node --config scripts/vite.config.ts scripts/check-command-ids.ts",
"zip": "npm-build-zip --source=dist --destination=build",
"test:e2e": "playwright test"
},
Expand Down
237 changes: 0 additions & 237 deletions packages/extension/scripts/check-command-ids.mjs

This file was deleted.

73 changes: 73 additions & 0 deletions packages/extension/scripts/check-command-ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env vite-node
import { cmd2uuid } from "@shared/utils/uuid"
import {
DefaultCommands,
LOCALE_COMMANDS,
} from "@/services/option/defaultSettings"
import { OPEN_MODE } from "@/const"

/**
* Generates UUIDs for each default command using cmd2uuid (uuid.ts),
* then compares with the currently set id.
*
* Usage:
* yarn check-ids
*/

// Modes where cmd2uuid can generate a deterministic ID
const CHECKABLE_MODES = new Set<string>([
OPEN_MODE.POPUP,
OPEN_MODE.TAB,
OPEN_MODE.WINDOW,
OPEN_MODE.BACKGROUND_TAB,
OPEN_MODE.SIDE_PANEL,
OPEN_MODE.AI_PROMPT,
OPEN_MODE.PAGE_ACTION,
])

// Collect all unique commands from DefaultCommands and all locales
const seen = new Set<string>()
const commands: Array<{ title: string; parsed: Record<string, string> }> = []

for (const cmd of DefaultCommands) {
const c = cmd as Record<string, string>
if (seen.has(c.id)) continue
seen.add(c.id)
commands.push({ title: c.title, parsed: c })
}

for (const cmds of Object.values(LOCALE_COMMANDS)) {
for (const cmd of cmds) {
const c = cmd as Record<string, string>
if (seen.has(c.id)) continue
seen.add(c.id)
commands.push({ title: c.title, parsed: c })
}
}

// Generate UUID and compare
const PAD_NAME = 36
const PAD_ID = 38

console.log(
`${"TITLE".padEnd(PAD_NAME)} ${"GENERATED_ID".padEnd(PAD_ID)} CHECK`,
)
console.log("-".repeat(PAD_NAME + PAD_ID + 10))

for (const { title, parsed } of commands) {
const currentId = parsed.id
const openMode = parsed.openMode

if (CHECKABLE_MODES.has(openMode)) {
const generatedId = cmd2uuid(parsed)
const check = currentId === generatedId ? "OK" : "MISMATCH"
console.log(
`${title.padEnd(PAD_NAME)} ${generatedId.padEnd(PAD_ID)} ${check}${check === "MISMATCH" ? ` (current: ${currentId})` : ""}`,
)
} else {
// Drag commands or other special types
console.log(
`${title.padEnd(PAD_NAME)} ${"(special - N/A)".padEnd(PAD_ID)} SKIP`,
)
}
}
Loading
Loading