@hubspot/ui-extensions-dev-server 0.8.38 → 0.8.40

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.
@@ -164,6 +164,9 @@ class DevModeInterface {
164
164
  webSocketPort = portData[constants_1.VITE_DEV_SERVER_ID];
165
165
  }
166
166
  catch (e) {
167
+ if ((e === null || e === void 0 ? void 0 : e.status) === 409) {
168
+ throw new Error('Another instance is already running. To proceed, please stop the existing server and try again.');
169
+ }
167
170
  this.logger.debug('Call to port manager failed, using default ports');
168
171
  }
169
172
  }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const node_fs_1 = __importDefault(require("node:fs"));
17
+ const node_path_1 = __importDefault(require("node:path"));
18
+ const node_util_1 = require("node:util");
19
+ const node_child_process_1 = require("node:child_process");
20
+ const commander_1 = require("commander");
21
+ const ora_1 = __importDefault(require("ora"));
22
+ const chalk_1 = __importDefault(require("chalk"));
23
+ const build_1 = require("../build");
24
+ const program = new commander_1.Command()
25
+ .name('ui-extension-tools')
26
+ .alias('uie')
27
+ .description('Tools for managing and building HubSpot UI Extensions.');
28
+ const buildSteps = {
29
+ lockfile: {
30
+ start: 'Processing lockfile...',
31
+ fn: generateLockfile,
32
+ success: 'Lockfile ready',
33
+ error: 'Error generating lockfile',
34
+ },
35
+ install: {
36
+ start: 'Installing dependencies...',
37
+ fn: installDeps,
38
+ success: 'Dependencies installed',
39
+ error: 'Error installing dependencies',
40
+ },
41
+ build: {
42
+ start: 'Building remote extension...',
43
+ fn: build,
44
+ success: 'Extension build complete',
45
+ error: 'Error building extension',
46
+ },
47
+ };
48
+ program
49
+ .command('build <module>', { isDefault: true })
50
+ .description('Build extension source code.')
51
+ .action((module) => __awaiter(void 0, void 0, void 0, function* () {
52
+ const options = getOptions(module);
53
+ yield runCommand('lockfile', options);
54
+ yield runCommand('install', options);
55
+ yield runCommand('build', options);
56
+ }));
57
+ program.parse(process.argv);
58
+ function runCommand(command, options) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const { start, fn, success, error } = buildSteps[command];
61
+ const spinner = (0, ora_1.default)();
62
+ try {
63
+ spinner.start(start);
64
+ yield fn(options);
65
+ spinner.succeed(chalk_1.default.green(success));
66
+ }
67
+ catch (err) {
68
+ spinner.fail(chalk_1.default.red(error));
69
+ process.exit(1);
70
+ }
71
+ finally {
72
+ spinner.stop();
73
+ }
74
+ });
75
+ }
76
+ // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L59-L63
77
+ function build({ extensionRoot, extensionDist, entrypoint }) {
78
+ return (0, build_1.remoteBuild)(extensionRoot, entrypoint, extensionDist);
79
+ }
80
+ // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L53-L57
81
+ function installDeps(options) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ yield execAsync('npm ci --ignore-scripts --no-audit --no-optional --no-fund', options);
84
+ });
85
+ }
86
+ // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L131-L136
87
+ function generateLockfile(options) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const { extensionRoot, spinner } = options;
90
+ if (node_fs_1.default.existsSync(node_path_1.default.join(extensionRoot, 'package-lock.json'))) {
91
+ spinner.info('Existing lockfile found, skipping generation');
92
+ }
93
+ else {
94
+ spinner.info('No lockfile found, generating...');
95
+ yield execAsync('npm install --package-lock-only', options);
96
+ }
97
+ });
98
+ }
99
+ function getOptions(modulePath) {
100
+ const entrypoint = node_path_1.default.isAbsolute(modulePath)
101
+ ? modulePath
102
+ : node_path_1.default.resolve(process.cwd(), modulePath);
103
+ const extensionRoot = node_path_1.default.dirname(entrypoint);
104
+ const extensionDist = node_path_1.default.join(extensionRoot, 'dist');
105
+ const spinner = (0, ora_1.default)();
106
+ return {
107
+ extensionRoot,
108
+ extensionDist,
109
+ entrypoint,
110
+ spinner,
111
+ };
112
+ }
113
+ function execAsync(command, options) {
114
+ return (0, node_util_1.promisify)(node_child_process_1.exec)(command, { cwd: options.extensionRoot });
115
+ }
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions-dev-server",
3
- "version": "0.8.38",
3
+ "version": "0.8.40",
4
4
  "description": "",
5
+ "bin": {
6
+ "uie": "./dist/lib/bin/cli.js"
7
+ },
5
8
  "scripts": {
6
9
  "test": "jest",
7
10
  "clean": "rm -rf dist/",
@@ -24,12 +27,15 @@
24
27
  ],
25
28
  "license": "MIT",
26
29
  "dependencies": {
27
- "@hubspot/app-functions-dev-server": "0.8.38",
30
+ "@hubspot/app-functions-dev-server": "0.8.40",
31
+ "chalk": "^5.4.1",
32
+ "commander": "^13.0.0",
28
33
  "cors": "^2.8.5",
29
34
  "detect-port": "1.5.1",
30
35
  "estraverse": "^5.3.0",
31
36
  "express": "^4.18.2",
32
37
  "inquirer": "8.2.0",
38
+ "ora": "^8.1.1",
33
39
  "vite": "^4.4.9"
34
40
  },
35
41
  "devDependencies": {
@@ -63,5 +69,5 @@
63
69
  "optional": true
64
70
  }
65
71
  },
66
- "gitHead": "87aa6e40049142bccafd175446fbd7d5c08caab6"
72
+ "gitHead": "1f4550a901eeba1e56943ef50c6ea7af30f95bc1"
67
73
  }