@hubspot/cli 5.0.2-beta.1 → 5.0.3-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/bin/cli.js +1 -1
- package/commands/accounts/clean.js +2 -3
- package/commands/accounts/info.js +1 -1
- package/commands/accounts/list.js +1 -1
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +1 -1
- package/commands/auth.js +4 -3
- package/commands/cms/convertFields.js +1 -1
- package/commands/config/set/allowUsageTracking.js +1 -1
- package/commands/config/set/defaultMode.js +2 -2
- package/commands/config/set/httpTimeout.js +1 -1
- package/commands/create.js +1 -1
- package/commands/customObject/create.js +1 -1
- package/commands/customObject/schema/create.js +7 -2
- package/commands/customObject/schema/delete.js +3 -1
- package/commands/customObject/schema/fetch-all.js +3 -1
- package/commands/customObject/schema/fetch.js +4 -2
- package/commands/customObject/schema/list.js +3 -1
- package/commands/customObject/schema/update.js +7 -2
- package/commands/filemanager/upload.js +3 -3
- package/commands/functions/deploy.js +1 -1
- package/commands/functions/list.js +1 -1
- package/commands/hubdb/clear.js +1 -1
- package/commands/hubdb/create.js +1 -1
- package/commands/hubdb/delete.js +1 -1
- package/commands/hubdb/fetch.js +1 -1
- package/commands/init.js +2 -2
- package/commands/lint.js +2 -2
- package/commands/list.js +1 -1
- package/commands/mv.js +1 -1
- package/commands/project/add.js +2 -2
- package/commands/project/create.js +1 -0
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev.js +15 -10
- package/commands/project/download.js +1 -1
- package/commands/project/listBuilds.js +1 -1
- package/commands/project/logs.js +2 -2
- package/commands/project/upload.js +3 -5
- package/commands/project/watch.js +1 -1
- package/commands/remove.js +1 -1
- package/commands/sandbox/create.js +4 -6
- package/commands/sandbox/delete.js +12 -9
- package/commands/sandbox/sync.js +4 -8
- package/commands/secrets/addSecret.js +1 -1
- package/commands/secrets/deleteSecret.js +1 -1
- package/commands/secrets/listSecrets.js +1 -1
- package/commands/secrets/updateSecret.js +1 -1
- package/commands/upload.js +3 -3
- package/lang/en.lyaml +39 -0
- package/lib/DevServerManager.js +14 -0
- package/lib/LocalDevManager.js +17 -12
- package/lib/__tests__/commonOpts.js +3 -3
- package/lib/__tests__/projects.test.js +144 -0
- package/lib/__tests__/validation.js +2 -1
- package/lib/commonOpts.js +2 -3
- package/lib/errorHandlers/apiErrors.js +352 -0
- package/lib/errorHandlers/fileSystemErrors.js +55 -0
- package/lib/errorHandlers/standardErrors.js +95 -0
- package/lib/links.js +1 -1
- package/lib/oauth.js +1 -1
- package/lib/process.js +24 -6
- package/lib/projects.js +24 -11
- package/lib/projectsWatch.js +2 -2
- package/lib/prompts/accountsPrompt.js +1 -1
- package/lib/prompts/downloadProjectPrompt.js +2 -2
- package/lib/prompts/enterAccountNamePrompt.js +1 -1
- package/lib/prompts/personalAccessKeyPrompt.js +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +1 -1
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/prompts/sandboxesPrompt.js +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -1
- package/lib/sandbox-create.js +4 -4
- package/lib/sandbox-sync.js +6 -6
- package/lib/sandboxes.js +7 -7
- package/lib/serverlessLogs.js +1 -1
- package/lib/ui.js +2 -1
- package/lib/upload.js +1 -1
- package/lib/usageTracking.js +4 -2
- package/lib/validation.js +9 -10
- package/package.json +5 -4
package/commands/sandbox/sync.js
CHANGED
|
@@ -10,7 +10,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
13
|
-
const { getAccountConfig, getEnv } = require('@hubspot/
|
|
13
|
+
const { getAccountConfig, getEnv } = require('@hubspot/local-dev-lib/config');
|
|
14
14
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
15
15
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
16
16
|
const { uiLine } = require('../../lib/ui');
|
|
@@ -23,13 +23,9 @@ const {
|
|
|
23
23
|
getSyncTypesWithContactRecordsPrompt,
|
|
24
24
|
} = require('../../lib/sandboxes');
|
|
25
25
|
const { syncSandbox } = require('../../lib/sandbox-sync');
|
|
26
|
-
const { getValidEnv } = require('@hubspot/
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
} = require('@hubspot/cli-lib/errorHandlers/apiErrors');
|
|
30
|
-
const {
|
|
31
|
-
logErrorInstance,
|
|
32
|
-
} = require('@hubspot/cli-lib/errorHandlers/standardErrors');
|
|
26
|
+
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
27
|
+
const { isSpecifiedError } = require('../../lib/errorHandlers/apiErrors');
|
|
28
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
33
29
|
|
|
34
30
|
const i18nKey = 'cli.commands.sandbox.subcommands.sync';
|
|
35
31
|
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { addSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
package/commands/upload.js
CHANGED
|
@@ -10,12 +10,12 @@ const {
|
|
|
10
10
|
} = require('@hubspot/cli-lib/path');
|
|
11
11
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
12
12
|
const {
|
|
13
|
-
logErrorInstance,
|
|
14
13
|
ApiErrorContext,
|
|
15
14
|
logApiUploadErrorInstance,
|
|
16
|
-
} = require('
|
|
15
|
+
} = require('../lib/errorHandlers/apiErrors');
|
|
16
|
+
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
17
17
|
const { validateSrcAndDestPaths } = require('@hubspot/cli-lib/modules');
|
|
18
|
-
const { shouldIgnoreFile } = require('@hubspot/
|
|
18
|
+
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
21
|
addConfigOptions,
|
package/lang/en.lyaml
CHANGED
|
@@ -885,6 +885,8 @@ en:
|
|
|
885
885
|
options:
|
|
886
886
|
describe: "Options to pass to javascript fields files"
|
|
887
887
|
lib:
|
|
888
|
+
process:
|
|
889
|
+
exitDebug: "Attempting to gracefully exit. Triggered by {{ signal }}"
|
|
888
890
|
DevServerManager:
|
|
889
891
|
portConflict: "The port {{ port }} is already in use."
|
|
890
892
|
notInitialized: "The Dev Server Manager must be initialized before it is started."
|
|
@@ -917,6 +919,8 @@ en:
|
|
|
917
919
|
startError: "Failed to start local dev server: {{ message }}"
|
|
918
920
|
fileChangeError: "Failed to notify local dev server of file change: {{ message }}"
|
|
919
921
|
projects:
|
|
922
|
+
config:
|
|
923
|
+
srcOutsideProjectDir: "Invalid value for 'srcDir' in {{ projectConfig }}: {{#bold}}srcDir: \"{{ srcDir }}\"{{/bold}}\n\t'srcDir' must be a relative path to a folder under the project root, such as \".\" or \"./src\""
|
|
920
924
|
uploadProjectFiles:
|
|
921
925
|
add: "Uploading {{#bold}}{{ projectName }}{{/bold}} project files to {{ accountIdentifier }}"
|
|
922
926
|
fail: "Failed to upload {{#bold}}{{ projectName }}{{/bold}} project files to {{ accountIdentifier }}"
|
|
@@ -994,6 +998,10 @@ en:
|
|
|
994
998
|
sandboxSyncStandardCommand:
|
|
995
999
|
command: "hs sandbox sync"
|
|
996
1000
|
message: "Run {{ command }} to to update all supported assets to your sandbox from production"
|
|
1001
|
+
sampleProjects:
|
|
1002
|
+
linkText: "HubSpot's sample projects"
|
|
1003
|
+
url: "https://developers.hubspot.com/docs/platform/sample-projects?utm_source=cli&utm_content=project_create_whats_next"
|
|
1004
|
+
message: "See {{ link }}"
|
|
997
1005
|
commonOpts:
|
|
998
1006
|
options:
|
|
999
1007
|
portal:
|
|
@@ -1259,6 +1267,37 @@ en:
|
|
|
1259
1267
|
label: "Lead Flows"
|
|
1260
1268
|
marketing-email:
|
|
1261
1269
|
label: "Marketing emails"
|
|
1270
|
+
errorHandlers:
|
|
1271
|
+
standardErrors:
|
|
1272
|
+
errorOccurred: "Error: {{ error }}"
|
|
1273
|
+
errorContext: "Context: {{ context }}"
|
|
1274
|
+
systemErrorOccurred: "A system error has occurred: {{ errorMessage }}"
|
|
1275
|
+
genericErrorOccurred: "A {{ name }} has occurred."
|
|
1276
|
+
unknownErrorOccurred: "An unknown error has occurred"
|
|
1277
|
+
fileSystemErrors:
|
|
1278
|
+
errorOccurred: "An error occurred while {{ fileAction }} {{ filepath }}."
|
|
1279
|
+
errorExplanation: "This is the result of a system error: {{ errorMessage }}"
|
|
1280
|
+
apiErrors:
|
|
1281
|
+
messageDetail: "{{ request }} in account {{ accountId }}"
|
|
1282
|
+
unableToUpload: 'Unable to upload "{{ payload }}.'
|
|
1283
|
+
codes:
|
|
1284
|
+
400: "The {{ messageDetail }} was bad."
|
|
1285
|
+
401: "The {{ messageDetail }} was unauthorized."
|
|
1286
|
+
403MissingScope: "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key."
|
|
1287
|
+
403Gating: "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216."
|
|
1288
|
+
403: "The {{ messageDetail }} was forbidden."
|
|
1289
|
+
404Request: 'The {{ action }} failed because "{{ request }}" was not found in account {{ accountId }}.'
|
|
1290
|
+
404: "The {{ messageDetail }} was not found."
|
|
1291
|
+
429: "The {{ messageDetail }} surpassed the rate limit. Retry in one minute."
|
|
1292
|
+
503: "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
1293
|
+
500generic: "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
1294
|
+
400generic: "The {{ messageDetail }} failed due to a client error."
|
|
1295
|
+
generic: "The {{ messageDetail }} failed."
|
|
1296
|
+
verifyAccessKeyAndUserAccess:
|
|
1297
|
+
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}: {{ error }}"
|
|
1298
|
+
portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
|
|
1299
|
+
userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
|
|
1300
|
+
genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
|
|
1262
1301
|
|
|
1263
1302
|
|
|
1264
1303
|
|
package/lib/DevServerManager.js
CHANGED
|
@@ -4,6 +4,12 @@ const { COMPONENT_TYPES } = require('./projectStructure');
|
|
|
4
4
|
const { i18n } = require('./lang');
|
|
5
5
|
const { promptUser } = require('./prompts/promptUtils');
|
|
6
6
|
const { DevModeInterface } = require('@hubspot/ui-extensions-dev-server');
|
|
7
|
+
const {
|
|
8
|
+
startPortManagerServer,
|
|
9
|
+
portManagerHasActiveServers,
|
|
10
|
+
stopPortManagerServer,
|
|
11
|
+
requestPorts,
|
|
12
|
+
} = require('@hubspot/local-dev-lib/portManager');
|
|
7
13
|
|
|
8
14
|
const i18nKey = 'cli.lib.DevServerManager';
|
|
9
15
|
|
|
@@ -61,6 +67,7 @@ class DevServerManager {
|
|
|
61
67
|
this.debug = debug;
|
|
62
68
|
this.componentsByType = this.arrangeComponentsByType(components);
|
|
63
69
|
|
|
70
|
+
await startPortManagerServer();
|
|
64
71
|
await this.iterateDevServers(
|
|
65
72
|
async (serverInterface, compatibleComponents) => {
|
|
66
73
|
if (serverInterface.setup) {
|
|
@@ -86,6 +93,7 @@ class DevServerManager {
|
|
|
86
93
|
debug: this.debug,
|
|
87
94
|
httpClient,
|
|
88
95
|
projectConfig,
|
|
96
|
+
requestPorts,
|
|
89
97
|
});
|
|
90
98
|
}
|
|
91
99
|
});
|
|
@@ -113,6 +121,12 @@ class DevServerManager {
|
|
|
113
121
|
await serverInterface.cleanup();
|
|
114
122
|
}
|
|
115
123
|
});
|
|
124
|
+
|
|
125
|
+
const hasActiveServers = await portManagerHasActiveServers();
|
|
126
|
+
|
|
127
|
+
if (!hasActiveServers) {
|
|
128
|
+
await stopPortManagerServer();
|
|
129
|
+
}
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
132
|
}
|
package/lib/LocalDevManager.js
CHANGED
|
@@ -7,7 +7,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
7
7
|
const {
|
|
8
8
|
getAccountId,
|
|
9
9
|
getConfigDefaultAccount,
|
|
10
|
-
} = require('@hubspot/
|
|
10
|
+
} = require('@hubspot/local-dev-lib/config');
|
|
11
11
|
const { PROJECT_CONFIG_FILE } = require('@hubspot/cli-lib/lib/constants');
|
|
12
12
|
const SpinniesManager = require('./SpinniesManager');
|
|
13
13
|
const DevServerManager = require('./DevServerManager');
|
|
@@ -141,25 +141,30 @@ class LocalDevManager {
|
|
|
141
141
|
this.compareLocalProjectToDeployed(runnableComponents);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
async stop() {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
async stop(showProgress = true) {
|
|
145
|
+
if (showProgress) {
|
|
146
|
+
SpinniesManager.add('cleanupMessage', {
|
|
147
|
+
text: i18n(`${i18nKey}.exitingStart`),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
149
150
|
await this.stopWatching();
|
|
150
151
|
|
|
151
152
|
const cleanupSucceeded = await this.devServerCleanup();
|
|
152
153
|
|
|
153
154
|
if (!cleanupSucceeded) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
if (showProgress) {
|
|
156
|
+
SpinniesManager.fail('cleanupMessage', {
|
|
157
|
+
text: i18n(`${i18nKey}.exitingFail`),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
157
160
|
process.exit(EXIT_CODES.ERROR);
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
if (showProgress) {
|
|
164
|
+
SpinniesManager.succeed('cleanupMessage', {
|
|
165
|
+
text: i18n(`${i18nKey}.exitingSucceed`),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
163
168
|
process.exit(EXIT_CODES.SUCCESS);
|
|
164
169
|
}
|
|
165
170
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
const { Mode, DEFAULT_MODE } = require('@hubspot/cli-lib');
|
|
1
2
|
const {
|
|
2
|
-
Mode,
|
|
3
|
-
DEFAULT_MODE,
|
|
4
3
|
getAndLoadConfigIfNeeded,
|
|
5
4
|
getAccountId,
|
|
6
5
|
getAccountConfig,
|
|
7
6
|
loadConfigFromEnvironment,
|
|
8
|
-
} = require('@hubspot/
|
|
7
|
+
} = require('@hubspot/local-dev-lib/config');
|
|
9
8
|
const { getMode } = require('../commonOpts');
|
|
10
9
|
|
|
11
10
|
jest.mock('@hubspot/cli-lib');
|
|
11
|
+
jest.mock('@hubspot/local-dev-lib/config');
|
|
12
12
|
|
|
13
13
|
describe('@hubspot/cli/lib/commonOpts', () => {
|
|
14
14
|
describe('getMode()', () => {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { EXIT_CODES } = require('../enums/exitCodes');
|
|
5
|
+
const projects = require('../projects');
|
|
6
|
+
|
|
7
|
+
describe('@hubspot/cli/lib/projects', () => {
|
|
8
|
+
describe('validateProjectConfig()', () => {
|
|
9
|
+
let realProcess;
|
|
10
|
+
let projectDir;
|
|
11
|
+
let exitMock;
|
|
12
|
+
let errorSpy;
|
|
13
|
+
|
|
14
|
+
beforeAll(() => {
|
|
15
|
+
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'projects-'));
|
|
16
|
+
fs.mkdirSync(path.join(projectDir, 'src'));
|
|
17
|
+
|
|
18
|
+
realProcess = process;
|
|
19
|
+
errorSpy = jest.spyOn(console, 'error');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
exitMock = jest.fn();
|
|
24
|
+
global.process = { ...realProcess, exit: exitMock };
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
errorSpy.mockClear();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterAll(() => {
|
|
32
|
+
global.process = realProcess;
|
|
33
|
+
errorSpy.mockRestore();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('rejects undefined configuration', () => {
|
|
37
|
+
projects.validateProjectConfig(null, projectDir);
|
|
38
|
+
|
|
39
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
40
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
41
|
+
expect.stringMatching(/.*config not found.*/)
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('rejects configuration with missing name', () => {
|
|
46
|
+
projects.validateProjectConfig({ srcDir: '.' }, projectDir);
|
|
47
|
+
|
|
48
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
49
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
50
|
+
expect.stringMatching(/.*missing required fields*/)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('rejects configuration with missing srcDir', () => {
|
|
55
|
+
projects.validateProjectConfig({ name: 'hello' }, projectDir);
|
|
56
|
+
|
|
57
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
58
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
59
|
+
expect.stringMatching(/.*missing required fields.*/)
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('rejects configuration with srcDir outside project directory', () => {
|
|
64
|
+
it('for parent directory', () => {
|
|
65
|
+
projects.validateProjectConfig(
|
|
66
|
+
{ name: 'hello', srcDir: '..' },
|
|
67
|
+
projectDir
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
71
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
72
|
+
expect.stringContaining('srcDir: ".."')
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('for root directory', () => {
|
|
77
|
+
projects.validateProjectConfig(
|
|
78
|
+
{ name: 'hello', srcDir: '/' },
|
|
79
|
+
projectDir
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
83
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
84
|
+
expect.stringContaining('srcDir: "/"')
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('for complicated directory', () => {
|
|
89
|
+
const srcDir = './src/././../src/../../src';
|
|
90
|
+
|
|
91
|
+
projects.validateProjectConfig({ name: 'hello', srcDir }, projectDir);
|
|
92
|
+
|
|
93
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
94
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
95
|
+
expect.stringContaining(`srcDir: "${srcDir}"`)
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('rejects configuration with srcDir that does not exist', () => {
|
|
101
|
+
projects.validateProjectConfig(
|
|
102
|
+
{ name: 'hello', srcDir: 'foo' },
|
|
103
|
+
projectDir
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(exitMock).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
107
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
108
|
+
expect.stringMatching(/.*could not be found in.*/)
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('accepts configuration with valid srcDir', () => {
|
|
113
|
+
it('for current directory', () => {
|
|
114
|
+
projects.validateProjectConfig(
|
|
115
|
+
{ name: 'hello', srcDir: '.' },
|
|
116
|
+
projectDir
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
120
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('for relative directory', () => {
|
|
124
|
+
projects.validateProjectConfig(
|
|
125
|
+
{ name: 'hello', srcDir: './src' },
|
|
126
|
+
projectDir
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
130
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('for implied relative directory', () => {
|
|
134
|
+
projects.validateProjectConfig(
|
|
135
|
+
{ name: 'hello', srcDir: 'src' },
|
|
136
|
+
projectDir
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
140
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getAccountConfig } = require('@hubspot/
|
|
1
|
+
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
2
2
|
const { getOauthManager } = require('@hubspot/cli-lib/oauth');
|
|
3
3
|
const {
|
|
4
4
|
accessTokenForPersonalAccessKey,
|
|
@@ -8,6 +8,7 @@ const { getAccountId } = require('../commonOpts');
|
|
|
8
8
|
const { validateAccount } = require('../validation');
|
|
9
9
|
|
|
10
10
|
jest.mock('@hubspot/cli-lib');
|
|
11
|
+
jest.mock('@hubspot/local-dev-lib/config');
|
|
11
12
|
jest.mock('@hubspot/cli-lib/logger');
|
|
12
13
|
jest.mock('@hubspot/cli-lib/oauth');
|
|
13
14
|
jest.mock('@hubspot/cli-lib/personalAccessKey');
|
package/lib/commonOpts.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const Logger = require('@hubspot/cli-lib/logger');
|
|
2
|
+
const { DEFAULT_MODE, Mode } = require('@hubspot/cli-lib');
|
|
2
3
|
const {
|
|
3
4
|
getAccountId: getAccountIdFromConfig,
|
|
4
5
|
getAccountConfig,
|
|
5
6
|
getAndLoadConfigIfNeeded,
|
|
6
|
-
|
|
7
|
-
Mode,
|
|
8
|
-
} = require('@hubspot/cli-lib');
|
|
7
|
+
} = require('@hubspot/local-dev-lib/config');
|
|
9
8
|
const { i18n } = require('./lang');
|
|
10
9
|
|
|
11
10
|
const i18nKey = 'cli.lib.commonOpts';
|