@yassidev/nuxt-directus 0.0.14 → 0.0.16
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/module.d.mts +4 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +125 -76
- package/package.json +17 -17
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { defineNuxtModule, useLogger, updateRuntimeConfig, hasNuxtModule, createResolver, addImportsDir, addImports, addServerImportsDir, addServerImports, addTemplate, addTypeTemplate } from 'nuxt/kit';
|
|
2
2
|
import { generateDirectusTypes } from 'directus-sdk-typegen';
|
|
3
3
|
import { fetchTranslations, syncTranslations } from '../dist/runtime/server.js';
|
|
4
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
4
|
+
import { unwatchFile, watchFile, watch as watch$1, stat as stat$1, readFileSync, existsSync } from 'node:fs';
|
|
5
5
|
import { NAME } from '../dist/runtime/constants.js';
|
|
6
|
+
import * as sp from 'node:path';
|
|
6
7
|
import { resolve, join, relative, sep } from 'node:path';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { EventEmitter } from 'events';
|
|
10
|
-
import * as sysPath from 'path';
|
|
11
|
-
import { lstat, stat, readdir, realpath } from 'node:fs/promises';
|
|
8
|
+
import { EventEmitter } from 'node:events';
|
|
9
|
+
import { lstat, stat, readdir, realpath, open } from 'node:fs/promises';
|
|
12
10
|
import { Readable } from 'node:stream';
|
|
13
|
-
import { type } from 'os';
|
|
11
|
+
import { type } from 'node:os';
|
|
14
12
|
|
|
15
13
|
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
16
14
|
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
@@ -155,6 +153,20 @@ const normalizeFilter = (filter) => {
|
|
|
155
153
|
};
|
|
156
154
|
/** Readable readdir stream, emitting new files as they're being listed. */
|
|
157
155
|
class ReaddirpStream extends Readable {
|
|
156
|
+
parents;
|
|
157
|
+
reading;
|
|
158
|
+
parent;
|
|
159
|
+
_stat;
|
|
160
|
+
_maxDepth;
|
|
161
|
+
_wantsDir;
|
|
162
|
+
_wantsFile;
|
|
163
|
+
_wantsEverything;
|
|
164
|
+
_root;
|
|
165
|
+
_isDirent;
|
|
166
|
+
_statsProp;
|
|
167
|
+
_rdOptions;
|
|
168
|
+
_fileFilter;
|
|
169
|
+
_directoryFilter;
|
|
158
170
|
constructor(options = {}) {
|
|
159
171
|
super({
|
|
160
172
|
objectMode: true,
|
|
@@ -173,7 +185,8 @@ class ReaddirpStream extends Readable {
|
|
|
173
185
|
else {
|
|
174
186
|
this._stat = statMethod;
|
|
175
187
|
}
|
|
176
|
-
this._maxDepth =
|
|
188
|
+
this._maxDepth =
|
|
189
|
+
opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
177
190
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
178
191
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
179
192
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -363,7 +376,7 @@ const EVENTS = {
|
|
|
363
376
|
};
|
|
364
377
|
const EV = EVENTS;
|
|
365
378
|
const THROTTLE_MODE_WATCH = 'watch';
|
|
366
|
-
const statMethods = { lstat
|
|
379
|
+
const statMethods = { lstat, stat };
|
|
367
380
|
const KEY_LISTENERS = 'listeners';
|
|
368
381
|
const KEY_ERR = 'errHandlers';
|
|
369
382
|
const KEY_RAW = 'rawEmitters';
|
|
@@ -403,7 +416,7 @@ const binaryExtensions = new Set([
|
|
|
403
416
|
'xmind', 'xpi', 'xpm', 'xwd', 'xz',
|
|
404
417
|
'z', 'zip', 'zipx',
|
|
405
418
|
]);
|
|
406
|
-
const isBinaryPath = (filePath) => binaryExtensions.has(
|
|
419
|
+
const isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
|
|
407
420
|
// TODO: emit errors properly. Example: EMFILE on Macos.
|
|
408
421
|
const foreach = (val, fn) => {
|
|
409
422
|
if (val instanceof Set) {
|
|
@@ -456,7 +469,7 @@ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
|
456
469
|
// emit based on events occurring for files from a directory's watcher in
|
|
457
470
|
// case the file's watcher misses it (and rely on throttling to de-dupe)
|
|
458
471
|
if (evPath && path !== evPath) {
|
|
459
|
-
fsWatchBroadcast(
|
|
472
|
+
fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
460
473
|
}
|
|
461
474
|
};
|
|
462
475
|
try {
|
|
@@ -627,6 +640,8 @@ const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
|
627
640
|
* @mixin
|
|
628
641
|
*/
|
|
629
642
|
class NodeFsHandler {
|
|
643
|
+
fsw;
|
|
644
|
+
_boundHandleError;
|
|
630
645
|
constructor(fsW) {
|
|
631
646
|
this.fsw = fsW;
|
|
632
647
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
@@ -639,11 +654,11 @@ class NodeFsHandler {
|
|
|
639
654
|
*/
|
|
640
655
|
_watchWithNodeFs(path, listener) {
|
|
641
656
|
const opts = this.fsw.options;
|
|
642
|
-
const directory =
|
|
643
|
-
const basename =
|
|
657
|
+
const directory = sp.dirname(path);
|
|
658
|
+
const basename = sp.basename(path);
|
|
644
659
|
const parent = this.fsw._getWatchedDir(directory);
|
|
645
660
|
parent.add(basename);
|
|
646
|
-
const absolutePath =
|
|
661
|
+
const absolutePath = sp.resolve(path);
|
|
647
662
|
const options = {
|
|
648
663
|
persistent: opts.persistent,
|
|
649
664
|
};
|
|
@@ -675,8 +690,8 @@ class NodeFsHandler {
|
|
|
675
690
|
if (this.fsw.closed) {
|
|
676
691
|
return;
|
|
677
692
|
}
|
|
678
|
-
const dirname =
|
|
679
|
-
const basename =
|
|
693
|
+
const dirname = sp.dirname(file);
|
|
694
|
+
const basename = sp.basename(file);
|
|
680
695
|
const parent = this.fsw._getWatchedDir(dirname);
|
|
681
696
|
// stats is always present
|
|
682
697
|
let prevStats = stats;
|
|
@@ -688,7 +703,7 @@ class NodeFsHandler {
|
|
|
688
703
|
return;
|
|
689
704
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
690
705
|
try {
|
|
691
|
-
const newStats = await stat
|
|
706
|
+
const newStats = await stat(file);
|
|
692
707
|
if (this.fsw.closed)
|
|
693
708
|
return;
|
|
694
709
|
// Check that change event was not fired because of changed only accessTime.
|
|
@@ -753,7 +768,7 @@ class NodeFsHandler {
|
|
|
753
768
|
this.fsw._incrReadyCount();
|
|
754
769
|
let linkPath;
|
|
755
770
|
try {
|
|
756
|
-
linkPath = await realpath
|
|
771
|
+
linkPath = await realpath(path);
|
|
757
772
|
}
|
|
758
773
|
catch (e) {
|
|
759
774
|
this.fsw._emitReady();
|
|
@@ -783,8 +798,9 @@ class NodeFsHandler {
|
|
|
783
798
|
}
|
|
784
799
|
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
785
800
|
// Normalize the directory name on Windows
|
|
786
|
-
directory =
|
|
787
|
-
|
|
801
|
+
directory = sp.join(directory, '');
|
|
802
|
+
const throttleKey = target ? `${directory}:${target}` : directory;
|
|
803
|
+
throttler = this.fsw._throttle('readdir', throttleKey, 1000);
|
|
788
804
|
if (!throttler)
|
|
789
805
|
return;
|
|
790
806
|
const previous = this.fsw._getWatchedDir(wh.path);
|
|
@@ -802,7 +818,7 @@ class NodeFsHandler {
|
|
|
802
818
|
return;
|
|
803
819
|
}
|
|
804
820
|
const item = entry.path;
|
|
805
|
-
let path =
|
|
821
|
+
let path = sp.join(directory, item);
|
|
806
822
|
current.add(item);
|
|
807
823
|
if (entry.stats.isSymbolicLink() &&
|
|
808
824
|
(await this._handleSymlink(entry, directory, path, item))) {
|
|
@@ -818,7 +834,7 @@ class NodeFsHandler {
|
|
|
818
834
|
if (item === target || (!target && !previous.has(item))) {
|
|
819
835
|
this.fsw._incrReadyCount();
|
|
820
836
|
// ensure relativeness of path is preserved in case of watcher reuse
|
|
821
|
-
path =
|
|
837
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
822
838
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
823
839
|
}
|
|
824
840
|
})
|
|
@@ -863,13 +879,13 @@ class NodeFsHandler {
|
|
|
863
879
|
* @returns closer for the watcher instance.
|
|
864
880
|
*/
|
|
865
881
|
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
866
|
-
const parentDir = this.fsw._getWatchedDir(
|
|
867
|
-
const tracked = parentDir.has(
|
|
882
|
+
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
883
|
+
const tracked = parentDir.has(sp.basename(dir));
|
|
868
884
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
869
885
|
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
870
886
|
}
|
|
871
887
|
// ensure dir is tracked (harmless if redundant)
|
|
872
|
-
parentDir.add(
|
|
888
|
+
parentDir.add(sp.basename(dir));
|
|
873
889
|
this.fsw._getWatchedDir(dir);
|
|
874
890
|
let throttler;
|
|
875
891
|
let closer;
|
|
@@ -921,8 +937,8 @@ class NodeFsHandler {
|
|
|
921
937
|
const follow = this.fsw.options.followSymlinks;
|
|
922
938
|
let closer;
|
|
923
939
|
if (stats.isDirectory()) {
|
|
924
|
-
const absPath =
|
|
925
|
-
const targetPath = follow ? await realpath
|
|
940
|
+
const absPath = sp.resolve(path);
|
|
941
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
926
942
|
if (this.fsw.closed)
|
|
927
943
|
return;
|
|
928
944
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -934,10 +950,10 @@ class NodeFsHandler {
|
|
|
934
950
|
}
|
|
935
951
|
}
|
|
936
952
|
else if (stats.isSymbolicLink()) {
|
|
937
|
-
const targetPath = follow ? await realpath
|
|
953
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
938
954
|
if (this.fsw.closed)
|
|
939
955
|
return;
|
|
940
|
-
const parent =
|
|
956
|
+
const parent = sp.dirname(wh.watchPath);
|
|
941
957
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
942
958
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
943
959
|
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
@@ -945,7 +961,7 @@ class NodeFsHandler {
|
|
|
945
961
|
return;
|
|
946
962
|
// preserve this symlink's target path
|
|
947
963
|
if (targetPath !== undefined) {
|
|
948
|
-
this.fsw._symlinkPaths.set(
|
|
964
|
+
this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
949
965
|
}
|
|
950
966
|
}
|
|
951
967
|
else {
|
|
@@ -972,7 +988,7 @@ const ONE_DOT = '.';
|
|
|
972
988
|
const TWO_DOTS = '..';
|
|
973
989
|
const STRING_TYPE = 'string';
|
|
974
990
|
const BACK_SLASH_RE = /\\/g;
|
|
975
|
-
const DOUBLE_SLASH_RE =
|
|
991
|
+
const DOUBLE_SLASH_RE = /\/\//g;
|
|
976
992
|
const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
977
993
|
const REPLACER_RE = /^\.[/\\]/;
|
|
978
994
|
function arrify(item) {
|
|
@@ -991,11 +1007,11 @@ function createPattern(matcher) {
|
|
|
991
1007
|
if (matcher.path === string)
|
|
992
1008
|
return true;
|
|
993
1009
|
if (matcher.recursive) {
|
|
994
|
-
const relative =
|
|
1010
|
+
const relative = sp.relative(matcher.path, string);
|
|
995
1011
|
if (!relative) {
|
|
996
1012
|
return false;
|
|
997
1013
|
}
|
|
998
|
-
return !relative.startsWith('..') && !
|
|
1014
|
+
return !relative.startsWith('..') && !sp.isAbsolute(relative);
|
|
999
1015
|
}
|
|
1000
1016
|
return false;
|
|
1001
1017
|
};
|
|
@@ -1005,14 +1021,12 @@ function createPattern(matcher) {
|
|
|
1005
1021
|
function normalizePath(path) {
|
|
1006
1022
|
if (typeof path !== 'string')
|
|
1007
1023
|
throw new Error('string expected');
|
|
1008
|
-
path =
|
|
1024
|
+
path = sp.normalize(path);
|
|
1009
1025
|
path = path.replace(/\\/g, '/');
|
|
1010
1026
|
let prepend = false;
|
|
1011
1027
|
if (path.startsWith('//'))
|
|
1012
1028
|
prepend = true;
|
|
1013
|
-
|
|
1014
|
-
while (path.match(DOUBLE_SLASH_RE))
|
|
1015
|
-
path = path.replace(DOUBLE_SLASH_RE, '/');
|
|
1029
|
+
path = path.replace(DOUBLE_SLASH_RE, '/');
|
|
1016
1030
|
if (prepend)
|
|
1017
1031
|
path = '/' + path;
|
|
1018
1032
|
return path;
|
|
@@ -1055,9 +1069,7 @@ const toUnix = (string) => {
|
|
|
1055
1069
|
if (str.startsWith(SLASH_SLASH)) {
|
|
1056
1070
|
prepend = true;
|
|
1057
1071
|
}
|
|
1058
|
-
|
|
1059
|
-
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
1060
|
-
}
|
|
1072
|
+
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
1061
1073
|
if (prepend) {
|
|
1062
1074
|
str = SLASH + str;
|
|
1063
1075
|
}
|
|
@@ -1065,27 +1077,30 @@ const toUnix = (string) => {
|
|
|
1065
1077
|
};
|
|
1066
1078
|
// Our version of upath.normalize
|
|
1067
1079
|
// TODO: this is not equal to path-normalize module - investigate why
|
|
1068
|
-
const normalizePathToUnix = (path) => toUnix(
|
|
1080
|
+
const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
|
|
1069
1081
|
// TODO: refactor
|
|
1070
1082
|
const normalizeIgnored = (cwd = '') => (path) => {
|
|
1071
1083
|
if (typeof path === 'string') {
|
|
1072
|
-
return normalizePathToUnix(
|
|
1084
|
+
return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
|
|
1073
1085
|
}
|
|
1074
1086
|
else {
|
|
1075
1087
|
return path;
|
|
1076
1088
|
}
|
|
1077
1089
|
};
|
|
1078
1090
|
const getAbsolutePath = (path, cwd) => {
|
|
1079
|
-
if (
|
|
1091
|
+
if (sp.isAbsolute(path)) {
|
|
1080
1092
|
return path;
|
|
1081
1093
|
}
|
|
1082
|
-
return
|
|
1094
|
+
return sp.join(cwd, path);
|
|
1083
1095
|
};
|
|
1084
1096
|
const EMPTY_SET = Object.freeze(new Set());
|
|
1085
1097
|
/**
|
|
1086
1098
|
* Directory entry.
|
|
1087
1099
|
*/
|
|
1088
1100
|
class DirEntry {
|
|
1101
|
+
path;
|
|
1102
|
+
_removeWatcher;
|
|
1103
|
+
items;
|
|
1089
1104
|
constructor(dir, removeWatcher) {
|
|
1090
1105
|
this.path = dir;
|
|
1091
1106
|
this._removeWatcher = removeWatcher;
|
|
@@ -1107,11 +1122,11 @@ class DirEntry {
|
|
|
1107
1122
|
return;
|
|
1108
1123
|
const dir = this.path;
|
|
1109
1124
|
try {
|
|
1110
|
-
await readdir
|
|
1125
|
+
await readdir(dir);
|
|
1111
1126
|
}
|
|
1112
1127
|
catch (err) {
|
|
1113
1128
|
if (this._removeWatcher) {
|
|
1114
|
-
this._removeWatcher(
|
|
1129
|
+
this._removeWatcher(sp.dirname(dir), sp.basename(dir));
|
|
1115
1130
|
}
|
|
1116
1131
|
}
|
|
1117
1132
|
}
|
|
@@ -1138,12 +1153,19 @@ class DirEntry {
|
|
|
1138
1153
|
const STAT_METHOD_F = 'stat';
|
|
1139
1154
|
const STAT_METHOD_L = 'lstat';
|
|
1140
1155
|
class WatchHelper {
|
|
1156
|
+
fsw;
|
|
1157
|
+
path;
|
|
1158
|
+
watchPath;
|
|
1159
|
+
fullWatchPath;
|
|
1160
|
+
dirParts;
|
|
1161
|
+
followSymlinks;
|
|
1162
|
+
statMethod;
|
|
1141
1163
|
constructor(path, follow, fsw) {
|
|
1142
1164
|
this.fsw = fsw;
|
|
1143
1165
|
const watchPath = path;
|
|
1144
1166
|
this.path = path = path.replace(REPLACER_RE, '');
|
|
1145
1167
|
this.watchPath = watchPath;
|
|
1146
|
-
this.fullWatchPath =
|
|
1168
|
+
this.fullWatchPath = sp.resolve(watchPath);
|
|
1147
1169
|
this.dirParts = [];
|
|
1148
1170
|
this.dirParts.forEach((parts) => {
|
|
1149
1171
|
if (parts.length > 1)
|
|
@@ -1153,7 +1175,7 @@ class WatchHelper {
|
|
|
1153
1175
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
1154
1176
|
}
|
|
1155
1177
|
entryPath(entry) {
|
|
1156
|
-
return
|
|
1178
|
+
return sp.join(this.watchPath, sp.relative(this.watchPath, entry.fullPath));
|
|
1157
1179
|
}
|
|
1158
1180
|
filterPath(entry) {
|
|
1159
1181
|
const { stats } = entry;
|
|
@@ -1176,6 +1198,24 @@ class WatchHelper {
|
|
|
1176
1198
|
* .on('add', path => log('File', path, 'was added'))
|
|
1177
1199
|
*/
|
|
1178
1200
|
class FSWatcher extends EventEmitter {
|
|
1201
|
+
closed;
|
|
1202
|
+
options;
|
|
1203
|
+
_closers;
|
|
1204
|
+
_ignoredPaths;
|
|
1205
|
+
_throttled;
|
|
1206
|
+
_streams;
|
|
1207
|
+
_symlinkPaths;
|
|
1208
|
+
_watched;
|
|
1209
|
+
_pendingWrites;
|
|
1210
|
+
_pendingUnlinks;
|
|
1211
|
+
_readyCount;
|
|
1212
|
+
_emitReady;
|
|
1213
|
+
_closePromise;
|
|
1214
|
+
_userIgnored;
|
|
1215
|
+
_readyEmitted;
|
|
1216
|
+
_emitRaw;
|
|
1217
|
+
_boundRemove;
|
|
1218
|
+
_nodeFsHandler;
|
|
1179
1219
|
// Not indenting methods for history sake; for now.
|
|
1180
1220
|
constructor(_opts = {}) {
|
|
1181
1221
|
super();
|
|
@@ -1309,7 +1349,7 @@ class FSWatcher extends EventEmitter {
|
|
|
1309
1349
|
return;
|
|
1310
1350
|
results.forEach((item) => {
|
|
1311
1351
|
if (item)
|
|
1312
|
-
this.add(
|
|
1352
|
+
this.add(sp.dirname(item), sp.basename(_origAdd || item));
|
|
1313
1353
|
});
|
|
1314
1354
|
});
|
|
1315
1355
|
return this;
|
|
@@ -1324,10 +1364,10 @@ class FSWatcher extends EventEmitter {
|
|
|
1324
1364
|
const { cwd } = this.options;
|
|
1325
1365
|
paths.forEach((path) => {
|
|
1326
1366
|
// convert to absolute path unless relative path already matches
|
|
1327
|
-
if (!
|
|
1367
|
+
if (!sp.isAbsolute(path) && !this._closers.has(path)) {
|
|
1328
1368
|
if (cwd)
|
|
1329
|
-
path =
|
|
1330
|
-
path =
|
|
1369
|
+
path = sp.join(cwd, path);
|
|
1370
|
+
path = sp.resolve(path);
|
|
1331
1371
|
}
|
|
1332
1372
|
this._closePath(path);
|
|
1333
1373
|
this._addIgnoredPath(path);
|
|
@@ -1381,7 +1421,7 @@ class FSWatcher extends EventEmitter {
|
|
|
1381
1421
|
getWatched() {
|
|
1382
1422
|
const watchList = {};
|
|
1383
1423
|
this._watched.forEach((entry, dir) => {
|
|
1384
|
-
const key = this.options.cwd ?
|
|
1424
|
+
const key = this.options.cwd ? sp.relative(this.options.cwd, dir) : dir;
|
|
1385
1425
|
const index = key || ONE_DOT;
|
|
1386
1426
|
watchList[index] = entry.getChildren().sort();
|
|
1387
1427
|
});
|
|
@@ -1407,9 +1447,9 @@ class FSWatcher extends EventEmitter {
|
|
|
1407
1447
|
return;
|
|
1408
1448
|
const opts = this.options;
|
|
1409
1449
|
if (isWindows)
|
|
1410
|
-
path =
|
|
1450
|
+
path = sp.normalize(path);
|
|
1411
1451
|
if (opts.cwd)
|
|
1412
|
-
path =
|
|
1452
|
+
path = sp.relative(opts.cwd, path);
|
|
1413
1453
|
const args = [path];
|
|
1414
1454
|
if (stats != null)
|
|
1415
1455
|
args.push(stats);
|
|
@@ -1465,10 +1505,10 @@ class FSWatcher extends EventEmitter {
|
|
|
1465
1505
|
if (opts.alwaysStat &&
|
|
1466
1506
|
stats === undefined &&
|
|
1467
1507
|
(event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
1468
|
-
const fullPath = opts.cwd ?
|
|
1508
|
+
const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
|
|
1469
1509
|
let stats;
|
|
1470
1510
|
try {
|
|
1471
|
-
stats = await stat
|
|
1511
|
+
stats = await stat(fullPath);
|
|
1472
1512
|
}
|
|
1473
1513
|
catch (err) {
|
|
1474
1514
|
// do nothing
|
|
@@ -1548,13 +1588,13 @@ class FSWatcher extends EventEmitter {
|
|
|
1548
1588
|
const pollInterval = awf.pollInterval;
|
|
1549
1589
|
let timeoutHandler;
|
|
1550
1590
|
let fullPath = path;
|
|
1551
|
-
if (this.options.cwd && !
|
|
1552
|
-
fullPath =
|
|
1591
|
+
if (this.options.cwd && !sp.isAbsolute(path)) {
|
|
1592
|
+
fullPath = sp.join(this.options.cwd, path);
|
|
1553
1593
|
}
|
|
1554
1594
|
const now = new Date();
|
|
1555
1595
|
const writes = this._pendingWrites;
|
|
1556
1596
|
function awaitWriteFinishFn(prevStat) {
|
|
1557
|
-
stat$
|
|
1597
|
+
stat$1(fullPath, (err, curStat) => {
|
|
1558
1598
|
if (err || !writes.has(path)) {
|
|
1559
1599
|
if (err && err.code !== 'ENOENT')
|
|
1560
1600
|
awfEmit(err);
|
|
@@ -1620,7 +1660,7 @@ class FSWatcher extends EventEmitter {
|
|
|
1620
1660
|
* @param directory path of the directory
|
|
1621
1661
|
*/
|
|
1622
1662
|
_getWatchedDir(directory) {
|
|
1623
|
-
const dir =
|
|
1663
|
+
const dir = sp.resolve(directory);
|
|
1624
1664
|
if (!this._watched.has(dir))
|
|
1625
1665
|
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
1626
1666
|
return this._watched.get(dir);
|
|
@@ -1646,8 +1686,8 @@ class FSWatcher extends EventEmitter {
|
|
|
1646
1686
|
// if what is being deleted is a directory, get that directory's paths
|
|
1647
1687
|
// for recursive deleting and cleaning of watched object
|
|
1648
1688
|
// if it is not a directory, nestedDirectoryChildren will be empty array
|
|
1649
|
-
const path =
|
|
1650
|
-
const fullPath =
|
|
1689
|
+
const path = sp.join(directory, item);
|
|
1690
|
+
const fullPath = sp.resolve(path);
|
|
1651
1691
|
isDirectory =
|
|
1652
1692
|
isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
1653
1693
|
// prevent duplicate handling in case of arriving here nearly simultaneously
|
|
@@ -1679,7 +1719,7 @@ class FSWatcher extends EventEmitter {
|
|
|
1679
1719
|
// If we wait for this file to be fully written, cancel the wait.
|
|
1680
1720
|
let relPath = path;
|
|
1681
1721
|
if (this.options.cwd)
|
|
1682
|
-
relPath =
|
|
1722
|
+
relPath = sp.relative(this.options.cwd, path);
|
|
1683
1723
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1684
1724
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
1685
1725
|
if (event === EVENTS.ADD)
|
|
@@ -1700,8 +1740,8 @@ class FSWatcher extends EventEmitter {
|
|
|
1700
1740
|
*/
|
|
1701
1741
|
_closePath(path) {
|
|
1702
1742
|
this._closeFile(path);
|
|
1703
|
-
const dir =
|
|
1704
|
-
this._getWatchedDir(dir).remove(
|
|
1743
|
+
const dir = sp.dirname(path);
|
|
1744
|
+
this._getWatchedDir(dir).remove(sp.basename(path));
|
|
1705
1745
|
}
|
|
1706
1746
|
/**
|
|
1707
1747
|
* Closes only file-specific watchers
|
|
@@ -1755,9 +1795,9 @@ function watch(paths, options = {}) {
|
|
|
1755
1795
|
watcher.add(paths);
|
|
1756
1796
|
return watcher;
|
|
1757
1797
|
}
|
|
1758
|
-
const chokidar = { watch, FSWatcher };
|
|
1798
|
+
const chokidar = { watch: watch, FSWatcher: FSWatcher };
|
|
1759
1799
|
|
|
1760
|
-
const module = defineNuxtModule({
|
|
1800
|
+
const module$1 = defineNuxtModule({
|
|
1761
1801
|
meta: { name: NAME },
|
|
1762
1802
|
setup(options, nuxt) {
|
|
1763
1803
|
const logger = useLogger(NAME);
|
|
@@ -1812,8 +1852,8 @@ function normalizeConfig(options) {
|
|
|
1812
1852
|
url: process.env.DIRECTUS_URL ?? "http://localhost:8055",
|
|
1813
1853
|
accessToken: process.env.DIRECTUS_ACCESS_TOKEN || process.env.DIRECTUS_ADMIN_TOKEN || "",
|
|
1814
1854
|
i18n: { enabled: hasNuxtModule("@nuxtjs/i18n"), sync: true, prefix: void 0 },
|
|
1815
|
-
types: { enabled: true },
|
|
1816
|
-
proxy: { enabled: true, path: "/
|
|
1855
|
+
types: { enabled: true, transform: [] },
|
|
1856
|
+
proxy: { enabled: true, path: "/directus", options: {} },
|
|
1817
1857
|
image: { enabled: hasNuxtModule("@nuxt/image"), alias: "directus" },
|
|
1818
1858
|
composables: { enabled: true, mode: "rest", client: true, server: true }
|
|
1819
1859
|
});
|
|
@@ -1883,11 +1923,20 @@ function setupI18n(config, nuxt, logger) {
|
|
|
1883
1923
|
async function setupTypes(config, nuxt, logger) {
|
|
1884
1924
|
addTypeTemplate({
|
|
1885
1925
|
filename: "directus/types.d.ts",
|
|
1886
|
-
getContents: () =>
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1926
|
+
getContents: async () => {
|
|
1927
|
+
let types = await generateDirectusTypes({
|
|
1928
|
+
directusUrl: withoutTrailingSlash(config.url),
|
|
1929
|
+
outputPath: "",
|
|
1930
|
+
directusToken: config.accessToken
|
|
1931
|
+
});
|
|
1932
|
+
if (config.types.transform && config.types.transform.length > 0) {
|
|
1933
|
+
for (const { from, to } of config.types.transform) {
|
|
1934
|
+
const regex = typeof from === "string" ? new RegExp(from, "g") : from;
|
|
1935
|
+
types = types.replace(regex, to);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
return types;
|
|
1939
|
+
}
|
|
1891
1940
|
});
|
|
1892
1941
|
nuxt.options.alias = defu(nuxt.options.alias, {
|
|
1893
1942
|
"#directus/types": "./directus/types.d.ts"
|
|
@@ -1913,4 +1962,4 @@ function setupImage(config, nuxt, logger) {
|
|
|
1913
1962
|
logger.info(`Image alias has been registered: ${config.image.alias} -> ${config.url}`);
|
|
1914
1963
|
}
|
|
1915
1964
|
|
|
1916
|
-
export { module as default };
|
|
1965
|
+
export { module$1 as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yassidev/nuxt-directus",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "A Nuxt module for better integration with Directus CMS.",
|
|
5
5
|
"repository": "yassilah/nuxt-directus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,31 +35,31 @@
|
|
|
35
35
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@directus/sdk": "^
|
|
39
|
-
"@nuxt/kit": "^4.
|
|
38
|
+
"@directus/sdk": "^21.0.0",
|
|
39
|
+
"@nuxt/kit": "^4.3.0",
|
|
40
40
|
"directus-sdk-typegen": "^0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"build": {
|
|
43
43
|
"failOnWarn": false
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@nuxt/devtools": "^
|
|
47
|
-
"@nuxt/eslint": "1.
|
|
48
|
-
"@nuxt/eslint-config": "^1.
|
|
49
|
-
"@nuxt/image": "^
|
|
46
|
+
"@nuxt/devtools": "^3.1.1",
|
|
47
|
+
"@nuxt/eslint": "1.13.0",
|
|
48
|
+
"@nuxt/eslint-config": "^1.13.0",
|
|
49
|
+
"@nuxt/image": "^2.0.0",
|
|
50
50
|
"@nuxt/module-builder": "^1.0.2",
|
|
51
|
-
"@nuxt/schema": "^4.
|
|
52
|
-
"@nuxt/test-utils": "^3.
|
|
53
|
-
"@nuxtjs/i18n": "^10.1
|
|
54
|
-
"@playwright/test": "^1.
|
|
51
|
+
"@nuxt/schema": "^4.3.0",
|
|
52
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
53
|
+
"@nuxtjs/i18n": "^10.2.1",
|
|
54
|
+
"@playwright/test": "^1.58.0",
|
|
55
55
|
"@types/node": "latest",
|
|
56
56
|
"changelogen": "^0.6.2",
|
|
57
|
-
"directus": "^11.
|
|
58
|
-
"eslint": "^9.
|
|
59
|
-
"nuxt": "^4.
|
|
60
|
-
"playwright-core": "^1.
|
|
57
|
+
"directus": "^11.14.1",
|
|
58
|
+
"eslint": "^9.39.2",
|
|
59
|
+
"nuxt": "^4.3.0",
|
|
60
|
+
"playwright-core": "^1.58.0",
|
|
61
61
|
"typescript": "~5.9.3",
|
|
62
|
-
"vitest": "^
|
|
63
|
-
"vue-tsc": "^3.
|
|
62
|
+
"vitest": "^4.0.18",
|
|
63
|
+
"vue-tsc": "^3.2.4"
|
|
64
64
|
}
|
|
65
65
|
}
|