lucy-cli 0.7.12 → 0.7.14
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/dist/gulp/pipeline.js +3 -3
- package/dist/gulp/types.js +115 -29
- package/package.json +1 -1
- package/settings/master-settings.json +2 -2
- package/settings/page-settings.json +2 -2
- package/settings/public-settings.json +2 -1
- package/src/gulp/pipeline.ts +1 -1
- package/src/gulp/types.ts +157 -60
- package/tsconfig.json +1 -1
package/dist/gulp/pipeline.js
CHANGED
|
@@ -3,13 +3,13 @@ import * as path from 'path';
|
|
|
3
3
|
import replace from 'gulp-string-replace';
|
|
4
4
|
import { blue, red } from '../index.js';
|
|
5
5
|
export function setProdConfig() {
|
|
6
|
-
const
|
|
6
|
+
const tag = process.env.GIT_TAG || 'development';
|
|
7
7
|
const regexGit = /gitTag:\s*(.*),/g;
|
|
8
8
|
const regexDev = /devMode:\s*(.*),/g;
|
|
9
9
|
return () => {
|
|
10
10
|
return gulp
|
|
11
|
-
.src(['./typescript/public/constants/
|
|
12
|
-
.pipe(replace(regexGit, `gitTag: '${
|
|
11
|
+
.src(['./typescript/public/constants/env.ts'])
|
|
12
|
+
.pipe(replace(regexGit, `gitTag: '${tag}',`))
|
|
13
13
|
.pipe(replace(regexDev, `devMode: false,`))
|
|
14
14
|
.pipe(gulp.dest((file) => {
|
|
15
15
|
const filePath = file.dirname;
|
package/dist/gulp/types.js
CHANGED
|
@@ -17,63 +17,113 @@ export function updateWixTypes(options) {
|
|
|
17
17
|
localModules = options.projectSettings.lucySettings.modules;
|
|
18
18
|
}
|
|
19
19
|
// Add module to publicSettings
|
|
20
|
+
publicSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
|
|
21
|
+
publicSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
|
|
22
|
+
publicSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
|
|
20
23
|
publicSettings.compilerOptions.paths.mocks = ["../../../typescript/__mocks__/*"];
|
|
21
24
|
publicSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
|
|
22
25
|
publicSettings.compilerOptions.paths['public/*'] = ["../../../typescript/public/*.ts"];
|
|
23
|
-
publicSettings.include = [
|
|
26
|
+
publicSettings.include = [
|
|
27
|
+
"../../../typescript/public/**/*",
|
|
28
|
+
"../../../typescript/__mocks__/**/*",
|
|
29
|
+
];
|
|
24
30
|
// Add module to backendSettings
|
|
25
31
|
backendSettings.compilerOptions.paths.mocks = ["../../../typescript/__mocks__/*"];
|
|
26
32
|
backendSettings.compilerOptions.paths['types/*'] = [`../../../typescript/types/*`];
|
|
27
|
-
backendSettings.include = [
|
|
33
|
+
backendSettings.include = [
|
|
34
|
+
"../../../typescript/backend/**/*",
|
|
35
|
+
"../../../typescript/__mocks__/**/*"
|
|
36
|
+
];
|
|
28
37
|
// Add module to masterSettings
|
|
38
|
+
masterSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
|
|
39
|
+
masterSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
|
|
40
|
+
masterSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
|
|
29
41
|
masterSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
|
|
30
|
-
masterSettings.include = [
|
|
42
|
+
masterSettings.include = [
|
|
43
|
+
"../../../typescript/public/**/*",
|
|
44
|
+
"../../../typescript/__mocks__/**/*",
|
|
45
|
+
];
|
|
31
46
|
// Add module to pageSettings
|
|
47
|
+
pageSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
|
|
48
|
+
pageSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
|
|
49
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
|
|
32
50
|
pageSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
|
|
33
|
-
pageSettings.compilerOptions.paths['backend
|
|
34
|
-
pageSettings.include = [
|
|
51
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
|
|
52
|
+
pageSettings.include = [
|
|
53
|
+
"../../../typescript/public/**/*",
|
|
54
|
+
"../../../typescript/__mocks__/**/*",
|
|
55
|
+
];
|
|
35
56
|
if (modules) {
|
|
36
57
|
for (const [name] of Object.entries(modules)) {
|
|
37
|
-
console.error(`Adding module ${name} to WIX types`);
|
|
38
58
|
// Add module to publicSettings
|
|
39
|
-
publicSettings.compilerOptions.paths['backend/*.web.js']
|
|
40
|
-
publicSettings.compilerOptions.paths['backend/*.web']
|
|
59
|
+
publicSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
|
|
60
|
+
publicSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
|
|
61
|
+
publicSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
|
|
41
62
|
publicSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
|
|
42
63
|
publicSettings.compilerOptions.paths.mocks.push(...[`../../../${name}/__mocks__/*`]);
|
|
43
64
|
publicSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
|
|
44
|
-
publicSettings.include.push(...[
|
|
65
|
+
publicSettings.include.push(...[
|
|
66
|
+
`../../../${name}/public/**/*`,
|
|
67
|
+
`../../../${name}__mocks__/**/*`,
|
|
68
|
+
]);
|
|
45
69
|
// Add module to backendSettings
|
|
46
70
|
backendSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
|
|
47
71
|
backendSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*`);
|
|
48
72
|
backendSettings.compilerOptions.paths.mocks.push(...[`../../../${name}/__mocks__/*`]);
|
|
49
73
|
backendSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
|
|
50
|
-
backendSettings.include.push(...[
|
|
74
|
+
backendSettings.include.push(...[
|
|
75
|
+
`../../../${name}/public/**/*`,
|
|
76
|
+
`../../../${name}__mocks__/**/*`,
|
|
77
|
+
`../../../${name}/backend/**/*`
|
|
78
|
+
]);
|
|
51
79
|
// Add module to masterSettings
|
|
52
|
-
masterSettings.compilerOptions.paths['backend/*.web.js']
|
|
53
|
-
masterSettings.compilerOptions.paths['backend/*.web']
|
|
80
|
+
masterSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
|
|
81
|
+
masterSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
|
|
82
|
+
masterSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
|
|
54
83
|
masterSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
|
|
55
|
-
masterSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*`);
|
|
56
84
|
masterSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
|
|
57
|
-
masterSettings.include.push(...[
|
|
85
|
+
masterSettings.include.push(...[
|
|
86
|
+
`../../../${name}/public/**/*`,
|
|
87
|
+
`../../../${name}__mocks__/**/*`,
|
|
88
|
+
]);
|
|
58
89
|
// Add module to pageSettings
|
|
59
|
-
pageSettings.compilerOptions.paths['backend/*.web.js']
|
|
60
|
-
pageSettings.compilerOptions.paths['backend/*.web']
|
|
90
|
+
pageSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
|
|
91
|
+
pageSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
|
|
92
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
|
|
61
93
|
pageSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
|
|
62
|
-
pageSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.jsw.ts`);
|
|
63
94
|
pageSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
|
|
64
|
-
pageSettings.include.push(...[
|
|
95
|
+
pageSettings.include.push(...[
|
|
96
|
+
`../../../${name}/public/**/*`,
|
|
97
|
+
`../../../${name}__mocks__/**/*`,
|
|
98
|
+
]);
|
|
65
99
|
}
|
|
66
100
|
}
|
|
67
|
-
return gulp.src(['./.wix/types/**/*.json', '!./.wix/types/wix-code-types
|
|
101
|
+
return gulp.src(['./.wix/types/**/*.json', '!./.wix/types/wix-code-types/**/*'])
|
|
68
102
|
.pipe(flatmap(function (stream, file) {
|
|
69
103
|
count++;
|
|
70
|
-
if (file.dirname.endsWith('public'))
|
|
71
|
-
return stream.pipe(jeditor(publicSettings))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
if (file.dirname.endsWith('public')) {
|
|
105
|
+
return stream.pipe(jeditor(publicSettings))
|
|
106
|
+
.pipe(jeditor((json) => cleanTsConfig(json)))
|
|
107
|
+
.pipe(jeditor((json) => processJson(json)))
|
|
108
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions));
|
|
109
|
+
}
|
|
110
|
+
if (file.dirname.endsWith('backend')) {
|
|
111
|
+
return stream.pipe(jeditor(backendSettings))
|
|
112
|
+
.pipe(jeditor((json) => cleanTsConfig(json)))
|
|
113
|
+
.pipe(jeditor((json) => processJson(json)));
|
|
114
|
+
}
|
|
115
|
+
;
|
|
116
|
+
if (file.dirname.endsWith('masterPage')) {
|
|
117
|
+
return stream.pipe(jeditor(masterSettings))
|
|
118
|
+
.pipe(jeditor((json) => cleanTsConfig(json)))
|
|
119
|
+
.pipe(jeditor((json) => processJson(json)))
|
|
120
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions));
|
|
121
|
+
}
|
|
122
|
+
;
|
|
123
|
+
return stream.pipe(jeditor(pageSettings))
|
|
124
|
+
.pipe(jeditor((json) => cleanTsConfig(json)))
|
|
125
|
+
.pipe(jeditor((json) => processJson(json)))
|
|
126
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions));
|
|
77
127
|
}))
|
|
78
128
|
.pipe(replace('masterPage.masterPage.js', 'masterPage.ts', replaceOptions))
|
|
79
129
|
.pipe(replace('/src/', '/typescript/', replaceOptions))
|
|
@@ -158,18 +208,54 @@ function removeDuplicatesFromArray(arr) {
|
|
|
158
208
|
}
|
|
159
209
|
function processJson(obj) {
|
|
160
210
|
if (Array.isArray(obj)) {
|
|
161
|
-
|
|
211
|
+
// Process arrays and remove duplicate items
|
|
212
|
+
const uniqueArray = removeDuplicatesFromArray(obj);
|
|
213
|
+
return uniqueArray.length > 0 ? uniqueArray : undefined; // Remove empty arrays
|
|
162
214
|
}
|
|
163
215
|
else if (obj && typeof obj === 'object') {
|
|
216
|
+
// Process objects, ensuring keys are unique
|
|
164
217
|
const result = {};
|
|
218
|
+
const seenKeys = new Set();
|
|
165
219
|
for (const key in obj) {
|
|
166
220
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
167
|
-
|
|
221
|
+
if (!seenKeys.has(key)) {
|
|
222
|
+
const processedValue = processJson(obj[key]);
|
|
223
|
+
if (processedValue !== undefined) { // Remove keys with undefined values
|
|
224
|
+
seenKeys.add(key);
|
|
225
|
+
result[key] = processedValue;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
168
228
|
}
|
|
169
229
|
}
|
|
170
|
-
return
|
|
230
|
+
// If all keys were empty or undefined, return undefined
|
|
231
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
171
232
|
}
|
|
172
233
|
else {
|
|
234
|
+
// Return primitive values as-is
|
|
173
235
|
return obj;
|
|
174
236
|
}
|
|
175
237
|
}
|
|
238
|
+
function cleanTsConfig(json) {
|
|
239
|
+
// Process the paths object to remove duplicates
|
|
240
|
+
if (json.compilerOptions?.paths) {
|
|
241
|
+
for (const key in json.compilerOptions.paths) {
|
|
242
|
+
if (Array.isArray(json.compilerOptions.paths[key])) {
|
|
243
|
+
const uniquePaths = [...new Set(json.compilerOptions.paths[key])];
|
|
244
|
+
json.compilerOptions.paths[key] = uniquePaths.length > 0 ? uniquePaths : undefined;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Process the include array to remove duplicates
|
|
249
|
+
if (Array.isArray(json.include)) {
|
|
250
|
+
const uniqueIncludes = [...new Set(json.include)];
|
|
251
|
+
json.include = uniqueIncludes.length > 0 ? uniqueIncludes : undefined;
|
|
252
|
+
}
|
|
253
|
+
// Remove empty or undefined fields
|
|
254
|
+
if (json.compilerOptions?.paths) {
|
|
255
|
+
json.compilerOptions.paths = Object.fromEntries(Object.entries(json.compilerOptions.paths).filter(([_, value]) => value !== undefined));
|
|
256
|
+
}
|
|
257
|
+
if (json.include?.length === 0) {
|
|
258
|
+
delete json.include;
|
|
259
|
+
}
|
|
260
|
+
return json;
|
|
261
|
+
}
|
package/package.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"jsx": "react-jsx",
|
|
7
7
|
"noEmit": false,
|
|
8
8
|
"noUncheckedIndexedAccess": true,
|
|
9
|
-
"lib": ["DOM"],
|
|
9
|
+
"lib": ["DOM", "ESNext"],
|
|
10
10
|
"paths": {
|
|
11
11
|
"backend/*.web.js": [],
|
|
12
12
|
"backend/*.web": [],
|
|
13
|
+
"backend/*.jsw": [],
|
|
13
14
|
"public/*": [],
|
|
14
|
-
"backend/*": [],
|
|
15
15
|
"wix-types/*": ["../wix-code-types/dist/types/*"],
|
|
16
16
|
"types/*": []
|
|
17
17
|
}
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"noEmit": false,
|
|
9
9
|
"noUncheckedIndexedAccess": true,
|
|
10
|
-
"lib": ["DOM", "
|
|
10
|
+
"lib": ["DOM", "ESNext"],
|
|
11
11
|
"paths": {
|
|
12
12
|
"backend/*.web.js": [],
|
|
13
13
|
"backend/*.web": [],
|
|
14
|
+
"backend/*.jsw": [],
|
|
14
15
|
"public/*": [],
|
|
15
|
-
"backend/*": [],
|
|
16
16
|
"wix-types/*": ["../wix-code-types/dist/types/*"],
|
|
17
17
|
"types/*": []
|
|
18
18
|
}
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
"strict": true,
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"strictNullChecks": true,
|
|
9
|
-
"lib": ["DOM"],
|
|
9
|
+
"lib": ["DOM", "ESNext"],
|
|
10
10
|
"paths": {
|
|
11
11
|
"backend/*.web.js": [],
|
|
12
12
|
"backend/*.web": [],
|
|
13
|
+
"backend/*.jsw": [],
|
|
13
14
|
"mocks": [],
|
|
14
15
|
"public/*": [],
|
|
15
16
|
"types/*": [],
|
package/src/gulp/pipeline.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function setProdConfig() {
|
|
|
11
11
|
|
|
12
12
|
return () => {
|
|
13
13
|
return gulp
|
|
14
|
-
.src(['./typescript/
|
|
14
|
+
.src(['./typescript/public/constants/env.ts'])
|
|
15
15
|
.pipe(replace(regexGit, `gitTag: '${tag}',`))
|
|
16
16
|
.pipe(replace(regexDev, `devMode: false,`))
|
|
17
17
|
.pipe(gulp.dest((file: File) => {
|
package/src/gulp/types.ts
CHANGED
|
@@ -22,62 +22,115 @@ export function updateWixTypes(options: TaskOptions) {
|
|
|
22
22
|
localModules = options.projectSettings.lucySettings.modules as unknown as Record<string, string>;
|
|
23
23
|
}
|
|
24
24
|
// Add module to publicSettings
|
|
25
|
+
publicSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
26
|
+
publicSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
27
|
+
publicSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
|
|
25
28
|
publicSettings.compilerOptions.paths.mocks = [ "../../../typescript/__mocks__/*" ] as never;
|
|
26
29
|
publicSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
|
|
27
30
|
publicSettings.compilerOptions.paths['public/*'] = [ "../../../typescript/public/*.ts" ] as never;
|
|
28
|
-
publicSettings.include = [
|
|
31
|
+
publicSettings.include = [
|
|
32
|
+
"../../../typescript/public/**/*",
|
|
33
|
+
"../../../typescript/__mocks__/**/*",
|
|
34
|
+
] as never;
|
|
35
|
+
|
|
29
36
|
// Add module to backendSettings
|
|
30
37
|
backendSettings.compilerOptions.paths.mocks = [ "../../../typescript/__mocks__/*" ] as never;
|
|
31
38
|
backendSettings.compilerOptions.paths['types/*'] = [ `../../../typescript/types/*` ] as never;
|
|
32
|
-
backendSettings.include = [
|
|
39
|
+
backendSettings.include = [
|
|
40
|
+
"../../../typescript/backend/**/*",
|
|
41
|
+
"../../../typescript/__mocks__/**/*"
|
|
42
|
+
] as never;
|
|
33
43
|
// Add module to masterSettings
|
|
44
|
+
masterSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
45
|
+
masterSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
46
|
+
masterSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
|
|
34
47
|
masterSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
|
|
35
|
-
masterSettings.include = [
|
|
48
|
+
masterSettings.include = [
|
|
49
|
+
"../../../typescript/public/**/*",
|
|
50
|
+
"../../../typescript/__mocks__/**/*",
|
|
51
|
+
] as never;
|
|
36
52
|
// Add module to pageSettings
|
|
53
|
+
pageSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
54
|
+
pageSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
|
|
55
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
|
|
37
56
|
pageSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
|
|
38
|
-
pageSettings.compilerOptions.paths['backend
|
|
39
|
-
pageSettings.include = [
|
|
57
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
|
|
58
|
+
pageSettings.include = [
|
|
59
|
+
"../../../typescript/public/**/*",
|
|
60
|
+
"../../../typescript/__mocks__/**/*",
|
|
61
|
+
] as never;
|
|
40
62
|
|
|
41
63
|
if (modules) {
|
|
42
64
|
for (const [name] of Object.entries(modules)) {
|
|
43
65
|
// Add module to publicSettings
|
|
44
|
-
publicSettings.compilerOptions.paths['backend/*.web.js']
|
|
45
|
-
publicSettings.compilerOptions.paths['backend/*.web']
|
|
66
|
+
publicSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
67
|
+
publicSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
68
|
+
publicSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
|
|
46
69
|
publicSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
|
|
47
70
|
publicSettings.compilerOptions.paths.mocks.push(...[ `../../../${name}/__mocks__/*` as never ]);
|
|
48
71
|
publicSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
|
|
49
|
-
publicSettings.include.push(...[
|
|
72
|
+
publicSettings.include.push(...[
|
|
73
|
+
`../../../${name}/public/**/*`,
|
|
74
|
+
`../../../${name}__mocks__/**/*`,
|
|
75
|
+
] as never[]);
|
|
50
76
|
// Add module to backendSettings
|
|
51
77
|
backendSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
|
|
52
78
|
backendSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*` as never);
|
|
53
79
|
backendSettings.compilerOptions.paths.mocks.push(...[ `../../../${name}/__mocks__/*` ] as never[]);
|
|
54
80
|
backendSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
|
|
55
|
-
backendSettings.include.push(...[
|
|
81
|
+
backendSettings.include.push(...[
|
|
82
|
+
`../../../${name}/public/**/*`,
|
|
83
|
+
`../../../${name}__mocks__/**/*`,
|
|
84
|
+
`../../../${name}/backend/**/*`
|
|
85
|
+
] as never[]);
|
|
56
86
|
// Add module to masterSettings
|
|
57
|
-
masterSettings.compilerOptions.paths['backend/*.web.js']
|
|
58
|
-
masterSettings.compilerOptions.paths['backend/*.web']
|
|
87
|
+
masterSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
88
|
+
masterSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
89
|
+
masterSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
|
|
59
90
|
masterSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
|
|
60
|
-
masterSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*` as never);
|
|
61
91
|
masterSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
|
|
62
|
-
masterSettings.include.push(...[
|
|
92
|
+
masterSettings.include.push(...[
|
|
93
|
+
`../../../${name}/public/**/*`,
|
|
94
|
+
`../../../${name}__mocks__/**/*`,
|
|
95
|
+
] as never[]);
|
|
63
96
|
// Add module to pageSettings
|
|
64
|
-
pageSettings.compilerOptions.paths['backend/*.web.js']
|
|
65
|
-
pageSettings.compilerOptions.paths['backend/*.web']
|
|
97
|
+
pageSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
98
|
+
pageSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
|
|
99
|
+
pageSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
|
|
66
100
|
pageSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
|
|
67
|
-
pageSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.jsw.ts` as never);
|
|
68
101
|
pageSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
|
|
69
|
-
pageSettings.include.push(...[
|
|
102
|
+
pageSettings.include.push(...[
|
|
103
|
+
`../../../${name}/public/**/*`,
|
|
104
|
+
`../../../${name}__mocks__/**/*`,
|
|
105
|
+
] as never[]);
|
|
70
106
|
}
|
|
71
107
|
}
|
|
72
108
|
|
|
73
|
-
return gulp.src(['./.wix/types/**/*.json', '!./.wix/types/wix-code-types
|
|
109
|
+
return gulp.src(['./.wix/types/**/*.json', '!./.wix/types/wix-code-types/**/*'])
|
|
74
110
|
.pipe(flatmap(function(stream: NodeJS.ReadableStream, file: File) {
|
|
75
111
|
count ++;
|
|
76
|
-
if (file.dirname.endsWith('public'))
|
|
77
|
-
|
|
78
|
-
|
|
112
|
+
if (file.dirname.endsWith('public')) {
|
|
113
|
+
return stream.pipe(jeditor(publicSettings))
|
|
114
|
+
.pipe(jeditor((json: any) => cleanTsConfig(json)))
|
|
115
|
+
.pipe(jeditor((json: any) => processJson(json)))
|
|
116
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions));
|
|
117
|
+
}
|
|
118
|
+
if (file.dirname.endsWith('backend')) {
|
|
119
|
+
return stream.pipe(jeditor(backendSettings))
|
|
120
|
+
.pipe(jeditor((json: any) => cleanTsConfig(json)))
|
|
121
|
+
.pipe(jeditor((json: any) => processJson(json)))
|
|
122
|
+
};
|
|
123
|
+
if (file.dirname.endsWith('masterPage')) {
|
|
124
|
+
return stream.pipe(jeditor(masterSettings))
|
|
125
|
+
.pipe(jeditor((json: any) => cleanTsConfig(json)))
|
|
126
|
+
.pipe(jeditor((json: any) => processJson(json)))
|
|
127
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions))
|
|
128
|
+
};
|
|
79
129
|
|
|
80
|
-
return stream.pipe(jeditor(pageSettings))
|
|
130
|
+
return stream.pipe(jeditor(pageSettings))
|
|
131
|
+
.pipe(jeditor((json: any) => cleanTsConfig(json)))
|
|
132
|
+
.pipe(jeditor((json: any) => processJson(json)))
|
|
133
|
+
.pipe(replace('"../backend.d.ts",', '', replaceOptions));
|
|
81
134
|
}))
|
|
82
135
|
.pipe(replace('masterPage.masterPage.js', 'masterPage.ts', replaceOptions))
|
|
83
136
|
.pipe(replace('/src/', '/typescript/', replaceOptions))
|
|
@@ -141,51 +194,95 @@ export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback):
|
|
|
141
194
|
});
|
|
142
195
|
};
|
|
143
196
|
|
|
144
|
-
|
|
145
197
|
function makeHashable(obj: any): any {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
198
|
+
if (Array.isArray(obj)) {
|
|
199
|
+
return obj.map(makeHashable);
|
|
200
|
+
} else if (obj && typeof obj === 'object') {
|
|
201
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
202
|
+
const result: any = {};
|
|
203
|
+
for (const key of sortedKeys) {
|
|
204
|
+
result[key] = makeHashable(obj[key]);
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
} else {
|
|
208
|
+
return obj;
|
|
209
|
+
}
|
|
158
210
|
}
|
|
159
211
|
|
|
160
212
|
function removeDuplicatesFromArray(arr: any[]): any[] {
|
|
161
|
-
|
|
162
|
-
|
|
213
|
+
const seen = new Set<string>();
|
|
214
|
+
const newArr: any[] = [];
|
|
163
215
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
216
|
+
for (const item of arr) {
|
|
217
|
+
const processedItem = processJson(item); // Recursively process the item
|
|
218
|
+
const hashableItem = makeHashable(processedItem);
|
|
219
|
+
const serializedItem = JSON.stringify(hashableItem);
|
|
168
220
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
221
|
+
if (!seen.has(serializedItem)) {
|
|
222
|
+
seen.add(serializedItem);
|
|
223
|
+
newArr.push(processedItem);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return newArr;
|
|
175
227
|
}
|
|
176
228
|
|
|
177
229
|
function processJson(obj: any): any {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
230
|
+
if (Array.isArray(obj)) {
|
|
231
|
+
// Process arrays and remove duplicate items
|
|
232
|
+
const uniqueArray = removeDuplicatesFromArray(obj);
|
|
233
|
+
return uniqueArray.length > 0 ? uniqueArray : undefined; // Remove empty arrays
|
|
234
|
+
} else if (obj && typeof obj === 'object') {
|
|
235
|
+
// Process objects, ensuring keys are unique
|
|
236
|
+
const result: any = {};
|
|
237
|
+
const seenKeys = new Set<string>();
|
|
238
|
+
|
|
239
|
+
for (const key in obj) {
|
|
240
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
241
|
+
if (!seenKeys.has(key)) {
|
|
242
|
+
const processedValue = processJson(obj[key]);
|
|
243
|
+
if (processedValue !== undefined) { // Remove keys with undefined values
|
|
244
|
+
seenKeys.add(key);
|
|
245
|
+
result[key] = processedValue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// If all keys were empty or undefined, return undefined
|
|
252
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
253
|
+
} else {
|
|
254
|
+
// Return primitive values as-is
|
|
255
|
+
return obj;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function cleanTsConfig(json: any): any {
|
|
260
|
+
// Process the paths object to remove duplicates
|
|
261
|
+
if (json.compilerOptions?.paths) {
|
|
262
|
+
for (const key in json.compilerOptions.paths) {
|
|
263
|
+
if (Array.isArray(json.compilerOptions.paths[key])) {
|
|
264
|
+
const uniquePaths = [...new Set(json.compilerOptions.paths[key])];
|
|
265
|
+
json.compilerOptions.paths[key] = uniquePaths.length > 0 ? uniquePaths : undefined;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Process the include array to remove duplicates
|
|
271
|
+
if (Array.isArray(json.include)) {
|
|
272
|
+
const uniqueIncludes = [...new Set(json.include)];
|
|
273
|
+
json.include = uniqueIncludes.length > 0 ? uniqueIncludes : undefined;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Remove empty or undefined fields
|
|
277
|
+
if (json.compilerOptions?.paths) {
|
|
278
|
+
json.compilerOptions.paths = Object.fromEntries(
|
|
279
|
+
Object.entries(json.compilerOptions.paths).filter(([_, value]) => value !== undefined)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (json.include?.length === 0) {
|
|
284
|
+
delete json.include;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return json;
|
|
191
288
|
}
|
package/tsconfig.json
CHANGED