@hubspot/cli 5.1.4-beta.1 → 5.1.4-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/bin/cli.js +1 -1
- package/commands/accounts/clean.js +1 -1
- package/commands/accounts/info.js +1 -1
- package/commands/accounts/list.js +12 -16
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +1 -1
- package/commands/accounts/use.js +1 -1
- package/commands/auth.js +1 -1
- package/commands/cms/convertFields.js +1 -1
- package/commands/cms/lighthouseScore.js +1 -1
- package/commands/cms/reactModules.js +67 -0
- package/commands/cms.js +2 -0
- package/commands/config/set/allowUsageTracking.js +1 -1
- package/commands/config/set/defaultMode.js +1 -1
- package/commands/config/set/httpTimeout.js +1 -1
- package/commands/create/api-sample.js +1 -1
- package/commands/create/module.js +3 -3
- package/commands/create/template.js +1 -1
- package/commands/create.js +10 -4
- package/commands/customObject/create.js +1 -1
- package/commands/customObject/schema/create.js +1 -1
- package/commands/customObject/schema/delete.js +1 -1
- package/commands/customObject/schema/fetch-all.js +1 -1
- package/commands/customObject/schema/fetch.js +1 -1
- package/commands/customObject/schema/list.js +1 -1
- package/commands/customObject/schema/update.js +1 -1
- package/commands/customObject.js +1 -1
- package/commands/feedback.js +1 -1
- package/commands/fetch.js +1 -1
- package/commands/filemanager/fetch.js +1 -1
- package/commands/filemanager/upload.js +1 -1
- package/commands/functions/deploy.js +1 -1
- package/commands/functions/list.js +1 -1
- package/commands/functions/server.js +1 -1
- package/commands/hubdb/clear.js +1 -1
- package/commands/hubdb/create.js +1 -1
- package/commands/hubdb/delete.js +1 -1
- package/commands/hubdb/fetch.js +1 -1
- package/commands/init.js +1 -1
- package/commands/lint.js +1 -1
- package/commands/list.js +1 -1
- package/commands/logs.js +1 -1
- package/commands/mv.js +1 -1
- package/commands/project/add.js +1 -1
- package/commands/project/create.js +1 -1
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev.js +11 -9
- package/commands/project/download.js +1 -1
- package/commands/project/listBuilds.js +1 -1
- package/commands/project/logs.js +1 -1
- package/commands/project/open.js +1 -1
- package/commands/project/upload.js +3 -3
- package/commands/project/watch.js +1 -1
- package/commands/remove.js +1 -1
- package/commands/sandbox/create.js +24 -13
- package/commands/sandbox/delete.js +1 -1
- package/commands/sandbox/sync.js +19 -16
- package/commands/secrets/addSecret.js +1 -1
- package/commands/secrets/deleteSecret.js +1 -1
- package/commands/secrets/listSecrets.js +1 -1
- package/commands/secrets/updateSecret.js +1 -1
- package/commands/theme/generate-selectors.js +1 -1
- package/commands/theme/preview.js +175 -0
- package/commands/theme.js +2 -0
- package/commands/upload.js +1 -1
- package/commands/watch.js +1 -1
- package/lang/en.lyaml +41 -2
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +1 -1
- package/lib/__tests__/validation.js +1 -1
- package/lib/commonOpts.js +4 -13
- package/lib/constants.js +0 -11
- package/lib/developerTestAccounts.js +0 -3
- package/lib/errorHandlers/apiErrors.js +1 -1
- package/lib/errorHandlers/fileSystemErrors.js +1 -1
- package/lib/errorHandlers/standardErrors.js +1 -1
- package/lib/generate-selectors.js +1 -1
- package/lib/hublValidate.js +1 -1
- package/lib/lang.js +1 -1
- package/lib/links.js +1 -1
- package/lib/marketplace-validate.js +1 -1
- package/lib/oauth.js +1 -1
- package/lib/process.js +5 -1
- package/lib/projectStructure.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projectsWatch.js +1 -1
- package/lib/prompts/createModulePrompt.js +14 -1
- package/lib/prompts/createProjectPrompt.js +1 -1
- package/lib/prompts/personalAccessKeyPrompt.js +1 -1
- package/lib/prompts/previewPrompt.js +39 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +10 -11
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/prompts/sandboxesPrompt.js +13 -16
- package/lib/sandboxCreate.js +12 -10
- package/lib/sandboxSync.js +4 -9
- package/lib/sandboxes.js +37 -42
- package/lib/schema.js +1 -1
- package/lib/serverlessLogs.js +1 -1
- package/lib/ui.js +8 -5
- package/lib/usageTracking.js +1 -1
- package/lib/validation.js +1 -1
- package/package.json +5 -4
package/commands/project/dev.js
CHANGED
|
@@ -12,7 +12,7 @@ const {
|
|
|
12
12
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
13
13
|
const { handleExit } = require('../../lib/process');
|
|
14
14
|
const { i18n } = require('../../lib/lang');
|
|
15
|
-
const { logger } = require('@hubspot/
|
|
15
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
16
16
|
const {
|
|
17
17
|
getConfigAccounts,
|
|
18
18
|
getAccountConfig,
|
|
@@ -69,11 +69,11 @@ const {
|
|
|
69
69
|
isMissingScopeError,
|
|
70
70
|
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
71
71
|
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
72
|
+
const { isDeveloperTestAccount } = require('../../lib/developerTestAccounts');
|
|
72
73
|
const {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} = require('
|
|
76
|
-
const { DEVELOPER_SANDBOX_TYPE } = require('../../lib/constants');
|
|
74
|
+
HUBSPOT_ACCOUNT_TYPES,
|
|
75
|
+
HUBSPOT_ACCOUNT_TYPE_STRINGS,
|
|
76
|
+
} = require('@hubspot/local-dev-lib/constants/config');
|
|
77
77
|
|
|
78
78
|
const i18nKey = 'cli.commands.project.subcommands.dev';
|
|
79
79
|
|
|
@@ -116,7 +116,7 @@ exports.handler = async options => {
|
|
|
116
116
|
accountConfig.name,
|
|
117
117
|
defaultAccountIsSandbox
|
|
118
118
|
? `${getSandboxTypeAsString(accountConfig.accountType)} sandbox`
|
|
119
|
-
:
|
|
119
|
+
: HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
if (useDefaultAccount) {
|
|
@@ -152,7 +152,7 @@ exports.handler = async options => {
|
|
|
152
152
|
try {
|
|
153
153
|
await validateSandboxUsageLimits(
|
|
154
154
|
accountConfig,
|
|
155
|
-
|
|
155
|
+
HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
156
156
|
env
|
|
157
157
|
);
|
|
158
158
|
} catch (err) {
|
|
@@ -176,7 +176,9 @@ exports.handler = async options => {
|
|
|
176
176
|
process.exit(EXIT_CODES.ERROR);
|
|
177
177
|
}
|
|
178
178
|
try {
|
|
179
|
-
const { name } = await sandboxNamePrompt(
|
|
179
|
+
const { name } = await sandboxNamePrompt(
|
|
180
|
+
HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
|
|
181
|
+
);
|
|
180
182
|
|
|
181
183
|
trackCommandMetadataUsage(
|
|
182
184
|
'sandbox-create',
|
|
@@ -186,7 +188,7 @@ exports.handler = async options => {
|
|
|
186
188
|
|
|
187
189
|
const { result } = await buildSandbox({
|
|
188
190
|
name,
|
|
189
|
-
type:
|
|
191
|
+
type: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
190
192
|
accountConfig,
|
|
191
193
|
env,
|
|
192
194
|
});
|
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
logApiErrorInstance,
|
|
12
12
|
ApiErrorContext,
|
|
13
13
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
14
|
-
const { logger } = require('@hubspot/
|
|
14
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
15
15
|
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
|
|
16
16
|
const {
|
|
17
17
|
downloadProject,
|
|
@@ -12,7 +12,7 @@ const {
|
|
|
12
12
|
logApiErrorInstance,
|
|
13
13
|
ApiErrorContext,
|
|
14
14
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
15
|
-
const { logger } = require('@hubspot/
|
|
15
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
16
16
|
const {
|
|
17
17
|
fetchProject,
|
|
18
18
|
fetchProjectBuilds,
|
package/commands/project/logs.js
CHANGED
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
addUseEnvironmentOptions,
|
|
9
9
|
} = require('../../lib/commonOpts');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
-
const { logger } = require('@hubspot/
|
|
11
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
12
12
|
// const { outputLogs } = require('@hubspot/cli-lib/lib/logs');
|
|
13
13
|
const {
|
|
14
14
|
fetchProject,
|
package/commands/project/open.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
|
-
const { logger } = require('@hubspot/
|
|
12
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
13
13
|
const {
|
|
14
14
|
getProjectConfig,
|
|
15
15
|
getProjectDetailUrl,
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
addUseEnvironmentOptions,
|
|
6
6
|
} = require('../../lib/commonOpts');
|
|
7
7
|
const chalk = require('chalk');
|
|
8
|
-
const { logger } = require('@hubspot/
|
|
8
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
9
9
|
const { uiBetaTag, uiLine } = require('../../lib/ui');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
11
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -39,9 +39,9 @@ exports.handler = async options => {
|
|
|
39
39
|
const { forceCreate, path: projectPath, message } = options;
|
|
40
40
|
const accountId = getAccountId(options);
|
|
41
41
|
const accountConfig = getAccountConfig(accountId);
|
|
42
|
-
const
|
|
42
|
+
const accountType = accountConfig && accountConfig.accountType;
|
|
43
43
|
|
|
44
|
-
trackCommandUsage('project-upload', { type:
|
|
44
|
+
trackCommandUsage('project-upload', { type: accountType }, accountId);
|
|
45
45
|
|
|
46
46
|
const { projectConfig, projectDir } = await getProjectConfig(projectPath);
|
|
47
47
|
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
logApiErrorInstance,
|
|
5
5
|
ApiErrorContext,
|
|
6
6
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
7
|
-
const { logger } = require('@hubspot/
|
|
7
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
8
|
const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
9
9
|
const {
|
|
10
10
|
addAccountOptions,
|
package/commands/remove.js
CHANGED
|
@@ -13,13 +13,12 @@ const { buildSandbox } = require('../../lib/sandboxCreate');
|
|
|
13
13
|
const { uiFeatureHighlight, uiAccountDescription } = require('../../lib/ui');
|
|
14
14
|
const {
|
|
15
15
|
sandboxTypeMap,
|
|
16
|
-
getSandboxTypeAsString,
|
|
17
16
|
getAvailableSyncTypes,
|
|
18
17
|
syncTypes,
|
|
19
18
|
validateSandboxUsageLimits,
|
|
20
19
|
} = require('../../lib/sandboxes');
|
|
21
20
|
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
22
|
-
const { logger } = require('@hubspot/
|
|
21
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
23
22
|
const {
|
|
24
23
|
trackCommandUsage,
|
|
25
24
|
trackCommandMetadataUsage,
|
|
@@ -35,7 +34,10 @@ const {
|
|
|
35
34
|
isMissingScopeError,
|
|
36
35
|
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
37
36
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
38
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
HUBSPOT_ACCOUNT_TYPES,
|
|
39
|
+
HUBSPOT_ACCOUNT_TYPE_STRINGS,
|
|
40
|
+
} = require('@hubspot/local-dev-lib/constants/config');
|
|
39
41
|
|
|
40
42
|
const i18nKey = 'cli.commands.sandbox.subcommands.create';
|
|
41
43
|
|
|
@@ -54,13 +56,16 @@ exports.handler = async options => {
|
|
|
54
56
|
|
|
55
57
|
// Default account is not a production portal
|
|
56
58
|
if (
|
|
57
|
-
accountConfig.
|
|
58
|
-
accountConfig.
|
|
59
|
+
accountConfig.accountType &&
|
|
60
|
+
accountConfig.accountType !== HUBSPOT_ACCOUNT_TYPES.STANDARD
|
|
59
61
|
) {
|
|
60
62
|
logger.error(
|
|
61
|
-
i18n(`${i18nKey}.failure.
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
i18n(`${i18nKey}.failure.invalidAccountType`, {
|
|
64
|
+
accountType:
|
|
65
|
+
HUBSPOT_ACCOUNT_TYPE_STRINGS[
|
|
66
|
+
HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
|
|
67
|
+
],
|
|
68
|
+
accountName: accountConfig.name,
|
|
64
69
|
})
|
|
65
70
|
);
|
|
66
71
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -69,7 +74,7 @@ exports.handler = async options => {
|
|
|
69
74
|
let typePrompt;
|
|
70
75
|
let namePrompt;
|
|
71
76
|
|
|
72
|
-
if ((type && !sandboxTypeMap[type]) || !type) {
|
|
77
|
+
if ((type && !sandboxTypeMap[type.toLowerCase()]) || !type) {
|
|
73
78
|
if (!force) {
|
|
74
79
|
typePrompt = await sandboxTypePrompt();
|
|
75
80
|
} else {
|
|
@@ -77,7 +82,9 @@ exports.handler = async options => {
|
|
|
77
82
|
process.exit(EXIT_CODES.ERROR);
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
|
-
const sandboxType =
|
|
85
|
+
const sandboxType = type
|
|
86
|
+
? sandboxTypeMap[type.toLowerCase()]
|
|
87
|
+
: typePrompt.type;
|
|
81
88
|
|
|
82
89
|
// Check usage limits and exit if parent portal has no available sandboxes for the selected type
|
|
83
90
|
try {
|
|
@@ -117,11 +124,15 @@ exports.handler = async options => {
|
|
|
117
124
|
let contactRecordsSyncPromptResult = true;
|
|
118
125
|
if (!force) {
|
|
119
126
|
const syncI18nKey = 'cli.lib.sandbox.sync';
|
|
127
|
+
const sandboxLangKey =
|
|
128
|
+
sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
|
|
129
|
+
? 'developer'
|
|
130
|
+
: 'standard';
|
|
120
131
|
const { sandboxSyncPrompt } = await promptUser([
|
|
121
132
|
{
|
|
122
133
|
name: 'sandboxSyncPrompt',
|
|
123
134
|
type: 'confirm',
|
|
124
|
-
message: i18n(`${syncI18nKey}.confirm.createFlow.${
|
|
135
|
+
message: i18n(`${syncI18nKey}.confirm.createFlow.${sandboxLangKey}`, {
|
|
125
136
|
parentAccountName: uiAccountDescription(accountId),
|
|
126
137
|
sandboxName,
|
|
127
138
|
}),
|
|
@@ -135,7 +146,7 @@ exports.handler = async options => {
|
|
|
135
146
|
name: 'contactRecordsSyncPrompt',
|
|
136
147
|
type: 'confirm',
|
|
137
148
|
message: i18n(
|
|
138
|
-
`${syncI18nKey}.confirm.syncContactRecords.${
|
|
149
|
+
`${syncI18nKey}.confirm.syncContactRecords.${sandboxLangKey}`
|
|
139
150
|
),
|
|
140
151
|
},
|
|
141
152
|
]);
|
|
@@ -191,7 +202,7 @@ exports.handler = async options => {
|
|
|
191
202
|
}
|
|
192
203
|
|
|
193
204
|
const highlightItems = ['accountsUseCommand', 'projectCreateCommand'];
|
|
194
|
-
if (sandboxType ===
|
|
205
|
+
if (sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
195
206
|
highlightItems.push('projectDevCommand');
|
|
196
207
|
} else {
|
|
197
208
|
highlightItems.push('projectUploadCommand');
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
getAccountId,
|
|
6
6
|
addTestingOptions,
|
|
7
7
|
} = require('../../lib/commonOpts');
|
|
8
|
-
const { logger } = require('@hubspot/
|
|
8
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
11
|
const {
|
package/commands/sandbox/sync.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
addTestingOptions,
|
|
7
7
|
} = require('../../lib/commonOpts');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { logger } = require('@hubspot/
|
|
9
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
@@ -15,18 +15,20 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
|
15
15
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
16
16
|
const { uiLine, uiAccountDescription } = require('../../lib/ui');
|
|
17
17
|
const {
|
|
18
|
-
sandboxTypeMap,
|
|
19
18
|
getAvailableSyncTypes,
|
|
20
19
|
getSyncTypesWithContactRecordsPrompt,
|
|
20
|
+
isDevelopmentSandbox,
|
|
21
|
+
isStandardSandbox,
|
|
22
|
+
isSandbox,
|
|
21
23
|
} = require('../../lib/sandboxes');
|
|
22
24
|
const { syncSandbox } = require('../../lib/sandboxSync');
|
|
23
25
|
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
24
26
|
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
25
27
|
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
26
28
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} = require('
|
|
29
|
+
HUBSPOT_ACCOUNT_TYPE_STRINGS,
|
|
30
|
+
HUBSPOT_ACCOUNT_TYPES,
|
|
31
|
+
} = require('@hubspot/local-dev-lib/constants/config');
|
|
30
32
|
|
|
31
33
|
const i18nKey = 'cli.commands.sandbox.subcommands.sync';
|
|
32
34
|
|
|
@@ -43,17 +45,22 @@ exports.handler = async options => {
|
|
|
43
45
|
|
|
44
46
|
trackCommandUsage(
|
|
45
47
|
'sandbox-sync',
|
|
46
|
-
{ type: accountConfig.
|
|
48
|
+
{ type: accountConfig.accountType },
|
|
47
49
|
accountId
|
|
48
50
|
);
|
|
49
51
|
|
|
50
52
|
if (
|
|
51
53
|
// Check if default account is a sandbox, otherwise exit
|
|
52
|
-
|
|
53
|
-
accountConfig.sandboxAccountType === undefined ||
|
|
54
|
-
accountConfig.sandboxAccountType === null
|
|
54
|
+
!isSandbox(accountConfig)
|
|
55
55
|
) {
|
|
56
|
-
logger.error(
|
|
56
|
+
logger.error(
|
|
57
|
+
i18n(`${i18nKey}.failure.invalidAccountType`, {
|
|
58
|
+
accountType:
|
|
59
|
+
HUBSPOT_ACCOUNT_TYPE_STRINGS[
|
|
60
|
+
HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
|
|
61
|
+
],
|
|
62
|
+
})
|
|
63
|
+
);
|
|
57
64
|
process.exit(EXIT_CODES.ERROR);
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -70,10 +77,6 @@ exports.handler = async options => {
|
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
const parentAccountConfig = getAccountConfig(parentAccountId);
|
|
73
|
-
const isDevelopmentSandbox =
|
|
74
|
-
sandboxTypeMap[accountConfig.sandboxAccountType] === DEVELOPER_SANDBOX_TYPE;
|
|
75
|
-
const isStandardSandbox =
|
|
76
|
-
sandboxTypeMap[accountConfig.sandboxAccountType] === STANDARD_SANDBOX_TYPE;
|
|
77
80
|
|
|
78
81
|
let availableSyncTasks;
|
|
79
82
|
try {
|
|
@@ -100,7 +103,7 @@ exports.handler = async options => {
|
|
|
100
103
|
process.exit(EXIT_CODES.ERROR);
|
|
101
104
|
}
|
|
102
105
|
|
|
103
|
-
if (isDevelopmentSandbox) {
|
|
106
|
+
if (isDevelopmentSandbox(accountConfig)) {
|
|
104
107
|
logger.log(i18n(`${i18nKey}.info.developmentSandbox`));
|
|
105
108
|
logger.log(
|
|
106
109
|
i18n(`${i18nKey}.info.sync`, {
|
|
@@ -129,7 +132,7 @@ exports.handler = async options => {
|
|
|
129
132
|
process.exit(EXIT_CODES.SUCCESS);
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
|
-
} else if (isStandardSandbox) {
|
|
135
|
+
} else if (isStandardSandbox(accountConfig)) {
|
|
133
136
|
const standardSyncUrl = `${getHubSpotWebsiteOrigin(
|
|
134
137
|
env
|
|
135
138
|
)}/sandboxes-developer/${parentAccountId}/sync?step=select_sync_path&id=${parentAccountId}_${accountId}`;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { i18n } = require('../../lib/lang');
|
|
4
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
+
const {
|
|
6
|
+
addAccountOptions,
|
|
7
|
+
addConfigOptions,
|
|
8
|
+
getAccountId,
|
|
9
|
+
} = require('../../lib/commonOpts');
|
|
10
|
+
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
11
|
+
const { preview } = require('@hubspot/theme-preview-dev-server');
|
|
12
|
+
const { getUploadableFileList } = require('../../lib/upload');
|
|
13
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
14
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
|
+
const { previewPrompt } = require('../../lib/prompts/previewPrompt');
|
|
16
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
17
|
+
const { FileUploadResultType } = require('@hubspot/cli-lib/lib/uploadFolder');
|
|
18
|
+
const i18nKey = 'cli.commands.preview';
|
|
19
|
+
const cliProgress = require('cli-progress');
|
|
20
|
+
const {
|
|
21
|
+
ApiErrorContext,
|
|
22
|
+
logApiUploadErrorInstance,
|
|
23
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
24
|
+
|
|
25
|
+
const validateSrcPath = src => {
|
|
26
|
+
const logInvalidPath = () => {
|
|
27
|
+
logger.error(
|
|
28
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
29
|
+
path: src,
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
const stats = fs.statSync(src);
|
|
35
|
+
if (!stats.isDirectory()) {
|
|
36
|
+
logInvalidPath();
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
logInvalidPath();
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.command = 'preview [--src] [--dest]';
|
|
47
|
+
exports.describe = false; // i18n(`${i18nKey}.describe`) - Hiding command
|
|
48
|
+
|
|
49
|
+
exports.handler = async options => {
|
|
50
|
+
const { notify, skipUpload, noSsl, port, debug } = options;
|
|
51
|
+
|
|
52
|
+
await loadAndValidateOptions(options);
|
|
53
|
+
|
|
54
|
+
const accountId = getAccountId(options);
|
|
55
|
+
|
|
56
|
+
const previewPromptAnswers = await previewPrompt(options);
|
|
57
|
+
const src = options.src || previewPromptAnswers.src;
|
|
58
|
+
let dest = options.dest || previewPromptAnswers.dest;
|
|
59
|
+
if (!dest) {
|
|
60
|
+
logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const absoluteSrc = path.resolve(getCwd(), src);
|
|
65
|
+
if (!validateSrcPath(absoluteSrc)) {
|
|
66
|
+
process.exit(EXIT_CODES.ERROR);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const filePaths = await getUploadableFileList(absoluteSrc, false);
|
|
70
|
+
|
|
71
|
+
const initialUploadProgressBar = new cliProgress.SingleBar(
|
|
72
|
+
{
|
|
73
|
+
gracefulExit: true,
|
|
74
|
+
format: '[{bar}] {percentage}% | {value}/{total} | {label}',
|
|
75
|
+
hideCursor: true,
|
|
76
|
+
},
|
|
77
|
+
cliProgress.Presets.rect
|
|
78
|
+
);
|
|
79
|
+
initialUploadProgressBar.start(filePaths.length, 0, {
|
|
80
|
+
label: i18n(`${i18nKey}.initialUploadProgressBar.start`),
|
|
81
|
+
});
|
|
82
|
+
let uploadsHaveStarted = false;
|
|
83
|
+
const uploadOptions = {
|
|
84
|
+
onAttemptCallback: () => {
|
|
85
|
+
/* Intentionally blank */
|
|
86
|
+
},
|
|
87
|
+
onSuccessCallback: () => {
|
|
88
|
+
initialUploadProgressBar.increment();
|
|
89
|
+
if (!uploadsHaveStarted) {
|
|
90
|
+
uploadsHaveStarted = true;
|
|
91
|
+
initialUploadProgressBar.update(0, {
|
|
92
|
+
label: i18n(`${i18nKey}.initialUploadProgressBar.uploading`),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
onFirstErrorCallback: () => {
|
|
97
|
+
/* Intentionally blank */
|
|
98
|
+
},
|
|
99
|
+
onRetryCallback: () => {
|
|
100
|
+
/* Intentionally blank */
|
|
101
|
+
},
|
|
102
|
+
onFinalErrorCallback: () => initialUploadProgressBar.increment(),
|
|
103
|
+
onFinishCallback: results => {
|
|
104
|
+
initialUploadProgressBar.update(filePaths.length, {
|
|
105
|
+
label: i18n(`${i18nKey}.initialUploadProgressBar.finish`),
|
|
106
|
+
});
|
|
107
|
+
initialUploadProgressBar.stop();
|
|
108
|
+
results.forEach(result => {
|
|
109
|
+
if (result.resultType == FileUploadResultType.FAILURE) {
|
|
110
|
+
logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
|
|
111
|
+
logApiUploadErrorInstance(
|
|
112
|
+
result.error,
|
|
113
|
+
new ApiErrorContext({
|
|
114
|
+
accountId,
|
|
115
|
+
request: dest,
|
|
116
|
+
payload: result.file,
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
trackCommandUsage('preview', accountId);
|
|
125
|
+
|
|
126
|
+
preview(accountId, absoluteSrc, dest, {
|
|
127
|
+
notify,
|
|
128
|
+
filePaths,
|
|
129
|
+
skipUpload,
|
|
130
|
+
noSsl,
|
|
131
|
+
port,
|
|
132
|
+
debug,
|
|
133
|
+
uploadOptions,
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
exports.builder = yargs => {
|
|
138
|
+
addConfigOptions(yargs, true);
|
|
139
|
+
addAccountOptions(yargs, true);
|
|
140
|
+
|
|
141
|
+
yargs.option('src', {
|
|
142
|
+
describe: i18n(`${i18nKey}.options.src.describe`),
|
|
143
|
+
type: 'string',
|
|
144
|
+
requiresArg: true,
|
|
145
|
+
});
|
|
146
|
+
yargs.option('dest', {
|
|
147
|
+
describe: i18n(`${i18nKey}.options.dest.describe`),
|
|
148
|
+
type: 'string',
|
|
149
|
+
requiresArg: true,
|
|
150
|
+
});
|
|
151
|
+
yargs.option('notify', {
|
|
152
|
+
alias: 'n',
|
|
153
|
+
describe: i18n(`${i18nKey}.options.notify.describe`),
|
|
154
|
+
type: 'string',
|
|
155
|
+
requiresArg: true,
|
|
156
|
+
});
|
|
157
|
+
yargs.option('no-ssl', {
|
|
158
|
+
describe: i18n(`${i18nKey}.options.noSsl.describe`),
|
|
159
|
+
type: 'boolean',
|
|
160
|
+
});
|
|
161
|
+
yargs.option('port', {
|
|
162
|
+
describe: i18n(`${i18nKey}.options.port.describe`),
|
|
163
|
+
type: 'number',
|
|
164
|
+
});
|
|
165
|
+
yargs.option('debug', {
|
|
166
|
+
describe: false,
|
|
167
|
+
type: 'boolean',
|
|
168
|
+
});
|
|
169
|
+
yargs.option('skipUpload', {
|
|
170
|
+
alias: 'skip',
|
|
171
|
+
describe: false,
|
|
172
|
+
type: 'boolean',
|
|
173
|
+
});
|
|
174
|
+
return yargs;
|
|
175
|
+
};
|
package/commands/theme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const marketplaceValidate = require('./theme/marketplace-validate');
|
|
2
2
|
const generateSelectors = require('./theme/generate-selectors');
|
|
3
|
+
const previewCommand = require('./theme/preview');
|
|
3
4
|
|
|
4
5
|
const { i18n } = require('../lib/lang');
|
|
5
6
|
|
|
@@ -10,6 +11,7 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
10
11
|
|
|
11
12
|
exports.builder = yargs => {
|
|
12
13
|
yargs
|
|
14
|
+
.command(previewCommand)
|
|
13
15
|
.command(marketplaceValidate)
|
|
14
16
|
.command(generateSelectors)
|
|
15
17
|
.demandCommand(1, '');
|
package/commands/upload.js
CHANGED
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
convertToUnixPath,
|
|
11
11
|
isAllowedExtension,
|
|
12
12
|
} = require('@hubspot/local-dev-lib/path');
|
|
13
|
-
const { logger } = require('@hubspot/
|
|
13
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
14
14
|
const {
|
|
15
15
|
ApiErrorContext,
|
|
16
16
|
logApiUploadErrorInstance,
|
package/commands/watch.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
|
|
4
4
|
const { watch } = require('@hubspot/cli-lib');
|
|
5
5
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
6
|
-
const { logger } = require('@hubspot/
|
|
6
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
addConfigOptions,
|