@vorra/cli 0.3.0

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.
@@ -0,0 +1,235 @@
1
+ // =============================================================================
2
+ // @forge/cli — forge new
3
+ // Scaffolds a new Forge application in a subdirectory of cwd.
4
+ // =============================================================================
5
+ import * as fs from 'node:fs';
6
+ import * as path from 'node:path';
7
+ /**
8
+ * Scaffolds a new project.
9
+ *
10
+ * Usage: forge new <project-name>
11
+ *
12
+ * Creates the following structure:
13
+ * <name>/
14
+ * .gitignore
15
+ * index.html
16
+ * forge.config.js
17
+ * package.json
18
+ * tsconfig.json
19
+ * src/
20
+ * env.d.ts
21
+ * main.ts
22
+ * App.forge
23
+ */
24
+ export function runNew(args) {
25
+ const name = args[0];
26
+ if (!name) {
27
+ console.error('[Forge CLI] Usage: forge new <project-name>');
28
+ process.exit(1);
29
+ return;
30
+ }
31
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
32
+ console.error('[Forge CLI] Project name must be lowercase letters/digits/hyphens, starting with a letter.');
33
+ process.exit(1);
34
+ return;
35
+ }
36
+ const projectDir = path.join(process.cwd(), name);
37
+ if (fs.existsSync(projectDir)) {
38
+ console.error(`[Forge CLI] Directory "${name}" already exists.`);
39
+ process.exit(1);
40
+ return;
41
+ }
42
+ console.log(`\n Scaffolding Forge app: ${name}\n`);
43
+ // Create directory tree.
44
+ fs.mkdirSync(path.join(projectDir, 'src'), { recursive: true });
45
+ // Write each template file.
46
+ write(projectDir, 'package.json', tplPackageJson(name));
47
+ write(projectDir, 'tsconfig.json', tplTsconfig());
48
+ write(projectDir, 'forge.config.js', tplForgeConfig());
49
+ write(projectDir, 'index.html', tplIndexHtml(name));
50
+ write(projectDir, '.gitignore', tplGitignore());
51
+ write(projectDir, 'src/env.d.ts', tplEnvDts());
52
+ write(projectDir, 'src/main.ts', tplMainTs());
53
+ write(projectDir, 'src/App.forge', tplAppForge());
54
+ const files = [
55
+ 'package.json',
56
+ 'tsconfig.json',
57
+ 'forge.config.js',
58
+ 'index.html',
59
+ '.gitignore',
60
+ 'src/env.d.ts',
61
+ 'src/main.ts',
62
+ 'src/App.forge',
63
+ ];
64
+ for (const f of files) {
65
+ console.log(` \u2713 ${name}/${f}`);
66
+ }
67
+ console.log(`
68
+ Done! Next steps:
69
+
70
+ cd ${name}
71
+ npm install
72
+ npm run dev
73
+ `);
74
+ }
75
+ // ---------------------------------------------------------------------------
76
+ // Helpers
77
+ // ---------------------------------------------------------------------------
78
+ function write(dir, filename, content) {
79
+ fs.writeFileSync(path.join(dir, filename), content, 'utf8');
80
+ }
81
+ // ---------------------------------------------------------------------------
82
+ // Templates
83
+ // ---------------------------------------------------------------------------
84
+ function tplPackageJson(name) {
85
+ return JSON.stringify({
86
+ name,
87
+ version: '0.1.0',
88
+ private: true,
89
+ type: 'module',
90
+ scripts: {
91
+ dev: 'forge dev',
92
+ build: 'forge build',
93
+ typecheck: 'forge typecheck',
94
+ },
95
+ dependencies: {
96
+ '@forge/core': '^0.1.0',
97
+ },
98
+ devDependencies: {
99
+ '@forge/cli': '^0.1.0',
100
+ '@forge/compiler': '^0.1.0',
101
+ rolldown: '^0.14.0',
102
+ typescript: '^5.4.0',
103
+ },
104
+ engines: {
105
+ node: '>=20.0.0',
106
+ },
107
+ }, null, 2);
108
+ }
109
+ function tplTsconfig() {
110
+ return JSON.stringify({
111
+ compilerOptions: {
112
+ target: 'ES2022',
113
+ module: 'ESNext',
114
+ moduleResolution: 'Bundler',
115
+ strict: true,
116
+ exactOptionalPropertyTypes: true,
117
+ noUncheckedIndexedAccess: true,
118
+ experimentalDecorators: true,
119
+ useDefineForClassFields: false,
120
+ skipLibCheck: true,
121
+ noEmit: true,
122
+ },
123
+ include: ['src'],
124
+ }, null, 2);
125
+ }
126
+ function tplForgeConfig() {
127
+ return `// forge.config.js
128
+ import { defineConfig } from '@forge/cli';
129
+
130
+ export default defineConfig({
131
+ entry: 'src/main.ts',
132
+ outDir: 'dist',
133
+ port: 3000,
134
+ });
135
+ `;
136
+ }
137
+ function tplIndexHtml(name) {
138
+ return `<!DOCTYPE html>
139
+ <html lang="en">
140
+ <head>
141
+ <meta charset="UTF-8" />
142
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
143
+ <title>${name}</title>
144
+ </head>
145
+ <body>
146
+ <div id="app"></div>
147
+ <script type="module" src="./dist/main.js"></script>
148
+ </body>
149
+ </html>
150
+ `;
151
+ }
152
+ function tplGitignore() {
153
+ return `node_modules/
154
+ dist/
155
+ *.tsbuildinfo
156
+ `;
157
+ }
158
+ function tplEnvDts() {
159
+ return `// Type declarations for .forge single-file components.
160
+ import type { ComponentContext } from '@forge/core';
161
+
162
+ declare module '*.forge' {
163
+ const component: (ctx: ComponentContext) => Node;
164
+ export default component;
165
+ }
166
+ `;
167
+ }
168
+ function tplMainTs() {
169
+ return `import { bootstrapApp } from '@forge/core';
170
+ import { createComponent, mountComponent } from '@forge/core';
171
+ import App from './App.forge';
172
+
173
+ const appEl = document.getElementById('app');
174
+ if (appEl === null) throw new Error('[App] #app element not found in index.html');
175
+
176
+ const root = bootstrapApp();
177
+ const ctx = createComponent(root);
178
+ mountComponent(App, appEl, ctx);
179
+ `;
180
+ }
181
+ function tplAppForge() {
182
+ return `<script>
183
+ import { signal } from '@forge/core';
184
+
185
+ const count = signal(0);
186
+
187
+ function increment(): void {
188
+ count.update((n) => n + 1);
189
+ }
190
+ </script>
191
+
192
+ <template>
193
+ <div class="app">
194
+ <h1>Welcome to Forge ⚡</h1>
195
+ <p class="counter">Count: {count()}</p>
196
+ <button @click="increment">Increment</button>
197
+ </div>
198
+ </template>
199
+
200
+ <style scoped>
201
+ .app {
202
+ font-family: system-ui, sans-serif;
203
+ max-width: 480px;
204
+ margin: 4rem auto;
205
+ padding: 0 1rem;
206
+ text-align: center;
207
+ }
208
+
209
+ h1 {
210
+ font-size: 2rem;
211
+ margin-bottom: 1rem;
212
+ }
213
+
214
+ .counter {
215
+ font-size: 1.25rem;
216
+ margin-bottom: 1.5rem;
217
+ }
218
+
219
+ button {
220
+ padding: 0.5rem 1.5rem;
221
+ font-size: 1rem;
222
+ cursor: pointer;
223
+ border: 2px solid currentColor;
224
+ border-radius: 6px;
225
+ background: transparent;
226
+ transition: background 0.2s;
227
+ }
228
+
229
+ button:hover {
230
+ background: #f0f0f0;
231
+ }
232
+ </style>
233
+ `;
234
+ }
235
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,yBAAyB;AACzB,8DAA8D;AAC9D,gFAAgF;AAEhF,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,IAAc;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAErB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,KAAK,CACX,4FAA4F,CAC7F,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAElD,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,mBAAmB,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;Q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;;;;CAOhB,CAAC;AACF,CAAC;AAED,SAAS,YAAY;IACnB,OAAO;;;CAGR,CAAC;AACF,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;;;;;;;;;;CAUR,CAAC;AACF,CAAC;AAED,SAAS,WAAW;IAClB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDR,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Runs TypeScript type checking via `tsc --build`.
3
+ * Passes `--noEmit` unless the project tsconfig already disables emit.
4
+ * Exits with the same code as tsc.
5
+ */
6
+ export declare function runTypecheck(args: string[]): void;
7
+ //# sourceMappingURL=typecheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../../src/commands/typecheck.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAkBjD"}
@@ -0,0 +1,26 @@
1
+ // =============================================================================
2
+ // @forge/cli — forge typecheck
3
+ // Delegates to `tsc --build` in the project root.
4
+ // =============================================================================
5
+ import { spawnSync } from 'node:child_process';
6
+ /**
7
+ * Runs TypeScript type checking via `tsc --build`.
8
+ * Passes `--noEmit` unless the project tsconfig already disables emit.
9
+ * Exits with the same code as tsc.
10
+ */
11
+ export function runTypecheck(args) {
12
+ const noEmit = args.includes('--emit') ? [] : ['--noEmit'];
13
+ console.log('[forge typecheck] Running tsc --build...');
14
+ const result = spawnSync('tsc', ['--build', ...noEmit], {
15
+ stdio: 'inherit',
16
+ shell: true,
17
+ cwd: process.cwd(),
18
+ });
19
+ if (result.error !== undefined) {
20
+ console.error('[Forge CLI] Failed to run tsc:', result.error.message);
21
+ process.exit(1);
22
+ return;
23
+ }
24
+ process.exit(result.status ?? 0);
25
+ }
26
+ //# sourceMappingURL=typecheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck.js","sourceRoot":"","sources":["../../src/commands/typecheck.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+BAA+B;AAC/B,kDAAkD;AAClD,gFAAgF;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAE3D,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAExD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,EAAE;QACtD,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;KACnB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AACnC,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/index.ts
3
+ /**
4
+ * Type-safe helper for writing `vorra.config.js`.
5
+ *
6
+ * @example
7
+ * ```js
8
+ * // vorra.config.js
9
+ * import { defineConfig } from '@vorra/cli';
10
+ *
11
+ * export default defineConfig({
12
+ * entry: 'src/main.ts',
13
+ * outDir: 'dist',
14
+ * port: 3000,
15
+ * });
16
+ * ```
17
+ */
18
+ function defineConfig(config) {
19
+ return config;
20
+ }
21
+ //#endregion
22
+ exports.defineConfig = defineConfig;
23
+
24
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["// =============================================================================\r\n// @vorra/cli — Public API\r\n// =============================================================================\r\n\r\n/**\r\n * User-facing configuration for a Vorra project.\r\n * Returned by `defineConfig()` and loaded by `vorra dev` / `vorra build`.\r\n */\r\nexport interface VorraConfig {\r\n /** Application entry point. Defaults to `'src/main.ts'`. */\r\n entry?: string;\r\n /** Output directory. Defaults to `'dist'`. */\r\n outDir?: string;\r\n /** Dev server port. Defaults to `3000`. */\r\n port?: number;\r\n /**\r\n * Output directory used by `vorra dev`. Defaults to `'.vorra'`.\r\n * Kept separate from `outDir` so dev artifacts never pollute the production\r\n * build folder. Add `.vorra/` to your `.gitignore`.\r\n */\r\n devOutDir?: string;\r\n /** Additional Rolldown plugins appended after the built-in vorra plugin. */\r\n plugins?: unknown[];\r\n /**\r\n * Emit source map files alongside build output.\r\n * Defaults to `false` for `vorra build` (production).\r\n * `vorra dev` always enables source maps regardless of this setting.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js — enable source maps for a debug/staging build\r\n * export default defineConfig({ sourcemap: true });\r\n * ```\r\n */\r\n sourcemap?: boolean;\r\n /**\r\n * Absolute or relative path to a CSS entry file processed through PostCSS\r\n * (e.g. a Tailwind CSS file using `@import \"tailwindcss\"`). Import the\r\n * virtual module `\"vorra:css\"` from your entry point to inject it:\r\n *\r\n * ```ts\r\n * // src/main.ts\r\n * import 'vorra:css';\r\n * ```\r\n */\r\n css?: string;\r\n /**\r\n * PostCSS configuration. Required when `css` uses PostCSS-processed rules\r\n * such as Tailwind CSS.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js\r\n * import tailwindcss from '@tailwindcss/postcss';\r\n * export default defineConfig({\r\n * css: './src/tailwind.css',\r\n * postcss: { plugins: [tailwindcss()] },\r\n * });\r\n * ```\r\n */\r\n postcss?: { plugins: unknown[] };\r\n}\r\n\r\n/**\r\n * Type-safe helper for writing `vorra.config.js`.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js\r\n * import { defineConfig } from '@vorra/cli';\r\n *\r\n * export default defineConfig({\r\n * entry: 'src/main.ts',\r\n * outDir: 'dist',\r\n * port: 3000,\r\n * });\r\n * ```\r\n */\r\nexport function defineConfig(config: VorraConfig): VorraConfig {\r\n return config;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;AA8EA,SAAgB,aAAa,QAAkC;AAC7D,QAAO"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * User-facing configuration for a Forge project.
3
+ * Returned by `defineConfig()` and loaded by `forge dev` / `forge build`.
4
+ */
5
+ export interface ForgeConfig {
6
+ /** Application entry point. Defaults to `'src/main.ts'`. */
7
+ entry?: string;
8
+ /** Output directory. Defaults to `'dist'`. */
9
+ outDir?: string;
10
+ /** Dev server port. Defaults to `3000`. */
11
+ port?: number;
12
+ /** Additional Rolldown plugins appended after the built-in forge plugin. */
13
+ plugins?: unknown[];
14
+ }
15
+ /**
16
+ * Type-safe helper for writing `forge.config.js`.
17
+ *
18
+ * @example
19
+ * ```js
20
+ * // forge.config.js
21
+ * import { defineConfig } from '@forge/cli';
22
+ *
23
+ * export default defineConfig({
24
+ * entry: 'src/main.ts',
25
+ * outDir: 'dist',
26
+ * port: 3000,
27
+ * });
28
+ * ```
29
+ */
30
+ export declare function defineConfig(config: ForgeConfig): ForgeConfig;
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAE7D"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ //#region src/index.ts
2
+ /**
3
+ * Type-safe helper for writing `vorra.config.js`.
4
+ *
5
+ * @example
6
+ * ```js
7
+ * // vorra.config.js
8
+ * import { defineConfig } from '@vorra/cli';
9
+ *
10
+ * export default defineConfig({
11
+ * entry: 'src/main.ts',
12
+ * outDir: 'dist',
13
+ * port: 3000,
14
+ * });
15
+ * ```
16
+ */
17
+ function defineConfig(config) {
18
+ return config;
19
+ }
20
+ //#endregion
21
+ export { defineConfig };
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// =============================================================================\r\n// @vorra/cli — Public API\r\n// =============================================================================\r\n\r\n/**\r\n * User-facing configuration for a Vorra project.\r\n * Returned by `defineConfig()` and loaded by `vorra dev` / `vorra build`.\r\n */\r\nexport interface VorraConfig {\r\n /** Application entry point. Defaults to `'src/main.ts'`. */\r\n entry?: string;\r\n /** Output directory. Defaults to `'dist'`. */\r\n outDir?: string;\r\n /** Dev server port. Defaults to `3000`. */\r\n port?: number;\r\n /**\r\n * Output directory used by `vorra dev`. Defaults to `'.vorra'`.\r\n * Kept separate from `outDir` so dev artifacts never pollute the production\r\n * build folder. Add `.vorra/` to your `.gitignore`.\r\n */\r\n devOutDir?: string;\r\n /** Additional Rolldown plugins appended after the built-in vorra plugin. */\r\n plugins?: unknown[];\r\n /**\r\n * Emit source map files alongside build output.\r\n * Defaults to `false` for `vorra build` (production).\r\n * `vorra dev` always enables source maps regardless of this setting.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js — enable source maps for a debug/staging build\r\n * export default defineConfig({ sourcemap: true });\r\n * ```\r\n */\r\n sourcemap?: boolean;\r\n /**\r\n * Absolute or relative path to a CSS entry file processed through PostCSS\r\n * (e.g. a Tailwind CSS file using `@import \"tailwindcss\"`). Import the\r\n * virtual module `\"vorra:css\"` from your entry point to inject it:\r\n *\r\n * ```ts\r\n * // src/main.ts\r\n * import 'vorra:css';\r\n * ```\r\n */\r\n css?: string;\r\n /**\r\n * PostCSS configuration. Required when `css` uses PostCSS-processed rules\r\n * such as Tailwind CSS.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js\r\n * import tailwindcss from '@tailwindcss/postcss';\r\n * export default defineConfig({\r\n * css: './src/tailwind.css',\r\n * postcss: { plugins: [tailwindcss()] },\r\n * });\r\n * ```\r\n */\r\n postcss?: { plugins: unknown[] };\r\n}\r\n\r\n/**\r\n * Type-safe helper for writing `vorra.config.js`.\r\n *\r\n * @example\r\n * ```js\r\n * // vorra.config.js\r\n * import { defineConfig } from '@vorra/cli';\r\n *\r\n * export default defineConfig({\r\n * entry: 'src/main.ts',\r\n * outDir: 'dist',\r\n * port: 3000,\r\n * });\r\n * ```\r\n */\r\nexport function defineConfig(config: VorraConfig): VorraConfig {\r\n return config;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,SAAgB,aAAa,QAAkC;AAC7D,QAAO"}
@@ -0,0 +1,11 @@
1
+ import type { ForgeConfig } from '../index.js';
2
+ /**
3
+ * Loads forge.config.{js,mjs,cjs} from `cwd` and returns the config object.
4
+ * Returns an empty object if no config file is found.
5
+ *
6
+ * Note: `.ts` configs are not supported at CLI runtime without a TS loader.
7
+ * Compile `forge.config.ts` to `.js` first, or run with `tsx`:
8
+ * npx tsx node_modules/.bin/forge dev
9
+ */
10
+ export declare function loadConfig(cwd: string): Promise<ForgeConfig>;
11
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ/C;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwBlE"}
@@ -0,0 +1,43 @@
1
+ // =============================================================================
2
+ // @forge/cli — Config loader
3
+ // Loads forge.config.js / .mjs / .cjs from the project root.
4
+ // TypeScript configs require a TS loader (tsx, ts-node) to be active.
5
+ // =============================================================================
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ import * as url from 'node:url';
9
+ const CONFIG_CANDIDATES = [
10
+ 'forge.config.js',
11
+ 'forge.config.mjs',
12
+ 'forge.config.cjs',
13
+ ];
14
+ /**
15
+ * Loads forge.config.{js,mjs,cjs} from `cwd` and returns the config object.
16
+ * Returns an empty object if no config file is found.
17
+ *
18
+ * Note: `.ts` configs are not supported at CLI runtime without a TS loader.
19
+ * Compile `forge.config.ts` to `.js` first, or run with `tsx`:
20
+ * npx tsx node_modules/.bin/forge dev
21
+ */
22
+ export async function loadConfig(cwd) {
23
+ for (const candidate of CONFIG_CANDIDATES) {
24
+ const configPath = path.join(cwd, candidate);
25
+ if (fs.existsSync(configPath)) {
26
+ const fileUrl = url.pathToFileURL(configPath).href;
27
+ // Dynamic import — works for ESM and CJS configs alike.
28
+ const mod = (await import(fileUrl));
29
+ if (mod.default !== null && mod.default !== undefined && typeof mod.default === 'object') {
30
+ return mod.default;
31
+ }
32
+ return {};
33
+ }
34
+ }
35
+ // Warn if a TS config exists but cannot be loaded.
36
+ const tsConfigPath = path.join(cwd, 'forge.config.ts');
37
+ if (fs.existsSync(tsConfigPath)) {
38
+ console.warn('[Forge CLI] forge.config.ts found but cannot be loaded without a TS loader.\n' +
39
+ ' Tip: Compile it first (tsc forge.config.ts) or run via: npx tsx .../bin.js dev');
40
+ }
41
+ return {};
42
+ }
43
+ //# source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YAC7E,kFAAkF,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@vorra/cli",
3
+ "version": "0.3.0",
4
+ "description": "Vorra CLI — vorra new / vorra dev / vorra build",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ubergeoff/vorra.git",
9
+ "directory": "packages/cli"
10
+ },
11
+ "homepage": "https://github.com/ubergeoff/vorra/tree/main/packages/cli#readme",
12
+ "keywords": [
13
+ "vorra",
14
+ "cli",
15
+ "dev-server",
16
+ "build-tool",
17
+ "framework"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "CHANGELOG.md"
26
+ ],
27
+ "type": "module",
28
+ "bin": {
29
+ "vorra": "./dist/bin.js"
30
+ },
31
+ "main": "./dist/index.cjs",
32
+ "module": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "import": "./dist/index.js",
37
+ "require": "./dist/index.cjs",
38
+ "types": "./dist/index.d.ts"
39
+ }
40
+ },
41
+ "scripts": {
42
+ "build": "rolldown -c rolldown.config.mjs",
43
+ "clean": "rm -rf dist *.tsbuildinfo"
44
+ },
45
+ "dependencies": {
46
+ "@vorra/compiler": "*",
47
+ "rolldown": "*"
48
+ },
49
+ "devDependencies": {
50
+ "typescript": "*"
51
+ }
52
+ }