Repo organization: doc fixes, scripting, scaffolding for testing, linting, etc. - #45
Conversation
There was a problem hiding this comment.
Pull request overview
This PR sets up repository organization, tooling, and documentation without changing application logic. It introduces development workflow scripts, testing infrastructure, code formatting configuration, CI/CD, and comprehensive project documentation.
Changes:
- Added setup script (
setup.mjs) to automate environment checks, dependency installation, and dev server startup - Configured Jest for testing, Prettier for formatting, and added CI workflow for automated checks
- Created extensive documentation including PRD, tech stack guide, and project charter
Reviewed changes
Copilot reviewed 17 out of 23 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
setup.mjs |
New setup automation script for local development environment |
package.json |
Root package with npm scripts for setup, start, lint, test, format, and gitcheck |
package-lock.json |
Updated package name from "NoteSharer" to "note-sharer" |
frontend/package.json |
Added test, format scripts and dependencies (jest, prettier, @types/jest) |
frontend/jest.config.cjs |
Jest configuration for Next.js with module path mapping |
frontend/eslint.config.mjs |
Added rule override to allow require imports in .cjs files |
frontend/__tests__/nicknames.test.ts |
Initial test file for nickname generation functions |
frontend/app/upload/page.tsx |
Added eslint-disable comments for unused error variables in catch blocks |
frontend/app/test-upload/page.tsx |
Added eslint-disable comments for unused imports and variables |
frontend/app/onboarding/page.tsx |
Removed no-console eslint-disable comments (now allowed by config) |
frontend/app/dashboard/page.tsx |
Added eslint-disable comments for unused error variables |
frontend/app/auth/page.tsx |
Removed no-console eslint-disable comment |
frontend/app/api/course-submissions/route.ts |
Added eslint-disable comment for unused error variable |
frontend/lib/nicknames.ts |
Removed no-console eslint-disable comment |
docs/PRD.md |
Comprehensive product requirements document (338 lines) |
docs/project-charter.md |
Project charter with team info, goals, timeline, and budget (81 lines) |
docs/Note_Sharer_Tech_Stack.md |
Technical architecture and stack documentation (191 lines) |
README.md |
Added setup instructions, CLI install guides, and documentation references |
.prettierrc.json |
Prettier configuration for code formatting |
.prettierignore |
Ignore patterns for Prettier |
.gitignore |
Added coverage and .vercel directories |
.github/workflows/ci.yml |
CI workflow to run checks on pull requests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "printWidth": 100, | |||
| "singleQuote": false, | |||
There was a problem hiding this comment.
The Prettier configuration sets "singleQuote": false, which means double quotes will be used. However, the existing codebase may have a mix of quote styles. Consider running Prettier on the entire codebase to ensure consistency, or verify that this configuration matches the project's existing style preferences.
| moduleNameMapper: { | ||
| "^@/(.*)$": "<rootDir>/$1", | ||
| }, | ||
| testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"], |
There was a problem hiding this comment.
The Jest configuration uses CommonJS format (.cjs) but the test file uses ES modules syntax (import). Jest 29 requires additional configuration to handle ES modules. Consider adding "testEnvironment": "node" is correct, but you may need to add "transform": {} and "extensionsToTreatAsEsm": [".ts"] or use a transformer like ts-jest to properly handle TypeScript with ES modules in Jest.
| testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"], | |
| testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"], | |
| extensionsToTreatAsEsm: [".ts", ".tsx"], |
|
|
||
| ## Contributing | ||
|
|
||
| Visit [contributing.md](docs/contributing.md) on info for how to contribute to this repo. |
There was a problem hiding this comment.
Grammar error: "on info for" should be "for info on" or "for information on".
| Visit [contributing.md](docs/contributing.md) on info for how to contribute to this repo. | |
| Visit [contributing.md](docs/contributing.md) for info on how to contribute to this repo. |
| with: | ||
| node-version: "20" | ||
| cache: "npm" | ||
| cache-dependency-path: frontend/package-lock.json |
There was a problem hiding this comment.
The CI workflow runs npm run gitcheck which executes the setup script with --skip-supabase --skip-env --no-start flags, followed by linting and testing. However, the setup script will still run npm install in the frontend directory at line 131. Since the workflow already has Node.js set up with caching, consider adding an explicit npm ci step in the workflow before running checks to ensure dependencies are installed, or document that the gitcheck script handles this.
| cache-dependency-path: frontend/package-lock.json | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: frontend |
| "lint": "npm --prefix frontend run lint", | ||
| "test": "npm --prefix frontend run test", | ||
| "format": "npm --prefix frontend run format", | ||
| "gitcheck": "node setup.mjs --skip-supabase --skip-env --no-start && npm --prefix frontend run lint && npm --prefix frontend run test" |
There was a problem hiding this comment.
The gitcheck script chains multiple commands with &&, which means if any command fails, the subsequent commands won't run. This is good for CI but consider whether you want to see all failures at once (linting AND test failures) rather than stopping at the first failure. If you want to see all failures, consider using a script that runs all commands and aggregates results.
| "gitcheck": "node setup.mjs --skip-supabase --skip-env --no-start && npm --prefix frontend run lint && npm --prefix frontend run test" | |
| "gitcheck:setup": "node setup.mjs --skip-supabase --skip-env --no-start", | |
| "gitcheck": "npm-run-all --continue-on-error gitcheck:setup lint test" | |
| }, | |
| "devDependencies": { | |
| "npm-run-all": "^4.1.5" |
| - Contributing: `docs/contributing.md` | ||
| - PR review guide: `docs/PR_REVIEW_GUIDE.md` | ||
|
|
||
| ## Contributing | ||
|
|
||
| Visit [contributing.md](docs/contributing.md) on info for how to contribute to this repo. |
There was a problem hiding this comment.
The documentation references "docs/contributing.md" and "docs/PR_REVIEW_GUIDE.md" but these files are not included in this PR. Ensure these files exist in the repository or will be added in a follow-up PR to avoid broken documentation links.
| - Contributing: `docs/contributing.md` | |
| - PR review guide: `docs/PR_REVIEW_GUIDE.md` | |
| ## Contributing | |
| Visit [contributing.md](docs/contributing.md) on info for how to contribute to this repo. | |
| - Contributing guidelines: (to be added in `docs/contributing.md`) | |
| - PR review guide: (to be added in `docs/PR_REVIEW_GUIDE.md`) | |
| ## Contributing | |
| Contributions are welcome. Please open an issue or pull request with your proposed changes; formal contributing guidelines will be added to `docs/contributing.md` in a future update. |
| const noStart = args.has("--no-start"); | ||
| const debug = args.has("--debug"); | ||
|
|
||
| const scriptRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); |
There was a problem hiding this comment.
The scriptRoot calculation at line 12 goes up one directory from where setup.mjs is located (using ".."). Since setup.mjs is in the repository root, this would resolve to the parent of the repository, which seems incorrect. The fallback logic at line 14 checks if frontend exists in cwdRoot (the current working directory) and uses that if found, otherwise falls back to scriptRoot. Consider removing the ".." from line 12 to make scriptRoot point to the repository root directly, which would be: path.dirname(fileURLToPath(import.meta.url))
| const scriptRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); | |
| const scriptRoot = path.dirname(fileURLToPath(import.meta.url)); |
| setTimeout(() => { | ||
| openBrowser("http://localhost:3000"); | ||
| }, 1500); |
There was a problem hiding this comment.
The setTimeout delay of 1500ms before opening the browser is arbitrary and may not be sufficient for slower systems. The dev server might not be ready yet, leading to a "connection refused" error in the browser. Consider checking for server readiness by polling localhost:3000 or using a longer/configurable delay.
| describe("nicknames", () => { | ||
| it("generates a nickname with letters and digits", () => { | ||
| const nickname = generateRandomNickname(); | ||
| expect(nickname).toMatch(/^[A-Za-z]+[A-Za-z]+[0-9]{1,2}$/); |
There was a problem hiding this comment.
The regex pattern /^[A-Za-z]+[A-Za-z]+[0-9]{1,2}$/ expects at least two letter groups followed by digits, but it would be clearer to express this as /^[A-Za-z]{2,}[0-9]{1,2}$/ if the intent is to match 2 or more letters followed by 1-2 digits. The current pattern /^[A-Za-z]+[A-Za-z]+[0-9]{1,2}$/ is redundant with two consecutive [A-Za-z]+ groups.
| expect(nickname).toMatch(/^[A-Za-z]+[A-Za-z]+[0-9]{1,2}$/); | |
| expect(nickname).toMatch(/^[A-Za-z]{2,}[0-9]{1,2}$/); |
Non-breaking changes. No code changes. Organizational, mostly scripting.
See full information at a high level: https://docs.google.com/document/d/1Z5ZuogPJgsPOnrmahv1TS2FNECc6qmROCm9K2Lgus6Q/edit?usp=sharing