@hubspot/local-dev-lib 3.16.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.
@@ -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
- let tmpDirRegex;
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 fieldsJsFileInfo = fieldsJsPaths.find(f => f.outputPath === file);
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
- for (let i = 0; i < fileList.length; i++) {
159
- const filesToUpload = fileList[i];
160
- await queue.addAll(filesToUpload.map(uploadFile));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "3.16.0",
3
+ "version": "3.16.1-beta.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "repository": {
6
6
  "type": "git",