@hubspot/local-dev-lib 3.15.0 → 3.16.1-beta.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/config/config_DEPRECATED.d.ts +1 -1
- package/config/config_DEPRECATED.js +3 -3
- package/config/index.d.ts +1 -1
- package/config/index.js +3 -3
- package/lib/cms/uploadFolder.js +35 -13
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ export declare function loadConfigFromEnvironment({ useEnv, }?: {
|
|
|
81
81
|
}): {
|
|
82
82
|
portals: Array<CLIAccount_DEPRECATED>;
|
|
83
83
|
} | undefined;
|
|
84
|
-
export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED): boolean;
|
|
84
|
+
export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED, defaultValue?: boolean): boolean;
|
|
85
85
|
export declare function hasLocalStateFlag(flag: string): boolean;
|
|
86
86
|
export declare function addLocalStateFlag(flag: string): void;
|
|
87
87
|
export declare function removeLocalStateFlag(flag: string): void;
|
|
@@ -698,12 +698,12 @@ function loadEnvironmentVariableConfig(options) {
|
|
|
698
698
|
logger_1.logger.debug(`Loaded config from environment variables for account ${portalId}`);
|
|
699
699
|
return setConfig(handleLegacyCmsPublishMode(envConfig));
|
|
700
700
|
}
|
|
701
|
-
function isConfigFlagEnabled(flag) {
|
|
701
|
+
function isConfigFlagEnabled(flag, defaultValue = false) {
|
|
702
702
|
if (!configFileExists() || configFileIsBlank()) {
|
|
703
|
-
return
|
|
703
|
+
return defaultValue;
|
|
704
704
|
}
|
|
705
705
|
const config = getAndLoadConfigIfNeeded();
|
|
706
|
-
return Boolean(config[flag] ||
|
|
706
|
+
return Boolean(config[flag] || defaultValue);
|
|
707
707
|
}
|
|
708
708
|
exports.isConfigFlagEnabled = isConfigFlagEnabled;
|
|
709
709
|
function handleLegacyCmsPublishMode(config) {
|
package/config/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare function updateAllowAutoUpdates(enabled: boolean): void;
|
|
|
28
28
|
export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
29
29
|
export declare function updateAutoOpenBrowser(isEnabled: boolean): void;
|
|
30
30
|
export declare function deleteConfigFile(): void;
|
|
31
|
-
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
31
|
+
export declare function isConfigFlagEnabled(flag: keyof CLIConfig, defaultValue?: boolean): boolean;
|
|
32
32
|
export declare function isTrackingAllowed(): boolean;
|
|
33
33
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
34
34
|
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
package/config/index.js
CHANGED
|
@@ -220,11 +220,11 @@ function deleteConfigFile() {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
exports.deleteConfigFile = deleteConfigFile;
|
|
223
|
-
function isConfigFlagEnabled(flag) {
|
|
223
|
+
function isConfigFlagEnabled(flag, defaultValue = false) {
|
|
224
224
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
225
|
-
return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag);
|
|
225
|
+
return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag, defaultValue);
|
|
226
226
|
}
|
|
227
|
-
return config_DEPRECATED.isConfigFlagEnabled(flag);
|
|
227
|
+
return config_DEPRECATED.isConfigFlagEnabled(flag, defaultValue);
|
|
228
228
|
}
|
|
229
229
|
exports.isConfigFlagEnabled = isConfigFlagEnabled;
|
|
230
230
|
function isTrackingAllowed() {
|
package/lib/cms/uploadFolder.js
CHANGED
|
@@ -38,6 +38,16 @@ function getFileType(filePath) {
|
|
|
38
38
|
return files_1.FILE_TYPES.other;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
function isMetaJsonFile(filePath) {
|
|
42
|
+
return path_1.default.basename(filePath).toLowerCase() === 'meta.json';
|
|
43
|
+
}
|
|
44
|
+
function resolveUploadPath(file, fieldsJsPaths, tmpDirRegex, regex, dest) {
|
|
45
|
+
const fieldsJsFileInfo = fieldsJsPaths.find(f => f.outputPath === file);
|
|
46
|
+
const relativePath = file.replace(fieldsJsFileInfo ? tmpDirRegex : regex, '');
|
|
47
|
+
const destPath = (0, path_2.convertToUnixPath)(path_1.default.join(dest, relativePath));
|
|
48
|
+
const originalFilePath = fieldsJsFileInfo ? fieldsJsFileInfo.filePath : file;
|
|
49
|
+
return { fieldsJsFileInfo, relativePath, destPath, originalFilePath };
|
|
50
|
+
}
|
|
41
51
|
async function getFilesByType(filePaths, projectDir, rootWriteDir, commandOptions) {
|
|
42
52
|
const { convertFields, fieldOptions } = commandOptions;
|
|
43
53
|
const projectDirRegex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(projectDir)}`);
|
|
@@ -106,6 +116,12 @@ const defaultUploadFinalErrorCallback = (accountId, file, destPath, error) => {
|
|
|
106
116
|
payload: file,
|
|
107
117
|
});
|
|
108
118
|
};
|
|
119
|
+
async function uploadMetaJsonFiles(moduleFiles, uploadFile) {
|
|
120
|
+
const moduleMetaJsonFiles = moduleFiles.filter(isMetaJsonFile);
|
|
121
|
+
if (moduleMetaJsonFiles.length > 0) {
|
|
122
|
+
await queue.addAll(moduleMetaJsonFiles.map(uploadFile));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
109
125
|
async function uploadFolder(accountId, src, dest, fileMapperOptions, commandOptions = {}, filePaths = [], cmsPublishMode = null) {
|
|
110
126
|
const { saveOutput, convertFields, onAttemptCallback, onSuccessCallback, onFirstErrorCallback, onRetryCallback, onFinalErrorCallback, } = commandOptions;
|
|
111
127
|
const _onAttemptCallback = onAttemptCallback || defaultUploadAttemptCallback;
|
|
@@ -120,23 +136,15 @@ async function uploadFolder(accountId, src, dest, fileMapperOptions, commandOpti
|
|
|
120
136
|
const apiOptions = (0, fileMapper_1.getFileMapperQueryValues)(cmsPublishMode, fileMapperOptions);
|
|
121
137
|
const failures = [];
|
|
122
138
|
let fieldsJsPaths = [];
|
|
123
|
-
|
|
139
|
+
const tmpDirRegex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(tmpDir || '')}`);
|
|
124
140
|
const [filesByType, fieldsJsObjects] = await getFilesByType(filePaths, src, tmpDir, commandOptions);
|
|
125
|
-
const fileList = Object.values(filesByType);
|
|
126
141
|
if (fieldsJsObjects.length) {
|
|
127
142
|
fieldsJsPaths = fieldsJsObjects.map(fieldsJs => {
|
|
128
143
|
return { outputPath: fieldsJs.outputPath, filePath: fieldsJs.filePath };
|
|
129
144
|
});
|
|
130
|
-
tmpDirRegex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(tmpDir || '')}`);
|
|
131
145
|
}
|
|
132
146
|
function uploadFile(file) {
|
|
133
|
-
const
|
|
134
|
-
const originalFilePath = fieldsJsFileInfo
|
|
135
|
-
? fieldsJsFileInfo.filePath
|
|
136
|
-
: file;
|
|
137
|
-
// files in fieldsJsPaths always belong to the tmp directory.
|
|
138
|
-
const relativePath = file.replace(fieldsJsFileInfo ? tmpDirRegex : regex, '');
|
|
139
|
-
const destPath = (0, path_2.convertToUnixPath)(path_1.default.join(dest, relativePath));
|
|
147
|
+
const { originalFilePath, destPath } = resolveUploadPath(file, fieldsJsPaths, tmpDirRegex, regex, dest);
|
|
140
148
|
return async () => {
|
|
141
149
|
_onAttemptCallback(originalFilePath, destPath);
|
|
142
150
|
try {
|
|
@@ -155,9 +163,23 @@ async function uploadFolder(accountId, src, dest, fileMapperOptions, commandOpti
|
|
|
155
163
|
}
|
|
156
164
|
};
|
|
157
165
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
// Upload all meta.json files first
|
|
167
|
+
await uploadMetaJsonFiles(filesByType[files_1.FILE_TYPES.module] || [], uploadFile);
|
|
168
|
+
// Collect all remaining files for upload
|
|
169
|
+
const deferredFiles = [];
|
|
170
|
+
Object.entries(filesByType).forEach(([fileType, files]) => {
|
|
171
|
+
if (fileType === files_1.FILE_TYPES.module) {
|
|
172
|
+
// Add non-meta.json module files
|
|
173
|
+
deferredFiles.push(...files.filter(f => !isMetaJsonFile(f)));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Add all non-module files
|
|
177
|
+
deferredFiles.push(...files);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
// Upload all remaining files concurrently
|
|
181
|
+
if (deferredFiles.length > 0) {
|
|
182
|
+
await queue.addAll(deferredFiles.map(uploadFile));
|
|
161
183
|
}
|
|
162
184
|
const results = await queue
|
|
163
185
|
.addAll(failures.map(({ file, destPath }) => {
|
package/package.json
CHANGED