@squiz/dxp-cli-next 5.18.0-develop.1 → 5.18.0
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 (
|
|
73
|
+
if (def.type === 'server') {
|
|
73
74
|
return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService.client, componentServiceUrl, source);
|
|
74
75
|
}
|
|
75
|
-
if (
|
|
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-'));
|
|
@@ -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', '
|
|
91
|
+
type: zod_1.z.enum(['edge', 'server']).optional().default('server'),
|
|
89
92
|
});
|