@hubspot/cli 5.1.3 → 5.1.4-beta.1
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/commands/accounts/list.js +43 -31
- package/commands/customObject/create.js +10 -6
- package/commands/customObject/schema/create.js +10 -9
- package/commands/customObject/schema/delete.js +6 -6
- package/commands/customObject/schema/fetch.js +1 -1
- package/commands/customObject/schema/update.js +10 -9
- package/commands/functions/deploy.js +1 -1
- package/commands/functions/list.js +1 -1
- package/commands/hubdb/clear.js +4 -4
- package/commands/hubdb/create.js +5 -5
- package/commands/hubdb/delete.js +3 -3
- package/commands/hubdb/fetch.js +3 -3
- package/commands/mv.js +3 -2
- package/commands/project/deploy.js +4 -1
- package/commands/project/dev.js +33 -14
- package/commands/project/download.js +1 -1
- package/commands/project/listBuilds.js +1 -1
- package/commands/project/logs.js +7 -7
- package/commands/project/upload.js +5 -2
- package/commands/project/watch.js +7 -2
- package/commands/sandbox/create.js +6 -7
- package/commands/sandbox/delete.js +8 -11
- package/commands/sandbox/sync.js +18 -17
- package/commands/secrets/addSecret.js +5 -6
- package/commands/secrets/deleteSecret.js +5 -6
- package/commands/secrets/listSecrets.js +5 -6
- package/commands/secrets/updateSecret.js +5 -6
- package/lang/en.lyaml +3 -2
- package/lib/DevServerManager.js +12 -6
- package/lib/LocalDevManager.js +1 -1
- package/lib/constants.js +11 -0
- package/lib/developerTestAccounts.js +14 -0
- package/lib/lang.js +3 -1
- package/lib/marketplace-validate.js +1 -1
- package/lib/projects.js +6 -5
- package/lib/projectsWatch.js +61 -19
- package/lib/prompts/accountsPrompt.js +5 -7
- package/lib/prompts/downloadProjectPrompt.js +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +15 -11
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/prompts/sandboxesPrompt.js +12 -13
- package/lib/{sandbox-create.js → sandboxCreate.js} +100 -13
- package/lib/{sandbox-sync.js → sandboxSync.js} +7 -7
- package/lib/sandboxes.js +53 -136
- package/lib/schema.js +4 -2
- package/lib/ui.js +16 -5
- package/lib/validation.js +8 -6
- package/package.json +4 -4
|
@@ -12,8 +12,15 @@ const {
|
|
|
12
12
|
} = require('../../lib/commonOpts');
|
|
13
13
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
14
14
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
|
-
const {
|
|
15
|
+
const { isSandbox, getSandboxName } = require('../../lib/sandboxes');
|
|
16
|
+
const {
|
|
17
|
+
isDeveloperTestAccount,
|
|
18
|
+
DEV_TEST_ACCOUNT_STRING,
|
|
19
|
+
} = require('../../lib/developerTestAccounts');
|
|
16
20
|
const { i18n } = require('../../lib/lang');
|
|
21
|
+
const {
|
|
22
|
+
HUBSPOT_ACCOUNT_TYPES,
|
|
23
|
+
} = require('@hubspot/local-dev-lib/constants/config');
|
|
17
24
|
|
|
18
25
|
const i18nKey = 'cli.commands.accounts.subcommands.list';
|
|
19
26
|
|
|
@@ -22,29 +29,32 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
22
29
|
|
|
23
30
|
const sortAndMapPortals = portals => {
|
|
24
31
|
const mappedPortalData = {};
|
|
32
|
+
// Standard and app developer portals
|
|
25
33
|
portals
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
return 0;
|
|
34
|
-
})
|
|
34
|
+
.filter(p =>
|
|
35
|
+
p.accountType
|
|
36
|
+
? p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
|
|
37
|
+
p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER
|
|
38
|
+
: p.sandboxAccountType === null
|
|
39
|
+
)
|
|
35
40
|
.forEach(portal => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
mappedPortalData[portal.portalId] = [portal];
|
|
42
|
+
});
|
|
43
|
+
// Non-standard portals (sandbox, developer test account)
|
|
44
|
+
portals
|
|
45
|
+
.filter(p =>
|
|
46
|
+
p.accountType
|
|
47
|
+
? isSandbox(p) || isDeveloperTestAccount(p)
|
|
48
|
+
: p.sandboxAccountType !== null
|
|
49
|
+
)
|
|
50
|
+
.forEach(p => {
|
|
51
|
+
if (p.parentAccountId) {
|
|
52
|
+
mappedPortalData[p.parentAccountId] = [
|
|
53
|
+
...(mappedPortalData[p.parentAccountId] || []),
|
|
54
|
+
p,
|
|
45
55
|
];
|
|
46
56
|
} else {
|
|
47
|
-
mappedPortalData[
|
|
57
|
+
mappedPortalData[p.portalId] = [p];
|
|
48
58
|
}
|
|
49
59
|
});
|
|
50
60
|
return mappedPortalData;
|
|
@@ -53,18 +63,20 @@ const sortAndMapPortals = portals => {
|
|
|
53
63
|
const getPortalData = mappedPortalData => {
|
|
54
64
|
const portalData = [];
|
|
55
65
|
Object.values(mappedPortalData).forEach(set => {
|
|
56
|
-
set.forEach(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`↳ ${
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
set.forEach(portal => {
|
|
67
|
+
let name = portal.name;
|
|
68
|
+
if (isSandbox(portal)) {
|
|
69
|
+
name = `${portal.name} ${getSandboxName(portal)}`;
|
|
70
|
+
if (set.length > 1) {
|
|
71
|
+
name = `↳ ${name}`;
|
|
72
|
+
}
|
|
73
|
+
} else if (isDeveloperTestAccount(portal)) {
|
|
74
|
+
name = `${portal.name} [${DEV_TEST_ACCOUNT_STRING}]`;
|
|
75
|
+
if (set.length > 1) {
|
|
76
|
+
name = `↳ ${name}`;
|
|
77
|
+
}
|
|
67
78
|
}
|
|
79
|
+
portalData.push([name, portal.portalId, portal.authType]);
|
|
68
80
|
});
|
|
69
81
|
});
|
|
70
82
|
return portalData;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
|
|
3
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
4
4
|
const {
|
|
5
|
-
|
|
5
|
+
checkAndConvertToJson,
|
|
6
6
|
loadAndValidateOptions,
|
|
7
7
|
} = require('../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
9
|
const { getAccountId } = require('../../lib/commonOpts');
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
batchCreateObjects,
|
|
12
|
+
} = require('@hubspot/local-dev-lib/api/customObjects');
|
|
11
13
|
const { i18n } = require('../../lib/lang');
|
|
12
14
|
|
|
13
15
|
const i18nKey = 'cli.commands.customObject.subcommands.create';
|
|
@@ -26,15 +28,17 @@ exports.handler = async options => {
|
|
|
26
28
|
trackCommandUsage('custom-object-batch-create', null, accountId);
|
|
27
29
|
|
|
28
30
|
const filePath = getAbsoluteFilePath(definition);
|
|
29
|
-
|
|
31
|
+
const objectJson = checkAndConvertToJson(filePath);
|
|
32
|
+
|
|
33
|
+
if (!objectJson) {
|
|
30
34
|
process.exit(EXIT_CODES.ERROR);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
try {
|
|
34
|
-
await batchCreateObjects(accountId, name,
|
|
38
|
+
await batchCreateObjects(accountId, name, objectJson);
|
|
35
39
|
logger.success(i18n(`${i18nKey}.success.objectsCreated`));
|
|
36
40
|
} catch (e) {
|
|
37
|
-
|
|
41
|
+
logApiErrorInstance(e, { accountId });
|
|
38
42
|
logger.error(
|
|
39
43
|
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
40
44
|
definition,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logErrorInstance,
|
|
4
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
2
|
+
const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
|
|
5
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
6
4
|
const {
|
|
7
|
-
|
|
5
|
+
checkAndConvertToJson,
|
|
8
6
|
loadAndValidateOptions,
|
|
9
7
|
} = require('../../../lib/validation');
|
|
10
8
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -14,10 +12,12 @@ const {
|
|
|
14
12
|
isConfigFlagEnabled,
|
|
15
13
|
} = require('@hubspot/local-dev-lib/config');
|
|
16
14
|
const { ENVIRONMENTS, ConfigFlags } = require('@hubspot/cli-lib/lib/constants');
|
|
17
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
createObjectSchema,
|
|
17
|
+
} = require('@hubspot/local-dev-lib/api/customObjects');
|
|
18
18
|
const {
|
|
19
19
|
createSchema: createSchemaFromHubFile,
|
|
20
|
-
} = require('@hubspot/
|
|
20
|
+
} = require('@hubspot/local-dev-lib/api/fileTransport');
|
|
21
21
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
22
22
|
const { i18n } = require('../../../lib/lang');
|
|
23
23
|
|
|
@@ -38,7 +38,8 @@ exports.handler = async options => {
|
|
|
38
38
|
trackCommandUsage('custom-object-schema-create', null, accountId);
|
|
39
39
|
|
|
40
40
|
const filePath = getAbsoluteFilePath(definition);
|
|
41
|
-
|
|
41
|
+
const schemaJson = checkAndConvertToJson(filePath);
|
|
42
|
+
if (!schemaJson) {
|
|
42
43
|
process.exit(EXIT_CODES.ERROR);
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -51,7 +52,7 @@ exports.handler = async options => {
|
|
|
51
52
|
})
|
|
52
53
|
);
|
|
53
54
|
} else {
|
|
54
|
-
const res = await
|
|
55
|
+
const res = await createObjectSchema(accountId, schemaJson);
|
|
55
56
|
logger.success(
|
|
56
57
|
i18n(`${i18nKey}.success.schemaViewable`, {
|
|
57
58
|
url: `${getHubSpotWebsiteOrigin(
|
|
@@ -61,7 +62,7 @@ exports.handler = async options => {
|
|
|
61
62
|
);
|
|
62
63
|
}
|
|
63
64
|
} catch (e) {
|
|
64
|
-
|
|
65
|
+
logApiErrorInstance(e, { accountId });
|
|
65
66
|
logger.error(
|
|
66
67
|
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
67
68
|
definition,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logErrorInstance,
|
|
4
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
2
|
+
const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
|
|
5
3
|
|
|
6
4
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
8
6
|
const { getAccountId } = require('../../../lib/commonOpts');
|
|
9
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
deleteObjectSchema,
|
|
9
|
+
} = require('@hubspot/local-dev-lib/api/customObjects');
|
|
10
10
|
const { i18n } = require('../../../lib/lang');
|
|
11
11
|
|
|
12
12
|
const i18nKey =
|
|
@@ -25,14 +25,14 @@ exports.handler = async options => {
|
|
|
25
25
|
trackCommandUsage('custom-object-schema-delete', null, accountId);
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
|
-
await
|
|
28
|
+
await deleteObjectSchema(accountId, name);
|
|
29
29
|
logger.success(
|
|
30
30
|
i18n(`${i18nKey}.success.delete`, {
|
|
31
31
|
name,
|
|
32
32
|
})
|
|
33
33
|
);
|
|
34
34
|
} catch (e) {
|
|
35
|
-
|
|
35
|
+
logApiErrorInstance(e);
|
|
36
36
|
logger.error(
|
|
37
37
|
i18n(`${i18nKey}.errors.delete`, {
|
|
38
38
|
name,
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
downloadSchema,
|
|
10
10
|
getResolvedPath,
|
|
11
11
|
} = require('@hubspot/local-dev-lib/customObjects');
|
|
12
|
-
const { fetchSchema } = require('@hubspot/
|
|
12
|
+
const { fetchSchema } = require('@hubspot/local-dev-lib/api/fileTransport');
|
|
13
13
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
14
14
|
|
|
15
15
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logErrorInstance,
|
|
4
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
2
|
+
const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
|
|
5
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
6
4
|
const {
|
|
7
|
-
|
|
5
|
+
checkAndConvertToJson,
|
|
8
6
|
loadAndValidateOptions,
|
|
9
7
|
} = require('../../../lib/validation');
|
|
10
8
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -14,10 +12,12 @@ const {
|
|
|
14
12
|
getEnv,
|
|
15
13
|
isConfigFlagEnabled,
|
|
16
14
|
} = require('@hubspot/local-dev-lib/config');
|
|
17
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
updateObjectSchema,
|
|
17
|
+
} = require('@hubspot/local-dev-lib/api/customObjects');
|
|
18
18
|
const {
|
|
19
19
|
updateSchema: updateSchemaFromHubFile,
|
|
20
|
-
} = require('@hubspot/
|
|
20
|
+
} = require('@hubspot/local-dev-lib/api/fileTransport');
|
|
21
21
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
22
22
|
const { i18n } = require('../../../lib/lang');
|
|
23
23
|
|
|
@@ -38,7 +38,8 @@ exports.handler = async options => {
|
|
|
38
38
|
trackCommandUsage('custom-object-schema-update', null, accountId);
|
|
39
39
|
|
|
40
40
|
const filePath = getAbsoluteFilePath(definition);
|
|
41
|
-
|
|
41
|
+
const schemaJson = checkAndConvertToJson(filePath);
|
|
42
|
+
if (!schemaJson) {
|
|
42
43
|
process.exit(EXIT_CODES.ERROR);
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -51,7 +52,7 @@ exports.handler = async options => {
|
|
|
51
52
|
})
|
|
52
53
|
);
|
|
53
54
|
} else {
|
|
54
|
-
const res = await
|
|
55
|
+
const res = await updateObjectSchema(accountId, name, schemaJson);
|
|
55
56
|
logger.success(
|
|
56
57
|
i18n(`${i18nKey}.success.viewAtUrl`, {
|
|
57
58
|
url: `${getHubSpotWebsiteOrigin(
|
|
@@ -61,7 +62,7 @@ exports.handler = async options => {
|
|
|
61
62
|
);
|
|
62
63
|
}
|
|
63
64
|
} catch (e) {
|
|
64
|
-
|
|
65
|
+
logApiErrorInstance(e, { accountId });
|
|
65
66
|
logger.error(
|
|
66
67
|
i18n(`${i18nKey}.errors.update`, {
|
|
67
68
|
definition,
|
|
@@ -15,7 +15,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
15
15
|
const {
|
|
16
16
|
buildPackage,
|
|
17
17
|
getBuildStatus,
|
|
18
|
-
} = require('@hubspot/
|
|
18
|
+
} = require('@hubspot/local-dev-lib/api/functions');
|
|
19
19
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
20
20
|
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
21
21
|
const { i18n } = require('../../lib/lang');
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
const { clearHubDbTableRows } = require('@hubspot/
|
|
4
|
-
const { publishTable } = require('@hubspot/
|
|
2
|
+
const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { clearHubDbTableRows } = require('@hubspot/local-dev-lib/hubdb');
|
|
4
|
+
const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
5
5
|
|
|
6
6
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
7
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -52,7 +52,7 @@ exports.handler = async options => {
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
} catch (e) {
|
|
55
|
-
|
|
55
|
+
logApiErrorInstance(e);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
package/commands/hubdb/create.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
4
|
-
const {
|
|
4
|
+
const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
|
|
5
5
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
6
|
-
const { createHubDbTable } = require('@hubspot/
|
|
6
|
+
const { createHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
-
|
|
9
|
+
checkAndConvertToJson,
|
|
10
10
|
loadAndValidateOptions,
|
|
11
11
|
} = require('../../lib/validation');
|
|
12
12
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -35,7 +35,7 @@ exports.handler = async options => {
|
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
37
|
const filePath = path.resolve(getCwd(), src);
|
|
38
|
-
if (!
|
|
38
|
+
if (!checkAndConvertToJson(filePath)) {
|
|
39
39
|
process.exit(EXIT_CODES.ERROR);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -56,7 +56,7 @@ exports.handler = async options => {
|
|
|
56
56
|
src,
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
|
-
|
|
59
|
+
logApiErrorInstance(e);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
const { deleteTable } = require('@hubspot/
|
|
2
|
+
const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { deleteTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
4
4
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
5
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
6
6
|
|
|
@@ -40,7 +40,7 @@ exports.handler = async options => {
|
|
|
40
40
|
tableId,
|
|
41
41
|
})
|
|
42
42
|
);
|
|
43
|
-
|
|
43
|
+
logApiErrorInstance(e);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
package/commands/hubdb/fetch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
const { downloadHubDbTable } = require('@hubspot/
|
|
2
|
+
const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { downloadHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
4
4
|
|
|
5
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -37,7 +37,7 @@ exports.handler = async options => {
|
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
} catch (e) {
|
|
40
|
-
|
|
40
|
+
logApiErrorInstance(e);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
package/commands/mv.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
2
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
+
const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
3
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
3
4
|
const {
|
|
4
5
|
logApiErrorInstance,
|
|
5
6
|
ApiErrorContext,
|
|
@@ -55,7 +56,7 @@ exports.handler = async options => {
|
|
|
55
56
|
srcPath,
|
|
56
57
|
})
|
|
57
58
|
);
|
|
58
|
-
if (error
|
|
59
|
+
if (isSpecifiedError(error, { statusCode: 409 })) {
|
|
59
60
|
logger.error(
|
|
60
61
|
i18n(`${i18nKey}.errors.sourcePathExists`, {
|
|
61
62
|
destPath,
|
|
@@ -11,7 +11,10 @@ const {
|
|
|
11
11
|
ApiErrorContext,
|
|
12
12
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
13
13
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
deployProject,
|
|
16
|
+
fetchProject,
|
|
17
|
+
} = require('@hubspot/local-dev-lib/api/projects');
|
|
15
18
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
16
19
|
const { getProjectConfig, pollDeployStatus } = require('../../lib/projects');
|
|
17
20
|
const { projectNamePrompt } = require('../../lib/prompts/projectNamePrompt');
|
package/commands/project/dev.js
CHANGED
|
@@ -18,7 +18,10 @@ const {
|
|
|
18
18
|
getAccountConfig,
|
|
19
19
|
getEnv,
|
|
20
20
|
} = require('@hubspot/local-dev-lib/config');
|
|
21
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
createProject,
|
|
23
|
+
fetchProject,
|
|
24
|
+
} = require('@hubspot/local-dev-lib/api/projects');
|
|
22
25
|
const {
|
|
23
26
|
getProjectConfig,
|
|
24
27
|
ensureProjectExists,
|
|
@@ -37,15 +40,14 @@ const {
|
|
|
37
40
|
const { confirmPrompt } = require('../../lib/prompts/promptUtils');
|
|
38
41
|
const {
|
|
39
42
|
selectTargetAccountPrompt,
|
|
40
|
-
|
|
43
|
+
confirmDefaultAccountPrompt,
|
|
41
44
|
} = require('../../lib/prompts/projectDevTargetAccountPrompt');
|
|
42
45
|
const SpinniesManager = require('../../lib/SpinniesManager');
|
|
43
46
|
const LocalDevManager = require('../../lib/LocalDevManager');
|
|
44
|
-
const { isSandbox } = require('../../lib/sandboxes');
|
|
47
|
+
const { isSandbox, getSandboxTypeAsString } = require('../../lib/sandboxes');
|
|
45
48
|
const { sandboxNamePrompt } = require('../../lib/prompts/sandboxesPrompt');
|
|
46
49
|
const {
|
|
47
50
|
validateSandboxUsageLimits,
|
|
48
|
-
DEVELOPER_SANDBOX,
|
|
49
51
|
getAvailableSyncTypes,
|
|
50
52
|
} = require('../../lib/sandboxes');
|
|
51
53
|
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
@@ -55,8 +57,8 @@ const {
|
|
|
55
57
|
ERROR_TYPES,
|
|
56
58
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
57
59
|
|
|
58
|
-
const { buildSandbox } = require('../../lib/
|
|
59
|
-
const { syncSandbox } = require('../../lib/
|
|
60
|
+
const { buildSandbox } = require('../../lib/sandboxCreate');
|
|
61
|
+
const { syncSandbox } = require('../../lib/sandboxSync');
|
|
60
62
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
61
63
|
const {
|
|
62
64
|
logApiErrorInstance,
|
|
@@ -67,6 +69,11 @@ const {
|
|
|
67
69
|
isMissingScopeError,
|
|
68
70
|
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
69
71
|
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
72
|
+
const {
|
|
73
|
+
isDeveloperTestAccount,
|
|
74
|
+
DEV_TEST_ACCOUNT_STRING,
|
|
75
|
+
} = require('../../lib/developerTestAccounts');
|
|
76
|
+
const { DEVELOPER_SANDBOX_TYPE } = require('../../lib/constants');
|
|
70
77
|
|
|
71
78
|
const i18nKey = 'cli.commands.project.subcommands.dev';
|
|
72
79
|
|
|
@@ -96,19 +103,27 @@ exports.handler = async options => {
|
|
|
96
103
|
let targetAccountId = options.account ? accountId : null;
|
|
97
104
|
let createNewSandbox = false;
|
|
98
105
|
const defaultAccountIsSandbox = isSandbox(accountConfig);
|
|
106
|
+
const defaultAccountIsDeveloperTestAccount = isDeveloperTestAccount(
|
|
107
|
+
accountConfig
|
|
108
|
+
);
|
|
99
109
|
|
|
100
|
-
if (
|
|
110
|
+
if (
|
|
111
|
+
!targetAccountId &&
|
|
112
|
+
(defaultAccountIsSandbox || defaultAccountIsDeveloperTestAccount)
|
|
113
|
+
) {
|
|
101
114
|
logger.log();
|
|
102
|
-
const
|
|
115
|
+
const useDefaultAccount = await confirmDefaultAccountPrompt(
|
|
103
116
|
accountConfig.name,
|
|
104
|
-
|
|
117
|
+
defaultAccountIsSandbox
|
|
118
|
+
? `${getSandboxTypeAsString(accountConfig.accountType)} sandbox`
|
|
119
|
+
: DEV_TEST_ACCOUNT_STRING
|
|
105
120
|
);
|
|
106
121
|
|
|
107
|
-
if (
|
|
122
|
+
if (useDefaultAccount) {
|
|
108
123
|
targetAccountId = accountId;
|
|
109
124
|
} else {
|
|
110
125
|
logger.log(
|
|
111
|
-
i18n(`${i18nKey}.logs.
|
|
126
|
+
i18n(`${i18nKey}.logs.declineDefaultAccountExplanation`, {
|
|
112
127
|
useCommand: uiCommandReference('hs accounts use'),
|
|
113
128
|
devCommand: uiCommandReference('hs project dev'),
|
|
114
129
|
})
|
|
@@ -135,7 +150,11 @@ exports.handler = async options => {
|
|
|
135
150
|
|
|
136
151
|
if (createNewSandbox) {
|
|
137
152
|
try {
|
|
138
|
-
await validateSandboxUsageLimits(
|
|
153
|
+
await validateSandboxUsageLimits(
|
|
154
|
+
accountConfig,
|
|
155
|
+
DEVELOPER_SANDBOX_TYPE,
|
|
156
|
+
env
|
|
157
|
+
);
|
|
139
158
|
} catch (err) {
|
|
140
159
|
if (isMissingScopeError(err)) {
|
|
141
160
|
logger.error(
|
|
@@ -157,7 +176,7 @@ exports.handler = async options => {
|
|
|
157
176
|
process.exit(EXIT_CODES.ERROR);
|
|
158
177
|
}
|
|
159
178
|
try {
|
|
160
|
-
const { name } = await sandboxNamePrompt(
|
|
179
|
+
const { name } = await sandboxNamePrompt(DEVELOPER_SANDBOX_TYPE);
|
|
161
180
|
|
|
162
181
|
trackCommandMetadataUsage(
|
|
163
182
|
'sandbox-create',
|
|
@@ -167,7 +186,7 @@ exports.handler = async options => {
|
|
|
167
186
|
|
|
168
187
|
const { result } = await buildSandbox({
|
|
169
188
|
name,
|
|
170
|
-
type:
|
|
189
|
+
type: DEVELOPER_SANDBOX_TYPE,
|
|
171
190
|
accountConfig,
|
|
172
191
|
env,
|
|
173
192
|
});
|
|
@@ -16,7 +16,7 @@ const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
|
|
|
16
16
|
const {
|
|
17
17
|
downloadProject,
|
|
18
18
|
fetchProjectBuilds,
|
|
19
|
-
} = require('@hubspot/
|
|
19
|
+
} = require('@hubspot/local-dev-lib/api/projects');
|
|
20
20
|
const { ensureProjectExists, getProjectConfig } = require('../../lib/projects');
|
|
21
21
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
22
22
|
const {
|
package/commands/project/logs.js
CHANGED
|
@@ -13,21 +13,21 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
13
13
|
const {
|
|
14
14
|
fetchProject,
|
|
15
15
|
fetchDeployComponentsMetadata,
|
|
16
|
-
} = require('@hubspot/
|
|
16
|
+
} = require('@hubspot/local-dev-lib/api/projects');
|
|
17
17
|
const {
|
|
18
18
|
getTableContents,
|
|
19
19
|
getTableHeader,
|
|
20
20
|
} = require('@hubspot/local-dev-lib/logging/table');
|
|
21
21
|
// const {
|
|
22
|
-
// getProjectAppFunctionLogs,
|
|
23
|
-
// getLatestProjectAppFunctionLog,
|
|
24
|
-
// getFunctionLogs,
|
|
25
|
-
// getLatestFunctionLog,
|
|
26
|
-
// } = require('@hubspot/cli-lib/api/functions');
|
|
27
|
-
// const {
|
|
28
22
|
// logApiErrorInstance,
|
|
29
23
|
// ApiErrorContext,
|
|
30
24
|
// } = require('../../lib/errorHandlers/apiErrors');
|
|
25
|
+
// const {
|
|
26
|
+
// getFunctionLogs,
|
|
27
|
+
// getLatestFunctionLog,
|
|
28
|
+
// getProjectAppFunctionLogs,
|
|
29
|
+
// getLatestProjectAppFunctionLog,
|
|
30
|
+
// } = require('@hubspot/local-dev-lib/api/functions');
|
|
31
31
|
|
|
32
32
|
const { ensureProjectExists } = require('../../lib/projects');
|
|
33
33
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -30,7 +30,7 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
|
30
30
|
|
|
31
31
|
const i18nKey = 'cli.commands.project.subcommands.upload';
|
|
32
32
|
|
|
33
|
-
exports.command = 'upload [path]';
|
|
33
|
+
exports.command = 'upload [path] [--forceCreate] [--message]';
|
|
34
34
|
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
35
35
|
|
|
36
36
|
exports.handler = async options => {
|
|
@@ -49,7 +49,10 @@ exports.handler = async options => {
|
|
|
49
49
|
|
|
50
50
|
await showPlatformVersionWarning(accountId, projectConfig);
|
|
51
51
|
|
|
52
|
-
await ensureProjectExists(accountId, projectConfig.name, {
|
|
52
|
+
await ensureProjectExists(accountId, projectConfig.name, {
|
|
53
|
+
forceCreate,
|
|
54
|
+
uploadCommand: true,
|
|
55
|
+
});
|
|
53
56
|
|
|
54
57
|
try {
|
|
55
58
|
const result = await handleProjectUpload(
|
|
@@ -27,7 +27,8 @@ const {
|
|
|
27
27
|
const {
|
|
28
28
|
cancelStagedBuild,
|
|
29
29
|
fetchProjectBuilds,
|
|
30
|
-
} = require('@hubspot/
|
|
30
|
+
} = require('@hubspot/local-dev-lib/api/projects');
|
|
31
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
31
32
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
32
33
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
33
34
|
const { handleKeypress, handleExit } = require('../../lib/process');
|
|
@@ -64,7 +65,11 @@ const handleUserInput = (accountId, projectName, currentBuildId) => {
|
|
|
64
65
|
await cancelStagedBuild(accountId, projectName);
|
|
65
66
|
process.exit(EXIT_CODES.SUCCESS);
|
|
66
67
|
} catch (err) {
|
|
67
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
isSpecifiedError(err, {
|
|
70
|
+
subCategory: ERROR_TYPES.BUILD_NOT_IN_PROGRESS,
|
|
71
|
+
})
|
|
72
|
+
) {
|
|
68
73
|
process.exit(EXIT_CODES.SUCCESS);
|
|
69
74
|
} else {
|
|
70
75
|
logApiErrorInstance(
|