create-fff-app 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +15 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fff-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold a new fff-stack project",
5
5
  "bin": {
6
6
  "create-fff-app": "src/index.ts"
package/src/index.ts CHANGED
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
11
- import { join, relative, dirname } from 'path';
11
+ import { join, relative, dirname, basename } from 'path';
12
12
  import { execSync } from 'child_process';
13
13
 
14
- // Prefer the template bundled alongside this package (npm published).
15
- // Fall back to the monorepo layout for local development.
14
+ // Prefer the monorepo template for local development (uses file: references).
15
+ // Fall back to the bundled template for npm-published installs.
16
16
  const bundledTemplate = join(import.meta.dir, '../template');
17
17
  const monorepTemplate = join(import.meta.dir, '../../../template');
18
- const TEMPLATE_DIR = existsSync(bundledTemplate) ? bundledTemplate : monorepTemplate;
18
+ const TEMPLATE_DIR = existsSync(monorepTemplate) ? monorepTemplate : bundledTemplate;
19
19
  const SKIP_DIRS = new Set(['obj', 'bin', 'node_modules', '.git', 'dist']);
20
20
 
21
21
  // ── Helpers ───────────────────────────────────────────────────────────────────
@@ -57,6 +57,7 @@ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
57
57
 
58
58
  ${bold('Usage:')}
59
59
  bunx create-fff-app ${cyan('<project-name>')}
60
+ bunx create-fff-app ${cyan('.')} ${dim('# scaffold into the current directory')}
60
61
 
61
62
  ${bold('Example:')}
62
63
  bunx create-fff-app my-workers-app
@@ -64,12 +65,15 @@ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
64
65
  process.exit(args.length === 0 ? 1 : 0);
65
66
  }
66
67
 
67
- const rawName = args[0].trim();
68
+ const rawArg = args[0].trim();
69
+ const inPlace = rawArg === '.';
70
+ const cwd = process.cwd();
71
+ const rawName = inPlace ? basename(cwd) : rawArg;
68
72
  const projectName = rawName.replace(/[^a-z0-9\-_]/gi, '-').toLowerCase();
69
- const targetDir = join(process.cwd(), rawName);
73
+ const targetDir = inPlace ? cwd : join(cwd, rawArg);
70
74
 
71
- if (existsSync(targetDir)) {
72
- console.error(`\n Error: directory '${rawName}' already exists.\n`);
75
+ if (!inPlace && existsSync(targetDir)) {
76
+ console.error(`\n Error: directory '${rawArg}' already exists.\n`);
73
77
  process.exit(1);
74
78
  }
75
79
 
@@ -95,13 +99,12 @@ try {
95
99
  }
96
100
 
97
101
  // Print next steps
102
+ const cdStep = inPlace ? '' : `\n ${cyan(`cd ${rawArg}`)}`;
98
103
  console.log(`
99
- ${green('✓')} Done! Your project is at ${bold(rawName)}/
104
+ ${green('✓')} Done! ${inPlace ? `Project ${bold(projectName)} is ready.` : `Your project is at ${bold(rawArg)}/`}
100
105
 
101
106
  ${bold('Next steps:')}
102
-
103
- ${cyan(`cd ${rawName}`)}
104
-
107
+ ${cdStep}
105
108
  ${dim('# Install JS dependencies')}
106
109
  ${cyan('bun install')}
107
110