oc-server 1.1.0 → 1.1.2
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/dist/cli.js +10 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ const cssModulesPlugin_1 = __importDefault(require("oc-vite-compiler/dist/lib/cs
|
|
|
16
16
|
const get_mocked_plugins_js_1 = __importDefault(require("oc/dist/cli/domain/get-mocked-plugins.js"));
|
|
17
17
|
const node_util_1 = require("node:util");
|
|
18
18
|
const promisify = (fn) => (...args) => new Promise((resolve, reject) => fn(...args, (err, data) => (err ? reject(err) : resolve(data))));
|
|
19
|
-
const plugins = (0, get_mocked_plugins_js_1.default)({ err: () => { }, log: () => { }, ok: () => { }, warn: () => { } }, process.cwd());
|
|
19
|
+
const plugins = (0, get_mocked_plugins_js_1.default)({ err: () => { }, log: () => { }, ok: () => { }, warn: () => { } }, node_path_1.default.join(process.cwd(), '..'));
|
|
20
20
|
const pkg = require(node_path_1.default.join(process.cwd(), 'package.json'));
|
|
21
21
|
const serverEntry = pkg.oc?.files?.data;
|
|
22
22
|
let appEntry = pkg.oc?.files?.template?.src || '';
|
|
@@ -65,7 +65,7 @@ function getContext(req, params, action) {
|
|
|
65
65
|
easeUrl: '/',
|
|
66
66
|
env: { name: 'local' },
|
|
67
67
|
params,
|
|
68
|
-
plugins,
|
|
68
|
+
plugins: Object.fromEntries(plugins.map((plugin) => [plugin.name, plugin.register.execute])),
|
|
69
69
|
renderComponent: () => {
|
|
70
70
|
throw new Error('renderComponent is not implemented in the server context');
|
|
71
71
|
},
|
|
@@ -119,7 +119,11 @@ async function getHtmlTemplate(appBlock, filePath = 'index.html') {
|
|
|
119
119
|
if (!template.includes('</body>')) {
|
|
120
120
|
throw new Error('If you use a custom html entry it has to have a closing body tag');
|
|
121
121
|
}
|
|
122
|
-
template = template.replace('</body>', `${appBlock
|
|
122
|
+
template = template.replace('</body>', `${appBlock({
|
|
123
|
+
name: pkg.name,
|
|
124
|
+
version: pkg.version,
|
|
125
|
+
entry: appEntry,
|
|
126
|
+
})}</body>`);
|
|
123
127
|
}
|
|
124
128
|
catch (error) {
|
|
125
129
|
template = getBaseTemplate(appBlock);
|
|
@@ -130,6 +134,9 @@ async function createServer({ template, port, }) {
|
|
|
130
134
|
const { dev: clientJs } = oc_client_browser_1.default.compileSync();
|
|
131
135
|
const app = (0, express_1.default)();
|
|
132
136
|
const dataProvider = getDataProvider();
|
|
137
|
+
for (const plugin of plugins) {
|
|
138
|
+
plugin.register.register(null, null, () => { });
|
|
139
|
+
}
|
|
133
140
|
app.use(express_1.default.json());
|
|
134
141
|
const vite = await (0, vite_1.createServer)({
|
|
135
142
|
server: { middlewareMode: true },
|