Commit Graph

55 Commits

Author SHA1 Message Date
d22aa276e8 docs: add download page readability implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:39:02 +08:00
ddf2729426 docs: add download page readability design
- Fix SearchForm text color for better visibility
- Add environment tags to commit id column in ApkList

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:38:02 +08:00
1eba2f5f39 chore: update env example and gitignore, add implementation plan
- Update .env.example with documentation and default values
- Add .resources to gitignore (dummy test files)
- Add APK parsing fix implementation plan document

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:06:44 +08:00
7268b91ed3 feat: add config API and update ApkList to use configured tabs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 12:54:31 +08:00
0b817984bb feat: pass version parameter to APK parser
Update parseApkFilename call to include the version parameter,
allowing the parser to use version-based configuration when
parsing APK filenames.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 23:52:53 +08:00
df4daea1c7 feat: rewrite APK parser to use version as delimiter
- Changed parseApkFilename to accept version parameter
- New parsing logic splits filename by version string to extract prefix
- detectEnvironment now takes prefix and configured tabs as arguments
- Environments not in APK_TABS are mapped to 'other' instead of hardcoded mapping
- Added getApkTabs helper function to expose configured tabs
- Updated all tests to use new API with version parameter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 23:33:45 +08:00
10fa6782e6 feat: add APK_TABS environment variable for configurable tabs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 23:27:42 +08:00
edc4cb770f fix: separate client and server utilities to fix build error
Split lib/utils.ts into:
- lib/utils.ts: Client-safe utilities only (no Node.js imports)
- lib/project-utils.ts: Server-only utilities with Node.js imports

This fixes the Next.js build error where client components were importing
modules that contained Node.js dependencies (fs, path).

All tests pass and build succeeds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
08f9015101 feat: update download page title to use display name
- Add Project interface with name and displayName
- Fetch projects via SWR
- Add getProjectDisplayName helper function
- Use display name in the download page title

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
585827c632 fix: remove unused formatVersion import from ApkList
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
173f182b21 feat: update ApkList to use tabbed view
Replaced card-based layout with tabbed interface for APK environments.
Now displays APKs grouped by dev/product/sandbox/other tabs with counts.

- Replaced ApkCard with ApkTable component
- Added tab navigation with active state styling
- Group APKs by environment using reduce
- Show count badges for each environment tab

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
d42b72b650 feat: update SearchForm to use project display names
Add Project interface with name and displayName fields to support project aliases. Update SWR hook to type projects as Project[]. Display project.displayName in dropdown while using project.name as the option value for API compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
bf63f52b66 feat: add ApkTable component 2026-03-04 22:17:31 +08:00
e217d1c6c9 fix: resolve duplicate commit field and add commitId filter test
- Replace spread operator with explicit field selection to avoid
  duplicate commit field from getApks() and parseApkFilename()
- Add test case for commitId parameter filtering to ensure
  the filter parameter works correctly with new metadata extraction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
792ad8619c feat: update APKs API to include environment metadata
- Add parseApkFilename() integration to extract environment and commit info
- Return environment field (dev/sandbox/product/other) in API response
- Return commit field (short commit ID) in API response
- Add comprehensive test coverage for the new metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
aeb29d0428 feat: update projects API to include display names
- Modified projects API route to return objects with name and displayName fields
- Added comprehensive tests for the updated API response structure
- Tests verify display name mapping and error handling
- All existing tests continue to pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
149e3a5924 feat: add getProjectDisplayName utility 2026-03-04 22:17:31 +08:00
87271c4602 fix: correct apk-parser test expectations and regex pattern
- Use letter-only regex pattern /ft_([a-z]+)_/i to correctly detect environment suffixes
- This ensures version numbers (starting with digits) are treated as no environment suffix
- Update test expectations to match spec behavior:
  - ft_0_42_ff9ff3441.apk now correctly returns 'product' (no match)
  - invalid_filename.apk returns 'product' (no match)
