@cocreate/file 1.7.1 → 1.7.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.
- package/CHANGELOG.md +8 -0
- package/CoCreate.config.js +4 -5
- package/package.json +5 -5
- package/src/client.js +7 -7
- package/src/server.js +27 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.7.2](https://github.com/CoCreate-app/CoCreate-file/compare/v1.7.1...v1.7.2) (2023-09-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Add path and pathname ([8dda8ed](https://github.com/CoCreate-app/CoCreate-file/commit/8dda8edb80c4dca324d6250ef5eb2a8588aa73ab))
|
|
7
|
+
* Update CoCreate depndencies to latest versions ([955f3b2](https://github.com/CoCreate-app/CoCreate-file/commit/955f3b2567d6cbb288c25e93f4dd8fa9adc96a27))
|
|
8
|
+
|
|
1
9
|
## [1.7.1](https://github.com/CoCreate-app/CoCreate-file/compare/v1.7.0...v1.7.1) (2023-09-17)
|
|
2
10
|
|
|
3
11
|
|
package/CoCreate.config.js
CHANGED
|
@@ -8,17 +8,16 @@ module.exports = {
|
|
|
8
8
|
"object": {
|
|
9
9
|
"_id": "61a12db2a8b6b4001a9f5a2e",
|
|
10
10
|
"name": "index.html",
|
|
11
|
-
"path": "/docs/file/
|
|
11
|
+
"path": "/docs/file/",
|
|
12
|
+
"pathname": "/docs/file/index.html",
|
|
12
13
|
"src": "{{./docs/index.html}}",
|
|
13
14
|
"host": [
|
|
14
15
|
"*",
|
|
15
16
|
"general.cocreate.app"
|
|
16
17
|
],
|
|
17
|
-
"directory": "
|
|
18
|
-
"parentDirectory": "{{parentDirectory}}",
|
|
18
|
+
"directory": "file",
|
|
19
19
|
"content-type": "{{content-type}}",
|
|
20
|
-
"public": "true"
|
|
21
|
-
"website_id": "644d4bff8036fb9d1d1fd69c"
|
|
20
|
+
"public": "true"
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/file",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "A headless file uploader that uses HTML5 attributes for customization. Allows easy upload of files to server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"webpack-log": "^3.0.1"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cocreate/actions": "^1.11.
|
|
63
|
-
"@cocreate/config": "^1.5.
|
|
64
|
-
"@cocreate/render": "^1.27.
|
|
65
|
-
"@cocreate/utils": "^1.24.
|
|
62
|
+
"@cocreate/actions": "^1.11.1",
|
|
63
|
+
"@cocreate/config": "^1.5.1",
|
|
64
|
+
"@cocreate/render": "^1.27.2",
|
|
65
|
+
"@cocreate/utils": "^1.24.1"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/client.js
CHANGED
|
@@ -117,8 +117,8 @@ async function fileEvent(event) {
|
|
|
117
117
|
files[i] = await readFile(files[i])
|
|
118
118
|
|
|
119
119
|
files[i].directory = handle.directory || '/'
|
|
120
|
-
files[i].
|
|
121
|
-
files[i].
|
|
120
|
+
files[i].path = handle.path || '/'
|
|
121
|
+
files[i].pathname = handle.pathname || '/' + handle.name
|
|
122
122
|
files[i]['content-type'] = files[i].type
|
|
123
123
|
files[i].input = input
|
|
124
124
|
files[i].id = await getFileId(files[i])
|
|
@@ -159,9 +159,9 @@ async function fileEvent(event) {
|
|
|
159
159
|
async function getDirectoryHandles(handle, name) {
|
|
160
160
|
let handles = [];
|
|
161
161
|
for await (const entry of handle.values()) {
|
|
162
|
-
entry.directory =
|
|
163
|
-
entry.
|
|
164
|
-
entry.
|
|
162
|
+
entry.directory = name
|
|
163
|
+
entry.path = '/' + name + '/'
|
|
164
|
+
entry.pathname = '/' + name + '/' + entry.name
|
|
165
165
|
if (!entry.webkitRelativePath)
|
|
166
166
|
entry.webkitRelativePath = name
|
|
167
167
|
|
|
@@ -631,8 +631,8 @@ async function create(directory, type, name, src = "") {
|
|
|
631
631
|
}
|
|
632
632
|
|
|
633
633
|
if (directory.input) {
|
|
634
|
-
file.directory = directory.
|
|
635
|
-
file.
|
|
634
|
+
file.directory = directory.name
|
|
635
|
+
file.pathname = directory.path + '/' + file.name
|
|
636
636
|
file.path = directory.path + '/' + file.name
|
|
637
637
|
file.input = directory.input
|
|
638
638
|
file.handle = handle
|
package/src/server.js
CHANGED
|
@@ -121,7 +121,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
crud.socket.create(config)
|
|
124
|
-
config.
|
|
124
|
+
// config.broadcastBrowser = false
|
|
125
125
|
|
|
126
126
|
if (config.email && config.password) {
|
|
127
127
|
let request = {
|
|
@@ -195,14 +195,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
195
195
|
let name = file
|
|
196
196
|
let source = ''
|
|
197
197
|
let directoryName = parentDirectory || '';
|
|
198
|
-
|
|
199
|
-
let index = parentDirectoryOnly.lastIndexOf('/') + 1
|
|
200
|
-
if (parentDirectoryOnly && index) {
|
|
201
|
-
parentDirectoryOnly = parentDirectoryOnly.substring(index)
|
|
202
|
-
}
|
|
198
|
+
|
|
203
199
|
const fileExtension = path.extname(file);
|
|
204
200
|
let mimeType = mimeTypes[fileExtension]
|
|
205
|
-
let pathName = '';
|
|
206
201
|
|
|
207
202
|
if (!directoryName && directory.object && directory.object.directory)
|
|
208
203
|
directoryName = directory.object.directory.replace('{{directory}}', '').trim()
|
|
@@ -211,12 +206,23 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
211
206
|
|
|
212
207
|
if (exclude && exclude.includes(directoryName)) continue
|
|
213
208
|
|
|
209
|
+
let Path = '';
|
|
214
210
|
if (directoryName.endsWith("/"))
|
|
215
|
-
|
|
211
|
+
Path = directoryName
|
|
216
212
|
else if (directoryName)
|
|
217
|
-
|
|
213
|
+
Path = directoryName + '/'
|
|
218
214
|
else
|
|
219
|
-
|
|
215
|
+
Path = '/'
|
|
216
|
+
|
|
217
|
+
let pathname = Path + name;
|
|
218
|
+
|
|
219
|
+
let folder = ''
|
|
220
|
+
if (Path === '/')
|
|
221
|
+
folder = Path
|
|
222
|
+
else {
|
|
223
|
+
let result = Path.split('/');
|
|
224
|
+
folder = result[result.length - 2];
|
|
225
|
+
}
|
|
220
226
|
|
|
221
227
|
if (isDirectory)
|
|
222
228
|
mimeType = "text/directory"
|
|
@@ -226,9 +232,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
226
232
|
let values = {
|
|
227
233
|
'{{name}}': name,
|
|
228
234
|
'{{source}}': source,
|
|
229
|
-
'{{directory}}':
|
|
230
|
-
'{{
|
|
231
|
-
'{{
|
|
235
|
+
'{{directory}}': folder,
|
|
236
|
+
'{{path}}': Path,
|
|
237
|
+
'{{pathname}}': pathname,
|
|
232
238
|
'{{content-type}}': mimeType
|
|
233
239
|
}
|
|
234
240
|
|
|
@@ -239,10 +245,10 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
239
245
|
object.src = "{{source}}"
|
|
240
246
|
if (!object.directory)
|
|
241
247
|
object.directory = "/{{directory}}"
|
|
242
|
-
if (!object.parentDirectory)
|
|
243
|
-
object.parentDirectory = "{{parentDirectory}}"
|
|
244
248
|
if (!object.path)
|
|
245
249
|
object.path = "{{path}}"
|
|
250
|
+
if (!object.pathname)
|
|
251
|
+
object.pathname = "{{pathname}}"
|
|
246
252
|
if (!object["content-type"])
|
|
247
253
|
object["content-type"] = '{{content-type}}'
|
|
248
254
|
if (!object.public && object.public != false && object.public != 'false')
|
|
@@ -259,7 +265,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
259
265
|
if (variables) {
|
|
260
266
|
for (let variable of variables) {
|
|
261
267
|
if (variable == '{{directory}}') {
|
|
262
|
-
if (
|
|
268
|
+
if (folder)
|
|
263
269
|
newObject.object[key] = values[variable]
|
|
264
270
|
else
|
|
265
271
|
newObject.object[key] = newObject.object[key].replace(variable, '');
|
|
@@ -276,21 +282,21 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
276
282
|
|
|
277
283
|
if (!newObject.object._id)
|
|
278
284
|
newObject.$filter = {
|
|
279
|
-
query: [{ key: '
|
|
285
|
+
query: [{ key: 'pathname', value: pathname, operator: '$or' }]
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
response = await runStore(newObject);
|
|
283
289
|
if (response.error)
|
|
284
290
|
errorLog.push(response.error)
|
|
285
291
|
|
|
286
|
-
if (isDirectory &&
|
|
292
|
+
if (isDirectory && pathname) {
|
|
287
293
|
let newEntry
|
|
288
294
|
if (entry.endsWith("/"))
|
|
289
295
|
newEntry = entry + name
|
|
290
296
|
else
|
|
291
297
|
newEntry = entry + '/' + name
|
|
292
298
|
|
|
293
|
-
await runFiles(directory, newEntry, exclude,
|
|
299
|
+
await runFiles(directory, newEntry, exclude, pathname)
|
|
294
300
|
}
|
|
295
301
|
}
|
|
296
302
|
if (errorLog.length)
|
|
@@ -377,9 +383,9 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
let data = { array, object }
|
|
380
|
-
if (!object._id && object.
|
|
386
|
+
if (!object._id && object.pathname)
|
|
381
387
|
data.$filter = {
|
|
382
|
-
query: [{ key: '
|
|
388
|
+
query: [{ key: 'pathname', value: object.pathname, operator: '$or' }]
|
|
383
389
|
}
|
|
384
390
|
|
|
385
391
|
if (match.length && isMatch)
|