Skip to content

AINATIVEM-44 pipedrive client generator and builder pattern refactor#2

Merged
youssef-saber-3 merged 44 commits into
masterfrom
AINATIVEM-44
May 11, 2026
Merged

AINATIVEM-44 pipedrive client generator and builder pattern refactor#2
youssef-saber-3 merged 44 commits into
masterfrom
AINATIVEM-44

Conversation

@youssef-saber-3
Copy link
Copy Markdown
Contributor

Summary

  • Refactors the Node.js generator to use a NodeProjectBuilder + BuildStep pattern — replaces imperative function calls in index.ts with a fluent, chainable builder with a when() combinator for conditional features
  • Adds SourceFileBuilder utility for constructing TypeScript file content declaratively (import deduplication, conditional blocks, export default guard)
  • Adds RouterMountBuilder and template helpers (expressRouterFile, routerMount, envVarAccess) in templates.ts
  • Adds PipedriveClientStep — generates src/pipedrive/client.ts wrapping the official pipedrive SDK with proactive token expiry check and placeholder stubs for database/oauth modules
  • Adds npm run generate script and post-scaffold npm install prompt with async spinner

Test Plan

  • npm test — 63 tests across 15 files all pass (includes tsc integration test on generated project)
  • npm run generate — generates a project in apps/test-app/, answer yes to install prompt and verify spinner animates and deps install
  • Inspect apps/test-app/src/pipedrive/client.ts — should contain getClient, getStoredToken, refreshStoredToken with TODO comments

youssef-saber-3 and others added 25 commits May 11, 2026 13:03
…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
@youssef-saber-3 youssef-saber-3 marked this pull request as ready for review May 11, 2026 12:00
Copilot AI review requested due to automatic review settings May 11, 2026 12:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + BuildStep orchestration 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 thread src/cli.ts Outdated
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));
Comment thread src/generators/node/pipedriveClient.ts Outdated
// pipedrive v21 ships no .d.ts files; this shim satisfies tsc
await writeFile(
join(outputDir, 'src/pipedrive/pipedrive.d.ts'),
`declare module 'pipedrive';\n`,
Comment thread README.md
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 thread CLAUDE.md
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 thread CLAUDE.md
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.
youssef-saber-3 and others added 17 commits May 11, 2026 15:07
- 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
Copy link
Copy Markdown
Contributor

@dmitriyeff dmitriyeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@youssef-saber-3 youssef-saber-3 merged commit 7331809 into master May 11, 2026
1 check passed
@youssef-saber-3 youssef-saber-3 deleted the AINATIVEM-44 branch May 11, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants