@hubspot/cli 4.1.6-beta.0 → 4.1.6-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.
@@ -1,7 +1,5 @@
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');
5
3
  const { uploadFolder, hasUploadErrors } = require('@hubspot/cli-lib');
6
4
  const { getFileMapperQueryValues } = require('@hubspot/cli-lib/fileMapper');
7
5
  const { upload } = require('@hubspot/cli-lib/api/fileMapper');
@@ -28,9 +26,9 @@ const {
28
26
  getMode,
29
27
  } = require('../lib/commonOpts');
30
28
  const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
31
- const { fieldsJsPrompt } = require('../lib/prompts/cmsFieldPrompt');
32
29
  const { validateMode, loadAndValidateOptions } = require('../lib/validation');
33
30
  const { trackCommandUsage } = require('../lib/usageTracking');
31
+ const { getUploadableFileList } = require('../lib/upload');
34
32
  const {
35
33
  getThemePreviewUrl,
36
34
  getThemeJSONPath,
@@ -248,46 +246,6 @@ exports.handler = async options => {
248
246
  }
249
247
  };
250
248
 
251
- /*
252
- * Walks the src folder for files, filters them based on ignore filter.
253
- * If convertFields is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
254
- */
255
- const getUploadableFileList = async (src, convertFields) => {
256
- const filePaths = await walk(src);
257
- const allowedFiles = filePaths
258
- .filter(file => {
259
- if (!isAllowedExtension(file)) {
260
- return false;
261
- }
262
- return true;
263
- })
264
- .filter(createIgnoreFilter());
265
- if (!convertFields) {
266
- return allowedFiles;
267
- }
268
-
269
- let uploadableFiles = [];
270
- let skipFiles = [];
271
- for (const filePath of allowedFiles) {
272
- const fileName = path.basename(filePath);
273
- if (skipFiles.includes(filePath)) continue;
274
- const isConvertable = isConvertableFieldJs(src, filePath, convertFields);
275
- if (isConvertable || fileName == 'fields.json') {
276
- // This prompt checks if there are multiple field files in the folder and gets user to choose.
277
- const [choice, updatedSkipFiles] = await fieldsJsPrompt(
278
- filePath,
279
- src,
280
- skipFiles
281
- );
282
- skipFiles = updatedSkipFiles;
283
- // If they chose something other than the current file, move on.
284
- if (choice !== filePath) continue;
285
- }
286
- uploadableFiles.push(filePath);
287
- }
288
- return uploadableFiles;
289
- };
290
-
291
249
  exports.builder = yargs => {
292
250
  addConfigOptions(yargs, true);
293
251
  addAccountOptions(yargs, true);
package/commands/watch.js CHANGED
@@ -17,6 +17,7 @@ const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
17
17
  const { validateMode, loadAndValidateOptions } = require('../lib/validation');
18
18
  const { trackCommandUsage } = require('../lib/usageTracking');
19
19
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
20
+ const { getUploadableFileList } = require('../lib/upload');
20
21
 
21
22
  const i18nKey = 'cli.commands.watch';
22
23
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
@@ -66,6 +67,8 @@ exports.handler = async options => {
66
67
  return;
67
68
  }
68
69
 
70
+ let filesToUpload = [];
71
+
69
72
  if (disableInitial) {
70
73
  logger.info(i18n(`${i18nKey}.warnings.disableInitial`));
71
74
  } else {
@@ -76,6 +79,13 @@ exports.handler = async options => {
76
79
  }
77
80
  }
78
81
 
82
+ if (initialUpload) {
83
+ filesToUpload = await getUploadableFileList(
84
+ absoluteSrcPath,
85
+ options.convertFields
86
+ );
87
+ }
88
+
79
89
  trackCommandUsage('watch', { mode }, accountId);
80
90
  watch(accountId, absoluteSrcPath, dest, {
81
91
  mode,
@@ -83,6 +93,7 @@ exports.handler = async options => {
83
93
  disableInitial: initialUpload ? false : true,
84
94
  notify,
85
95
  commandOptions: options,
96
+ filePaths: filesToUpload,
86
97
  });
87
98
  };
88
99
 
@@ -117,7 +128,6 @@ exports.builder = yargs => {
117
128
  type: 'boolean',
118
129
  });
119
130
  yargs.option('disable-initial', {
120
- alias: 'd',
121
131
  describe: i18n(`${i18nKey}.options.disableInitial.describe`),
122
132
  type: 'boolean',
123
133
  hidden: true,
package/lib/upload.js ADDED
@@ -0,0 +1,50 @@
1
+ const path = require('path');
2
+ const { walk } = require('@hubspot/cli-lib/lib/walk');
3
+ const { createIgnoreFilter } = require('@hubspot/cli-lib/ignoreRules');
4
+ const { fieldsJsPrompt } = require('../lib/prompts/cmsFieldPrompt');
5
+ const { isAllowedExtension } = require('@hubspot/cli-lib/path');
6
+ const { isConvertableFieldJs } = require('@hubspot/cli-lib/lib/handleFieldsJs');
7
+
8
+ /*
9
+ * Walks the src folder for files, filters them based on ignore filter.
10
+ * If convertFields is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
11
+ */
12
+ const getUploadableFileList = async (src, convertFields) => {
13
+ const filePaths = await walk(src);
14
+ const allowedFiles = filePaths
15
+ .filter(file => {
16
+ if (!isAllowedExtension(file)) {
17
+ return false;
18
+ }
19
+ return true;
20
+ })
21
+ .filter(createIgnoreFilter());
22
+ if (!convertFields) {
23
+ return allowedFiles;
24
+ }
25
+
26
+ let uploadableFiles = [];
27
+ let skipFiles = [];
28
+ for (const filePath of allowedFiles) {
29
+ const fileName = path.basename(filePath);
30
+ if (skipFiles.includes(filePath)) continue;
31
+ const isConvertable = isConvertableFieldJs(src, filePath, convertFields);
32
+ if (isConvertable || fileName == 'fields.json') {
33
+ // This prompt checks if there are multiple field files in the folder and gets user to choose.
34
+ const [choice, updatedSkipFiles] = await fieldsJsPrompt(
35
+ filePath,
36
+ src,
37
+ skipFiles
38
+ );
39
+ skipFiles = updatedSkipFiles;
40
+ // If they chose something other than the current file, move on.
41
+ if (choice !== filePath) continue;
42
+ }
43
+ uploadableFiles.push(filePath);
44
+ }
45
+ return uploadableFiles;
46
+ };
47
+
48
+ module.exports = {
49
+ getUploadableFileList,
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.1.6-beta.0",
3
+ "version": "4.1.6-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.1.6-beta.0",
12
- "@hubspot/serverless-dev-runtime": "4.1.6-beta.0",
11
+ "@hubspot/cli-lib": "4.1.6-beta.1",
12
+ "@hubspot/serverless-dev-runtime": "4.1.6-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": "e6b7f76604de27bb0932671deb390a985176467b"
40
+ "gitHead": "886b32d3fd4385be85dfb118e58b61a24a7ac568"
41
41
  }