doclific 0.2.0 → 0.2.2

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.
Files changed (220) hide show
  1. package/LICENSE +17 -0
  2. package/dist/bin/doclific.js +36 -8
  3. package/package.json +11 -4
  4. package/readme.md +77 -0
  5. package/.gitattributes +0 -2
  6. package/.prettierignore +0 -5
  7. package/.prettierrc +0 -9
  8. package/.vscode/settings.json +0 -13
  9. package/frontend/components.json +0 -24
  10. package/frontend/eslint.config.js +0 -23
  11. package/frontend/index.html +0 -25
  12. package/frontend/package-lock.json +0 -15754
  13. package/frontend/public/logo.svg +0 -1
  14. package/frontend/src/App.tsx +0 -21
  15. package/frontend/src/components/app-sidebar.tsx +0 -393
  16. package/frontend/src/components/editor/editor-base-kit.tsx +0 -43
  17. package/frontend/src/components/editor/editor-kit.tsx +0 -93
  18. package/frontend/src/components/editor/plugins/align-base-kit.tsx +0 -16
  19. package/frontend/src/components/editor/plugins/align-kit.tsx +0 -18
  20. package/frontend/src/components/editor/plugins/autoformat-kit.tsx +0 -236
  21. package/frontend/src/components/editor/plugins/basic-blocks-base-kit.tsx +0 -35
  22. package/frontend/src/components/editor/plugins/basic-blocks-kit.tsx +0 -88
  23. package/frontend/src/components/editor/plugins/basic-marks-base-kit.tsx +0 -27
  24. package/frontend/src/components/editor/plugins/basic-marks-kit.tsx +0 -41
  25. package/frontend/src/components/editor/plugins/basic-nodes-kit.tsx +0 -6
  26. package/frontend/src/components/editor/plugins/block-menu-kit.tsx +0 -14
  27. package/frontend/src/components/editor/plugins/block-placeholder-kit.tsx +0 -17
  28. package/frontend/src/components/editor/plugins/block-selection-kit.tsx +0 -32
  29. package/frontend/src/components/editor/plugins/callout-base-kit.tsx +0 -7
  30. package/frontend/src/components/editor/plugins/callout-kit.tsx +0 -7
  31. package/frontend/src/components/editor/plugins/code-block-base-kit.tsx +0 -23
  32. package/frontend/src/components/editor/plugins/code-block-kit.tsx +0 -26
  33. package/frontend/src/components/editor/plugins/codebase-kit.tsx +0 -23
  34. package/frontend/src/components/editor/plugins/column-base-kit.tsx +0 -11
  35. package/frontend/src/components/editor/plugins/column-kit.tsx +0 -10
  36. package/frontend/src/components/editor/plugins/comment-base-kit.tsx +0 -7
  37. package/frontend/src/components/editor/plugins/comment-kit.tsx +0 -97
  38. package/frontend/src/components/editor/plugins/cursor-overlay-kit.tsx +0 -13
  39. package/frontend/src/components/editor/plugins/date-base-kit.tsx +0 -5
  40. package/frontend/src/components/editor/plugins/date-kit.tsx +0 -7
  41. package/frontend/src/components/editor/plugins/discussion-kit.tsx +0 -148
  42. package/frontend/src/components/editor/plugins/dnd-kit.tsx +0 -28
  43. package/frontend/src/components/editor/plugins/docx-kit.tsx +0 -6
  44. package/frontend/src/components/editor/plugins/emoji-kit.tsx +0 -13
  45. package/frontend/src/components/editor/plugins/excalidraw-kit.tsx +0 -9
  46. package/frontend/src/components/editor/plugins/exit-break-kit.tsx +0 -12
  47. package/frontend/src/components/editor/plugins/floating-toolbar-kit.tsx +0 -19
  48. package/frontend/src/components/editor/plugins/font-base-kit.tsx +0 -20
  49. package/frontend/src/components/editor/plugins/font-kit.tsx +0 -29
  50. package/frontend/src/components/editor/plugins/indent-base-kit.tsx +0 -19
  51. package/frontend/src/components/editor/plugins/indent-kit.tsx +0 -22
  52. package/frontend/src/components/editor/plugins/line-height-base-kit.tsx +0 -14
  53. package/frontend/src/components/editor/plugins/line-height-kit.tsx +0 -16
  54. package/frontend/src/components/editor/plugins/link-base-kit.tsx +0 -5
  55. package/frontend/src/components/editor/plugins/link-kit.tsx +0 -15
  56. package/frontend/src/components/editor/plugins/list-base-kit.tsx +0 -23
  57. package/frontend/src/components/editor/plugins/list-kit.tsx +0 -26
  58. package/frontend/src/components/editor/plugins/markdown-kit.tsx +0 -46
  59. package/frontend/src/components/editor/plugins/math-base-kit.tsx +0 -11
  60. package/frontend/src/components/editor/plugins/math-kit.tsx +0 -13
  61. package/frontend/src/components/editor/plugins/media-base-kit.tsx +0 -31
  62. package/frontend/src/components/editor/plugins/media-kit.tsx +0 -43
  63. package/frontend/src/components/editor/plugins/mention-base-kit.tsx +0 -7
  64. package/frontend/src/components/editor/plugins/mention-kit.tsx +0 -15
  65. package/frontend/src/components/editor/plugins/slash-kit.tsx +0 -18
  66. package/frontend/src/components/editor/plugins/suggestion-base-kit.tsx +0 -7
  67. package/frontend/src/components/editor/plugins/suggestion-kit.tsx +0 -90
  68. package/frontend/src/components/editor/plugins/table-base-kit.tsx +0 -20
  69. package/frontend/src/components/editor/plugins/table-kit.tsx +0 -22
  70. package/frontend/src/components/editor/plugins/toc-base-kit.tsx +0 -5
  71. package/frontend/src/components/editor/plugins/toc-kit.tsx +0 -14
  72. package/frontend/src/components/editor/plugins/toggle-base-kit.tsx +0 -7
  73. package/frontend/src/components/editor/plugins/toggle-kit.tsx +0 -11
  74. package/frontend/src/components/editor/transforms.ts +0 -194
  75. package/frontend/src/components/markdown-to-slate-demo.tsx +0 -50
  76. package/frontend/src/components/mode-toggle.tsx +0 -15
  77. package/frontend/src/components/theme-provider.tsx +0 -73
  78. package/frontend/src/components/ui/alert-dialog.tsx +0 -155
  79. package/frontend/src/components/ui/align-toolbar-button.tsx +0 -84
  80. package/frontend/src/components/ui/avatar.tsx +0 -51
  81. package/frontend/src/components/ui/block-context-menu.tsx +0 -199
  82. package/frontend/src/components/ui/block-discussion.tsx +0 -365
  83. package/frontend/src/components/ui/block-draggable.tsx +0 -512
  84. package/frontend/src/components/ui/block-list-static.tsx +0 -80
  85. package/frontend/src/components/ui/block-list.tsx +0 -87
  86. package/frontend/src/components/ui/block-selection.tsx +0 -42
  87. package/frontend/src/components/ui/block-suggestion.tsx +0 -473
  88. package/frontend/src/components/ui/blockquote-node-static.tsx +0 -11
  89. package/frontend/src/components/ui/blockquote-node.tsx +0 -13
  90. package/frontend/src/components/ui/button.tsx +0 -62
  91. package/frontend/src/components/ui/calendar.tsx +0 -218
  92. package/frontend/src/components/ui/callout-node-static.tsx +0 -36
  93. package/frontend/src/components/ui/callout-node.tsx +0 -63
  94. package/frontend/src/components/ui/caption.tsx +0 -63
  95. package/frontend/src/components/ui/checkbox.tsx +0 -30
  96. package/frontend/src/components/ui/code-block-node-static.tsx +0 -35
  97. package/frontend/src/components/ui/code-block-node.tsx +0 -287
  98. package/frontend/src/components/ui/code-node-static.tsx +0 -15
  99. package/frontend/src/components/ui/code-node.tsx +0 -17
  100. package/frontend/src/components/ui/codebase-snippet-node.tsx +0 -237
  101. package/frontend/src/components/ui/column-node-static.tsx +0 -29
  102. package/frontend/src/components/ui/column-node.tsx +0 -317
  103. package/frontend/src/components/ui/command.tsx +0 -182
  104. package/frontend/src/components/ui/comment-node-static.tsx +0 -15
  105. package/frontend/src/components/ui/comment-node.tsx +0 -45
  106. package/frontend/src/components/ui/comment-toolbar-button.tsx +0 -24
  107. package/frontend/src/components/ui/comment.tsx +0 -618
  108. package/frontend/src/components/ui/context-menu.tsx +0 -250
  109. package/frontend/src/components/ui/cursor-overlay.tsx +0 -66
  110. package/frontend/src/components/ui/date-node-static.tsx +0 -45
  111. package/frontend/src/components/ui/date-node.tsx +0 -93
  112. package/frontend/src/components/ui/dialog.tsx +0 -143
  113. package/frontend/src/components/ui/dropdown-menu.tsx +0 -255
  114. package/frontend/src/components/ui/dynamic-icon.tsx +0 -12
  115. package/frontend/src/components/ui/editor-static.tsx +0 -53
  116. package/frontend/src/components/ui/editor.tsx +0 -130
  117. package/frontend/src/components/ui/emoji-node.tsx +0 -69
  118. package/frontend/src/components/ui/emoji-toolbar-button.tsx +0 -628
  119. package/frontend/src/components/ui/equation-node-static.tsx +0 -98
  120. package/frontend/src/components/ui/equation-node.tsx +0 -235
  121. package/frontend/src/components/ui/equation-toolbar-button.tsx +0 -25
  122. package/frontend/src/components/ui/excalidraw-node.tsx +0 -36
  123. package/frontend/src/components/ui/export-toolbar-button.tsx +0 -174
  124. package/frontend/src/components/ui/file-selector.tsx +0 -339
  125. package/frontend/src/components/ui/floating-toolbar-buttons.tsx +0 -73
  126. package/frontend/src/components/ui/floating-toolbar.tsx +0 -85
  127. package/frontend/src/components/ui/font-color-toolbar-button.tsx +0 -831
  128. package/frontend/src/components/ui/font-size-toolbar-button.tsx +0 -152
  129. package/frontend/src/components/ui/heading-node-static.tsx +0 -68
  130. package/frontend/src/components/ui/heading-node.tsx +0 -58
  131. package/frontend/src/components/ui/highlight-node-static.tsx +0 -11
  132. package/frontend/src/components/ui/highlight-node.tsx +0 -13
  133. package/frontend/src/components/ui/history-toolbar-button.tsx +0 -50
  134. package/frontend/src/components/ui/hr-node-static.tsx +0 -20
  135. package/frontend/src/components/ui/hr-node.tsx +0 -33
  136. package/frontend/src/components/ui/import-toolbar-button.tsx +0 -97
  137. package/frontend/src/components/ui/indent-toolbar-button.tsx +0 -30
  138. package/frontend/src/components/ui/inline-combobox.tsx +0 -414
  139. package/frontend/src/components/ui/input.tsx +0 -21
  140. package/frontend/src/components/ui/insert-toolbar-button.tsx +0 -254
  141. package/frontend/src/components/ui/kbd-node-static.tsx +0 -15
  142. package/frontend/src/components/ui/kbd-node.tsx +0 -17
  143. package/frontend/src/components/ui/layout-header.tsx +0 -35
  144. package/frontend/src/components/ui/line-height-toolbar-button.tsx +0 -68
  145. package/frontend/src/components/ui/link-node-static.tsx +0 -21
  146. package/frontend/src/components/ui/link-node.tsx +0 -39
  147. package/frontend/src/components/ui/link-toolbar-button.tsx +0 -22
  148. package/frontend/src/components/ui/link-toolbar.tsx +0 -206
  149. package/frontend/src/components/ui/list-toolbar-button.tsx +0 -204
  150. package/frontend/src/components/ui/mark-toolbar-button.tsx +0 -19
  151. package/frontend/src/components/ui/media-audio-node-static.tsx +0 -17
  152. package/frontend/src/components/ui/media-audio-node.tsx +0 -39
  153. package/frontend/src/components/ui/media-embed-node.tsx +0 -136
  154. package/frontend/src/components/ui/media-file-node-static.tsx +0 -29
  155. package/frontend/src/components/ui/media-file-node.tsx +0 -47
  156. package/frontend/src/components/ui/media-image-node-static.tsx +0 -39
  157. package/frontend/src/components/ui/media-image-node.tsx +0 -80
  158. package/frontend/src/components/ui/media-placeholder-node.tsx +0 -249
  159. package/frontend/src/components/ui/media-preview-dialog.tsx +0 -152
  160. package/frontend/src/components/ui/media-toolbar-button.tsx +0 -225
  161. package/frontend/src/components/ui/media-toolbar.tsx +0 -115
  162. package/frontend/src/components/ui/media-upload-toast.tsx +0 -66
  163. package/frontend/src/components/ui/media-video-node-static.tsx +0 -30
  164. package/frontend/src/components/ui/media-video-node.tsx +0 -121
  165. package/frontend/src/components/ui/mention-node-static.tsx +0 -36
  166. package/frontend/src/components/ui/mention-node.tsx +0 -194
  167. package/frontend/src/components/ui/mode-toolbar-button.tsx +0 -123
  168. package/frontend/src/components/ui/more-toolbar-button.tsx +0 -80
  169. package/frontend/src/components/ui/paragraph-node-static.tsx +0 -13
  170. package/frontend/src/components/ui/paragraph-node.tsx +0 -15
  171. package/frontend/src/components/ui/popover.tsx +0 -46
  172. package/frontend/src/components/ui/resize-handle.tsx +0 -87
  173. package/frontend/src/components/ui/separator.tsx +0 -28
  174. package/frontend/src/components/ui/sheet.tsx +0 -139
  175. package/frontend/src/components/ui/sidebar.tsx +0 -726
  176. package/frontend/src/components/ui/skeleton.tsx +0 -13
  177. package/frontend/src/components/ui/slash-node.tsx +0 -233
  178. package/frontend/src/components/ui/sonner.tsx +0 -38
  179. package/frontend/src/components/ui/suggestion-node-static.tsx +0 -35
  180. package/frontend/src/components/ui/suggestion-node.tsx +0 -162
  181. package/frontend/src/components/ui/suggestion-toolbar-button.tsx +0 -25
  182. package/frontend/src/components/ui/table-icons.tsx +0 -862
  183. package/frontend/src/components/ui/table-node-static.tsx +0 -98
  184. package/frontend/src/components/ui/table-node.tsx +0 -656
  185. package/frontend/src/components/ui/table-toolbar-button.tsx +0 -264
  186. package/frontend/src/components/ui/toc-node-static.tsx +0 -92
  187. package/frontend/src/components/ui/toc-node.tsx +0 -55
  188. package/frontend/src/components/ui/toggle-node-static.tsx +0 -18
  189. package/frontend/src/components/ui/toggle-node.tsx +0 -36
  190. package/frontend/src/components/ui/toggle-toolbar-button.tsx +0 -22
  191. package/frontend/src/components/ui/toolbar.tsx +0 -387
  192. package/frontend/src/components/ui/tooltip.tsx +0 -59
  193. package/frontend/src/components/ui/turn-into-toolbar-button.tsx +0 -188
  194. package/frontend/src/hooks/use-debounce.ts +0 -18
  195. package/frontend/src/hooks/use-is-touch-device.ts +0 -24
  196. package/frontend/src/hooks/use-mobile.ts +0 -19
  197. package/frontend/src/hooks/use-mounted.ts +0 -11
  198. package/frontend/src/hooks/use-upload-file.ts +0 -128
  199. package/frontend/src/index.css +0 -128
  200. package/frontend/src/layout.tsx +0 -42
  201. package/frontend/src/lib/markdown-joiner-transform.ts +0 -239
  202. package/frontend/src/lib/orpc.ts +0 -13
  203. package/frontend/src/lib/uploadthing.ts +0 -19
  204. package/frontend/src/lib/utils.ts +0 -6
  205. package/frontend/src/main.tsx +0 -13
  206. package/frontend/src/pages/editor.tsx +0 -44
  207. package/frontend/src/types/docs.d.ts +0 -6
  208. package/frontend/src/types/global.d.ts +0 -9
  209. package/frontend/src/types/router.d.ts +0 -4
  210. package/frontend/tsconfig.app.json +0 -33
  211. package/frontend/tsconfig.json +0 -10
  212. package/frontend/tsconfig.node.json +0 -26
  213. package/frontend/vite.config.ts +0 -14
  214. package/src/bin/doclific.ts +0 -47
  215. package/src/core/codebase.ts +0 -39
  216. package/src/core/docs.ts +0 -90
  217. package/src/core/git.ts +0 -48
  218. package/src/server/index.ts +0 -55
  219. package/src/server/router.ts +0 -65
  220. package/tsconfig.json +0 -15
