@squiz/dxp-cli-next 5.17.0 → 5.18.0-develop.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/lib/cmp/deploy.js CHANGED
@@ -84,8 +84,8 @@ const deployCommand = new commander_1.Command()
84
84
  yield fs.mkdir(dxpCacheDirPath, { recursive: true });
85
85
  const outputDir = yield fs.mkdtemp(path.resolve(dxpCacheDirPath, 'cmp-'));
86
86
  yield (0, compiler_1.compileUserCode)(def.mainEntryFilePath, path.join(outputDir, 'userCode.js'));
87
- yield fs.copyFile(def.manifestPath, path.resolve(outputDir, 'manifest.json'));
88
- return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService, componentServiceUrl, outputDir);
87
+ yield def.copyManifest(outputDir);
88
+ return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService.client, componentServiceUrl, outputDir);
89
89
  }
90
90
  }
91
91
  catch (error) {
@@ -112,6 +112,6 @@ exports.default = deployCommand;
112
112
  function buildComponentServiceUrl(tenantID) {
113
113
  return __awaiter(this, void 0, void 0, function* () {
114
114
  const existingConfig = yield (0, ApplicationConfig_1.fetchApplicationConfig)(tenantID);
115
- return `${existingConfig.baseUrl}/__dxp/${existingConfig.region}/components-management/${existingConfig.tenant}/`;
115
+ return `${existingConfig.baseUrl}/__dxp/${existingConfig.region}/components-management/${existingConfig.tenant}`;
116
116
  });
117
117
  }
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ export declare const buildDevModeUICommand: () => Command;
3
+ declare const devModeUICommand: Command;
4
+ export default devModeUICommand;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.buildDevModeUICommand = void 0;
13
+ const local_component_dev_ui_1 = require("@squiz/local-component-dev-ui");
14
+ const commander_1 = require("commander");
15
+ const MIN_PORT = 1024;
16
+ const MAX_PORT = 65535;
17
+ const buildDevModeUICommand = () => new commander_1.Command()
18
+ .name('dev-ui')
19
+ .description('A local component UI for developing new components')
20
+ .addHelpText('after', `
21
+
22
+ The logs are currently \`bunyan\` formatted and should be piped into the bunyan cli:
23
+ $ dxp-next cmp dev-ui <source> | npx bunyan
24
+ `)
25
+ .argument('<source>', 'folder containing the template files in development')
26
+ .addOption(new commander_1.Option('-p, --port <number>', 'Define port the webserver runs on')
27
+ .default(3000)
28
+ .argParser(v => {
29
+ const parsedPort = Number(v);
30
+ if (isNaN(parsedPort) ||
31
+ MIN_PORT > parsedPort ||
32
+ parsedPort > MAX_PORT) {
33
+ throw new commander_1.InvalidArgumentError(`Port must be a number between ${MIN_PORT}-${MAX_PORT}`);
34
+ }
35
+ return parsedPort;
36
+ }))
37
+ .addOption(new commander_1.Option('-l, --logging-format <string>', 'Format of log output')
38
+ .choices(['human', 'json'])
39
+ .default('human'))
40
+ .action((source, options) => __awaiter(void 0, void 0, void 0, function* () {
41
+ const input = {
42
+ port: options.port,
43
+ loggingFormat: options.loggingFormat,
44
+ noBrowser: true,
45
+ };
46
+ // Starts the dev-mode server with the development UI
47
+ yield (0, local_component_dev_ui_1.startLocalDevelopmentUIServer)(source, input);
48
+ }));
49
+ exports.buildDevModeUICommand = buildDevModeUICommand;
50
+ const devModeUICommand = (0, exports.buildDevModeUICommand)();
51
+ exports.default = devModeUICommand;
package/lib/cmp/index.js CHANGED
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const commander_1 = require("commander");
7
7
  const deploy_1 = __importDefault(require("./deploy"));
8
8
  const dev_mode_1 = __importDefault(require("./dev-mode"));
9
+ const dev_mode_ui_1 = __importDefault(require("./dev-mode-ui"));
9
10
  const init_1 = __importDefault(require("./init"));
10
11
  const cmpCommand = new commander_1.Command('cmp');
11
12
  cmpCommand
12
13
  .description('Component Service Commands')
13
14
  .addCommand(deploy_1.default)
14
15
  .addCommand(dev_mode_1.default)
16
+ .addCommand(dev_mode_ui_1.default)
15
17
  .addCommand(init_1.default);
16
18
  exports.default = cmpCommand;
@@ -9,4 +9,5 @@ export declare class ComponentDefinition {
9
9
  entry: string;
10
10
  };
11
11
  get manifestPath(): string;
12
+ copyManifest(copyDir: string): Promise<void>;
12
13
  }
@@ -62,6 +62,19 @@ class ComponentDefinition {
62
62
  get manifestPath() {
63
63
  return path.resolve(this.baseDir, 'manifest.json');
64
64
  }
65
+ copyManifest(copyDir) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ yield fs.copyFile(this.manifestPath, path.resolve(copyDir, 'manifest.json'));
68
+ const manifest = yield fs.readFile(path.resolve(copyDir, 'manifest.json'), {
69
+ encoding: 'utf-8',
70
+ });
71
+ const definition = JSON.parse(manifest);
72
+ definition.functions = definition.functions.map((func) => {
73
+ return Object.assign(Object.assign({}, func), { entry: 'userCode.js' });
74
+ });
75
+ return yield fs.writeFile(path.resolve(copyDir, 'manifest.json'), JSON.stringify(definition));
76
+ });
77
+ }
65
78
  }
66
79
  exports.ComponentDefinition = ComponentDefinition;
67
80
  const BasicDefinition = zod_1.z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.17.0",
3
+ "version": "5.18.0-develop.1",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },
@@ -42,6 +42,8 @@
42
42
  "@apidevtools/swagger-parser": "10.1.0",
43
43
  "@squiz/component-cli-lib": "1.67.0",
44
44
  "@squiz/dxp-porter-shared": "0.4.0",
45
+ "@squiz/local-component-dev-ui": "^0.2.2",
46
+ "@squiz/render-runtime-lib": "^1.69.0",
45
47
  "axios": "1.1.3",
46
48
  "cli-color": "2.0.3",
47
49
  "commander": "9.4.0",