@hubspot/cli 7.5.2-beta.0 → 7.5.2-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/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.js +2 -0
- package/commands/project/dev/unifiedFlow.js +5 -7
- package/lang/en.d.ts +16 -0
- package/lang/en.js +18 -0
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +5 -1
- package/lib/projects/localDev/AppDevModeInterface.d.ts +1 -0
- package/lib/projects/localDev/AppDevModeInterface.js +8 -0
- package/lib/projects/localDev/LocalDevLogger.js +1 -0
- package/lib/projects/localDev/LocalDevProcess.d.ts +2 -1
- package/lib/projects/localDev/LocalDevProcess.js +3 -0
- package/lib/projects/localDev/LocalDevState.d.ts +4 -1
- package/lib/projects/localDev/LocalDevState.js +10 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +3 -2
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +8 -2
- package/package.json +2 -2
- package/types/LocalDev.d.ts +2 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
+
type HubdbListArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs;
|
|
3
|
+
declare const hubdbListCommand: YargsCommandModule<unknown, HubdbListArgs>;
|
|
4
|
+
export default hubdbListCommand;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hubdb_1 = require("@hubspot/local-dev-lib/api/hubdb");
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
6
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
7
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
8
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
9
|
+
const en_1 = require("../../lang/en");
|
|
10
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
11
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
12
|
+
const table_1 = require("../../lib/ui/table");
|
|
13
|
+
const command = ['list', 'ls'];
|
|
14
|
+
const describe = en_1.commands.hubdb.subcommands.list.describe;
|
|
15
|
+
async function getTableData(accountId) {
|
|
16
|
+
try {
|
|
17
|
+
const response = await (0, hubdb_1.fetchTables)(accountId);
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
(0, index_1.logError)(err);
|
|
22
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// stripping the types and unnecessary fields so this data can be turned into a UI table
|
|
26
|
+
function mapTablesToUI(tables) {
|
|
27
|
+
return tables.map(({ id, label, name, columnCount, rowCount }) => [
|
|
28
|
+
`${id}`,
|
|
29
|
+
label,
|
|
30
|
+
name,
|
|
31
|
+
`${columnCount || 0}`,
|
|
32
|
+
`${rowCount}`,
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
async function handler(args) {
|
|
36
|
+
const { derivedAccountId } = args;
|
|
37
|
+
(0, usageTracking_1.trackCommandUsage)('hubdb-list', {}, derivedAccountId);
|
|
38
|
+
const { results: tables, total } = await getTableData(derivedAccountId);
|
|
39
|
+
const tableUIData = mapTablesToUI(tables);
|
|
40
|
+
tableUIData.unshift((0, table_1.getTableHeader)([
|
|
41
|
+
en_1.commands.hubdb.subcommands.list.labels.id,
|
|
42
|
+
en_1.commands.hubdb.subcommands.list.labels.label,
|
|
43
|
+
en_1.commands.hubdb.subcommands.list.labels.name,
|
|
44
|
+
en_1.commands.hubdb.subcommands.list.labels.columns,
|
|
45
|
+
en_1.commands.hubdb.subcommands.list.labels.rows,
|
|
46
|
+
]));
|
|
47
|
+
logger_1.uiLogger.success(en_1.commands.hubdb.subcommands.list.success(derivedAccountId));
|
|
48
|
+
logger_1.uiLogger.log(' ');
|
|
49
|
+
// link devs to the hubdb page in hubspot for easy access
|
|
50
|
+
// TODO: This is hacky, we should make a util like getBaseUrl()
|
|
51
|
+
const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)((0, config_1.getEnv)());
|
|
52
|
+
logger_1.uiLogger.log(en_1.commands.hubdb.subcommands.list.viewTablesLink(baseUrl, derivedAccountId));
|
|
53
|
+
// don't bother showing an empty list of tables
|
|
54
|
+
if (tables.length > 0) {
|
|
55
|
+
// if truncated is 0, it will be interpreted as falsy
|
|
56
|
+
const truncated = total - tables.length;
|
|
57
|
+
logger_1.uiLogger.log(en_1.commands.hubdb.subcommands.list.tablesDisplayed(tables.length, total, truncated));
|
|
58
|
+
logger_1.uiLogger.log('--------------------------------');
|
|
59
|
+
logger_1.uiLogger.log(en_1.commands.hubdb.subcommands.list.tables);
|
|
60
|
+
logger_1.uiLogger.log((0, table_1.getTableContents)(tableUIData, { border: { bodyLeft: ' ' } }));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
logger_1.uiLogger.log(en_1.commands.hubdb.subcommands.list.noTables(derivedAccountId));
|
|
64
|
+
}
|
|
65
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
66
|
+
}
|
|
67
|
+
function hubdbListBuilder(yargs) {
|
|
68
|
+
yargs.example([['$0 hubdb list']]);
|
|
69
|
+
return yargs;
|
|
70
|
+
}
|
|
71
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(hubdbListBuilder, command, describe, {
|
|
72
|
+
useGlobalOptions: true,
|
|
73
|
+
useConfigOptions: true,
|
|
74
|
+
useAccountOptions: true,
|
|
75
|
+
useEnvironmentOptions: true,
|
|
76
|
+
});
|
|
77
|
+
const hubdbListCommand = {
|
|
78
|
+
command,
|
|
79
|
+
describe,
|
|
80
|
+
handler,
|
|
81
|
+
builder,
|
|
82
|
+
};
|
|
83
|
+
exports.default = hubdbListCommand;
|
package/commands/hubdb.js
CHANGED
|
@@ -8,6 +8,7 @@ const create_1 = __importDefault(require("./hubdb/create"));
|
|
|
8
8
|
const fetch_1 = __importDefault(require("./hubdb/fetch"));
|
|
9
9
|
const delete_1 = __importDefault(require("./hubdb/delete"));
|
|
10
10
|
const clear_1 = __importDefault(require("./hubdb/clear"));
|
|
11
|
+
const list_1 = __importDefault(require("./hubdb/list"));
|
|
11
12
|
const lang_1 = require("../lib/lang");
|
|
12
13
|
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
13
14
|
exports.command = 'hubdb';
|
|
@@ -18,6 +19,7 @@ function hubdbBuilder(yargs) {
|
|
|
18
19
|
.command(create_1.default)
|
|
19
20
|
.command(fetch_1.default)
|
|
20
21
|
.command(delete_1.default)
|
|
22
|
+
.command(list_1.default)
|
|
21
23
|
.demandCommand(1, '');
|
|
22
24
|
return yargs;
|
|
23
25
|
}
|
|
@@ -24,6 +24,7 @@ const accountTypes_1 = require("../../../lib/accountTypes");
|
|
|
24
24
|
const ui_1 = require("../../../lib/ui");
|
|
25
25
|
const logger_1 = require("../../../lib/ui/logger");
|
|
26
26
|
const en_1 = require("../../../lang/en");
|
|
27
|
+
const LocalDevWebsocketServer_1 = __importDefault(require("../../../lib/projects/localDev/LocalDevWebsocketServer"));
|
|
27
28
|
async function unifiedProjectDevFlow({ args, targetProjectAccountId, providedTargetTestingAccountId, projectConfig, projectDir, profileConfig, }) {
|
|
28
29
|
const env = (0, environment_1.getValidEnv)((0, config_2.getEnv)(targetProjectAccountId));
|
|
29
30
|
let projectNodes;
|
|
@@ -131,23 +132,20 @@ async function unifiedProjectDevFlow({ args, targetProjectAccountId, providedTar
|
|
|
131
132
|
await localDevProcess.start();
|
|
132
133
|
const watcher = new LocalDevWatcher_1.default(localDevProcess);
|
|
133
134
|
watcher.start();
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// args.debug
|
|
137
|
-
// );
|
|
138
|
-
// await websocketServer.start();
|
|
135
|
+
const websocketServer = new LocalDevWebsocketServer_1.default(localDevProcess, args.debug);
|
|
136
|
+
await websocketServer.start();
|
|
139
137
|
(0, process_1.handleKeypress)(async (key) => {
|
|
140
138
|
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
141
139
|
await Promise.all([
|
|
142
140
|
localDevProcess.stop(),
|
|
143
141
|
watcher.stop(),
|
|
144
|
-
|
|
142
|
+
websocketServer.shutdown(),
|
|
145
143
|
]);
|
|
146
144
|
}
|
|
147
145
|
});
|
|
148
146
|
(0, process_1.handleExit)(({ isSIGHUP }) => {
|
|
149
147
|
localDevProcess.stop(!isSIGHUP);
|
|
150
148
|
watcher.stop();
|
|
151
|
-
|
|
149
|
+
websocketServer.shutdown();
|
|
152
150
|
});
|
|
153
151
|
}
|
package/lang/en.d.ts
CHANGED
|
@@ -665,6 +665,21 @@ Global configuration replaces hubspot.config.yml, and you will be prompted to mi
|
|
|
665
665
|
readonly fetch: (tableId: string, path: string) => string;
|
|
666
666
|
};
|
|
667
667
|
};
|
|
668
|
+
readonly list: {
|
|
669
|
+
readonly tables: `${string}:`;
|
|
670
|
+
readonly describe: "List HubDB tables.";
|
|
671
|
+
readonly labels: {
|
|
672
|
+
readonly label: "Label";
|
|
673
|
+
readonly id: "ID";
|
|
674
|
+
readonly name: "Name";
|
|
675
|
+
readonly columns: "Columns";
|
|
676
|
+
readonly rows: "Rows";
|
|
677
|
+
};
|
|
678
|
+
readonly success: (accountId: number) => string;
|
|
679
|
+
readonly noTables: (accountId: number) => string;
|
|
680
|
+
readonly tablesDisplayed: (displayed: number, total: number, truncated?: number) => string;
|
|
681
|
+
readonly viewTablesLink: (baseUrl: string, accountId: number) => string;
|
|
682
|
+
};
|
|
668
683
|
};
|
|
669
684
|
};
|
|
670
685
|
readonly init: {
|
|
@@ -2258,6 +2273,7 @@ export declare const lib: {
|
|
|
2258
2273
|
readonly running: (projectName: string, accountIdentifier: string) => string;
|
|
2259
2274
|
readonly quitHelper: `Press ${string} to stop the local dev server`;
|
|
2260
2275
|
readonly viewProjectLink: (name: string, accountId: number) => string;
|
|
2276
|
+
readonly viewLocalDevUILink: (accountId: number) => string;
|
|
2261
2277
|
readonly viewTestAccountLink: "View developer test account in HubSpot";
|
|
2262
2278
|
readonly exitingStart: "Stopping local dev server ...";
|
|
2263
2279
|
readonly exitingSucceed: "Successfully exited";
|
package/lang/en.js
CHANGED
|
@@ -675,6 +675,23 @@ exports.commands = {
|
|
|
675
675
|
fetch: (tableId, path) => `Downloaded HubDB table ${tableId} to ${path}`,
|
|
676
676
|
},
|
|
677
677
|
},
|
|
678
|
+
list: {
|
|
679
|
+
tables: `${chalk_1.default.bold('Tables')}:`,
|
|
680
|
+
describe: 'List HubDB tables.',
|
|
681
|
+
labels: {
|
|
682
|
+
label: 'Label',
|
|
683
|
+
id: 'ID',
|
|
684
|
+
name: 'Name',
|
|
685
|
+
columns: 'Columns',
|
|
686
|
+
rows: 'Rows',
|
|
687
|
+
},
|
|
688
|
+
success: (accountId) => `Showing tables for account ${accountId}:`,
|
|
689
|
+
noTables: (accountId) => `No tables found for account ${accountId}.`,
|
|
690
|
+
tablesDisplayed: (displayed, total, truncated) => `Displaying ${displayed} of ${total} tables${truncated
|
|
691
|
+
? `, the remaining ${truncated} tables were not displayed.`
|
|
692
|
+
: '.'}`,
|
|
693
|
+
viewTablesLink: (baseUrl, accountId) => (0, ui_1.uiLink)('Manage tables in HubSpot', `${baseUrl}/hubdb/${accountId}`),
|
|
694
|
+
},
|
|
678
695
|
},
|
|
679
696
|
},
|
|
680
697
|
init: {
|
|
@@ -2257,6 +2274,7 @@ exports.lib = {
|
|
|
2257
2274
|
running: (projectName, accountIdentifier) => chalk_1.default.hex(ui_1.UI_COLORS.SORBET)(`Running ${chalk_1.default.bold(projectName)} locally on ${accountIdentifier}, waiting for changes ...`),
|
|
2258
2275
|
quitHelper: `Press ${chalk_1.default.bold('q')} to stop the local dev server`,
|
|
2259
2276
|
viewProjectLink: (name, accountId) => (0, ui_1.uiLink)('View project in HubSpot', (0, urls_1.getProjectDetailUrl)(name, accountId) || ''),
|
|
2277
|
+
viewLocalDevUILink: (accountId) => (0, ui_1.uiLink)('View local dev session in HubSpot', (0, urls_1.getLocalDevUiUrl)(accountId)),
|
|
2260
2278
|
viewTestAccountLink: 'View developer test account in HubSpot',
|
|
2261
2279
|
exitingStart: 'Stopping local dev server ...',
|
|
2262
2280
|
exitingSucceed: 'Successfully exited',
|
package/lib/constants.d.ts
CHANGED
|
@@ -98,3 +98,7 @@ export declare const oAuth = "oauth";
|
|
|
98
98
|
export declare const privateDistribution = "private";
|
|
99
99
|
export declare const marketplaceDistribution = "marketplace";
|
|
100
100
|
export declare const appComponent = "app";
|
|
101
|
+
export declare const LOCAL_DEV_SERVER_MESSAGE_TYPES: {
|
|
102
|
+
readonly INITIAL: "INITIAL";
|
|
103
|
+
readonly WEBSOCKET_SERVER_CONNECTED: "WEBSOCKET_SERVER_CONNECTED";
|
|
104
|
+
};
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appComponent = exports.marketplaceDistribution = exports.privateDistribution = exports.oAuth = exports.staticAuth = exports.APP_INSTALLATION_STATES = exports.LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES = exports.LOCAL_DEV_UI_MESSAGE_SEND_TYPES = exports.FEATURES = exports.APP_AUTH_TYPES = exports.APP_DISTRIBUTION_TYPES = exports.IR_COMPONENT_TYPES = exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
|
|
3
|
+
exports.LOCAL_DEV_SERVER_MESSAGE_TYPES = exports.appComponent = exports.marketplaceDistribution = exports.privateDistribution = exports.oAuth = exports.staticAuth = exports.APP_INSTALLATION_STATES = exports.LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES = exports.LOCAL_DEV_UI_MESSAGE_SEND_TYPES = exports.FEATURES = exports.APP_AUTH_TYPES = exports.APP_DISTRIBUTION_TYPES = exports.IR_COMPONENT_TYPES = exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
|
|
4
4
|
exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
|
|
5
5
|
exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
|
|
6
6
|
exports.FEEDBACK_INTERVAL = 10;
|
|
@@ -93,3 +93,7 @@ exports.oAuth = 'oauth';
|
|
|
93
93
|
exports.privateDistribution = 'private';
|
|
94
94
|
exports.marketplaceDistribution = 'marketplace';
|
|
95
95
|
exports.appComponent = 'app';
|
|
96
|
+
exports.LOCAL_DEV_SERVER_MESSAGE_TYPES = {
|
|
97
|
+
INITIAL: 'INITIAL',
|
|
98
|
+
WEBSOCKET_SERVER_CONNECTED: 'WEBSOCKET_SERVER_CONNECTED',
|
|
99
|
+
};
|
|
@@ -18,6 +18,7 @@ declare class AppDevModeInterface {
|
|
|
18
18
|
private fetchAppData;
|
|
19
19
|
private checkMarketplaceAppInstalls;
|
|
20
20
|
private checkTestAccountAppInstallation;
|
|
21
|
+
private setUpLocalDevServerMessageListeners;
|
|
21
22
|
setup(args: any): Promise<void>;
|
|
22
23
|
start(): Promise<void>;
|
|
23
24
|
fileChange(filePath: string, event: string): Promise<void>;
|
|
@@ -133,6 +133,13 @@ class AppDevModeInterface {
|
|
|
133
133
|
await (0, installAppPrompt_1.installAppPrompt)(installUrl, isReinstall);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
setUpLocalDevServerMessageListeners() {
|
|
137
|
+
this.localDevState.addListener('devServerMessage', message => {
|
|
138
|
+
if (message === constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED) {
|
|
139
|
+
this.checkTestAccountAppInstallation();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
136
143
|
// @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
|
|
137
144
|
// In the future, update UIE Dev Server to use LocalDevState
|
|
138
145
|
async setup(args) {
|
|
@@ -149,6 +156,7 @@ class AppDevModeInterface {
|
|
|
149
156
|
catch (e) {
|
|
150
157
|
(0, index_1.logError)(e);
|
|
151
158
|
}
|
|
159
|
+
this.setUpLocalDevServerMessageListeners();
|
|
152
160
|
return ui_extensions_dev_server_1.DevModeUnifiedInterface.setup(args);
|
|
153
161
|
}
|
|
154
162
|
async start() {
|
|
@@ -101,6 +101,7 @@ class LocalDevLogger {
|
|
|
101
101
|
logger_2.uiLogger.log('');
|
|
102
102
|
logger_2.uiLogger.log(en_1.lib.LocalDevManager.running(this.state.projectConfig.name, (0, ui_1.uiAccountDescription)(this.state.targetProjectAccountId)));
|
|
103
103
|
logger_2.uiLogger.log(en_1.lib.LocalDevManager.viewProjectLink(this.state.projectConfig.name, this.state.targetProjectAccountId));
|
|
104
|
+
logger_2.uiLogger.log(en_1.lib.LocalDevManager.viewLocalDevUILink(this.state.targetTestingAccountId));
|
|
104
105
|
logger_2.uiLogger.log('');
|
|
105
106
|
logger_2.uiLogger.log(en_1.lib.LocalDevManager.quitHelper);
|
|
106
107
|
(0, ui_1.uiLine)();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
2
|
import LocalDevState from './LocalDevState';
|
|
3
3
|
import LocalDevLogger from './LocalDevLogger';
|
|
4
|
-
import { LocalDevStateConstructorOptions, LocalDevStateListener } from '../../../types/LocalDev';
|
|
4
|
+
import { LocalDevStateConstructorOptions, LocalDevStateListener, LocalDevServerMessage } from '../../../types/LocalDev';
|
|
5
5
|
declare class LocalDevProcess {
|
|
6
6
|
private state;
|
|
7
7
|
private _logger;
|
|
@@ -29,5 +29,6 @@ declare class LocalDevProcess {
|
|
|
29
29
|
stop(showProgress?: boolean): Promise<void>;
|
|
30
30
|
uploadProject(): Promise<boolean>;
|
|
31
31
|
addStateListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>, callOnInit?: boolean): void;
|
|
32
|
+
sendDevServerMessage(message: LocalDevServerMessage): void;
|
|
32
33
|
}
|
|
33
34
|
export default LocalDevProcess;
|
|
@@ -194,5 +194,8 @@ class LocalDevProcess {
|
|
|
194
194
|
addStateListener(key, listener, callOnInit = false) {
|
|
195
195
|
this.state.addListener(key, listener, callOnInit);
|
|
196
196
|
}
|
|
197
|
+
sendDevServerMessage(message) {
|
|
198
|
+
this.state.devServerMessage = message;
|
|
199
|
+
}
|
|
197
200
|
}
|
|
198
201
|
exports.default = LocalDevProcess;
|
|
@@ -2,7 +2,7 @@ import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
|
2
2
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
3
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
4
|
import { ProjectConfig } from '../../../types/Projects';
|
|
5
|
-
import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData } from '../../../types/LocalDev';
|
|
5
|
+
import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData, LocalDevServerMessage } from '../../../types/LocalDev';
|
|
6
6
|
declare class LocalDevState {
|
|
7
7
|
private _targetProjectAccountId;
|
|
8
8
|
private _targetTestingAccountId;
|
|
@@ -18,6 +18,7 @@ declare class LocalDevState {
|
|
|
18
18
|
private _listeners;
|
|
19
19
|
private _configFilesUpdatedSinceLastUpload;
|
|
20
20
|
private _appData;
|
|
21
|
+
private _devServerMessage;
|
|
21
22
|
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }: LocalDevStateConstructorOptions);
|
|
22
23
|
private runListeners;
|
|
23
24
|
get targetProjectAccountId(): number;
|
|
@@ -42,6 +43,8 @@ declare class LocalDevState {
|
|
|
42
43
|
get appData(): Record<string, AppLocalDevData>;
|
|
43
44
|
getAppDataByUid(uid: string): AppLocalDevData | undefined;
|
|
44
45
|
setAppDataForUid(uid: string, appData: AppLocalDevData): void;
|
|
46
|
+
get devServerMessage(): string;
|
|
47
|
+
set devServerMessage(message: LocalDevServerMessage);
|
|
45
48
|
addListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>, callOnInit?: boolean): void;
|
|
46
49
|
}
|
|
47
50
|
export default LocalDevState;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../constants");
|
|
3
4
|
class LocalDevState {
|
|
4
5
|
_targetProjectAccountId;
|
|
5
6
|
_targetTestingAccountId;
|
|
@@ -15,6 +16,7 @@ class LocalDevState {
|
|
|
15
16
|
_listeners;
|
|
16
17
|
_configFilesUpdatedSinceLastUpload;
|
|
17
18
|
_appData;
|
|
19
|
+
_devServerMessage;
|
|
18
20
|
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }) {
|
|
19
21
|
this._targetProjectAccountId = targetProjectAccountId;
|
|
20
22
|
this._targetTestingAccountId = targetTestingAccountId;
|
|
@@ -29,6 +31,7 @@ class LocalDevState {
|
|
|
29
31
|
this._env = env;
|
|
30
32
|
this._configFilesUpdatedSinceLastUpload = new Set();
|
|
31
33
|
this._appData = {};
|
|
34
|
+
this._devServerMessage = constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.INITIAL;
|
|
32
35
|
this._listeners = {};
|
|
33
36
|
}
|
|
34
37
|
runListeners(key) {
|
|
@@ -96,6 +99,13 @@ class LocalDevState {
|
|
|
96
99
|
this._appData[uid] = appData;
|
|
97
100
|
this.runListeners('appData');
|
|
98
101
|
}
|
|
102
|
+
get devServerMessage() {
|
|
103
|
+
return this._devServerMessage;
|
|
104
|
+
}
|
|
105
|
+
set devServerMessage(message) {
|
|
106
|
+
this._devServerMessage = message;
|
|
107
|
+
this.runListeners('devServerMessage');
|
|
108
|
+
}
|
|
99
109
|
addListener(key, listener, callOnInit = false) {
|
|
100
110
|
if (!this._listeners[key]) {
|
|
101
111
|
this._listeners[key] = [];
|
|
@@ -13,8 +13,8 @@ class LocalDevWebsocketServer {
|
|
|
13
13
|
debug;
|
|
14
14
|
localDevProcess;
|
|
15
15
|
ALLOWED_ORIGINS = [
|
|
16
|
-
'https://hubspot.com',
|
|
17
|
-
'https://hubspotqa.com',
|
|
16
|
+
'https://app.hubspot.com',
|
|
17
|
+
'https://app.hubspotqa.com',
|
|
18
18
|
'https://local.hubspot.com',
|
|
19
19
|
'https://local.hubspotqa.com',
|
|
20
20
|
];
|
|
@@ -119,6 +119,7 @@ class LocalDevWebsocketServer {
|
|
|
119
119
|
this.sendProjectData();
|
|
120
120
|
this.setupMessageHandlers();
|
|
121
121
|
this.setupStateListeners();
|
|
122
|
+
this.localDevProcess.sendDevServerMessage(constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED);
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
shutdown() {
|
package/lib/projects/urls.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare function getProjectSettingsUrl(projectName: string, accountId: nu
|
|
|
3
3
|
export declare function getProjectActivityUrl(projectName: string, accountId: number): string;
|
|
4
4
|
export declare function getProjectBuildDetailUrl(projectName: string, buildId: number, accountId: number): string;
|
|
5
5
|
export declare function getProjectDeployDetailUrl(projectName: string, deployId: number, accountId: number): string;
|
|
6
|
+
export declare function getLocalDevUiUrl(accountId: number): string;
|
package/lib/projects/urls.js
CHANGED
|
@@ -5,12 +5,15 @@ exports.getProjectSettingsUrl = getProjectSettingsUrl;
|
|
|
5
5
|
exports.getProjectActivityUrl = getProjectActivityUrl;
|
|
6
6
|
exports.getProjectBuildDetailUrl = getProjectBuildDetailUrl;
|
|
7
7
|
exports.getProjectDeployDetailUrl = getProjectDeployDetailUrl;
|
|
8
|
+
exports.getLocalDevUiUrl = getLocalDevUiUrl;
|
|
8
9
|
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
9
10
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
11
|
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
12
|
+
function getBaseUrl(accountId) {
|
|
13
|
+
return (0, urls_1.getHubSpotWebsiteOrigin)((0, config_1.getEnv)(accountId) === 'qa' ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD);
|
|
14
|
+
}
|
|
11
15
|
function getProjectHomeUrl(accountId) {
|
|
12
|
-
|
|
13
|
-
return `${baseUrl}/developer-projects/${accountId}`;
|
|
16
|
+
return `${getBaseUrl(accountId)}/developer-projects/${accountId}`;
|
|
14
17
|
}
|
|
15
18
|
function getProjectDetailUrl(projectName, accountId) {
|
|
16
19
|
if (!projectName)
|
|
@@ -31,3 +34,6 @@ function getProjectBuildDetailUrl(projectName, buildId, accountId) {
|
|
|
31
34
|
function getProjectDeployDetailUrl(projectName, deployId, accountId) {
|
|
32
35
|
return `${getProjectActivityUrl(projectName, accountId)}/deploy/${deployId}`;
|
|
33
36
|
}
|
|
37
|
+
function getLocalDevUiUrl(accountId) {
|
|
38
|
+
return `${getBaseUrl(accountId)}/developer-projects-local-dev/${accountId}`;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.5.2-beta.
|
|
3
|
+
"version": "7.5.2-beta.1",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@hubspot/local-dev-lib": "3.7.1",
|
|
9
9
|
"@hubspot/project-parsing-lib": "0.3.0",
|
|
10
|
-
"@hubspot/serverless-dev-runtime": "7.0.
|
|
10
|
+
"@hubspot/serverless-dev-runtime": "7.0.6",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.9.2",
|
|
13
13
|
"archiver": "7.0.1",
|
package/types/LocalDev.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
|
4
4
|
import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
|
|
5
5
|
import { ProjectConfig } from './Projects';
|
|
6
6
|
import LocalDevState from '../lib/projects/localDev/LocalDevState';
|
|
7
|
-
import { APP_INSTALLATION_STATES } from '../lib/constants';
|
|
7
|
+
import { APP_INSTALLATION_STATES, LOCAL_DEV_SERVER_MESSAGE_TYPES } from '../lib/constants';
|
|
8
8
|
export type LocalDevStateConstructorOptions = {
|
|
9
9
|
targetProjectAccountId: number;
|
|
10
10
|
targetTestingAccountId: number;
|
|
@@ -31,3 +31,4 @@ export type AppLocalDevData = {
|
|
|
31
31
|
name: string;
|
|
32
32
|
installationState: ValueOf<typeof APP_INSTALLATION_STATES>;
|
|
33
33
|
};
|
|
34
|
+
export type LocalDevServerMessage = ValueOf<typeof LOCAL_DEV_SERVER_MESSAGE_TYPES>;
|