@hubspot/cli 7.4.7-experimental.0 → 7.4.7
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/api/migrate.d.ts +14 -4
- package/api/migrate.js +16 -2
- package/bin/cli.js +8 -183
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +188 -0
- package/commands/account/clean.js +38 -5
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +104 -0
- package/commands/account/info.js +38 -4
- package/commands/account/list.js +23 -5
- package/commands/account/remove.js +36 -2
- package/commands/account/removeOverride.d.ts +10 -0
- package/commands/account/removeOverride.js +76 -0
- package/commands/account/use.js +25 -3
- package/commands/account.js +7 -2
- package/commands/app/migrate.d.ts +6 -6
- package/commands/app/migrate.js +62 -45
- package/commands/app.js +0 -2
- package/commands/auth.js +14 -11
- package/commands/cms/lighthouseScore.js +7 -3
- package/commands/cms.js +1 -2
- package/commands/completion.js +2 -3
- package/commands/config/migrate.d.ts +10 -0
- package/commands/config/migrate.js +84 -0
- package/commands/config/set.d.ts +10 -0
- package/commands/config/set.js +34 -29
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -11
- package/commands/create/api-sample.js +3 -1
- package/commands/create/website-theme.js +1 -1
- package/commands/create.js +7 -8
- package/commands/customObject/schema/delete.js +4 -1
- package/commands/customObject/schema/fetch-all.js +2 -1
- package/commands/customObject/schema/fetch.js +2 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +5 -6
- package/commands/feedback.js +7 -8
- package/commands/fetch.js +6 -7
- package/commands/filemanager.js +1 -2
- package/commands/function.js +1 -2
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +7 -8
- package/commands/hubdb/delete.js +8 -7
- package/commands/hubdb/fetch.js +4 -5
- package/commands/hubdb.js +1 -2
- package/commands/init.js +18 -20
- package/commands/lint.js +3 -4
- package/commands/list.js +5 -6
- package/commands/logs.js +12 -13
- package/commands/module/marketplace-validate.js +5 -6
- package/commands/module.js +1 -3
- package/commands/mv.js +4 -5
- package/commands/open.js +4 -5
- package/commands/project/add.d.ts +3 -7
- package/commands/project/add.js +28 -23
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +49 -45
- package/commands/project/create.d.ts +10 -1
- package/commands/project/create.js +85 -63
- package/commands/project/deploy.d.ts +3 -6
- package/commands/project/deploy.js +27 -25
- package/commands/project/dev/deprecatedFlow.js +32 -25
- package/commands/project/dev/index.d.ts +4 -2
- package/commands/project/dev/index.js +31 -18
- package/commands/project/dev/unifiedFlow.js +10 -11
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -27
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +6 -0
- package/commands/project/migrate.js +71 -0
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +23 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/upload.d.ts +9 -1
- package/commands/project/upload.js +78 -54
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +95 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +47 -35
- package/commands/remove.js +7 -5
- package/commands/sandbox/create.js +10 -11
- package/commands/sandbox/delete.js +18 -19
- package/commands/sandbox.js +1 -2
- package/commands/secret/addSecret.js +5 -6
- package/commands/secret/deleteSecret.js +12 -9
- package/commands/secret/listSecret.js +3 -4
- package/commands/secret/updateSecret.js +9 -8
- package/commands/secret.js +1 -2
- package/commands/theme/generate-selectors.js +5 -6
- package/commands/theme/marketplace-validate.js +5 -6
- package/commands/theme/preview.js +16 -16
- package/commands/theme.js +1 -2
- package/commands/upload.js +23 -24
- package/commands/watch.js +18 -19
- package/lang/en.d.ts +2806 -0
- package/lang/en.js +2659 -3300
- package/lang/en.lyaml +98 -41
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +12 -0
- package/lib/app/migrate.d.ts +10 -4
- package/lib/app/migrate.js +208 -94
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +10 -7
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +3 -4
- package/lib/commonOpts.js +46 -18
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +104 -0
- package/lib/configOptions.js +11 -10
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +5 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +19 -16
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +57 -44
- package/lib/errorHandlers/index.js +6 -7
- package/lib/errorHandlers/suppressError.js +6 -7
- package/lib/generateSelectors.js +1 -2
- package/lib/hasFeature.d.ts +3 -1
- package/lib/middleware/__test__/configMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/configMiddleware.test.js +194 -0
- package/lib/middleware/__test__/gitMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/gitMiddleware.test.js +76 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +10 -0
- package/lib/middleware/__test__/requestMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/requestMiddleware.test.js +20 -0
- package/lib/middleware/__test__/utils.test.d.ts +1 -0
- package/lib/middleware/__test__/utils.test.js +53 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +81 -0
- package/lib/middleware/configMiddleware.d.ts +13 -0
- package/lib/middleware/configMiddleware.js +116 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +123 -0
- package/lib/middleware/gitMiddleware.d.ts +2 -0
- package/lib/middleware/gitMiddleware.js +14 -0
- package/lib/middleware/notificationsMiddleware.d.ts +1 -0
- package/lib/middleware/notificationsMiddleware.js +38 -0
- package/lib/middleware/requestMiddleware.d.ts +1 -0
- package/lib/middleware/requestMiddleware.js +11 -0
- package/lib/middleware/utils.d.ts +8 -0
- package/lib/middleware/utils.js +17 -0
- package/lib/middleware/yargsChecksMiddleware.d.ts +4 -0
- package/lib/middleware/yargsChecksMiddleware.js +24 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- package/lib/projects/buildAndDeploy.js +28 -39
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create.js +5 -6
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +6 -6
- package/lib/{DevServerManagerV2.d.ts → projects/localDev/DevServerManagerV2.d.ts} +1 -1
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +3 -4
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +49 -82
- package/lib/{LocalDevManagerV2.d.ts → projects/localDev/LocalDevManagerV2.d.ts} +2 -2
- package/lib/{LocalDevManagerV2.js → projects/localDev/LocalDevManagerV2.js} +43 -75
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +5 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +97 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +13 -2
- package/lib/projects/upload.js +18 -34
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +6 -0
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +21 -18
- package/lib/prompts/accountNamePrompt.js +16 -13
- package/lib/prompts/accountsPrompt.js +1 -2
- package/lib/prompts/cmsFieldPrompt.js +1 -2
- package/lib/prompts/createApiSamplePrompt.js +4 -5
- package/lib/prompts/createFunctionPrompt.js +13 -14
- package/lib/prompts/createModulePrompt.js +8 -9
- package/lib/prompts/createProjectPrompt.d.ts +11 -4
- package/lib/prompts/createProjectPrompt.js +14 -9
- package/lib/prompts/createTemplatePrompt.js +1 -2
- package/lib/prompts/downloadProjectPrompt.js +3 -4
- package/lib/prompts/installPublicAppPrompt.js +6 -5
- package/lib/prompts/personalAccessKeyPrompt.js +17 -18
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.js +4 -5
- package/lib/prompts/projectDevTargetAccountPrompt.js +11 -12
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +1 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/selectPublicAppPrompt.js +6 -7
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -2
- package/lib/prompts/uploadPrompt.js +4 -5
- package/lib/sandboxSync.js +15 -14
- package/lib/sandboxes.js +12 -13
- package/lib/serverlessLogs.js +4 -6
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/boxen.d.ts +5 -0
- package/lib/ui/boxen.js +30 -0
- package/lib/ui/git.js +8 -9
- package/lib/ui/index.d.ts +4 -2
- package/lib/ui/index.js +16 -16
- package/lib/ui/logger.d.ts +10 -0
- package/lib/ui/logger.js +15 -0
- package/lib/ui/serverlessFunctionLogs.js +2 -3
- package/lib/ui/spinniesUtils.d.ts +5 -5
- package/lib/yargsUtils.d.ts +1 -1
- package/package.json +7 -6
- package/types/Yargs.d.ts +5 -11
- package/lib/projects/index.d.ts +0 -20
- package/lib/projects/index.js +0 -195
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const config = __importStar(require("@hubspot/local-dev-lib/config"));
|
|
37
|
+
const gitUI = __importStar(require("../../ui/git"));
|
|
38
|
+
const gitMiddleware_1 = require("../gitMiddleware");
|
|
39
|
+
jest.mock('@hubspot/local-dev-lib/config');
|
|
40
|
+
jest.mock('../../ui/git');
|
|
41
|
+
const getConfigPathSpy = jest.spyOn(config, 'getConfigPath');
|
|
42
|
+
const checkAndWarnGitInclusionSpy = jest.spyOn(gitUI, 'checkAndWarnGitInclusion');
|
|
43
|
+
describe('lib/middleware/gitMiddleware', () => {
|
|
44
|
+
describe('checkAndWarnGitInclusionMiddleware()', () => {
|
|
45
|
+
it('should call checkAndWarnGitInclusion when command is provided and config path exists', () => {
|
|
46
|
+
const mockConfigPath = '/path/to/config';
|
|
47
|
+
getConfigPathSpy.mockReturnValue(mockConfigPath);
|
|
48
|
+
const argv = {
|
|
49
|
+
_: ['some-command'],
|
|
50
|
+
$0: 'hs',
|
|
51
|
+
};
|
|
52
|
+
(0, gitMiddleware_1.checkAndWarnGitInclusionMiddleware)(argv);
|
|
53
|
+
expect(getConfigPathSpy).toHaveBeenCalledTimes(1);
|
|
54
|
+
expect(checkAndWarnGitInclusionSpy).toHaveBeenCalledWith(mockConfigPath);
|
|
55
|
+
});
|
|
56
|
+
it('should not call checkAndWarnGitInclusion when no command is provided', () => {
|
|
57
|
+
const argv = {
|
|
58
|
+
_: [],
|
|
59
|
+
$0: 'hs',
|
|
60
|
+
};
|
|
61
|
+
(0, gitMiddleware_1.checkAndWarnGitInclusionMiddleware)(argv);
|
|
62
|
+
expect(getConfigPathSpy).not.toHaveBeenCalled();
|
|
63
|
+
expect(checkAndWarnGitInclusionSpy).not.toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
it('should not call checkAndWarnGitInclusion when config path is null', () => {
|
|
66
|
+
getConfigPathSpy.mockReturnValue(null);
|
|
67
|
+
const argv = {
|
|
68
|
+
_: ['some-command'],
|
|
69
|
+
$0: 'hs',
|
|
70
|
+
};
|
|
71
|
+
(0, gitMiddleware_1.checkAndWarnGitInclusionMiddleware)(argv);
|
|
72
|
+
expect(getConfigPathSpy).toHaveBeenCalledTimes(1);
|
|
73
|
+
expect(checkAndWarnGitInclusionSpy).not.toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const { notifyAboutUpdates } = require('../notificationsMiddleware');
|
|
4
|
+
describe('lib/middleware/notificationsMiddleware', () => {
|
|
5
|
+
describe('notifyAboutUpdates()', () => {
|
|
6
|
+
it('should safely execute without throwing an error', () => {
|
|
7
|
+
expect(() => notifyAboutUpdates()).not.toThrow();
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const http_1 = require("@hubspot/local-dev-lib/http");
|
|
7
|
+
const requestMiddleware_1 = require("../requestMiddleware");
|
|
8
|
+
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
9
|
+
jest.mock('@hubspot/local-dev-lib/http', () => ({
|
|
10
|
+
addUserAgentHeader: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
describe('lib/middleware/requestMiddleware', () => {
|
|
13
|
+
describe('setRequestHeaders()', () => {
|
|
14
|
+
it('should call addUserAgentHeader with correct parameters', () => {
|
|
15
|
+
(0, requestMiddleware_1.setRequestHeaders)();
|
|
16
|
+
expect(http_1.addUserAgentHeader).toHaveBeenCalledTimes(1);
|
|
17
|
+
expect(http_1.addUserAgentHeader).toHaveBeenCalledWith('HubSpot CLI', package_json_1.default.version);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const targetCommandMap = {
|
|
5
|
+
init: { target: true },
|
|
6
|
+
account: {
|
|
7
|
+
target: true,
|
|
8
|
+
subCommands: {
|
|
9
|
+
use: { target: true },
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
project: {
|
|
13
|
+
subCommands: {
|
|
14
|
+
deploy: { target: true },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
describe('lib/middleware/utils', () => {
|
|
19
|
+
describe('isTargetedCommand()', () => {
|
|
20
|
+
it('should return true for a direct target command', () => {
|
|
21
|
+
const result = (0, utils_1.isTargetedCommand)(['init'], targetCommandMap);
|
|
22
|
+
expect(result).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it('should return true for a command with a subcommand', () => {
|
|
25
|
+
const result = (0, utils_1.isTargetedCommand)(['account'], targetCommandMap);
|
|
26
|
+
expect(result).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
it('should return true for a nested target command', () => {
|
|
29
|
+
const result = (0, utils_1.isTargetedCommand)(['project', 'deploy'], targetCommandMap);
|
|
30
|
+
expect(result).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it('should return false for a non-existent command', () => {
|
|
33
|
+
const result = (0, utils_1.isTargetedCommand)(['nonexistent'], targetCommandMap);
|
|
34
|
+
expect(result).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
it('should return false for a non-targeted command', () => {
|
|
37
|
+
const result = (0, utils_1.isTargetedCommand)(['auth'], targetCommandMap);
|
|
38
|
+
expect(result).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
it('should return false for a command with a targeted subcommand', () => {
|
|
41
|
+
const result = (0, utils_1.isTargetedCommand)(['project'], targetCommandMap);
|
|
42
|
+
expect(result).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
it('should return false for a non-existent subcommand', () => {
|
|
45
|
+
const result = (0, utils_1.isTargetedCommand)(['auth', 'nonexistent'], targetCommandMap);
|
|
46
|
+
expect(result).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
it('should return false for an empty command array', () => {
|
|
49
|
+
const result = (0, utils_1.isTargetedCommand)([], targetCommandMap);
|
|
50
|
+
expect(result).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
37
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
38
|
+
const projectsConfig = __importStar(require("../../projects/config"));
|
|
39
|
+
const yargsChecksMiddleware_1 = require("../yargsChecksMiddleware");
|
|
40
|
+
jest.mock('@hubspot/local-dev-lib/logger', () => ({
|
|
41
|
+
logger: {
|
|
42
|
+
error: jest.fn(),
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
jest.mock('../../projects/config');
|
|
46
|
+
jest.mock('../../lang', () => ({
|
|
47
|
+
i18n: jest.fn(key => key),
|
|
48
|
+
}));
|
|
49
|
+
const getIsInProjectSpy = jest.spyOn(projectsConfig, 'getIsInProject');
|
|
50
|
+
const processExitSpy = jest.spyOn(process, 'exit');
|
|
51
|
+
describe('lib/middleware/yargsChecksMiddleware', () => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
processExitSpy.mockImplementation(code => {
|
|
54
|
+
throw new Error(`Process.exit called with code ${code}`);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('performChecks()', () => {
|
|
58
|
+
it('should exit with error when running upload/watch inside a project', () => {
|
|
59
|
+
const argv = {
|
|
60
|
+
_: ['upload'],
|
|
61
|
+
src: './project',
|
|
62
|
+
$0: 'hs',
|
|
63
|
+
};
|
|
64
|
+
getIsInProjectSpy.mockReturnValue(true);
|
|
65
|
+
expect(() => (0, yargsChecksMiddleware_1.performChecks)(argv)).toThrow();
|
|
66
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
67
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith('commands.generalErrors.srcIsProject');
|
|
68
|
+
});
|
|
69
|
+
it('should return true when no checks fail', () => {
|
|
70
|
+
const argv = {
|
|
71
|
+
_: ['upload'],
|
|
72
|
+
src: './not-a-project',
|
|
73
|
+
$0: 'hs',
|
|
74
|
+
};
|
|
75
|
+
getIsInProjectSpy.mockReturnValue(false);
|
|
76
|
+
expect((0, yargsChecksMiddleware_1.performChecks)(argv)).toBe(true);
|
|
77
|
+
expect(processExitSpy).not.toHaveBeenCalled();
|
|
78
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Arguments } from 'yargs';
|
|
2
|
+
import { CLIOptions } from '@hubspot/local-dev-lib/types/CLIOptions';
|
|
3
|
+
export declare function handleDeprecatedEnvVariables(argv: Arguments<{
|
|
4
|
+
useEnv?: boolean;
|
|
5
|
+
}>): void;
|
|
6
|
+
/**
|
|
7
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
8
|
+
*/
|
|
9
|
+
export declare function injectAccountIdMiddleware(argv: Arguments<{
|
|
10
|
+
account?: string;
|
|
11
|
+
}>): Promise<void>;
|
|
12
|
+
export declare function loadConfigMiddleware(argv: Arguments<CLIOptions>): Promise<void>;
|
|
13
|
+
export declare function validateAccountOptions(argv: Arguments): Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleDeprecatedEnvVariables = handleDeprecatedEnvVariables;
|
|
4
|
+
exports.injectAccountIdMiddleware = injectAccountIdMiddleware;
|
|
5
|
+
exports.loadConfigMiddleware = loadConfigMiddleware;
|
|
6
|
+
exports.validateAccountOptions = validateAccountOptions;
|
|
7
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
9
|
+
const validation_1 = require("../validation");
|
|
10
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
11
|
+
const lang_1 = require("../lang");
|
|
12
|
+
const ui_1 = require("../ui");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
function handleDeprecatedEnvVariables(argv) {
|
|
15
|
+
// HUBSPOT_PORTAL_ID is deprecated, but we'll still support it for now
|
|
16
|
+
// The HubSpot GH Deploy Action still uses HUBSPOT_PORTAL_ID
|
|
17
|
+
if (argv.useEnv &&
|
|
18
|
+
process.env.HUBSPOT_PORTAL_ID &&
|
|
19
|
+
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
20
|
+
(0, ui_1.uiDeprecatedTag)((0, lang_1.i18n)(`commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated`, {
|
|
21
|
+
configPath: (0, config_1.getConfigPath)(),
|
|
22
|
+
}));
|
|
23
|
+
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
28
|
+
*/
|
|
29
|
+
async function injectAccountIdMiddleware(argv) {
|
|
30
|
+
const { account } = argv;
|
|
31
|
+
// Preserves the original --account flag for certain commands.
|
|
32
|
+
argv.providedAccountId = account;
|
|
33
|
+
if (argv.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
34
|
+
argv.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
argv.derivedAccountId = (0, config_1.getAccountId)(account);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const SKIP_CONFIG_VALIDATION = {
|
|
41
|
+
init: { target: true },
|
|
42
|
+
auth: { target: true },
|
|
43
|
+
};
|
|
44
|
+
async function loadConfigMiddleware(argv) {
|
|
45
|
+
// Skip this when no command is provided
|
|
46
|
+
if (!argv._.length || argv.help) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const maybeValidateConfig = () => {
|
|
50
|
+
if (!(0, utils_1.isTargetedCommand)(argv._, SKIP_CONFIG_VALIDATION) &&
|
|
51
|
+
!(0, config_1.validateConfig)()) {
|
|
52
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (!(0, config_1.configFileExists)(true) &&
|
|
56
|
+
(0, utils_1.isTargetedCommand)(argv._, {
|
|
57
|
+
account: { target: false, subCommands: { auth: { target: true } } },
|
|
58
|
+
})) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if ((0, config_1.configFileExists)(true) &&
|
|
62
|
+
argv.config &&
|
|
63
|
+
!(0, utils_1.isTargetedCommand)(argv._, {
|
|
64
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
65
|
+
})) {
|
|
66
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
67
|
+
configPath: (0, config_1.getConfigPath)(),
|
|
68
|
+
}));
|
|
69
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
70
|
+
}
|
|
71
|
+
else if (!(0, utils_1.isTargetedCommand)(argv._, { init: { target: true } })) {
|
|
72
|
+
const config = (0, config_1.loadConfig)(argv.config, argv);
|
|
73
|
+
// We don't run validateConfig() for auth because users should be able to run it when
|
|
74
|
+
// no accounts are configured, but we still want to exit if the config file is not found
|
|
75
|
+
if ((0, utils_1.isTargetedCommand)(argv._, { auth: { target: true } }) && !config) {
|
|
76
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
maybeValidateConfig();
|
|
80
|
+
}
|
|
81
|
+
const accountsSubCommands = {
|
|
82
|
+
target: false,
|
|
83
|
+
subCommands: {
|
|
84
|
+
auth: { target: true },
|
|
85
|
+
clean: { target: true },
|
|
86
|
+
list: { target: true },
|
|
87
|
+
ls: { target: true },
|
|
88
|
+
remove: { target: true },
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const sandboxesSubCommands = {
|
|
92
|
+
target: false,
|
|
93
|
+
subCommands: {
|
|
94
|
+
delete: { target: true },
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const SKIP_ACCOUNT_VALIDATION = {
|
|
98
|
+
init: { target: true },
|
|
99
|
+
auth: { target: true },
|
|
100
|
+
account: accountsSubCommands,
|
|
101
|
+
accounts: accountsSubCommands,
|
|
102
|
+
sandbox: sandboxesSubCommands,
|
|
103
|
+
sandboxes: sandboxesSubCommands,
|
|
104
|
+
};
|
|
105
|
+
async function validateAccountOptions(argv) {
|
|
106
|
+
// Skip this when no command is provided
|
|
107
|
+
if (argv._.length && !argv.help) {
|
|
108
|
+
let validAccount = true;
|
|
109
|
+
if (!(0, utils_1.isTargetedCommand)(argv._, SKIP_ACCOUNT_VALIDATION)) {
|
|
110
|
+
validAccount = await (0, validation_1.validateAccount)(argv);
|
|
111
|
+
}
|
|
112
|
+
if (!validAccount) {
|
|
113
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkFireAlarms = checkFireAlarms;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fireAlarm_1 = require("@hubspot/local-dev-lib/api/fireAlarm");
|
|
9
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const boxen_1 = require("../ui/boxen");
|
|
12
|
+
/*
|
|
13
|
+
* Versions can be formatted like this:
|
|
14
|
+
* =7.2.2 -> targets the exact version 7.2.2
|
|
15
|
+
* =7.2.* -> targets all versions with a major of 7 and a minor of 2
|
|
16
|
+
* =7.* -> targets all versions with a major of 7
|
|
17
|
+
* =* -> targets all versions
|
|
18
|
+
* <=7.2.2 -> targets all versions equal to or less than 7.2.2
|
|
19
|
+
* <=7.2.* -> targets all versions equal to or less than 7.2
|
|
20
|
+
*/
|
|
21
|
+
const WILDCARD = '*';
|
|
22
|
+
function isVersionTargeted(version, targetVersionString) {
|
|
23
|
+
// Assume we're targeting no versions if no version string is found
|
|
24
|
+
// Target all versions using the * wildcard
|
|
25
|
+
if (!targetVersionString) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
// Only support version targeting for the <= or = operator
|
|
29
|
+
if (!targetVersionString.startsWith('<=') &&
|
|
30
|
+
!targetVersionString.startsWith('=')) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const targetVersion = targetVersionString.substring(targetVersionString.indexOf('=') + 1);
|
|
34
|
+
// Only allow exact version matching for tagged CLI releases (like -beta)
|
|
35
|
+
if (version.includes('-') || targetVersionString.includes('-')) {
|
|
36
|
+
if (!targetVersionString.startsWith('=')) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return version === targetVersion;
|
|
40
|
+
}
|
|
41
|
+
const targetVersionParts = targetVersion.split('.');
|
|
42
|
+
const versionParts = version.split('.');
|
|
43
|
+
// Require the wildcard to be explicitly set to target all versions
|
|
44
|
+
if (versionParts.length < 3 &&
|
|
45
|
+
versionParts[versionParts.length - 1] !== WILDCARD) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Don't allow the less than or equal to operator to be used with the wildcard
|
|
49
|
+
// in the major version part (e.g. <=*)
|
|
50
|
+
if (targetVersionString.startsWith('<=') && versionParts[0] === WILDCARD) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
let targetAnyVersion = false;
|
|
54
|
+
return targetVersionParts.every((targetPart, i) => {
|
|
55
|
+
const versionPart = versionParts[i];
|
|
56
|
+
// Support generic version targeting (like 1.2.*)
|
|
57
|
+
if (targetPart === WILDCARD || targetAnyVersion) {
|
|
58
|
+
targetAnyVersion = true;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
// Double check that the target part is a number
|
|
62
|
+
if (isNaN(Number(targetPart))) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return targetVersionString.startsWith('<=')
|
|
66
|
+
? Number(versionPart) <= Number(targetPart)
|
|
67
|
+
: Number(versionPart) === Number(targetPart);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function isCommandTargeted(command, targetCommandsString) {
|
|
71
|
+
// Require the wildcard to be explicitly set to target all commands
|
|
72
|
+
if (!targetCommandsString) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (targetCommandsString === WILDCARD) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const targetCommands = targetCommandsString.split(',');
|
|
79
|
+
return targetCommands.some(cmd => command.startsWith(cmd));
|
|
80
|
+
}
|
|
81
|
+
function filterFireAlarm(fireAlarm, command, version) {
|
|
82
|
+
const commandIsTargeted = isCommandTargeted(command, fireAlarm.querySelector);
|
|
83
|
+
const versionIsTargeted = isVersionTargeted(version, fireAlarm.urlRegexPattern);
|
|
84
|
+
return commandIsTargeted && versionIsTargeted;
|
|
85
|
+
}
|
|
86
|
+
async function getFireAlarms(accountId, command, version) {
|
|
87
|
+
let relevantAlarms = [];
|
|
88
|
+
try {
|
|
89
|
+
const { data: fireAlarms } = await (0, fireAlarm_1.fetchFireAlarms)(accountId);
|
|
90
|
+
relevantAlarms = fireAlarms.filter(fireAlarm => filterFireAlarm(fireAlarm, command, version));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
(0, errorHandlers_1.debugError)(error);
|
|
94
|
+
}
|
|
95
|
+
return relevantAlarms;
|
|
96
|
+
}
|
|
97
|
+
async function logFireAlarms(accountId, command, version) {
|
|
98
|
+
const alarms = await getFireAlarms(accountId, command, version);
|
|
99
|
+
if (alarms.length > 0) {
|
|
100
|
+
const notifications = alarms.reduce((acc, alarm) => {
|
|
101
|
+
if (alarm.title && alarm.message) {
|
|
102
|
+
return (acc +
|
|
103
|
+
`${acc.length > 0 ? '\n\n' : ''}${chalk_1.default.bold(alarm.title)}\n${alarm.message}`);
|
|
104
|
+
}
|
|
105
|
+
return acc;
|
|
106
|
+
}, '');
|
|
107
|
+
await (0, boxen_1.logInBox)({
|
|
108
|
+
contents: notifications,
|
|
109
|
+
options: {
|
|
110
|
+
title: 'Notifications',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function checkFireAlarms(args) {
|
|
116
|
+
const { derivedAccountId } = args;
|
|
117
|
+
try {
|
|
118
|
+
await logFireAlarms(derivedAccountId, args._.join(' '), package_json_1.default.version);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
(0, errorHandlers_1.debugError)(error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAndWarnGitInclusionMiddleware = checkAndWarnGitInclusionMiddleware;
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const git_1 = require("../ui/git");
|
|
6
|
+
function checkAndWarnGitInclusionMiddleware(argv) {
|
|
7
|
+
// Skip this when no command is provided
|
|
8
|
+
if (argv._.length) {
|
|
9
|
+
const configPath = (0, config_1.getConfigPath)();
|
|
10
|
+
if (configPath) {
|
|
11
|
+
(0, git_1.checkAndWarnGitInclusion)(configPath);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function notifyAboutUpdates(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notifyAboutUpdates = notifyAboutUpdates;
|
|
4
|
+
// Update-notifier is CommonJS, so we need to use require
|
|
5
|
+
const updateNotifier = require('update-notifier');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
const pkg = require('../../package.json');
|
|
8
|
+
const { UI_COLORS, uiCommandReference } = require('../ui');
|
|
9
|
+
const { i18n } = require('../lang');
|
|
10
|
+
const notifier = updateNotifier({
|
|
11
|
+
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
12
|
+
distTag: 'latest',
|
|
13
|
+
shouldNotifyInNpmScript: true,
|
|
14
|
+
});
|
|
15
|
+
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
16
|
+
function notifyAboutUpdates() {
|
|
17
|
+
notifier.notify({
|
|
18
|
+
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
19
|
+
? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
20
|
+
packageName: CMS_CLI_PACKAGE_NAME,
|
|
21
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
22
|
+
})
|
|
23
|
+
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
24
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
25
|
+
}),
|
|
26
|
+
defer: false,
|
|
27
|
+
boxenOptions: {
|
|
28
|
+
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
29
|
+
margin: 1,
|
|
30
|
+
padding: 1,
|
|
31
|
+
textAlignment: 'center',
|
|
32
|
+
borderStyle: 'round',
|
|
33
|
+
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
34
|
+
? null
|
|
35
|
+
: chalk.bold(i18n(`commands.generalErrors.updateNotify.notifyTitle`)),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setRequestHeaders(): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setRequestHeaders = setRequestHeaders;
|
|
7
|
+
const http_1 = require("@hubspot/local-dev-lib/http");
|
|
8
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
9
|
+
function setRequestHeaders() {
|
|
10
|
+
(0, http_1.addUserAgentHeader)('HubSpot CLI', package_json_1.default.version);
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTargetedCommand = isTargetedCommand;
|
|
4
|
+
function isTargetedCommand(commandParts, targetCommandMap) {
|
|
5
|
+
const currentCommand = commandParts[0];
|
|
6
|
+
if (!targetCommandMap[currentCommand]) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (targetCommandMap[currentCommand].target) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const subCommands = targetCommandMap[currentCommand].subCommands || {};
|
|
13
|
+
if (commandParts.length > 1) {
|
|
14
|
+
return isTargetedCommand(commandParts.slice(1), subCommands);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performChecks = performChecks;
|
|
4
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
5
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
6
|
+
const lang_1 = require("../lang");
|
|
7
|
+
const config_1 = require("../projects/config");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const UPLOAD_AND_WATCH_COMMANDS = {
|
|
10
|
+
upload: { target: true },
|
|
11
|
+
watch: { target: true },
|
|
12
|
+
};
|
|
13
|
+
function performChecks(argv) {
|
|
14
|
+
// Require "project" command when running upload/watch inside of a project
|
|
15
|
+
if ((0, utils_1.isTargetedCommand)(argv._, UPLOAD_AND_WATCH_COMMANDS) &&
|
|
16
|
+
(0, config_1.getIsInProject)(argv.src)) {
|
|
17
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.srcIsProject`, {
|
|
18
|
+
src: argv.src || './',
|
|
19
|
+
command: argv._.join(' '),
|
|
20
|
+
}));
|
|
21
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|