Project Scripts
Relevant source files
The following files were used as context for generating this wiki page:The QR-Tool project utilizes a set of NPM scripts to automate common development tasks, including running the development server, building for production, executing tests, linting code, and performing security checks. These scripts are defined in the scripts section of the package.json file and are executed using a package manager like npm.
The scripts leverage tools like Vite for development and bundling, Vitest for testing, and ESLint for code quality. This standardized approach ensures a consistent and efficient workflow for all developers contributing to the project.
Sources: package.json:5-12, README.md:52-70
Scripts Overview
The project scripts provide a command-line interface for key development lifecycle stages. The following table summarizes the available scripts, their purpose, and the underlying tools they invoke.
| Script | Command | Description |
|---|---|---|
dev | npm run dev | Starts the Vite development server, typically on http://localhost:5173. |
build | npm run build | Creates a production-ready build of the application in the dist/ directory. |
lint | npm run lint | Runs ESLint to analyze the codebase for potential errors and style issues. |
preview | npm run preview | Starts a local server to preview the production build from the dist/ directory. |
test | npm test | Executes all unit tests once using Vitest. |
test:watch | npm run test:watch | Runs Vitest in watch mode, re-running tests on file changes. |
audit | npm audit | Checks for security vulnerabilities in project dependencies. |
Sources: package.json:6-11, README.md:155-162, SECURITY_AUDIT_REPORT.md:41-44
Script Definitions
The scripts are defined in package.json as follows:
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest"
},
Sources: package.json:5-12
Development Workflow
The scripts are designed to support a standard development workflow, from local development to production deployment.
This diagram illustrates the typical sequence of using the project scripts.
Sources: README.md:52-70, 155-162
Detailed Script Breakdown
Core Development
dev
The dev script starts the Vite development server. This provides a fast development experience with Hot Module Replacement (HMR).
- Command:
vite - Usage:
npm run dev
Sources: package.json:6, README.md:61-63
build
The build script uses Vite to bundle the application for production. The output is placed in the dist/ directory.
- Command:
vite build - Usage:
npm run build
Sources: package.json:7, README.md:68-70
preview
After a production build is created, the preview script can be used to serve the dist/ folder locally to verify the build.
- Command:
vite preview - Usage:
npm run preview
Sources: package.json:9, README.md:72-74
Testing
The project uses Vitest as its testing framework. Tests are located in the tests/ directory and alongside source files.
Sources: README.md:146-148, tests/qr-helpers.test.js
test
This script runs the entire test suite once and exits. It is suitable for CI/CD environments or pre-commit hooks.
- Command:
vitest run - Usage:
npm test
Sources: package.json:10, README.md:76-78
test:watch
This script starts Vitest in watch mode, which is ideal for local development. It automatically re-runs tests when source or test files are modified.
- Command:
vitest - Usage:
npm run test:watch
Sources: package.json:11, README.md:80-82
Code Quality
lint
The lint script executes ESLint across the project to enforce code quality and find potential bugs. The configuration for this is defined in eslint.config.js.
- Command:
eslint . - Usage:
npm run lint
Sources: package.json:8, README.md:84-86, eslint.config.js
Security
npm audit
Although not explicitly defined in the scripts section, npm audit is a critical command used in the project's security protocol. It scans project dependencies for known vulnerabilities. The security audit report confirms its use to achieve zero vulnerabilities.
- Usage:
npm audit