@hubspot/cli 6.2.0 → 6.2.2-experimental.0
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/bin/cli.d.ts +2 -0
- package/bin/cli.js +107 -128
- package/commands/accounts/clean.d.ts +4 -0
- package/commands/accounts/clean.js +80 -116
- package/commands/accounts/info.d.ts +4 -0
- package/commands/accounts/info.js +30 -43
- package/commands/accounts/list.d.ts +4 -0
- package/commands/accounts/list.js +63 -92
- package/commands/accounts/remove.d.ts +4 -0
- package/commands/accounts/remove.js +41 -73
- package/commands/accounts/rename.d.ts +4 -0
- package/commands/accounts/rename.js +24 -41
- package/commands/accounts/use.d.ts +4 -0
- package/commands/accounts/use.js +34 -57
- package/commands/accounts.d.ts +3 -0
- package/commands/accounts.js +14 -18
- package/commands/auth.d.ts +4 -0
- package/commands/auth.js +131 -200
- package/commands/cms/convertFields.d.ts +4 -0
- package/commands/cms/convertFields.js +64 -81
- package/commands/cms/lighthouseScore.d.ts +4 -0
- package/commands/cms/lighthouseScore.js +234 -298
- package/commands/cms/reactModules.d.ts +4 -0
- package/commands/cms/reactModules.js +44 -53
- package/commands/cms.d.ts +3 -0
- package/commands/cms.js +9 -13
- package/commands/config/set/allowUsageTracking.d.ts +4 -0
- package/commands/config/set/allowUsageTracking.js +31 -38
- package/commands/config/set/defaultMode.d.ts +4 -0
- package/commands/config/set/defaultMode.js +32 -43
- package/commands/config/set/httpTimeout.d.ts +4 -0
- package/commands/config/set/httpTimeout.js +21 -30
- package/commands/config/set.d.ts +4 -0
- package/commands/config/set.js +61 -76
- package/commands/config.d.ts +3 -0
- package/commands/config.js +5 -9
- package/commands/create/api-sample.d.ts +13 -0
- package/commands/create/api-sample.js +52 -74
- package/commands/create/app.d.ts +10 -0
- package/commands/create/app.js +6 -7
- package/commands/create/function.d.ts +6 -0
- package/commands/create/function.js +13 -14
- package/commands/create/index.d.ts +109 -0
- package/commands/create/index.js +10 -9
- package/commands/create/module.d.ts +11 -0
- package/commands/create/module.js +19 -19
- package/commands/create/react-app.d.ts +9 -0
- package/commands/create/react-app.js +5 -6
- package/commands/create/template.d.ts +12 -0
- package/commands/create/template.js +21 -24
- package/commands/create/vue-app.d.ts +9 -0
- package/commands/create/vue-app.js +5 -6
- package/commands/create/webpack-serverless.d.ts +9 -0
- package/commands/create/webpack-serverless.js +5 -6
- package/commands/create/website-theme.d.ts +9 -0
- package/commands/create/website-theme.js +13 -15
- package/commands/create.d.ts +4 -0
- package/commands/create.js +62 -80
- package/commands/customObject/create.d.ts +4 -0
- package/commands/customObject/create.js +31 -47
- package/commands/customObject/schema/create.d.ts +4 -0
- package/commands/customObject/schema/create.js +40 -67
- package/commands/customObject/schema/delete.d.ts +4 -0
- package/commands/customObject/schema/delete.js +26 -39
- package/commands/customObject/schema/fetch-all.d.ts +4 -0
- package/commands/customObject/schema/fetch-all.js +28 -39
- package/commands/customObject/schema/fetch.d.ts +4 -0
- package/commands/customObject/schema/fetch.js +46 -63
- package/commands/customObject/schema/list.d.ts +3 -0
- package/commands/customObject/schema/list.js +12 -17
- package/commands/customObject/schema/update.d.ts +4 -0
- package/commands/customObject/schema/update.js +44 -72
- package/commands/customObject/schema.d.ts +3 -0
- package/commands/customObject/schema.js +10 -12
- package/commands/customObject.d.ts +3 -0
- package/commands/customObject.js +12 -22
- package/commands/feedback.d.ts +4 -0
- package/commands/feedback.js +23 -33
- package/commands/fetch.d.ts +4 -0
- package/commands/fetch.js +51 -78
- package/commands/filemanager/fetch.d.ts +4 -0
- package/commands/filemanager/fetch.js +36 -56
- package/commands/filemanager/upload.d.ts +4 -0
- package/commands/filemanager/upload.js +86 -128
- package/commands/filemanager.d.ts +3 -0
- package/commands/filemanager.js +10 -18
- package/commands/functions/deploy.d.ts +4 -0
- package/commands/functions/deploy.js +74 -99
- package/commands/functions/list.d.ts +4 -0
- package/commands/functions/list.js +29 -47
- package/commands/functions/server.d.ts +4 -0
- package/commands/functions/server.js +48 -65
- package/commands/functions.d.ts +3 -0
- package/commands/functions.js +11 -15
- package/commands/hubdb/clear.d.ts +4 -0
- package/commands/hubdb/clear.js +35 -56
- package/commands/hubdb/create.d.ts +4 -0
- package/commands/hubdb/create.js +32 -57
- package/commands/hubdb/delete.d.ts +4 -0
- package/commands/hubdb/delete.js +27 -44
- package/commands/hubdb/fetch.d.ts +4 -0
- package/commands/hubdb/fetch.js +28 -46
- package/commands/hubdb.d.ts +3 -0
- package/commands/hubdb.js +10 -14
- package/commands/init.d.ts +4 -0
- package/commands/init.js +101 -160
- package/commands/lint.d.ts +4 -0
- package/commands/lint.js +32 -45
- package/commands/list.d.ts +4 -0
- package/commands/list.js +72 -101
- package/commands/logs.d.ts +4 -0
- package/commands/logs.js +96 -121
- package/commands/module/marketplace-validate.d.ts +4 -0
- package/commands/module/marketplace-validate.js +30 -57
- package/commands/module.d.ts +3 -0
- package/commands/module.js +5 -9
- package/commands/mv.d.ts +4 -0
- package/commands/mv.js +51 -71
- package/commands/open.d.ts +4 -0
- package/commands/open.js +46 -62
- package/commands/project/add.d.ts +4 -0
- package/commands/project/add.js +45 -70
- package/commands/project/cloneApp.d.ts +4 -0
- package/commands/project/cloneApp.js +117 -180
- package/commands/project/create.d.ts +4 -0
- package/commands/project/create.js +47 -81
- package/commands/project/deploy.d.ts +4 -0
- package/commands/project/deploy.js +103 -182
- package/commands/project/dev.d.ts +4 -0
- package/commands/project/dev.js +123 -227
- package/commands/project/download.d.ts +4 -0
- package/commands/project/download.js +71 -123
- package/commands/project/installDeps.d.ts +6 -0
- package/commands/project/installDeps.js +50 -59
- package/commands/project/listBuilds.d.ts +4 -0
- package/commands/project/listBuilds.js +95 -139
- package/commands/project/logs.d.ts +4 -0
- package/commands/project/logs.js +84 -128
- package/commands/project/migrateApp.d.ts +4 -0
- package/commands/project/migrateApp.js +156 -248
- package/commands/project/open.d.ts +4 -0
- package/commands/project/open.js +42 -68
- package/commands/project/upload.d.ts +4 -0
- package/commands/project/upload.js +70 -116
- package/commands/project/watch.d.ts +4 -0
- package/commands/project/watch.js +92 -152
- package/commands/project.d.ts +3 -0
- package/commands/project.js +19 -23
- package/commands/remove.d.ts +4 -0
- package/commands/remove.js +26 -43
- package/commands/sandbox/create.d.ts +4 -0
- package/commands/sandbox/create.js +141 -187
- package/commands/sandbox/delete.d.ts +4 -0
- package/commands/sandbox/delete.js +164 -221
- package/commands/sandbox.d.ts +3 -0
- package/commands/sandbox.js +8 -12
- package/commands/secrets/addSecret.d.ts +4 -0
- package/commands/secrets/addSecret.js +32 -52
- package/commands/secrets/deleteSecret.d.ts +4 -0
- package/commands/secrets/deleteSecret.js +31 -50
- package/commands/secrets/listSecrets.d.ts +4 -0
- package/commands/secrets/listSecrets.js +26 -42
- package/commands/secrets/updateSecret.d.ts +4 -0
- package/commands/secrets/updateSecret.js +33 -53
- package/commands/secrets.d.ts +3 -0
- package/commands/secrets.js +10 -13
- package/commands/theme/generate-selectors.d.ts +4 -0
- package/commands/theme/generate-selectors.js +127 -192
- package/commands/theme/marketplace-validate.d.ts +4 -0
- package/commands/theme/marketplace-validate.js +30 -57
- package/commands/theme/preview.d.ts +4 -0
- package/commands/theme/preview.js +161 -196
- package/commands/theme.d.ts +3 -0
- package/commands/theme.js +7 -11
- package/commands/upload.d.ts +4 -0
- package/commands/upload.js +197 -287
- package/commands/watch.d.ts +4 -0
- package/commands/watch.js +126 -172
- package/lang/en.lyaml +2 -3
- package/lib/DevServerManager.d.ts +35 -0
- package/lib/DevServerManager.js +97 -124
- package/lib/LocalDevManager.d.ts +41 -0
- package/lib/LocalDevManager.js +320 -490
- package/lib/accountTypes.d.ts +6 -0
- package/lib/accountTypes.js +16 -32
- package/lib/buildAccount.d.ts +22 -0
- package/lib/buildAccount.js +130 -179
- package/lib/commonOpts.d.ts +20 -0
- package/lib/commonOpts.js +58 -91
- package/lib/constants.d.ts +83 -0
- package/lib/constants.js +61 -71
- package/lib/debugInfo.d.ts +3 -0
- package/lib/debugInfo.js +12 -13
- package/lib/dependencyManagement.d.ts +7 -0
- package/lib/dependencyManagement.js +90 -132
- package/lib/developerTestAccounts.d.ts +7 -0
- package/lib/developerTestAccounts.js +65 -91
- package/lib/enums/exitCodes.d.ts +5 -0
- package/lib/enums/exitCodes.js +5 -7
- package/lib/environment.d.ts +1 -0
- package/lib/environment.js +10 -10
- package/lib/errorHandlers/index.d.ts +19 -0
- package/lib/errorHandlers/index.js +64 -80
- package/lib/errorHandlers/suppressError.d.ts +1 -0
- package/lib/errorHandlers/suppressError.js +64 -106
- package/lib/filesystem.d.ts +2 -0
- package/lib/filesystem.js +16 -24
- package/lib/generate-selectors.d.ts +6 -0
- package/lib/generate-selectors.js +99 -137
- package/lib/getFunctionArrays.d.ts +1 -0
- package/lib/getFunctionArrays.js +12 -13
- package/lib/hasFeature.d.ts +1 -0
- package/lib/hasFeature.js +5 -11
- package/lib/hasFlag.d.ts +2 -0
- package/lib/hasFlag.js +6 -10
- package/lib/hublValidate.d.ts +4 -0
- package/lib/hublValidate.js +20 -24
- package/lib/interpolation.d.ts +10 -0
- package/lib/interpolation.js +48 -92
- package/lib/interpolationHelpers.d.ts +6 -0
- package/lib/interpolationHelpers.js +19 -19
- package/lib/lang.d.ts +3 -0
- package/lib/lang.js +50 -78
- package/lib/links.d.ts +127 -0
- package/lib/links.js +92 -114
- package/lib/localDev.d.ts +11 -0
- package/lib/localDev.js +283 -433
- package/lib/marketplace-validate.d.ts +5 -0
- package/lib/marketplace-validate.js +103 -126
- package/lib/oauth.d.ts +1 -0
- package/lib/oauth.js +62 -78
- package/lib/polling.d.ts +1 -0
- package/lib/polling.js +24 -26
- package/lib/process.d.ts +2 -0
- package/lib/process.js +39 -53
- package/lib/projectLogsManager.d.ts +19 -0
- package/lib/projectLogsManager.js +76 -130
- package/lib/projectStructure.d.ts +13 -0
- package/lib/projectStructure.js +87 -109
- package/lib/projects.d.ts +40 -0
- package/lib/projects.js +589 -957
- package/lib/projectsWatch.d.ts +1 -0
- package/lib/projectsWatch.js +122 -228
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +58 -65
- package/lib/prompts/accountsPrompt.d.ts +3 -0
- package/lib/prompts/accountsPrompt.js +31 -37
- package/lib/prompts/activeInstallConfirmationPrompt.d.ts +1 -0
- package/lib/prompts/activeInstallConfirmationPrompt.js +11 -13
- package/lib/prompts/cleanUploadPrompt.d.ts +1 -0
- package/lib/prompts/cleanUploadPrompt.js +11 -13
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -0
- package/lib/prompts/cmsFieldPrompt.js +35 -39
- package/lib/prompts/createApiSamplePrompt.d.ts +1 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -52
- package/lib/prompts/createFunctionPrompt.d.ts +1 -0
- package/lib/prompts/createFunctionPrompt.js +55 -56
- package/lib/prompts/createModulePrompt.d.ts +1 -0
- package/lib/prompts/createModulePrompt.js +45 -50
- package/lib/prompts/createProjectPrompt.d.ts +1 -0
- package/lib/prompts/createProjectPrompt.js +88 -127
- package/lib/prompts/createTemplatePrompt.d.ts +1 -0
- package/lib/prompts/createTemplatePrompt.js +16 -19
- package/lib/prompts/deployBuildIdPrompt.d.ts +1 -0
- package/lib/prompts/deployBuildIdPrompt.js +13 -15
- package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
- package/lib/prompts/downloadProjectPrompt.js +36 -40
- package/lib/prompts/feedbackPrompt.d.ts +2 -0
- package/lib/prompts/feedbackPrompt.js +27 -30
- package/lib/prompts/folderOverwritePrompt.d.ts +1 -0
- package/lib/prompts/folderOverwritePrompt.js +8 -10
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -0
- package/lib/prompts/installPublicAppPrompt.js +27 -42
- package/lib/prompts/personalAccessKeyPrompt.d.ts +69 -0
- package/lib/prompts/personalAccessKeyPrompt.js +102 -110
- package/lib/prompts/previewPrompt.d.ts +2 -0
- package/lib/prompts/previewPrompt.js +44 -47
- package/lib/prompts/projectAddPrompt.d.ts +1 -0
- package/lib/prompts/projectAddPrompt.js +35 -38
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +4 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +148 -193
- package/lib/prompts/projectNamePrompt.d.ts +1 -0
- package/lib/prompts/projectNamePrompt.js +23 -25
- package/lib/prompts/projectsLogsPrompt.d.ts +5 -0
- package/lib/prompts/projectsLogsPrompt.js +19 -27
- package/lib/prompts/promptUtils.d.ts +2 -0
- package/lib/prompts/promptUtils.js +15 -17
- package/lib/prompts/sandboxesPrompt.d.ts +2 -0
- package/lib/prompts/sandboxesPrompt.js +48 -59
- package/lib/prompts/secretPrompt.d.ts +1 -0
- package/lib/prompts/secretPrompt.js +13 -16
- package/lib/prompts/selectPublicAppPrompt.d.ts +5 -0
- package/lib/prompts/selectPublicAppPrompt.js +55 -81
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -0
- package/lib/prompts/setAsDefaultAccountPrompt.js +17 -24
- package/lib/prompts/uploadPrompt.d.ts +1 -0
- package/lib/prompts/uploadPrompt.js +28 -30
- package/lib/regex.d.ts +1 -0
- package/lib/regex.js +2 -2
- package/lib/sandboxSync.d.ts +8 -0
- package/lib/sandboxSync.js +98 -166
- package/lib/sandboxes.d.ts +40 -0
- package/lib/sandboxes.js +199 -316
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +20 -26
- package/lib/serverlessLogs.d.ts +8 -0
- package/lib/serverlessLogs.js +128 -172
- package/lib/ui/SpinniesManager.d.ts +61 -0
- package/lib/ui/SpinniesManager.js +196 -254
- package/lib/ui/git.d.ts +1 -0
- package/lib/ui/git.js +18 -19
- package/lib/ui/index.d.ts +36 -0
- package/lib/ui/index.js +115 -167
- package/lib/ui/serverlessFunctionLogs.d.ts +1 -0
- package/lib/ui/serverlessFunctionLogs.js +51 -70
- package/lib/ui/spinniesUtils.d.ts +60 -0
- package/lib/ui/spinniesUtils.js +109 -133
- package/lib/ui/supportHyperlinks.d.ts +3 -0
- package/lib/ui/supportHyperlinks.js +46 -61
- package/lib/ui/supportsColor.d.ts +13 -0
- package/lib/ui/supportsColor.js +78 -108
- package/lib/ui/table.d.ts +2 -0
- package/lib/ui/table.js +47 -55
- package/lib/upload.d.ts +1 -0
- package/lib/upload.js +37 -42
- package/lib/usageTracking.d.ts +6 -0
- package/lib/usageTracking.js +131 -155
- package/lib/validation.d.ts +16 -0
- package/lib/validation.js +142 -203
- package/package.json +78 -48
- package/CHANGELOG.md +0 -16
- package/LICENSE +0 -12
- package/README.md +0 -154
- package/commands/__tests__/projects.test.js +0 -105
- package/commands/project/__tests__/deploy.test.js +0 -443
- package/commands/project/__tests__/installDeps.test.js +0 -168
- package/commands/project/__tests__/logs.test.js +0 -304
- package/hubspot.sample.config.yml +0 -28
- package/jest.config.js +0 -4
- package/lib/__tests__/commonOpts.test.js +0 -83
- package/lib/__tests__/dependencyManagement.test.js +0 -243
- package/lib/__tests__/downloadProjectPrompt.test.js +0 -31
- package/lib/__tests__/projectLogsManager.test.js +0 -212
- package/lib/__tests__/projects.test.js +0 -140
- package/lib/__tests__/serverlessLogs.test.js +0 -162
- package/lib/__tests__/validation.test.js +0 -140
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +0 -46
package/README.md
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# @hubspot/cli
|
|
2
|
-
|
|
3
|
-
Provides an `hs` command for interacting with HubSpot. [Learn more about building on HubSpot](https://developers.hubspot.com).
|
|
4
|
-
|
|
5
|
-
## Getting started
|
|
6
|
-
|
|
7
|
-
For more information on using these tools, see [Local Development Tooling: Getting Started](https://developers.hubspot.com/docs/cms/guides/getting-started-with-local-development)
|
|
8
|
-
|
|
9
|
-
### Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install -g @hubspot/cli
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Configuring
|
|
16
|
-
|
|
17
|
-
Once the `@hubspot/cli` has been added to a project, a config file named [hubspot.config.yml](../../docs/HubspotConfigFile.md) will also be needed. It is recommended that the config file is kept in your `$HOME` directory.
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
cd ~
|
|
21
|
-
hs init
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
#### Auto Completion
|
|
25
|
-
|
|
26
|
-
You can set up command autocompletion by running
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
hs completion
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
and copying the output to either your `.bashrc` or `.zshrc`, and then sourcing that file `source ~/.bashrc` `source ~/.zshrc` or restarting your terminal.
|
|
33
|
-
|
|
34
|
-
## Commands
|
|
35
|
-
|
|
36
|
-
A full breakdown of the commands can be found on the [local development tools reference page](https://developers.hubspot.com/docs/cms/developer-reference/local-development-cli).
|
|
37
|
-
|
|
38
|
-
**Note:** When `@hubspot/cli` is installed local to a project, the commands need to be prefixed with either `yarn` if using `yarn` or `npx` if using `npm`.
|
|
39
|
-
|
|
40
|
-
Initialize the CLI and create a config file
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
hs init
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Show all commands
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
hs help
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Upload a file or directory to the Design Manager
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
hs upload --account=DEV [src] [dest]
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Fetch a file or directory by path from the Design Manager
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
hs fetch --account=DEV [path] [dest]
|
|
62
|
-
|
|
63
|
-
# Overwrite existing files
|
|
64
|
-
hs fetch --account=DEV --overwrite [path] [dest]
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Watch a directory of files and automatically upload changes to the Design Manager
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
hs watch --account=DEV [src] [dest]
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Create a new asset locally
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
hs create [type] [dest]
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Delete a file or directory from the Design Manager
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
hs remove --account=DEV [path]
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Authenticate against an account using either `personalaccesskey` or `oauth2`
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
hs auth personalaccesskey
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### File Manager Commands
|
|
92
|
-
|
|
93
|
-
Upload a file or directory to the File Manager
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
hs filemanager upload --account=DEV [src] [dest]
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Fetch a file or directory from the File Manager
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
hs filemanager fetch --account=DEV [src] [dest]
|
|
103
|
-
|
|
104
|
-
# Overwrite existing files
|
|
105
|
-
hs filemanager fetch --account=DEV --overwrite [path] [dest]
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### HubDB Commands
|
|
109
|
-
|
|
110
|
-
Create a new HubDB table
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
hs hubdb create <src>
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Fetch a HubDB table
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
hs hubdb fetch <id or name> <src>
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Clear all rows in a HubDB table
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
hs hubdb clear <id or name>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Delete a HubDB table
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
hs hubdb delete <id or name>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Authentication
|
|
135
|
-
|
|
136
|
-
There are two ways that the tools can authenticate with HubSpot.
|
|
137
|
-
|
|
138
|
-
### Personal Access Key (recommended)
|
|
139
|
-
|
|
140
|
-
1. Run `hs init` or `hs auth personalaccesskey` and follow the instructions
|
|
141
|
-
|
|
142
|
-
### OAuth2
|
|
143
|
-
|
|
144
|
-
1. [Create a developer app](https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot)
|
|
145
|
-
2. Run `hs auth oauth2`
|
|
146
|
-
3. Select `OAuth2` and follow the steps
|
|
147
|
-
|
|
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
|
-
### Exit Codes
|
|
150
|
-
|
|
151
|
-
The CLI will exit with one of the following exit codes:
|
|
152
|
-
- `0`: A successful run
|
|
153
|
-
- `1`: There was a config problem or an internal error
|
|
154
|
-
- `2`: There are warnings or validation issues
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
const { command, describe: projectDescribe, builder } = require('../project');
|
|
2
|
-
|
|
3
|
-
jest.mock('../project/deploy');
|
|
4
|
-
jest.mock('../project/create');
|
|
5
|
-
jest.mock('../project/upload');
|
|
6
|
-
jest.mock('../project/listBuilds');
|
|
7
|
-
jest.mock('../project/logs');
|
|
8
|
-
jest.mock('../project/watch');
|
|
9
|
-
jest.mock('../project/download');
|
|
10
|
-
jest.mock('../project/open');
|
|
11
|
-
jest.mock('../project/dev');
|
|
12
|
-
jest.mock('../project/add');
|
|
13
|
-
jest.mock('../project/migrateApp');
|
|
14
|
-
jest.mock('../project/cloneApp');
|
|
15
|
-
jest.mock('../project/installDeps');
|
|
16
|
-
jest.mock('../../lib/commonOpts');
|
|
17
|
-
|
|
18
|
-
const deploy = require('../project/deploy');
|
|
19
|
-
const create = require('../project/create');
|
|
20
|
-
const upload = require('../project/upload');
|
|
21
|
-
const listBuilds = require('../project/listBuilds');
|
|
22
|
-
const logs = require('../project/logs');
|
|
23
|
-
const watch = require('../project/watch');
|
|
24
|
-
const download = require('../project/download');
|
|
25
|
-
const open = require('../project/open');
|
|
26
|
-
const dev = require('../project/dev');
|
|
27
|
-
const add = require('../project/add');
|
|
28
|
-
const migrateApp = require('../project/migrateApp');
|
|
29
|
-
const cloneApp = require('../project/cloneApp');
|
|
30
|
-
const installDeps = require('../project/installDeps');
|
|
31
|
-
const { addConfigOptions, addAccountOptions } = require('../../lib/commonOpts');
|
|
32
|
-
|
|
33
|
-
describe('commands/projects', () => {
|
|
34
|
-
describe('command', () => {
|
|
35
|
-
it('should have the correct command structure', () => {
|
|
36
|
-
expect(command).toEqual('project');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('describe', () => {
|
|
41
|
-
it('should contain the beta tag', () => {
|
|
42
|
-
expect(projectDescribe).toContain('[BETA]');
|
|
43
|
-
});
|
|
44
|
-
it('should provide an accurate description of what the command is doing', () => {
|
|
45
|
-
expect(projectDescribe).toContain(
|
|
46
|
-
'Commands for working with projects. For more information, visit our documentation: https://developers.hubspot.com/docs/platform/build-and-deploy-using-hubspot-projects'
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('builder', () => {
|
|
52
|
-
let yargs;
|
|
53
|
-
|
|
54
|
-
const subcommands = [
|
|
55
|
-
['create', create],
|
|
56
|
-
['add', add],
|
|
57
|
-
['watch', watch],
|
|
58
|
-
['dev', dev],
|
|
59
|
-
['upload', upload],
|
|
60
|
-
['deploy', deploy],
|
|
61
|
-
['logs', logs],
|
|
62
|
-
['listBuilds', listBuilds],
|
|
63
|
-
['download', download],
|
|
64
|
-
['open', open],
|
|
65
|
-
['migrateApp', migrateApp],
|
|
66
|
-
['cloneApp', cloneApp],
|
|
67
|
-
['installDeps', installDeps],
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
beforeEach(() => {
|
|
71
|
-
yargs = {
|
|
72
|
-
command: jest.fn().mockImplementation(() => yargs),
|
|
73
|
-
demandCommand: jest.fn().mockImplementation(() => yargs),
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should add the config options', () => {
|
|
78
|
-
builder(yargs);
|
|
79
|
-
expect(addConfigOptions).toHaveBeenCalledTimes(1);
|
|
80
|
-
expect(addConfigOptions).toHaveBeenCalledWith(yargs);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should add the account options', () => {
|
|
84
|
-
builder(yargs);
|
|
85
|
-
expect(addAccountOptions).toHaveBeenCalledTimes(1);
|
|
86
|
-
expect(addAccountOptions).toHaveBeenCalledWith(yargs);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should add the correct number of sub commands', () => {
|
|
90
|
-
builder(yargs);
|
|
91
|
-
expect(yargs.command).toHaveBeenCalledTimes(subcommands.length);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it.each(subcommands)('should attach the %s subcommand', (name, module) => {
|
|
95
|
-
builder(yargs);
|
|
96
|
-
expect(yargs.command).toHaveBeenCalledWith(module);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should demand the command takes one positional argument', () => {
|
|
100
|
-
builder(yargs);
|
|
101
|
-
expect(yargs.demandCommand).toHaveBeenCalledTimes(1);
|
|
102
|
-
expect(yargs.demandCommand).toHaveBeenCalledWith(1, '');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
jest.mock('../../../lib/commonOpts');
|
|
2
|
-
jest.mock('yargs');
|
|
3
|
-
jest.mock('@hubspot/local-dev-lib/logger');
|
|
4
|
-
jest.mock('@hubspot/local-dev-lib/api/projects');
|
|
5
|
-
jest.mock('../../../lib/validation');
|
|
6
|
-
jest.mock('../../../lib/projects');
|
|
7
|
-
jest.mock('../../../lib/prompts/projectNamePrompt');
|
|
8
|
-
jest.mock('../../../lib/prompts/deployBuildIdPrompt');
|
|
9
|
-
jest.mock('@hubspot/local-dev-lib/config');
|
|
10
|
-
jest.mock('../../../lib/usageTracking');
|
|
11
|
-
jest.mock('../../../lib/ui');
|
|
12
|
-
|
|
13
|
-
const libUi = jest.requireActual('../../../lib/ui');
|
|
14
|
-
const {
|
|
15
|
-
uiCommandReference,
|
|
16
|
-
uiAccountDescription,
|
|
17
|
-
uiBetaTag,
|
|
18
|
-
uiLink,
|
|
19
|
-
} = require('../../../lib/ui');
|
|
20
|
-
|
|
21
|
-
uiBetaTag.mockImplementation(libUi.uiBetaTag);
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
handler,
|
|
25
|
-
describe: deployDescribe,
|
|
26
|
-
command,
|
|
27
|
-
builder,
|
|
28
|
-
} = require('../deploy');
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
addAccountOptions,
|
|
32
|
-
addConfigOptions,
|
|
33
|
-
getAccountId,
|
|
34
|
-
addUseEnvironmentOptions,
|
|
35
|
-
} = require('../../../lib/commonOpts');
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
deployProject,
|
|
39
|
-
fetchProject,
|
|
40
|
-
} = require('@hubspot/local-dev-lib/api/projects');
|
|
41
|
-
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
42
|
-
const {
|
|
43
|
-
getProjectConfig,
|
|
44
|
-
pollDeployStatus,
|
|
45
|
-
getProjectDetailUrl,
|
|
46
|
-
} = require('../../../lib/projects');
|
|
47
|
-
const { projectNamePrompt } = require('../../../lib/prompts/projectNamePrompt');
|
|
48
|
-
const {
|
|
49
|
-
deployBuildIdPrompt,
|
|
50
|
-
} = require('../../../lib/prompts/deployBuildIdPrompt');
|
|
51
|
-
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
52
|
-
|
|
53
|
-
const yargs = require('yargs');
|
|
54
|
-
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
55
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
56
|
-
const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
57
|
-
const { AxiosError, HttpStatusCode } = require('axios');
|
|
58
|
-
|
|
59
|
-
const chalk = require('chalk');
|
|
60
|
-
const {
|
|
61
|
-
HubSpotHttpError,
|
|
62
|
-
} = require('@hubspot/local-dev-lib/models/HubSpotHttpError');
|
|
63
|
-
|
|
64
|
-
describe('commands/project/deploy', () => {
|
|
65
|
-
const projectFlag = 'project';
|
|
66
|
-
const buildFlag = 'build';
|
|
67
|
-
const buildAliases = ['buildId'];
|
|
68
|
-
|
|
69
|
-
describe('describe', () => {
|
|
70
|
-
it('should contain the beta tag', () => {
|
|
71
|
-
expect(deployDescribe).toContain('[BETA]');
|
|
72
|
-
});
|
|
73
|
-
it('should provide an accurate description of what the command is doing', () => {
|
|
74
|
-
expect(deployDescribe).toMatch(/Deploy a project build/);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('command', () => {
|
|
79
|
-
it('should the correct command structure', () => {
|
|
80
|
-
expect(command).toEqual('deploy');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('builder', () => {
|
|
85
|
-
it('should add the correct options', () => {
|
|
86
|
-
builder(yargs);
|
|
87
|
-
expect(yargs.options).toHaveBeenCalledTimes(1);
|
|
88
|
-
expect(yargs.options).toHaveBeenCalledWith({
|
|
89
|
-
[projectFlag]: {
|
|
90
|
-
describe: 'Project name',
|
|
91
|
-
type: 'string',
|
|
92
|
-
},
|
|
93
|
-
[buildFlag]: {
|
|
94
|
-
alias: buildAliases,
|
|
95
|
-
describe: 'Project build ID to be deployed',
|
|
96
|
-
type: 'number',
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should add the correct examples', () => {
|
|
102
|
-
builder(yargs);
|
|
103
|
-
expect(yargs.example).toHaveBeenCalledTimes(1);
|
|
104
|
-
expect(yargs.example).toHaveBeenCalledWith([
|
|
105
|
-
['$0 project deploy', 'Deploy the latest build of the current project'],
|
|
106
|
-
[
|
|
107
|
-
`$0 project deploy --${projectFlag}="my-project" --${buildFlag}=5`,
|
|
108
|
-
'Deploy build 5 of the project my-project',
|
|
109
|
-
],
|
|
110
|
-
]);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should add the config options', () => {
|
|
114
|
-
builder(yargs);
|
|
115
|
-
expect(addConfigOptions).toHaveBeenCalledTimes(1);
|
|
116
|
-
expect(addConfigOptions).toHaveBeenCalledWith(yargs);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should add the account options', () => {
|
|
120
|
-
builder(yargs);
|
|
121
|
-
expect(addAccountOptions).toHaveBeenCalledTimes(1);
|
|
122
|
-
expect(addAccountOptions).toHaveBeenCalledWith(yargs);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should add the environment options', () => {
|
|
126
|
-
builder(yargs);
|
|
127
|
-
expect(addUseEnvironmentOptions).toHaveBeenCalledTimes(1);
|
|
128
|
-
expect(addUseEnvironmentOptions).toHaveBeenCalledWith(yargs);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should the yargs object it is passed', () => {
|
|
132
|
-
expect(builder(yargs)).toEqual(yargs);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('handler', () => {
|
|
137
|
-
let projectConfig;
|
|
138
|
-
let processExitSpy;
|
|
139
|
-
const accountId = 1234567890;
|
|
140
|
-
const accountType = 'STANDARD';
|
|
141
|
-
let options;
|
|
142
|
-
const projectDetails = {
|
|
143
|
-
latestBuild: { buildId: 8 },
|
|
144
|
-
deployedBuildId: 1,
|
|
145
|
-
};
|
|
146
|
-
const deployDetails = {
|
|
147
|
-
id: 123,
|
|
148
|
-
};
|
|
149
|
-
const projectDetailUrl = 'http://project-details-page-url.com';
|
|
150
|
-
const viewProjectsInHubSpot = 'View project builds in HubSpot';
|
|
151
|
-
|
|
152
|
-
beforeEach(() => {
|
|
153
|
-
options = {
|
|
154
|
-
project: 'project name from options',
|
|
155
|
-
buildId: 2,
|
|
156
|
-
accountId,
|
|
157
|
-
};
|
|
158
|
-
projectConfig = {
|
|
159
|
-
name: 'project name from config',
|
|
160
|
-
};
|
|
161
|
-
getProjectConfig.mockResolvedValue({ projectConfig });
|
|
162
|
-
projectNamePrompt.mockResolvedValue({ projectName: 'fooo' });
|
|
163
|
-
getProjectDetailUrl.mockReturnValue(projectDetailUrl);
|
|
164
|
-
uiLink.mockImplementation(text => {
|
|
165
|
-
return text;
|
|
166
|
-
});
|
|
167
|
-
getAccountId.mockReturnValue(accountId);
|
|
168
|
-
getAccountConfig.mockReturnValue({ accountType });
|
|
169
|
-
fetchProject.mockResolvedValue({ data: projectDetails });
|
|
170
|
-
deployProject.mockResolvedValue({ data: deployDetails });
|
|
171
|
-
deployBuildIdPrompt.mockResolvedValue({
|
|
172
|
-
buildId: projectDetails.latestBuild.buildId,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Spy on process.exit so our tests don't close when it's called
|
|
176
|
-
processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should load and validate the options', async () => {
|
|
180
|
-
await handler(options);
|
|
181
|
-
expect(loadAndValidateOptions).toHaveBeenCalledTimes(1);
|
|
182
|
-
expect(loadAndValidateOptions).toHaveBeenCalledWith(options);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should get the account id from the options', async () => {
|
|
186
|
-
await handler(options);
|
|
187
|
-
expect(getAccountId).toHaveBeenCalledTimes(1);
|
|
188
|
-
expect(getAccountId).toHaveBeenCalledWith(options);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('should load the account config for the correct account id', async () => {
|
|
192
|
-
await handler(options);
|
|
193
|
-
expect(getAccountConfig).toHaveBeenCalledTimes(1);
|
|
194
|
-
expect(getAccountConfig).toHaveBeenCalledWith(accountId);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('should track the command usage', async () => {
|
|
198
|
-
await handler(options);
|
|
199
|
-
expect(trackCommandUsage).toHaveBeenCalledTimes(1);
|
|
200
|
-
expect(trackCommandUsage).toHaveBeenCalledWith(
|
|
201
|
-
'project-deploy',
|
|
202
|
-
{ type: accountType },
|
|
203
|
-
accountId
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('should load the project config', async () => {
|
|
208
|
-
await handler(options);
|
|
209
|
-
expect(getProjectConfig).toHaveBeenCalledTimes(1);
|
|
210
|
-
expect(getProjectConfig).toHaveBeenCalledWith();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should load the project config', async () => {
|
|
214
|
-
await handler(options);
|
|
215
|
-
expect(getProjectConfig).toHaveBeenCalledTimes(1);
|
|
216
|
-
expect(getProjectConfig).toHaveBeenCalledWith();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should prompt for the project name', async () => {
|
|
220
|
-
await handler(options);
|
|
221
|
-
expect(projectNamePrompt).toHaveBeenCalledTimes(1);
|
|
222
|
-
expect(projectNamePrompt).toHaveBeenCalledWith(accountId, {
|
|
223
|
-
project: options.project,
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('should use the project name from the config is a project options is not provided', async () => {
|
|
228
|
-
delete options.project;
|
|
229
|
-
await handler(options);
|
|
230
|
-
expect(projectNamePrompt).toHaveBeenCalledTimes(1);
|
|
231
|
-
expect(projectNamePrompt).toHaveBeenCalledWith(accountId, {
|
|
232
|
-
project: projectConfig.name,
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('should fetch the project details', async () => {
|
|
237
|
-
await handler(options);
|
|
238
|
-
expect(fetchProject).toHaveBeenCalledTimes(1);
|
|
239
|
-
expect(fetchProject).toHaveBeenCalledWith(accountId, options.project);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('should use the name from the prompt if no others are defined', async () => {
|
|
243
|
-
delete options.project;
|
|
244
|
-
const promptProjectName = 'project name from the prompt';
|
|
245
|
-
projectNamePrompt.mockReturnValue({ projectName: promptProjectName });
|
|
246
|
-
getProjectConfig.mockResolvedValue({});
|
|
247
|
-
|
|
248
|
-
await handler(options);
|
|
249
|
-
|
|
250
|
-
expect(projectNamePrompt).toHaveBeenCalledTimes(1);
|
|
251
|
-
expect(projectNamePrompt).toHaveBeenCalledWith(accountId, {});
|
|
252
|
-
expect(fetchProject).toHaveBeenCalledTimes(1);
|
|
253
|
-
expect(fetchProject).toHaveBeenCalledWith(accountId, promptProjectName);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should log an error and exit when latest build is not defined', async () => {
|
|
257
|
-
fetchProject.mockResolvedValue({ data: {} });
|
|
258
|
-
await handler(options);
|
|
259
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
260
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
261
|
-
'Deploy error: no builds for this project were found.'
|
|
262
|
-
);
|
|
263
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
264
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('should log an error and exit when buildId option is not a valid build', async () => {
|
|
268
|
-
options.buildId = projectDetails.latestBuild.buildId + 1;
|
|
269
|
-
await handler(options);
|
|
270
|
-
expect(uiLink).toHaveBeenCalledTimes(1);
|
|
271
|
-
expect(uiLink).toHaveBeenCalledWith(
|
|
272
|
-
viewProjectsInHubSpot,
|
|
273
|
-
projectDetailUrl
|
|
274
|
-
);
|
|
275
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
276
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
277
|
-
`Build ${options.buildId} does not exist for project ${options.project}. ${viewProjectsInHubSpot}`
|
|
278
|
-
);
|
|
279
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
280
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('should log an error and exit when buildId option is already deployed', async () => {
|
|
284
|
-
options.buildId = projectDetails.deployedBuildId;
|
|
285
|
-
await handler(options);
|
|
286
|
-
expect(uiLink).toHaveBeenCalledTimes(1);
|
|
287
|
-
expect(uiLink).toHaveBeenCalledWith(
|
|
288
|
-
viewProjectsInHubSpot,
|
|
289
|
-
projectDetailUrl
|
|
290
|
-
);
|
|
291
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
292
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
293
|
-
`Build ${options.buildId} is already deployed. ${viewProjectsInHubSpot}`
|
|
294
|
-
);
|
|
295
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
296
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('should prompt for build id if no option is provided', async () => {
|
|
300
|
-
delete options.buildId;
|
|
301
|
-
await handler(options);
|
|
302
|
-
expect(deployBuildIdPrompt).toHaveBeenCalledTimes(1);
|
|
303
|
-
expect(deployBuildIdPrompt).toHaveBeenCalledWith(
|
|
304
|
-
projectDetails.latestBuild.buildId,
|
|
305
|
-
projectDetails.deployedBuildId,
|
|
306
|
-
expect.any(Function)
|
|
307
|
-
);
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('should log an error and exit if the prompted value is invalid', async () => {
|
|
311
|
-
delete options.buildId;
|
|
312
|
-
deployBuildIdPrompt.mockReturnValue({});
|
|
313
|
-
|
|
314
|
-
await handler(options);
|
|
315
|
-
|
|
316
|
-
expect(deployBuildIdPrompt).toHaveBeenCalledTimes(1);
|
|
317
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
318
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
319
|
-
'You must specify a build to deploy'
|
|
320
|
-
);
|
|
321
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
322
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
it('should deploy the project', async () => {
|
|
326
|
-
await handler(options);
|
|
327
|
-
expect(deployProject).toHaveBeenCalledTimes(1);
|
|
328
|
-
expect(deployProject).toHaveBeenCalledWith(
|
|
329
|
-
accountId,
|
|
330
|
-
options.project,
|
|
331
|
-
options.buildId
|
|
332
|
-
);
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('should log an error and exit when the deploy fails', async () => {
|
|
336
|
-
const errorMessage = `Just wasn't feeling it`;
|
|
337
|
-
deployProject.mockResolvedValue({
|
|
338
|
-
data: {
|
|
339
|
-
error: { message: errorMessage },
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
await handler(options);
|
|
344
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
345
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
346
|
-
`Deploy error: ${errorMessage}`
|
|
347
|
-
);
|
|
348
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
349
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('should poll the deploy status', async () => {
|
|
353
|
-
await handler(options);
|
|
354
|
-
expect(pollDeployStatus).toHaveBeenCalledTimes(1);
|
|
355
|
-
expect(pollDeployStatus).toHaveBeenCalledWith(
|
|
356
|
-
accountId,
|
|
357
|
-
options.project,
|
|
358
|
-
deployDetails.id,
|
|
359
|
-
options.buildId
|
|
360
|
-
);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('log an error and exit if a 404 status is returned', async () => {
|
|
364
|
-
const commandReference = 'hs project upload';
|
|
365
|
-
const accountDescription = 'SuperCoolTestAccount';
|
|
366
|
-
uiCommandReference.mockReturnValue(commandReference);
|
|
367
|
-
uiAccountDescription.mockReturnValue(accountDescription);
|
|
368
|
-
fetchProject.mockImplementation(() => {
|
|
369
|
-
throw new HubSpotHttpError('OH NO', {
|
|
370
|
-
cause: new AxiosError(
|
|
371
|
-
'OH NO',
|
|
372
|
-
'',
|
|
373
|
-
{},
|
|
374
|
-
{},
|
|
375
|
-
{ status: HttpStatusCode.NotFound }
|
|
376
|
-
),
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
await handler(options);
|
|
380
|
-
|
|
381
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
382
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
383
|
-
`The project ${chalk.bold(
|
|
384
|
-
options.project
|
|
385
|
-
)} does not exist in account ${accountDescription}. Run ${commandReference} to upload your project files to HubSpot.`
|
|
386
|
-
);
|
|
387
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
388
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
it('log an error and exit if a 400 status is returned', async () => {
|
|
392
|
-
const commandReference = 'hs project upload';
|
|
393
|
-
const accountDescription = 'SuperCoolTestAccount';
|
|
394
|
-
uiCommandReference.mockReturnValue(commandReference);
|
|
395
|
-
uiAccountDescription.mockReturnValue(accountDescription);
|
|
396
|
-
const errorMessage = 'Something bad happened';
|
|
397
|
-
fetchProject.mockImplementation(() => {
|
|
398
|
-
throw new HubSpotHttpError(errorMessage, {
|
|
399
|
-
cause: new AxiosError(
|
|
400
|
-
errorMessage,
|
|
401
|
-
'',
|
|
402
|
-
{},
|
|
403
|
-
{},
|
|
404
|
-
{ status: HttpStatusCode.BadRequest }
|
|
405
|
-
),
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
await handler(options);
|
|
409
|
-
|
|
410
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
411
|
-
expect(logger.error).toHaveBeenCalledWith('The request was bad.');
|
|
412
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
413
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('log an error another unexpected status code is returned', async () => {
|
|
417
|
-
const commandReference = 'hs project upload';
|
|
418
|
-
const accountDescription = 'SuperCoolTestAccount';
|
|
419
|
-
uiCommandReference.mockReturnValue(commandReference);
|
|
420
|
-
uiAccountDescription.mockReturnValue(accountDescription);
|
|
421
|
-
const errorMessage = 'Something bad happened';
|
|
422
|
-
fetchProject.mockImplementation(() => {
|
|
423
|
-
throw new HubSpotHttpError('OH NO', {
|
|
424
|
-
cause: new AxiosError(
|
|
425
|
-
errorMessage,
|
|
426
|
-
'',
|
|
427
|
-
{},
|
|
428
|
-
{},
|
|
429
|
-
{ status: HttpStatusCode.MethodNotAllowed }
|
|
430
|
-
),
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
await handler(options);
|
|
434
|
-
|
|
435
|
-
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
436
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
437
|
-
`The request for 'project deploy' in account ${accountId} failed due to a client error.`
|
|
438
|
-
);
|
|
439
|
-
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
440
|
-
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
});
|