-
Notifications
You must be signed in to change notification settings - Fork 0
Stage 1: Project Setup and Configuration
mandla-enkosi edited this page Apr 5, 2025
·
1 revision
-
Objective: Establish the monorepo structure (
@react-api-kit/corepackage), configure base tooling (TypeScript, ESLint, Prettier, ViTest, Rollup), and set up CI/CD tooling. -
Expected Result:
- Functioning monorepo (
/packages/core) with shared root configuration files (e.g., roottsconfig.json, ESLint, Prettier) - Configured CI pipeline (GitHub Actions)
- Build process that compiles the initial core package structure without errors.
- Functioning monorepo (
- Pre-Stage Requirements: Initial development environment setup (Node.js, NPM with Workspaces).
-
External Dependencies: Lerna, TypeScript, ESLint, Prettier, ViTest, Rollup (with plugins: typescript, node-resolve, commonjs),
rimraf(for clean script). Addaxiosandzustandas core dependencies. -
External Dependencies:
typescript,eslint,prettier,vitest,rollup(with plugins: typescript, node-resolve, commonjs),axios,zustand, relevant@types/*. - Environment Configurations: Basic CI environment variables (if any).
-
Visual Aids:
Loading
graph LR A[Root Directory] --> B[packages/core] subgraph "Monorepo Root" direction LR R_PKG["package.json"] R_TS["tsconfig.json"] R_ES["eslintrc.js"] R_PR["prettierrc"] R_VITEST["vitest.config.js"] R_GIT["github/workflows/ci.yml"] end subgraph "@react-api-kit/core Package" direction LR C_PKG["package.json"] C_TS["tsconfig.json"] C_ROLL["rollup.config.js"] C_SRC["src/index.ts"] end A --- R_PKG & R_TS & R_ES & R_PR & R_VITEST & R_GIT A --- B --- C_PKG & C_TS & C_ROLL & C_SRC C_TS -- extends --> R_TS C_PKG -- uses deps from --> R_PKG
-
Modules/Files:
-
Root Files:
-
package.json: Configure workspaces (packages/core), add root dev dependencies (typescript,vitest,eslint,prettier,rollup,@rollup/plugin-*,rimraf,@types/*). Define root scripts (bootstrap,build,test,lint). -
tsconfig.json: Define base TS compiler options (target ES2018+, module ESNext, strict, declaration, sourceMap, esModuleInterop, skipLibCheck, isolatedModules). Configure composite projectreferences. -
.eslintrc.js: Configure ESLint parser (@typescript-eslint/parser), plugins (@typescript-eslint,react,react-hooks,prettier), extends (eslint:recommended,plugin:react/recommended,plugin:@typescript-eslint/recommended,plugin:prettier/recommended), rules (react/react-in-jsx-scope: off, etc.). Define settings (react version). -
.prettierrc.jsor.prettierrc.json: Define formatting rules (semi: true,singleQuote: true,tabWidth: 2,trailingComma: 'es5',printWidth: 80). -
vitest.config.js: Configure base ViTest settings. -
.github/workflows/ci.yml: Setup basic workflow (triggers on push/PR, matrix for Node versions, steps: checkout, setup node, install deps, lint, test, build).
-
-
/packages/corePackage:-
/packages/core/package.json: Create package definition (name: "@react-api-kit/core",version,description,main,module,types,files: ["dist"]). Adddependencies:axios,zustand. AddpeerDependencies:react. Add optional RN peer dependencies (@react-native-community/netinfo,react-native-encrypted-storage,react-native-linking,react-native-app-auth) usingpeerDependenciesMeta. Define package scripts (build,dev,test,lint,clean). Addrepository,keywords,author,license. -
/packages/core/tsconfig.json: Create package-specific TS config (extends,compilerOptions.outDir,compilerOptions.rootDir,include: ["src/**/*"],exclude: ["node_modules", "dist", "**/__tests__"]). -
/packages/core/rollup.config.js: Setup Rollup (inputsrc/index.ts, output CJS/ESM formats indist/, sourcemaps, plugins: typescript, node-resolve, commonjs). Mark peer dependencies asexternal. -
/packages/core/src/index.ts: Create initial empty entry point file.
-
-
Root Files:
-
Functionalities:
- Establish monorepo workspace structure.
- Define base code quality, formatting, and compilation settings.
- Set up automated CI checks.
- Create the skeleton for the core package with build/test configurations and essential dependencies.
-
Configuration Contracts (Implicit via Files):
- Root config files define baseline standards for TypeScript, ESLint, Prettier, ViTest.
-
Package Interface Contracts (
/packages/core/package.json):- Specifies the package name, version, entry points (
main,module,types), included files (files), core dependencies (axios,zustand), peer dependencies (react), optional RN peer dependencies, and standard build/test/lint scripts.
- Specifies the package name, version, entry points (
-
Public API Entry Point (
/packages/core/src/index.ts):- Initially empty or contains placeholder exports. Defines the starting point for the package's public API surface.
- Frameworks & Coverage Goals: Configure ViTest. Set coverage reporting (e.g., Clover, JSON) and target >90% for later stages.
-
Initial Tests: Add a placeholder test file (
src/tests/index.test.ts) ensuring the test runner executes correctly within the core package environment.
- Monorepo structure correctly set up; package installation works via workspace commands.
- Shared configuration files are correctly inherited/applied to the core package.
- Build script (
npm run build --workspace=@react-api-kit/core) successfully generatesdistfolder with CJS/ESM files for core package (@react-api-kit/core) using Rollup. - Test script (
npm run test) runs successfully using root ViTest config. - Lint script (
npm run lint --workspace=@react-api-kit/core) runs successfully using root ESLint config. - CI pipeline executes build, lint, and test steps successfully.
- Root
README.md: Explain monorepo structure, refined project purpose, development workflow (install, build, test, lint commands). -
/packages/core/README.md: Briefly explain the purpose of the core package. -
CONTRIBUTING.md: Outline contribution process, code style, PR requirements. - Initialize
CHANGELOG.md: Start tracking changes; define SemVer policy.
- Ensure TypeScript
strictmode is enabled in the basetsconfig.json. - Configure Rollup to correctly handle
externalpeer dependencies and generate accurate type definition files (.d.ts).
- Base TSConfig (
lib,jsx) should support both Web and React Native targets. - ESLint config includes rules relevant for React/hooks applicable to both.
- Rollup output should be compatible with both web bundlers (Webpack, Vite) and React Native's Metro bundler.