create-veap 0.3.0 → 0.3.2

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.
package/README.md CHANGED
@@ -1,3 +1,76 @@
1
1
  # create-veap
2
2
 
3
- Initializer for Veap Framework applications. Scaffolds a full plugin-enabled Veap project on top of the official create-next-app.
3
+ The official project initializer for [Veap Framework](https://veap.pl) applications. Scaffolds a full plugin-enabled Veap project on top of the official `create-next-app`.
4
+
5
+ ## Quickstart
6
+
7
+ Initialize a new Veap project using your preferred package manager:
8
+
9
+ ```bash
10
+ # Using Bun (recommended)
11
+ bun create veap my-app
12
+
13
+ # Using pnpm
14
+ pnpm create veap my-app
15
+
16
+ # Using npm
17
+ npm create veap my-app
18
+
19
+ # Using Yarn
20
+ yarn create veap my-app
21
+ ```
22
+
23
+ Or execute directly through a package runner:
24
+
25
+ ```bash
26
+ bunx create-veap my-app
27
+ # or
28
+ npx create-veap my-app
29
+ ```
30
+
31
+ When you omit the project name in an interactive terminal, `create-veap` prompts for a project name.
32
+
33
+ During project creation, `create-veap` asks whether to include optional Docker configuration (`Dockerfile`, `compose.yml`, and `.dockerignore`). You can pass `--docker` or `--no-docker` to bypass the interactive prompt.
34
+
35
+ ## Command options
36
+
37
+ | Flag | Description |
38
+ | ---------------- | ------------------------------------------------------------------------------ |
39
+ | `--docker` | Generate Docker configuration (`Dockerfile`, `compose.yml`, `.dockerignore`). |
40
+ | `--no-docker` | Skip Docker configuration without prompting. |
41
+ | `--skip-install` | Do not run the package manager install step. |
42
+ | `--pm <manager>` | Specify package manager (`bun`, `pnpm`, `npm`, `yarn`). |
43
+ | `--pnpm` | Force pnpm as package manager. |
44
+ | `--bun` | Force Bun as package manager. |
45
+ | `--npm` | Force npm as package manager. |
46
+ | `--yarn` | Force Yarn as package manager. |
47
+
48
+ ### Automatic package manager detection
49
+
50
+ `create-veap` automatically detects the package manager from the execution command (`bun create`, `pnpm create`, `npm create`, `yarn create`, `bunx`, or `npx`) and environment variables without prompting.
51
+
52
+ If you want to use a different package manager than the runner (for example, executing via Bun while configuring the generated project for pnpm), pass the target package manager flag:
53
+
54
+ ```bash
55
+ bun create veap my-app --pnpm
56
+ ```
57
+
58
+ ## What it scaffolds
59
+
60
+ - Next.js 16 App Router with React Server Components, TypeScript, and Tailwind CSS v4.
61
+ - Veap overlay with virtual routing (`app/[[...catchAll]]/page.tsx` and `app/api/[...catchAll]/route.ts`).
62
+ - Service provider composition root in `lib/veap.ts`.
63
+ - Workspace configuration for plugins (`plugins/` directory).
64
+ - Default environment configuration (`.env`) with generated `ENCRYPTION_KEY` and local SQLite database.
65
+ - Agent instructions (`AGENTS.md`) and project guide (`README.md`).
66
+
67
+ ## Documentation
68
+
69
+ For full documentation and guides, visit:
70
+ - [https://veap.pl/docs](https://veap.pl/docs)
71
+ - [Installation Guide](https://veap.pl/docs/getting-started/installation)
72
+ - [CLI Reference](https://veap.pl/docs/reference/cli)
73
+
74
+ ## License
75
+
76
+ MIT
@@ -1,5 +1,5 @@
1
- export declare function initProject(name?: string, options?: {
1
+ import { type ResolvePackageManagerOptions } from "../package-manager.js";
2
+ export declare function initProject(name?: string, options?: ResolvePackageManagerOptions & {
2
3
  docker?: boolean;
3
4
  skipInstall?: boolean;
4
- pm?: string;
5
5
  }): Promise<void>;
@@ -32,9 +32,8 @@ export async function initProject(name, options) {
32
32
  if (withDocker === undefined) {
33
33
  withDocker = await promptConfirm("Include Docker configuration?", false);
34
34
  }
35
- // Resolve the package manager up front so the prompt runs before any
36
- // scaffolding starts (cleaner UX than asking mid-scaffold).
37
- const pm = await resolvePackageManager({ pm: options?.pm });
35
+ // Resolve the package manager automatically (or from flags)
36
+ const pm = await resolvePackageManager(options);
38
37
  const overlayFolder = "../../stubs/overlay-full";
39
38
  console.log(`🚀 Initializing new Veap project (Full plugin-enabled): ${projectName} in ${destDir}...`);
40
39
  try {
package/dist/index.js CHANGED
@@ -7,6 +7,10 @@ cli
7
7
  .option("--docker", "Initialize Docker configuration")
8
8
  .option("--skip-install", "Skip dependencies installation")
9
9
  .option("--pm <manager>", "Package manager to use: pnpm, npm, yarn or bun (auto-detected when omitted)")
10
+ .option("--pnpm, --use-pnpm", "Use pnpm as package manager")
11
+ .option("--bun, --use-bun", "Use bun as package manager")
12
+ .option("--npm, --use-npm", "Use npm as package manager")
13
+ .option("--yarn, --use-yarn", "Use yarn as package manager")
10
14
  .action(async (name, options) => {
11
15
  await initProject(name, options);
12
16
  });
@@ -7,6 +7,15 @@ export interface PackageManagerDetection {
7
7
  /** Human-readable detail, e.g. "pnpm@11.9.0" or "pnpm-lock.yaml". */
8
8
  detail?: string;
9
9
  }
10
+ /**
11
+ * Detects the package manager currently executing the process.
12
+ *
13
+ * Inspects:
14
+ * 1. `npm_config_user_agent` (set when invoked via npx, bunx, pnpm dlx, yarn create)
15
+ * 2. `process.versions.bun` (running directly inside Bun runtime)
16
+ * 3. `npm_execpath` (path containing the binary name)
17
+ */
18
+ export declare function detectRunningPackageManager(env?: NodeJS.ProcessEnv, versions?: NodeJS.ProcessVersions): PackageManager | null;
10
19
  /**
11
20
  * Detects the package manager to default to by inspecting `dir` (usually the
12
21
  * directory the scaffolding command was launched from).
@@ -18,22 +27,32 @@ export declare function detectPackageManager(dir: string): PackageManagerDetecti
18
27
  * Interactive numbered-choice prompt rendered on readline (no external
19
28
  * prompt library, matching the rest of this CLI).
20
29
  *
21
- * The detected package manager is listed first as the default; pressing
22
- * Enter accepts it. Accepts a number (1-4) or a name (`pnpm`, `npm`,
23
- * `yarn`, `bun`). On EOF / closed stdin (piped input, CI) resolves to the
24
- * detected default instead of hanging.
30
+ * Kept as a fallback helper.
25
31
  */
26
32
  export declare function promptPackageManager(detection: PackageManagerDetection): Promise<PackageManager>;
33
+ export interface ResolvePackageManagerOptions {
34
+ pm?: string;
35
+ pnpm?: boolean;
36
+ bun?: boolean;
37
+ npm?: boolean;
38
+ yarn?: boolean;
39
+ usePnpm?: boolean;
40
+ useBun?: boolean;
41
+ useNpm?: boolean;
42
+ useYarn?: boolean;
43
+ }
27
44
  /**
28
45
  * Resolves the package manager to use for a new project.
29
46
  *
30
- * Order: explicit `--pm <name>` flag (validated hard - scripts must not hang
31
- * on a prompt) → interactive prompt (TTY only) → auto-detected default
32
- * (non-TTY, CI).
47
+ * Priority:
48
+ * 1. Explicit manager flag: `--pnpm`, `--bun`, `--npm`, `--yarn`
49
+ * 2. Explicit `--pm <name>` flag
50
+ * 3. Auto-detected from currently running environment (e.g. `bun create`, `pnpm dlx`, `npx`)
51
+ * 4. Auto-detected from current directory (packageManager field, lockfiles, or default)
52
+ *
53
+ * Automatically resolves without prompting.
33
54
  */
34
- export declare function resolvePackageManager(options?: {
35
- pm?: string;
36
- }): Promise<PackageManager>;
55
+ export declare function resolvePackageManager(options?: ResolvePackageManagerOptions, cwd?: string): Promise<PackageManager>;
37
56
  /**
38
57
  * Applies the chosen package manager to the freshly scaffolded project:
39
58
  *
@@ -21,6 +21,43 @@ const LOCKFILES = [
21
21
  { file: "package-lock.json", pm: "npm" },
22
22
  ];
23
23
  const isPackageManager = (value) => PACKAGE_MANAGERS.includes(value);
24
+ /**
25
+ * Detects the package manager currently executing the process.
26
+ *
27
+ * Inspects:
28
+ * 1. `npm_config_user_agent` (set when invoked via npx, bunx, pnpm dlx, yarn create)
29
+ * 2. `process.versions.bun` (running directly inside Bun runtime)
30
+ * 3. `npm_execpath` (path containing the binary name)
31
+ */
32
+ export function detectRunningPackageManager(env = process.env, versions = process.versions) {
33
+ const userAgent = env.npm_config_user_agent;
34
+ if (userAgent) {
35
+ if (userAgent.startsWith("pnpm"))
36
+ return "pnpm";
37
+ if (userAgent.startsWith("bun"))
38
+ return "bun";
39
+ if (userAgent.startsWith("yarn"))
40
+ return "yarn";
41
+ if (userAgent.startsWith("npm"))
42
+ return "npm";
43
+ }
44
+ // Running directly under Bun runtime (e.g. `bun create veap` or `bunx create-veap`)
45
+ if (typeof versions?.bun === "string") {
46
+ return "bun";
47
+ }
48
+ const execPath = env.npm_execpath;
49
+ if (execPath) {
50
+ if (execPath.includes("pnpm"))
51
+ return "pnpm";
52
+ if (execPath.includes("bun"))
53
+ return "bun";
54
+ if (execPath.includes("yarn"))
55
+ return "yarn";
56
+ if (execPath.includes("npm"))
57
+ return "npm";
58
+ }
59
+ return null;
60
+ }
24
61
  /**
25
62
  * Detects the package manager to default to by inspecting `dir` (usually the
26
63
  * directory the scaffolding command was launched from).
@@ -56,8 +93,9 @@ export function detectPackageManager(dir) {
56
93
  detail: `multiple lockfiles found: ${found.map((l) => l.file).join(", ")}`,
57
94
  };
58
95
  }
59
- if (found.length === 1) {
60
- return { pm: found[0].pm, source: "lockfile", detail: found[0].file };
96
+ const first = found[0];
97
+ if (found.length === 1 && first) {
98
+ return { pm: first.pm, source: "lockfile", detail: first.file };
61
99
  }
62
100
  // 3. Framework default
63
101
  return { pm: "pnpm", source: "default" };
@@ -74,10 +112,7 @@ function formatDetection(d) {
74
112
  * Interactive numbered-choice prompt rendered on readline (no external
75
113
  * prompt library, matching the rest of this CLI).
76
114
  *
77
- * The detected package manager is listed first as the default; pressing
78
- * Enter accepts it. Accepts a number (1-4) or a name (`pnpm`, `npm`,
79
- * `yarn`, `bun`). On EOF / closed stdin (piped input, CI) resolves to the
80
- * detected default instead of hanging.
115
+ * Kept as a fallback helper.
81
116
  */
82
117
  export async function promptPackageManager(detection) {
83
118
  console.log(formatDetection(detection));
@@ -123,8 +158,11 @@ export async function promptPackageManager(detection) {
123
158
  if (String(asNumber) === value &&
124
159
  asNumber >= 1 &&
125
160
  asNumber <= PACKAGE_MANAGERS.length) {
126
- finish(PACKAGE_MANAGERS[asNumber - 1]);
127
- return;
161
+ const chosen = PACKAGE_MANAGERS[asNumber - 1];
162
+ if (chosen) {
163
+ finish(chosen);
164
+ return;
165
+ }
128
166
  }
129
167
  if (isPackageManager(value)) {
130
168
  finish(value);
@@ -140,25 +178,52 @@ export async function promptPackageManager(detection) {
140
178
  /**
141
179
  * Resolves the package manager to use for a new project.
142
180
  *
143
- * Order: explicit `--pm <name>` flag (validated hard - scripts must not hang
144
- * on a prompt) → interactive prompt (TTY only) → auto-detected default
145
- * (non-TTY, CI).
181
+ * Priority:
182
+ * 1. Explicit manager flag: `--pnpm`, `--bun`, `--npm`, `--yarn`
183
+ * 2. Explicit `--pm <name>` flag
184
+ * 3. Auto-detected from currently running environment (e.g. `bun create`, `pnpm dlx`, `npx`)
185
+ * 4. Auto-detected from current directory (packageManager field, lockfiles, or default)
186
+ *
187
+ * Automatically resolves without prompting.
146
188
  */
147
- export async function resolvePackageManager(options) {
148
- const detection = detectPackageManager(process.cwd());
189
+ export async function resolvePackageManager(options, cwd = process.cwd()) {
190
+ // 1. Explicit boolean flags: --pnpm, --bun, --npm, --yarn
191
+ if (options?.pnpm || options?.usePnpm) {
192
+ console.log("📦 Using package manager: pnpm (specified via --pnpm flag)");
193
+ return "pnpm";
194
+ }
195
+ if (options?.bun || options?.useBun) {
196
+ console.log("📦 Using package manager: bun (specified via --bun flag)");
197
+ return "bun";
198
+ }
199
+ if (options?.npm || options?.useNpm) {
200
+ console.log("📦 Using package manager: npm (specified via --npm flag)");
201
+ return "npm";
202
+ }
203
+ if (options?.yarn || options?.useYarn) {
204
+ console.log("📦 Using package manager: yarn (specified via --yarn flag)");
205
+ return "yarn";
206
+ }
207
+ // 2. Explicit --pm <name> flag
149
208
  if (options?.pm) {
150
209
  const requested = options.pm.trim().toLowerCase();
151
210
  if (isPackageManager(requested)) {
211
+ console.log(`📦 Using package manager: ${requested} (specified via --pm flag)`);
152
212
  return requested;
153
213
  }
154
214
  console.error(`Error: Unknown package manager "${options.pm}". Allowed: ${PACKAGE_MANAGERS.join(", ")}.`);
155
215
  process.exit(1);
156
216
  }
157
- if (!process.stdin.isTTY) {
158
- console.log(`📦 Using ${detection.pm} (auto-detected${detection.detail ? `: ${detection.detail}` : ""})`);
159
- return detection.pm;
217
+ // 3. Auto-detected from currently running execution environment
218
+ const running = detectRunningPackageManager();
219
+ if (running) {
220
+ console.log(`📦 Package manager detected: ${running} (from running environment)`);
221
+ return running;
160
222
  }
161
- return promptPackageManager(detection);
223
+ // 4. Auto-detected from directory context or framework default
224
+ const detection = detectPackageManager(cwd);
225
+ console.log(formatDetection(detection));
226
+ return detection.pm;
162
227
  }
163
228
  /**
164
229
  * Applies the chosen package manager to the freshly scaffolded project:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-veap",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Initializer for Veap Framework applications",
5
5
  "bugs": "https://github.com/veapjs/create-veap/issues",
6
6
  "repository": {
@@ -0,0 +1,132 @@
1
+ # {{name}}
2
+
3
+ A modern full-stack web application built with [Veap](https://veap.pl) and Next.js 16 (App Router & React Server Components).
4
+
5
+ ## What is Veap?
6
+
7
+ **Veap** is a modular application framework built on top of the Next.js App Router. It combines Next.js frontend flexibility with robust, enterprise-grade backend architectural primitives:
8
+
9
+ - **Clean Architecture & Service Providers**: Inversion of control container and modular service providers configured in `lib/veap.ts`.
10
+ - **Virtual Routing**: Dynamic route tree serving installed plugin routes and application routes through `app/[[...catchAll]]/page.tsx` and `app/api/[...catchAll]/route.ts`.
11
+ - **Plugin System**: Isolated, composable packages located in `plugins/` with declarative extensions and widgets.
12
+ - **ActiveRecord ORM**: Eloquent-style models and query builder backed by Knex with transactions and migrations.
13
+ - **Authentication & RBAC**: Built-in session management, user models, role-based access control, and password hashing.
14
+ - **Storage & Communication**: Unified file storage drivers and mail transports.
15
+
16
+ ---
17
+
18
+ ## Getting Started
19
+
20
+ ### 1. Requirements
21
+
22
+ - **Node.js** `>= 22` or **Bun** `>= 1.2`
23
+ - Supported package managers: `bun`, `pnpm`, `npm`, or `yarn`
24
+
25
+ ### 2. Environment Configuration
26
+
27
+ During project initialization, a default `.env` file is generated with a secure random `ENCRYPTION_KEY` and a local SQLite database configuration:
28
+
29
+ ```bash
30
+ DATABASE_CLIENT=sqlite3
31
+ DATABASE_URL=./storage/veap.sqlite
32
+ ENCRYPTION_KEY=<generated-key>
33
+ ```
34
+
35
+ > **Important**: The application enforces fail-fast verification on `ENCRYPTION_KEY`. Never commit `.env` to version control.
36
+
37
+ ### 3. Run the Development Server
38
+
39
+ Start the local development server:
40
+
41
+ ```bash
42
+ # Using bun
43
+ bun dev
44
+
45
+ # Or using pnpm
46
+ pnpm dev
47
+
48
+ # Or using npm
49
+ npm run dev
50
+ ```
51
+
52
+ Open [http://localhost:3000](http://localhost:3000) with your browser to view the application.
53
+
54
+ ---
55
+
56
+ ## Available Scripts
57
+
58
+ | Command | Description |
59
+ | --- | --- |
60
+ | `bun dev` | Starts the Next.js development server with Turbopack |
61
+ | `bun run build` | Builds the application for production |
62
+ | `bun run start` | Runs the production build |
63
+ | `bun run lint` | Runs ESLint checks |
64
+
65
+ *(Replace `bun` with `pnpm` or `npm run` depending on your package manager)*
66
+
67
+ ---
68
+
69
+ ## Veap CLI
70
+
71
+ The `veap` CLI manages plugins, database migrations, and framework components:
72
+
73
+ ```bash
74
+ # Add and register a plugin package
75
+ veap add <plugin-name>
76
+
77
+ # Scaffold a new workspace plugin in plugins/
78
+ veap make:plugin <plugin-name>
79
+
80
+ # Create a new database migration
81
+ veap make:migration <migration-name>
82
+
83
+ # Scaffold a new site layout template
84
+ veap make:template <template-name>
85
+
86
+ # Re-synchronize and generate lib/plugins.gen.ts
87
+ veap register
88
+
89
+ # Generate Docker deployment configuration
90
+ veap docker
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Project Structure
96
+
97
+ ```
98
+ ├── app/
99
+ │ ├── (site)/ # Declarative site layout route group
100
+ │ ├── [[...catchAll]]/ # Veap virtual page router
101
+ │ ├── api/[...catchAll]/ # Veap API pipeline (middlewares, RBAC, auth)
102
+ │ ├── storage/ # Local storage route handler
103
+ │ ├── layout.tsx # Root layout shell with force-dynamic bootstrap
104
+ │ └── globals.css # Tailwind CSS styling
105
+ ├── components/ # Reusable UI components (SiteLayout, Navbar, Footer)
106
+ ├── lib/
107
+ │ ├── veap.ts # Composition root: Application configuration & bootstrap
108
+ │ └── plugins.gen.ts # Generated plugin registry (managed by veap register)
109
+ ├── migrations/ # Database migrations
110
+ ├── plugins/ # Local workspace plugins
111
+ ├── storage/ # Local SQLite database & uploaded files
112
+ ├── AGENTS.md # AI coding agent instructions and architectural contracts
113
+ └── next.config.ts # Next.js configuration with Veap & Turbopack support
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Documentation & Resources
119
+
120
+ Explore the official Veap documentation to learn more about architecture, plugins, and guides:
121
+
122
+ - **Official Website**: [https://veap.pl](https://veap.pl)
123
+ - **Documentation**: [https://veap.pl/docs](https://veap.pl/docs)
124
+ - [Getting Started](https://veap.pl/docs/getting-started/introduction)
125
+ - [Architecture & Fundamentals](https://veap.pl/docs/fundamentals/architecture)
126
+ - [Virtual Routing & Middleware](https://veap.pl/docs/routing/routing)
127
+ - [Database & ORM](https://veap.pl/docs/data/database)
128
+ - [Authentication & RBAC](https://veap.pl/docs/auth)
129
+ - [Authoring Plugins](https://veap.pl/docs/plugins/creating-plugins)
130
+ - [CLI Reference](https://veap.pl/docs/reference/cli)
131
+ - **GitHub Repository**: [https://github.com/veapjs/veap](https://github.com/veapjs/veap)
132
+ - **Community Discussions**: [https://github.com/veapjs/veap/discussions](https://github.com/veapjs/veap/discussions)
@@ -1,7 +1,7 @@
1
1
  import { cache } from "react";
2
2
  import { Application } from "@veap/framework/core/server";
3
3
 
4
- import { appMigrations } from "../migrations";
4
+ import { migrations } from "../migrations";
5
5
  import { plugins } from "./plugins.gen";
6
6
  import { SiteLayout } from "../components/site-layout";
7
7
 
@@ -14,7 +14,7 @@ export const app = Application.configure()
14
14
  .withRouter()
15
15
  .withSiteLayout(SiteLayout)
16
16
  .withSettings()
17
- .withMigrations(appMigrations)
17
+ .withMigrations(migrations)
18
18
  .withPlugins(plugins)
19
19
  .create();
20
20
 
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated by Veap CLI. Do not edit manually.
2
- export const appMigrations: any[] = [];
2
+ export const migrations: any[] = [];
@@ -14,6 +14,16 @@ const nextConfig: NextConfig = {
14
14
  turbopackRustReactCompiler: true
15
15
  },
16
16
 
17
+ // @tailwindcss/turbopack support
18
+ turbopack: {
19
+ rules: {
20
+ "*.css": {
21
+ loaders: ["@tailwindcss/turbopack"],
22
+ as: "*.css",
23
+ },
24
+ },
25
+ },
26
+
17
27
  outputFileTracingIncludes: {
18
28
  "/**/*": ["veap.config.ts"],
19
29
  },