@hubspot/local-dev-lib 1.2.0 → 1.3.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/lib/cms/watch.d.ts +1 -1
- package/lib/cms/watch.js +16 -15
- package/package.json +1 -1
package/lib/cms/watch.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ type WatchOptions = {
|
|
|
13
13
|
filePaths?: Array<string>;
|
|
14
14
|
};
|
|
15
15
|
type ErrorHandler = (error: AxiosError) => void;
|
|
16
|
-
export declare function watch(accountId: number, src: string, dest: string, { mode, remove, disableInitial, notify, commandOptions, filePaths, }: WatchOptions, postInitialUploadCallback?: ((result: Array<UploadFolderResults>) => void) | null, onUploadFolderError?: ErrorHandler, onQueueAddError?: ErrorHandler): chokidar.FSWatcher;
|
|
16
|
+
export declare function watch(accountId: number, src: string, dest: string, { mode, remove, disableInitial, notify, commandOptions, filePaths, }: WatchOptions, postInitialUploadCallback?: ((result: Array<UploadFolderResults>) => void) | null, onUploadFolderError?: ErrorHandler, onQueueAddError?: ErrorHandler, onUploadFileError?: (file: string, dest: string, accountId: number) => ErrorHandler): chokidar.FSWatcher;
|
|
17
17
|
export {};
|
package/lib/cms/watch.js
CHANGED
|
@@ -35,7 +35,18 @@ function _notifyOfThemePreview(filePath, accountId) {
|
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
const notifyOfThemePreview = (0, debounce_1.default)(_notifyOfThemePreview, 1000);
|
|
38
|
-
|
|
38
|
+
const defaultOnUploadFileError = (file, dest, accountId) => (error) => {
|
|
39
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, {
|
|
40
|
+
file,
|
|
41
|
+
dest,
|
|
42
|
+
}));
|
|
43
|
+
(0, apiErrors_1.throwApiUploadError)(error, {
|
|
44
|
+
accountId,
|
|
45
|
+
request: dest,
|
|
46
|
+
payload: file,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
async function uploadFile(accountId, file, dest, options, mode = null, onUploadFileError = defaultOnUploadFileError) {
|
|
39
50
|
const src = options.src;
|
|
40
51
|
const absoluteSrcPath = path_1.default.resolve((0, path_2.getCwd)(), file);
|
|
41
52
|
const themeJsonPath = (0, themes_1.getThemeJSONPath)(absoluteSrcPath);
|
|
@@ -71,17 +82,7 @@ async function uploadFile(accountId, file, dest, options, mode = null) {
|
|
|
71
82
|
.catch(() => {
|
|
72
83
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, { file, dest }));
|
|
73
84
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadRetry`, { file, dest }));
|
|
74
|
-
return (0, fileMapper_2.upload)(accountId, file, dest, apiOptions).catch((
|
|
75
|
-
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, {
|
|
76
|
-
file,
|
|
77
|
-
dest,
|
|
78
|
-
}));
|
|
79
|
-
(0, apiErrors_1.throwApiUploadError)(error, {
|
|
80
|
-
accountId,
|
|
81
|
-
request: dest,
|
|
82
|
-
payload: file,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
+
return (0, fileMapper_2.upload)(accountId, file, dest, apiOptions).catch(onUploadFileError(file, dest, accountId));
|
|
85
86
|
});
|
|
86
87
|
});
|
|
87
88
|
}
|
|
@@ -108,7 +109,7 @@ async function deleteRemoteFile(accountId, filePath, remoteFilePath) {
|
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
function watch(accountId, src, dest, { mode, remove, disableInitial, notify, commandOptions, filePaths, }, postInitialUploadCallback = null, onUploadFolderError, onQueueAddError) {
|
|
112
|
+
function watch(accountId, src, dest, { mode, remove, disableInitial, notify, commandOptions, filePaths, }, postInitialUploadCallback = null, onUploadFolderError, onQueueAddError, onUploadFileError) {
|
|
112
113
|
const regex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(src)}`);
|
|
113
114
|
if (notify) {
|
|
114
115
|
(0, ignoreRules_1.ignoreFile)(notify);
|
|
@@ -145,7 +146,7 @@ function watch(accountId, src, dest, { mode, remove, disableInitial, notify, com
|
|
|
145
146
|
const uploadPromise = uploadFile(accountId, filePath, destPath, {
|
|
146
147
|
src,
|
|
147
148
|
commandOptions,
|
|
148
|
-
}, mode);
|
|
149
|
+
}, mode, onUploadFileError);
|
|
149
150
|
(0, notify_1.triggerNotify)(notify, 'Added', filePath, uploadPromise);
|
|
150
151
|
});
|
|
151
152
|
if (remove) {
|
|
@@ -185,7 +186,7 @@ function watch(accountId, src, dest, { mode, remove, disableInitial, notify, com
|
|
|
185
186
|
const uploadPromise = uploadFile(accountId, filePath, destPath, {
|
|
186
187
|
src,
|
|
187
188
|
commandOptions,
|
|
188
|
-
}, mode);
|
|
189
|
+
}, mode, onUploadFileError);
|
|
189
190
|
(0, notify_1.triggerNotify)(notify, 'Changed', filePath, uploadPromise);
|
|
190
191
|
});
|
|
191
192
|
return watcher;
|
package/package.json
CHANGED