arcanajs 2.5.4 → 3.0.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.
- package/README.md +7 -22
- package/bin/arcanajs.js +1 -1
- package/dist/arcanajs.js +2 -0
- package/dist/arcanajs.js.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -0
- package/{framework → dist}/lib/client/index.d.ts +6 -26
- package/{framework → dist}/lib/global.d.ts +6 -10
- package/dist/lib/index.d.ts +38 -0
- package/{framework → dist}/lib/server/ArcanaJSServer.d.ts +4 -4
- package/dist/lib/server/DefaultTemplate.d.ts +1 -0
- package/{framework → dist}/lib/shared/components/Body.d.ts +2 -2
- package/{framework → dist}/lib/shared/components/Head.d.ts +2 -1
- package/{framework → dist}/lib/shared/components/Link.d.ts +2 -2
- package/{framework → dist}/lib/shared/components/NavLink.d.ts +2 -2
- package/dist/lib/shared/components/Page.d.ts +7 -0
- package/{framework → dist}/lib/shared/context/RouterContext.d.ts +1 -0
- package/dist/lib/shared/core/ArcanaJSApp.d.ts +20 -0
- package/{framework → dist}/lib/shared/hooks/useLocation.d.ts +2 -1
- package/dist/lib/shared/hooks/usePage.d.ts +2 -0
- package/dist/lib/shared/hooks/useParams.d.ts +2 -0
- package/dist/lib/shared/hooks/useQuery.d.ts +2 -0
- package/dist/lib/shared/hooks/useRouter.d.ts +2 -0
- package/package.json +16 -26
- package/framework/cli/index.js +0 -204
- package/framework/cli/templates.d.ts +0 -6
- package/framework/cli/templates.js +0 -60
- package/framework/cli/webpack.config.js +0 -310
- package/framework/lib/client/index.js +0 -97
- package/framework/lib/config/index.d.ts +0 -46
- package/framework/lib/config/index.js +0 -115
- package/framework/lib/index.d.ts +0 -19
- package/framework/lib/index.js +0 -59
- package/framework/lib/server/ArcanaJSMiddleware.js +0 -114
- package/framework/lib/server/ArcanaJSServer.js +0 -441
- package/framework/lib/server/ControllerBinder.js +0 -32
- package/framework/lib/server/CsrfMiddleware.js +0 -34
- package/framework/lib/server/DynamicRouter.js +0 -50
- package/framework/lib/server/ResponseHandlerMiddleware.js +0 -30
- package/framework/lib/server/Router.js +0 -203
- package/framework/lib/server/default-index.html +0 -12
- package/framework/lib/server.d.ts +0 -33
- package/framework/lib/server.js +0 -69
- package/framework/lib/shared/components/Body.js +0 -8
- package/framework/lib/shared/components/Head.js +0 -125
- package/framework/lib/shared/components/Link.js +0 -27
- package/framework/lib/shared/components/NavLink.js +0 -13
- package/framework/lib/shared/components/Page.d.ts +0 -6
- package/framework/lib/shared/components/Page.js +0 -10
- package/framework/lib/shared/context/HeadContext.js +0 -5
- package/framework/lib/shared/context/PageContext.js +0 -5
- package/framework/lib/shared/context/RouterContext.js +0 -10
- package/framework/lib/shared/core/ArcanaJSApp.d.ts +0 -14
- package/framework/lib/shared/core/ArcanaJSApp.js +0 -153
- package/framework/lib/shared/hooks/useHead.js +0 -7
- package/framework/lib/shared/hooks/useLocation.js +0 -13
- package/framework/lib/shared/hooks/usePage.d.ts +0 -1
- package/framework/lib/shared/hooks/usePage.js +0 -7
- package/framework/lib/shared/hooks/useParams.d.ts +0 -1
- package/framework/lib/shared/hooks/useParams.js +0 -13
- package/framework/lib/shared/hooks/useQuery.d.ts +0 -1
- package/framework/lib/shared/hooks/useQuery.js +0 -9
- package/framework/lib/shared/hooks/useRouter.d.ts +0 -1
- package/framework/lib/shared/hooks/useRouter.js +0 -13
- package/framework/lib/shared/utils/createSingletonContext.js +0 -21
- package/framework/lib/shared/views/ErrorPage.js +0 -12
- package/framework/lib/shared/views/NotFoundPage.js +0 -11
- package/framework/lib/types.d.ts +0 -174
- package/framework/lib/types.js +0 -8
- package/framework/templates/arcanajs.config.ts +0 -44
- package/framework/templates/package.json +0 -15
- package/framework/templates/postcss.config.js +0 -6
- package/framework/templates/public/arcanajs.png +0 -0
- package/framework/templates/public/arcanajs.svg +0 -12
- package/framework/templates/public/favicon.ico +0 -0
- package/framework/templates/src/arcanajs.d.ts +0 -8
- package/framework/templates/src/client/globals.css +0 -199
- package/framework/templates/src/client/index.tsx +0 -7
- package/framework/templates/src/db/mongo.ts +0 -10
- package/framework/templates/src/db/mongoose.ts +0 -12
- package/framework/templates/src/db/mysql.ts +0 -15
- package/framework/templates/src/db/postgres.ts +0 -8
- package/framework/templates/src/server/controllers/HomeController.ts +0 -7
- package/framework/templates/src/server/controllers/UsersController.ts +0 -37
- package/framework/templates/src/server/index.ts +0 -38
- package/framework/templates/src/server/routes/api.ts +0 -6
- package/framework/templates/src/server/routes/web.ts +0 -7
- package/framework/templates/src/views/ErrorPage.tsx +0 -136
- package/framework/templates/src/views/HomePage.tsx +0 -344
- package/framework/templates/src/views/NotFoundPage.tsx +0 -108
- package/framework/templates/tsconfig.json +0 -27
- /package/{framework → dist}/cli/index.d.ts +0 -0
- /package/{framework → dist}/cli/webpack.config.d.ts +0 -0
- /package/{framework → dist}/lib/server/ArcanaJSMiddleware.d.ts +0 -0
- /package/{framework → dist}/lib/server/ControllerBinder.d.ts +0 -0
- /package/{framework → dist}/lib/server/CsrfMiddleware.d.ts +0 -0
- /package/{framework → dist}/lib/server/DynamicRouter.d.ts +0 -0
- /package/{framework → dist}/lib/server/ResponseHandlerMiddleware.d.ts +0 -0
- /package/{framework → dist}/lib/server/Router.d.ts +0 -0
- /package/{framework → dist}/lib/shared/context/HeadContext.d.ts +0 -0
- /package/{framework → dist}/lib/shared/context/PageContext.d.ts +0 -0
- /package/{framework → dist}/lib/shared/hooks/useHead.d.ts +0 -0
- /package/{framework → dist}/lib/shared/utils/createSingletonContext.d.ts +0 -0
- /package/{framework → dist}/lib/shared/views/ErrorPage.d.ts +0 -0
- /package/{framework → dist}/lib/shared/views/NotFoundPage.d.ts +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
import ArcanaJSServer, { ArcanaJSConfig } from "./server/ArcanaJSServer";
|
|
3
|
+
export { default as Body } from "./shared/components/Body";
|
|
4
|
+
export { default as Head } from "./shared/components/Head";
|
|
5
|
+
export { default as Link } from "./shared/components/Link";
|
|
6
|
+
export { default as NavLink } from "./shared/components/NavLink";
|
|
7
|
+
export { default as Page } from "./shared/components/Page";
|
|
8
|
+
export { default as hydrateArcanaJS } from "./client/index";
|
|
9
|
+
export { default as useLocation } from "./shared/hooks/useLocation";
|
|
10
|
+
export { default as usePage } from "./shared/hooks/usePage";
|
|
11
|
+
export { default as useParams } from "./shared/hooks/useParams";
|
|
12
|
+
export { default as useQuery } from "./shared/hooks/useQuery";
|
|
13
|
+
export { default as useRouter } from "./shared/hooks/useRouter";
|
|
14
|
+
export { default as ArcanaJSServer } from "./server/ArcanaJSServer";
|
|
15
|
+
export { Express, NextFunction, Request, Response } from "express";
|
|
16
|
+
export { default as Route } from "./server/Router";
|
|
17
|
+
/**
|
|
18
|
+
* Create an ArcanaJS server with the given Express app
|
|
19
|
+
*
|
|
20
|
+
* @param app - Express application instance
|
|
21
|
+
* @param config - Optional ArcanaJS configuration
|
|
22
|
+
* @returns ArcanaJSServer instance
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import express from 'express';
|
|
27
|
+
* import { createArcanaServer } from 'arcanajs/server';
|
|
28
|
+
*
|
|
29
|
+
* const app = express();
|
|
30
|
+
* const server = createArcanaServer(app, {
|
|
31
|
+
* port: 3000,
|
|
32
|
+
* viewsDir: 'src/views',
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* server.start();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createArcanaServer(app: Express, config?: Partial<ArcanaJSConfig>): ArcanaJSServer;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Express, RequestHandler } from "express";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Router as ArcanaRouter } from "./Router";
|
|
4
3
|
export interface ArcanaJSConfig<TDb = any> {
|
|
5
4
|
port?: number | string;
|
|
6
5
|
views?: Record<string, React.FC<any>>;
|
|
7
6
|
viewsDir?: string;
|
|
8
7
|
viewsContext?: any;
|
|
9
|
-
routes?: RequestHandler | RequestHandler[]
|
|
8
|
+
routes?: RequestHandler | RequestHandler[];
|
|
10
9
|
/** API routes can be provided separately from web routes */
|
|
11
|
-
apiRoutes?: RequestHandler | RequestHandler[]
|
|
10
|
+
apiRoutes?: RequestHandler | RequestHandler[];
|
|
12
11
|
/** Base path under which API routes will be mounted (default: '/api') */
|
|
13
12
|
apiBase?: string;
|
|
14
13
|
staticDir?: string;
|
|
@@ -31,7 +30,7 @@ declare global {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
33
|
+
declare class ArcanaJSServer<TDb = any> {
|
|
35
34
|
app: Express;
|
|
36
35
|
private config;
|
|
37
36
|
private serverInstance?;
|
|
@@ -53,3 +52,4 @@ export declare class ArcanaJSServer<TDb = any> {
|
|
|
53
52
|
*/
|
|
54
53
|
stop(): Promise<void>;
|
|
55
54
|
}
|
|
55
|
+
export default ArcanaJSServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultHtmlTemplate = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <!--HEAD_CONTENT-->\n </head>\n <body>\n <div id=\"root\"><!--APP_CONTENT--></div>\n <!--ARCANAJS_DATA_SCRIPT-->\n </body>\n</html>";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ArcanaJSAppProps<TData = any, TParams extends Record<string, string> = Record<string, string>> {
|
|
3
|
+
initialPage: string;
|
|
4
|
+
initialData: TData;
|
|
5
|
+
initialParams?: TParams;
|
|
6
|
+
initialUrl?: string;
|
|
7
|
+
csrfToken?: string;
|
|
8
|
+
views: Record<string, React.ComponentType<{
|
|
9
|
+
data: TData;
|
|
10
|
+
navigateTo: (url: string) => Promise<void>;
|
|
11
|
+
params: TParams;
|
|
12
|
+
}>>;
|
|
13
|
+
layout?: React.FC<{
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}>;
|
|
16
|
+
onNavigate?: (url: string) => void;
|
|
17
|
+
/** Maximum number of entries to keep in the navigation cache */
|
|
18
|
+
cacheLimit?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const ArcanaJSApp: <TData = any, TParams extends Record<string, string> = Record<string, string>>(props: ArcanaJSAppProps<TData, TParams>) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -5,42 +5,31 @@
|
|
|
5
5
|
"email": "mohammed.bencheikh.dev@gmail.com",
|
|
6
6
|
"url": "https://mohammedbencheikh.com/"
|
|
7
7
|
},
|
|
8
|
-
"version": "
|
|
8
|
+
"version": "3.0.0",
|
|
9
9
|
"description": "ArcanaJS Framework",
|
|
10
|
-
"main": "
|
|
11
|
-
"types": "
|
|
10
|
+
"main": "./dist/arcanajs.js",
|
|
11
|
+
"types": "./dist/lib/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json --emitDeclarationOnly && webpack --config webpack.config.ts && cp src/lib/global.d.ts dist/lib/"
|
|
14
|
+
},
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
|
-
"types": "./
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"default": "./framework/lib/server.js"
|
|
20
|
-
},
|
|
21
|
-
"./client": {
|
|
22
|
-
"types": "./framework/lib/client/index.d.ts",
|
|
23
|
-
"default": "./framework/lib/client/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./types": {
|
|
26
|
-
"types": "./framework/lib/types.d.ts",
|
|
27
|
-
"default": "./framework/lib/types.js"
|
|
28
|
-
},
|
|
29
|
-
"./config": {
|
|
30
|
-
"types": "./framework/lib/config/index.d.ts",
|
|
31
|
-
"default": "./framework/lib/config/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./package.json": "./package.json"
|
|
17
|
+
"types": "./dist/lib/index.d.ts",
|
|
18
|
+
"require": "./dist/arcanajs.js",
|
|
19
|
+
"import": "./dist/arcanajs.js",
|
|
20
|
+
"default": "./dist/arcanajs.js"
|
|
21
|
+
}
|
|
34
22
|
},
|
|
35
23
|
"bin": {
|
|
36
24
|
"arcanajs": "./bin/arcanajs.js"
|
|
37
25
|
},
|
|
38
26
|
"files": [
|
|
39
|
-
"
|
|
27
|
+
"dist",
|
|
40
28
|
"bin"
|
|
41
29
|
],
|
|
42
|
-
"
|
|
43
|
-
"
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^19.0.0",
|
|
32
|
+
"react-dom": "^19.0.0"
|
|
44
33
|
},
|
|
45
34
|
"dependencies": {
|
|
46
35
|
"@babel/core": "^7.23.0",
|
|
@@ -80,6 +69,7 @@
|
|
|
80
69
|
"ws": "^8.18.3"
|
|
81
70
|
},
|
|
82
71
|
"devDependencies": {
|
|
72
|
+
"@types/webpack-node-externals": "^3.0.4",
|
|
83
73
|
"react": "^19.2.0",
|
|
84
74
|
"react-dom": "^19.2.0"
|
|
85
75
|
},
|
package/framework/cli/index.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
10
|
-
const templates_1 = require("./templates");
|
|
11
|
-
const webpack_config_1 = require("./webpack.config");
|
|
12
|
-
const args = process.argv.slice(2);
|
|
13
|
-
const command = args[0];
|
|
14
|
-
if (!command) {
|
|
15
|
-
console.error("Please specify a command: init, dev, build, start");
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const runCompiler = (compiler) => {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
compiler.run((err, stats) => {
|
|
21
|
-
if (err) {
|
|
22
|
-
console.error(err);
|
|
23
|
-
return reject(err);
|
|
24
|
-
}
|
|
25
|
-
if (stats && stats.hasErrors()) {
|
|
26
|
-
console.error(stats.toString({ colors: true }));
|
|
27
|
-
return reject(new Error("Webpack build failed"));
|
|
28
|
-
}
|
|
29
|
-
console.log(stats?.toString({ colors: true }));
|
|
30
|
-
resolve();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
let serverProcess = null;
|
|
35
|
-
const ws_1 = require("ws");
|
|
36
|
-
const startDevServer = (hmrPort) => {
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
if (serverProcess) {
|
|
39
|
-
serverProcess.kill();
|
|
40
|
-
}
|
|
41
|
-
const serverPath = path_1.default.resolve(process.cwd(), "dist/server.js");
|
|
42
|
-
serverProcess = (0, child_process_1.spawn)("node", [serverPath], {
|
|
43
|
-
stdio: ["inherit", "pipe", "inherit"],
|
|
44
|
-
env: { ...process.env, ARCANA_HMR_PORT: hmrPort.toString() },
|
|
45
|
-
});
|
|
46
|
-
serverProcess.stdout?.on("data", (data) => {
|
|
47
|
-
process.stdout.write(data);
|
|
48
|
-
if (data.toString().includes("Server is running")) {
|
|
49
|
-
resolve();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
serverProcess.on("close", (code) => {
|
|
53
|
-
if (code !== 0 && code !== null) {
|
|
54
|
-
console.error(`Dev server exited with code ${code}`);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
const watchCompiler = (compiler, onBuildComplete) => {
|
|
60
|
-
compiler.watch({}, (err, stats) => {
|
|
61
|
-
if (err) {
|
|
62
|
-
console.error(err);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
console.log(stats?.toString({ colors: true }));
|
|
66
|
-
if (stats && !stats.hasErrors() && onBuildComplete) {
|
|
67
|
-
onBuildComplete();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
const build = async () => {
|
|
72
|
-
process.env.NODE_ENV = "production";
|
|
73
|
-
console.log("Building for production...");
|
|
74
|
-
const clientConfig = (0, webpack_config_1.createClientConfig)();
|
|
75
|
-
const serverConfig = (0, webpack_config_1.createServerConfig)();
|
|
76
|
-
try {
|
|
77
|
-
await runCompiler((0, webpack_1.default)(clientConfig));
|
|
78
|
-
await runCompiler((0, webpack_1.default)(serverConfig));
|
|
79
|
-
console.log("Build complete.");
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
console.error("Build failed:", error);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const dev = async () => {
|
|
87
|
-
process.env.NODE_ENV = "development";
|
|
88
|
-
console.log("Starting development server...");
|
|
89
|
-
// Start HMR WebSocket Server
|
|
90
|
-
const HMR_PORT = 3001;
|
|
91
|
-
const wss = new ws_1.WebSocketServer({ port: HMR_PORT });
|
|
92
|
-
console.log(`HMR Server running on port ${HMR_PORT}`);
|
|
93
|
-
const broadcastReload = () => {
|
|
94
|
-
wss.clients.forEach((client) => {
|
|
95
|
-
if (client.readyState === 1) {
|
|
96
|
-
client.send(JSON.stringify({ type: "reload" }));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
const clientConfig = (0, webpack_config_1.createClientConfig)();
|
|
101
|
-
const serverConfig = (0, webpack_config_1.createServerConfig)();
|
|
102
|
-
let isServerBuilding = false;
|
|
103
|
-
let pendingReload = false;
|
|
104
|
-
const serverCompiler = (0, webpack_1.default)(serverConfig);
|
|
105
|
-
serverCompiler.hooks.invalid.tap("ArcanaJS", () => {
|
|
106
|
-
isServerBuilding = true;
|
|
107
|
-
});
|
|
108
|
-
// Watch client
|
|
109
|
-
watchCompiler((0, webpack_1.default)(clientConfig), () => {
|
|
110
|
-
console.log("Client build complete.");
|
|
111
|
-
if (isServerBuilding) {
|
|
112
|
-
console.log("Server is building. Waiting to reload...");
|
|
113
|
-
pendingReload = true;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
console.log("Reloading browsers...");
|
|
117
|
-
broadcastReload();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
// Watch server and restart on build
|
|
121
|
-
watchCompiler(serverCompiler, async () => {
|
|
122
|
-
console.log("Server build complete. Restarting server...");
|
|
123
|
-
await startDevServer(HMR_PORT);
|
|
124
|
-
isServerBuilding = false;
|
|
125
|
-
if (pendingReload) {
|
|
126
|
-
console.log("Pending reload found. Reloading browsers...");
|
|
127
|
-
broadcastReload();
|
|
128
|
-
pendingReload = false;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
const init = () => {
|
|
133
|
-
console.log("Initializing ArcanaJS project with Tailwind CSS...");
|
|
134
|
-
const cwd = process.cwd();
|
|
135
|
-
const templatesDir = path_1.default.resolve(__dirname, "../templates");
|
|
136
|
-
// Create necessary directories
|
|
137
|
-
templates_1.requiredDirs.forEach((dir) => {
|
|
138
|
-
const fullPath = path_1.default.resolve(cwd, dir);
|
|
139
|
-
if (!fs_1.default.existsSync(fullPath)) {
|
|
140
|
-
fs_1.default.mkdirSync(fullPath, { recursive: true });
|
|
141
|
-
console.log(`Created directory: ${dir}`);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
// Copy configuration files
|
|
145
|
-
templates_1.configFiles.forEach(({ src, dest }) => {
|
|
146
|
-
const srcPath = path_1.default.resolve(templatesDir, src);
|
|
147
|
-
const destPath = path_1.default.resolve(cwd, dest);
|
|
148
|
-
if (!fs_1.default.existsSync(destPath)) {
|
|
149
|
-
if (fs_1.default.existsSync(srcPath)) {
|
|
150
|
-
fs_1.default.copyFileSync(srcPath, destPath);
|
|
151
|
-
console.log(`Created: ${dest}`);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
console.warn(`Template not found: ${src}`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
console.log(`Skipped: ${dest} (already exists)`);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
// Create default error pages
|
|
162
|
-
templates_1.errorPages.forEach((page) => {
|
|
163
|
-
const viewPath = path_1.default.resolve(cwd, `src/views/${page}`);
|
|
164
|
-
const templatePath = path_1.default.resolve(templatesDir, page);
|
|
165
|
-
if (!fs_1.default.existsSync(viewPath) && fs_1.default.existsSync(templatePath)) {
|
|
166
|
-
fs_1.default.copyFileSync(templatePath, viewPath);
|
|
167
|
-
console.log(`Created: src/views/${page}`);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
console.log("\n✅ ArcanaJS project initialized successfully!");
|
|
171
|
-
console.log("\nNext steps:");
|
|
172
|
-
console.log("1. Run 'npm install' to install dependencies");
|
|
173
|
-
console.log("2. Run 'npm run dev' to start development");
|
|
174
|
-
console.log("3. Visit http://localhost:3000 to see your app");
|
|
175
|
-
console.log("4. Edit src/views/HomePage.tsx to customize your homepage");
|
|
176
|
-
console.log("5. Customize your theme in src/client/globals.css");
|
|
177
|
-
console.log("6. Add your Tailwind classes and enjoy!");
|
|
178
|
-
};
|
|
179
|
-
const start = () => {
|
|
180
|
-
process.env.NODE_ENV = "production";
|
|
181
|
-
const serverPath = path_1.default.resolve(process.cwd(), "dist/server.js");
|
|
182
|
-
console.log(`Starting server at ${serverPath}...`);
|
|
183
|
-
const child = (0, child_process_1.spawn)("node", [serverPath], { stdio: "inherit" });
|
|
184
|
-
child.on("close", (code) => {
|
|
185
|
-
process.exit(code || 0);
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
switch (command) {
|
|
189
|
-
case "init":
|
|
190
|
-
init();
|
|
191
|
-
break;
|
|
192
|
-
case "build":
|
|
193
|
-
build();
|
|
194
|
-
break;
|
|
195
|
-
case "dev":
|
|
196
|
-
dev();
|
|
197
|
-
break;
|
|
198
|
-
case "start":
|
|
199
|
-
start();
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
console.error(`Unknown command: ${command}`);
|
|
203
|
-
process.exit(1);
|
|
204
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requiredDirs = exports.errorPages = exports.configFiles = void 0;
|
|
4
|
-
exports.configFiles = [
|
|
5
|
-
// project root files
|
|
6
|
-
{ src: "package.json", dest: "package.json" },
|
|
7
|
-
{ src: "tsconfig.json", dest: "tsconfig.json" },
|
|
8
|
-
{ src: "arcanajs.config.ts", dest: "arcanajs.config.ts" },
|
|
9
|
-
{ src: "postcss.config.js", dest: "postcss.config.js" },
|
|
10
|
-
// types
|
|
11
|
-
{ src: "src/arcanajs.d.ts", dest: "src/arcanajs.d.ts" },
|
|
12
|
-
// client
|
|
13
|
-
{ src: "src/client/globals.css", dest: "src/client/globals.css" },
|
|
14
|
-
{ src: "src/client/index.tsx", dest: "src/client/index.tsx" },
|
|
15
|
-
// server
|
|
16
|
-
{ src: "src/server/index.ts", dest: "src/server/index.ts" },
|
|
17
|
-
{ src: "src/server/routes/web.ts", dest: "src/server/routes/web.ts" },
|
|
18
|
-
{ src: "src/server/routes/api.ts", dest: "src/server/routes/api.ts" },
|
|
19
|
-
{
|
|
20
|
-
src: "src/server/controllers/HomeController.ts",
|
|
21
|
-
dest: "src/server/controllers/HomeController.ts",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
src: "src/server/controllers/UsersController.ts",
|
|
25
|
-
dest: "src/server/controllers/UsersController.ts",
|
|
26
|
-
},
|
|
27
|
-
// views
|
|
28
|
-
{ src: "src/views/HomePage.tsx", dest: "src/views/HomePage.tsx" },
|
|
29
|
-
{ src: "src/views/NotFoundPage.tsx", dest: "src/views/NotFoundPage.tsx" },
|
|
30
|
-
{ src: "src/views/ErrorPage.tsx", dest: "src/views/ErrorPage.tsx" },
|
|
31
|
-
//public
|
|
32
|
-
{
|
|
33
|
-
src: "public/arcanajs.png",
|
|
34
|
-
dest: "public/arcanajs.png",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
src: "public/arcanajs.svg",
|
|
38
|
-
dest: "public/arcanajs.svg",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
src: "public/favicon.ico",
|
|
42
|
-
dest: "public/favicon.ico",
|
|
43
|
-
},
|
|
44
|
-
// optional DB templates
|
|
45
|
-
{ src: "src/db/mongo.ts", dest: "src/db/mongo.ts" },
|
|
46
|
-
{ src: "src/db/mongoose.ts", dest: "src/db/mongoose.ts" },
|
|
47
|
-
{ src: "src/db/mysql.ts", dest: "src/db/mysql.ts" },
|
|
48
|
-
{ src: "src/db/postgres.ts", dest: "src/db/postgres.ts" },
|
|
49
|
-
];
|
|
50
|
-
exports.errorPages = ["NotFoundPage.tsx", "ErrorPage.tsx"];
|
|
51
|
-
exports.requiredDirs = [
|
|
52
|
-
"public",
|
|
53
|
-
"src",
|
|
54
|
-
"src/client",
|
|
55
|
-
"src/db",
|
|
56
|
-
"src/server",
|
|
57
|
-
"src/server/routes",
|
|
58
|
-
"src/server/controllers",
|
|
59
|
-
"src/views",
|
|
60
|
-
];
|