@hubspot/cli 6.4.0 → 7.0.0-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 +110 -16
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +4 -4
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -39
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/dependencyManagement.d.ts +4 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +11 -6
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +3 -2
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +12 -6
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
package/lib/projects.js
DELETED
|
@@ -1,681 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectConfig = void 0;
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
const fs = require('fs-extra');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const archiver = require('archiver');
|
|
8
|
-
const tmp = require('tmp');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
|
-
const findup = require('findup-sync');
|
|
11
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
12
|
-
const { getEnv } = require('@hubspot/local-dev-lib/config');
|
|
13
|
-
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
14
|
-
const { fetchFileFromRepository } = require('@hubspot/local-dev-lib/github');
|
|
15
|
-
const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments');
|
|
16
|
-
const { FEEDBACK_INTERVAL, POLLING_DELAY, PROJECT_BUILD_TEXT, PROJECT_DEPLOY_TEXT, PROJECT_CONFIG_FILE, PROJECT_TASK_TYPES, PROJECT_ERROR_TYPES, HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, PROJECT_COMPONENT_TYPES, } = require('./constants');
|
|
17
|
-
const { createProject, getBuildStatus, getBuildStructure, getDeployStatus, getDeployStructure, fetchProject, uploadProject, fetchBuildWarnLogs, fetchDeployWarnLogs, } = require('@hubspot/local-dev-lib/api/projects');
|
|
18
|
-
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
19
|
-
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
20
|
-
const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
21
|
-
const { downloadGithubRepoContents } = require('@hubspot/local-dev-lib/github');
|
|
22
|
-
const { promptUser } = require('./prompts/promptUtils');
|
|
23
|
-
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
24
|
-
const { uiLine, uiLink, uiAccountDescription } = require('./ui');
|
|
25
|
-
const { i18n } = require('./lang');
|
|
26
|
-
const SpinniesManager = require('./ui/SpinniesManager');
|
|
27
|
-
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
28
|
-
const i18nKey = 'lib.projects';
|
|
29
|
-
const SPINNER_STATUS = {
|
|
30
|
-
SPINNING: 'spinning',
|
|
31
|
-
};
|
|
32
|
-
const writeProjectConfig = (configPath, config) => {
|
|
33
|
-
try {
|
|
34
|
-
fs.ensureFileSync(configPath);
|
|
35
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
36
|
-
logger.debug(`Wrote project config at ${configPath}`);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
logger.debug(e);
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
const getIsInProject = _dir => {
|
|
45
|
-
const configPath = getProjectConfigPath(_dir);
|
|
46
|
-
return !!configPath;
|
|
47
|
-
};
|
|
48
|
-
const getProjectConfigPath = _dir => {
|
|
49
|
-
const projectDir = _dir ? getAbsoluteFilePath(_dir) : getCwd();
|
|
50
|
-
const configPath = findup(PROJECT_CONFIG_FILE, {
|
|
51
|
-
cwd: projectDir,
|
|
52
|
-
nocase: true,
|
|
53
|
-
});
|
|
54
|
-
return configPath;
|
|
55
|
-
};
|
|
56
|
-
const getProjectConfig = async (_dir) => {
|
|
57
|
-
const configPath = await getProjectConfigPath(_dir);
|
|
58
|
-
if (!configPath) {
|
|
59
|
-
return { projectConfig: null, projectDir: null };
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const config = fs.readFileSync(configPath);
|
|
63
|
-
const projectConfig = JSON.parse(config);
|
|
64
|
-
return {
|
|
65
|
-
projectDir: path.dirname(configPath),
|
|
66
|
-
projectConfig,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
logger.error('Could not read from project config');
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
exports.getProjectConfig = getProjectConfig;
|
|
74
|
-
const createProjectConfig = async (projectPath, projectName, template, templateSource, githubRef) => {
|
|
75
|
-
const { projectConfig, projectDir } = await (0, exports.getProjectConfig)(projectPath);
|
|
76
|
-
if (projectConfig) {
|
|
77
|
-
logger.warn(projectPath === projectDir
|
|
78
|
-
? 'A project already exists in that location.'
|
|
79
|
-
: `Found an existing project definition in ${projectDir}.`);
|
|
80
|
-
const { shouldContinue } = await promptUser([
|
|
81
|
-
{
|
|
82
|
-
name: 'shouldContinue',
|
|
83
|
-
message: () => {
|
|
84
|
-
return projectPath === projectDir
|
|
85
|
-
? 'Do you want to overwrite the existing project definition with a new one?'
|
|
86
|
-
: `Continue creating a new project in ${projectPath}?`;
|
|
87
|
-
},
|
|
88
|
-
type: 'confirm',
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
if (!shouldContinue) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const projectConfigPath = path.join(projectPath, PROJECT_CONFIG_FILE);
|
|
97
|
-
logger.log(`Creating project config in ${projectPath ? projectPath : 'the current folder'}`);
|
|
98
|
-
const hasCustomTemplateSource = Boolean(templateSource);
|
|
99
|
-
await downloadGithubRepoContents(templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, template.path, projectPath, hasCustomTemplateSource ? undefined : githubRef);
|
|
100
|
-
const _config = JSON.parse(fs.readFileSync(projectConfigPath));
|
|
101
|
-
writeProjectConfig(projectConfigPath, {
|
|
102
|
-
..._config,
|
|
103
|
-
name: projectName,
|
|
104
|
-
});
|
|
105
|
-
if (template.name === 'no-template') {
|
|
106
|
-
fs.ensureDirSync(path.join(projectPath, 'src'));
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
const validateProjectConfig = (projectConfig, projectDir) => {
|
|
111
|
-
if (!projectConfig) {
|
|
112
|
-
logger.error(`Project config not found. Try running 'hs project create' first.`);
|
|
113
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
114
|
-
}
|
|
115
|
-
if (!projectConfig.name || !projectConfig.srcDir) {
|
|
116
|
-
logger.error('Project config is missing required fields. Try running `hs project create`.');
|
|
117
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
118
|
-
}
|
|
119
|
-
const resolvedPath = path.resolve(projectDir, projectConfig.srcDir);
|
|
120
|
-
if (!resolvedPath.startsWith(projectDir)) {
|
|
121
|
-
const projectConfigFile = path.relative('.', path.join(projectDir, PROJECT_CONFIG_FILE));
|
|
122
|
-
logger.error(i18n(`${i18nKey}.config.srcOutsideProjectDir`, {
|
|
123
|
-
srcDir: projectConfig.srcDir,
|
|
124
|
-
projectConfig: projectConfigFile,
|
|
125
|
-
}));
|
|
126
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
127
|
-
}
|
|
128
|
-
if (!fs.existsSync(resolvedPath)) {
|
|
129
|
-
logger.error(`Project source directory '${projectConfig.srcDir}' could not be found in ${projectDir}.`);
|
|
130
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const pollFetchProject = async (accountId, projectName) => {
|
|
134
|
-
// Temporary solution for gating slowness. Retry on 403 statusCode
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
let pollCount = 0;
|
|
137
|
-
SpinniesManager.init();
|
|
138
|
-
SpinniesManager.add('pollFetchProject', {
|
|
139
|
-
text: i18n(`${i18nKey}.pollFetchProject.checkingProject`, {
|
|
140
|
-
accountIdentifier: uiAccountDescription(accountId),
|
|
141
|
-
}),
|
|
142
|
-
});
|
|
143
|
-
const pollInterval = setInterval(async () => {
|
|
144
|
-
try {
|
|
145
|
-
const response = await fetchProject(accountId, projectName);
|
|
146
|
-
if (response && response.data) {
|
|
147
|
-
SpinniesManager.remove('pollFetchProject');
|
|
148
|
-
clearInterval(pollInterval);
|
|
149
|
-
resolve(response);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (err) {
|
|
153
|
-
if (isSpecifiedError(err, {
|
|
154
|
-
statusCode: 403,
|
|
155
|
-
category: 'GATED',
|
|
156
|
-
subCategory: 'BuildPipelineErrorType.PORTAL_GATED',
|
|
157
|
-
}) &&
|
|
158
|
-
pollCount < 15) {
|
|
159
|
-
pollCount += 1;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
SpinniesManager.remove('pollFetchProject');
|
|
163
|
-
clearInterval(pollInterval);
|
|
164
|
-
reject(err);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}, POLLING_DELAY);
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
const ensureProjectExists = async (accountId, projectName, { forceCreate = false, allowCreate = true, noLogs = false, withPolling = false, uploadCommand = false, } = {}) => {
|
|
171
|
-
const accountIdentifier = uiAccountDescription(accountId);
|
|
172
|
-
try {
|
|
173
|
-
const { data: project } = withPolling
|
|
174
|
-
? await pollFetchProject(accountId, projectName)
|
|
175
|
-
: await fetchProject(accountId, projectName);
|
|
176
|
-
return { projectExists: !!project, project };
|
|
177
|
-
}
|
|
178
|
-
catch (err) {
|
|
179
|
-
if (isSpecifiedError(err, { statusCode: 404 })) {
|
|
180
|
-
let shouldCreateProject = forceCreate;
|
|
181
|
-
if (allowCreate && !shouldCreateProject) {
|
|
182
|
-
const promptKey = uploadCommand ? 'createPromptUpload' : 'createPrompt';
|
|
183
|
-
const promptResult = await promptUser([
|
|
184
|
-
{
|
|
185
|
-
name: 'shouldCreateProject',
|
|
186
|
-
message: i18n(`${i18nKey}.ensureProjectExists.${promptKey}`, {
|
|
187
|
-
projectName,
|
|
188
|
-
accountIdentifier,
|
|
189
|
-
}),
|
|
190
|
-
type: 'confirm',
|
|
191
|
-
},
|
|
192
|
-
]);
|
|
193
|
-
shouldCreateProject = promptResult.shouldCreateProject;
|
|
194
|
-
}
|
|
195
|
-
if (shouldCreateProject) {
|
|
196
|
-
try {
|
|
197
|
-
const { data: project } = await createProject(accountId, projectName);
|
|
198
|
-
logger.success(i18n(`${i18nKey}.ensureProjectExists.createSuccess`, {
|
|
199
|
-
projectName,
|
|
200
|
-
accountIdentifier,
|
|
201
|
-
}));
|
|
202
|
-
return { projectExists: true, project };
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
return logError(err, new ApiErrorContext({ accountId }));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
if (!noLogs) {
|
|
210
|
-
logger.log(i18n(`${i18nKey}.ensureProjectExists.notFound`, {
|
|
211
|
-
projectName,
|
|
212
|
-
accountIdentifier,
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
return { projectExists: false };
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (isSpecifiedError(err, {
|
|
219
|
-
statusCode: 401,
|
|
220
|
-
})) {
|
|
221
|
-
logger.error(err.message);
|
|
222
|
-
process.exit(EXIT_CODES.ERROR);
|
|
223
|
-
}
|
|
224
|
-
logError(err, new ApiErrorContext({ accountId }));
|
|
225
|
-
process.exit(EXIT_CODES.ERROR);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
const getProjectHomeUrl = accountId => {
|
|
229
|
-
const baseUrl = getHubSpotWebsiteOrigin(getEnv(accountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
|
|
230
|
-
return `${baseUrl}/developer-projects/${accountId}`;
|
|
231
|
-
};
|
|
232
|
-
const getProjectDetailUrl = (projectName, accountId) => {
|
|
233
|
-
if (!projectName)
|
|
234
|
-
return;
|
|
235
|
-
return `${getProjectHomeUrl(accountId)}/project/${projectName}`;
|
|
236
|
-
};
|
|
237
|
-
const getProjectActivityUrl = (projectName, accountId) => {
|
|
238
|
-
if (!projectName)
|
|
239
|
-
return;
|
|
240
|
-
return `${getProjectDetailUrl(projectName, accountId)}/activity`;
|
|
241
|
-
};
|
|
242
|
-
const getProjectBuildDetailUrl = (projectName, buildId, accountId) => {
|
|
243
|
-
if (!projectName || !buildId || !accountId)
|
|
244
|
-
return;
|
|
245
|
-
return `${getProjectActivityUrl(projectName, accountId)}/build/${buildId}`;
|
|
246
|
-
};
|
|
247
|
-
const getProjectDeployDetailUrl = (projectName, deployId, accountId) => {
|
|
248
|
-
if (!projectName || !deployId || !accountId)
|
|
249
|
-
return;
|
|
250
|
-
return `${getProjectActivityUrl(projectName, accountId)}/deploy/${deployId}`;
|
|
251
|
-
};
|
|
252
|
-
const uploadProjectFiles = async (accountId, projectName, filePath, uploadMessage, platformVersion) => {
|
|
253
|
-
SpinniesManager.init({});
|
|
254
|
-
const accountIdentifier = uiAccountDescription(accountId);
|
|
255
|
-
SpinniesManager.add('upload', {
|
|
256
|
-
text: i18n(`${i18nKey}.uploadProjectFiles.add`, {
|
|
257
|
-
accountIdentifier,
|
|
258
|
-
projectName,
|
|
259
|
-
}),
|
|
260
|
-
succeedColor: 'white',
|
|
261
|
-
});
|
|
262
|
-
let buildId;
|
|
263
|
-
let error;
|
|
264
|
-
try {
|
|
265
|
-
const { data: upload } = await uploadProject(accountId, projectName, filePath, uploadMessage, platformVersion);
|
|
266
|
-
buildId = upload.buildId;
|
|
267
|
-
SpinniesManager.succeed('upload', {
|
|
268
|
-
text: i18n(`${i18nKey}.uploadProjectFiles.succeed`, {
|
|
269
|
-
accountIdentifier,
|
|
270
|
-
projectName,
|
|
271
|
-
}),
|
|
272
|
-
});
|
|
273
|
-
logger.debug(i18n(`${i18nKey}.uploadProjectFiles.buildCreated`, {
|
|
274
|
-
buildId,
|
|
275
|
-
projectName,
|
|
276
|
-
}));
|
|
277
|
-
}
|
|
278
|
-
catch (err) {
|
|
279
|
-
SpinniesManager.fail('upload', {
|
|
280
|
-
text: i18n(`${i18nKey}.uploadProjectFiles.fail`, {
|
|
281
|
-
accountIdentifier,
|
|
282
|
-
projectName,
|
|
283
|
-
}),
|
|
284
|
-
});
|
|
285
|
-
error = err;
|
|
286
|
-
}
|
|
287
|
-
return { buildId, error };
|
|
288
|
-
};
|
|
289
|
-
const pollProjectBuildAndDeploy = async (accountId, projectConfig, tempFile, buildId, silenceLogs = false) => {
|
|
290
|
-
let buildStatus = await pollBuildStatus(accountId, projectConfig.name, buildId, null, silenceLogs);
|
|
291
|
-
if (!silenceLogs) {
|
|
292
|
-
uiLine();
|
|
293
|
-
}
|
|
294
|
-
const result = {
|
|
295
|
-
succeeded: true,
|
|
296
|
-
buildId,
|
|
297
|
-
buildResult: buildStatus,
|
|
298
|
-
deployResult: null,
|
|
299
|
-
};
|
|
300
|
-
if (buildStatus.status === 'FAILURE') {
|
|
301
|
-
result.succeeded = false;
|
|
302
|
-
return result;
|
|
303
|
-
}
|
|
304
|
-
else if (buildStatus.isAutoDeployEnabled) {
|
|
305
|
-
if (!silenceLogs) {
|
|
306
|
-
logger.log(i18n(`${i18nKey}.pollProjectBuildAndDeploy.buildSucceededAutomaticallyDeploying`, {
|
|
307
|
-
accountIdentifier: uiAccountDescription(accountId),
|
|
308
|
-
buildId,
|
|
309
|
-
}));
|
|
310
|
-
await displayWarnLogs(accountId, projectConfig.name, buildId);
|
|
311
|
-
}
|
|
312
|
-
// autoDeployId of 0 indicates a skipped deploy
|
|
313
|
-
const getIsDeploying = () => buildStatus.autoDeployId > 0 && buildStatus.deployStatusTaskLocator;
|
|
314
|
-
// Sometimes the deploys do not immediately initiate, give them a chance to kick off
|
|
315
|
-
if (!getIsDeploying()) {
|
|
316
|
-
buildStatus = await pollBuildAutodeployStatus(accountId, projectConfig.name, buildId);
|
|
317
|
-
}
|
|
318
|
-
if (getIsDeploying()) {
|
|
319
|
-
const deployStatus = await pollDeployStatus(accountId, projectConfig.name, buildStatus.deployStatusTaskLocator.id, buildId, silenceLogs);
|
|
320
|
-
result.deployResult = deployStatus;
|
|
321
|
-
if (deployStatus.status === 'FAILURE') {
|
|
322
|
-
result.succeeded = false;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
else if (!silenceLogs) {
|
|
326
|
-
logger.log(i18n(`${i18nKey}.pollProjectBuildAndDeploy.unableToFindAutodeployStatus`, {
|
|
327
|
-
buildId,
|
|
328
|
-
viewDeploysLink: uiLink(i18n(`${i18nKey}.pollProjectBuildAndDeploy.viewDeploys`), getProjectActivityUrl(projectConfig.name, accountId)),
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
try {
|
|
333
|
-
if (tempFile) {
|
|
334
|
-
tempFile.removeCallback();
|
|
335
|
-
logger.debug(i18n(`${i18nKey}.pollProjectBuildAndDeploy.cleanedUpTempFile`, {
|
|
336
|
-
path: tempFile.name,
|
|
337
|
-
}));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
catch (e) {
|
|
341
|
-
logger.error(e);
|
|
342
|
-
}
|
|
343
|
-
if (result && result.deployResult) {
|
|
344
|
-
await displayWarnLogs(accountId, projectConfig.name, result.deployResult.deployId, true);
|
|
345
|
-
}
|
|
346
|
-
return result;
|
|
347
|
-
};
|
|
348
|
-
const handleProjectUpload = async (accountId, projectConfig, projectDir, callbackFunc, uploadMessage) => {
|
|
349
|
-
const srcDir = path.resolve(projectDir, projectConfig.srcDir);
|
|
350
|
-
const filenames = fs.readdirSync(srcDir);
|
|
351
|
-
if (!filenames || filenames.length === 0) {
|
|
352
|
-
logger.log(i18n(`${i18nKey}.handleProjectUpload.emptySource`, {
|
|
353
|
-
srcDir: projectConfig.srcDir,
|
|
354
|
-
}));
|
|
355
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
356
|
-
}
|
|
357
|
-
const tempFile = tmp.fileSync({ postfix: '.zip' });
|
|
358
|
-
logger.debug(i18n(`${i18nKey}.handleProjectUpload.compressing`, {
|
|
359
|
-
path: tempFile.name,
|
|
360
|
-
}));
|
|
361
|
-
const output = fs.createWriteStream(tempFile.name);
|
|
362
|
-
const archive = archiver('zip');
|
|
363
|
-
const result = new Promise(resolve => output.on('close', async function () {
|
|
364
|
-
let uploadResult = {};
|
|
365
|
-
logger.debug(i18n(`${i18nKey}.handleProjectUpload.compressed`, {
|
|
366
|
-
byteCount: archive.pointer(),
|
|
367
|
-
}));
|
|
368
|
-
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion);
|
|
369
|
-
if (error) {
|
|
370
|
-
uploadResult.uploadError = error;
|
|
371
|
-
}
|
|
372
|
-
else if (callbackFunc) {
|
|
373
|
-
uploadResult = await callbackFunc(accountId, projectConfig, tempFile, buildId);
|
|
374
|
-
}
|
|
375
|
-
resolve(uploadResult || {});
|
|
376
|
-
}));
|
|
377
|
-
archive.pipe(output);
|
|
378
|
-
let loggedIgnoredNodeModule = false;
|
|
379
|
-
archive.directory(srcDir, false, file => {
|
|
380
|
-
const ignored = shouldIgnoreFile(file.name, true);
|
|
381
|
-
if (ignored) {
|
|
382
|
-
const isNodeModule = file.name.includes('node_modules');
|
|
383
|
-
if (!isNodeModule || !loggedIgnoredNodeModule) {
|
|
384
|
-
logger.debug(i18n(`${i18nKey}.handleProjectUpload.fileFiltered`, {
|
|
385
|
-
filename: file.name,
|
|
386
|
-
}));
|
|
387
|
-
}
|
|
388
|
-
if (isNodeModule && !loggedIgnoredNodeModule) {
|
|
389
|
-
loggedIgnoredNodeModule = true;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return ignored ? false : file;
|
|
393
|
-
});
|
|
394
|
-
archive.finalize();
|
|
395
|
-
return result;
|
|
396
|
-
};
|
|
397
|
-
const makePollTaskStatusFunc = ({ statusFn, structureFn, statusText, statusStrings, linkToHubSpot, }) => {
|
|
398
|
-
return async (accountId, taskName, taskId, deployedBuildId = null, silenceLogs = false) => {
|
|
399
|
-
const displayId = deployedBuildId || taskId;
|
|
400
|
-
if (linkToHubSpot && !silenceLogs) {
|
|
401
|
-
logger.log(`\n${linkToHubSpot(accountId, taskName, taskId, deployedBuildId)}\n`);
|
|
402
|
-
}
|
|
403
|
-
SpinniesManager.init();
|
|
404
|
-
const overallTaskSpinniesKey = `overallTaskStatus-${statusText.STATUS_TEXT}`;
|
|
405
|
-
SpinniesManager.add(overallTaskSpinniesKey, {
|
|
406
|
-
text: 'Beginning',
|
|
407
|
-
succeedColor: 'white',
|
|
408
|
-
failColor: 'white',
|
|
409
|
-
failPrefix: chalk.bold('!'),
|
|
410
|
-
});
|
|
411
|
-
const [{ data: initialTaskStatus }, { data: { topLevelComponentsWithChildren: taskStructure }, },] = await Promise.all([
|
|
412
|
-
statusFn(accountId, taskName, taskId),
|
|
413
|
-
structureFn(accountId, taskName, taskId),
|
|
414
|
-
]);
|
|
415
|
-
const tasksById = initialTaskStatus[statusText.SUBTASK_KEY].reduce((acc, task) => {
|
|
416
|
-
const { id, visible } = task;
|
|
417
|
-
if (visible) {
|
|
418
|
-
acc[id] = task;
|
|
419
|
-
}
|
|
420
|
-
return acc;
|
|
421
|
-
}, {});
|
|
422
|
-
const structuredTasks = Object.keys(taskStructure).map(key => {
|
|
423
|
-
return {
|
|
424
|
-
...tasksById[key],
|
|
425
|
-
subtasks: taskStructure[key]
|
|
426
|
-
.filter(taskId => Boolean(tasksById[taskId]))
|
|
427
|
-
.map(taskId => tasksById[taskId]),
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
const numComponents = structuredTasks.length;
|
|
431
|
-
const componentCountText = silenceLogs
|
|
432
|
-
? ''
|
|
433
|
-
: i18n(numComponents === 1
|
|
434
|
-
? `${i18nKey}.makePollTaskStatusFunc.componentCountSingular`
|
|
435
|
-
: `${i18nKey}.makePollTaskStatusFunc.componentCount`, { numComponents }) + '\n';
|
|
436
|
-
SpinniesManager.update(overallTaskSpinniesKey, {
|
|
437
|
-
text: `${statusStrings.INITIALIZE(taskName, displayId)}\n${componentCountText}`,
|
|
438
|
-
});
|
|
439
|
-
if (!silenceLogs) {
|
|
440
|
-
const addTaskSpinner = (task, indent, newline) => {
|
|
441
|
-
const taskName = task[statusText.SUBTASK_NAME_KEY];
|
|
442
|
-
const taskType = task[statusText.TYPE_KEY];
|
|
443
|
-
const formattedTaskType = PROJECT_TASK_TYPES[taskType]
|
|
444
|
-
? `[${PROJECT_TASK_TYPES[taskType]}]`
|
|
445
|
-
: '';
|
|
446
|
-
const text = `${indent <= 2 ? statusText.STATUS_TEXT : ''} ${chalk.bold(taskName)} ${formattedTaskType} ...${newline ? '\n' : ''}`;
|
|
447
|
-
SpinniesManager.add(task.id, {
|
|
448
|
-
text,
|
|
449
|
-
indent,
|
|
450
|
-
succeedColor: 'white',
|
|
451
|
-
failColor: 'white',
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
structuredTasks.forEach(task => {
|
|
455
|
-
addTaskSpinner(task, 2, !task.subtasks || task.subtasks.length === 0);
|
|
456
|
-
task.subtasks.forEach((subtask, i) => addTaskSpinner(subtask, 4, i === task.subtasks.length - 1));
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
return new Promise((resolve, reject) => {
|
|
460
|
-
const pollInterval = setInterval(async () => {
|
|
461
|
-
let taskStatus;
|
|
462
|
-
try {
|
|
463
|
-
const { data } = await statusFn(accountId, taskName, taskId);
|
|
464
|
-
taskStatus = data;
|
|
465
|
-
}
|
|
466
|
-
catch (e) {
|
|
467
|
-
logger.debug(e);
|
|
468
|
-
logError(e, new ApiErrorContext({
|
|
469
|
-
accountId,
|
|
470
|
-
projectName: taskName,
|
|
471
|
-
}));
|
|
472
|
-
return reject(new Error(i18n(`${i18nKey}.makePollTaskStatusFunc.errorFetchingTaskStatus`, {
|
|
473
|
-
taskType: statusText.TYPE_KEY === PROJECT_BUILD_TEXT.TYPE_KEY
|
|
474
|
-
? 'build'
|
|
475
|
-
: 'deploy',
|
|
476
|
-
})));
|
|
477
|
-
}
|
|
478
|
-
if (!taskStatus ||
|
|
479
|
-
!taskStatus.status ||
|
|
480
|
-
!taskStatus[statusText.SUBTASK_KEY]) {
|
|
481
|
-
return reject(new Error(i18n(`${i18nKey}.makePollTaskStatusFunc.errorFetchingTaskStatus`, {
|
|
482
|
-
taskType: statusText.TYPE_KEY === PROJECT_BUILD_TEXT.TYPE_KEY
|
|
483
|
-
? 'build'
|
|
484
|
-
: 'deploy',
|
|
485
|
-
})));
|
|
486
|
-
}
|
|
487
|
-
const { status, [statusText.SUBTASK_KEY]: subTaskStatus } = taskStatus;
|
|
488
|
-
if (SpinniesManager.hasActiveSpinners()) {
|
|
489
|
-
subTaskStatus.forEach(subTask => {
|
|
490
|
-
const { id, status } = subTask;
|
|
491
|
-
const spinner = SpinniesManager.pick(id);
|
|
492
|
-
if (!spinner || spinner.status !== SPINNER_STATUS.SPINNING) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
const topLevelTask = structuredTasks.find(t => t.id == id);
|
|
496
|
-
if (status === statusText.STATES.SUCCESS ||
|
|
497
|
-
status === statusText.STATES.FAILURE) {
|
|
498
|
-
const taskStatusText = subTask.status === statusText.STATES.SUCCESS
|
|
499
|
-
? i18n(`${i18nKey}.makePollTaskStatusFunc.successStatusText`)
|
|
500
|
-
: i18n(`${i18nKey}.makePollTaskStatusFunc.failedStatusText`);
|
|
501
|
-
const hasNewline = spinner.text.includes('\n') || Boolean(topLevelTask);
|
|
502
|
-
const updatedText = `${spinner.text.replace('\n', '')} ${taskStatusText}${hasNewline ? '\n' : ''}`;
|
|
503
|
-
if (status === statusText.STATES.SUCCESS) {
|
|
504
|
-
SpinniesManager.succeed(id, { text: updatedText });
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
SpinniesManager.fail(id, { text: updatedText });
|
|
508
|
-
}
|
|
509
|
-
if (topLevelTask) {
|
|
510
|
-
topLevelTask.subtasks.forEach(currentSubtask => SpinniesManager.remove(currentSubtask.id));
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
if (status === statusText.STATES.SUCCESS) {
|
|
515
|
-
SpinniesManager.succeed(overallTaskSpinniesKey, {
|
|
516
|
-
text: statusStrings.SUCCESS(taskName, displayId),
|
|
517
|
-
});
|
|
518
|
-
clearInterval(pollInterval);
|
|
519
|
-
resolve(taskStatus);
|
|
520
|
-
}
|
|
521
|
-
else if (status === statusText.STATES.FAILURE) {
|
|
522
|
-
SpinniesManager.fail(overallTaskSpinniesKey, {
|
|
523
|
-
text: statusStrings.FAIL(taskName, displayId),
|
|
524
|
-
});
|
|
525
|
-
if (!silenceLogs) {
|
|
526
|
-
const failedSubtasks = subTaskStatus.filter(subtask => subtask.status === 'FAILURE');
|
|
527
|
-
uiLine();
|
|
528
|
-
logger.log(`${statusStrings.SUBTASK_FAIL(displayId, failedSubtasks.length === 1
|
|
529
|
-
? failedSubtasks[0][statusText.SUBTASK_NAME_KEY]
|
|
530
|
-
: failedSubtasks.length + ' components')}\n`);
|
|
531
|
-
logger.log('See below for a summary of errors.');
|
|
532
|
-
uiLine();
|
|
533
|
-
const displayErrors = failedSubtasks.filter(subtask => subtask.standardError.subCategory !==
|
|
534
|
-
PROJECT_ERROR_TYPES.SUBBUILD_FAILED &&
|
|
535
|
-
subtask.standardError.subCategory !==
|
|
536
|
-
PROJECT_ERROR_TYPES.SUBDEPLOY_FAILED);
|
|
537
|
-
displayErrors.forEach(subTask => {
|
|
538
|
-
logger.log(`\n--- ${chalk.bold(subTask[statusText.SUBTASK_NAME_KEY])} failed with the following error ---`);
|
|
539
|
-
logger.error(subTask.errorMessage);
|
|
540
|
-
// Log nested errors
|
|
541
|
-
if (subTask.standardError && subTask.standardError.errors) {
|
|
542
|
-
logger.log();
|
|
543
|
-
subTask.standardError.errors.forEach(error => {
|
|
544
|
-
logger.log(error.message);
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
clearInterval(pollInterval);
|
|
550
|
-
resolve(taskStatus);
|
|
551
|
-
}
|
|
552
|
-
else if (!subTaskStatus.length) {
|
|
553
|
-
clearInterval(pollInterval);
|
|
554
|
-
resolve(taskStatus);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}, POLLING_DELAY);
|
|
558
|
-
});
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
const pollBuildAutodeployStatus = (accountId, taskName, buildId) => {
|
|
562
|
-
return new Promise((resolve, reject) => {
|
|
563
|
-
let maxIntervals = (30 * 1000) / POLLING_DELAY; // Num of intervals in ~30s
|
|
564
|
-
const pollInterval = setInterval(async () => {
|
|
565
|
-
let taskStatus;
|
|
566
|
-
try {
|
|
567
|
-
taskStatus = await getBuildStatus(accountId, taskName, buildId);
|
|
568
|
-
}
|
|
569
|
-
catch (e) {
|
|
570
|
-
logger.debug(e);
|
|
571
|
-
return reject(new Error(i18n(`${i18nKey}.pollBuildAutodeployStatusError`, { buildId })));
|
|
572
|
-
}
|
|
573
|
-
if (!taskStatus || !taskStatus.status) {
|
|
574
|
-
return reject(new Error(i18n(`${i18nKey}.pollBuildAutodeployStatusError`, { buildId })));
|
|
575
|
-
}
|
|
576
|
-
if (taskStatus.deployStatusTaskLocator || maxIntervals <= 0) {
|
|
577
|
-
clearInterval(pollInterval);
|
|
578
|
-
resolve(taskStatus);
|
|
579
|
-
}
|
|
580
|
-
else {
|
|
581
|
-
maxIntervals -= 1;
|
|
582
|
-
}
|
|
583
|
-
}, POLLING_DELAY);
|
|
584
|
-
});
|
|
585
|
-
};
|
|
586
|
-
const pollBuildStatus = makePollTaskStatusFunc({
|
|
587
|
-
linkToHubSpot: (accountId, taskName, taskId) => uiLink(`View build #${taskId} in HubSpot`, getProjectBuildDetailUrl(taskName, taskId, accountId)),
|
|
588
|
-
statusFn: getBuildStatus,
|
|
589
|
-
structureFn: getBuildStructure,
|
|
590
|
-
statusText: PROJECT_BUILD_TEXT,
|
|
591
|
-
statusStrings: {
|
|
592
|
-
INITIALIZE: (name, buildId) => `Building ${chalk.bold(name)} #${buildId}`,
|
|
593
|
-
SUCCESS: (name, buildId) => `Built ${chalk.bold(name)} #${buildId}`,
|
|
594
|
-
FAIL: (name, buildId) => `Failed to build ${chalk.bold(name)} #${buildId}`,
|
|
595
|
-
SUBTASK_FAIL: (buildId, name) => `Build #${buildId} failed because there was a problem\nbuilding ${chalk.bold(name)}`,
|
|
596
|
-
},
|
|
597
|
-
});
|
|
598
|
-
const pollDeployStatus = makePollTaskStatusFunc({
|
|
599
|
-
linkToHubSpot: (accountId, taskName, taskId, deployedBuildId) => uiLink(`View deploy of build #${deployedBuildId} in HubSpot`, getProjectDeployDetailUrl(taskName, taskId, accountId)),
|
|
600
|
-
statusFn: getDeployStatus,
|
|
601
|
-
structureFn: getDeployStructure,
|
|
602
|
-
statusText: PROJECT_DEPLOY_TEXT,
|
|
603
|
-
statusStrings: {
|
|
604
|
-
INITIALIZE: (name, buildId) => `Deploying build #${buildId} in ${chalk.bold(name)}`,
|
|
605
|
-
SUCCESS: (name, buildId) => `Deployed build #${buildId} in ${chalk.bold(name)}`,
|
|
606
|
-
FAIL: (name, buildId) => `Failed to deploy build #${buildId} in ${chalk.bold(name)}`,
|
|
607
|
-
SUBTASK_FAIL: (deployedBuildId, name) => `Deploy for build #${deployedBuildId} failed because there was a\nproblem deploying ${chalk.bold(name)}`,
|
|
608
|
-
},
|
|
609
|
-
});
|
|
610
|
-
const logFeedbackMessage = buildId => {
|
|
611
|
-
if (buildId > 0 && buildId % FEEDBACK_INTERVAL === 0) {
|
|
612
|
-
uiLine();
|
|
613
|
-
logger.log(i18n(`${i18nKey}.logFeedbackMessage.feedbackHeader`));
|
|
614
|
-
uiLine();
|
|
615
|
-
logger.log(i18n(`${i18nKey}.logFeedbackMessage.feedbackMessage`));
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
const createProjectComponent = async (component, name, projectComponentsVersion) => {
|
|
619
|
-
const i18nKey = 'commands.project.subcommands.add';
|
|
620
|
-
const componentName = name;
|
|
621
|
-
const configInfo = await (0, exports.getProjectConfig)();
|
|
622
|
-
if (!configInfo.projectDir && !configInfo.projectConfig) {
|
|
623
|
-
logger.error(i18n(`${i18nKey}.error.locationInProject`));
|
|
624
|
-
process.exit(EXIT_CODES.ERROR);
|
|
625
|
-
}
|
|
626
|
-
const componentPath = path.join(configInfo.projectDir, configInfo.projectConfig.srcDir, component.insertPath, componentName);
|
|
627
|
-
await downloadGithubRepoContents(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, component.path, componentPath, projectComponentsVersion);
|
|
628
|
-
};
|
|
629
|
-
const displayWarnLogs = async (accountId, projectName, taskId, isDeploy = false) => {
|
|
630
|
-
let result;
|
|
631
|
-
if (isDeploy) {
|
|
632
|
-
try {
|
|
633
|
-
const { data } = await fetchDeployWarnLogs(accountId, projectName, taskId);
|
|
634
|
-
result = data;
|
|
635
|
-
}
|
|
636
|
-
catch (e) {
|
|
637
|
-
logError(e);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
try {
|
|
642
|
-
const { data } = await fetchBuildWarnLogs(accountId, projectName, taskId);
|
|
643
|
-
result = data;
|
|
644
|
-
}
|
|
645
|
-
catch (e) {
|
|
646
|
-
logError(e);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
if (result && result.logs) {
|
|
650
|
-
const logLength = result.logs.length;
|
|
651
|
-
result.logs.forEach((log, i) => {
|
|
652
|
-
logger.warn(log.message);
|
|
653
|
-
if (i < logLength - 1) {
|
|
654
|
-
logger.log('');
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
const getProjectComponentsByVersion = async (projectComponentsVersion) => {
|
|
660
|
-
const config = await fetchFileFromRepository(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', projectComponentsVersion);
|
|
661
|
-
return config[PROJECT_COMPONENT_TYPES.COMPONENTS];
|
|
662
|
-
};
|
|
663
|
-
module.exports = {
|
|
664
|
-
writeProjectConfig,
|
|
665
|
-
getProjectConfig: exports.getProjectConfig,
|
|
666
|
-
getIsInProject,
|
|
667
|
-
pollProjectBuildAndDeploy,
|
|
668
|
-
handleProjectUpload,
|
|
669
|
-
createProjectConfig,
|
|
670
|
-
validateProjectConfig,
|
|
671
|
-
getProjectHomeUrl,
|
|
672
|
-
getProjectDetailUrl,
|
|
673
|
-
getProjectBuildDetailUrl,
|
|
674
|
-
pollBuildStatus,
|
|
675
|
-
pollDeployStatus,
|
|
676
|
-
ensureProjectExists,
|
|
677
|
-
logFeedbackMessage,
|
|
678
|
-
createProjectComponent,
|
|
679
|
-
displayWarnLogs,
|
|
680
|
-
getProjectComponentsByVersion,
|
|
681
|
-
};
|
package/lib/projectsWatch.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|