@hubspot/cli 4.0.2-beta.0 → 4.0.2-beta.1

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.
Files changed (2) hide show
  1. package/commands/upload.js +51 -1
  2. package/package.json +4 -4
@@ -1,5 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const { walk } = require('@hubspot/cli-lib/lib/walk');
4
+ const { createIgnoreFilter } = require('@hubspot/cli-lib/ignoreRules');
3
5
  const { uploadFolder, hasUploadErrors } = require('@hubspot/cli-lib');
4
6
  const { getFileMapperQueryValues } = require('@hubspot/cli-lib/fileMapper');
5
7
  const { upload } = require('@hubspot/cli-lib/api/fileMapper');
@@ -26,6 +28,7 @@ const {
26
28
  getMode,
27
29
  } = require('../lib/commonOpts');
28
30
  const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
31
+ const { fieldsJsPrompt } = require('../lib/prompts/cmsFieldPrompt');
29
32
  const { validateMode, loadAndValidateOptions } = require('../lib/validation');
30
33
  const { trackCommandUsage } = require('../lib/usageTracking');
31
34
  const {
@@ -196,6 +199,12 @@ exports.handler = async options => {
196
199
  src,
197
200
  })
198
201
  );
202
+
203
+ // Generate the first-pass file list in here, and pass to uploadFolder.
204
+ const filePaths = await getUploadableFileList(
205
+ absoluteSrcPath,
206
+ options.processFieldsJs
207
+ );
199
208
  uploadFolder(
200
209
  accountId,
201
210
  absoluteSrcPath,
@@ -203,7 +212,8 @@ exports.handler = async options => {
203
212
  {
204
213
  mode,
205
214
  },
206
- options
215
+ options,
216
+ filePaths
207
217
  )
208
218
  .then(results => {
209
219
  if (!hasUploadErrors(results)) {
@@ -237,6 +247,46 @@ exports.handler = async options => {
237
247
  }
238
248
  };
239
249
 
250
+ /*
251
+ * Walks the src folder for files, filters them based on ignore filter.
252
+ * If processFieldsJs is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
253
+ */
254
+ const getUploadableFileList = async (src, processFieldsJs) => {
255
+ const filePaths = await walk(src);
256
+ const allowedFiles = filePaths
257
+ .filter(file => {
258
+ if (!isAllowedExtension(file)) {
259
+ return false;
260
+ }
261
+ return true;
262
+ })
263
+ .filter(createIgnoreFilter());
264
+ if (!processFieldsJs) {
265
+ return allowedFiles;
266
+ }
267
+
268
+ let uploadableFiles = [];
269
+ let skipFiles = [];
270
+ for (const filePath of allowedFiles) {
271
+ const fileName = path.basename(filePath);
272
+ if (skipFiles.includes(filePath)) continue;
273
+ const isProcessable = isProcessableFieldsJs(src, filePath, processFieldsJs);
274
+ if (isProcessable || fileName == 'fields.json') {
275
+ // This prompt checks if there are multiple field files in the folder and gets user to choose.
276
+ const [choice, updatedSkipFiles] = await fieldsJsPrompt(
277
+ filePath,
278
+ src,
279
+ skipFiles
280
+ );
281
+ skipFiles = updatedSkipFiles;
282
+ // If they chose something other than the current file, move on.
283
+ if (choice !== filePath) continue;
284
+ }
285
+ uploadableFiles.push(filePath);
286
+ }
287
+ return uploadableFiles;
288
+ };
289
+
240
290
  exports.builder = yargs => {
241
291
  addConfigOptions(yargs, true);
242
292
  addAccountOptions(yargs, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.0.2-beta.0",
3
+ "version": "4.0.2-beta.1",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,8 +8,8 @@
8
8
  "url": "https://github.com/HubSpot/hubspot-cms-tools"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/cli-lib": "4.0.2-beta.0",
12
- "@hubspot/serverless-dev-runtime": "4.0.2-beta.0",
11
+ "@hubspot/cli-lib": "4.0.2-beta.1",
12
+ "@hubspot/serverless-dev-runtime": "4.0.2-beta.1",
13
13
  "archiver": "^5.3.0",
14
14
  "chalk": "^4.1.2",
15
15
  "express": "^4.17.1",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "861cd70866ca2e8f803d5b61c73fccd04f3d6c75"
40
+ "gitHead": "75ff004ab82bfdf35107d602530237b6dd37ebee"
41
41
  }