Skip to content

Commit 2382a9a

Browse files
committed
AINATIVEM-41 co-pilot review adjustments
dev app creation folder - app
1 parent 612c6bf commit 2382a9a

6 files changed

Lines changed: 29 additions & 11 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ node_modules/
22
dist/
33
.env
44
docs/superpowers/
5+
6+
# locally generated test apps
7+
*-app/

CLAUDE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ Wrapper around the official Pipedrive Node.js client with preconfigured authenti
7272
### App Extensions frontend (`frontend/app-extension-ui/`)
7373
Only generated when the user opts in. Iframe-based UI using the App Extensions SDK, supporting: initialization, resizing, modals, notifications/snackbars, theme handling.
7474

75+
## Development
76+
77+
To test app generation locally:
78+
79+
```bash
80+
npx tsx src/cli.ts app
81+
```
82+
83+
This creates an `app/` directory in the repo root (gitignored via `*-app/`).
84+
7585
## AI Plugin Commands (future layer)
7686

7787
```

src/cli.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as clack from '@clack/prompts';
2-
import { join } from 'path';
2+
import { basename, resolve } from 'path';
33
import { promptAppExtensions } from './prompts/appExtensions.js';
44
import { promptDatabase } from './prompts/database.js';
55
import { promptProjectName } from './prompts/projectName.js';
@@ -9,12 +9,13 @@ import { nodeGenerator } from './generators/node/index.js';
99
async function main(): Promise<void> {
1010
clack.intro('create-pipedrive-app');
1111

12-
const projectName = await promptProjectName(process.argv[2]);
12+
const nameOrPath = await promptProjectName(process.argv[2]);
1313
const database = await promptDatabase();
1414
const appExtensions = await promptAppExtensions();
1515
const webhooks = await promptWebhooks();
1616

17-
const outputDir = join(process.cwd(), projectName);
17+
const outputDir = resolve(process.cwd(), nameOrPath);
18+
const projectName = basename(outputDir);
1819

1920
try {
2021
await nodeGenerator.generate(outputDir, { projectName, database, appExtensions, webhooks });
@@ -29,7 +30,7 @@ async function main(): Promise<void> {
2930

3031
const needsDocker = database === 'postgres' || database === 'mysql';
3132
console.log('\nNext steps:');
32-
console.log(` cd ${projectName}`);
33+
console.log(` cd ${nameOrPath}`);
3334
console.log(' cp .env.example .env');
3435
if (needsDocker) console.log(' docker-compose up -d');
3536
console.log(' npm install');

src/generators/node/oauth.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import type { GeneratorOptions } from '../interface.js';
55
export async function generateOauth(outputDir: string, _options: GeneratorOptions): Promise<void> {
66
await writeFile(
77
join(outputDir, 'src/oauth/index.ts'),
8-
`import { Router } from 'express';
9-
export default Router();
10-
`,
8+
`
9+
import { Router } from 'express';
10+
export default Router();
11+
`,
1112
);
1213
}

src/prompts/projectName.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as clack from '@clack/prompts';
2+
import { basename } from 'path';
23

34
export async function promptProjectName(initial?: string): Promise<string> {
45
const value = await clack.text({
5-
message: 'Project name?',
6+
message: 'Project name or path?',
67
initialValue: initial,
78
validate: (v) => {
8-
if (!v.trim()) return 'Project name is required';
9+
const trimmed = v.trim();
10+
if (!trimmed) return 'Project name is required';
11+
if (!basename(trimmed)) return 'Path must include a directory name';
912
},
1013
});
1114

@@ -14,5 +17,5 @@ export async function promptProjectName(initial?: string): Promise<string> {
1417
process.exit(0);
1518
}
1619

17-
return value as string;
20+
return (value as string).trim();
1821
}

src/utils/writeFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export async function writeFile(filePath: string, content: string): Promise<void
55
let formatted: string;
66
try {
77
const config = await resolveConfig(filePath);
8-
formatted = await format(content, { singleQuote: true, ...config, filepath: filePath });
8+
formatted = await format(content, { singleQuote: true, ...(config ?? {}), filepath: filePath });
99
} catch (error) {
1010
if (error instanceof Error && error.message.includes('No parser could be inferred')) {
1111
formatted = content;

0 commit comments

Comments
 (0)