doclific 0.1.0 → 0.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doclific",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "doclific": "./dist/bin/doclific.js"
@@ -8,7 +8,8 @@
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 run build && cd frontend && npm install && npm run build"
12
13
  },
13
14
  "dependencies": {
14
15
  "@mdx-js/mdx": "^3.1.1",
package/readme.md ADDED
File without changes
@@ -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 port =
6
- process.argv.find((arg) => arg.startsWith('-p=') || arg.startsWith('--port='))?.split('=')[1] ||
7
- 6767;
8
+ const command = process.argv[2];
8
9
 
9
- const cwd = process.cwd();
10
- console.log('Doclific CLI running in directory:', cwd);
10
+ if (command === 'init') {
11
+ const cwd = process.cwd();
12
+ const doclificDir = path.join(cwd, 'doclific');
11
13
 
12
- startServer(Number(port));
14
+ if (existsSync(doclificDir)) {
15
+ console.log('Directory "doclific" already exists.');
16
+ process.exit(0);
17
+ }
13
18
 
14
- // Optional: open browser automatically
15
- const open =
16
- process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
17
- spawn(open, [`http://localhost:${port}`]);
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
+ }