@rws-framework/client 2.5.4 → 2.5.5
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/_tools.js +153 -139
- package/cfg/_default.cfg.js +1 -1
- package/package.json +2 -2
- package/rws.webpack.config.js +36 -44
- package/src/client.ts +4 -4
- package/src/services/ConfigService.ts +2 -3
package/_tools.js
CHANGED
|
@@ -7,8 +7,8 @@ const md5 = require('md5');
|
|
|
7
7
|
const chalk = require('chalk');
|
|
8
8
|
const { rwsPath } = require('@rws-framework/console');
|
|
9
9
|
|
|
10
|
-
function findRootWorkspacePath(currentPath) {
|
|
11
|
-
const parentPackageJsonPath = path.join(currentPath + '/..', 'package.json');
|
|
10
|
+
function findRootWorkspacePath(currentPath) {
|
|
11
|
+
const parentPackageJsonPath = path.join(currentPath + '/..', 'package.json');
|
|
12
12
|
const parentPackageDir = path.dirname(parentPackageJsonPath);
|
|
13
13
|
|
|
14
14
|
if (fs.existsSync(parentPackageJsonPath)) {
|
|
@@ -22,22 +22,21 @@ function findRootWorkspacePath(currentPath) {
|
|
|
22
22
|
return currentPath;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function findPackageDir()
|
|
26
|
-
{
|
|
25
|
+
function findPackageDir() {
|
|
27
26
|
return path.resolve(path.dirname(module.id));
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
function getActiveWorkSpaces(currentPath, mode = 'all') {
|
|
31
|
-
if(!currentPath){
|
|
29
|
+
function getActiveWorkSpaces(currentPath, mode = 'all') {
|
|
30
|
+
if (!currentPath) {
|
|
32
31
|
throw new Error(`[_tools.js:getActiveWorkSpaces] "currentPath" argument is required.`);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
if(!(['all', 'frontend', 'backend'].includes(mode))){
|
|
34
|
+
if (!(['all', 'frontend', 'backend'].includes(mode))) {
|
|
36
35
|
throw new Error(`[_tools.js:getActiveWorkSpaces] "mode" argument can be only: "frontend", "backend" or "all".`);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
const rootPkgDir = findRootWorkspacePath(currentPath)
|
|
40
|
-
const parentPackageJsonPath = path.join(rootPkgDir, 'package.json');
|
|
39
|
+
const parentPackageJsonPath = path.join(rootPkgDir, 'package.json');
|
|
41
40
|
const parentPackageDir = path.dirname(parentPackageJsonPath);
|
|
42
41
|
|
|
43
42
|
if (fs.existsSync(parentPackageJsonPath)) {
|
|
@@ -45,19 +44,19 @@ function getActiveWorkSpaces(currentPath, mode = 'all') {
|
|
|
45
44
|
|
|
46
45
|
if (packageJson.workspaces) {
|
|
47
46
|
return packageJson.workspaces.map((workspaceName) => path.join(rootPkgDir, workspaceName)).filter((workspaceDir) => {
|
|
48
|
-
if(mode === 'all'){
|
|
47
|
+
if (mode === 'all') {
|
|
49
48
|
return true;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
let rwsPkgName = '@rws-framework/server';
|
|
53
52
|
|
|
54
|
-
if(mode === 'frontend'){
|
|
53
|
+
if (mode === 'frontend') {
|
|
55
54
|
rwsPkgName = '@rws-framework/client';
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
let hasDesiredPackage = false;
|
|
59
58
|
|
|
60
|
-
const workspaceWebpackFilePath = path.join(workspaceDir, 'package.json');
|
|
59
|
+
const workspaceWebpackFilePath = path.join(workspaceDir, 'package.json');
|
|
61
60
|
const workspacePackageJson = JSON.parse(fs.readFileSync(workspaceWebpackFilePath, 'utf-8'));
|
|
62
61
|
|
|
63
62
|
if (workspacePackageJson.dependencies && (!!workspacePackageJson.dependencies[rwsPkgName])) {
|
|
@@ -72,16 +71,16 @@ function getActiveWorkSpaces(currentPath, mode = 'all') {
|
|
|
72
71
|
return [currentPath];
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
async function runCommand(command, cwd = null, silent = false, extraArgs = { env: {}}) {
|
|
74
|
+
async function runCommand(command, cwd = null, silent = false, extraArgs = { env: {} }) {
|
|
76
75
|
return new Promise((resolve, reject) => {
|
|
77
76
|
const [cmd, ...args] = command.split(' ');
|
|
78
|
-
|
|
79
|
-
if(!cwd){
|
|
77
|
+
|
|
78
|
+
if (!cwd) {
|
|
80
79
|
console.log(`[RWS] Setting default CWD for "${command}"`);
|
|
81
80
|
cwd = process.cwd();
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
|
|
85
84
|
const env = { ...process.env, ...extraArgs.env };
|
|
86
85
|
|
|
87
86
|
console.log(`[RWS] Running command "${command}" from "${cwd}"`);
|
|
@@ -101,7 +100,7 @@ async function runCommand(command, cwd = null, silent = false, extraArgs = { env
|
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
function findSuperclassFilePath(entryFile){
|
|
103
|
+
function findSuperclassFilePath(entryFile) {
|
|
105
104
|
const program = ts.createProgram([entryFile], {
|
|
106
105
|
target: ts.ScriptTarget.ES5,
|
|
107
106
|
module: ts.ModuleKind.CommonJS
|
|
@@ -136,7 +135,7 @@ function findSuperclassFilePath(entryFile){
|
|
|
136
135
|
return null; // Return null if no superclass or file path is found
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
function findServiceFilesWithClassExtend(dir, classPath){
|
|
138
|
+
function findServiceFilesWithClassExtend(dir, classPath) {
|
|
140
139
|
const files = fs.readdirSync(dir);
|
|
141
140
|
let results = []
|
|
142
141
|
|
|
@@ -144,11 +143,11 @@ function findServiceFilesWithClassExtend(dir, classPath){
|
|
|
144
143
|
const filePath = path.join(dir, file);
|
|
145
144
|
const fileStat = fs.statSync(filePath);
|
|
146
145
|
|
|
147
|
-
if (fileStat.isDirectory()) {
|
|
146
|
+
if (fileStat.isDirectory()) {
|
|
148
147
|
results = [...results, ...findServiceFilesWithClassExtend(filePath, classPath)];
|
|
149
|
-
} else if (fileStat.isFile() && filePath.endsWith('.ts')) {
|
|
150
|
-
const foundPath = findSuperclassFilePath(filePath);
|
|
151
|
-
if(foundPath === classPath){
|
|
148
|
+
} else if (fileStat.isFile() && filePath.endsWith('.ts')) {
|
|
149
|
+
const foundPath = findSuperclassFilePath(filePath);
|
|
150
|
+
if (foundPath === classPath) {
|
|
152
151
|
results = [...results, filePath];
|
|
153
152
|
}
|
|
154
153
|
};
|
|
@@ -157,7 +156,7 @@ function findServiceFilesWithClassExtend(dir, classPath){
|
|
|
157
156
|
return results;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
function findComponentFilesWithText(dir, text, ignored = [], fileList = []){
|
|
159
|
+
function findComponentFilesWithText(dir, text, ignored = [], fileList = []) {
|
|
161
160
|
const files = fs.readdirSync(dir);
|
|
162
161
|
|
|
163
162
|
files.forEach(file => {
|
|
@@ -167,15 +166,15 @@ function findComponentFilesWithText(dir, text, ignored = [], fileList = []){
|
|
|
167
166
|
if (fileStat.isDirectory() && !ignored.includes(file)) {
|
|
168
167
|
// Recursively search this directory
|
|
169
168
|
findComponentFilesWithText(filePath, text, ignored, fileList);
|
|
170
|
-
} else if (fileStat.isFile() && filePath.endsWith('.ts')) {
|
|
169
|
+
} else if (fileStat.isFile() && filePath.endsWith('.ts')) {
|
|
171
170
|
// Read file content and check for text
|
|
172
171
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
173
|
-
if (content.includes(text)) {
|
|
172
|
+
if (content.includes(text)) {
|
|
174
173
|
const compInfo = extractComponentInfo(content);
|
|
175
|
-
if(compInfo){
|
|
176
|
-
const {tagName, className, options, isIgnored} = compInfo;
|
|
174
|
+
if (compInfo) {
|
|
175
|
+
const { tagName, className, options, isIgnored } = compInfo;
|
|
177
176
|
|
|
178
|
-
if(isIgnored){
|
|
177
|
+
if (isIgnored) {
|
|
179
178
|
return;
|
|
180
179
|
}
|
|
181
180
|
|
|
@@ -198,88 +197,88 @@ function findComponentFilesWithText(dir, text, ignored = [], fileList = []){
|
|
|
198
197
|
return fileList;
|
|
199
198
|
}
|
|
200
199
|
|
|
201
|
-
function extractRWSViewArguments(sourceFile){
|
|
200
|
+
function extractRWSViewArguments(sourceFile) {
|
|
202
201
|
let argumentsExtracted = {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
className: null,
|
|
203
|
+
tagName: null,
|
|
204
|
+
options: null
|
|
206
205
|
};
|
|
207
206
|
|
|
208
207
|
let foundDecorator = false;
|
|
209
|
-
|
|
208
|
+
|
|
210
209
|
function visit(node) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (node.parent && ts.isClassDeclaration(node.parent)) {
|
|
228
|
-
const classNode = node.parent;
|
|
229
|
-
if (classNode.name) { // ClassDeclaration.name is optional as classes can be unnamed/anonymous
|
|
230
|
-
argumentsExtracted.className = classNode.name.getText(sourceFile);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
210
|
+
if (ts.isDecorator(node) && ts.isCallExpression(node.expression)) {
|
|
211
|
+
const expression = node.expression;
|
|
212
|
+
const decoratorName = expression.expression.getText(sourceFile);
|
|
213
|
+
if (decoratorName === 'RWSView') {
|
|
214
|
+
foundDecorator = true;
|
|
215
|
+
const args = expression.arguments;
|
|
216
|
+
if (args.length > 0 && ts.isStringLiteral(args[0])) {
|
|
217
|
+
argumentsExtracted.tagName = args[0].text;
|
|
218
|
+
}
|
|
219
|
+
if (args.length > 1) {
|
|
220
|
+
if (ts.isObjectLiteralExpression(args[1])) {
|
|
221
|
+
const argVal = args[1].getText(sourceFile);
|
|
222
|
+
argumentsExtracted.options = JSON5.parse(argVal);
|
|
233
223
|
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (node.parent && ts.isClassDeclaration(node.parent)) {
|
|
227
|
+
const classNode = node.parent;
|
|
228
|
+
if (classNode.name) { // ClassDeclaration.name is optional as classes can be unnamed/anonymous
|
|
229
|
+
argumentsExtracted.className = classNode.name.getText(sourceFile);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
234
232
|
}
|
|
233
|
+
}
|
|
235
234
|
|
|
236
|
-
|
|
235
|
+
ts.forEachChild(node, visit);
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
visit(sourceFile);
|
|
240
239
|
|
|
241
|
-
if(!foundDecorator){
|
|
240
|
+
if (!foundDecorator) {
|
|
242
241
|
return null;
|
|
243
242
|
}
|
|
244
243
|
|
|
245
244
|
return argumentsExtracted;
|
|
246
245
|
}
|
|
247
246
|
|
|
248
|
-
function extractRWSIgnoreArguments(sourceFile){
|
|
247
|
+
function extractRWSIgnoreArguments(sourceFile) {
|
|
249
248
|
let argumentsExtracted = {
|
|
250
|
-
|
|
249
|
+
params: null,
|
|
251
250
|
};
|
|
252
251
|
let foundDecorator = false;
|
|
253
252
|
let ignored = false;
|
|
254
|
-
|
|
253
|
+
|
|
255
254
|
function visit(node) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
}
|
|
255
|
+
if (ts.isDecorator(node) && ts.isCallExpression(node.expression)) {
|
|
256
|
+
const expression = node.expression;
|
|
257
|
+
const decoratorName = expression.expression.getText(sourceFile);
|
|
258
|
+
if (decoratorName === 'RWSView') {
|
|
259
|
+
foundDecorator = true;
|
|
260
|
+
const args = expression.arguments;
|
|
261
|
+
|
|
262
|
+
if (args.length) {
|
|
263
|
+
// Assuming the second argument is an object literal
|
|
264
|
+
if (ts.isObjectLiteralExpression(args[0])) {
|
|
265
|
+
const argVal = args[0].getText(sourceFile);
|
|
266
|
+
argumentsExtracted.options = argVal;
|
|
267
|
+
|
|
268
|
+
if (argVal.ignorePackaging === true) {
|
|
269
|
+
ignored = true;
|
|
270
|
+
}
|
|
274
271
|
}
|
|
272
|
+
}
|
|
275
273
|
}
|
|
274
|
+
}
|
|
276
275
|
|
|
277
|
-
|
|
276
|
+
ts.forEachChild(node, visit);
|
|
278
277
|
}
|
|
279
278
|
|
|
280
279
|
visit(sourceFile);
|
|
281
280
|
|
|
282
|
-
if(!foundDecorator){
|
|
281
|
+
if (!foundDecorator) {
|
|
283
282
|
return true;
|
|
284
283
|
}
|
|
285
284
|
|
|
@@ -288,8 +287,8 @@ function extractRWSIgnoreArguments(sourceFile){
|
|
|
288
287
|
|
|
289
288
|
function extractComponentInfo(componentCode) {
|
|
290
289
|
const componentNameRegex = /\@RWSView/g;
|
|
291
|
-
|
|
292
|
-
if(!componentNameRegex.test(componentCode)){
|
|
290
|
+
|
|
291
|
+
if (!componentNameRegex.test(componentCode)) {
|
|
293
292
|
return;
|
|
294
293
|
}
|
|
295
294
|
|
|
@@ -297,92 +296,89 @@ function extractComponentInfo(componentCode) {
|
|
|
297
296
|
|
|
298
297
|
let decoratorArgs = extractRWSViewArguments(tsSourceFile);
|
|
299
298
|
|
|
300
|
-
if(!decoratorArgs){
|
|
299
|
+
if (!decoratorArgs) {
|
|
301
300
|
decoratorArgs = {};
|
|
302
301
|
}
|
|
303
302
|
|
|
304
|
-
decoratorOpts = decoratorArgs.options;
|
|
303
|
+
decoratorOpts = decoratorArgs.options;
|
|
305
304
|
|
|
306
|
-
return {...decoratorArgs, options: decoratorOpts };
|
|
305
|
+
return { ...decoratorArgs, options: decoratorOpts };
|
|
307
306
|
}
|
|
308
307
|
|
|
309
308
|
function getAllFilesInFolder(folderPath, ignoreFilenames = [], recursive = false) {
|
|
310
309
|
const files = [];
|
|
311
310
|
function traverseDirectory(currentPath) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
if (pass) {
|
|
323
|
-
files.push(entryPath);
|
|
324
|
-
}
|
|
311
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
312
|
+
entries.forEach(entry => {
|
|
313
|
+
const entryPath = path.join(currentPath, entry.name);
|
|
314
|
+
if (entry.isFile()) {
|
|
315
|
+
let pass = true;
|
|
316
|
+
ignoreFilenames.forEach((regEx) => {
|
|
317
|
+
if (regEx.test(entryPath)) {
|
|
318
|
+
pass = false;
|
|
325
319
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
320
|
+
});
|
|
321
|
+
if (pass) {
|
|
322
|
+
files.push(entryPath);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if (entry.isDirectory() && recursive) {
|
|
326
|
+
traverseDirectory(entryPath);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
330
329
|
}
|
|
331
330
|
traverseDirectory(folderPath);
|
|
332
331
|
return files;
|
|
333
332
|
}
|
|
334
333
|
|
|
335
|
-
function setupTsConfig(tsConfigPath, executionDir)
|
|
336
|
-
{
|
|
337
|
-
|
|
338
|
-
if(!fs.existsSync(tsConfigPath)){
|
|
339
|
-
throw new Error(`Typescript config file "${tsConfigPath}" does not exist`);
|
|
340
|
-
}
|
|
334
|
+
function setupTsConfig(tsConfigPath, executionDir) {
|
|
341
335
|
|
|
342
|
-
|
|
336
|
+
if (!fs.existsSync(tsConfigPath)) {
|
|
337
|
+
throw new Error(`Typescript config file "${tsConfigPath}" does not exist`);
|
|
338
|
+
}
|
|
343
339
|
|
|
344
|
-
const tsConfigContents = fs.readFileSync(tsConfigPath, 'utf-8');
|
|
340
|
+
const tsConfigContents = fs.readFileSync(tsConfigPath, 'utf-8');
|
|
345
341
|
|
|
346
|
-
try{
|
|
347
|
-
let tsConfig = JSON.parse(tsConfigContents);
|
|
342
|
+
try {
|
|
343
|
+
let tsConfig = JSON.parse(tsConfigContents);
|
|
348
344
|
|
|
349
345
|
const declarationsPath = path.resolve(__dirname, 'types') + '/declarations.d.ts';
|
|
350
346
|
const testsPath = path.resolve(__dirname, 'tests');
|
|
351
347
|
const declarationsPathMD5 = md5(fs.readFileSync(declarationsPath, 'utf-8'));
|
|
352
|
-
const testsPathMD5 =
|
|
353
|
-
|
|
348
|
+
const testsPathMD5 = fs.existsSync(testsPath) ? md5(fs.readFileSync(testsPath, 'utf-8')) : null;
|
|
349
|
+
|
|
354
350
|
const includedMD5 = [];
|
|
355
351
|
|
|
356
|
-
let changed = false;
|
|
352
|
+
let changed = false;
|
|
357
353
|
|
|
358
354
|
const included = [];
|
|
359
|
-
|
|
360
|
-
if(!Object.keys(tsConfig).includes('include')){
|
|
355
|
+
|
|
356
|
+
if (!Object.keys(tsConfig).includes('include')) {
|
|
361
357
|
tsConfig['include'] = [];
|
|
362
|
-
}else{
|
|
358
|
+
} else {
|
|
363
359
|
tsConfig['include'] = tsConfig['include'].map((inc) => fs.existsSync(rwsPath.relativize(tsConfig['include'], executionDir)))
|
|
364
360
|
}
|
|
365
|
-
|
|
366
|
-
if(!Object.keys(tsConfig).includes('exclude')){
|
|
361
|
+
|
|
362
|
+
if (!Object.keys(tsConfig).includes('exclude')) {
|
|
367
363
|
tsConfig['exclude'] = [];
|
|
368
364
|
}
|
|
369
|
-
|
|
370
|
-
if(!included.includes(declarationsPath) && !includedMD5.includes(declarationsPathMD5)){
|
|
365
|
+
|
|
366
|
+
if (!included.includes(declarationsPath) && !includedMD5.includes(declarationsPathMD5)) {
|
|
371
367
|
console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS typescript declarations to project tsconfig.json');
|
|
372
368
|
included.push(declarationsPath);
|
|
373
369
|
includedMD5.push(md5(fs.readFileSync(declarationsPath, 'utf-8')));
|
|
374
370
|
changed = true;
|
|
375
371
|
}
|
|
376
|
-
|
|
372
|
+
|
|
377
373
|
tsConfig['include'] = included;
|
|
378
|
-
|
|
379
|
-
if(testsPathMD5 && (!tsConfig['exclude'].includes(testsPath) && !included.includes(testsPathMD5))){
|
|
374
|
+
|
|
375
|
+
if (testsPathMD5 && (!tsConfig['exclude'].includes(testsPath) && !included.includes(testsPathMD5))) {
|
|
380
376
|
console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS typescript exclusions to project tsconfig.json');
|
|
381
|
-
tsConfig['exclude'].push(testsPath);
|
|
377
|
+
tsConfig['exclude'].push(testsPath);
|
|
382
378
|
changed = true;
|
|
383
379
|
}
|
|
384
|
-
|
|
385
|
-
if(changed){
|
|
380
|
+
|
|
381
|
+
if (changed) {
|
|
386
382
|
fs.writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
|
|
387
383
|
console.log(chalk.yellowBright('Typescript config file'), `"${chalk.blueBright(tsConfigPath)}"`, chalk.yellowBright('has been changed'));
|
|
388
384
|
}
|
|
@@ -396,17 +392,35 @@ function setupTsConfig(tsConfigPath, executionDir)
|
|
|
396
392
|
}
|
|
397
393
|
}
|
|
398
394
|
|
|
395
|
+
function getPartedModeVendorsBannerParams(partedDirUrlPrefix, partedPrefix) {
|
|
396
|
+
return {
|
|
397
|
+
banner: `if(!window.RWS_PARTS_LOADED){
|
|
398
|
+
const script = document.createElement('script');
|
|
399
|
+
script.src = '${partedDirUrlPrefix}/${partedPrefix}.vendors.js';
|
|
400
|
+
script.type = 'text/javascript';
|
|
401
|
+
document.body.appendChild(script);
|
|
402
|
+
window.RWS_PARTS_LOADED = true;
|
|
403
|
+
console.log('[RWS INIT SCRIPT]', 'vendors injected...');
|
|
404
|
+
}`.replace('\n', ''),
|
|
405
|
+
raw: true,
|
|
406
|
+
entryOnly: true,
|
|
407
|
+
include: `${partedPrefix}.client.js`
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
|
|
399
412
|
module.exports = {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
413
|
+
findRootWorkspacePath,
|
|
414
|
+
findPackageDir,
|
|
415
|
+
getActiveWorkSpaces,
|
|
416
|
+
runCommand,
|
|
417
|
+
findComponentFilesWithText,
|
|
418
|
+
extractComponentInfo,
|
|
419
|
+
extractRWSViewArguments,
|
|
420
|
+
extractRWSIgnoreArguments,
|
|
421
|
+
findServiceFilesWithClassExtend,
|
|
422
|
+
findSuperclassFilePath,
|
|
423
|
+
getAllFilesInFolder,
|
|
424
|
+
setupTsConfig,
|
|
425
|
+
getPartedModeVendorsBannerParams
|
|
412
426
|
}
|
package/cfg/_default.cfg.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rws-framework/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.5",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs": "typedoc --tsconfig ./tsconfig.json"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@microsoft/fast-element": "^1.12.0",
|
|
30
30
|
"@microsoft/fast-foundation": "^2.46.2",
|
|
31
|
-
"@rws-framework/console": "^0.3.
|
|
31
|
+
"@rws-framework/console": "^0.3.2",
|
|
32
32
|
"@types/moment": "^2.13.0",
|
|
33
33
|
"dragula": "^3.7.3",
|
|
34
34
|
"he": "^1.2.0",
|
package/rws.webpack.config.js
CHANGED
|
@@ -4,7 +4,7 @@ const webpack = require('webpack');
|
|
|
4
4
|
const uglify = require('uglify-js')
|
|
5
5
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
6
6
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
7
|
-
|
|
7
|
+
const chalk = require('chalk');
|
|
8
8
|
const RWSAfterPlugin = require('./webpack/rws_after_plugin');
|
|
9
9
|
const tools = require('./_tools');
|
|
10
10
|
const { _DEFAULT_CONFIG } = require('./cfg/_default.cfg');
|
|
@@ -19,6 +19,7 @@ const json5 = require('json5');
|
|
|
19
19
|
const { rwsPath } = require('@rws-framework/console');
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
const RWSWebpackWrapper = (config) => {
|
|
23
24
|
const BuildConfigurator = new RWSConfigBuilder(RWSPath.findPackageDir(process.cwd()) + '/.rws.json', _DEFAULT_CONFIG);
|
|
24
25
|
|
|
@@ -26,17 +27,17 @@ const RWSWebpackWrapper = (config) => {
|
|
|
26
27
|
|
|
27
28
|
const executionDir = RWSPath.relativize(BuildConfigurator.get('executionDir') || config.executionDir || process.cwd(), config.packageDir);
|
|
28
29
|
|
|
29
|
-
const isDev = BuildConfigurator.get('dev'
|
|
30
|
-
const isHotReload = BuildConfigurator.get('hot'
|
|
31
|
-
const isReport = BuildConfigurator.get('report'
|
|
30
|
+
const isDev = BuildConfigurator.get('dev', config.dev);
|
|
31
|
+
const isHotReload = BuildConfigurator.get('hot', config.hot) ;
|
|
32
|
+
const isReport = BuildConfigurator.get('report', config.report);
|
|
33
|
+
const isParted = BuildConfigurator.get('parted', config.parted || false);
|
|
32
34
|
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix') || config.partedDirUrlPrefix;
|
|
35
|
+
const partedPrefix = BuildConfigurator.get('partedPrefix', config.partedPrefix);
|
|
36
|
+
const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix', config.partedDirUrlPrefix);
|
|
36
37
|
|
|
37
|
-
const partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations'
|
|
38
|
-
const customServiceLocations = BuildConfigurator.get('customServiceLocations'
|
|
39
|
-
const outputDir = RWSPath.relativize(BuildConfigurator.get('outputDir'
|
|
38
|
+
const partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations', config.partedComponentsLocations);
|
|
39
|
+
const customServiceLocations = BuildConfigurator.get('customServiceLocations', config.customServiceLocations);
|
|
40
|
+
const outputDir = RWSPath.relativize(BuildConfigurator.get('outputDir', config.outputDir), config.packageDir);
|
|
40
41
|
|
|
41
42
|
const outputFileName = BuildConfigurator.get('outputFileName') || config.outputFileName;
|
|
42
43
|
const publicDir = BuildConfigurator.get('publicDir') || config.publicDir;
|
|
@@ -47,6 +48,24 @@ const RWSWebpackWrapper = (config) => {
|
|
|
47
48
|
|
|
48
49
|
const tsConfigPath = rwsPath.relativize(BuildConfigurator.get('tsConfigPath') || config.tsConfigPath, executionDir);
|
|
49
50
|
|
|
51
|
+
|
|
52
|
+
RWSPath.removeDirectory(outputDir, true);
|
|
53
|
+
|
|
54
|
+
console.log(chalk.green('Build started with'))
|
|
55
|
+
console.log({
|
|
56
|
+
executionDir,
|
|
57
|
+
tsConfigPath,
|
|
58
|
+
outputDir,
|
|
59
|
+
dev: isDev,
|
|
60
|
+
publicDir,
|
|
61
|
+
parted: isParted,
|
|
62
|
+
partedPrefix,
|
|
63
|
+
partedDirUrlPrefix
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//AFTER OPTION DEFINITIONS
|
|
68
|
+
|
|
50
69
|
let WEBPACK_PLUGINS = [
|
|
51
70
|
new webpack.DefinePlugin({
|
|
52
71
|
'process.env._RWS_DEFAULTS': JSON.stringify(BuildConfigurator.exportDefaultConfig()),
|
|
@@ -55,21 +74,6 @@ const RWSWebpackWrapper = (config) => {
|
|
|
55
74
|
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/)
|
|
56
75
|
];
|
|
57
76
|
|
|
58
|
-
// if(isParted){
|
|
59
|
-
// WEBPACK_PLUGINS.push(new webpack.BannerPlugin({
|
|
60
|
-
// banner: `if(!window.RWS_PARTS_LOADED){
|
|
61
|
-
// const script = document.createElement('script');
|
|
62
|
-
// script.src = '${partedDirUrlPrefix}/${partedPrefix}.vendors.js';
|
|
63
|
-
// script.type = 'text/javascript';
|
|
64
|
-
// document.body.appendChild(script);
|
|
65
|
-
// window.RWS_PARTS_LOADED = true;
|
|
66
|
-
// }`.replace('\n', ''),
|
|
67
|
-
// raw: true,
|
|
68
|
-
// entryOnly: true,
|
|
69
|
-
// // include: 'client'
|
|
70
|
-
// }));
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
77
|
const WEBPACK_AFTER_ACTIONS = config.actions || [];
|
|
74
78
|
|
|
75
79
|
const aliases = config.aliases = {};
|
|
@@ -117,7 +121,7 @@ const RWSWebpackWrapper = (config) => {
|
|
|
117
121
|
WEBPACK_PLUGINS.push(new RWSAfterPlugin({ actions: WEBPACK_AFTER_ACTIONS }));
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
const
|
|
124
|
+
const rwsInfoJson = outputDir + '/rws_info.json'
|
|
121
125
|
const automatedEntries = {};
|
|
122
126
|
|
|
123
127
|
const foundRWSUserClasses = tools.findComponentFilesWithText(executionDir, '@RWSView', ['dist', 'node_modules', '@rws-framework/client']);
|
|
@@ -139,18 +143,7 @@ const RWSWebpackWrapper = (config) => {
|
|
|
139
143
|
|
|
140
144
|
const optimConfig = {
|
|
141
145
|
minimize: true,
|
|
142
|
-
minimizer:
|
|
143
|
-
new TerserPlugin({
|
|
144
|
-
terserOptions: {
|
|
145
|
-
mangle: false, //@error breaks FAST view stuff if enabled for all assets
|
|
146
|
-
output: {
|
|
147
|
-
comments: false
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
extractComments: false,
|
|
151
|
-
parallel: true,
|
|
152
|
-
})
|
|
153
|
-
] : [
|
|
146
|
+
minimizer: [
|
|
154
147
|
new TerserPlugin({
|
|
155
148
|
terserOptions: {
|
|
156
149
|
keep_classnames: true, // Prevent mangling of class names
|
|
@@ -171,6 +164,8 @@ const RWSWebpackWrapper = (config) => {
|
|
|
171
164
|
};
|
|
172
165
|
|
|
173
166
|
if (isParted) {
|
|
167
|
+
WEBPACK_PLUGINS.push(new webpack.BannerPlugin(tools.getPartedModeVendorsBannerParams(partedDirUrlPrefix, partedPrefix)));
|
|
168
|
+
|
|
174
169
|
if (partedComponentsLocations) {
|
|
175
170
|
partedComponentsLocations.forEach((componentDir) => {
|
|
176
171
|
RWSComponents = [...RWSComponents, ...(tools.findComponentFilesWithText(path.resolve(componentDir), '@RWSView', ['dist', 'node_modules', '@rws-framework/client']))];
|
|
@@ -188,7 +183,8 @@ const RWSWebpackWrapper = (config) => {
|
|
|
188
183
|
automatedEntries[fileInfo.sanitName] = fileInfo.filePath;
|
|
189
184
|
});
|
|
190
185
|
|
|
191
|
-
fs.writeFileSync(
|
|
186
|
+
fs.writeFileSync(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2));
|
|
187
|
+
|
|
192
188
|
optimConfig.splitChunks = {
|
|
193
189
|
cacheGroups: {
|
|
194
190
|
vendor: {
|
|
@@ -215,10 +211,6 @@ const RWSWebpackWrapper = (config) => {
|
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
};
|
|
218
|
-
} else {
|
|
219
|
-
if (fs.existsSync(splitInfoJson)) {
|
|
220
|
-
fs.unlinkSync(splitInfoJson);
|
|
221
|
-
}
|
|
222
214
|
}
|
|
223
215
|
|
|
224
216
|
const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir);
|
|
@@ -226,7 +218,7 @@ const RWSWebpackWrapper = (config) => {
|
|
|
226
218
|
if(!tsValidated){
|
|
227
219
|
throw new Error('RWS Webpack build failed.');
|
|
228
220
|
}
|
|
229
|
-
|
|
221
|
+
|
|
230
222
|
const cfgExport = {
|
|
231
223
|
entry: {
|
|
232
224
|
client: config.entry,
|
package/src/client.ts
CHANGED
|
@@ -32,7 +32,7 @@ interface IHotModule extends NodeModule {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
type RWSInfoType = { components: string[] };
|
|
36
36
|
type RWSEventListener = (event: CustomEvent) => void;
|
|
37
37
|
|
|
38
38
|
class RWSClient {
|
|
@@ -221,9 +221,9 @@ class RWSClient {
|
|
|
221
221
|
async loadPartedComponents(): Promise<void> {
|
|
222
222
|
this.assignClientToBrowser();
|
|
223
223
|
|
|
224
|
-
const componentParts:
|
|
224
|
+
const componentParts: RWSInfoType = await this.apiService.get<RWSInfoType>(this.appConfig.get('partedDirUrlPrefix') + '/rws_info.json');
|
|
225
225
|
|
|
226
|
-
componentParts.forEach((componentName: string, key: number) => {
|
|
226
|
+
componentParts.components.forEach((componentName: string, key: number) => {
|
|
227
227
|
const partUrl = `${this.appConfig.get('partedDirUrlPrefix')}/${this.appConfig.get('partedPrefix')}.${componentName}.js`;
|
|
228
228
|
|
|
229
229
|
const script: HTMLScriptElement = document.createElement('script');
|
|
@@ -232,7 +232,7 @@ class RWSClient {
|
|
|
232
232
|
script.type = 'text/javascript';
|
|
233
233
|
document.body.appendChild(script);
|
|
234
234
|
|
|
235
|
-
console.log(`Appended ${componentParts[key]} component (${partUrl})`);
|
|
235
|
+
console.log(`Appended ${componentParts.components[key]} component (${partUrl})`);
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -46,10 +46,9 @@ class ConfigService extends TheService {
|
|
|
46
46
|
if(defaultVal && defaultVal[0] === '@'){
|
|
47
47
|
defaultVal = this.data[((defaultVal as string).slice(1)) as keyof IRWSConfig];
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
return defaultVal;
|
|
51
|
-
}
|
|
52
|
-
|
|
51
|
+
}
|
|
53
52
|
|
|
54
53
|
return this.data[key as keyof IRWSConfig];
|
|
55
54
|
}
|