rsf-zero 0.1.7 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAIvB,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAGlD,eAAO,MAAM,KAAK,GAAU,SAAS,cAAc,kBAyBlD,CAAA"}
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAIvB,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAIlD,eAAO,MAAM,KAAK,GAAU,SAAS,cAAc,kBAyBlD,CAAA"}
package/dist/cli/start.js CHANGED
@@ -11,6 +11,7 @@ import express from "express";
11
11
  import morgan from "morgan";
12
12
  import "dotenv/config";
13
13
  import { createActionRoute } from "./start/createActionRoute.js";
14
+ import { debug } from "../debug.js";
14
15
  export const start = async (options) => {
15
16
  const app = express();
16
17
  const port = 3000;
@@ -18,7 +19,7 @@ export const start = async (options) => {
18
19
  app.use(express.json());
19
20
  // Client
20
21
  const staticPath = path.join(process.cwd(), 'dist/client/');
21
- console.log('Serving static files from:', staticPath);
22
+ debug('Serving static files from: ' + staticPath);
22
23
  app.use(express.static('dist/client/', options.startStatic ?? {}));
23
24
  // Server
24
25
  // - create action route
@@ -0,0 +1,2 @@
1
+ export declare const banner: () => void;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,YAsBlB,CAAA"}
@@ -0,0 +1,21 @@
1
+ import fs from "fs";
2
+ export const banner = () => {
3
+ const pkgUrl = new URL('../../package.json', import.meta.url);
4
+ const pkg = JSON.parse(fs.readFileSync(pkgUrl, 'utf-8'));
5
+ const version = pkg.version ?? 'dev';
6
+ console.log(`
7
+ ___ ___ ___ ___ ___ ___ ___
8
+ / /\\ / /\\ / /\\ / /\\ / /\\ / /\\ / /\\
9
+ / /::\\ / /:/_ / /:/_ / /::| / /:/_ / /::\\ / /::\\
10
+ / /:/\\:\\ / /:/ /\\ / /:/ /\\ / /:/:| / /:/ /\\ / /:/\\:\\ / /:/\\:\\
11
+ / /:/~/:/ / /:/ /::\\ / /:/ /:/ / /:/|:|__ / /:/ /:/_ / /:/~/:/ / /:/ \\:\\
12
+ /__/:/ /:/___ /__/:/ /:/\\:\\ /__/:/ /:/ /__/:/ |:| /\\ /__/:/ /:/ /\\ /__/:/ /:/___ /__/:/ \\__\\:\\
13
+ \\ \\:\\/:::::/ \\ \\:\\/:/~/:/ \\ \\:\\/:/ \\__\\/ |:|/:/ \\ \\:\\/:/ /:/ \\ \\:\\/:::::/ \\ \\:\\ / /:/
14
+ \\ \\::/~~~~ \\ \\::/ /:/ \\ \\::/ | |:/:/ \\ \\::/ /:/ \\ \\::/~~~~ \\ \\:\\ /:/
15
+ \\ \\:\\ \\__\\/ /:/ \\ \\:\\ | |::/ \\ \\:\\/:/ \\ \\:\\ \\ \\:\\/:/
16
+ \\ \\:\\ /__/:/ \\ \\:\\ | |:/ \\ \\::/ \\ \\:\\ \\ \\::/
17
+ \\__\\/ \\__\\/ \\__\\/ |__|/ \\__\\/ \\__\\/ \\__\\/
18
+
19
+ RSF Zero v${version}
20
+ `);
21
+ };
package/dist/cli.js CHANGED
@@ -3,8 +3,10 @@ import { dev } from "./cli/dev.js";
3
3
  import { build } from "./cli/build.js";
4
4
  import { start } from "./cli/start.js";
5
5
  import { loadOptions } from "./options.js";
6
+ import { banner } from "./cli/utils.js";
6
7
  const args = process.argv.slice(2);
7
8
  const command = args[0];
9
+ banner();
8
10
  const options = await loadOptions();
9
11
  if (command === 'dev') {
10
12
  await dev();
package/dist/options.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import { RsfZeroOptions } from "./export-types.ts";
2
- /**
3
- * Locate rsf0-config.js in the current project root (process.cwd()).
4
- */
5
- export declare function findOptionsFile(cwd?: string): string | null;
6
2
  /**
7
3
  * Load RSF options from rsf0-config.js at project root.
8
4
  * Returns an empty object if no file is found or on safe failure.
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMnD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAG1E;AAUD;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,CAiB3D"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAenD;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,CAoB3D"}
package/dist/options.js CHANGED
@@ -13,13 +13,6 @@ import { debug } from "./debug.js";
13
13
  const defaultOptions = {
14
14
  startStatic: {},
15
15
  };
16
- /**
17
- * Locate rsf0-config.js in the current project root (process.cwd()).
18
- */
19
- export function findOptionsFile(cwd = process.cwd()) {
20
- const jsPath = path.join(cwd, 'rsf0-config.js');
21
- return fs.existsSync(jsPath) ? jsPath : null;
22
- }
23
16
  /**
24
17
  * Dynamically import a JS module by absolute file path.
25
18
  */
@@ -32,21 +25,22 @@ async function importJsModule(absPath) {
32
25
  * Returns an empty object if no file is found or on safe failure.
33
26
  */
34
27
  export async function loadOptions() {
35
- const configPath = findOptionsFile();
36
- if (!configPath)
37
- return {};
28
+ const configPath = path.join(process.cwd(), 'rsf0-config.js');
29
+ if (!fs.existsSync(configPath)) {
30
+ debug('No config file found at: ' + configPath);
31
+ return defaultOptions;
32
+ }
38
33
  try {
39
34
  const mod = await importJsModule(configPath);
40
- const options = (mod && (mod.default ?? mod.options ?? mod.rsf ?? mod.config ?? mod));
35
+ const options = (mod && mod.default);
41
36
  if (options && typeof options === 'object') {
42
- debug('Options loaded: ' + configPath);
37
+ debug('Config loaded: ' + configPath);
43
38
  return options;
44
39
  }
45
- return {};
40
+ throw new Error('Invalid');
46
41
  }
47
42
  catch (err) {
48
- // Fail soft: log a friendly message and continue with defaults
49
- debug('No options file found at: ' + configPath);
50
- return defaultOptions;
43
+ console.log('Rsf Zero Error: Invalid config file at: ' + configPath);
44
+ throw err;
51
45
  }
52
46
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A minimal micro-framework with React Server Functions support",
4
4
  "author": "Igor Nadj",
5
5
  "type": "module",
6
- "version": "0.1.7",
6
+ "version": "0.2.0",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/IgorNadj/rsf-zero.git",