@hubspot/cli 4.0.1-beta.2 → 4.0.1-beta.3
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/README.md +1 -15
- package/commands/auth.js +0 -22
- package/commands/init.js +0 -19
- package/commands/project/logs.js +32 -6
- package/hubspot.sample.config.yml +0 -7
- package/lib/__tests__/validation.js +0 -7
- package/lib/prompts/personalAccessKeyPrompt.js +0 -15
- package/lib/regex.js +0 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ hs hubdb delete <id or name>
|
|
|
133
133
|
|
|
134
134
|
## Authentication
|
|
135
135
|
|
|
136
|
-
There are
|
|
136
|
+
There are two ways that the tools can authenticate with HubSpot.
|
|
137
137
|
|
|
138
138
|
### Personal Access Key (recommended)
|
|
139
139
|
|
|
@@ -146,20 +146,6 @@ There are three ways that the tools can authenticate with HubSpot.
|
|
|
146
146
|
3. Select `OAuth2` and follow the steps
|
|
147
147
|
|
|
148
148
|
_**Note:** The Account ID used should be the Test Account ID (not the developer app ID). Client ID and Client Secret are from the developer app._
|
|
149
|
-
|
|
150
|
-
### HubSpot API Key
|
|
151
|
-
|
|
152
|
-
1. [Set up an API Key for the Account](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)
|
|
153
|
-
2. Edit the [hubspot.config.yml](../../docs/HubspotConfigFile.md) file to set the `authType` for the account to `apikey` and add `apiKey` as shown below:
|
|
154
|
-
|
|
155
|
-
```yaml
|
|
156
|
-
defaultPortal: DEV
|
|
157
|
-
portals:
|
|
158
|
-
- name: DEV
|
|
159
|
-
portalId: 123
|
|
160
|
-
authType: apikey
|
|
161
|
-
apiKey: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
162
|
-
```
|
|
163
149
|
### Exit Codes
|
|
164
150
|
|
|
165
151
|
The CLI will exit with one of the following exit codes:
|
package/commands/auth.js
CHANGED
|
@@ -3,7 +3,6 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
3
3
|
const {
|
|
4
4
|
OAUTH_AUTH_METHOD,
|
|
5
5
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
6
|
-
API_KEY_AUTH_METHOD,
|
|
7
6
|
ENVIRONMENTS,
|
|
8
7
|
DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
9
8
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
@@ -22,7 +21,6 @@ const { promptUser } = require('../lib/prompts/promptUtils');
|
|
|
22
21
|
const {
|
|
23
22
|
personalAccessKeyPrompt,
|
|
24
23
|
OAUTH_FLOW,
|
|
25
|
-
API_KEY_FLOW,
|
|
26
24
|
} = require('../lib/prompts/personalAccessKeyPrompt');
|
|
27
25
|
const {
|
|
28
26
|
enterAccountNamePrompt,
|
|
@@ -80,25 +78,6 @@ exports.handler = async options => {
|
|
|
80
78
|
let successAuthMethod;
|
|
81
79
|
|
|
82
80
|
switch (authType) {
|
|
83
|
-
case API_KEY_AUTH_METHOD.value:
|
|
84
|
-
configData = await promptUser(API_KEY_FLOW);
|
|
85
|
-
updatedConfig = await updateAccountConfig(configData);
|
|
86
|
-
validName = updatedConfig.name;
|
|
87
|
-
|
|
88
|
-
if (!validName) {
|
|
89
|
-
const { name: namePrompt } = await enterAccountNamePrompt();
|
|
90
|
-
validName = namePrompt;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
updateAccountConfig({
|
|
94
|
-
...updatedConfig,
|
|
95
|
-
environment: updatedConfig.env,
|
|
96
|
-
name: validName,
|
|
97
|
-
});
|
|
98
|
-
writeConfig();
|
|
99
|
-
|
|
100
|
-
successAuthMethod = API_KEY_AUTH_METHOD.name;
|
|
101
|
-
break;
|
|
102
81
|
case OAUTH_AUTH_METHOD.value:
|
|
103
82
|
configData = await promptUser(OAUTH_FLOW);
|
|
104
83
|
await authenticateWithOauth({
|
|
@@ -188,7 +167,6 @@ exports.builder = yargs => {
|
|
|
188
167
|
choices: [
|
|
189
168
|
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
190
169
|
`${OAUTH_AUTH_METHOD.value}`,
|
|
191
|
-
`${API_KEY_AUTH_METHOD.value}`,
|
|
192
170
|
],
|
|
193
171
|
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
194
172
|
defaultDescription: i18n(`${i18nKey}.positionals.type.defaultDescription`, {
|
package/commands/init.js
CHANGED
|
@@ -5,8 +5,6 @@ const {
|
|
|
5
5
|
createEmptyConfigFile,
|
|
6
6
|
deleteEmptyConfigFile,
|
|
7
7
|
updateDefaultAccount,
|
|
8
|
-
writeConfig,
|
|
9
|
-
updateAccountConfig,
|
|
10
8
|
} = require('@hubspot/cli-lib/lib/config');
|
|
11
9
|
const { addConfigOptions } = require('../lib/commonOpts');
|
|
12
10
|
const { handleExit } = require('@hubspot/cli-lib/lib/process');
|
|
@@ -15,7 +13,6 @@ const {
|
|
|
15
13
|
DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
16
14
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
17
15
|
OAUTH_AUTH_METHOD,
|
|
18
|
-
API_KEY_AUTH_METHOD,
|
|
19
16
|
ENVIRONMENTS,
|
|
20
17
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
21
18
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
@@ -29,7 +26,6 @@ const { setLogLevel, addTestingOptions } = require('../lib/commonOpts');
|
|
|
29
26
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
30
27
|
const {
|
|
31
28
|
OAUTH_FLOW,
|
|
32
|
-
API_KEY_FLOW,
|
|
33
29
|
personalAccessKeyPrompt,
|
|
34
30
|
} = require('../lib/prompts/personalAccessKeyPrompt');
|
|
35
31
|
const {
|
|
@@ -70,28 +66,14 @@ const oauthConfigCreationFlow = async env => {
|
|
|
70
66
|
return accountConfig;
|
|
71
67
|
};
|
|
72
68
|
|
|
73
|
-
const apiKeyConfigCreationFlow = async env => {
|
|
74
|
-
const configData = await promptUser(API_KEY_FLOW);
|
|
75
|
-
const accountConfig = {
|
|
76
|
-
...configData,
|
|
77
|
-
env,
|
|
78
|
-
};
|
|
79
|
-
updateAccountConfig(accountConfig);
|
|
80
|
-
updateDefaultAccount(accountConfig.name);
|
|
81
|
-
writeConfig();
|
|
82
|
-
return accountConfig;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
69
|
const CONFIG_CREATION_FLOWS = {
|
|
86
70
|
[PERSONAL_ACCESS_KEY_AUTH_METHOD.value]: personalAccessKeyConfigCreationFlow,
|
|
87
71
|
[OAUTH_AUTH_METHOD.value]: oauthConfigCreationFlow,
|
|
88
|
-
[API_KEY_AUTH_METHOD.value]: apiKeyConfigCreationFlow,
|
|
89
72
|
};
|
|
90
73
|
|
|
91
74
|
const AUTH_TYPE_NAMES = {
|
|
92
75
|
[PERSONAL_ACCESS_KEY_AUTH_METHOD.value]: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
|
|
93
76
|
[OAUTH_AUTH_METHOD.value]: OAUTH_AUTH_METHOD.name,
|
|
94
|
-
[API_KEY_AUTH_METHOD.value]: API_KEY_AUTH_METHOD.name,
|
|
95
77
|
};
|
|
96
78
|
|
|
97
79
|
exports.command = 'init [--account]';
|
|
@@ -164,7 +146,6 @@ exports.builder = yargs => {
|
|
|
164
146
|
choices: [
|
|
165
147
|
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
166
148
|
`${OAUTH_AUTH_METHOD.value}`,
|
|
167
|
-
`${API_KEY_AUTH_METHOD.value}`,
|
|
168
149
|
],
|
|
169
150
|
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
170
151
|
defaultDescription: i18n(`${i18nKey}.options.auth.defaultDescription`, {
|
package/commands/project/logs.js
CHANGED
|
@@ -10,7 +10,10 @@ const {
|
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
11
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
12
12
|
const { outputLogs } = require('@hubspot/cli-lib/lib/logs');
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
fetchProject,
|
|
15
|
+
fetchDeployComponentsMetadata,
|
|
16
|
+
} = require('@hubspot/cli-lib/api/dfs');
|
|
14
17
|
const {
|
|
15
18
|
getTableContents,
|
|
16
19
|
getTableHeader,
|
|
@@ -142,12 +145,30 @@ exports.handler = async options => {
|
|
|
142
145
|
const endpointName = options.endpoint || promptEndpointName;
|
|
143
146
|
|
|
144
147
|
let relativeAppPath;
|
|
148
|
+
let appId;
|
|
145
149
|
|
|
146
150
|
if (appName && !endpointName) {
|
|
147
151
|
await ensureProjectExists(accountId, projectName, {
|
|
148
152
|
allowCreate: false,
|
|
149
153
|
});
|
|
150
|
-
|
|
154
|
+
|
|
155
|
+
const { deployedBuild, id: projectId } = await fetchProject(
|
|
156
|
+
accountId,
|
|
157
|
+
projectName
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const { results: deployComponents } = await fetchDeployComponentsMetadata(
|
|
161
|
+
accountId,
|
|
162
|
+
projectId
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const appComponent = deployComponents.find(
|
|
166
|
+
c => c.componentName === appName
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
if (appComponent) {
|
|
170
|
+
appId = appComponent.componentIdentifier;
|
|
171
|
+
}
|
|
151
172
|
|
|
152
173
|
if (deployedBuild && deployedBuild.subbuildStatuses) {
|
|
153
174
|
const appSubbuild = deployedBuild.subbuildStatuses.find(
|
|
@@ -196,10 +217,15 @@ exports.handler = async options => {
|
|
|
196
217
|
);
|
|
197
218
|
|
|
198
219
|
logger.log(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
220
|
+
appId
|
|
221
|
+
? uiLink(
|
|
222
|
+
i18n(`${i18nKey}.logs.hubspotLogsDirectLink`),
|
|
223
|
+
`${getPrivateAppsUrl(accountId)}/${appId}/logs/extensions`
|
|
224
|
+
)
|
|
225
|
+
: uiLink(
|
|
226
|
+
i18n(`${i18nKey}.logs.hubspotLogsLink`),
|
|
227
|
+
getPrivateAppsUrl(accountId)
|
|
228
|
+
)
|
|
203
229
|
);
|
|
204
230
|
logger.log();
|
|
205
231
|
uiLine();
|
|
@@ -11,13 +11,6 @@ allowUsageTracking: false
|
|
|
11
11
|
|
|
12
12
|
# List of accounts that are intended to be used
|
|
13
13
|
portals:
|
|
14
|
-
# Account set up to use an API Key
|
|
15
|
-
- name: DEV
|
|
16
|
-
portalId: 123
|
|
17
|
-
# Override mode for account
|
|
18
|
-
defaultMode: draft
|
|
19
|
-
authType: apikey
|
|
20
|
-
apiKey: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
21
14
|
# Account set up to use OAuth2
|
|
22
15
|
- name: PROD
|
|
23
16
|
portalId: 456
|
|
@@ -24,13 +24,6 @@ describe('validation', () => {
|
|
|
24
24
|
getAccountConfig.mockReturnValueOnce(undefined);
|
|
25
25
|
expect(await validateAccount({ account: 123 })).toBe(false);
|
|
26
26
|
});
|
|
27
|
-
it('returns false if an api key is missing', async () => {
|
|
28
|
-
getAccountId.mockReturnValueOnce(123);
|
|
29
|
-
getAccountConfig.mockReturnValueOnce({
|
|
30
|
-
accountId: 123,
|
|
31
|
-
});
|
|
32
|
-
expect(await validateAccount({ account: 123 })).toBe(false);
|
|
33
|
-
});
|
|
34
27
|
it('returns false for oauth2 authType if auth is missing', async () => {
|
|
35
28
|
getAccountId.mockReturnValueOnce(123);
|
|
36
29
|
getAccountConfig.mockReturnValueOnce({
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
const { deleteEmptyConfigFile } = require('@hubspot/cli-lib/lib/config');
|
|
7
7
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
8
8
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
9
|
-
const { API_KEY_REGEX } = require('../regex');
|
|
10
9
|
const { promptUser } = require('./promptUtils');
|
|
11
10
|
const { accountNamePrompt } = require('./enterAccountNamePrompt');
|
|
12
11
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
@@ -89,17 +88,6 @@ const CLIENT_SECRET = {
|
|
|
89
88
|
},
|
|
90
89
|
};
|
|
91
90
|
|
|
92
|
-
const ACCOUNT_API_KEY = {
|
|
93
|
-
name: 'apiKey',
|
|
94
|
-
message: i18n(`${i18nKey}.enterApiKey`),
|
|
95
|
-
validate(val) {
|
|
96
|
-
if (!API_KEY_REGEX.test(val)) {
|
|
97
|
-
return i18n(`${i18nKey}.errors.invalidAPIKey`);
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
91
|
const PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP = {
|
|
104
92
|
name: 'personalAcessKeyBrowserOpenPrep',
|
|
105
93
|
type: 'confirm',
|
|
@@ -142,17 +130,14 @@ const OAUTH_FLOW = [
|
|
|
142
130
|
CLIENT_SECRET,
|
|
143
131
|
SCOPES,
|
|
144
132
|
];
|
|
145
|
-
const API_KEY_FLOW = [accountNamePrompt(), ACCOUNT_ID, ACCOUNT_API_KEY];
|
|
146
133
|
|
|
147
134
|
module.exports = {
|
|
148
135
|
personalAccessKeyPrompt,
|
|
149
136
|
CLIENT_ID,
|
|
150
137
|
CLIENT_SECRET,
|
|
151
|
-
ACCOUNT_API_KEY,
|
|
152
138
|
ACCOUNT_ID,
|
|
153
139
|
SCOPES,
|
|
154
140
|
PERSONAL_ACCESS_KEY,
|
|
155
141
|
// Flows
|
|
156
|
-
API_KEY_FLOW,
|
|
157
142
|
OAUTH_FLOW,
|
|
158
143
|
};
|
package/lib/regex.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.3",
|
|
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.1-beta.
|
|
12
|
-
"@hubspot/serverless-dev-runtime": "4.0.1-beta.
|
|
11
|
+
"@hubspot/cli-lib": "4.0.1-beta.3",
|
|
12
|
+
"@hubspot/serverless-dev-runtime": "4.0.1-beta.3",
|
|
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": "
|
|
40
|
+
"gitHead": "e2fac76a5ea9f51f69dfb786a5f285ffcf88a47a"
|
|
41
41
|
}
|