AINATIVEM-44 pipedrive client generator and builder pattern refactor#2
Merged
Conversation
…ed package.json - Update generatePackageJson to include database-specific drivers (postgres, mysql2, better-sqlite3) - Add sqlite type definitions for better-sqlite3 - Add drizzle-kit to devDependencies - Add db:migrate script to run drizzle-kit migrate - Fix schema.ts primaryKey syntax to use object callback instead of array
There was a problem hiding this comment.
Pull request overview
Refactors the Node.js scaffolding pipeline to a step-based NodeProjectBuilder pattern, adds small string/template builders for generating TypeScript sources, and introduces generation of a Pipedrive SDK wrapper plus a post-scaffold dependency install prompt in the CLI.
Changes:
- Introduces
NodeProjectBuilder+BuildSteporchestration and updates the Node generator to use it. - Adds
SourceFileBuilder+ routing/template helpers (templates.ts) and refactors generators to use them. - Adds a generated Pipedrive client wrapper and updates CLI/docs/scripts to support local generation + optional
npm install.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/templates.ts | Adds small helpers for router files, mounts, and env var access + a mount builder. |
| src/utils/templates.test.ts | Tests for the new template helpers/builders. |
| src/utils/sourceFileBuilder.ts | Adds a declarative TS source builder with import dedupe + default export guard. |
| src/utils/sourceFileBuilder.test.ts | Tests import merging/deduping, conditional blocks, and default export behavior. |
| src/generators/node/projectBuilder.ts | Implements the NodeProjectBuilder / BuildStep pipeline and moves file-generation responsibilities into steps. |
| src/generators/node/projectBuilder.test.ts | Verifies conditional when() behavior and step execution order. |
| src/generators/node/pipedriveClient.ts | Generates src/pipedrive/client.ts and a pipedrive.d.ts shim for typing. |
| src/generators/node/pipedriveClient.test.ts | Tests generated Pipedrive client files/contents. |
| src/generators/node/oauth.ts | Switches OAuth router stub generation to a shared template helper. |
| src/generators/node/index.ts | Replaces imperative generation flow with fluent builder chaining. |
| src/generators/node/index.test.ts | Updates E2E expectations (includes generated Pipedrive client) + uses node: built-ins. |
| src/generators/node/app.ts | Refactors app generation to use SourceFileBuilder and RouterMountBuilder. |
| src/cli.ts | Adds optional post-generation npm install with a spinner. |
| README.md | Expands usage documentation and describes generated project structure. |
| package.json | Adds npm run generate for local scaffold testing. |
| CLAUDE.md | Updates contributor commands/docs (but has some stale generator-flow details). |
| .gitignore | Ignores apps/ generated test projects and IDE files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+35
to
+38
| spinner.start('Installing dependencies'); | ||
| const ok = await new Promise<boolean>(resolve => { | ||
| const child = spawn('npm', ['install'], { cwd: outputDir, stdio: 'ignore' }); | ||
| child.on('close', code => resolve(code === 0)); |
| // pipedrive v21 ships no .d.ts files; this shim satisfies tsc | ||
| await writeFile( | ||
| join(outputDir, 'src/pipedrive/pipedrive.d.ts'), | ||
| `declare module 'pipedrive';\n`, |
| app.ts # Express app with OAuth router (+ optional webhooks/extensions) | ||
| oauth/ # OAuth 2.0 install, callback, token exchange, refresh | ||
| database/ # Drizzle ORM schema, migrations, db driver | ||
| pipedrive-client/ # Pipedrive API client wrapper |
Comment on lines
+39
to
+44
| → prompts/ (projectName, database, appExtensions, webhooks) | ||
| → nodeGenerator (orchestrates 5 sub-generators) | ||
| → oauth.ts, database.ts, app.ts | ||
| → webhooks.ts (conditional), appExtensions.ts (conditional) | ||
| → serverEntry, packageJson, tsConfig, envExample, dockerCompose | ||
| ``` |
Comment on lines
+46
to
+48
| **There is no template directory.** Generators build file content as strings using `dedent()`, with conditional string interpolation for optional features (webhooks, app extension types). The `src/utils/writeFile.ts` utility writes files, creates parent directories, and auto-formats output with Prettier — generated code is formatted automatically without an explicit format step. | ||
|
|
||
| `app.ts` is the main example of the conditional pattern: imports and router mounts are included only when the relevant features are enabled, and the result is written once. |
- Adopt NodeProjectBuilder/BuildStep pattern from AINATIVEM-44 - Move docker-compose generation from database.ts to projectBuilder.ts steps - Add healthchecks to PostgresDockerStep and MySQLDockerStep - Update ServerEntryStep to call runMigrations() before app.listen() - Update PackageJsonStep with DB drivers, drizzle-kit ^0.21.0, db:migrate script - Add pipedrive ^21.0.0 dependency - Move docker-compose tests to projectBuilder.test.ts
Resolve three merge conflicts from AINATIVEM-44: - database.test.ts: keep multi-database test helpers (pgOptions, read, afterEach) - pipedriveClient.ts: drop v21 d.ts shim, pipedrive v32 ships proper types - projectBuilder.ts: adopt pipedrive ^32.0.0, retain database driver deps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat(sqlite): switch to @libsql/client, add migration journal generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NodeProjectBuilder+BuildSteppattern — replaces imperative function calls inindex.tswith a fluent, chainable builder with awhen()combinator for conditional featuresSourceFileBuilderutility for constructing TypeScript file content declaratively (import deduplication, conditional blocks, export default guard)RouterMountBuilderand template helpers (expressRouterFile,routerMount,envVarAccess) intemplates.tsPipedriveClientStep— generatessrc/pipedrive/client.tswrapping the officialpipedriveSDK with proactive token expiry check and placeholder stubs for database/oauth modulesnpm run generatescript and post-scaffoldnpm installprompt with async spinnerTest Plan
npm test— 63 tests across 15 files all pass (includes tsc integration test on generated project)npm run generate— generates a project inapps/test-app/, answer yes to install prompt and verify spinner animates and deps installapps/test-app/src/pipedrive/client.ts— should containgetClient,getStoredToken,refreshStoredTokenwith TODO comments