@hubspot/cli 5.3.1 → 5.4.1-beta.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.js +24 -5
- package/commands/__tests__/projects.test.js +105 -0
- package/commands/accounts/clean.js +1 -1
- package/commands/cms/convertFields.js +13 -7
- package/commands/project/__tests__/deploy.test.js +1 -1
- package/commands/project/__tests__/installDeps.test.js +168 -0
- package/commands/project/__tests__/logs.test.js +305 -0
- package/commands/project/add.js +24 -12
- package/commands/project/cloneApp.js +13 -21
- package/commands/project/deploy.js +4 -1
- package/commands/project/dev.js +22 -11
- package/commands/project/download.js +6 -3
- package/commands/project/installDeps.js +78 -0
- package/commands/project/logs.js +80 -242
- package/commands/project/migrateApp.js +8 -9
- package/commands/project/upload.js +5 -3
- package/commands/project/watch.js +3 -9
- package/commands/project.js +2 -0
- package/commands/sandbox/create.js +1 -0
- package/commands/sandbox.js +0 -2
- package/lang/en.lyaml +40 -75
- package/lib/LocalDevManager.js +1 -22
- package/lib/__tests__/dependencyManagement.test.js +245 -0
- package/lib/__tests__/projectLogsManager.test.js +210 -0
- package/lib/dependencyManagement.js +157 -0
- package/lib/errorHandlers/apiErrors.js +1 -3
- package/lib/errorHandlers/overrideErrors.js +57 -36
- package/lib/localDev.js +25 -16
- package/lib/projectLogsManager.js +144 -0
- package/lib/projects.js +17 -7
- package/lib/projectsWatch.js +2 -5
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +46 -0
- package/lib/prompts/createProjectPrompt.js +4 -0
- package/lib/prompts/projectAddPrompt.js +4 -21
- package/lib/prompts/projectDevTargetAccountPrompt.js +16 -25
- package/lib/prompts/projectsLogsPrompt.js +17 -108
- package/lib/sandboxSync.js +13 -15
- package/package.json +6 -6
- package/commands/sandbox/sync.js +0 -225
package/commands/sandbox/sync.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
addAccountOptions,
|
|
3
|
-
addConfigOptions,
|
|
4
|
-
getAccountId,
|
|
5
|
-
addUseEnvironmentOptions,
|
|
6
|
-
addTestingOptions,
|
|
7
|
-
} = require('../../lib/commonOpts');
|
|
8
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
10
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
|
-
const { i18n } = require('../../lib/lang');
|
|
12
|
-
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
13
|
-
const { getAccountConfig, getEnv } = require('@hubspot/local-dev-lib/config');
|
|
14
|
-
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
15
|
-
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
16
|
-
const {
|
|
17
|
-
uiLine,
|
|
18
|
-
uiAccountDescription,
|
|
19
|
-
uiDeprecatedMessage,
|
|
20
|
-
uiDeprecatedDescription,
|
|
21
|
-
} = require('../../lib/ui');
|
|
22
|
-
const {
|
|
23
|
-
isSandbox,
|
|
24
|
-
isStandardSandbox,
|
|
25
|
-
isDevelopmentSandbox,
|
|
26
|
-
} = require('../../lib/accountTypes');
|
|
27
|
-
const {
|
|
28
|
-
getAvailableSyncTypes,
|
|
29
|
-
getSyncTypesWithContactRecordsPrompt,
|
|
30
|
-
} = require('../../lib/sandboxes');
|
|
31
|
-
const { syncSandbox } = require('../../lib/sandboxSync');
|
|
32
|
-
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
33
|
-
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
34
|
-
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
35
|
-
const {
|
|
36
|
-
HUBSPOT_ACCOUNT_TYPE_STRINGS,
|
|
37
|
-
HUBSPOT_ACCOUNT_TYPES,
|
|
38
|
-
} = require('@hubspot/local-dev-lib/constants/config');
|
|
39
|
-
|
|
40
|
-
const i18nKey = 'commands.sandbox.subcommands.sync';
|
|
41
|
-
|
|
42
|
-
exports.command = 'sync';
|
|
43
|
-
exports.describe = uiDeprecatedDescription(
|
|
44
|
-
i18n(`${i18nKey}.describe`),
|
|
45
|
-
'hs sandbox sync'
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
exports.handler = async options => {
|
|
49
|
-
await loadAndValidateOptions(options);
|
|
50
|
-
|
|
51
|
-
uiDeprecatedMessage('hs sandbox sync');
|
|
52
|
-
|
|
53
|
-
const { force } = options; // For scripting purposes
|
|
54
|
-
const accountId = getAccountId(options);
|
|
55
|
-
const accountConfig = getAccountConfig(accountId);
|
|
56
|
-
const env = getValidEnv(getEnv(accountId));
|
|
57
|
-
|
|
58
|
-
trackCommandUsage(
|
|
59
|
-
'sandbox-sync',
|
|
60
|
-
{ type: accountConfig.accountType },
|
|
61
|
-
accountId
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
// Check if default account is a sandbox, otherwise exit
|
|
66
|
-
!isSandbox(accountConfig)
|
|
67
|
-
) {
|
|
68
|
-
logger.error(
|
|
69
|
-
i18n(`${i18nKey}.failure.invalidAccountType`, {
|
|
70
|
-
accountType:
|
|
71
|
-
HUBSPOT_ACCOUNT_TYPE_STRINGS[
|
|
72
|
-
HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
|
|
73
|
-
],
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
process.exit(EXIT_CODES.ERROR);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Verify parent account exists in the config
|
|
80
|
-
let parentAccountId = accountConfig.parentAccountId || undefined;
|
|
81
|
-
if (!parentAccountId || !getAccountId({ account: parentAccountId })) {
|
|
82
|
-
logger.log('');
|
|
83
|
-
logger.error(
|
|
84
|
-
i18n(`${i18nKey}.failure.missingParentPortal`, {
|
|
85
|
-
sandboxName: uiAccountDescription(accountId),
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
process.exit(EXIT_CODES.ERROR);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const parentAccountConfig = getAccountConfig(parentAccountId);
|
|
92
|
-
|
|
93
|
-
let availableSyncTasks;
|
|
94
|
-
try {
|
|
95
|
-
availableSyncTasks = await getAvailableSyncTypes(
|
|
96
|
-
parentAccountConfig,
|
|
97
|
-
accountConfig
|
|
98
|
-
);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
if (
|
|
101
|
-
isSpecifiedError(error, {
|
|
102
|
-
statusCode: 404,
|
|
103
|
-
category: 'OBJECT_NOT_FOUND',
|
|
104
|
-
subCategory: 'SandboxErrors.SANDBOX_NOT_FOUND',
|
|
105
|
-
})
|
|
106
|
-
) {
|
|
107
|
-
logger.error(
|
|
108
|
-
i18n('lib.sandbox.sync.failure.objectNotFound', {
|
|
109
|
-
account: uiAccountDescription(accountId),
|
|
110
|
-
})
|
|
111
|
-
);
|
|
112
|
-
} else {
|
|
113
|
-
logErrorInstance(error);
|
|
114
|
-
}
|
|
115
|
-
process.exit(EXIT_CODES.ERROR);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (isDevelopmentSandbox(accountConfig)) {
|
|
119
|
-
logger.log(i18n(`${i18nKey}.info.developmentSandbox`));
|
|
120
|
-
logger.log(
|
|
121
|
-
i18n(`${i18nKey}.info.sync`, {
|
|
122
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
123
|
-
sandboxName: uiAccountDescription(accountId),
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
uiLine();
|
|
127
|
-
logger.warn(i18n(`${i18nKey}.warning.developmentSandbox`));
|
|
128
|
-
uiLine();
|
|
129
|
-
logger.log('');
|
|
130
|
-
|
|
131
|
-
if (!force) {
|
|
132
|
-
// Skip confirmation if force flag is present.
|
|
133
|
-
const { confirmSandboxSyncPrompt: confirmed } = await promptUser([
|
|
134
|
-
{
|
|
135
|
-
name: 'confirmSandboxSyncPrompt',
|
|
136
|
-
type: 'confirm',
|
|
137
|
-
message: i18n(`${i18nKey}.confirm.developmentSandbox`, {
|
|
138
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
139
|
-
sandboxName: uiAccountDescription(accountId),
|
|
140
|
-
}),
|
|
141
|
-
},
|
|
142
|
-
]);
|
|
143
|
-
if (!confirmed) {
|
|
144
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} else if (isStandardSandbox(accountConfig)) {
|
|
148
|
-
const standardSyncUrl = `${getHubSpotWebsiteOrigin(
|
|
149
|
-
env
|
|
150
|
-
)}/sandboxes-developer/${parentAccountId}/sync?step=select_sync_path&id=${parentAccountId}_${accountId}`;
|
|
151
|
-
|
|
152
|
-
logger.log(
|
|
153
|
-
i18n(`${i18nKey}.info.standardSandbox`, {
|
|
154
|
-
url: standardSyncUrl,
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
logger.log(
|
|
158
|
-
i18n(`${i18nKey}.info.sync`, {
|
|
159
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
160
|
-
sandboxName: uiAccountDescription(accountId),
|
|
161
|
-
})
|
|
162
|
-
);
|
|
163
|
-
uiLine();
|
|
164
|
-
logger.warn(i18n(`${i18nKey}.warning.standardSandbox`));
|
|
165
|
-
uiLine();
|
|
166
|
-
logger.log('');
|
|
167
|
-
|
|
168
|
-
if (!force) {
|
|
169
|
-
// Skip confirmation if force flag is present.
|
|
170
|
-
const { confirmSandboxSyncPrompt: confirmed } = await promptUser([
|
|
171
|
-
{
|
|
172
|
-
name: 'confirmSandboxSyncPrompt',
|
|
173
|
-
type: 'confirm',
|
|
174
|
-
message: i18n(`${i18nKey}.confirm.standardSandbox`, {
|
|
175
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
176
|
-
sandboxName: uiAccountDescription(accountId),
|
|
177
|
-
}),
|
|
178
|
-
},
|
|
179
|
-
]);
|
|
180
|
-
if (!confirmed) {
|
|
181
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
logger.error('Sync must be run in a sandbox account.');
|
|
186
|
-
process.exit(EXIT_CODES.ERROR);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
const syncTasks = await getSyncTypesWithContactRecordsPrompt(
|
|
191
|
-
accountConfig,
|
|
192
|
-
availableSyncTasks,
|
|
193
|
-
force
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
await syncSandbox({
|
|
197
|
-
accountConfig,
|
|
198
|
-
parentAccountConfig,
|
|
199
|
-
env,
|
|
200
|
-
syncTasks,
|
|
201
|
-
allowEarlyTermination: true,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
205
|
-
} catch (error) {
|
|
206
|
-
process.exit(EXIT_CODES.ERROR);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
exports.builder = yargs => {
|
|
211
|
-
yargs.option('f', {
|
|
212
|
-
type: 'boolean',
|
|
213
|
-
alias: 'force',
|
|
214
|
-
describe: i18n(`${i18nKey}.examples.force`),
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
yargs.example([['$0 sandbox sync', i18n(`${i18nKey}.examples.default`)]]);
|
|
218
|
-
|
|
219
|
-
addConfigOptions(yargs);
|
|
220
|
-
addAccountOptions(yargs);
|
|
221
|
-
addUseEnvironmentOptions(yargs);
|
|
222
|
-
addTestingOptions(yargs);
|
|
223
|
-
|
|
224
|
-
return yargs;
|
|
225
|
-
};
|