@hubspot/cli 3.0.10-beta.15 → 3.0.10-beta.16

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.
@@ -0,0 +1,103 @@
1
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
2
+ const { createWatcher } = require('@hubspot/cli-lib/projectsWatch');
3
+ const { cancelStagedBuild } = require('@hubspot/cli-lib/api/dfs');
4
+ const {
5
+ logApiErrorInstance,
6
+ ApiErrorContext,
7
+ } = require('@hubspot/cli-lib/errorHandlers');
8
+ const { logger } = require('@hubspot/cli-lib/logger');
9
+ const {
10
+ addAccountOptions,
11
+ addConfigOptions,
12
+ getAccountId,
13
+ addUseEnvironmentOptions,
14
+ } = require('../../lib/commonOpts');
15
+ const { trackCommandUsage } = require('../../lib/usageTracking');
16
+ const {
17
+ getProjectConfig,
18
+ validateProjectConfig,
19
+ pollBuildStatus,
20
+ pollDeployStatus,
21
+ } = require('../../lib/projects');
22
+ const { loadAndValidateOptions } = require('../../lib/validation');
23
+ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
24
+
25
+ const i18nKey = 'cli.commands.project.subcommands.watch';
26
+
27
+ exports.command = 'watch [path]';
28
+ exports.describe = false;
29
+
30
+ const handleBuildStatus = async (accountId, projectName, buildId) => {
31
+ const {
32
+ isAutoDeployEnabled,
33
+ deployStatusTaskLocator,
34
+ } = await pollBuildStatus(accountId, projectName, buildId);
35
+
36
+ if (isAutoDeployEnabled && deployStatusTaskLocator) {
37
+ await pollDeployStatus(
38
+ accountId,
39
+ projectName,
40
+ deployStatusTaskLocator.id,
41
+ buildId
42
+ );
43
+ }
44
+ };
45
+
46
+ const handleSigInt = (accountId, projectName, currentBuildId) => {
47
+ process.removeAllListeners('SIGINT');
48
+ process.on('SIGINT', async () => {
49
+ if (currentBuildId) {
50
+ try {
51
+ await cancelStagedBuild(accountId, projectName);
52
+ logger.debug(i18n(`${i18nKey}.debug.buildCancelled`));
53
+ process.exit(EXIT_CODES.SUCCESS);
54
+ } catch (err) {
55
+ logApiErrorInstance(
56
+ err,
57
+ new ApiErrorContext({ accountId, projectName: projectName })
58
+ );
59
+ process.exit(EXIT_CODES.ERROR);
60
+ }
61
+ } else {
62
+ process.exit(EXIT_CODES.SUCCESS);
63
+ }
64
+ });
65
+ };
66
+
67
+ exports.handler = async options => {
68
+ await loadAndValidateOptions(options);
69
+
70
+ const { path: projectPath } = options;
71
+ const accountId = getAccountId(options);
72
+
73
+ trackCommandUsage('project-watch', { projectPath }, accountId);
74
+
75
+ const { projectConfig, projectDir } = await getProjectConfig(projectPath);
76
+
77
+ validateProjectConfig(projectConfig, projectDir);
78
+
79
+ await createWatcher(
80
+ accountId,
81
+ projectConfig,
82
+ projectDir,
83
+ handleBuildStatus,
84
+ handleSigInt
85
+ );
86
+ };
87
+
88
+ exports.builder = yargs => {
89
+ yargs.positional('path', {
90
+ describe: i18n(`${i18nKey}.describe`),
91
+ type: 'string',
92
+ });
93
+
94
+ yargs.example([
95
+ ['$0 project watch myProjectFolder', i18n(`${i18nKey}.examples.default`)],
96
+ ]);
97
+
98
+ addConfigOptions(yargs, true);
99
+ addAccountOptions(yargs, true);
100
+ addUseEnvironmentOptions(yargs, true);
101
+
102
+ return yargs;
103
+ };
@@ -4,6 +4,7 @@ const create = require('./project/create');
4
4
  const upload = require('./project/upload');
5
5
  const listBuilds = require('./project/listBuilds');
6
6
  const logs = require('./project/logs');
7
+ const watch = require('./project/watch');
7
8
 
8
9
  exports.command = 'project';
9
10
  exports.describe = false; //'Commands for working with projects';
@@ -16,6 +17,7 @@ exports.builder = yargs => {
16
17
  yargs.command(deploy).demandCommand(1, '');
17
18
  yargs.command(create).demandCommand(0, '');
18
19
  yargs.command(upload).demandCommand(0, '');
20
+ yargs.command(watch).demandCommand(0, '');
19
21
  yargs.command(listBuilds).demandCommand(0, '');
20
22
  yargs.command(logs).demandCommand(1, '');
21
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "3.0.10-beta.15",
3
+ "version": "3.0.10-beta.16",
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": "^3.0.10-beta.15",
12
- "@hubspot/serverless-dev-runtime": "^3.0.10-beta.15",
11
+ "@hubspot/cli-lib": "^3.0.10-beta.16",
12
+ "@hubspot/serverless-dev-runtime": "^3.0.10-beta.16",
13
13
  "archiver": "^5.3.0",
14
14
  "chalk": "^4.1.2",
15
15
  "express": "^4.17.1",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "314c0c53c64f45e0eb7663db46808d7265361a0a"
42
+ "gitHead": "cd0fc0a7beb927badc615ac4b8060f65bda851f4"
43
43
  }
package/bin/hubspot DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('./cli');