HubSpot/hubspot-cli

`hs watch --convertFields` fails if `.hsignore` exists

100handa opened this issue ยท 3 comments

Description and Context

  • macOS 12.6
  • Node.js 18.12.1
  • hubspot/cli 4.1.4

File uploading with hs watch --convertFields fails if .hsignore exists even if the contents are empty. Error message is below:

[INFO] The "hs watch" command no longer uploads the watched directory when started. The directory "./" was not uploaded.
[INFO] To upload the directory run "hs upload" beforehand or add the "--initial-upload" option when running "hs watch".
Watcher is ready and watching /Users/atsushi/Downloads/website-theme. Any changes detected will be automatically uploaded and overwrite the current version in the developer file system.
[INFO] Converting "/Users/atsushi/Downloads/website-theme/modules/button.module/fields.js" to "/Users/atsushi/Downloads/website-theme/modules/button.module/fields.json".
[SUCCESS] Finished converting "/Users/atsushi/Downloads/website-theme/modules/button.module/fields.js" to "/Users/atsushi/Downloads/website-theme/modules/button.module/fields.json".
(node:44008) UnhandledPromiseRejectionWarning: RangeError: path should be a `path.relative()`d string, but got "../../../../var/folders/vf/p8_cls4n35qgg2xhmr1916d40000gn/T/hubspot-temp-fieldsjs-output-80mYpk/modules/button.module/fields.json"
    at throwError (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/node_modules/ignore/index.js:364:9)
    at checkPath (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/node_modules/ignore/index.js:383:12)
    at Ignore._test (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/node_modules/ignore/index.js:504:5)
    at Ignore.ignores (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/node_modules/ignore/index.js:549:17)
    at shouldIgnoreFile (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/node_modules/@hubspot/cli-lib/ignoreRules.js:57:40)
    at Object.exports.handler (/Users/atsushi/.volta/tools/image/packages/@hubspot/cli/lib/node_modules/@hubspot/cli/commands/upload.js:145:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:44008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:44008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce

  1. Fetch CMS Hub boilerplate with hs create website-theme
  2. Make a file .hsignore
  3. Hit hs watch [src] [dest] --convertFields

Expected behavior

fields.js will be uploaded as fields.json without error, even though .hsignore exists.

Screenshots

hs-cli-convert-fields

Thank you for reporting this! Looking into it.

I can confirm this. Without .hsignore everything works as expected, but even with an empty .hsignore, the following error is thrown:

[SUCCESS] Finished converting "/Users/johndoe/Code/theme-hubspot/src/fields.js" to "/Users/johndoe/Code/theme-hubspot/src/fields.json".
/Users/johndoe/Code/theme-hubspot/node_modules/ignore/index.js:379
  throw new Ctor(message)
        ^

RangeError: path should be a `path.relative()`d string, but got "../../../../var/folders/tl/fk6dykt91kd73y7c5tb078k40000gn/T/hubspot-temp-fieldsjs-output-MJx0yp/fields.json"
    at throwError (/Users/johndoe/Code/theme-hubspot/node_modules/ignore/index.js:379:9)
    at checkPath (/Users/johndoe/Code/theme-hubspot/node_modules/ignore/index.js:398:12)
    at Ignore._test (/Users/johndoe/Code/theme-hubspot/node_modules/ignore/index.js:519:5)
    at Ignore.ignores (/Users/johndoe/Code/theme-hubspot/node_modules/ignore/index.js:564:17)
    at shouldIgnoreFile (/Users/johndoe/Code/theme-hubspot/node_modules/@hubspot/cli-lib/ignoreRules.js:57:40)
    at Object.exports.handler (/Users/johndoe/Code/theme-hubspot/node_modules/@hubspot/cli/commands/upload.js:145:9)

Thank you for reporting. This should be fixed in the latest beta version if you'd like to upgrade to that version you can run npm i -g @hubspot/cli@next