donebear 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -3
- package/dist/cli.mjs +3098 -150
- package/dist/cli.mjs.map +1 -1
- package/dist/context-store-DH561Z1u.mjs.map +1 -1
- package/package.json +3 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-store-DH561Z1u.mjs","names":[],"sources":["../src/constants.ts","../src/errors.ts","../src/context-store.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport const CLI_NAME = \"donebear\";\n\nexport const DONEBEAR_TOKEN_ENV = \"DONEBEAR_TOKEN\";\nexport const DONEBEAR_DEBUG_ENV = \"DONEBEAR_DEBUG\";\nconst DONEBEAR_CONFIG_DIR_ENV = \"DONEBEAR_CONFIG_DIR\";\nexport const DONEBEAR_SUPABASE_URL_ENV = \"DONEBEAR_SUPABASE_URL\";\nexport const DONEBEAR_SUPABASE_KEY_ENV = \"DONEBEAR_SUPABASE_PUBLISHABLE_KEY\";\nexport const DONEBEAR_API_URL_ENV = \"DONEBEAR_API_URL\";\n\nexport const DEFAULT_API_URL = \"https://api.donebear.com\";\n\nexport const DEFAULT_SUPABASE_URL = \"https://kdarvputxmlxqemisnbh.supabase.co\";\nexport const DEFAULT_SUPABASE_PUBLISHABLE_KEY =\n \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtkYXJ2cHV0eG1seHFlbWlzbmJoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzIzNTcyNjcsImV4cCI6MjA4NzkzMzI2N30.A8sDPWNe_1EcCy0-GsUw4h1icxSGz_VDc9E9tPTYEU8\";\n\nexport const CLI_OAUTH_CLIENT_ID = \"9cc84e5c-6a0e-4a6d-93a2-334d8d307122\";\nexport const DONEBEAR_OAUTH_CLIENT_ID_ENV = \"DONEBEAR_OAUTH_CLIENT_ID\";\n\nexport const DEFAULT_OAUTH_CALLBACK_PORT = 8787;\nexport const DEFAULT_OAUTH_CALLBACK_PATH = \"/auth/callback\";\nexport const DEFAULT_OAUTH_TIMEOUT_SECONDS = 180;\n\nconst getDefaultConfigBaseDir = (): string => {\n if (process.platform === \"win32\") {\n return process.env.APPDATA ?? join(homedir(), \"AppData\", \"Roaming\");\n }\n\n return process.env.XDG_CONFIG_HOME ?? join(homedir(), \".config\");\n};\n\nconst configBaseDir = getDefaultConfigBaseDir();\n\nexport const CONFIG_DIR =\n process.env[DONEBEAR_CONFIG_DIR_ENV] ?? join(configBaseDir, CLI_NAME);\n\nexport const AUTH_FILE_PATH = join(CONFIG_DIR, \"auth.json\");\nexport const CONTEXT_FILE_PATH = join(CONFIG_DIR, \"context.json\");\n","export const EXIT_CODES = {\n AUTH_REQUIRED: 4,\n CANCELLED: 2,\n ERROR: 1,\n NETWORK: 5,\n SUCCESS: 0,\n VALIDATION: 3,\n} as const;\n\
|
|
1
|
+
{"version":3,"file":"context-store-DH561Z1u.mjs","names":[],"sources":["../src/constants.ts","../src/errors.ts","../src/context-store.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport const CLI_NAME = \"donebear\";\n\nexport const DONEBEAR_TOKEN_ENV = \"DONEBEAR_TOKEN\";\nexport const DONEBEAR_DEBUG_ENV = \"DONEBEAR_DEBUG\";\nconst DONEBEAR_CONFIG_DIR_ENV = \"DONEBEAR_CONFIG_DIR\";\nexport const DONEBEAR_SUPABASE_URL_ENV = \"DONEBEAR_SUPABASE_URL\";\nexport const DONEBEAR_SUPABASE_KEY_ENV = \"DONEBEAR_SUPABASE_PUBLISHABLE_KEY\";\nexport const DONEBEAR_API_URL_ENV = \"DONEBEAR_API_URL\";\n\nexport const DEFAULT_API_URL = \"https://api.donebear.com\";\n\nexport const DEFAULT_SUPABASE_URL = \"https://kdarvputxmlxqemisnbh.supabase.co\";\nexport const DEFAULT_SUPABASE_PUBLISHABLE_KEY =\n \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtkYXJ2cHV0eG1seHFlbWlzbmJoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzIzNTcyNjcsImV4cCI6MjA4NzkzMzI2N30.A8sDPWNe_1EcCy0-GsUw4h1icxSGz_VDc9E9tPTYEU8\";\n\nexport const CLI_OAUTH_CLIENT_ID = \"9cc84e5c-6a0e-4a6d-93a2-334d8d307122\";\nexport const DONEBEAR_OAUTH_CLIENT_ID_ENV = \"DONEBEAR_OAUTH_CLIENT_ID\";\n\nexport const DEFAULT_OAUTH_CALLBACK_PORT = 8787;\nexport const DEFAULT_OAUTH_CALLBACK_PATH = \"/auth/callback\";\nexport const DEFAULT_OAUTH_TIMEOUT_SECONDS = 180;\n\nconst getDefaultConfigBaseDir = (): string => {\n if (process.platform === \"win32\") {\n return process.env.APPDATA ?? join(homedir(), \"AppData\", \"Roaming\");\n }\n\n return process.env.XDG_CONFIG_HOME ?? join(homedir(), \".config\");\n};\n\nconst configBaseDir = getDefaultConfigBaseDir();\n\nexport const CONFIG_DIR =\n process.env[DONEBEAR_CONFIG_DIR_ENV] ?? join(configBaseDir, CLI_NAME);\n\nexport const AUTH_FILE_PATH = join(CONFIG_DIR, \"auth.json\");\nexport const CONTEXT_FILE_PATH = join(CONFIG_DIR, \"context.json\");\n","export const EXIT_CODES = {\n AUTH_REQUIRED: 4,\n CANCELLED: 2,\n ERROR: 1,\n NETWORK: 5,\n SUCCESS: 0,\n VALIDATION: 3,\n} as const;\n\ntype ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];\n\ntype ErrorCode =\n | \"unknown_error\"\n | \"cancelled\"\n | \"validation_error\"\n | \"auth_error\"\n | \"network_error\";\n\nconst EXIT_CODE_TO_ERROR_CODE: Record<ExitCode, ErrorCode> = {\n [EXIT_CODES.SUCCESS]: \"unknown_error\",\n [EXIT_CODES.ERROR]: \"unknown_error\",\n [EXIT_CODES.CANCELLED]: \"cancelled\",\n [EXIT_CODES.VALIDATION]: \"validation_error\",\n [EXIT_CODES.AUTH_REQUIRED]: \"auth_error\",\n [EXIT_CODES.NETWORK]: \"network_error\",\n};\n\nconst exitCodeToErrorCode = (exitCode: ExitCode): ErrorCode =>\n EXIT_CODE_TO_ERROR_CODE[exitCode] ?? \"unknown_error\";\n\nexport class CliError extends Error {\n readonly exitCode: ExitCode;\n readonly code: ErrorCode;\n readonly hint: string | null;\n\n constructor(\n message: string,\n exitCode: ExitCode = EXIT_CODES.ERROR,\n hint?: string\n ) {\n super(message);\n this.name = \"CliError\";\n this.exitCode = exitCode;\n this.code = exitCodeToErrorCode(exitCode);\n this.hint = hint ?? null;\n }\n}\n\nexport const toCliError = (error: unknown): CliError => {\n if (error instanceof CliError) {\n return error;\n }\n\n if (error instanceof Error) {\n // Network errors (fetch failures)\n if (error instanceof TypeError && error.message.includes(\"fetch\")) {\n return new CliError(\n \"Cannot connect to Done Bear API.\",\n EXIT_CODES.NETWORK,\n \"Check your internet connection and API URL configuration.\"\n );\n }\n\n // Timeout errors\n if (error.name === \"TimeoutError\" || error.name === \"AbortError\") {\n return new CliError(\n \"Request timed out.\",\n EXIT_CODES.NETWORK,\n \"The API may be unavailable. Try again later.\"\n );\n }\n\n return new CliError(error.message, EXIT_CODES.ERROR);\n }\n\n return new CliError(\"Unknown error\", EXIT_CODES.ERROR);\n};\n","import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\n\nimport { CONFIG_DIR, CONTEXT_FILE_PATH } from \"./constants\";\nimport { CliError, EXIT_CODES } from \"./errors\";\nimport type { CliContextFileData, LocalCliContext } from \"./types\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst parseLocalContext = (value: unknown): LocalCliContext | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n if (value.workspaceId !== null && typeof value.workspaceId !== \"string\") {\n return null;\n }\n\n if (typeof value.clientId !== \"string\" || value.clientId.length === 0) {\n return null;\n }\n\n return {\n clientId: value.clientId,\n workspaceId: value.workspaceId,\n };\n};\n\nconst parseContextFile = (payload: string): CliContextFileData => {\n const parsed = JSON.parse(payload) as unknown;\n\n if (!isRecord(parsed) || parsed.version !== 1) {\n throw new CliError(\n `Invalid CLI context format in ${CONTEXT_FILE_PATH}`,\n EXIT_CODES.ERROR\n );\n }\n\n const context = parseLocalContext(parsed.context);\n\n if (!context) {\n throw new CliError(\n `Invalid CLI context in ${CONTEXT_FILE_PATH}`,\n EXIT_CODES.ERROR\n );\n }\n\n return {\n context,\n version: 1,\n };\n};\n\nconst writeContext = async (context: LocalCliContext): Promise<void> => {\n const payload: CliContextFileData = {\n context,\n version: 1,\n };\n\n await mkdir(CONFIG_DIR, {\n mode: 0o700,\n recursive: true,\n });\n\n await writeFile(CONTEXT_FILE_PATH, `${JSON.stringify(payload, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n};\n\nconst readLocalContext = async (): Promise<LocalCliContext | null> => {\n try {\n const raw = await readFile(CONTEXT_FILE_PATH, \"utf8\");\n return parseContextFile(raw).context;\n } catch (error) {\n if (isRecord(error) && error.code === \"ENOENT\") {\n return null;\n }\n\n if (error instanceof CliError) {\n throw error;\n }\n\n throw new CliError(\n `Failed to read context from ${CONTEXT_FILE_PATH}`,\n EXIT_CODES.ERROR\n );\n }\n};\n\nexport const ensureLocalContext = async (): Promise<LocalCliContext> => {\n const existing = await readLocalContext();\n\n if (existing) {\n return existing;\n }\n\n const created: LocalCliContext = {\n clientId: randomUUID(),\n workspaceId: null,\n };\n\n await writeContext(created);\n return created;\n};\n\nexport const setCurrentWorkspace = async (\n workspaceId: string | null\n): Promise<LocalCliContext> => {\n const context = await ensureLocalContext();\n\n const nextContext: LocalCliContext = {\n ...context,\n workspaceId,\n };\n\n await writeContext(nextContext);\n return nextContext;\n};\n"],"mappings":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S,MAAM,IAAI,MAAM,SAAS,SACpC,QAAO;AAGT,MAAI,iBAAiB,SACnB,OAAM;AAGR,QAAM,IAAI,SACR,+BAA+B,qBAC/B,WAAW,MACZ;;;AAIL,MAAa,qBAAqB,YAAsC;CACtE,MAAM,WAAW,MAAM,kBAAkB;AAEzC,KAAI,SACF,QAAO;CAGT,MAAM,UAA2B;EAC/B,UAAU,YAAY;EACtB,aAAa;EACd;AAED,OAAM,aAAa,QAAQ;AAC3B,QAAO;;AAGT,MAAa,sBAAsB,OACjC,gBAC6B;CAG7B,MAAM,cAA+B;EACnC,GAHc,MAAM,oBAAoB;EAIxC;EACD;AAED,OAAM,aAAa,YAAY;AAC/B,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "donebear",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Done Bear CLI with OAuth authentication",
|
|
5
5
|
"homepage": "https://github.com/mblode/donebear#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -35,10 +35,6 @@
|
|
|
35
35
|
"build": "tsdown",
|
|
36
36
|
"dev": "tsdown --watch",
|
|
37
37
|
"start": "node dist/cli.mjs",
|
|
38
|
-
"lint": "oxlint .",
|
|
39
|
-
"lint:fix": "oxlint --fix .",
|
|
40
|
-
"format": "oxfmt --write .",
|
|
41
|
-
"format:check": "oxfmt --check .",
|
|
42
38
|
"check-types": "tsc --noEmit",
|
|
43
39
|
"test": "vitest run"
|
|
44
40
|
},
|
|
@@ -48,7 +44,7 @@
|
|
|
48
44
|
"dotenv": "^17.3.1",
|
|
49
45
|
"jmespath": "^0.16.0",
|
|
50
46
|
"rrule": "^2.8.1",
|
|
51
|
-
"yaml": "^2.8.
|
|
47
|
+
"yaml": "^2.8.3"
|
|
52
48
|
},
|
|
53
49
|
"devDependencies": {
|
|
54
50
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -56,7 +52,7 @@
|
|
|
56
52
|
"@types/node": "^25.5.0",
|
|
57
53
|
"tsdown": "^0.21.4",
|
|
58
54
|
"typescript": "^5.9.3",
|
|
59
|
-
"vitest": "^4.1.
|
|
55
|
+
"vitest": "^4.1.1"
|
|
60
56
|
},
|
|
61
57
|
"engines": {
|
|
62
58
|
"node": ">=18"
|