@@ -1,10 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
4
- "compilerOptions": {
5
- "baseUrl": ".",
6
- "paths": {
7
- "@/*": ["./src/*"]
8
- }
9
- }
10
- }
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2023",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "types": ["node"],
8
- "skipLibCheck": true,
9
-
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
16
-
17
- /* Linting */
18
- "strict": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "erasableSyntaxOnly": true,
22
- "noFallthroughCasesInSwitch": true,
23
- "noUncheckedSideEffectImports": true
24
- },
25
- "include": ["vite.config.ts"]
26
- }
@@ -1,14 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import react from '@vitejs/plugin-react-swc';
3
- import tailwindcss from '@tailwindcss/vite';
4
- import path from 'path';
5
-
6
- // https://vite.dev/config/
7
- export default defineConfig({
8
- plugins: [react(), tailwindcss()],
9
- resolve: {
10
- alias: {
11
- '@': path.resolve(__dirname, './src'),
12
- },
13
- },
14
- });
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from 'child_process';
3
- import { startServer } from '../server/index.js';
4
- import { mkdir } from 'fs/promises';
5
- import { existsSync } from 'fs';
6
- import path from 'path';
7
-
8
- const command = process.argv[2];
9
-
10
- if (command === 'init') {
11
- const cwd = process.cwd();
12
- const doclificDir = path.join(cwd, 'doclific');
13
-
14
- if (existsSync(doclificDir)) {
15
- console.log('Directory "doclific" already exists.');
16
- process.exit(0);
17
- }
18
-
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
- }
@@ -1,39 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs/promises';
3
-
4
- interface FileNode {
5
- path: string;
6
- name: string;
7
- type: 'file' | 'directory';
8
- children?: FileNode[];
9
- }
10
-
11
- /**
12
- * Get all contents of a folder given a filePath.
13
- * @param filePath - The relative path to the folder
14
- */
15
- export const getFolderContents = async (filePath: string): Promise<FileNode[]> => {
16
- const currentDir = process.cwd();
17
- let fullPath = '';
18
- if (filePath !== '') {
19
- fullPath = path.join(currentDir, filePath);
20
- } else {
21
- fullPath = currentDir;
22
- }
23
- const entries = await fs.readdir(fullPath, { withFileTypes: true });
24
- const nodes: FileNode[] = [];
25
- for (const entry of entries) {
26
- nodes.push({
27
- path: path.join(filePath, entry.name),
28
- name: entry.name,
29
- type: entry.isDirectory() ? 'directory' : 'file',
30
- });
31
- }
32
- return nodes;
33
- };
34
-
35
- export const getFileContents = async (filePath: string) => {
36
- const currentDir = process.cwd();
37
- const fullPath = path.join(currentDir, filePath);
38
- return fs.readFile(fullPath, 'utf8');
39
- };
package/src/core/docs.ts DELETED
@@ -1,90 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
-
4
- type FolderStructure = {
5
- name: string;
6
- title: string;
7
- icon?: string;
8
- children: FolderStructure[];
9
- };
10
-
11
- const scanDirectory = async (dirPath: string): Promise<FolderStructure[]> => {
12
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
13
- const folders: FolderStructure[] = [];
14
-
15
- for (const entry of entries) {
16
- if (entry.isDirectory()) {
17
- const fullPath = path.join(dirPath, entry.name);
18
- const children = await scanDirectory(fullPath);
19
- let config: { title: string; icon: string | undefined } = {
20
- title: entry.name,
21
- icon: undefined,
22
- };
23
- // get the config.json file
24
- const configPath = path.join(fullPath, 'config.json');
25
- try {
26
- const configFile = await fs.readFile(configPath, 'utf8');
27
- config = JSON.parse(configFile);
28
- } catch {
29
- throw new Error(`Config file not found for ${entry.name}`);
30
- }
31
- folders.push({
32
- name: entry.name,
33
- title: config.title,
34
- icon: config.icon,
35
- children,
36
- });
37
- }
38
- }
39
-
40
- return folders;
41
- };
42
-
43
- export const getDocs = async (): Promise<FolderStructure[]> => {
44
- const docsFolder = path.join(process.cwd(), 'doclific');
45
- try {
46
- await fs.access(docsFolder);
47
- } catch {
48
- return [];
49
- }
50
- return scanDirectory(docsFolder);
51
- };
52
-
53
- /**
54
- * This function will return the content of the .mdx file in the directory with the given filePath.
55
- * @param filePath - The path to the file
56
- * @returns
57
- */
58
- export const getDoc = async (filePath: string) => {
59
- const currentDir = process.cwd();
60
- const fullPath = path.join(currentDir, 'doclific', filePath);
61
- try {
62
- return fs.readFile(path.join(fullPath, 'content.mdx'), 'utf8');
63
- } catch {
64
- return undefined;
65
- }
66
- };
67
-
68
- export const updateDoc = async (filePath: string, content: string) => {
69
- const currentDir = process.cwd();
70
- const fullPath = path.join(currentDir, 'doclific', filePath);
71
- await fs.writeFile(path.join(fullPath, 'content.mdx'), content);
72
- };
73
-
74
- export const createDoc = async (filePath: string, title: string, icon: string | undefined) => {
75
- const currentDir = process.cwd();
76
- const fullPath = path.join(currentDir, 'doclific', filePath);
77
-
78
- const newFolderName = crypto.randomUUID();
79
- const newFolderPath = path.join(fullPath, newFolderName);
80
- await fs.mkdir(newFolderPath, { recursive: true });
81
- // create content.mdx file
82
- await fs.writeFile(path.join(newFolderPath, 'content.mdx'), '# Hello World');
83
- // create config.json file
84
- await fs.writeFile(
85
- path.join(newFolderPath, 'config.json'),
86
- JSON.stringify({ title, icon }, null, 2)
87
- );
88
- // return the new folder path
89
- return newFolderPath;
90
- };
package/src/core/git.ts DELETED
@@ -1,48 +0,0 @@
1
- import util from 'util';
2
- import { exec } from 'child_process';
3
-
4
- const execAsync = util.promisify(exec);
5
-
6
- export const getGitRepositoryName = async (): Promise<string | null> => {
7
- try {
8
- const GET_REPO_NAME_COMMAND = `git config --get remote.origin.url | sed -E "s|.*/(.+)\\.git|\\1|"`;
9
- const repoName = await execAsync(GET_REPO_NAME_COMMAND);
10
- return repoName.stdout.toString().trim();
11
- } catch (error) {
12
- console.error(error);
13
- return null;
14
- }
15
- };
16
-
17
- export const getGitRepositoryBranch = async (): Promise<string | null> => {
18
- try {
19
- const GET_REPO_BRANCH_COMMAND = `git rev-parse --abbrev-ref HEAD`;
20
- const repoBranch = await execAsync(GET_REPO_BRANCH_COMMAND);
21
- return repoBranch.stdout.toString().trim();
22
- } catch (error) {
23
- console.error(error);
24
- return null;
25
- }
26
- };
27
-
28
- export const getGitUser = async (): Promise<string | null> => {
29
- try {
30
- const GET_USER_COMMAND = `git config user.name`;
31
- const user = await execAsync(GET_USER_COMMAND);
32
- return user.stdout.toString().trim();
33
- } catch (error) {
34
- console.error(error);
35
- return null;
36
- }
37
- };
38
-
39
- export const getGitUserEmail = async (): Promise<string | null> => {
40
- try {
41
- const GET_USER_EMAIL_COMMAND = `git config user.email`;
42
- const userEmail = await execAsync(GET_USER_EMAIL_COMMAND);
43
- return userEmail.stdout.toString().trim();
44
- } catch (error) {
45
- console.error(error);
46
- return null;
47
- }
48
- };
@@ -1,55 +0,0 @@
1
- import express from 'express';
2
- import cors from 'cors';
3
- import { RPCHandler } from '@orpc/server/node';
4
- import { onError } from '@orpc/server';
5
- import { router } from './router.js';
6
- import path from 'path';
7
- import { fileURLToPath } from 'url';
8
- import fs from 'fs';
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
-
13
- const frontendDist = path.join(__dirname, '../../frontend/dist');
14
-
15
- export function startServer(port: number = 6767) {
16
- const app = express();
17
-
18
- app.use(cors());
19
-
20
- const handler = new RPCHandler(router, {
21
- interceptors: [
22
- onError((error) => {
23
- console.error(error);
24
- }),
25
- ],
26
- });
27
-
28
- app.use('/rpc{/*path}', async (req, res, next) => {
29
- const { matched } = await handler.handle(req, res, {
30
- prefix: '/rpc',
31
- context: {},
32
- });
33
-
34
- if (matched) return;
35
-
36
- next();
37
- });
38
-
39
- // serve static files in frontend/dist
40
- app.use((req, res, next) => {
41
- if (req.url === '/') {
42
- const html = fs.readFileSync(path.join(frontendDist, 'index.html'), 'utf8');
43
- res.send(html.replace(': BACKEND_PORT', `: ${port.toString()}`));
44
- } else {
45
- express.static(frontendDist)(req, res, next);
46
- }
47
- });
48
-
49
- app.get('/{*splat}', (req, res) => {
50
- const html = fs.readFileSync(path.join(frontendDist, 'index.html'), 'utf8');
51
- res.send(html.replace(': BACKEND_PORT', `: ${port.toString()}`));
52
- });
53
-
54
- app.listen(port, () => console.log(`Access your documentation here: http://localhost:${port}`));
55
- }
@@ -1,65 +0,0 @@
1
- import { os } from '@orpc/server';
2
- import {
3
- getGitRepositoryBranch,
4
- getGitRepositoryName,
5
- getGitUser,
6
- getGitUserEmail,
7
- } from '../core/git.js';
8
- import { createDoc, getDoc, getDocs, updateDoc } from '../core/docs.js';
9
- import { z } from 'zod';
10
- import { getFileContents, getFolderContents } from '../core/codebase.js';
11
- import path from 'path';
12
-
13
- export const router = {
14
- git: {
15
- getRepoInfo: os.handler(async () => {
16
- return {
17
- repositoryName: await getGitRepositoryName(),
18
- repositoryBranch: await getGitRepositoryBranch(),
19
- user: await getGitUser(),
20
- userEmail: await getGitUserEmail(),
21
- };
22
- }),
23
- },
24
- docs: {
25
- getDocs: os.handler(async () => {
26
- return await getDocs();
27
- }),
28
- getDoc: os.input(z.object({ filePath: z.string() })).handler(async ({ input }) => {
29
- const { filePath } = input;
30
- return await getDoc(filePath);
31
- }),
32
- updateDoc: os
33
- .input(z.object({ filePath: z.string(), content: z.string() }))
34
- .handler(async ({ input }) => {
35
- const { filePath, content } = input;
36
- return await updateDoc(filePath, content);
37
- }),
38
- createDoc: os
39
- .input(
40
- z.object({ filePath: z.string(), title: z.string(), icon: z.string().optional() })
41
- )
42
- .handler(async ({ input }) => {
43
- const { filePath, title, icon } = input;
44
- return await createDoc(filePath, title, icon);
45
- }),
46
- },
47
- codebase: {
48
- getFolderContents: os
49
- .input(z.object({ filePath: z.string() }))
50
- .handler(async ({ input }) => {
51
- const { filePath } = input;
52
- return await getFolderContents(filePath);
53
- }),
54
- getFileContents: os.input(z.object({ filePath: z.string() })).handler(async ({ input }) => {
55
- const { filePath } = input;
56
- const currentDir = process.cwd();
57
- return {
58
- contents: await getFileContents(filePath),
59
- fullPath: path.join(currentDir, '..', filePath),
60
- };
61
- }),
62
- },
63
- };
64
-
65
- export type Router = typeof router;
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2020"],
7
- "outDir": "dist",
8
- "rootDir": "src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "types": ["node"]
13
- },
14
- "include": ["src"]
15
- }