@hubspot/cli 7.0.2-experimental.0 → 7.0.3-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.js +7 -2
- package/commands/account/info.d.ts +7 -0
- package/commands/account/info.js +28 -25
- package/commands/account/remove.js +4 -4
- package/commands/account/use.js +3 -3
- package/commands/auth.js +3 -3
- package/commands/init.js +1 -1
- package/commands/logs.js +1 -7
- package/commands/project/create.js +6 -0
- package/commands/project/installDeps.js +2 -4
- package/commands/project/upload.js +5 -10
- package/commands/project/watch.js +4 -4
- package/commands/sandbox/create.js +2 -8
- package/commands/sandbox/delete.js +6 -10
- package/lang/en.lyaml +8 -3
- package/lib/LocalDevManager.d.ts +58 -1
- package/lib/LocalDevManager.js +162 -122
- package/lib/buildAccount.d.ts +12 -0
- package/lib/buildAccount.js +110 -95
- package/lib/commonOpts.d.ts +4 -8
- package/lib/commonOpts.js +2 -14
- package/lib/developerTestAccounts.d.ts +1 -0
- package/lib/developerTestAccounts.js +1 -0
- package/lib/localDev.d.ts +17 -1
- package/lib/localDev.js +203 -197
- package/lib/projects/buildAndDeploy.d.ts +1 -7
- package/lib/projects/index.js +8 -3
- package/lib/projects/structure.d.ts +3 -0
- package/lib/projects/structure.js +21 -0
- package/lib/projects/upload.d.ts +4 -3
- package/lib/projects/upload.js +7 -31
- package/lib/prompts/createProjectPrompt.js +8 -1
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -2
- package/lib/sandboxes.d.ts +1 -1
- package/lib/serverlessLogs.d.ts +4 -1
- package/lib/serverlessLogs.js +64 -60
- package/lib/ui/serverlessFunctionLogs.d.ts +8 -0
- package/lib/ui/serverlessFunctionLogs.js +1 -3
- package/lib/validation.d.ts +2 -0
- package/lib/validation.js +5 -8
- package/package.json +2 -3
- package/types/Projects.d.ts +8 -2
- package/types/Yargs.d.ts +14 -0
- package/types/Yargs.js +2 -0
package/lib/projects/upload.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FileResult } from 'tmp';
|
|
2
2
|
import { ProjectConfig } from '../../types/Projects';
|
|
3
|
-
type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId?: number) => Promise<T
|
|
4
|
-
type
|
|
3
|
+
type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId?: number) => Promise<T>;
|
|
4
|
+
type ProjectUploadResult<T> = {
|
|
5
|
+
result?: T;
|
|
5
6
|
uploadError?: unknown;
|
|
6
7
|
};
|
|
7
|
-
export declare function handleProjectUpload<T
|
|
8
|
+
export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string): Promise<ProjectUploadResult<T>>;
|
|
8
9
|
export {};
|
package/lib/projects/upload.js
CHANGED
|
@@ -15,11 +15,8 @@ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
|
15
15
|
const ui_1 = require("../ui");
|
|
16
16
|
const lang_1 = require("../lang");
|
|
17
17
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
18
|
-
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
19
|
-
const errorHandlers_1 = require("../errorHandlers");
|
|
20
|
-
const node_util_1 = __importDefault(require("node:util"));
|
|
21
18
|
const i18nKey = 'lib.projectUpload';
|
|
22
|
-
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion
|
|
19
|
+
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion) {
|
|
23
20
|
SpinniesManager_1.default.init({});
|
|
24
21
|
const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
|
|
25
22
|
SpinniesManager_1.default.add('upload', {
|
|
@@ -32,7 +29,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
32
29
|
let buildId;
|
|
33
30
|
let error;
|
|
34
31
|
try {
|
|
35
|
-
const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion
|
|
32
|
+
const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion);
|
|
36
33
|
buildId = upload.buildId;
|
|
37
34
|
SpinniesManager_1.default.succeed('upload', {
|
|
38
35
|
text: (0, lang_1.i18n)(`${i18nKey}.uploadProjectFiles.succeed`, {
|
|
@@ -58,7 +55,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
58
55
|
}
|
|
59
56
|
return { buildId, error };
|
|
60
57
|
}
|
|
61
|
-
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage
|
|
58
|
+
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage) {
|
|
62
59
|
const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
63
60
|
const filenames = fs_extra_1.default.readdirSync(srcDir);
|
|
64
61
|
if (!filenames || filenames.length === 0) {
|
|
@@ -74,38 +71,17 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
74
71
|
const output = fs_extra_1.default.createWriteStream(tempFile.name);
|
|
75
72
|
const archive = (0, archiver_1.default)('zip');
|
|
76
73
|
const result = new Promise(resolve => output.on('close', async function () {
|
|
77
|
-
let uploadResult;
|
|
78
74
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.handleProjectUpload.compressed`, {
|
|
79
75
|
byteCount: archive.pointer(),
|
|
80
76
|
}));
|
|
81
|
-
|
|
82
|
-
if (sendIR) {
|
|
83
|
-
try {
|
|
84
|
-
intermediateRepresentation = await (0, project_parsing_lib_1.translate)({
|
|
85
|
-
projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
|
|
86
|
-
platformVersion: projectConfig.platformVersion,
|
|
87
|
-
accountId,
|
|
88
|
-
});
|
|
89
|
-
logger_1.logger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
if ((0, project_parsing_lib_1.isTranslationError)(e)) {
|
|
93
|
-
logger_1.logger.error(e.toString());
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
(0, errorHandlers_1.logError)(e);
|
|
97
|
-
}
|
|
98
|
-
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion, intermediateRepresentation);
|
|
77
|
+
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion);
|
|
102
78
|
if (error) {
|
|
103
|
-
|
|
79
|
+
resolve({ uploadError: error });
|
|
104
80
|
}
|
|
105
81
|
else if (callbackFunc) {
|
|
106
|
-
uploadResult = await callbackFunc(accountId, projectConfig, tempFile, buildId);
|
|
82
|
+
const uploadResult = await callbackFunc(accountId, projectConfig, tempFile, buildId);
|
|
83
|
+
resolve({ result: uploadResult });
|
|
107
84
|
}
|
|
108
|
-
resolve(uploadResult || {});
|
|
109
85
|
}));
|
|
110
86
|
archive.pipe(output);
|
|
111
87
|
let loggedIgnoredNodeModule = false;
|
|
@@ -23,7 +23,14 @@ async function createTemplateOptions(templateSource, githubRef) {
|
|
|
23
23
|
const branch = hasCustomTemplateSource
|
|
24
24
|
? constants_1.DEFAULT_PROJECT_TEMPLATE_BRANCH
|
|
25
25
|
: githubRef;
|
|
26
|
-
|
|
26
|
+
let config;
|
|
27
|
+
try {
|
|
28
|
+
config = await (0, github_1.fetchFileFromRepository)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingConfigFileTemplateSource`));
|
|
32
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
33
|
+
}
|
|
27
34
|
if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
|
|
28
35
|
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
|
|
29
36
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId:
|
|
1
|
+
export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId: string, scopes: string[], redirectUrls: string[], isReinstall?: boolean): Promise<void>;
|
|
@@ -21,7 +21,7 @@ type ScopesPromptResponse = {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function personalAccessKeyPrompt({ env, account, }: {
|
|
23
23
|
env: string;
|
|
24
|
-
account?:
|
|
24
|
+
account?: number;
|
|
25
25
|
}): Promise<PersonalAccessKeyPromptResponse>;
|
|
26
26
|
export declare const OAUTH_FLOW: (PromptConfig<{
|
|
27
27
|
name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CLIAccount
|
|
1
|
+
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
2
|
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
3
3
|
export declare function selectSandboxTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
|
|
4
4
|
export declare function selectDeveloperTestTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
|
|
5
|
-
export declare function confirmDefaultAccountPrompt(accountName: string, accountType:
|
|
5
|
+
export declare function confirmDefaultAccountPrompt(accountName: string, accountType: string): Promise<boolean>;
|
|
6
6
|
export declare function confirmUseExistingDeveloperTestAccountPrompt(account: DeveloperTestAccount): Promise<boolean>;
|
package/lib/sandboxes.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export declare const SANDBOX_API_TYPE_MAP: {
|
|
|
17
17
|
export declare function getSandboxTypeAsString(accountType?: AccountType): string;
|
|
18
18
|
export declare function getAvailableSyncTypes(parentAccountConfig: CLIAccount, config: CLIAccount): Promise<Array<SandboxSyncTask>>;
|
|
19
19
|
export declare function validateSandboxUsageLimits(accountConfig: CLIAccount, sandboxType: AccountType, env: Environment): Promise<void>;
|
|
20
|
-
export declare function handleSandboxCreateError(err: unknown, env: Environment, name: string, accountId: number):
|
|
20
|
+
export declare function handleSandboxCreateError(err: unknown, env: Environment, name: string, accountId: number): never;
|
package/lib/serverlessLogs.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http';
|
|
2
|
+
import { FunctionLog, GetFunctionLogsResponse } from '@hubspot/local-dev-lib/types/Functions';
|
|
3
|
+
export declare function tailLogs(accountId: number, name: string, fetchLatest: () => HubSpotPromise<FunctionLog>, tailCall: (after?: string) => HubSpotPromise<GetFunctionLogsResponse>, compact?: boolean): Promise<void>;
|
|
4
|
+
export declare function outputBuildLog(buildLogUrl: string): Promise<string>;
|
package/lib/serverlessLogs.js
CHANGED
|
@@ -1,89 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
6
|
+
exports.tailLogs = tailLogs;
|
|
7
|
+
exports.outputBuildLog = outputBuildLog;
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
12
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
13
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
14
|
+
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
15
|
+
const serverlessFunctionLogs_1 = require("./ui/serverlessFunctionLogs");
|
|
16
|
+
const index_2 = require("./errorHandlers/index");
|
|
17
|
+
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
18
|
+
const process_1 = require("./process");
|
|
19
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
20
|
+
const lang_1 = require("./lang");
|
|
17
21
|
const TAIL_DELAY = 5000;
|
|
18
|
-
|
|
22
|
+
function base64EncodeString(valueToEncode) {
|
|
19
23
|
if (typeof valueToEncode !== 'string') {
|
|
20
24
|
return valueToEncode;
|
|
21
25
|
}
|
|
22
26
|
const stringBuffer = Buffer.from(valueToEncode);
|
|
23
27
|
return encodeURIComponent(stringBuffer.toString('base64'));
|
|
24
|
-
}
|
|
25
|
-
|
|
28
|
+
}
|
|
29
|
+
function handleUserInput() {
|
|
26
30
|
const onTerminate = async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
31
|
+
SpinniesManager_1.default.remove('tailLogs');
|
|
32
|
+
SpinniesManager_1.default.remove('stopMessage');
|
|
33
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
30
34
|
};
|
|
31
|
-
handleExit(onTerminate);
|
|
32
|
-
handleKeypress(key => {
|
|
35
|
+
(0, process_1.handleExit)(onTerminate);
|
|
36
|
+
(0, process_1.handleKeypress)(key => {
|
|
33
37
|
if ((key.ctrl && key.name == 'c') || key.name === 'q') {
|
|
34
38
|
onTerminate();
|
|
35
39
|
}
|
|
36
40
|
});
|
|
37
|
-
}
|
|
41
|
+
}
|
|
38
42
|
async function verifyAccessKeyAndUserAccess(accountId, scopeGroup) {
|
|
39
|
-
const accountConfig = getAccountConfig(accountId);
|
|
43
|
+
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
44
|
+
if (!accountConfig) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
40
47
|
// TODO[JOE]: Update this i18n key
|
|
41
48
|
const i18nKey = 'lib.serverless';
|
|
42
49
|
const { authType } = accountConfig;
|
|
43
|
-
if (authType !== PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
|
|
50
|
+
if (authType !== auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
53
|
let scopesData;
|
|
47
54
|
try {
|
|
48
|
-
|
|
55
|
+
const resp = await (0, localDevAuth_1.fetchScopeData)(accountId, scopeGroup);
|
|
56
|
+
scopesData = resp.data;
|
|
49
57
|
}
|
|
50
58
|
catch (e) {
|
|
51
|
-
logger.debug(i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.fetchScopeDataError`, {
|
|
59
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.verifyAccessKeyAndUserAccess.fetchScopeDataError`, {
|
|
52
60
|
scopeGroup,
|
|
53
|
-
error: e,
|
|
54
61
|
}));
|
|
62
|
+
logger_1.logger.debug(e);
|
|
55
63
|
return;
|
|
56
64
|
}
|
|
57
65
|
const { portalScopesInGroup, userScopesInGroup } = scopesData;
|
|
58
66
|
if (!portalScopesInGroup.length) {
|
|
59
|
-
logger.error(i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.portalMissingScope`));
|
|
67
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.verifyAccessKeyAndUserAccess.portalMissingScope`));
|
|
60
68
|
return;
|
|
61
69
|
}
|
|
62
70
|
if (!portalScopesInGroup.every(s => userScopesInGroup.includes(s))) {
|
|
63
|
-
logger.error(i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.userMissingScope`));
|
|
71
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.verifyAccessKeyAndUserAccess.userMissingScope`));
|
|
64
72
|
}
|
|
65
73
|
else {
|
|
66
|
-
logger.error(i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.genericMissingScope`));
|
|
74
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.verifyAccessKeyAndUserAccess.genericMissingScope`));
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
|
-
|
|
70
|
-
let initialAfter;
|
|
77
|
+
async function tailLogs(accountId, name, fetchLatest, tailCall, compact = false) {
|
|
78
|
+
let initialAfter = '';
|
|
71
79
|
try {
|
|
72
80
|
const { data: latestLog } = await fetchLatest();
|
|
73
81
|
initialAfter = latestLog && base64EncodeString(latestLog.id);
|
|
74
82
|
}
|
|
75
83
|
catch (e) {
|
|
76
84
|
// A 404 means no latest log exists(never executed)
|
|
77
|
-
if (isHubSpotHttpError(e) && e.status !== 404) {
|
|
78
|
-
if (isMissingScopeError(e)) {
|
|
79
|
-
await verifyAccessKeyAndUserAccess(accountId, SCOPE_GROUPS.CMS_FUNCTIONS);
|
|
85
|
+
if ((0, index_1.isHubSpotHttpError)(e) && e.status !== 404) {
|
|
86
|
+
if ((0, index_1.isMissingScopeError)(e)) {
|
|
87
|
+
await verifyAccessKeyAndUserAccess(accountId, auth_1.SCOPE_GROUPS.CMS_FUNCTIONS);
|
|
80
88
|
}
|
|
81
89
|
else {
|
|
82
|
-
await logError(e, new ApiErrorContext({ accountId }));
|
|
90
|
+
await (0, index_2.logError)(e, new index_2.ApiErrorContext({ accountId }));
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
|
-
|
|
94
|
+
async function tail(after) {
|
|
87
95
|
let latestLog;
|
|
88
96
|
let nextAfter;
|
|
89
97
|
try {
|
|
@@ -92,41 +100,41 @@ const tailLogs = async ({ accountId, compact, fetchLatest, tailCall, name, }) =>
|
|
|
92
100
|
nextAfter = latestLog.paging.next.after;
|
|
93
101
|
}
|
|
94
102
|
catch (e) {
|
|
95
|
-
if (isHubSpotHttpError(e) && e.status !== 404) {
|
|
96
|
-
logError(e, new ApiErrorContext({
|
|
103
|
+
if ((0, index_1.isHubSpotHttpError)(e) && e.status !== 404) {
|
|
104
|
+
(0, index_2.logError)(e, new index_2.ApiErrorContext({
|
|
97
105
|
accountId,
|
|
98
106
|
}));
|
|
99
107
|
}
|
|
100
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
108
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
101
109
|
}
|
|
102
110
|
if (latestLog && latestLog.results.length) {
|
|
103
|
-
outputLogs(latestLog, {
|
|
111
|
+
(0, serverlessFunctionLogs_1.outputLogs)(latestLog, {
|
|
104
112
|
compact,
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
115
|
setTimeout(async () => {
|
|
108
116
|
await tail(nextAfter);
|
|
109
117
|
}, TAIL_DELAY);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
}
|
|
119
|
+
SpinniesManager_1.default.init();
|
|
120
|
+
SpinniesManager_1.default.add('tailLogs', {
|
|
113
121
|
text: `Following logs for ${name}`,
|
|
114
122
|
});
|
|
115
|
-
|
|
116
|
-
text: `> Press ${
|
|
123
|
+
SpinniesManager_1.default.add('stopMessage', {
|
|
124
|
+
text: `> Press ${chalk_1.default.bold('q')} to stop following`,
|
|
117
125
|
status: 'non-spinnable',
|
|
118
126
|
});
|
|
119
127
|
handleUserInput();
|
|
120
128
|
await tail(initialAfter);
|
|
121
|
-
}
|
|
122
|
-
|
|
129
|
+
}
|
|
130
|
+
async function outputBuildLog(buildLogUrl) {
|
|
123
131
|
if (!buildLogUrl) {
|
|
124
|
-
logger.debug('Unable to display build output. No build log URL was provided.');
|
|
125
|
-
return;
|
|
132
|
+
logger_1.logger.debug('Unable to display build output. No build log URL was provided.');
|
|
133
|
+
return '';
|
|
126
134
|
}
|
|
127
135
|
return new Promise(resolve => {
|
|
128
136
|
try {
|
|
129
|
-
|
|
137
|
+
https_1.default
|
|
130
138
|
.get(buildLogUrl, response => {
|
|
131
139
|
if (response.statusCode === 404) {
|
|
132
140
|
resolve('');
|
|
@@ -136,21 +144,17 @@ const outputBuildLog = async (buildLogUrl) => {
|
|
|
136
144
|
data += chunk;
|
|
137
145
|
});
|
|
138
146
|
response.on('end', () => {
|
|
139
|
-
logger.log(data);
|
|
147
|
+
logger_1.logger.log(data);
|
|
140
148
|
resolve(data);
|
|
141
149
|
});
|
|
142
150
|
})
|
|
143
151
|
.on('error', () => {
|
|
144
|
-
logger.error('The build log could not be retrieved.');
|
|
152
|
+
logger_1.logger.error('The build log could not be retrieved.');
|
|
145
153
|
});
|
|
146
154
|
}
|
|
147
155
|
catch (e) {
|
|
148
|
-
logger.error('The build log could not be retrieved.');
|
|
156
|
+
logger_1.logger.error('The build log could not be retrieved.');
|
|
149
157
|
resolve('');
|
|
150
158
|
}
|
|
151
159
|
});
|
|
152
|
-
}
|
|
153
|
-
module.exports = {
|
|
154
|
-
outputBuildLog,
|
|
155
|
-
tailLogs,
|
|
156
|
-
};
|
|
160
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
import { FunctionLog, GetFunctionLogsResponse } from '@hubspot/local-dev-lib/types/Functions';
|
|
2
|
+
type Options = {
|
|
3
|
+
compact?: boolean;
|
|
4
|
+
insertions?: {
|
|
5
|
+
header?: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function outputLogs(logsResp: GetFunctionLogsResponse | FunctionLog, options: Options): void;
|
|
1
9
|
export {};
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.outputLogs = outputLogs;
|
|
6
7
|
const moment_1 = __importDefault(require("moment"));
|
|
7
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
9
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
@@ -90,6 +91,3 @@ function processLogs(logsResp, options) {
|
|
|
90
91
|
function outputLogs(logsResp, options) {
|
|
91
92
|
logger_1.logger.log(processLogs(logsResp, options));
|
|
92
93
|
}
|
|
93
|
-
module.exports = {
|
|
94
|
-
outputLogs,
|
|
95
|
-
};
|
package/lib/validation.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
|
3
3
|
export declare function validateAccount(options: Arguments<{
|
|
4
4
|
account?: string;
|
|
5
5
|
accountId?: string;
|
|
6
|
+
derivedAccountId?: number;
|
|
7
|
+
providedAccountId?: string;
|
|
6
8
|
}>): Promise<boolean>;
|
|
7
9
|
export declare function validateCmsPublishMode(options: Arguments<{
|
|
8
10
|
cmsPublishMode?: CmsPublishMode;
|
package/lib/validation.js
CHANGED
|
@@ -50,21 +50,18 @@ const path_1 = require("@hubspot/local-dev-lib/path");
|
|
|
50
50
|
const commonOpts_1 = require("./commonOpts");
|
|
51
51
|
const index_1 = require("./errorHandlers/index");
|
|
52
52
|
async function validateAccount(options) {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
53
|
+
const { derivedAccountId, providedAccountId } = options;
|
|
54
|
+
const accountId = (0, config_1.getAccountId)(derivedAccountId);
|
|
55
55
|
if (!accountId) {
|
|
56
|
-
if (
|
|
57
|
-
logger_1.logger.error(`The account "${
|
|
58
|
-
}
|
|
59
|
-
else if (accountIdOption) {
|
|
60
|
-
logger_1.logger.error(`The account "${accountIdOption}" could not be found in the config`);
|
|
56
|
+
if (providedAccountId) {
|
|
57
|
+
logger_1.logger.error(`The account "${providedAccountId}" could not be found in the config`);
|
|
61
58
|
}
|
|
62
59
|
else {
|
|
63
60
|
logger_1.logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
|
|
64
61
|
}
|
|
65
62
|
return false;
|
|
66
63
|
}
|
|
67
|
-
if (
|
|
64
|
+
if (providedAccountId && (0, config_1.loadConfigFromEnvironment)()) {
|
|
68
65
|
throw new Error('Cannot specify an account when environment variables are supplied. Please unset the environment variables or do not use the "--account" flag.');
|
|
69
66
|
}
|
|
70
67
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "3.1.
|
|
9
|
-
"@hubspot/project-parsing-lib": "^0.0.2-experimental.0",
|
|
8
|
+
"@hubspot/local-dev-lib": "3.1.3",
|
|
10
9
|
"@hubspot/serverless-dev-runtime": "7.0.1",
|
|
11
10
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
11
|
"@hubspot/ui-extensions-dev-server": "0.8.40",
|
package/types/Projects.d.ts
CHANGED
|
@@ -41,6 +41,12 @@ export type ProjectTemplateRepoConfig = {
|
|
|
41
41
|
projects?: ProjectTemplate[];
|
|
42
42
|
components?: ComponentTemplate[];
|
|
43
43
|
};
|
|
44
|
+
export type ProjectPollResult = {
|
|
45
|
+
succeeded: boolean;
|
|
46
|
+
buildId: number;
|
|
47
|
+
buildResult: Build;
|
|
48
|
+
deployResult: Deploy | null;
|
|
49
|
+
};
|
|
44
50
|
export type PrivateAppComponentConfig = {
|
|
45
51
|
name: string;
|
|
46
52
|
description: string;
|
|
@@ -103,9 +109,9 @@ export declare enum ComponentTypes {
|
|
|
103
109
|
PublicApp = "public-app",
|
|
104
110
|
HublTheme = "hubl-theme"
|
|
105
111
|
}
|
|
106
|
-
export type Component = {
|
|
112
|
+
export type Component<T = GenericComponentConfig> = {
|
|
107
113
|
type: ComponentTypes;
|
|
108
|
-
config:
|
|
114
|
+
config: T;
|
|
109
115
|
runnable: boolean;
|
|
110
116
|
path: string;
|
|
111
117
|
};
|
package/types/Yargs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Options } from 'yargs';
|
|
2
|
+
export type CommonArgs = {
|
|
3
|
+
derivedAccountId: number;
|
|
4
|
+
providedAccountId?: number;
|
|
5
|
+
d: boolean;
|
|
6
|
+
debug: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ConfigArgs = {
|
|
9
|
+
c?: string;
|
|
10
|
+
config?: string;
|
|
11
|
+
};
|
|
12
|
+
export type StringArgType = Options & {
|
|
13
|
+
type: 'string';
|
|
14
|
+
};
|
package/types/Yargs.js
ADDED