@squiz/dxp-cli-next 5.18.0-develop.2 → 5.19.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
|
@@ -82,6 +82,8 @@ const deployCommand = new commander_1.Command()
|
|
|
82
82
|
const outputDir = yield fs.mkdtemp(path.resolve(dxpCacheDirPath, 'cmp-'));
|
|
83
83
|
yield (0, compiler_1.compileUserCode)(def.mainEntryFilePath, path.join(outputDir, 'userCode.js'));
|
|
84
84
|
yield def.copyManifest(outputDir);
|
|
85
|
+
yield def.copyPreviewFiles(outputDir);
|
|
86
|
+
yield def.copyMockedUriFiles(outputDir);
|
|
85
87
|
return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService.client, componentServiceUrl, outputDir);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -11,4 +11,6 @@ export declare class ComponentDefinition {
|
|
|
11
11
|
get manifestPath(): string;
|
|
12
12
|
get type(): "edge" | "server";
|
|
13
13
|
copyManifest(copyDir: string): Promise<void>;
|
|
14
|
+
copyPreviewFiles(copyDir: string): Promise<void>;
|
|
15
|
+
copyMockedUriFiles(copyDir: string): Promise<void>;
|
|
14
16
|
}
|
|
@@ -78,6 +78,35 @@ class ComponentDefinition {
|
|
|
78
78
|
return yield fs.writeFile(path.resolve(copyDir, 'manifest.json'), JSON.stringify(definition));
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
+
copyPreviewFiles(copyDir) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (!this.definition.previews) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
for (const [_previewKey, value] of Object.entries(this.definition.previews)) {
|
|
87
|
+
for (const [_funcName, funcInput] of Object.entries(value.functionData)) {
|
|
88
|
+
if (funcInput.inputData.type === 'file') {
|
|
89
|
+
yield fs.copyFile(path.resolve(this.baseDir, funcInput.inputData.path), path.resolve(copyDir, funcInput.inputData.path));
|
|
90
|
+
if (funcInput.wrapper) {
|
|
91
|
+
yield fs.copyFile(path.resolve(this.baseDir, funcInput.wrapper.path), path.resolve(copyDir, funcInput.wrapper.path));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
copyMockedUriFiles(copyDir) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
if (!this.definition.mockedUris) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const [_mockedUriName, mockedUriValue] of Object.entries(this.definition.mockedUris)) {
|
|
104
|
+
if (mockedUriValue.type === 'file') {
|
|
105
|
+
yield fs.copyFile(path.resolve(this.baseDir, mockedUriValue.path), path.resolve(copyDir, mockedUriValue.path));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
81
110
|
}
|
|
82
111
|
exports.ComponentDefinition = ComponentDefinition;
|
|
83
112
|
const BasicDefinition = zod_1.z.object({
|
|
@@ -89,4 +118,38 @@ const BasicDefinition = zod_1.z.object({
|
|
|
89
118
|
}))
|
|
90
119
|
.refine(fns => new Set(fns.map(f => f.name)).size === fns.length),
|
|
91
120
|
type: zod_1.z.enum(['edge', 'server']).optional().default('server'),
|
|
121
|
+
mockedUris: zod_1.z
|
|
122
|
+
.record(zod_1.z.string(), zod_1.z.discriminatedUnion('type', [
|
|
123
|
+
zod_1.z.object({
|
|
124
|
+
type: zod_1.z.literal('inline'),
|
|
125
|
+
value: zod_1.z.record(zod_1.z.any()),
|
|
126
|
+
}),
|
|
127
|
+
zod_1.z.object({
|
|
128
|
+
type: zod_1.z.literal('file'),
|
|
129
|
+
path: zod_1.z.string(),
|
|
130
|
+
}),
|
|
131
|
+
]))
|
|
132
|
+
.optional(),
|
|
133
|
+
previews: zod_1.z
|
|
134
|
+
.record(zod_1.z.object({
|
|
135
|
+
functionData: zod_1.z.record(zod_1.z.object({
|
|
136
|
+
inputData: zod_1.z.discriminatedUnion('type', [
|
|
137
|
+
zod_1.z.object({
|
|
138
|
+
type: zod_1.z.literal('inline'),
|
|
139
|
+
value: zod_1.z.record(zod_1.z.any()),
|
|
140
|
+
}),
|
|
141
|
+
zod_1.z.object({
|
|
142
|
+
type: zod_1.z.literal('file'),
|
|
143
|
+
path: zod_1.z.string(),
|
|
144
|
+
}),
|
|
145
|
+
]),
|
|
146
|
+
headers: zod_1.z.record(zod_1.z.string()).optional(),
|
|
147
|
+
wrapper: zod_1.z
|
|
148
|
+
.object({
|
|
149
|
+
path: zod_1.z.string(),
|
|
150
|
+
})
|
|
151
|
+
.optional(),
|
|
152
|
+
})),
|
|
153
|
+
}))
|
|
154
|
+
.optional(),
|
|
92
155
|
});
|