@squiz/dxp-cli-next 5.17.1-develop.1 → 5.18.0-develop.2

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
@@ -50,9 +50,6 @@ const deployCommand = new commander_1.Command()
50
50
  .argument('<source>', 'folder containing a manifest.json file')
51
51
  .addOption(new commander_1.Option('-cu, --component-service-url <string>', 'Override the component service url from login').env('COMPONENT_SERVICE_URL'))
52
52
  .addOption(new commander_1.Option('-t, --tenant <string>', 'Tenant ID to deploy to. If not provided will use configured tenant from login'))
53
- .addOption(new commander_1.Option('--type <type>', 'Type of component to deploy')
54
- .choices(['edge', 'sandbox'])
55
- .default('sandbox'))
56
53
  .action((source, options) => __awaiter(void 0, void 0, void 0, function* () {
57
54
  var _a, _b;
58
55
  if (process.env.COMPONENT_SERVICE_URL !== undefined) {
@@ -67,19 +64,19 @@ const deployCommand = new commander_1.Command()
67
64
  console.warn(cli_color_1.default.yellow('WARN: Component service URL no longer requires /v1/ suffix'));
68
65
  }
69
66
  try {
67
+ const def = yield definitions_1.ComponentDefinition.load(source);
68
+ if (!def) {
69
+ throw new Error('Invalid definition');
70
+ }
70
71
  const componentServiceUrl = ((_b = options.componentServiceUrl) === null || _b === void 0 ? void 0 : _b.replace(/v1\/?$/, '')) ||
71
72
  (yield buildComponentServiceUrl(options.tenant));
72
- if (options.type === 'sandbox') {
73
+ if (def.type === 'server') {
73
74
  return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService.client, componentServiceUrl, source);
74
75
  }
75
- if (options.type === 'edge') {
76
+ if (def.type === 'edge') {
76
77
  if (process.env.FEATURE_EDGE_COMPONENTS !== 'true') {
77
78
  throw new Error('Component type "edge" is still in development. Run with environment variable "FEATURE_EDGE_COMPONENTS=true" to enable');
78
79
  }
79
- const def = yield definitions_1.ComponentDefinition.load(source);
80
- if (!def) {
81
- throw new Error('Invalid definition');
82
- }
83
80
  const dxpCacheDirPath = path.resolve(source, '.dxp');
84
81
  yield fs.mkdir(dxpCacheDirPath, { recursive: true });
85
82
  const outputDir = yield fs.mkdtemp(path.resolve(dxpCacheDirPath, 'cmp-'));
@@ -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,5 +9,6 @@ export declare class ComponentDefinition {
9
9
  entry: string;
10
10
  };
11
11
  get manifestPath(): string;
12
+ get type(): "edge" | "server";
12
13
  copyManifest(copyDir: string): Promise<void>;
13
14
  }
@@ -62,6 +62,9 @@ class ComponentDefinition {
62
62
  get manifestPath() {
63
63
  return path.resolve(this.baseDir, 'manifest.json');
64
64
  }
65
+ get type() {
66
+ return this.definition.type;
67
+ }
65
68
  copyManifest(copyDir) {
66
69
  return __awaiter(this, void 0, void 0, function* () {
67
70
  yield fs.copyFile(this.manifestPath, path.resolve(copyDir, 'manifest.json'));
@@ -85,5 +88,5 @@ const BasicDefinition = zod_1.z.object({
85
88
  entry: zod_1.z.string(),
86
89
  }))
87
90
  .refine(fns => new Set(fns.map(f => f.name)).size === fns.length),
88
- type: zod_1.z.enum(['edge', 'sandbox']).optional().default('sandbox'),
91
+ type: zod_1.z.enum(['edge', 'server']).optional().default('server'),
89
92
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.17.1-develop.1",
3
+ "version": "5.18.0-develop.2",
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",