openlearn-next 0.1.1 → 0.1.3
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/{cli.cjs → cli.mjs} +14 -11
- package/package.json +4 -3
package/{cli.cjs → cli.mjs}
RENAMED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { mkdirSync } from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
10
|
|
|
8
11
|
const args = process.argv.slice(2);
|
|
9
12
|
let port = null;
|
|
@@ -29,20 +32,20 @@ Environment:
|
|
|
29
32
|
if (port) process.env.PORT = port;
|
|
30
33
|
|
|
31
34
|
if (!process.env.OPENLEARN_DB_PATH) {
|
|
32
|
-
const dataDir =
|
|
33
|
-
|
|
34
|
-
process.env.OPENLEARN_DB_PATH =
|
|
35
|
+
const dataDir = join(os.homedir(), 'openlearn-next');
|
|
36
|
+
mkdirSync(dataDir, { recursive: true });
|
|
37
|
+
process.env.OPENLEARN_DB_PATH = join(dataDir, 'data.db');
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(
|
|
40
|
+
console.log(`[openlearn-next] PORT=${process.env.PORT || '9000'}`);
|
|
41
|
+
console.log(`[openlearn-next] DB=${process.env.OPENLEARN_DB_PATH}`);
|
|
39
42
|
|
|
40
|
-
const serverPath =
|
|
43
|
+
const serverPath = join(__dirname, 'dist', 'server.cjs');
|
|
41
44
|
const child = spawn('node', [serverPath], {
|
|
42
45
|
stdio: 'inherit',
|
|
43
46
|
env: { ...process.env },
|
|
44
47
|
});
|
|
45
48
|
|
|
46
|
-
child.on('exit',
|
|
49
|
+
child.on('exit', (code) => {
|
|
47
50
|
process.exit(code || 0);
|
|
48
51
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openlearn-next",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "npx tsx --no-cache server.ts",
|
|
@@ -78,14 +78,15 @@
|
|
|
78
78
|
"@vitejs/plugin-react": "^5.0.4"
|
|
79
79
|
},
|
|
80
80
|
"bin": {
|
|
81
|
-
"openlearn-next": "
|
|
81
|
+
"openlearn-next": "cli.mjs"
|
|
82
82
|
},
|
|
83
83
|
"files": [
|
|
84
84
|
"dist/index.html",
|
|
85
85
|
"dist/server.cjs",
|
|
86
86
|
"dist/assets/",
|
|
87
87
|
"dist/plugins/",
|
|
88
|
-
"cli.
|
|
88
|
+
"cli.mjs",
|
|
89
|
+
|
|
89
90
|
"package.json",
|
|
90
91
|
"README.md"
|
|
91
92
|
],
|