clovie 0.2.4 → 0.2.5
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/createClovie.js +0 -4
- package/lib/services/Run.js +12 -1
- package/package.json +1 -1
package/lib/createClovie.js
CHANGED
|
@@ -7,7 +7,6 @@ import { transformConfig } from './utils/transformConfig.js';
|
|
|
7
7
|
import { Server } from '@jucie.io/engine-server';
|
|
8
8
|
import { EsBuild } from '@jucie.io/engine-esbuild';
|
|
9
9
|
import { LiveReload } from './services/LiveReload.js';
|
|
10
|
-
import { resolveRoutes } from './utils/viewsToRoutes.js';
|
|
11
10
|
|
|
12
11
|
export const createClovie = async (config = {}) => {
|
|
13
12
|
return new Promise((resolve, reject) => {
|
|
@@ -58,9 +57,6 @@ export const createClovie = async (config = {}) => {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
opts.api = opts.api && opts.api.length ? resolveRoutes(opts.api, (...args) => clovie.useContext(...args)) : [];
|
|
62
|
-
opts.routes = opts.routes && opts.routes.length ? resolveRoutes(opts.routes, (...args) => clovie.useContext(...args)) : [];
|
|
63
|
-
|
|
64
60
|
// Don't auto-execute commands - let CLI decide
|
|
65
61
|
resolve(clovie);
|
|
66
62
|
});
|
package/lib/services/Run.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServiceProvider } from '@jucie.io/engine';
|
|
2
2
|
import { normalizeToFactories } from '../utils/normalizeToFactories.js';
|
|
3
|
-
import { viewsToRoutes, pagesToRoutes } from '../utils/viewsToRoutes.js';
|
|
3
|
+
import { viewsToRoutes, pagesToRoutes, resolveRoutes } from '../utils/viewsToRoutes.js';
|
|
4
4
|
import { defineRoutes as defineServerRoutes, defineHooks as defineServerHooks, defineMiddleware as defineServerMiddleware } from '@jucie.io/engine-server';
|
|
5
5
|
import { extractScriptSources } from '../utils/extractScripts.js';
|
|
6
6
|
|
|
@@ -24,6 +24,7 @@ export class Run extends ServiceProvider {
|
|
|
24
24
|
|
|
25
25
|
serve: async () => {
|
|
26
26
|
const opts = configurator.opts;
|
|
27
|
+
await this.#normalizeRoutes(opts);
|
|
27
28
|
const server = useContext('server');
|
|
28
29
|
if (!server) {
|
|
29
30
|
throw new Error('Server service not available. Use type: "server" in opts.');
|
|
@@ -49,6 +50,8 @@ export class Run extends ServiceProvider {
|
|
|
49
50
|
|
|
50
51
|
log.info('🚀 Starting development server...');
|
|
51
52
|
|
|
53
|
+
await this.#normalizeRoutes(configurator.opts);
|
|
54
|
+
|
|
52
55
|
// Build initial version
|
|
53
56
|
await this.#build(configurator.opts);
|
|
54
57
|
|
|
@@ -86,6 +89,12 @@ export class Run extends ServiceProvider {
|
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
async #normalizeRoutes(opts) {
|
|
93
|
+
opts.api = opts.api && opts.api.length ? await resolveRoutes(opts.api, (...args) => this.useContext(...args), opts) : [];
|
|
94
|
+
opts.routes = opts.routes && opts.routes.length ? await resolveRoutes(opts.routes, (...args) => this.useContext(...args), opts) : [];
|
|
95
|
+
return opts;
|
|
96
|
+
}
|
|
97
|
+
|
|
89
98
|
async #build(opts) {
|
|
90
99
|
const [file, compile, log] = this.useContext('file', 'compile', 'log');
|
|
91
100
|
|
|
@@ -95,6 +104,8 @@ export class Run extends ServiceProvider {
|
|
|
95
104
|
log.info('🚀 Starting compilation...');
|
|
96
105
|
const startTime = Date.now();
|
|
97
106
|
|
|
107
|
+
opts = await this.#normalizeRoutes(opts);
|
|
108
|
+
|
|
98
109
|
// Phase 1: partials must load before templates can render
|
|
99
110
|
await compile.partials(opts);
|
|
100
111
|
|