@hubspot/local-dev-lib 1.5.0 → 1.6.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/lang/en.json +5 -5
- package/lang/lang/en.json +5 -5
- package/lib/archive.js +4 -4
- package/lib/path.d.ts +2 -0
- package/lib/path.js +34 -1
- package/lib/sandboxes.js +1 -2
- package/package.json +1 -1
- package/types/FileManager.d.ts +0 -1
package/lang/en.json
CHANGED
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"init": "Extracting project source...",
|
|
11
11
|
"success": "Completed project source extraction.",
|
|
12
12
|
"errors": {
|
|
13
|
-
"write": "An error
|
|
14
|
-
"extract": "An error
|
|
13
|
+
"write": "An error occurred writing temp project source.",
|
|
14
|
+
"extract": "An error occurred extracting project source."
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"copySourceToDest": {
|
|
18
18
|
"init": "Copying project source...",
|
|
19
19
|
"sourceEmpty": "Project source is empty",
|
|
20
20
|
"success": "Completed copying project source.",
|
|
21
|
-
"error": "An error
|
|
21
|
+
"error": "An error occurred copying project source to {{ dest }}."
|
|
22
22
|
},
|
|
23
23
|
"cleanupTempDir": {
|
|
24
24
|
"error": "Failed to clean up temp dir: {{ tmpDir }}"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"fetchFileFromRepository": {
|
|
34
34
|
"fetching": "Fetching {{ path }}...",
|
|
35
35
|
"errors": {
|
|
36
|
-
"fetchFail": "An error
|
|
36
|
+
"fetchFail": "An error occurred fetching JSON file."
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"fetchReleaseData": {
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
},
|
|
131
131
|
"createTmpDirSync": {
|
|
132
132
|
"errors": {
|
|
133
|
-
"writeFailed": "An error
|
|
133
|
+
"writeFailed": "An error occurred writing temporary project source."
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
136
|
"cleanupTmpDirSync": {
|
package/lang/lang/en.json
CHANGED
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"init": "Extracting project source...",
|
|
11
11
|
"success": "Completed project source extraction.",
|
|
12
12
|
"errors": {
|
|
13
|
-
"write": "An error
|
|
14
|
-
"extract": "An error
|
|
13
|
+
"write": "An error occurred writing temp project source.",
|
|
14
|
+
"extract": "An error occurred extracting project source."
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"copySourceToDest": {
|
|
18
18
|
"init": "Copying project source...",
|
|
19
19
|
"sourceEmpty": "Project source is empty",
|
|
20
20
|
"success": "Completed copying project source.",
|
|
21
|
-
"error": "An error
|
|
21
|
+
"error": "An error occurred copying project source to {{ dest }}."
|
|
22
22
|
},
|
|
23
23
|
"cleanupTempDir": {
|
|
24
24
|
"error": "Failed to clean up temp dir: {{ tmpDir }}"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"fetchFileFromRepository": {
|
|
34
34
|
"fetching": "Fetching {{ path }}...",
|
|
35
35
|
"errors": {
|
|
36
|
-
"fetchFail": "An error
|
|
36
|
+
"fetchFail": "An error occurred fetching JSON file."
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"fetchReleaseData": {
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
},
|
|
131
131
|
"createTmpDirSync": {
|
|
132
132
|
"errors": {
|
|
133
|
-
"writeFailed": "An error
|
|
133
|
+
"writeFailed": "An error occurred writing temporary project source."
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
136
|
"cleanupTmpDirSync": {
|
package/lib/archive.js
CHANGED
|
@@ -65,7 +65,7 @@ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true,
|
|
|
65
65
|
if (!rootDir) {
|
|
66
66
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.sourceEmpty`));
|
|
67
67
|
// Create the dest path if it doesn't already exist
|
|
68
|
-
fs_extra_1.default.ensureDir(dest);
|
|
68
|
+
await fs_extra_1.default.ensureDir(dest);
|
|
69
69
|
// No root found so nothing to copy
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
@@ -88,11 +88,11 @@ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true,
|
|
|
88
88
|
}
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
|
-
function cleanupTempDir(tmpDir) {
|
|
91
|
+
async function cleanupTempDir(tmpDir) {
|
|
92
92
|
if (!tmpDir)
|
|
93
93
|
return;
|
|
94
94
|
try {
|
|
95
|
-
fs_extra_1.default.remove(tmpDir);
|
|
95
|
+
await fs_extra_1.default.remove(tmpDir);
|
|
96
96
|
}
|
|
97
97
|
catch (e) {
|
|
98
98
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
|
|
@@ -109,7 +109,7 @@ async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir,
|
|
|
109
109
|
hideLogs,
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
cleanupTempDir(tmpDir);
|
|
112
|
+
await cleanupTempDir(tmpDir);
|
|
113
113
|
}
|
|
114
114
|
return success;
|
|
115
115
|
}
|
package/lib/path.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export declare function getExt(filepath: string): string;
|
|
|
9
9
|
export declare function getAllowedExtensions(allowList?: Array<string>): Set<string>;
|
|
10
10
|
export declare function isAllowedExtension(filepath: string, allowList?: Array<string>): boolean;
|
|
11
11
|
export declare function getAbsoluteFilePath(_path: string): string;
|
|
12
|
+
export declare function sanitizeFileName(fileName: string): string;
|
|
13
|
+
export declare function isValidPath(_path: string): boolean;
|
package/lib/path.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
6
|
+
exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const unixify_1 = __importDefault(require("unixify"));
|
|
9
9
|
const extensions_1 = require("../constants/extensions");
|
|
@@ -87,3 +87,36 @@ function getAbsoluteFilePath(_path) {
|
|
|
87
87
|
return path_1.default.resolve(getCwd(), _path);
|
|
88
88
|
}
|
|
89
89
|
exports.getAbsoluteFilePath = getAbsoluteFilePath;
|
|
90
|
+
// Reserved names (Windows specific)
|
|
91
|
+
const reservedNames = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
92
|
+
// Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
|
|
93
|
+
function sanitizeFileName(fileName) {
|
|
94
|
+
// Windows invalid/control characters
|
|
95
|
+
// eslint-disable-next-line no-control-regex
|
|
96
|
+
const invalidChars = /[<>:"/|?*\x00-\x1F]/g;
|
|
97
|
+
//Replace invalid characters with dash
|
|
98
|
+
let sanitizedFileName = fileName.replace(invalidChars, '-');
|
|
99
|
+
// Removes trailing periods and spaces for Windows
|
|
100
|
+
sanitizedFileName = sanitizedFileName.replace(/[. ]+$/, '');
|
|
101
|
+
//Reserved names check for Windows
|
|
102
|
+
if (reservedNames.test(sanitizedFileName)) {
|
|
103
|
+
sanitizedFileName = `-${sanitizedFileName}`;
|
|
104
|
+
}
|
|
105
|
+
return sanitizedFileName;
|
|
106
|
+
}
|
|
107
|
+
exports.sanitizeFileName = sanitizeFileName;
|
|
108
|
+
// Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
|
|
109
|
+
function isValidPath(_path) {
|
|
110
|
+
// Invalid characters excluding forward slash
|
|
111
|
+
// eslint-disable-next-line no-control-regex
|
|
112
|
+
const invalidChars = /[<>:"|?*\x00-\x1F]/;
|
|
113
|
+
const baseName = path_1.default.basename(_path);
|
|
114
|
+
if (invalidChars.test(baseName)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (reservedNames.test(baseName)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
exports.isValidPath = isValidPath;
|
package/lib/sandboxes.js
CHANGED
|
@@ -51,8 +51,7 @@ async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
|
51
51
|
exports.initiateSync = initiateSync;
|
|
52
52
|
async function fetchTaskStatus(accountId, taskId) {
|
|
53
53
|
try {
|
|
54
|
-
|
|
55
|
-
return result;
|
|
54
|
+
return await (0, sandboxSync_1.fetchTaskStatus)(accountId, taskId);
|
|
56
55
|
}
|
|
57
56
|
catch (err) {
|
|
58
57
|
(0, apiErrors_1.throwApiError)(err);
|
package/package.json
CHANGED