vzcode 0.76.0 → 0.77.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/dist/assets/{index-BpuOxvvE.css → index-B1DSqTuG.css} +1 -1
- package/dist/assets/{index--cETBO9l.js → index-DVG2p8p3.js} +48 -48
- package/dist/assets/{worker-BCgDdjKY.js → worker-CPGExEr5.js} +45 -45
- package/dist/index.html +2 -2
- package/package.json +8 -8
- package/src/client/VZSidebar/index.tsx +104 -89
- package/src/client/VZSidebar/styles.scss +11 -12
- package/src/client/VZSidebar/{DragAndDrop.tsx → useDragAndDrop.tsx} +8 -12
- package/src/client/useFileCRUD.ts +12 -2
- package/src/client/useTypeScript/worker.ts +6 -1
- package/src/server/computeInitialDocument.js +1 -2
- package/src/server/index.js +82 -1
- package/src/server/isDirectory.js +1 -0
package/dist/index.html
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-DVG2p8p3.js"></script>
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B1DSqTuG.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vzcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"description": "Multiplayer code editor system",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"@codemirror/lang-markdown": "^6.2.4",
|
|
72
72
|
"@codemirror/state": "^6.4.1",
|
|
73
73
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
74
|
-
"@codemirror/view": "^6.
|
|
74
|
+
"@codemirror/view": "^6.26.0",
|
|
75
75
|
"@lezer/highlight": "^1.2.0",
|
|
76
|
-
"@replit/codemirror-indentation-markers": "^6.5.
|
|
76
|
+
"@replit/codemirror-indentation-markers": "^6.5.1",
|
|
77
77
|
"@replit/codemirror-interact": "^6.3.0",
|
|
78
78
|
"@replit/codemirror-lang-svelte": "^6.0.0",
|
|
79
79
|
"@replit/codemirror-vscode-keymap": "^6.0.2",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"json0-ot-diff": "^1.1.2",
|
|
101
101
|
"ngrok": "^4.3.3",
|
|
102
102
|
"open": "^10.1.0",
|
|
103
|
-
"openai": "^4.
|
|
103
|
+
"openai": "^4.29.1",
|
|
104
104
|
"prettier-plugin-svelte": "^3.2.2",
|
|
105
105
|
"react": "^18.2.0",
|
|
106
|
-
"react-bootstrap": "^2.10.
|
|
106
|
+
"react-bootstrap": "^2.10.2",
|
|
107
107
|
"react-dom": "^18.2.0",
|
|
108
108
|
"react-router-dom": "^6.22.3",
|
|
109
109
|
"sharedb": "^4.1.2",
|
|
@@ -112,14 +112,14 @@
|
|
|
112
112
|
"ws": "^8.16.0"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@types/react": "^18.2.
|
|
115
|
+
"@types/react": "^18.2.67",
|
|
116
116
|
"@types/react-dom": "^18.2.22",
|
|
117
117
|
"@vitejs/plugin-react": "^4.2.1",
|
|
118
118
|
"concurrently": "^8.2.2",
|
|
119
119
|
"prettier": "^3.2.5",
|
|
120
|
-
"sass": "^1.
|
|
120
|
+
"sass": "^1.72.0",
|
|
121
121
|
"typescript": "^5.4.2",
|
|
122
122
|
"vite": "^5.1.6",
|
|
123
|
-
"vitest": "^1.
|
|
123
|
+
"vitest": "^1.4.0"
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -17,7 +17,7 @@ import { SplitPaneResizeContext } from '../SplitPaneResizeContext';
|
|
|
17
17
|
import { BugSVG, GearSVG, NewSVG } from '../Icons';
|
|
18
18
|
import { Listing } from './Listing';
|
|
19
19
|
import { VZCodeContext } from '../VZCodeContext';
|
|
20
|
-
import {
|
|
20
|
+
import { useDragAndDrop } from './useDragAndDrop';
|
|
21
21
|
import './styles.scss';
|
|
22
22
|
|
|
23
23
|
// TODO turn this UI back on when we are actually detecting
|
|
@@ -84,116 +84,131 @@ export const VZSidebar = ({
|
|
|
84
84
|
fileTree.children &&
|
|
85
85
|
fileTree.children.length > 0;
|
|
86
86
|
|
|
87
|
+
const {
|
|
88
|
+
isDragOver,
|
|
89
|
+
handleDragEnter,
|
|
90
|
+
handleDragOver,
|
|
91
|
+
handleDragLeave,
|
|
92
|
+
handleDrop,
|
|
93
|
+
} = useDragAndDrop();
|
|
94
|
+
|
|
87
95
|
return (
|
|
88
96
|
<div
|
|
89
|
-
className=
|
|
90
|
-
|
|
97
|
+
className={`drop-zone ${isDragOver ? 'dragover' : ''}`}
|
|
98
|
+
onDragEnter={handleDragEnter}
|
|
99
|
+
onDragOver={handleDragOver}
|
|
100
|
+
onDragLeave={handleDragLeave}
|
|
101
|
+
onDrop={handleDrop}
|
|
91
102
|
>
|
|
92
|
-
<div
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<div className="
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
rel="noopener noreferrer"
|
|
103
|
+
<div
|
|
104
|
+
className="vz-sidebar"
|
|
105
|
+
style={{ width: sidebarWidth + 'px' }}
|
|
106
|
+
>
|
|
107
|
+
<div className="files">
|
|
108
|
+
<div className="full-box">
|
|
109
|
+
<div className="sidebar-section-hint">
|
|
110
|
+
Project Files
|
|
111
|
+
</div>
|
|
112
|
+
<div className="sidebar-section-buttons">
|
|
113
|
+
<OverlayTrigger
|
|
114
|
+
placement="left"
|
|
115
|
+
overlay={
|
|
116
|
+
<Tooltip id="report-bug-tooltip">
|
|
117
|
+
{reportBugTooltipText}
|
|
118
|
+
</Tooltip>
|
|
119
|
+
}
|
|
110
120
|
>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
<a
|
|
122
|
+
href="https://github.com/vizhub-core/vzcode/issues/new"
|
|
123
|
+
target="_blank"
|
|
124
|
+
rel="noopener noreferrer"
|
|
125
|
+
>
|
|
126
|
+
<i className="icon-button icon-button-dark">
|
|
127
|
+
<BugSVG />
|
|
128
|
+
</i>
|
|
129
|
+
</a>
|
|
130
|
+
</OverlayTrigger>
|
|
131
|
+
{disableSettings ? null : (
|
|
132
|
+
<OverlayTrigger
|
|
133
|
+
placement="left"
|
|
134
|
+
overlay={
|
|
135
|
+
<Tooltip id="open-settings-tooltip">
|
|
136
|
+
{openSettingsTooltipText}
|
|
137
|
+
</Tooltip>
|
|
138
|
+
}
|
|
139
|
+
>
|
|
140
|
+
<i
|
|
141
|
+
onClick={handleSettingsClick}
|
|
142
|
+
className="icon-button icon-button-dark"
|
|
143
|
+
>
|
|
144
|
+
<GearSVG />
|
|
145
|
+
</i>
|
|
146
|
+
</OverlayTrigger>
|
|
147
|
+
)}
|
|
117
148
|
<OverlayTrigger
|
|
118
149
|
placement="left"
|
|
119
150
|
overlay={
|
|
120
|
-
<Tooltip id="
|
|
121
|
-
{
|
|
151
|
+
<Tooltip id="create-file-tooltip">
|
|
152
|
+
{createFileTooltipText}
|
|
122
153
|
</Tooltip>
|
|
123
154
|
}
|
|
124
155
|
>
|
|
125
156
|
<i
|
|
126
|
-
onClick={
|
|
157
|
+
onClick={handleOpenCreateFileModal}
|
|
127
158
|
className="icon-button icon-button-dark"
|
|
128
159
|
>
|
|
129
|
-
<
|
|
160
|
+
<NewSVG />
|
|
130
161
|
</i>
|
|
131
162
|
</OverlayTrigger>
|
|
132
|
-
|
|
133
|
-
<OverlayTrigger
|
|
134
|
-
placement="left"
|
|
135
|
-
overlay={
|
|
136
|
-
<Tooltip id="create-file-tooltip">
|
|
137
|
-
{createFileTooltipText}
|
|
138
|
-
</Tooltip>
|
|
139
|
-
}
|
|
140
|
-
>
|
|
141
|
-
<i
|
|
142
|
-
onClick={handleOpenCreateFileModal}
|
|
143
|
-
className="icon-button icon-button-dark"
|
|
144
|
-
>
|
|
145
|
-
<NewSVG />
|
|
146
|
-
</i>
|
|
147
|
-
</OverlayTrigger>
|
|
163
|
+
</div>
|
|
148
164
|
</div>
|
|
165
|
+
{filesExist ? (
|
|
166
|
+
fileTree.children.map((entity) => {
|
|
167
|
+
const { fileId } = entity as FileTreeFile;
|
|
168
|
+
const { path } = entity as FileTree;
|
|
169
|
+
const key = fileId ? fileId : path;
|
|
170
|
+
return (
|
|
171
|
+
<Listing
|
|
172
|
+
key={key}
|
|
173
|
+
entity={entity}
|
|
174
|
+
renameFile={renameFile}
|
|
175
|
+
deleteFile={deleteFile}
|
|
176
|
+
renameDirectory={renameDirectory}
|
|
177
|
+
deleteDirectory={deleteDirectory}
|
|
178
|
+
handleFileClick={handleFileClick}
|
|
179
|
+
handleFileDoubleClick={
|
|
180
|
+
handleFileDoubleClick
|
|
181
|
+
}
|
|
182
|
+
isDirectoryOpen={isDirectoryOpen}
|
|
183
|
+
toggleDirectory={toggleDirectory}
|
|
184
|
+
activeFileId={activeFileId}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
})
|
|
188
|
+
) : (
|
|
189
|
+
<div className="empty">
|
|
190
|
+
<div className="empty-text">
|
|
191
|
+
It looks like you don't have any files yet!
|
|
192
|
+
Click the "Create file" button above to
|
|
193
|
+
create your first file.
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
149
197
|
</div>
|
|
150
|
-
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
entity={entity}
|
|
160
|
-
renameFile={renameFile}
|
|
161
|
-
deleteFile={deleteFile}
|
|
162
|
-
renameDirectory={renameDirectory}
|
|
163
|
-
deleteDirectory={deleteDirectory}
|
|
164
|
-
handleFileClick={handleFileClick}
|
|
165
|
-
handleFileDoubleClick={
|
|
166
|
-
handleFileDoubleClick
|
|
167
|
-
}
|
|
168
|
-
isDirectoryOpen={isDirectoryOpen}
|
|
169
|
-
toggleDirectory={toggleDirectory}
|
|
170
|
-
activeFileId={activeFileId}
|
|
198
|
+
|
|
199
|
+
{enableConnectionStatus && (
|
|
200
|
+
<div className="connection-status">
|
|
201
|
+
{connected ? 'Connected' : 'Connection Lost'}
|
|
202
|
+
<div className="connection">
|
|
203
|
+
<div
|
|
204
|
+
className={`connection-status-indicator ${
|
|
205
|
+
connected ? 'connected' : 'disconnected'
|
|
206
|
+
}`}
|
|
171
207
|
/>
|
|
172
|
-
);
|
|
173
|
-
})
|
|
174
|
-
) : (
|
|
175
|
-
<div className="empty">
|
|
176
|
-
<div className="empty-text">
|
|
177
|
-
It looks like you don't have any files yet!
|
|
178
|
-
Click the "Create file" button above to create
|
|
179
|
-
your first file.
|
|
180
208
|
</div>
|
|
181
209
|
</div>
|
|
182
210
|
)}
|
|
183
211
|
</div>
|
|
184
|
-
|
|
185
|
-
{enableConnectionStatus && (
|
|
186
|
-
<div className="connection-status">
|
|
187
|
-
{connected ? 'Connected' : 'Connection Lost'}
|
|
188
|
-
<div className="connection">
|
|
189
|
-
<div
|
|
190
|
-
className={`connection-status-indicator ${
|
|
191
|
-
connected ? 'connected' : 'disconnected'
|
|
192
|
-
}`}
|
|
193
|
-
/>
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
)}
|
|
197
212
|
</div>
|
|
198
213
|
);
|
|
199
214
|
};
|
|
@@ -154,18 +154,17 @@
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
+
}
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
159
|
+
.drop-zone {
|
|
160
|
+
border: 3px solid #0a1731;
|
|
161
|
+
width: auto;
|
|
162
|
+
color: #bdc7dc;
|
|
163
|
+
text-align: center;
|
|
164
|
+
font-family: var(--vzcode-font-family);
|
|
165
|
+
font-weight: 500;
|
|
166
|
+
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
168
|
+
.drop-zone.dragover {
|
|
169
|
+
border-color: #009639;
|
|
171
170
|
}
|
|
@@ -4,7 +4,7 @@ import './styles.scss';
|
|
|
4
4
|
|
|
5
5
|
const debug = false;
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const useDragAndDrop = () => {
|
|
8
8
|
const [isDragOver, setIsDragOver] = useState(false);
|
|
9
9
|
const { createFile } = useContext(VZCodeContext);
|
|
10
10
|
|
|
@@ -60,15 +60,11 @@ export const DragAndDrop = () => {
|
|
|
60
60
|
[createFile],
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
>
|
|
71
|
-
Drag files here
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
63
|
+
return {
|
|
64
|
+
isDragOver,
|
|
65
|
+
handleDragEnter,
|
|
66
|
+
handleDragOver,
|
|
67
|
+
handleDragLeave,
|
|
68
|
+
handleDrop,
|
|
69
|
+
};
|
|
74
70
|
};
|
|
@@ -75,20 +75,30 @@ export const useFileCRUD = ({
|
|
|
75
75
|
oldName: string,
|
|
76
76
|
newName: string,
|
|
77
77
|
) => {
|
|
78
|
+
console.log(path);
|
|
79
|
+
console.log(oldName);
|
|
78
80
|
submitOperation((document: VZCodeContent) => {
|
|
79
81
|
const updatedFiles = Object.keys(
|
|
80
82
|
document.files,
|
|
81
83
|
).reduce((acc, key) => {
|
|
82
84
|
const file = document.files[key];
|
|
83
85
|
const fileName = file.name;
|
|
84
|
-
if
|
|
85
|
-
|
|
86
|
+
//See if it's actually in directory
|
|
87
|
+
if (fileName.includes(path + '/')) {
|
|
88
|
+
//Create New Name for System
|
|
89
|
+
const pathPart = fileName.substring(
|
|
90
|
+
0,
|
|
91
|
+
fileName.indexOf(path) + path.length,
|
|
92
|
+
);
|
|
93
|
+
const oldNamePos =
|
|
94
|
+
pathPart.lastIndexOf(oldName);
|
|
86
95
|
const fileNewName =
|
|
87
96
|
fileName.substring(0, oldNamePos) +
|
|
88
97
|
newName +
|
|
89
98
|
fileName.substring(
|
|
90
99
|
oldNamePos + oldName.length,
|
|
91
100
|
);
|
|
101
|
+
//Return with new names
|
|
92
102
|
acc[key] = { ...file, name: fileNewName };
|
|
93
103
|
} else {
|
|
94
104
|
acc[key] = file;
|
|
@@ -260,6 +260,10 @@ onmessage = async ({ data }) => {
|
|
|
260
260
|
// Not valid in TypeScript, but common in JavaScript.
|
|
261
261
|
const LINT_ERROR_CODE_NON_EXISTENT_PROPERTY = 2339;
|
|
262
262
|
|
|
263
|
+
// "Type 'Set<unknown>' can only be iterated through when using the '--downlevelIteration'
|
|
264
|
+
// flag or with a '--target' of 'es2015' or higher."
|
|
265
|
+
const LINT_ERROR_CODE_ITERATED_THROUGH = 2802;
|
|
266
|
+
|
|
263
267
|
if (debug) {
|
|
264
268
|
console.log(tsErrors);
|
|
265
269
|
}
|
|
@@ -271,7 +275,8 @@ onmessage = async ({ data }) => {
|
|
|
271
275
|
error.code !== LINT_ERROR_CODE_ANY_TYPE &&
|
|
272
276
|
error.code !== LINT_ERROR_CODE_ANY_TYPE_KEYS &&
|
|
273
277
|
error.code !==
|
|
274
|
-
LINT_ERROR_CODE_NON_EXISTENT_PROPERTY
|
|
278
|
+
LINT_ERROR_CODE_NON_EXISTENT_PROPERTY &&
|
|
279
|
+
error.code !== LINT_ERROR_CODE_ITERATED_THROUGH,
|
|
275
280
|
);
|
|
276
281
|
// }
|
|
277
282
|
tsErrors = convertToCodeMirrorDiagnostic(tsErrors);
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
} from './featureFlags.js';
|
|
9
9
|
import createIgnore from 'ignore';
|
|
10
10
|
import { ignoreFilePattern, baseIgnore } from './config.js';
|
|
11
|
-
|
|
12
|
-
const isDirectory = (file) => file.endsWith('/');
|
|
11
|
+
import { isDirectory } from './isDirectory.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* @param {string} fullPath - absolut path of the workspace root
|
package/src/server/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import bodyParser from 'body-parser';
|
|
|
14
14
|
import { json1Presence } from '../ot.js';
|
|
15
15
|
import { computeInitialDocument } from './computeInitialDocument.js';
|
|
16
16
|
import { handleAIAssist } from './handleAIAssist.js';
|
|
17
|
+
import { isDirectory } from './isDirectory.js';
|
|
17
18
|
|
|
18
19
|
// The time in milliseconds by which auto-saving is debounced.
|
|
19
20
|
const autoSaveDebounceTimeMS = 800;
|
|
@@ -114,6 +115,9 @@ const save = () => {
|
|
|
114
115
|
...currentDocument.files,
|
|
115
116
|
...previousDocument.files,
|
|
116
117
|
});
|
|
118
|
+
|
|
119
|
+
const directoriesToDelete = [];
|
|
120
|
+
|
|
117
121
|
for (const key of allKeys) {
|
|
118
122
|
const previous = previousDocument.files[key];
|
|
119
123
|
const current = currentDocument.files[key];
|
|
@@ -125,9 +129,69 @@ const save = () => {
|
|
|
125
129
|
fs.writeFileSync(current.name, current.text);
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
// // Handle renaming files.
|
|
133
|
+
// if (previous.name !== current.name) {
|
|
134
|
+
|
|
135
|
+
// const previousPath = previous.name.split('/');
|
|
136
|
+
// const currentPath = current.name.split('/');
|
|
137
|
+
|
|
138
|
+
// // - If the path is length 1 for previous and current,
|
|
139
|
+
// // then this should be true.
|
|
140
|
+
// // - If the path length is the sane for previous and current,
|
|
141
|
+
// // AND all the entries leading up to the last one are the same
|
|
142
|
+
// // between previous and current, AND the last entry in the arrays
|
|
143
|
+
// // (the file name itself) is different between previous and current
|
|
144
|
+
// const onlyFileNameChanged =
|
|
145
|
+
// (previousPath.length === 1 &&
|
|
146
|
+
// currentPath.length === 1) ||
|
|
147
|
+
// (previousPath.length === currentPath.length &&
|
|
148
|
+
// previousPath
|
|
149
|
+
// .slice(0, -1)
|
|
150
|
+
// .every(
|
|
151
|
+
// (val, index) => val === currentPath[index],
|
|
152
|
+
// ) &&
|
|
153
|
+
// previousPath.at(-1) !== currentPath.at(-1));
|
|
154
|
+
|
|
155
|
+
// // This logic works if only the file name itself changes.
|
|
156
|
+
// if (onlyFileNameChanged) {
|
|
157
|
+
// fs.renameSync(previous.name, current.name);
|
|
158
|
+
// }
|
|
159
|
+
// {
|
|
160
|
+
// // If we get here, then the directory may have been renamed,
|
|
161
|
+
// // or the file has been moved between directories.
|
|
162
|
+
// // If we get here, then the directory may have been renamed,
|
|
163
|
+
// // or the file has been moved between directories.
|
|
164
|
+
// const newDir = path.dirname(current.name);
|
|
165
|
+
|
|
166
|
+
// // Check if the new directory exists, if not, create it
|
|
167
|
+
// if (!fs.existsSync(newDir)) {
|
|
168
|
+
// fs.mkdirSync(newDir, { recursive: true });
|
|
169
|
+
// }
|
|
170
|
+
|
|
171
|
+
// // Move the file to the new directory
|
|
172
|
+
// fs.renameSync(previous.name, current.name);
|
|
173
|
+
// }
|
|
174
|
+
// }
|
|
128
175
|
// Handle renaming files.
|
|
129
176
|
if (previous.name !== current.name) {
|
|
130
|
-
|
|
177
|
+
if (isDirectory(previous.name)) {
|
|
178
|
+
// If the directory itself is being renamed,
|
|
179
|
+
// Phase I: Ignore it, and get the files moved
|
|
180
|
+
// Phase II: Keep track of these, and delete them after
|
|
181
|
+
// all the files moved.
|
|
182
|
+
// directoriesToDelete.push(previous.name)
|
|
183
|
+
directoriesToDelete.push(previous.name);
|
|
184
|
+
} else {
|
|
185
|
+
const newDir = path.dirname(current.name);
|
|
186
|
+
|
|
187
|
+
// Check if the new directory exists, if not, create it
|
|
188
|
+
if (!fs.existsSync(newDir)) {
|
|
189
|
+
fs.mkdirSync(newDir, { recursive: true });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Move the file to the new directory
|
|
193
|
+
fs.renameSync(previous.name, current.name);
|
|
194
|
+
}
|
|
131
195
|
}
|
|
132
196
|
}
|
|
133
197
|
|
|
@@ -158,6 +222,23 @@ const save = () => {
|
|
|
158
222
|
fs.writeFileSync(current.name, current.text);
|
|
159
223
|
}
|
|
160
224
|
}
|
|
225
|
+
// TODO deleted all directories under directoriesToDelete
|
|
226
|
+
|
|
227
|
+
for (const dir of directoriesToDelete) {
|
|
228
|
+
//Performs directory deletion.
|
|
229
|
+
fs.rm(
|
|
230
|
+
dir,
|
|
231
|
+
{
|
|
232
|
+
recursive: true, //Makes sure that all files in directory are deleted.
|
|
233
|
+
},
|
|
234
|
+
(error) => {
|
|
235
|
+
if (error) {
|
|
236
|
+
console.log(error);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
161
242
|
previousDocument = currentDocument;
|
|
162
243
|
};
|
|
163
244
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isDirectory = (file) => file.endsWith('/');
|