@vendure/ui-devkit 2.2.0-next.2 → 2.2.0-next.4
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/client/devkit-client-api.d.ts +109 -109
- package/client/index.d.ts +1 -1
- package/compiler/compile.d.ts +9 -9
- package/compiler/compile.js +261 -261
- package/compiler/constants.d.ts +6 -6
- package/compiler/constants.js +9 -9
- package/compiler/helpers.d.ts +25 -25
- package/compiler/helpers.js +49 -49
- package/compiler/index.d.ts +3 -3
- package/compiler/index.js +19 -19
- package/compiler/scaffold.d.ts +4 -4
- package/compiler/scaffold.js +237 -237
- package/compiler/translations.d.ts +12 -12
- package/compiler/translations.js +136 -136
- package/compiler/types.d.ts +419 -419
- package/compiler/types.js +2 -2
- package/compiler/utils.d.ts +34 -34
- package/compiler/utils.js +137 -137
- package/package.json +6 -6
package/compiler/compile.js
CHANGED
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.compileUiExtensions = void 0;
|
|
27
|
-
const child_process_1 = require("child_process");
|
|
28
|
-
const chokidar_1 = require("chokidar");
|
|
29
|
-
const fs = __importStar(require("fs-extra"));
|
|
30
|
-
const path = __importStar(require("path"));
|
|
31
|
-
const constants_1 = require("./constants");
|
|
32
|
-
const scaffold_1 = require("./scaffold");
|
|
33
|
-
const translations_1 = require("./translations");
|
|
34
|
-
const utils_1 = require("./utils");
|
|
35
|
-
/**
|
|
36
|
-
* @description
|
|
37
|
-
* Compiles the Admin UI app with the specified extensions.
|
|
38
|
-
*
|
|
39
|
-
* @docsCategory UiDevkit
|
|
40
|
-
*/
|
|
41
|
-
function compileUiExtensions(options) {
|
|
42
|
-
const { devMode, watchPort, command } = options;
|
|
43
|
-
const usingYarn = command && command === 'npm' ? false : (0, utils_1.shouldUseYarn)();
|
|
44
|
-
if (devMode) {
|
|
45
|
-
return runWatchMode({
|
|
46
|
-
watchPort: watchPort || 4200,
|
|
47
|
-
usingYarn,
|
|
48
|
-
...options,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return runCompileMode({
|
|
53
|
-
usingYarn,
|
|
54
|
-
...options,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.compileUiExtensions = compileUiExtensions;
|
|
59
|
-
function runCompileMode({ outputPath, baseHref, extensions, usingYarn, additionalProcessArguments, ngCompilerPath, }) {
|
|
60
|
-
const distPath = path.join(outputPath, 'dist');
|
|
61
|
-
const compile = () => new Promise(async (resolve, reject) => {
|
|
62
|
-
await (0, scaffold_1.setupScaffold)(outputPath, extensions);
|
|
63
|
-
await (0, scaffold_1.setBaseHref)(outputPath, baseHref || constants_1.DEFAULT_BASE_HREF);
|
|
64
|
-
let cmd = usingYarn ? 'yarn' : 'npm';
|
|
65
|
-
let commandArgs = ['run', 'build'];
|
|
66
|
-
if (ngCompilerPath) {
|
|
67
|
-
cmd = 'node';
|
|
68
|
-
commandArgs = [ngCompilerPath, 'build', '--configuration production'];
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
if (!usingYarn) {
|
|
72
|
-
// npm requires `--` before any command line args being passed to a script
|
|
73
|
-
commandArgs.splice(2, 0, '--');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
console.log(`Running ${cmd} ${commandArgs.join(' ')}`);
|
|
77
|
-
const buildProcess = (0, child_process_1.spawn)(cmd, [...commandArgs, ...buildProcessArguments(additionalProcessArguments)], {
|
|
78
|
-
cwd: outputPath,
|
|
79
|
-
shell: true,
|
|
80
|
-
stdio: 'inherit',
|
|
81
|
-
});
|
|
82
|
-
buildProcess.on('close', code => {
|
|
83
|
-
if (code !== 0) {
|
|
84
|
-
reject(code);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
resolve();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
return {
|
|
92
|
-
path: distPath,
|
|
93
|
-
compile,
|
|
94
|
-
route: baseHrefToRoute(baseHref || constants_1.DEFAULT_BASE_HREF),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function runWatchMode({ outputPath, baseHref, watchPort, extensions, usingYarn, additionalProcessArguments, ngCompilerPath, }) {
|
|
98
|
-
const devkitPath = require.resolve('@vendure/ui-devkit');
|
|
99
|
-
let buildProcess;
|
|
100
|
-
let watcher;
|
|
101
|
-
let close = () => {
|
|
102
|
-
/* */
|
|
103
|
-
};
|
|
104
|
-
const compile = () => new Promise(async (resolve, reject) => {
|
|
105
|
-
await (0, scaffold_1.setupScaffold)(outputPath, extensions);
|
|
106
|
-
await (0, scaffold_1.setBaseHref)(outputPath, baseHref || constants_1.DEFAULT_BASE_HREF);
|
|
107
|
-
const adminUiExtensions = extensions.filter(utils_1.isAdminUiExtension);
|
|
108
|
-
const normalizedExtensions = (0, utils_1.normalizeExtensions)(adminUiExtensions);
|
|
109
|
-
const globalStylesExtensions = extensions.filter(utils_1.isGlobalStylesExtension);
|
|
110
|
-
const staticAssetExtensions = extensions.filter(utils_1.isStaticAssetExtension);
|
|
111
|
-
const allTranslationFiles = (0, translations_1.getAllTranslationFiles)(extensions.filter(utils_1.isTranslationExtension));
|
|
112
|
-
let cmd = usingYarn ? 'yarn' : 'npm';
|
|
113
|
-
let commandArgs = ['run', 'start'];
|
|
114
|
-
if (ngCompilerPath) {
|
|
115
|
-
cmd = 'node';
|
|
116
|
-
commandArgs = [ngCompilerPath, 'serve'];
|
|
117
|
-
}
|
|
118
|
-
buildProcess = (0, child_process_1.spawn)(cmd, [
|
|
119
|
-
...commandArgs,
|
|
120
|
-
`--port=${watchPort || 4200}`,
|
|
121
|
-
...buildProcessArguments(additionalProcessArguments),
|
|
122
|
-
], {
|
|
123
|
-
cwd: outputPath,
|
|
124
|
-
shell: true,
|
|
125
|
-
stdio: 'inherit',
|
|
126
|
-
});
|
|
127
|
-
buildProcess.on('close', code => {
|
|
128
|
-
if (code !== 0) {
|
|
129
|
-
reject(code);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
resolve();
|
|
133
|
-
}
|
|
134
|
-
close();
|
|
135
|
-
});
|
|
136
|
-
for (const extension of normalizedExtensions) {
|
|
137
|
-
if (!watcher) {
|
|
138
|
-
watcher = (0, chokidar_1.watch)(extension.extensionPath, {
|
|
139
|
-
depth: 4,
|
|
140
|
-
ignored: '**/node_modules/',
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
watcher.add(extension.extensionPath);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
for (const extension of staticAssetExtensions) {
|
|
148
|
-
for (const staticAssetDef of extension.staticAssets) {
|
|
149
|
-
const assetPath = (0, utils_1.getStaticAssetPath)(staticAssetDef);
|
|
150
|
-
if (!watcher) {
|
|
151
|
-
watcher = (0, chokidar_1.watch)(assetPath);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
watcher.add(assetPath);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
for (const extension of globalStylesExtensions) {
|
|
159
|
-
const globalStylePaths = Array.isArray(extension.globalStyles)
|
|
160
|
-
? extension.globalStyles
|
|
161
|
-
: [extension.globalStyles];
|
|
162
|
-
for (const stylePath of globalStylePaths) {
|
|
163
|
-
if (!watcher) {
|
|
164
|
-
watcher = (0, chokidar_1.watch)(stylePath);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
watcher.add(stylePath);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
for (const translationFiles of Object.values(allTranslationFiles)) {
|
|
172
|
-
if (!translationFiles) {
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
for (const file of translationFiles) {
|
|
176
|
-
if (!watcher) {
|
|
177
|
-
watcher = (0, chokidar_1.watch)(file);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
watcher.add(file);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (watcher) {
|
|
185
|
-
// watch the ui-devkit package files too
|
|
186
|
-
watcher.add(devkitPath);
|
|
187
|
-
}
|
|
188
|
-
if (watcher) {
|
|
189
|
-
const allStaticAssetDefs = staticAssetExtensions.reduce((defs, e) => [...defs, ...(e.staticAssets || [])], []);
|
|
190
|
-
const allGlobalStyles = globalStylesExtensions.reduce((defs, e) => [
|
|
191
|
-
...defs,
|
|
192
|
-
...(Array.isArray(e.globalStyles) ? e.globalStyles : [e.globalStyles]),
|
|
193
|
-
], []);
|
|
194
|
-
watcher.on('change', async (filePath) => {
|
|
195
|
-
const extension = normalizedExtensions.find(e => filePath.includes(e.extensionPath));
|
|
196
|
-
if (extension) {
|
|
197
|
-
const outputDir = path.join(outputPath, constants_1.MODULES_OUTPUT_DIR, extension.id);
|
|
198
|
-
const filePart = path.relative(extension.extensionPath, filePath);
|
|
199
|
-
const dest = path.join(outputDir, filePart);
|
|
200
|
-
await fs.copyFile(filePath, dest);
|
|
201
|
-
}
|
|
202
|
-
if (filePath.includes(devkitPath)) {
|
|
203
|
-
(0, utils_1.copyUiDevkit)(outputPath);
|
|
204
|
-
}
|
|
205
|
-
for (const staticAssetDef of allStaticAssetDefs) {
|
|
206
|
-
const assetPath = (0, utils_1.getStaticAssetPath)(staticAssetDef);
|
|
207
|
-
if (filePath.includes(assetPath)) {
|
|
208
|
-
await (0, utils_1.copyStaticAsset)(outputPath, staticAssetDef);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
for (const stylePath of allGlobalStyles) {
|
|
213
|
-
if (filePath.includes(stylePath)) {
|
|
214
|
-
await (0, scaffold_1.copyGlobalStyleFile)(outputPath, stylePath);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
for (const languageCode of Object.keys(allTranslationFiles)) {
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
220
|
-
const translationFiles = allTranslationFiles[languageCode];
|
|
221
|
-
for (const file of translationFiles) {
|
|
222
|
-
if (filePath.includes(path.normalize(file))) {
|
|
223
|
-
await (0, translations_1.mergeExtensionTranslations)(outputPath, {
|
|
224
|
-
[languageCode]: translationFiles,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
resolve();
|
|
232
|
-
});
|
|
233
|
-
close = () => {
|
|
234
|
-
if (watcher) {
|
|
235
|
-
void watcher.close();
|
|
236
|
-
}
|
|
237
|
-
if (buildProcess) {
|
|
238
|
-
buildProcess.kill();
|
|
239
|
-
}
|
|
240
|
-
process.exit();
|
|
241
|
-
};
|
|
242
|
-
process.on('SIGINT', close);
|
|
243
|
-
return {
|
|
244
|
-
sourcePath: outputPath,
|
|
245
|
-
port: watchPort || 4200,
|
|
246
|
-
compile,
|
|
247
|
-
route: baseHrefToRoute(baseHref || constants_1.DEFAULT_BASE_HREF),
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function buildProcessArguments(args) {
|
|
251
|
-
return (args ?? []).map(arg => {
|
|
252
|
-
if (Array.isArray(arg)) {
|
|
253
|
-
const [key, value] = arg;
|
|
254
|
-
return `${key}=${value}`;
|
|
255
|
-
}
|
|
256
|
-
return arg;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
function baseHrefToRoute(baseHref) {
|
|
260
|
-
return baseHref.replace(/^\//, '').replace(/\/$/, '');
|
|
261
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.compileUiExtensions = void 0;
|
|
27
|
+
const child_process_1 = require("child_process");
|
|
28
|
+
const chokidar_1 = require("chokidar");
|
|
29
|
+
const fs = __importStar(require("fs-extra"));
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const constants_1 = require("./constants");
|
|
32
|
+
const scaffold_1 = require("./scaffold");
|
|
33
|
+
const translations_1 = require("./translations");
|
|
34
|
+
const utils_1 = require("./utils");
|
|
35
|
+
/**
|
|
36
|
+
* @description
|
|
37
|
+
* Compiles the Admin UI app with the specified extensions.
|
|
38
|
+
*
|
|
39
|
+
* @docsCategory UiDevkit
|
|
40
|
+
*/
|
|
41
|
+
function compileUiExtensions(options) {
|
|
42
|
+
const { devMode, watchPort, command } = options;
|
|
43
|
+
const usingYarn = command && command === 'npm' ? false : (0, utils_1.shouldUseYarn)();
|
|
44
|
+
if (devMode) {
|
|
45
|
+
return runWatchMode({
|
|
46
|
+
watchPort: watchPort || 4200,
|
|
47
|
+
usingYarn,
|
|
48
|
+
...options,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return runCompileMode({
|
|
53
|
+
usingYarn,
|
|
54
|
+
...options,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.compileUiExtensions = compileUiExtensions;
|
|
59
|
+
function runCompileMode({ outputPath, baseHref, extensions, usingYarn, additionalProcessArguments, ngCompilerPath, }) {
|
|
60
|
+
const distPath = path.join(outputPath, 'dist');
|
|
61
|
+
const compile = () => new Promise(async (resolve, reject) => {
|
|
62
|
+
await (0, scaffold_1.setupScaffold)(outputPath, extensions);
|
|
63
|
+
await (0, scaffold_1.setBaseHref)(outputPath, baseHref || constants_1.DEFAULT_BASE_HREF);
|
|
64
|
+
let cmd = usingYarn ? 'yarn' : 'npm';
|
|
65
|
+
let commandArgs = ['run', 'build'];
|
|
66
|
+
if (ngCompilerPath) {
|
|
67
|
+
cmd = 'node';
|
|
68
|
+
commandArgs = [ngCompilerPath, 'build', '--configuration production'];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (!usingYarn) {
|
|
72
|
+
// npm requires `--` before any command line args being passed to a script
|
|
73
|
+
commandArgs.splice(2, 0, '--');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
console.log(`Running ${cmd} ${commandArgs.join(' ')}`);
|
|
77
|
+
const buildProcess = (0, child_process_1.spawn)(cmd, [...commandArgs, ...buildProcessArguments(additionalProcessArguments)], {
|
|
78
|
+
cwd: outputPath,
|
|
79
|
+
shell: true,
|
|
80
|
+
stdio: 'inherit',
|
|
81
|
+
});
|
|
82
|
+
buildProcess.on('close', code => {
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
reject(code);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
resolve();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
path: distPath,
|
|
93
|
+
compile,
|
|
94
|
+
route: baseHrefToRoute(baseHref || constants_1.DEFAULT_BASE_HREF),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function runWatchMode({ outputPath, baseHref, watchPort, extensions, usingYarn, additionalProcessArguments, ngCompilerPath, }) {
|
|
98
|
+
const devkitPath = require.resolve('@vendure/ui-devkit');
|
|
99
|
+
let buildProcess;
|
|
100
|
+
let watcher;
|
|
101
|
+
let close = () => {
|
|
102
|
+
/* */
|
|
103
|
+
};
|
|
104
|
+
const compile = () => new Promise(async (resolve, reject) => {
|
|
105
|
+
await (0, scaffold_1.setupScaffold)(outputPath, extensions);
|
|
106
|
+
await (0, scaffold_1.setBaseHref)(outputPath, baseHref || constants_1.DEFAULT_BASE_HREF);
|
|
107
|
+
const adminUiExtensions = extensions.filter(utils_1.isAdminUiExtension);
|
|
108
|
+
const normalizedExtensions = (0, utils_1.normalizeExtensions)(adminUiExtensions);
|
|
109
|
+
const globalStylesExtensions = extensions.filter(utils_1.isGlobalStylesExtension);
|
|
110
|
+
const staticAssetExtensions = extensions.filter(utils_1.isStaticAssetExtension);
|
|
111
|
+
const allTranslationFiles = (0, translations_1.getAllTranslationFiles)(extensions.filter(utils_1.isTranslationExtension));
|
|
112
|
+
let cmd = usingYarn ? 'yarn' : 'npm';
|
|
113
|
+
let commandArgs = ['run', 'start'];
|
|
114
|
+
if (ngCompilerPath) {
|
|
115
|
+
cmd = 'node';
|
|
116
|
+
commandArgs = [ngCompilerPath, 'serve'];
|
|
117
|
+
}
|
|
118
|
+
buildProcess = (0, child_process_1.spawn)(cmd, [
|
|
119
|
+
...commandArgs,
|
|
120
|
+
`--port=${watchPort || 4200}`,
|
|
121
|
+
...buildProcessArguments(additionalProcessArguments),
|
|
122
|
+
], {
|
|
123
|
+
cwd: outputPath,
|
|
124
|
+
shell: true,
|
|
125
|
+
stdio: 'inherit',
|
|
126
|
+
});
|
|
127
|
+
buildProcess.on('close', code => {
|
|
128
|
+
if (code !== 0) {
|
|
129
|
+
reject(code);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
resolve();
|
|
133
|
+
}
|
|
134
|
+
close();
|
|
135
|
+
});
|
|
136
|
+
for (const extension of normalizedExtensions) {
|
|
137
|
+
if (!watcher) {
|
|
138
|
+
watcher = (0, chokidar_1.watch)(extension.extensionPath, {
|
|
139
|
+
depth: 4,
|
|
140
|
+
ignored: '**/node_modules/',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
watcher.add(extension.extensionPath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const extension of staticAssetExtensions) {
|
|
148
|
+
for (const staticAssetDef of extension.staticAssets) {
|
|
149
|
+
const assetPath = (0, utils_1.getStaticAssetPath)(staticAssetDef);
|
|
150
|
+
if (!watcher) {
|
|
151
|
+
watcher = (0, chokidar_1.watch)(assetPath);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
watcher.add(assetPath);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const extension of globalStylesExtensions) {
|
|
159
|
+
const globalStylePaths = Array.isArray(extension.globalStyles)
|
|
160
|
+
? extension.globalStyles
|
|
161
|
+
: [extension.globalStyles];
|
|
162
|
+
for (const stylePath of globalStylePaths) {
|
|
163
|
+
if (!watcher) {
|
|
164
|
+
watcher = (0, chokidar_1.watch)(stylePath);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
watcher.add(stylePath);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
for (const translationFiles of Object.values(allTranslationFiles)) {
|
|
172
|
+
if (!translationFiles) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
for (const file of translationFiles) {
|
|
176
|
+
if (!watcher) {
|
|
177
|
+
watcher = (0, chokidar_1.watch)(file);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
watcher.add(file);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (watcher) {
|
|
185
|
+
// watch the ui-devkit package files too
|
|
186
|
+
watcher.add(devkitPath);
|
|
187
|
+
}
|
|
188
|
+
if (watcher) {
|
|
189
|
+
const allStaticAssetDefs = staticAssetExtensions.reduce((defs, e) => [...defs, ...(e.staticAssets || [])], []);
|
|
190
|
+
const allGlobalStyles = globalStylesExtensions.reduce((defs, e) => [
|
|
191
|
+
...defs,
|
|
192
|
+
...(Array.isArray(e.globalStyles) ? e.globalStyles : [e.globalStyles]),
|
|
193
|
+
], []);
|
|
194
|
+
watcher.on('change', async (filePath) => {
|
|
195
|
+
const extension = normalizedExtensions.find(e => filePath.includes(e.extensionPath));
|
|
196
|
+
if (extension) {
|
|
197
|
+
const outputDir = path.join(outputPath, constants_1.MODULES_OUTPUT_DIR, extension.id);
|
|
198
|
+
const filePart = path.relative(extension.extensionPath, filePath);
|
|
199
|
+
const dest = path.join(outputDir, filePart);
|
|
200
|
+
await fs.copyFile(filePath, dest);
|
|
201
|
+
}
|
|
202
|
+
if (filePath.includes(devkitPath)) {
|
|
203
|
+
(0, utils_1.copyUiDevkit)(outputPath);
|
|
204
|
+
}
|
|
205
|
+
for (const staticAssetDef of allStaticAssetDefs) {
|
|
206
|
+
const assetPath = (0, utils_1.getStaticAssetPath)(staticAssetDef);
|
|
207
|
+
if (filePath.includes(assetPath)) {
|
|
208
|
+
await (0, utils_1.copyStaticAsset)(outputPath, staticAssetDef);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
for (const stylePath of allGlobalStyles) {
|
|
213
|
+
if (filePath.includes(stylePath)) {
|
|
214
|
+
await (0, scaffold_1.copyGlobalStyleFile)(outputPath, stylePath);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const languageCode of Object.keys(allTranslationFiles)) {
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
220
|
+
const translationFiles = allTranslationFiles[languageCode];
|
|
221
|
+
for (const file of translationFiles) {
|
|
222
|
+
if (filePath.includes(path.normalize(file))) {
|
|
223
|
+
await (0, translations_1.mergeExtensionTranslations)(outputPath, {
|
|
224
|
+
[languageCode]: translationFiles,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
resolve();
|
|
232
|
+
});
|
|
233
|
+
close = () => {
|
|
234
|
+
if (watcher) {
|
|
235
|
+
void watcher.close();
|
|
236
|
+
}
|
|
237
|
+
if (buildProcess) {
|
|
238
|
+
buildProcess.kill();
|
|
239
|
+
}
|
|
240
|
+
process.exit();
|
|
241
|
+
};
|
|
242
|
+
process.on('SIGINT', close);
|
|
243
|
+
return {
|
|
244
|
+
sourcePath: outputPath,
|
|
245
|
+
port: watchPort || 4200,
|
|
246
|
+
compile,
|
|
247
|
+
route: baseHrefToRoute(baseHref || constants_1.DEFAULT_BASE_HREF),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function buildProcessArguments(args) {
|
|
251
|
+
return (args ?? []).map(arg => {
|
|
252
|
+
if (Array.isArray(arg)) {
|
|
253
|
+
const [key, value] = arg;
|
|
254
|
+
return `${key}=${value}`;
|
|
255
|
+
}
|
|
256
|
+
return arg;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function baseHrefToRoute(baseHref) {
|
|
260
|
+
return baseHref.replace(/^\//, '').replace(/\/$/, '');
|
|
261
|
+
}
|
|
262
262
|
//# sourceMappingURL=compile.js.map
|
package/compiler/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const STATIC_ASSETS_OUTPUT_DIR = "static-assets";
|
|
2
|
-
export declare const GLOBAL_STYLES_OUTPUT_DIR = "global-styles";
|
|
3
|
-
export declare const EXTENSION_ROUTES_FILE = "src/extension.routes.ts";
|
|
4
|
-
export declare const SHARED_EXTENSIONS_FILE = "src/shared-extensions.module.ts";
|
|
5
|
-
export declare const MODULES_OUTPUT_DIR = "src/extensions";
|
|
6
|
-
export declare const DEFAULT_BASE_HREF = "/admin/";
|
|
1
|
+
export declare const STATIC_ASSETS_OUTPUT_DIR = "static-assets";
|
|
2
|
+
export declare const GLOBAL_STYLES_OUTPUT_DIR = "global-styles";
|
|
3
|
+
export declare const EXTENSION_ROUTES_FILE = "src/extension.routes.ts";
|
|
4
|
+
export declare const SHARED_EXTENSIONS_FILE = "src/shared-extensions.module.ts";
|
|
5
|
+
export declare const MODULES_OUTPUT_DIR = "src/extensions";
|
|
6
|
+
export declare const DEFAULT_BASE_HREF = "/admin/";
|
package/compiler/constants.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_BASE_HREF = exports.MODULES_OUTPUT_DIR = exports.SHARED_EXTENSIONS_FILE = exports.EXTENSION_ROUTES_FILE = exports.GLOBAL_STYLES_OUTPUT_DIR = exports.STATIC_ASSETS_OUTPUT_DIR = void 0;
|
|
4
|
-
exports.STATIC_ASSETS_OUTPUT_DIR = 'static-assets';
|
|
5
|
-
exports.GLOBAL_STYLES_OUTPUT_DIR = 'global-styles';
|
|
6
|
-
exports.EXTENSION_ROUTES_FILE = 'src/extension.routes.ts';
|
|
7
|
-
exports.SHARED_EXTENSIONS_FILE = 'src/shared-extensions.module.ts';
|
|
8
|
-
exports.MODULES_OUTPUT_DIR = 'src/extensions';
|
|
9
|
-
exports.DEFAULT_BASE_HREF = '/admin/';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_BASE_HREF = exports.MODULES_OUTPUT_DIR = exports.SHARED_EXTENSIONS_FILE = exports.EXTENSION_ROUTES_FILE = exports.GLOBAL_STYLES_OUTPUT_DIR = exports.STATIC_ASSETS_OUTPUT_DIR = void 0;
|
|
4
|
+
exports.STATIC_ASSETS_OUTPUT_DIR = 'static-assets';
|
|
5
|
+
exports.GLOBAL_STYLES_OUTPUT_DIR = 'global-styles';
|
|
6
|
+
exports.EXTENSION_ROUTES_FILE = 'src/extension.routes.ts';
|
|
7
|
+
exports.SHARED_EXTENSIONS_FILE = 'src/shared-extensions.module.ts';
|
|
8
|
+
exports.MODULES_OUTPUT_DIR = 'src/extensions';
|
|
9
|
+
exports.DEFAULT_BASE_HREF = '/admin/';
|
|
10
10
|
//# sourceMappingURL=constants.js.map
|
package/compiler/helpers.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { BrandingOptions, StaticAssetExtension } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @description
|
|
4
|
-
* A helper function to simplify the process of setting custom branding images.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* compileUiExtensions({
|
|
9
|
-
* outputPath: path.join(__dirname, '../admin-ui'),
|
|
10
|
-
* extensions: [
|
|
11
|
-
* setBranding({
|
|
12
|
-
* // This is used as the branding in the top-left above the navigation
|
|
13
|
-
* smallLogoPath: path.join(__dirname, 'images/my-logo-sm.png'),
|
|
14
|
-
* // This is used on the login page
|
|
15
|
-
* largeLogoPath: path.join(__dirname, 'images/my-logo-lg.png'),
|
|
16
|
-
* faviconPath: path.join(__dirname, 'images/my-favicon.ico'),
|
|
17
|
-
* }),
|
|
18
|
-
* ],
|
|
19
|
-
* });
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @docsCategory UiDevkit
|
|
23
|
-
* @docsPage helpers
|
|
24
|
-
*/
|
|
25
|
-
export declare function setBranding(options: BrandingOptions): StaticAssetExtension;
|
|
1
|
+
import { BrandingOptions, StaticAssetExtension } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* A helper function to simplify the process of setting custom branding images.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* compileUiExtensions({
|
|
9
|
+
* outputPath: path.join(__dirname, '../admin-ui'),
|
|
10
|
+
* extensions: [
|
|
11
|
+
* setBranding({
|
|
12
|
+
* // This is used as the branding in the top-left above the navigation
|
|
13
|
+
* smallLogoPath: path.join(__dirname, 'images/my-logo-sm.png'),
|
|
14
|
+
* // This is used on the login page
|
|
15
|
+
* largeLogoPath: path.join(__dirname, 'images/my-logo-lg.png'),
|
|
16
|
+
* faviconPath: path.join(__dirname, 'images/my-favicon.ico'),
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @docsCategory UiDevkit
|
|
23
|
+
* @docsPage helpers
|
|
24
|
+
*/
|
|
25
|
+
export declare function setBranding(options: BrandingOptions): StaticAssetExtension;
|