@hubspot/cli 3.0.10-beta.10 → 3.0.10-beta.14

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.
package/commands/auth.js CHANGED
@@ -85,7 +85,7 @@ exports.handler = async options => {
85
85
 
86
86
  const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
87
87
  loadConfig(configPath);
88
- checkAndWarnGitInclusion();
88
+ checkAndWarnGitInclusion(getConfigPath());
89
89
 
90
90
  trackCommandUsage('auth');
91
91
 
@@ -13,9 +13,14 @@ const {
13
13
  getProjectAppFunctionLogs,
14
14
  getLatestProjectAppFunctionLog,
15
15
  } = require('@hubspot/cli-lib/api/functions');
16
+ const {
17
+ getFunctionLogs,
18
+ getLatestFunctionLog,
19
+ } = require('@hubspot/cli-lib/api/results');
16
20
  const { getProjectConfig } = require('../../lib/projects');
17
21
  const { loadAndValidateOptions } = require('../../lib/validation');
18
22
  const { tailLogs } = require('../../lib/serverlessLogs');
23
+ const { uiAccountDescription } = require('../../lib/ui');
19
24
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
20
25
 
21
26
  const i18nKey = 'cli.commands.project.subcommands.logs';
@@ -24,17 +29,23 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
24
29
  const handleLogsError = (e, accountId, projectName, appPath, functionName) => {
25
30
  if (e.statusCode === 404) {
26
31
  logger.error(
27
- i18n(`${i18nKey}.errors.logs`, {
28
- accountId,
29
- appPath,
30
- functionName,
31
- projectName,
32
- })
32
+ appPath
33
+ ? i18n(`${i18nKey}.errors.noAppFunctionLogs`, {
34
+ accountId,
35
+ appPath,
36
+ functionName,
37
+ projectName,
38
+ })
39
+ : i18n(`${i18nKey}.errors.noEndpointLogs`, {
40
+ accountId,
41
+ functionName,
42
+ projectName,
43
+ })
33
44
  );
34
45
  }
35
46
  };
36
47
 
37
- const appFunctionLog = async (accountId, options) => {
48
+ const functionLog = async (accountId, options) => {
38
49
  const {
39
50
  latest,
40
51
  follow,
@@ -46,28 +57,43 @@ const appFunctionLog = async (accountId, options) => {
46
57
 
47
58
  let logsResp;
48
59
 
60
+ const tailCall = async after => {
61
+ try {
62
+ return appPath
63
+ ? getProjectAppFunctionLogs(
64
+ accountId,
65
+ functionName,
66
+ projectName,
67
+ appPath,
68
+ {
69
+ after,
70
+ }
71
+ )
72
+ : getFunctionLogs(accountId, functionName, { after });
73
+ } catch (e) {
74
+ handleLogsError(e, accountId, projectName, appPath, functionName);
75
+ }
76
+ };
77
+ const fetchLatest = async () => {
78
+ return appPath
79
+ ? getLatestProjectAppFunctionLog(
80
+ accountId,
81
+ functionName,
82
+ projectName,
83
+ appPath
84
+ )
85
+ : getLatestFunctionLog(accountId, functionName);
86
+ };
87
+
49
88
  if (follow) {
50
89
  const spinnies = new Spinnies();
51
90
 
52
91
  spinnies.add('tailLogs', {
53
- text: i18n(`${i18nKey}.loading`),
92
+ text: i18n(`${i18nKey}.loading`, {
93
+ functionName,
94
+ accountId: uiAccountDescription(accountId),
95
+ }),
54
96
  });
55
- const tailCall = after =>
56
- getProjectAppFunctionLogs(accountId, functionName, projectName, appPath, {
57
- after,
58
- });
59
- const fetchLatest = () => {
60
- try {
61
- return getLatestProjectAppFunctionLog(
62
- accountId,
63
- functionName,
64
- projectName,
65
- appPath
66
- );
67
- } catch (e) {
68
- handleLogsError(e, accountId, projectName, appPath, functionName);
69
- }
70
- };
71
97
 
72
98
  await tailLogs({
73
99
  accountId,
@@ -78,24 +104,13 @@ const appFunctionLog = async (accountId, options) => {
78
104
  });
79
105
  } else if (latest) {
80
106
  try {
81
- logsResp = await getLatestProjectAppFunctionLog(
82
- accountId,
83
- functionName,
84
- projectName,
85
- appPath
86
- );
107
+ logsResp = await fetchLatest();
87
108
  } catch (e) {
88
109
  handleLogsError(e, accountId, projectName, appPath, functionName);
89
110
  }
90
111
  } else {
91
112
  try {
92
- logsResp = await getProjectAppFunctionLogs(
93
- accountId,
94
- functionName,
95
- projectName,
96
- appPath,
97
- {}
98
- );
113
+ logsResp = await tailCall();
99
114
  } catch (e) {
100
115
  handleLogsError(e, accountId, projectName, appPath, functionName);
101
116
  }
@@ -106,50 +121,47 @@ const appFunctionLog = async (accountId, options) => {
106
121
  }
107
122
  };
108
123
 
109
- exports.command = 'logs [functionName]';
124
+ exports.command = 'logs';
110
125
  exports.describe = i18n(`${i18nKey}.describe`);
111
126
 
112
127
  exports.handler = async options => {
113
128
  await loadAndValidateOptions(options);
114
129
 
115
- const { latest, functionName, appPath } = options;
130
+ const { latest, functionName } = options;
116
131
  let projectName = options.projectName;
117
132
 
118
133
  if (!functionName) {
119
134
  logger.error(i18n(`${i18nKey}.errors.functionNameRequired`));
120
135
  process.exit(EXIT_CODES.ERROR);
121
136
  } else if (!projectName) {
122
- const projectConfig = await getProjectConfig(getCwd());
137
+ const { projectConfig } = await getProjectConfig(getCwd());
123
138
  if (projectConfig && projectConfig.name) {
124
139
  projectName = projectConfig.name;
125
140
  } else {
126
141
  logger.error(i18n(`${i18nKey}.errors.projectNameRequired`));
127
142
  process.exit(EXIT_CODES.ERROR);
128
143
  }
129
- } else if (!appPath) {
130
- logger.error(i18n(`${i18nKey}.errors.appPathRequired`));
131
- process.exit(EXIT_CODES.ERROR);
132
144
  }
133
145
 
134
146
  const accountId = getAccountId(options);
135
147
 
136
148
  trackCommandUsage('project-logs', { latest }, accountId);
137
149
 
138
- appFunctionLog(accountId, { ...options, projectName });
150
+ functionLog(accountId, { ...options, projectName });
139
151
  };
140
152
 
141
153
  exports.builder = yargs => {
142
- yargs.positional('functionName', {
143
- describe: i18n(`${i18nKey}.positionals.functionName.describe`),
144
- type: 'string',
145
- demandOption: true,
146
- });
147
154
  yargs
148
155
  .options({
156
+ functionName: {
157
+ alias: 'function',
158
+ describe: i18n(`${i18nKey}.positionals.functionName.describe`),
159
+ type: 'string',
160
+ demandOption: true,
161
+ },
149
162
  appPath: {
150
163
  describe: i18n(`${i18nKey}.options.appPath.describe`),
151
164
  type: 'string',
152
- demandOption: true,
153
165
  },
154
166
  projectName: {
155
167
  describe: i18n(`${i18nKey}.options.projectName.describe`),
@@ -179,7 +191,7 @@ exports.builder = yargs => {
179
191
 
180
192
  yargs.example([
181
193
  [
182
- '$0 project logs my-function --appName="app" --projectName="my-project"',
194
+ '$0 project logs --function=my-function --appPath="app" --projectName="my-project"',
183
195
  i18n(`${i18nKey}.examples.default`),
184
196
  ],
185
197
  ]);
@@ -5,6 +5,7 @@ const {
5
5
  loadConfig,
6
6
  validateConfig,
7
7
  checkAndWarnGitInclusion,
8
+ getConfigPath,
8
9
  } = require('@hubspot/cli-lib');
9
10
  const { logger } = require('@hubspot/cli-lib/logger');
10
11
  const { getCwd } = require('@hubspot/cli-lib/path');
@@ -38,7 +39,7 @@ function configureServerCommand(program) {
38
39
  logDebugInfo(options);
39
40
  const { config: configPath, serverConfig, contextDir } = options;
40
41
  loadConfig(configPath, options);
41
- checkAndWarnGitInclusion();
42
+ checkAndWarnGitInclusion(getConfigPath());
42
43
 
43
44
  if (!validateConfig()) {
44
45
  process.exit(EXIT_CODES.ERROR);
package/lib/projects.js CHANGED
@@ -271,6 +271,7 @@ const makeGetTaskStatus = taskType => {
271
271
  const spinnies = new Spinnies({
272
272
  succeedColor: 'white',
273
273
  failColor: 'white',
274
+ failPrefix: chalk.bold('!'),
274
275
  });
275
276
 
276
277
  spinnies.add('overallTaskStatus', { text: 'Beginning' });
package/lib/validation.js CHANGED
@@ -4,10 +4,10 @@ const {
4
4
  loadConfigFromEnvironment,
5
5
  Mode,
6
6
  loadConfig,
7
+ getConfigPath,
7
8
  validateConfig,
8
9
  checkAndWarnGitInclusion,
9
10
  } = require('@hubspot/cli-lib');
10
- const { getConfigPath } = require('@hubspot/cli-lib/lib/config');
11
11
  const {
12
12
  API_KEY_AUTH_METHOD,
13
13
  OAUTH_AUTH_METHOD,
@@ -31,7 +31,7 @@ async function loadAndValidateOptions(options) {
31
31
  logDebugInfo(options);
32
32
  const { config: configPath } = options;
33
33
  loadConfig(configPath, options);
34
- checkAndWarnGitInclusion();
34
+ checkAndWarnGitInclusion(getConfigPath());
35
35
 
36
36
  if (!(validateConfig() && (await validateAccount(options)))) {
37
37
  process.exit(EXIT_CODES.ERROR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "3.0.10-beta.10",
3
+ "version": "3.0.10-beta.14",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,14 +8,14 @@
8
8
  "url": "https://github.com/HubSpot/hubspot-cms-tools"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/cli-lib": "^3.0.10-beta.10",
12
- "@hubspot/serverless-dev-runtime": "^3.0.10-beta.10",
11
+ "@hubspot/cli-lib": "^3.0.10-beta.13",
12
+ "@hubspot/serverless-dev-runtime": "^3.0.10-beta.13",
13
13
  "archiver": "^5.3.0",
14
- "chalk": "^4.1.0",
14
+ "chalk": "^4.1.2",
15
15
  "express": "^4.17.1",
16
16
  "findup-sync": "^4.0.0",
17
17
  "fs-extra": "^8.1.0",
18
- "inquirer": "^6.3.1",
18
+ "inquirer": "^8.2.0",
19
19
  "moment": "^2.29.1",
20
20
  "open": "^7.0.3",
21
21
  "ora": "^4.0.3",
@@ -23,7 +23,7 @@
23
23
  "spinnies": "^0.5.1",
24
24
  "supports-hyperlinks": "^2.2.0",
25
25
  "tmp": "^0.2.1",
26
- "update-notifier": "3.0.1",
26
+ "update-notifier": "^5.1.0",
27
27
  "yargs": "15.4.1"
28
28
  },
29
29
  "devDependencies": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "8422c53ea645c2159b9b143393513cab4e8500a9"
42
+ "gitHead": "e77b37281411b7eed123974eefd2b839d92376c8"
43
43
  }