@asterflow/fs 1.0.1 → 1.0.3

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
@@ -76,7 +76,7 @@ In your main application file, import and register the `fsRouting` plugin.
76
76
  **`src/index.ts`**
77
77
 
78
78
  ```typescript
79
- import { AsterFlow } from '@asterflow/core';
79
+ import { AsterFlow } from 'asterflow';
80
80
  import { fsRouting } from '@asterflow/fs';
81
81
  import { join } from 'path';
82
82
 
@@ -112,7 +112,7 @@ The plugin transforms file paths into URL routes based on the following rules:
112
112
 
113
113
  ## 🔗 Related Packages
114
114
 
115
- - [@asterflow/core](https://www.npmjs.com/package/@asterflow/core) - The core of the AsterFlow framework.
115
+ - [asterflow](https://www.npmjs.com/package/asterflow) - The core of the AsterFlow framework.
116
116
  - [@asterflow/plugin](https://www.npmjs.com/package/@asterflow/plugin) - The main plugin system.
117
117
  - [@asterflow/router](https://www.npmjs.com/package/@asterflow/router) - The type-safe routing system used by this plugin.
118
118
 
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var p = Object.defineProperty;
3
+ var h = Object.getOwnPropertyDescriptor;
4
+ var w = Object.getOwnPropertyNames;
5
+ var R = Object.prototype.hasOwnProperty;
6
+ var v = (t, o) => {
7
+ for (var r in o)
8
+ p(t, r, { get: o[r], enumerable: !0 });
9
+ }, F = (t, o, r, e) => {
10
+ if (o && typeof o == "object" || typeof o == "function")
11
+ for (let s of w(o))
12
+ !R.call(t, s) && s !== r && p(t, s, { get: () => o[s], enumerable: !(e = h(o, s)) || e.enumerable });
13
+ return t;
14
+ };
15
+ var j = (t) => F(p({}, "__esModule", { value: !0 }), t);
16
+
17
+ // plugins/fs/src/index.ts
18
+ var P = {};
19
+ v(P, {
20
+ default: () => T,
21
+ fsRoutingPlugin: () => y,
22
+ getFilesRecursively: () => n,
23
+ transformPathToUrl: () => u
24
+ });
25
+ module.exports = j(P);
26
+ var x = require("@asterflow/plugin"), a = require("@asterflow/router");
27
+
28
+ // plugins/fs/package.json
29
+ var f = "1.0.3";
30
+
31
+ // plugins/fs/src/utils/format.ts
32
+ var d = require("path");
33
+ function u(t, o) {
34
+ let e = (0, d.relative)(o, t).replace(/\.(ts|js)$/, "");
35
+ return e.endsWith("/index") ? e = e.slice(0, -6) : e === "index" && (e = ""), e = e.replace(/\$/g, ":"), `/${e}`;
36
+ }
37
+
38
+ // plugins/fs/src/utils/glob.ts
39
+ var g = require("fs/promises"), m = require("path");
40
+ async function n(t) {
41
+ let o = await (0, g.readdir)(t, { withFileTypes: !0 });
42
+ return (await Promise.all(
43
+ o.map(async (e) => {
44
+ let s = (0, m.join)(t, e.name);
45
+ return e.isDirectory() ? n(s) : s;
46
+ })
47
+ )).flat();
48
+ }
49
+
50
+ // plugins/fs/src/utils/log.ts
51
+ var l = {
52
+ reset: "\x1B[0m",
53
+ red: "\x1B[31m",
54
+ yellow: "\x1B[33m",
55
+ cyan: "\x1B[36m"
56
+ };
57
+ function c(t, o) {
58
+ console.warn(`${l.yellow}%s %s${l.reset}`, "[AsterFlow]", t), console.group();
59
+ for (let [r, e] of Object.entries(o))
60
+ console.log(`${l.cyan}%s:${l.reset} %s`, r, e);
61
+ console.groupEnd(), console.log();
62
+ }
63
+
64
+ // plugins/fs/src/index.ts
65
+ var y = x.Plugin.create({ name: "fs-routing" }).decorate("creator", "Ashu11-A").decorate("version", f).config({ path: "" }).derive("files", async (t) => await n(t.path)).extends((t, o) => ({
66
+ async registerRoutes(r) {
67
+ if (r.files.length !== 0)
68
+ for (let e of r.files) {
69
+ let i = (await import(e)).default;
70
+ if (!i) {
71
+ c("File Skipped: No Default Export", {
72
+ File: e,
73
+ Reason: "The file does not contain any default exported routes (export default).",
74
+ Solution: 'Ensure the file has a "export default new Router()" or similar.'
75
+ });
76
+ continue;
77
+ }
78
+ if (!(i instanceof a.Method || i instanceof a.Router)) {
79
+ c("File Skipped: Invalid Export Type", {
80
+ File: e,
81
+ "Exported Type": typeof i,
82
+ Reason: "The file does not export a known class instance (e.g., Router, Method)."
83
+ });
84
+ continue;
85
+ }
86
+ i.path = u(e, r.path), t.controller(i);
87
+ }
88
+ }
89
+ })).on("beforeInitialize", async (t, o) => await t.registerRoutes(o)), T = y;
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ fsRoutingPlugin,
93
+ getFilesRecursively,
94
+ transformPathToUrl
95
+ });
@@ -0,0 +1,73 @@
1
+ // plugins/fs/src/index.ts
2
+ import { Plugin as x } from "@asterflow/plugin";
3
+ import { Method as y, Router as h } from "@asterflow/router";
4
+
5
+ // plugins/fs/package.json
6
+ var p = "1.0.3";
7
+
8
+ // plugins/fs/src/utils/format.ts
9
+ import { relative as d } from "path";
10
+ function u(t, o) {
11
+ let e = d(o, t).replace(/\.(ts|js)$/, "");
12
+ return e.endsWith("/index") ? e = e.slice(0, -6) : e === "index" && (e = ""), e = e.replace(/\$/g, ":"), `/${e}`;
13
+ }
14
+
15
+ // plugins/fs/src/utils/glob.ts
16
+ import { readdir as g } from "fs/promises";
17
+ import { join as m } from "path";
18
+ async function l(t) {
19
+ let o = await g(t, { withFileTypes: !0 });
20
+ return (await Promise.all(
21
+ o.map(async (e) => {
22
+ let n = m(t, e.name);
23
+ return e.isDirectory() ? l(n) : n;
24
+ })
25
+ )).flat();
26
+ }
27
+
28
+ // plugins/fs/src/utils/log.ts
29
+ var i = {
30
+ reset: "\x1B[0m",
31
+ red: "\x1B[31m",
32
+ yellow: "\x1B[33m",
33
+ cyan: "\x1B[36m"
34
+ };
35
+ function a(t, o) {
36
+ console.warn(`${i.yellow}%s %s${i.reset}`, "[AsterFlow]", t), console.group();
37
+ for (let [r, e] of Object.entries(o))
38
+ console.log(`${i.cyan}%s:${i.reset} %s`, r, e);
39
+ console.groupEnd(), console.log();
40
+ }
41
+
42
+ // plugins/fs/src/index.ts
43
+ var w = x.create({ name: "fs-routing" }).decorate("creator", "Ashu11-A").decorate("version", p).config({ path: "" }).derive("files", async (t) => await l(t.path)).extends((t, o) => ({
44
+ async registerRoutes(r) {
45
+ if (r.files.length !== 0)
46
+ for (let e of r.files) {
47
+ let s = (await import(e)).default;
48
+ if (!s) {
49
+ a("File Skipped: No Default Export", {
50
+ File: e,
51
+ Reason: "The file does not contain any default exported routes (export default).",
52
+ Solution: 'Ensure the file has a "export default new Router()" or similar.'
53
+ });
54
+ continue;
55
+ }
56
+ if (!(s instanceof y || s instanceof h)) {
57
+ a("File Skipped: Invalid Export Type", {
58
+ File: e,
59
+ "Exported Type": typeof s,
60
+ Reason: "The file does not export a known class instance (e.g., Router, Method)."
61
+ });
62
+ continue;
63
+ }
64
+ s.path = u(e, r.path), t.controller(s);
65
+ }
66
+ }
67
+ })).on("beforeInitialize", async (t, o) => await t.registerRoutes(o)), M = w;
68
+ export {
69
+ M as default,
70
+ w as fsRoutingPlugin,
71
+ l as getFilesRecursively,
72
+ u as transformPathToUrl
73
+ };
@@ -2,32 +2,26 @@
2
2
 
3
3
  import { Plugin } from '@asterflow/plugin';
4
4
 
5
- export declare const fsRoutingPlugin: Plugin<"fs-routing", import("@asterflow/core").IAsterflow<import("@asterflow/core").AnyReminist, {}, [
6
- ], import("@asterflow/adapter").Adapter<import("@asterflow/adapter").Runtime.Node>, {}>, {
5
+ export declare const fsRoutingPlugin: Plugin<"fs-routing", import("asterflow").AnyAsterflow, {
7
6
  path: string;
7
+ defaultConfig: {
8
+ path: string;
9
+ };
8
10
  }, {
9
11
  creator: string;
10
- } & {
11
12
  version: string;
12
- } & {
13
+ }, {
13
14
  files: string[];
14
- }, Omit<{}, Event> & {
15
- beforeInitialize: [
16
- (instance: import("@asterflow/core").IAsterflow<import("@asterflow/core").AnyReminist, {}, [
17
- ], import("@asterflow/adapter").Adapter<import("@asterflow/adapter").Runtime.Node>, {}> & {
18
- registerRoutes(context: FSRoutingContext): Promise<void>;
19
- }, context: {
20
- creator: string;
21
- } & {
22
- version: string;
23
- } & {
24
- files: string[];
25
- } & {
26
- path: string;
27
- }) => Promise<void>
28
- ];
29
15
  }, {
30
- registerRoutes(context: FSRoutingContext): Promise<void>;
16
+ registerRoutes: (context: {
17
+ creator: string;
18
+ version: string;
19
+ path: string;
20
+ defaultConfig: {
21
+ path: string;
22
+ };
23
+ files: string[];
24
+ }) => Promise<void>;
31
25
  }>;
32
26
  /**
33
27
  * Recursively lists files from a starting directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterflow/fs",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "dist/cjs/index.cjs",
5
5
  "module": "dist/mjs/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -26,15 +26,9 @@
26
26
  "engines": {
27
27
  "node": ">=20"
28
28
  },
29
- "devDependencies": {
30
- "@asterflow/core": "^1.0.7",
31
- "@types/bun": "latest"
32
- },
33
- "peerDependencies": {
34
- "typescript": "^5.8.3"
35
- },
36
29
  "dependencies": {
37
- "@asterflow/router": "^1.0.7",
38
- "@asterflow/url-parser": "^2.0.1"
30
+ "@asterflow/plugin": "^1.0.5",
31
+ "@asterflow/router": "^1.0.9",
32
+ "@asterflow/url-parser": "^2.0.2"
39
33
  }
40
- }
34
+ }
package/cjs/index.cjs DELETED
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var a = Object.defineProperty;
3
- var h = Object.getOwnPropertyDescriptor;
4
- var x = Object.getOwnPropertyNames;
5
- var w = Object.prototype.hasOwnProperty;
6
- var A = (t, e) => {
7
- for (var i in e)
8
- a(t, i, { get: e[i], enumerable: !0 });
9
- }, v = (t, e, i, r) => {
10
- if (e && typeof e == "object" || typeof e == "function")
11
- for (let s of x(e))
12
- !w.call(t, s) && s !== i && a(t, s, { get: () => e[s], enumerable: !(r = h(e, s)) || r.enumerable });
13
- return t;
14
- };
15
- var j = (t) => v(a({}, "__esModule", { value: !0 }), t);
16
-
17
- // plugins/fs/src/index.ts
18
- var b = {};
19
- A(b, {
20
- default: () => P,
21
- fsRoutingPlugin: () => y,
22
- getFilesRecursively: () => o,
23
- transformPathToUrl: () => p
24
- });
25
- module.exports = j(b);
26
- var d = require("@asterflow/plugin"), n = require("@asterflow/router"), g = require("@asterflow/url-parser");
27
-
28
- // plugins/fs/package.json
29
- var u = "1.0.1";
30
-
31
- // plugins/fs/src/utils/format.ts
32
- var c = require("path");
33
- function p(t, e) {
34
- let r = (0, c.relative)(e, t).replace(/\.(ts|js)$/, "");
35
- return r.endsWith("/index") ? r = r.slice(0, -6) : r === "index" && (r = ""), r = r.replace(/\$/g, ":"), `/${r}`;
36
- }
37
-
38
- // plugins/fs/src/utils/glob.ts
39
- var f = require("fs/promises"), m = require("path");
40
- async function o(t) {
41
- let e = await (0, f.readdir)(t, { withFileTypes: !0 });
42
- return (await Promise.all(
43
- e.map(async (r) => {
44
- let s = (0, m.join)(t, r.name);
45
- return r.isDirectory() ? o(s) : s;
46
- })
47
- )).flat();
48
- }
49
-
50
- // plugins/fs/src/index.ts
51
- var y = d.Plugin.instance().create({ name: "fs-routing" }).decorate("creator", "Ashu11-A").decorate("version", u).config({ path: "" }).derive("files", async (t) => await o(t.path)).extends((t) => ({
52
- async registerRoutes(e) {
53
- if (e.files.length !== 0)
54
- for (let i of e.files) {
55
- let s = (await import(i)).default;
56
- if (!s || !(s instanceof n.Method || s instanceof n.Router)) continue;
57
- let l = p(i, e.path);
58
- s.path = l, s.url = new g.Analyze(l), t.controller(s);
59
- }
60
- }
61
- })).on("beforeInitialize", async (t, e) => await t.registerRoutes(e)), P = y;
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- fsRoutingPlugin,
65
- getFilesRecursively,
66
- transformPathToUrl
67
- });
package/mjs/index.js DELETED
@@ -1,46 +0,0 @@
1
- // plugins/fs/src/index.ts
2
- import { Plugin as d } from "@asterflow/plugin";
3
- import { Method as g, Router as y } from "@asterflow/router";
4
- import { Analyze as h } from "@asterflow/url-parser";
5
-
6
- // plugins/fs/package.json
7
- var a = "1.0.1";
8
-
9
- // plugins/fs/src/utils/format.ts
10
- import { relative as c } from "path";
11
- function p(t, r) {
12
- let e = c(r, t).replace(/\.(ts|js)$/, "");
13
- return e.endsWith("/index") ? e = e.slice(0, -6) : e === "index" && (e = ""), e = e.replace(/\$/g, ":"), `/${e}`;
14
- }
15
-
16
- // plugins/fs/src/utils/glob.ts
17
- import { readdir as f } from "fs/promises";
18
- import { join as m } from "path";
19
- async function o(t) {
20
- let r = await f(t, { withFileTypes: !0 });
21
- return (await Promise.all(
22
- r.map(async (e) => {
23
- let s = m(t, e.name);
24
- return e.isDirectory() ? o(s) : s;
25
- })
26
- )).flat();
27
- }
28
-
29
- // plugins/fs/src/index.ts
30
- var x = d.instance().create({ name: "fs-routing" }).decorate("creator", "Ashu11-A").decorate("version", a).config({ path: "" }).derive("files", async (t) => await o(t.path)).extends((t) => ({
31
- async registerRoutes(r) {
32
- if (r.files.length !== 0)
33
- for (let i of r.files) {
34
- let s = (await import(i)).default;
35
- if (!s || !(s instanceof g || s instanceof y)) continue;
36
- let n = p(i, r.path);
37
- s.path = n, s.url = new h(n), t.controller(s);
38
- }
39
- }
40
- })).on("beforeInitialize", async (t, r) => await t.registerRoutes(r)), D = x;
41
- export {
42
- D as default,
43
- x as fsRoutingPlugin,
44
- o as getFilesRecursively,
45
- p as transformPathToUrl
46
- };
File without changes
File without changes