rasengan 1.0.0-beta.37 → 1.0.0-beta.39
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/lib/esm/cli/index.js +4 -2
- package/lib/esm/config/index.js +15 -0
- package/lib/types/config/index.d.ts +7 -0
- package/package.json +1 -1
- package/server.js +18 -5
package/lib/esm/cli/index.js
CHANGED
|
@@ -51,6 +51,7 @@ import { Command } from "commander";
|
|
|
51
51
|
import { execa } from "execa";
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
import path from "node:path";
|
|
54
|
+
import { resolvePath } from "../config/index.js";
|
|
54
55
|
var program = new Command();
|
|
55
56
|
program
|
|
56
57
|
.name(chalk.blue("rasengan"))
|
|
@@ -95,7 +96,7 @@ program
|
|
|
95
96
|
.command("prepare")
|
|
96
97
|
.description("Prepare the project")
|
|
97
98
|
.action(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
-
var appConfig, server, hostingStrategy;
|
|
99
|
+
var configPath, appConfig, server, hostingStrategy;
|
|
99
100
|
var _a, _b;
|
|
100
101
|
return __generator(this, function (_c) {
|
|
101
102
|
switch (_c.label) {
|
|
@@ -104,7 +105,8 @@ program
|
|
|
104
105
|
console.log("");
|
|
105
106
|
console.log(chalk.blue("Preparing your project for production..."));
|
|
106
107
|
console.log("");
|
|
107
|
-
|
|
108
|
+
configPath = resolvePath(path.join(process.cwd(), "rasengan.config.js"));
|
|
109
|
+
return [4 /*yield*/, import(configPath)];
|
|
108
110
|
case 1:
|
|
109
111
|
appConfig = _c.sent();
|
|
110
112
|
server = appConfig.server;
|
package/lib/esm/config/index.js
CHANGED
|
@@ -150,3 +150,18 @@ export var adaptPath = function (paths) {
|
|
|
150
150
|
// If the path is a string
|
|
151
151
|
return "".concat(process.cwd(), "/").concat(prefix).concat(paths);
|
|
152
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Adapts the provided file path to a valid URL format based on the operating system.
|
|
155
|
+
*
|
|
156
|
+
* @param path - The file path to be adapted.
|
|
157
|
+
* @returns The adapted file path in a valid URL format.
|
|
158
|
+
*/
|
|
159
|
+
export var resolvePath = function (path) {
|
|
160
|
+
// Check the OS
|
|
161
|
+
var isWindows = process.platform === "win32";
|
|
162
|
+
// Adapt the path
|
|
163
|
+
if (isWindows) {
|
|
164
|
+
return "file:///".concat(path);
|
|
165
|
+
}
|
|
166
|
+
return path;
|
|
167
|
+
};
|
|
@@ -64,3 +64,10 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
|
|
|
64
64
|
* @param {string | Array<string>} paths
|
|
65
65
|
*/
|
|
66
66
|
export declare const adaptPath: (paths: string | Array<string>) => string | string[];
|
|
67
|
+
/**
|
|
68
|
+
* Adapts the provided file path to a valid URL format based on the operating system.
|
|
69
|
+
*
|
|
70
|
+
* @param path - The file path to be adapted.
|
|
71
|
+
* @returns The adapted file path in a valid URL format.
|
|
72
|
+
*/
|
|
73
|
+
export declare const resolvePath: (path: string) => string;
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
fix404,
|
|
17
17
|
} from "./lib/esm/server/utils/index.js";
|
|
18
18
|
|
|
19
|
+
// Resolve path
|
|
20
|
+
import { resolvePath } from "./lib/esm/config/index.js";
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* This function is responsible for creating a server for the development environment.
|
|
21
24
|
* @param {boolean} isProduction - Whether the server is in production mode or not.
|
|
@@ -81,7 +84,9 @@ async function createServer({
|
|
|
81
84
|
join(appPath, `node_modules/rasengan/lib/esm/entries/entry-server.js`)
|
|
82
85
|
);
|
|
83
86
|
} else {
|
|
84
|
-
entry = await import(
|
|
87
|
+
entry = await import(
|
|
88
|
+
resolvePath(join(appPath, "dist/server/entry-server.js"))
|
|
89
|
+
);
|
|
85
90
|
|
|
86
91
|
// replace bootstrap script with compiled scripts
|
|
87
92
|
bootstrap =
|
|
@@ -240,12 +245,20 @@ async function createServer({
|
|
|
240
245
|
|
|
241
246
|
// Launch server
|
|
242
247
|
(async function launchServer() {
|
|
243
|
-
// Get config
|
|
244
|
-
const config = (await import(join(process.cwd(), "rasengan.config.js")))
|
|
245
|
-
.default;
|
|
246
|
-
|
|
247
248
|
// Constants
|
|
248
249
|
const isProduction = process.env.NODE_ENV === "production";
|
|
250
|
+
|
|
251
|
+
// Format config path
|
|
252
|
+
const configPath = resolvePath(
|
|
253
|
+
join(
|
|
254
|
+
isProduction ? process.cwd() + "./../../" : process.cwd(),
|
|
255
|
+
"rasengan.config.js"
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Get config
|
|
260
|
+
const config = (await import(configPath)).default;
|
|
261
|
+
|
|
249
262
|
const port = !isProduction
|
|
250
263
|
? (process.env.PORT && Number(process.env.PORT)) ||
|
|
251
264
|
config.server?.development?.port ||
|