- All 10 tests pass with corrected implementation
2026-03-04 22:17:31 +08:00
95101d5914 fix: add missing lan test and simplify apk-parser implementation
- Add missing test case for lan environment detection
- Simplify detectEnvironment() to match spec exactly
- Remove extra logic (version number detection, ft_ prefix check)
- Update test expectations to match simplified implementation behavior
- All tests now pass with spec-compliant implementation
2026-03-04 22:17:31 +08:00
5e280d4cbe feat: add APK filename parser utilities
- Add detectEnvironment() to parse environment from APK filenames
- Add parseApkFilename() to extract environment and commit ID metadata
- Support dev, sandbox, product, and other environment types
- Map environment patterns: timeshift, lan, dev -> dev; sandbox -> sandbox
- Detect product APKs when no environment suffix present
- Handle invalid formats gracefully
2026-03-04 22:17:31 +08:00
889c6ee2f6 feat: add project aliases configuration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
b311589d06 docs: add implementation plan for enhanced download UI
Add comprehensive implementation plan with TDD approach,
bite-sized tasks, and detailed code examples for each step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
6182c38366 docs: add design document for enhanced download UI
Add comprehensive design document for project aliases and
APK environment classification feature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00
3fde67c86f [M] ignore .env 2026-03-04 13:06:26 +08:00
46d9f3a299 fix: set cookie secure flag based on request protocol
Fix login issue when accessing via IP address over HTTP. Previously,
the cookie secure flag was set based on NODE_ENV which caused
cookies to not be sent when accessing via HTTP in production mode.
Now it uses the actual request protocol (checking x-forwarded-proto
header or request URL).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 13:03:44 +08:00
8227f36cbe refactor: organize tests and extract formatting utilities
- Move test files to lib/__tests__/ directory
- Extract formatting utilities (formatVersion, formatFileSize, formatDateTime)
  from fs-utils.ts to new utils.ts module
- Add Jest test configuration and test scripts
- Update component imports to use new utils module
- Add CLAUDE.md documentation for project structure

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:33:30 +08:00
17a23611b6 docs: add README 2026-03-04 02:16:35 +08:00
93d43c8451 feat: redirect home page to download page 2026-03-04 02:15:38 +08:00
240fd8b528 feat: add download page with SearchForm and ApkList 2026-03-04 02:14:16 +08:00
993ce520f0 fix: add 'use client' directive and fix prop mismatch
- Add 'use client' directive at top of ApkList.tsx to support useSWR hook
- Remove highlightCommit prop from ApkCard component call as it's not accepted by ApkCard interface

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:12:39 +08:00
608d67c7fd feat: add ApkList component 2026-03-04 02:11:04 +08:00
36b60687f0 fix: remove XSS vulnerability and add security attributes
- Removed dangerouslySetInnerHTML with unsanitized user input
- Removed highlightCommit prop and related highlighting logic
- Added download and rel="noopener noreferrer" attributes to download link
- Simplified component to safely display filename without HTML rendering

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:10:06 +08:00
99694cbc4c feat: add ApkCard component 2026-03-04 02:08:50 +08:00
df5c0b4237 fix: add error handling and use existing utility
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:08:09 +08:00
fdeb42f212 feat: add SearchForm component 2026-03-04 02:06:53 +08:00
5365352331 fix: add cookie security attributes and error handling
- Add secure and sameSite attributes to cookie configuration
- Add try-catch block to handle malformed JSON and other errors
- Add validation for missing username or password fields

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:05:55 +08:00
bdb4d0cf32 feat: add login page and API 2026-03-04 02:04:50 +08:00
e2b4105fb6 fix: remove font overrides to use Tailwind configuration 2026-03-04 02:04:02 +08:00
0329bd2ff6 fix: improve font configuration for Chinese support 2026-03-04 02:03:22 +08:00
f3b0d79ef9 feat: update root layout with metadata
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:02:31 +08:00
cf7d3d5618 fix: use streaming and add path validation
- Replace fs.readFileSync() with fs.createReadStream() to prevent memory exhaustion
- Export validatePath() from fs-utils.ts
- Use validatePath() to validate full path including project and version parameters
- Fix incomplete path traversal protection
- Add filename encoding in Content-Disposition header

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:01:38 +08:00
7d5ee36f56 feat: add /api/download endpoint for APK file downloads
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:00:36 +08:00
91c94bde88 fix: add URL encoding and remove unused import
- Add encodeURIComponent() for project, version, and filename parameters in downloadUrl to prevent XSS and URL breakage
- Remove unused formatDateTime import

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 01:59:53 +08:00
0d1ba31175 feat: add /api/apks endpoint 2026-03-04 01:58:52 +08:00
c032c7fd5d feat: add /api/versions endpoint 2026-03-04 01:57:46 +08:00
5be115d323 feat: add /api/projects endpoint 2026-03-04 01:56:47 +08:00
7609e99076 fix: use constant for cookie value and remove unused import
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 01:56:14 +08:00
db479c9da1 feat: implement simple cookie-based authentication middleware 2026-03-04 01:54:56 +08:00
2a883c23f9 fix: address race conditions and add path validation
- Fixed race condition in getProjects() by using Promise.all with proper async/await
- Fixed race condition in getVersions() by using Promise.all with proper async/await
- Fixed race condition in getApks() by ensuring Promise.all wraps the async map
- Added validatePath() helper function to prevent path traversal attacks
- Applied path validation to all file system operations

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 01:54:07 +08:00
5e00e36e57 feat: add file system utility functions 2026-03-04 01:52:44 +08:00