@hubspot/cli 4.0.2-beta.6 → 4.1.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/commands/accounts/list.js +4 -1
- package/commands/project/watch.js +10 -5
- package/commands/sandbox/create.js +3 -0
- package/commands/sandbox/delete.js +17 -3
- package/commands/secrets/addSecret.js +2 -1
- package/commands/secrets/deleteSecret.js +2 -1
- package/commands/secrets/listSecrets.js +2 -1
- package/commands/secrets/updateSecret.js +3 -1
- package/commands/theme/marketplace-validate.js +97 -59
- package/lib/prompts/accountsPrompt.js +3 -8
- package/lib/prompts/sandboxesPrompt.js +16 -1
- package/lib/validators/__tests__/validatorTestUtils.js +0 -28
- package/lib/validators/applyValidators.js +1 -17
- package/lib/validators/constants.js +0 -5
- package/lib/validators/index.js +0 -13
- package/package.json +4 -4
- package/lib/validators/__tests__/AbsoluteValidator.js +0 -28
- package/lib/validators/__tests__/TemplateValidator.js +0 -101
- package/lib/validators/__tests__/ThemeConfigValidator.js +0 -70
- package/lib/validators/__tests__/ThemeDependencyValidator.js +0 -89
- package/lib/validators/__tests__/ThemeModuleValidator.js +0 -84
- package/lib/validators/marketplaceValidators/AbsoluteValidator.js +0 -50
- package/lib/validators/marketplaceValidators/theme/SectionValidator.js +0 -96
- package/lib/validators/marketplaceValidators/theme/TemplateValidator.js +0 -175
- package/lib/validators/marketplaceValidators/theme/ThemeConfigValidator.js +0 -106
- package/lib/validators/marketplaceValidators/theme/ThemeDependencyValidator.js +0 -126
- package/lib/validators/marketplaceValidators/theme/ThemeModuleValidator.js +0 -117
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
} = require('../../lib/commonOpts');
|
|
13
13
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
14
14
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
|
+
const { getSandboxType } = require('../../lib/prompts/sandboxesPrompt');
|
|
15
16
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
16
17
|
|
|
17
18
|
const i18nKey = 'cli.commands.accounts.subcommands.list';
|
|
@@ -57,7 +58,9 @@ const getPortalData = mappedPortalData => {
|
|
|
57
58
|
portalData.push([portal.name, portal.portalId, portal.authType]);
|
|
58
59
|
} else {
|
|
59
60
|
portalData.push([
|
|
60
|
-
`↳ ${portal.name} [
|
|
61
|
+
`↳ ${portal.name} [${getSandboxType(
|
|
62
|
+
portal.sandboxAccountType
|
|
63
|
+
)} sandbox]`,
|
|
61
64
|
portal.portalId,
|
|
62
65
|
portal.authType,
|
|
63
66
|
]);
|
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
ApiErrorContext,
|
|
6
6
|
} = require('@hubspot/cli-lib/errorHandlers');
|
|
7
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
8
|
+
const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
8
9
|
const {
|
|
9
10
|
addAccountOptions,
|
|
10
11
|
addConfigOptions,
|
|
@@ -61,11 +62,15 @@ const handleUserInput = (accountId, projectName, currentBuildId) => {
|
|
|
61
62
|
await cancelStagedBuild(accountId, projectName);
|
|
62
63
|
process.exit(EXIT_CODES.SUCCESS);
|
|
63
64
|
} catch (err) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
if (err.error.subCategory === ERROR_TYPES.BUILD_NOT_IN_PROGRESS) {
|
|
66
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
67
|
+
} else {
|
|
68
|
+
logApiErrorInstance(
|
|
69
|
+
err,
|
|
70
|
+
new ApiErrorContext({ accountId, projectName: projectName })
|
|
71
|
+
);
|
|
72
|
+
process.exit(EXIT_CODES.ERROR);
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
} else {
|
|
71
76
|
process.exit(EXIT_CODES.SUCCESS);
|
|
@@ -49,6 +49,9 @@ exports.handler = async options => {
|
|
|
49
49
|
account: account || accountPrompt.account,
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
const isDefaultAccount =
|
|
53
|
+
sandboxAccountId === getAccountId(config.defaultPortal);
|
|
54
|
+
|
|
52
55
|
trackCommandUsage('sandbox-delete', null, sandboxAccountId);
|
|
53
56
|
|
|
54
57
|
let parentAccountId;
|
|
@@ -91,6 +94,14 @@ exports.handler = async options => {
|
|
|
91
94
|
})
|
|
92
95
|
);
|
|
93
96
|
|
|
97
|
+
if (isDefaultAccount) {
|
|
98
|
+
logger.log(
|
|
99
|
+
i18n(`${i18nKey}.defaultAccountWarning`, {
|
|
100
|
+
account: account || accountPrompt.account,
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
94
105
|
try {
|
|
95
106
|
const { confirmSandboxDeletePrompt: confirmed } = await promptUser([
|
|
96
107
|
{
|
|
@@ -107,9 +118,12 @@ exports.handler = async options => {
|
|
|
107
118
|
|
|
108
119
|
await deleteSandbox(parentAccountId, sandboxAccountId);
|
|
109
120
|
|
|
121
|
+
const deleteKey = isDefaultAccount
|
|
122
|
+
? `${i18nKey}.success.deleteDefault`
|
|
123
|
+
: `${i18nKey}.success.delete`;
|
|
110
124
|
logger.log('');
|
|
111
125
|
logger.success(
|
|
112
|
-
i18n(
|
|
126
|
+
i18n(deleteKey, {
|
|
113
127
|
account: account || accountPrompt.account,
|
|
114
128
|
sandboxHubId: sandboxAccountId,
|
|
115
129
|
})
|
|
@@ -120,7 +134,7 @@ exports.handler = async options => {
|
|
|
120
134
|
sandboxAccountId
|
|
121
135
|
);
|
|
122
136
|
if (promptDefaultAccount) {
|
|
123
|
-
await selectAndSetAsDefaultAccountPrompt(
|
|
137
|
+
await selectAndSetAsDefaultAccountPrompt(getConfig());
|
|
124
138
|
}
|
|
125
139
|
process.exit(EXIT_CODES.SUCCESS);
|
|
126
140
|
} catch (err) {
|
|
@@ -149,7 +163,7 @@ exports.handler = async options => {
|
|
|
149
163
|
sandboxAccountId
|
|
150
164
|
);
|
|
151
165
|
if (promptDefaultAccount) {
|
|
152
|
-
await selectAndSetAsDefaultAccountPrompt(
|
|
166
|
+
await selectAndSetAsDefaultAccountPrompt(getConfig());
|
|
153
167
|
}
|
|
154
168
|
process.exit(EXIT_CODES.SUCCESS);
|
|
155
169
|
} else {
|
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
addUseEnvironmentOptions,
|
|
15
15
|
getAccountId,
|
|
16
16
|
} = require('../../lib/commonOpts');
|
|
17
|
+
const { uiAccountDescription } = require('../../lib/ui');
|
|
17
18
|
const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
|
|
18
19
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
19
20
|
|
|
@@ -36,7 +37,7 @@ exports.handler = async options => {
|
|
|
36
37
|
await addSecret(accountId, secretName, secretValue);
|
|
37
38
|
logger.success(
|
|
38
39
|
i18n(`${i18nKey}.success.add`, {
|
|
39
|
-
accountId,
|
|
40
|
+
accountIdentifier: uiAccountDescription(accountId),
|
|
40
41
|
secretName,
|
|
41
42
|
})
|
|
42
43
|
);
|
|
@@ -7,6 +7,7 @@ const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
+
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
addConfigOptions,
|
|
@@ -33,7 +34,7 @@ exports.handler = async options => {
|
|
|
33
34
|
await deleteSecret(accountId, secretName);
|
|
34
35
|
logger.success(
|
|
35
36
|
i18n(`${i18nKey}.success.delete`, {
|
|
36
|
-
accountId,
|
|
37
|
+
accountIdentifier: uiAccountDescription(accountId),
|
|
37
38
|
secretName,
|
|
38
39
|
})
|
|
39
40
|
);
|
|
@@ -7,6 +7,7 @@ const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
|
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
+
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
addConfigOptions,
|
|
@@ -30,7 +31,7 @@ exports.handler = async options => {
|
|
|
30
31
|
try {
|
|
31
32
|
const { results } = await fetchSecrets(accountId);
|
|
32
33
|
const groupLabel = i18n(`${i18nKey}.groupLabel`, {
|
|
33
|
-
accountId,
|
|
34
|
+
accountIdentifier: uiAccountDescription(accountId),
|
|
34
35
|
});
|
|
35
36
|
logger.group(groupLabel);
|
|
36
37
|
results.forEach(secret => logger.log(secret));
|
|
@@ -7,6 +7,7 @@ const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
+
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
11
|
|
|
11
12
|
const {
|
|
12
13
|
addConfigOptions,
|
|
@@ -36,10 +37,11 @@ exports.handler = async options => {
|
|
|
36
37
|
await updateSecret(accountId, secretName, secretValue);
|
|
37
38
|
logger.success(
|
|
38
39
|
i18n(`${i18nKey}.success.update`, {
|
|
39
|
-
accountId,
|
|
40
|
+
accountIdentifier: uiAccountDescription(accountId),
|
|
40
41
|
secretName,
|
|
41
42
|
})
|
|
42
43
|
);
|
|
44
|
+
logger.log(i18n(`${i18nKey}.success.updateReupload`));
|
|
43
45
|
} catch (e) {
|
|
44
46
|
logger.error(
|
|
45
47
|
i18n(`${i18nKey}.errors.update`, {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const Spinnies = require('spinnies');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
3
|
|
|
4
|
-
const { getCwd } = require('@hubspot/cli-lib/path');
|
|
5
4
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
6
|
-
const { walk } = require('@hubspot/cli-lib');
|
|
7
5
|
|
|
8
6
|
const {
|
|
9
7
|
addConfigOptions,
|
|
@@ -14,17 +12,16 @@ const {
|
|
|
14
12
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
13
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
16
14
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const MARKETPLACE_VALIDATORS = require('../../lib/validators');
|
|
23
|
-
const { VALIDATION_RESULT } = require('../../lib/validators/constants');
|
|
15
|
+
requestValidation,
|
|
16
|
+
getValidationStatus,
|
|
17
|
+
getValidationResults,
|
|
18
|
+
} = require('@hubspot/cli-lib/api/marketplaceValidation');
|
|
19
|
+
|
|
24
20
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
25
21
|
|
|
26
22
|
const i18nKey = 'cli.commands.theme.subcommands.marketplaceValidate';
|
|
27
23
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
24
|
+
const SLEEP_TIME = 2000;
|
|
28
25
|
|
|
29
26
|
exports.command = 'marketplace-validate <src>';
|
|
30
27
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -35,54 +32,101 @@ exports.handler = async options => {
|
|
|
35
32
|
await loadAndValidateOptions(options);
|
|
36
33
|
|
|
37
34
|
const accountId = getAccountId(options);
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
|
|
36
|
+
trackCommandUsage('validate', null, accountId);
|
|
37
|
+
|
|
38
|
+
const spinnies = new Spinnies();
|
|
39
|
+
|
|
40
|
+
spinnies.add('marketplaceValidation', {
|
|
41
|
+
text: i18n(`${i18nKey}.logs.validatingTheme`, {
|
|
42
|
+
path: src,
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Kick off validation
|
|
47
|
+
let requestResult;
|
|
48
|
+
const assetType = 'THEME';
|
|
49
|
+
const requestGroup = 'EXTERNAL_DEVELOPER';
|
|
40
50
|
try {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
requestResult = await requestValidation(accountId, {
|
|
52
|
+
path: src,
|
|
53
|
+
assetType,
|
|
54
|
+
requestGroup,
|
|
55
|
+
});
|
|
56
|
+
} catch (err) {
|
|
57
|
+
logger.debug(err);
|
|
58
|
+
process.exit(EXIT_CODES.ERROR);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Poll till validation is finished
|
|
62
|
+
try {
|
|
63
|
+
const checkValidationStatus = async () => {
|
|
64
|
+
const validationStatus = await getValidationStatus(accountId, {
|
|
65
|
+
validationId: requestResult,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (validationStatus === 'REQUESTED') {
|
|
69
|
+
await new Promise(resolve => setTimeout(resolve, SLEEP_TIME));
|
|
70
|
+
await checkValidationStatus();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
await checkValidationStatus();
|
|
75
|
+
|
|
76
|
+
spinnies.remove('marketplaceValidation');
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.debug(err);
|
|
79
|
+
process.exit(EXIT_CODES.ERROR);
|
|
57
80
|
}
|
|
58
81
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
82
|
+
// Fetch the validation results
|
|
83
|
+
let validationResults;
|
|
84
|
+
try {
|
|
85
|
+
validationResults = await getValidationResults(accountId, {
|
|
86
|
+
validationId: requestResult,
|
|
87
|
+
});
|
|
88
|
+
} catch (err) {
|
|
89
|
+
logger.debug(err);
|
|
90
|
+
process.exit(EXIT_CODES.ERROR);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (validationResults.errors.length) {
|
|
94
|
+
const { errors } = validationResults;
|
|
95
|
+
|
|
96
|
+
errors.forEach(err => {
|
|
97
|
+
logger.error(`${err.context}`);
|
|
98
|
+
});
|
|
99
|
+
process.exit(EXIT_CODES.ERROR);
|
|
65
100
|
}
|
|
66
|
-
trackCommandUsage('validate', null, accountId);
|
|
67
101
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
102
|
+
const displayResults = checks => {
|
|
103
|
+
if (checks) {
|
|
104
|
+
const { status, results } = checks;
|
|
105
|
+
|
|
106
|
+
if (status === 'FAIL') {
|
|
107
|
+
const failedValidations = results.filter(
|
|
108
|
+
test => test.status === 'FAIL'
|
|
109
|
+
);
|
|
110
|
+
failedValidations.forEach(val => {
|
|
111
|
+
logger.error(`${val.message}`);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (status === 'PASS') {
|
|
116
|
+
logger.success(i18n(`${i18nKey}.results.noErrors`));
|
|
117
|
+
}
|
|
84
118
|
}
|
|
85
|
-
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
logger.log(chalk.bold(i18n(`${i18nKey}.results.required`)));
|
|
123
|
+
displayResults(validationResults.results['REQUIRED']);
|
|
124
|
+
logger.log();
|
|
125
|
+
logger.log(chalk.bold(i18n(`${i18nKey}.results.recommended`)));
|
|
126
|
+
displayResults(validationResults.results['RECOMMENDED']);
|
|
127
|
+
logger.log();
|
|
128
|
+
|
|
129
|
+
process.exit();
|
|
86
130
|
};
|
|
87
131
|
|
|
88
132
|
exports.builder = yargs => {
|
|
@@ -90,12 +134,6 @@ exports.builder = yargs => {
|
|
|
90
134
|
addAccountOptions(yargs, true);
|
|
91
135
|
addUseEnvironmentOptions(yargs, true);
|
|
92
136
|
|
|
93
|
-
yargs.options({
|
|
94
|
-
json: {
|
|
95
|
-
describe: i18n(`${i18nKey}.options.json.describe`),
|
|
96
|
-
type: 'boolean',
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
137
|
yargs.positional('src', {
|
|
100
138
|
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
101
139
|
type: 'string',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { updateDefaultAccount } = require('@hubspot/cli-lib/lib/config');
|
|
2
2
|
const { promptUser } = require('./promptUtils');
|
|
3
3
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
4
|
+
const { mapAccountChoices } = require('./sandboxesPrompt');
|
|
4
5
|
|
|
5
6
|
const i18nKey = 'cli.commands.accounts.subcommands.use';
|
|
6
7
|
|
|
@@ -12,10 +13,7 @@ const selectAccountFromConfig = async config => {
|
|
|
12
13
|
name: 'default',
|
|
13
14
|
pageSize: 20,
|
|
14
15
|
message: i18n(`${i18nKey}.promptMessage`),
|
|
15
|
-
choices: config.portals
|
|
16
|
-
name: `${p.name} (${p.portalId})`,
|
|
17
|
-
value: p.name || p.portalId,
|
|
18
|
-
})),
|
|
16
|
+
choices: mapAccountChoices(config.portals),
|
|
19
17
|
default: config.defaultPortal,
|
|
20
18
|
},
|
|
21
19
|
]);
|
|
@@ -31,10 +29,7 @@ const selectAndSetAsDefaultAccountPrompt = async config => {
|
|
|
31
29
|
name: 'default',
|
|
32
30
|
pageSize: 20,
|
|
33
31
|
message: i18n(`${i18nKey}.promptMessage`),
|
|
34
|
-
choices: config.portals
|
|
35
|
-
name: `${p.name} (${p.portalId})`,
|
|
36
|
-
value: p.name || p.portalId,
|
|
37
|
-
})),
|
|
32
|
+
choices: mapAccountChoices(config.portals),
|
|
38
33
|
default: config.defaultPortal,
|
|
39
34
|
},
|
|
40
35
|
]);
|
|
@@ -3,6 +3,19 @@ const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
|
3
3
|
|
|
4
4
|
const i18nKey = 'cli.lib.prompts.sandboxesPrompt';
|
|
5
5
|
|
|
6
|
+
const getSandboxType = type =>
|
|
7
|
+
type === 'DEVELOPER' ? 'development' : 'standard';
|
|
8
|
+
|
|
9
|
+
const mapAccountChoices = portals =>
|
|
10
|
+
portals.map(p => {
|
|
11
|
+
const isSandbox = p.sandboxAccountType !== null;
|
|
12
|
+
const sandboxName = `[${getSandboxType(p.sandboxAccountType)} sandbox] `;
|
|
13
|
+
return {
|
|
14
|
+
name: `${p.name} ${isSandbox ? sandboxName : ''}(${p.portalId})`,
|
|
15
|
+
value: p.name || p.portalId,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
6
19
|
const createSandboxPrompt = () => {
|
|
7
20
|
return promptUser([
|
|
8
21
|
{
|
|
@@ -31,7 +44,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
|
|
|
31
44
|
type: 'list',
|
|
32
45
|
look: false,
|
|
33
46
|
pageSize: 20,
|
|
34
|
-
choices: config.portals
|
|
47
|
+
choices: mapAccountChoices(config.portals),
|
|
35
48
|
default: config.defaultPortal,
|
|
36
49
|
},
|
|
37
50
|
]);
|
|
@@ -40,4 +53,6 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
|
|
|
40
53
|
module.exports = {
|
|
41
54
|
createSandboxPrompt,
|
|
42
55
|
deleteSandboxPrompt,
|
|
56
|
+
getSandboxType,
|
|
57
|
+
mapAccountChoices,
|
|
43
58
|
};
|
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
//HACK so we can keep this util file next to the tests that use it
|
|
2
2
|
test.skip('skip', () => null);
|
|
3
3
|
|
|
4
|
-
const THEME_PATH = '/path/to/a/theme';
|
|
5
4
|
const MODULE_PATH = 'module/path';
|
|
6
5
|
|
|
7
|
-
const makeFindError = baseKey => (errors, errorKey) =>
|
|
8
|
-
errors.find(error => error.key === `${baseKey}.${errorKey}`);
|
|
9
|
-
|
|
10
|
-
const generateModulesList = numFiles => {
|
|
11
|
-
const files = [];
|
|
12
|
-
for (let i = 0; i < numFiles; i++) {
|
|
13
|
-
const base = `module-${i}.module`;
|
|
14
|
-
files.push(`${base}/meta.json`);
|
|
15
|
-
files.push(`${base}/fields.json`);
|
|
16
|
-
files.push(`${base}/module.html`);
|
|
17
|
-
files.push(`${base}/module.js`);
|
|
18
|
-
}
|
|
19
|
-
return files;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const generateTemplatesList = numFiles => {
|
|
23
|
-
const files = [];
|
|
24
|
-
for (let i = 0; i < numFiles; i++) {
|
|
25
|
-
files.push(`template-${i}.html`);
|
|
26
|
-
}
|
|
27
|
-
return files;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
6
|
module.exports = {
|
|
31
|
-
generateModulesList,
|
|
32
|
-
generateTemplatesList,
|
|
33
|
-
makeFindError,
|
|
34
|
-
THEME_PATH,
|
|
35
7
|
MODULE_PATH,
|
|
36
8
|
};
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
async function applyAbsoluteValidators(validators, absolutePath, ...args) {
|
|
2
|
-
return Promise.all(
|
|
3
|
-
validators.map(async Validator => {
|
|
4
|
-
Validator.setAbsolutePath(absolutePath);
|
|
5
|
-
const validationResult = await Validator.validate(...args);
|
|
6
|
-
Validator.clearAbsolutePath();
|
|
7
|
-
|
|
8
|
-
if (!validationResult.length) {
|
|
9
|
-
// Return a success obj so we can log the successes
|
|
10
|
-
return [Validator.getSuccess()];
|
|
11
|
-
}
|
|
12
|
-
return validationResult;
|
|
13
|
-
})
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
1
|
async function applyRelativeValidators(validators, relativePath, ...args) {
|
|
18
2
|
return Promise.all(
|
|
19
3
|
validators.map(async Validator => {
|
|
@@ -30,4 +14,4 @@ async function applyRelativeValidators(validators, relativePath, ...args) {
|
|
|
30
14
|
);
|
|
31
15
|
}
|
|
32
16
|
|
|
33
|
-
module.exports = {
|
|
17
|
+
module.exports = { applyRelativeValidators };
|
|
@@ -4,11 +4,6 @@ const SUCCESS = 'SUCCESS';
|
|
|
4
4
|
|
|
5
5
|
const VALIDATION_RESULT = { WARNING, FATAL, SUCCESS };
|
|
6
6
|
const VALIDATOR_KEYS = {
|
|
7
|
-
themeDependency: 'themeDependency',
|
|
8
|
-
themeModule: 'themeModule',
|
|
9
|
-
section: 'section',
|
|
10
|
-
template: 'template',
|
|
11
|
-
themeConfig: 'themeConfig',
|
|
12
7
|
module: 'module',
|
|
13
8
|
moduleDependency: 'moduleDependency',
|
|
14
9
|
};
|
package/lib/validators/index.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
const ThemeConfigValidator = require('./marketplaceValidators/theme/ThemeConfigValidator');
|
|
2
|
-
const SectionValidator = require('./marketplaceValidators/theme/SectionValidator');
|
|
3
|
-
const TemplateValidator = require('./marketplaceValidators/theme/TemplateValidator');
|
|
4
|
-
const ThemeModuleValidator = require('./marketplaceValidators/theme/ThemeModuleValidator');
|
|
5
|
-
const ThemeDependencyValidator = require('./marketplaceValidators/theme/ThemeDependencyValidator');
|
|
6
|
-
|
|
7
1
|
const ModuleValidator = require('./marketplaceValidators/module/ModuleValidator');
|
|
8
2
|
const ModuleDependencyValidator = require('./marketplaceValidators/module/ModuleDependencyValidator');
|
|
9
3
|
|
|
10
4
|
const MARKETPLACE_VALIDATORS = {
|
|
11
|
-
theme: [
|
|
12
|
-
ThemeConfigValidator,
|
|
13
|
-
SectionValidator,
|
|
14
|
-
TemplateValidator,
|
|
15
|
-
ThemeModuleValidator,
|
|
16
|
-
ThemeDependencyValidator,
|
|
17
|
-
],
|
|
18
5
|
module: [ModuleValidator, ModuleDependencyValidator],
|
|
19
6
|
};
|
|
20
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "CLI for working with HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"url": "https://github.com/HubSpot/hubspot-cms-tools"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@hubspot/cli-lib": "4.0
|
|
12
|
-
"@hubspot/serverless-dev-runtime": "4.0
|
|
11
|
+
"@hubspot/cli-lib": "4.1.0",
|
|
12
|
+
"@hubspot/serverless-dev-runtime": "4.1.0",
|
|
13
13
|
"archiver": "^5.3.0",
|
|
14
14
|
"chalk": "^4.1.2",
|
|
15
15
|
"express": "^4.17.1",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "642e8486f6dad6d91b1e5854fc427239ca4d11bb"
|
|
41
41
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const AbsoluteValidator = require('../marketplaceValidators/AbsoluteValidator');
|
|
2
|
-
const { VALIDATION_RESULT } = require('../constants');
|
|
3
|
-
|
|
4
|
-
const Validator = new AbsoluteValidator({
|
|
5
|
-
name: 'Test validator',
|
|
6
|
-
key: 'validatorKey',
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
describe('validators/marketplaceValidators/AbsoluteValidator', () => {
|
|
10
|
-
it('getSuccess returns expected object', async () => {
|
|
11
|
-
const success = Validator.getSuccess();
|
|
12
|
-
|
|
13
|
-
expect(success.validatorKey).toBe('validatorKey');
|
|
14
|
-
expect(success.validatorName).toBe('Test validator');
|
|
15
|
-
expect(success.result).toBe(VALIDATION_RESULT.SUCCESS);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('getError returns expected object', async () => {
|
|
19
|
-
const errorObj = { key: 'errorkey', getCopy: () => 'Some error copy' };
|
|
20
|
-
const success = Validator.getError(errorObj);
|
|
21
|
-
|
|
22
|
-
expect(success.validatorKey).toBe('validatorKey');
|
|
23
|
-
expect(success.validatorName).toBe('Test validator');
|
|
24
|
-
expect(success.error).toBe('Some error copy');
|
|
25
|
-
expect(success.result).toBe(VALIDATION_RESULT.FATAL);
|
|
26
|
-
expect(success.key).toBe('validatorKey.errorkey');
|
|
27
|
-
});
|
|
28
|
-
});
|