|
| 1 | +### Development Guidelines for `apps-script-utils` |
| 2 | + |
| 3 | +#### 1. Build and Configuration |
| 4 | + |
| 5 | +This project is a TypeScript-based utility library for Google Apps Script. |
| 6 | + |
| 7 | +- **Prerequisites**: Node.js and npm installed. |
| 8 | +- **Installation**: Run `npm install` to install all dependencies. |
| 9 | +- **Building**: Use `npm run build` to compile the TypeScript source into the `dist` directory. This script performs |
| 10 | + cleanup of the `dist` folder before running `tsc`. |
| 11 | +- **Linting and Formatting**: |
| 12 | + - `npm run lint`: Runs ESLint with auto-fix enabled. |
| 13 | + - `npm run format`: Runs Prettier to format all files in the project. |
| 14 | + |
| 15 | +#### 2. Testing |
| 16 | + |
| 17 | +The project uses [Vitest](https://vitest.dev/) for unit testing. |
| 18 | + |
| 19 | +- **Running Tests**: |
| 20 | + - `npm test`: Runs all tests once. |
| 21 | + - `npm run dev`: Starts Vitest in watch mode for interactive development. |
| 22 | +- **Adding New Tests**: |
| 23 | + - Tests should be placed in the `test/` directory, mirroring the structure of the `src/` directory. |
| 24 | + - Test files must follow the naming convention `*.test.ts`. |
| 25 | + - Use the `@/` alias to import from the `src/` directory (configured in `vitest.config.ts`). |
| 26 | +- **Example Test**: |
| 27 | + |
| 28 | + ```typescript |
| 29 | + import { describe, expect, it } from "vitest"; |
| 30 | + import { isString } from "@/lang/base/isString"; |
| 31 | + |
| 32 | + describe("isString", () => { |
| 33 | + it("should return true for strings", () => { |
| 34 | + expect(isString("hello")).toBe(true); |
| 35 | + }); |
| 36 | + |
| 37 | + it("should return false for non-strings", () => { |
| 38 | + expect(isString(123)).toBe(false); |
| 39 | + }); |
| 40 | + }); |
| 41 | + ``` |
| 42 | + |
| 43 | +#### 3. Code Style and Development |
| 44 | + |
| 45 | +- **Consistency**: Follow the existing code style. The project uses Prettier and ESLint to enforce formatting and best |
| 46 | + practices. |
| 47 | +- **CHANGELOG**: Do not modify `CHANGELOG.md` manually. It is updated automatically during the release process. |
| 48 | +- **Documentation**: Use JSDoc/KDoc comments for all exported functions. Include `@param`, `@returns`, `@since`, and |
| 49 | + `@version` tags where applicable. |
| 50 | +- **Modules**: The project is organized into logical modules: |
| 51 | + - `appsscript/`: Utilities specifically for Google Apps Script environments (Sheets, Drive, etc.). |
| 52 | + - `lang/`: General JavaScript/TypeScript language utilities (type checks, array/object helpers). |
| 53 | + - `net/`: Network and path-related utilities. |
| 54 | + - `exception/`, `html/`, `json/`, `time/`: Other specialized utility groups. |
| 55 | +- **Types**: Use strict TypeScript typing. Avoid `any` where possible. Prefer interface or type definitions for complex |
| 56 | + objects. |
| 57 | +- **Git Hooks**: The project uses `husky` for pre-commit and pre-push hooks to ensure code quality before pushing. |
0 commit comments