@techninja/clearstack 0.2.19 → 0.2.20
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/package-gen.js +6 -9
- package/package.json +1 -1
- package/templates/static/src/server.js +30 -0
package/lib/package-gen.js
CHANGED
|
@@ -17,21 +17,18 @@ export async function writePackageJson(dest, vars, existing) {
|
|
|
17
17
|
const isFullstack = vars.mode === 'fullstack';
|
|
18
18
|
|
|
19
19
|
const specScripts = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
dev: 'node --watch --env-file=.env src/server.js',
|
|
23
|
-
} : {
|
|
24
|
-
dev: 'npx serve src',
|
|
25
|
-
}),
|
|
20
|
+
start: 'node src/server.js',
|
|
21
|
+
dev: 'node --watch --env-file=.env src/server.js',
|
|
26
22
|
postinstall: 'node scripts/setup.js',
|
|
27
23
|
test: 'node scripts/test.js',
|
|
28
24
|
spec: 'clearstack',
|
|
29
25
|
};
|
|
30
26
|
|
|
31
27
|
const specDeps = {
|
|
28
|
+
express: '^5.2.1',
|
|
32
29
|
hybrids: '^9.1.22',
|
|
33
30
|
'lucide-static': '^1.7.0',
|
|
34
|
-
...(isFullstack ? {
|
|
31
|
+
...(isFullstack ? { ws: '^8.0.0' } : {}),
|
|
35
32
|
};
|
|
36
33
|
|
|
37
34
|
const specDevDeps = {
|
|
@@ -57,7 +54,7 @@ export async function writePackageJson(dest, vars, existing) {
|
|
|
57
54
|
name: vars.name,
|
|
58
55
|
description: vars.description,
|
|
59
56
|
type: 'module',
|
|
60
|
-
|
|
57
|
+
main: 'src/server.js',
|
|
61
58
|
scripts: { ...existing.scripts, ...specScripts },
|
|
62
59
|
dependencies: { ...existing.dependencies, ...specDeps },
|
|
63
60
|
devDependencies: { ...existing.devDependencies, ...specDevDeps },
|
|
@@ -67,7 +64,7 @@ export async function writePackageJson(dest, vars, existing) {
|
|
|
67
64
|
version: '0.1.0',
|
|
68
65
|
type: 'module',
|
|
69
66
|
description: vars.description,
|
|
70
|
-
|
|
67
|
+
main: 'src/server.js',
|
|
71
68
|
scripts: specScripts,
|
|
72
69
|
keywords: ['hybrids', 'web-components', 'no-build'],
|
|
73
70
|
license: 'MIT',
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static dev server — serves src/ for the browser with SPA fallback.
|
|
3
|
+
* @module server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import express from 'express';
|
|
7
|
+
|
|
8
|
+
/** @type {any} */
|
|
9
|
+
const app = express();
|
|
10
|
+
|
|
11
|
+
app.use(express.static('src'));
|
|
12
|
+
|
|
13
|
+
app.use((req, res, next) => {
|
|
14
|
+
if (req.method === 'GET' && !req.path.includes('.')) {
|
|
15
|
+
return res.sendFile('index.html', { root: 'src/public' });
|
|
16
|
+
}
|
|
17
|
+
next();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** @param {number} [port] */
|
|
21
|
+
export function start(port = {{port}}) {
|
|
22
|
+
const server = app.listen(port, () => console.log(`http://localhost:${port}`));
|
|
23
|
+
return server;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
27
|
+
start(parseInt(process.env.PORT) || {{port}});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default app;
|