doclific 0.1.0 → 0.2.1
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/package.json +4 -3
- package/readme.md +0 -0
- package/src/bin/doclific.ts +40 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doclific",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"doclific": "./dist/bin/doclific.js"
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
|
|
11
|
-
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\""
|
|
11
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\"",
|
|
12
|
+
"postinstall": "npm i && npm run build && cd frontend && npm install && npm run build"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@mdx-js/mdx": "^3.1.1",
|
|
15
16
|
"@orpc/client": "^1.12.2",
|
|
16
17
|
"@orpc/server": "^1.12.2",
|
|
18
|
+
"@types/node": "^20.6.0",
|
|
17
19
|
"child_process": "^1.0.2",
|
|
18
20
|
"cors": "^2.8.5",
|
|
19
21
|
"express": "^5.2.1",
|
|
@@ -23,7 +25,6 @@
|
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@types/cors": "^2.8.19",
|
|
25
27
|
"@types/express": "^5.0.6",
|
|
26
|
-
"@types/node": "^20.6.0",
|
|
27
28
|
"prettier": "^3.7.4",
|
|
28
29
|
"typescript": "^5.4.5"
|
|
29
30
|
}
|
package/readme.md
ADDED
|
File without changes
|
package/src/bin/doclific.ts
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import { startServer } from '../server/index.js';
|
|
4
|
+
import { mkdir } from 'fs/promises';
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import path from 'path';
|
|
4
7
|
|
|
5
|
-
const
|
|
6
|
-
process.argv.find((arg) => arg.startsWith('-p=') || arg.startsWith('--port='))?.split('=')[1] ||
|
|
7
|
-
6767;
|
|
8
|
+
const command = process.argv[2];
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
if (command === 'init') {
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const doclificDir = path.join(cwd, 'doclific');
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
if (existsSync(doclificDir)) {
|
|
15
|
+
console.log('Directory "doclific" already exists.');
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
mkdir(doclificDir, { recursive: true })
|
|
20
|
+
.then(() => {
|
|
21
|
+
console.log(`Created directory: ${doclificDir}`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
})
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
console.error('Failed to create directory:', error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
const port =
|
|
30
|
+
process.argv
|
|
31
|
+
.find((arg) => arg.startsWith('-p=') || arg.startsWith('--port='))
|
|
32
|
+
?.split('=')[1] || 6767;
|
|
33
|
+
|
|
34
|
+
const cwd = process.cwd();
|
|
35
|
+
console.log('Doclific CLI running in directory:', cwd);
|
|
36
|
+
|
|
37
|
+
startServer(Number(port));
|
|
38
|
+
|
|
39
|
+
// Optional: open browser automatically
|
|
40
|
+
const open =
|
|
41
|
+
process.platform === 'win32'
|
|
42
|
+
? 'start'
|
|
43
|
+
: process.platform === 'darwin'
|
|
44
|
+
? 'open'
|
|
45
|
+
: 'xdg-open';
|
|
46
|
+
spawn(open, [`http://localhost:${port}`]);
|
|
47
|
+
}
|