lucy-cli 1.0.15 → 1.1.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.
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ["**/*.{ts,tsx}"],
5
+ customSyntax: "@stylelint/postcss-css-in-js",
6
+ },
7
+ ],
8
+ };
@@ -18,6 +18,7 @@ export type TaskOptions = {
18
18
  publicSettings: typeof publicSettings;
19
19
  modulesSync: Record<string, string> | undefined;
20
20
  cwd: string;
21
+ isWatching?: boolean;
21
22
  };
22
23
  export interface File {
23
24
  path: string;
package/dist/Gulpfile.js CHANGED
@@ -45,6 +45,7 @@ const taskOptions = {
45
45
  cwd: process.cwd(),
46
46
  modulesSync: getModulesSync(),
47
47
  };
48
+ const watchTaskOptions = { ...taskOptions, isWatching: true };
48
49
  gulp.task('check-ts', gulp.parallel(checkTs(taskOptions)));
49
50
  gulp.task('scss', gulp.parallel(compileScss(taskOptions)));
50
51
  gulp.task('build-backend', gulp.parallel(buildBackend(taskOptions), buildBackendJSW(taskOptions)));
@@ -58,6 +59,13 @@ gulp.task('test', function () {
58
59
  console.log("šŸ’©" + red.underline.bold(' => Error in test task!'));
59
60
  });
60
61
  });
62
+ gulp.task('test-ci', function () {
63
+ return shell.task(['yarn test --run'], { ignoreErrors: true })().then(() => {
64
+ console.log("šŸ•" + blue.underline.bold(' => Exited test task!'));
65
+ }).catch(err => {
66
+ console.log("šŸ’©" + red.underline.bold(' => Error in test task!'));
67
+ });
68
+ });
61
69
  gulp.task('sync-types', shell.task([
62
70
  'yarn postinstall',
63
71
  ]));
@@ -74,11 +82,9 @@ gulp.task('gen-docs', shell.task([
74
82
  ]));
75
83
  gulp.task('fix-wix', gulp.series(cleanWix(), 'sync-types', 'fix-wixtypes', 'add-wix-types'));
76
84
  gulp.task('build', gulp.parallel('build-backend', 'build-public', 'preview-templates', buildPages(taskOptions), compileScss(taskOptions), 'copy-files'));
77
- gulp.task('build-pipeline', gulp.series(cleanSrc(taskOptions), 'set-production', 'fix-wixtypes', 'add-wix-types',
78
- // 'test',
79
- 'build'));
80
- gulp.task('build-prod', gulp.series((done) => checkPages(true, false).then(() => done(), (err) => done(err)), cleanSrc(taskOptions), 'set-production', 'fix-wix', 'build-backend', 'build-public', buildPages(taskOptions), 'copy-files', compileScss(taskOptions)));
81
- gulp.task('start-dev-env', gulp.parallel(watchAll(taskOptions), 'test', 'start-wix', (done) => checkPages(false, taskOptions.moduleSettings?.force ?? false).then(() => done(), (err) => done(err))));
85
+ gulp.task('build-pipeline', gulp.series(cleanSrc(taskOptions), 'set-production', 'check-ts', 'fix-wixtypes', 'add-wix-types', 'test-ci', 'build'));
86
+ gulp.task('build-prod', gulp.series((done) => checkPages(true, false).then(() => done(), (err) => done(err)), cleanSrc(taskOptions), 'set-production', 'fix-wix', 'check-ts', 'test-ci', 'build-backend', 'build-public', buildPages(taskOptions), 'copy-files', compileScss(taskOptions)));
87
+ gulp.task('start-dev-env', gulp.parallel(watchAll(watchTaskOptions), 'test', 'start-wix', 'check-ts', (done) => checkPages(false, taskOptions.moduleSettings?.force ?? false).then(() => done(), (err) => done(err))));
82
88
  gulp.task('dev', gulp.series(cleanSrc(taskOptions), 'fix-wix', 'build', 'start-dev-env'));
83
89
  async function gulpTaskRunner(task) {
84
90
  return new Promise(function (resolve, reject) {
@@ -149,6 +149,27 @@ export async function checkPages(fail, force) {
149
149
  }
150
150
  });
151
151
  }
152
+ const customReporter = {
153
+ error: (error, tsInstance) => {
154
+ if (!error.diagnostic) {
155
+ console.log(red(error.message));
156
+ return;
157
+ }
158
+ const { fullFilename, startPosition } = error;
159
+ const relativePath = path.relative(process.cwd(), fullFilename ?? '');
160
+ const line = startPosition ? startPosition.line + 1 : 0;
161
+ const col = startPosition ? startPosition.character + 1 : 0;
162
+ const message = tsInstance.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n');
163
+ console.log(`${blue.underline(relativePath)}:${yellow(String(line))}:${yellow(String(col))}`);
164
+ console.log(` ${red('error')} ${yellow(`TS${error.diagnostic.code}`)}: ${message}`);
165
+ },
166
+ finish: (results) => {
167
+ const errorCount = results.transpileErrors + results.semanticErrors + results.declarationErrors;
168
+ if (errorCount > 0) {
169
+ console.log(`\nšŸ’„ ${red.bold(`Found ${errorCount} error${errorCount > 1 ? 's' : ''}.`)}`);
170
+ }
171
+ },
172
+ };
152
173
  export function checkTs(options) {
153
174
  const folders = ['typescript'];
154
175
  if (options.modulesSync) {
@@ -158,18 +179,27 @@ export function checkTs(options) {
158
179
  }
159
180
  // Create tasks for each folder
160
181
  const tasks = folders.map((folder) => {
161
- const tsProject = ts.createProject(`./${folder}/tsconfig.json`, { noEmit: true });
182
+ const tsProject = ts.createProject(`./local.tsconfig.json`, { noEmit: true, declaration: false, skipDefaultLibCheck: true });
162
183
  const taskName = `test-${folder}`; // Create a unique name for each task
163
- const task = () => gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`], { cwd: folder })
164
- .pipe(tsProject(ts.reporter.fullReporter(true)))
165
- .on('error', function (e) {
166
- console.log("šŸ’©" + red.underline.bold(` => Typescriptcheck for ${orange(folder)} failed!`));
167
- console.log("šŸ’©" + red.underline.bold(` => Error: ${orange(e.message)}`));
168
- this.emit('end');
169
- })
170
- .on('end', function () {
171
- console.log("🐶" + blue.underline(` => Typescriptcheck for ${orange(folder)} succeeded!`));
172
- });
184
+ const task = () => {
185
+ let hasError = false;
186
+ const stream = gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`])
187
+ .pipe(tsProject(customReporter))
188
+ .on('error', () => {
189
+ hasError = true;
190
+ });
191
+ if (options.isWatching) {
192
+ stream.on('error', function () {
193
+ this.emit('end');
194
+ });
195
+ }
196
+ stream.on('end', () => {
197
+ if (!hasError) {
198
+ console.log("🐶" + blue.underline(` => Typescriptcheck for ${orange(folder)} succeeded!`));
199
+ }
200
+ });
201
+ return stream;
202
+ };
173
203
  // Register the task with Gulp
174
204
  Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
175
205
  return task;
@@ -19,6 +19,7 @@ export function updateWixTypes(options) {
19
19
  // Add module to publicSettings
20
20
  publicSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
21
21
  publicSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
22
+ publicSettings.compilerOptions.paths['backend/*'] = ["../../../typescript/backend/*.web.ts"];
22
23
  publicSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
23
24
  publicSettings.compilerOptions.paths.mocks = ["../../../typescript/__mocks__/*"];
24
25
  publicSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
@@ -43,6 +44,7 @@ export function updateWixTypes(options) {
43
44
  // Add module to masterSettings
44
45
  masterSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
45
46
  masterSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
47
+ masterSettings.compilerOptions.paths['backend/*'] = ["../../../typescript/backend/*.web.ts"];
46
48
  masterSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
47
49
  masterSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
48
50
  masterSettings.include = [
@@ -55,6 +57,7 @@ export function updateWixTypes(options) {
55
57
  // Add module to pageSettings
56
58
  pageSettings.compilerOptions.paths['backend/*.web'] = ["../../../typescript/backend/*.web.ts"];
57
59
  pageSettings.compilerOptions.paths['backend/*.web.js'] = ["../../../typescript/backend/*.web.ts"];
60
+ pageSettings.compilerOptions.paths['backend/*'] = ["../../../typescript/backend/*.web.ts"];
58
61
  pageSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
59
62
  pageSettings.compilerOptions.paths['types/*'] = ["../../../typescript/types/*"];
60
63
  pageSettings.compilerOptions.paths['backend/*.jsw'] = ["../../../typescript/backend/*.jsw.ts"];
@@ -70,6 +73,7 @@ export function updateWixTypes(options) {
70
73
  // Add module to publicSettings
71
74
  publicSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
72
75
  publicSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
76
+ publicSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts`);
73
77
  publicSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
74
78
  publicSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
75
79
  publicSettings.compilerOptions.paths.mocks.push(...[`../../../${name}/__mocks__/*`]);
@@ -97,6 +101,7 @@ export function updateWixTypes(options) {
97
101
  // Add module to masterSettings
98
102
  masterSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
99
103
  masterSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
104
+ masterSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts`);
100
105
  masterSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
101
106
  masterSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
102
107
  masterSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
@@ -110,6 +115,7 @@ export function updateWixTypes(options) {
110
115
  // Add module to pageSettings
111
116
  pageSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts`);
112
117
  pageSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts`);
118
+ pageSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts`);
113
119
  pageSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts`);
114
120
  pageSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*`);
115
121
  pageSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*`);
@@ -173,26 +179,27 @@ export function updateWixTypes(options) {
173
179
  }
174
180
  export function addTypes(options, done) {
175
181
  const { replaceOptions } = options;
176
- // const processPages = gulp.src(['./.wix/types/wix-code-types/dist/types/page/$w.d.ts'])
177
- // .pipe(replace('declare namespace \\$w {', ' declare namespace $w{\nconst api: $w.Api;\n', replaceOptions))
178
- // .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/page/'));
182
+ // Regex to match keywords at the beginning of a line, capturing any leading whitespace.
183
+ // The 'm' flag is for multiline matching (^ matches start of line).
184
+ // The 'g' flag is for global matching (replace all instances).
185
+ const interfaceRegex = /^(\s*)interface\s/gm;
186
+ const enumRegex = /^(\s*)enum\s/gm;
187
+ const typeRegex = /^(\s*)type\s/gm;
179
188
  const exportTypes = gulp.src(['./.wix/types/wix-code-types/dist/types/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
180
- .pipe(replace('interface ', 'export interface ', replaceOptions))
181
- .pipe(replace('enum ', 'export enum ', replaceOptions))
182
- .pipe(replace('type ', 'export type ', replaceOptions))
189
+ // The replacement string '$1export...' uses the captured whitespace to preserve indentation.
190
+ .pipe(replace(interfaceRegex, 'export interface ', replaceOptions))
191
+ .pipe(replace(enumRegex, 'export enum ', replaceOptions))
192
+ .pipe(replace(typeRegex, 'export type ', replaceOptions))
183
193
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
184
194
  const exportTypesBeta = gulp.src(['./.wix/types/wix-code-types/dist/types/beta/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/beta/common/$w.d.ts'])
185
- .pipe(replace('interface ', 'export interface ', replaceOptions))
186
- .pipe(replace('enum ', 'export enum ', replaceOptions))
187
- .pipe(replace('type ', 'export type ', replaceOptions))
195
+ .pipe(replace(interfaceRegex, '$1export interface ', replaceOptions))
196
+ .pipe(replace(enumRegex, 'export enum ', replaceOptions))
197
+ .pipe(replace(typeRegex, 'export type ', replaceOptions))
188
198
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/beta/common/'));
189
199
  const processCommon = gulp.src(['./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
190
200
  .pipe(insert.prepend("import '@total-typescript/ts-reset';\n"))
191
- // .pipe(replace('namespace \\$w {', 'declare namespace $w{\ntype Api = FrontendAPI;\n', replaceOptions))
192
201
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
193
- return merge(
194
- // processPages,
195
- processCommon, exportTypesBeta, exportTypes)
202
+ return merge(processCommon, exportTypesBeta, exportTypes)
196
203
  .on('error', function (e) {
197
204
  console.log("šŸ’©" + red.underline.bold(' => Updating WIX failed!'));
198
205
  console.log("šŸ’©" + red.underline.bold(` => Error: ${orange(e.message)}`));
@@ -10,9 +10,10 @@
10
10
  "moduleResolution": "Node",
11
11
  "preserveConstEnums": true,
12
12
  "allowSyntheticDefaultImports": true,
13
- "skipLibCheck": false,
13
+ "skipLibCheck": true,
14
14
  "allowJs": true,
15
- "declaration": true,
15
+ "declaration": false,
16
+ "noEmit": true,
16
17
  "jsx": "react",
17
18
  "strict": true,
18
19
  "alwaysStrict": false,
@@ -20,7 +21,7 @@
20
21
  "noImplicitReturns": true,
21
22
  "noImplicitThis": true,
22
23
  "strictNullChecks": true,
23
- "exactOptionalPropertyTypes": true,
24
+ "exactOptionalPropertyTypes": false,
24
25
  "strictBindCallApply": true,
25
26
  "strictFunctionTypes": true,
26
27
  "strictPropertyInitialization": true,
@@ -34,18 +35,24 @@
34
35
  }
35
36
  ],
36
37
  "paths": {
37
- "public/*": ["./typescript/public/*", "./lib/public/*"],
38
- "backend/*": ["./typescript/backend/*", "./lib/backend/*"],
39
- "pages/*": ["./pages/*"],
40
- "types/*": ["./types/*"]
38
+ "public/*": ["./typescript/public/*"],
39
+ "backend/*": ["./typescript/backend/*"],
40
+ "pages/*": ["./typescript/pages/*"],
41
+ "types/*": ["./typescript/types/*"]
41
42
  },
42
- "typeRoots": ["./types", "../node_modules/@types"]
43
+ "typeRoots": [
44
+ "./types",
45
+ ".wix/types/wix-code-types/dist/types/backend",
46
+ ".wix/types/wix-code-types/dist/types/common",
47
+ ".wix/types/wix-code-types/dist/types/public",
48
+ ".wix/types/wix-code-types/dist/types/page",
49
+ ".wix/types/masterPage",
50
+ "node_modules/@types"
51
+ ]
43
52
  },
44
53
  "exclude": [
45
54
  "../node_modules",
46
- "../.wix",
47
55
  "node_modules",
48
- "./wix",
49
56
  "./**/*.test.ts",
50
57
  "../src/**/*"
51
58
  ],
@@ -3,26 +3,49 @@
3
3
  "enable": true
4
4
  },
5
5
  "compilerOptions": {
6
- "outDir": "../src",
7
- "rootDir": ".",
8
- "target": "ES2020",
6
+ // --- Path and Module Settings ---
9
7
  "module": "ES2020",
10
8
  "moduleResolution": "Node",
11
- "preserveConstEnums": true,
9
+ "target": "ES2020",
10
+ "baseUrl": "..",
11
+ "paths": {
12
+ "public/*": ["./public/*"],
13
+ "backend/*": ["./backend/*"],
14
+ "pages/*": ["./pages/*"],
15
+ "types/*": ["./types/*"]
16
+ },
17
+ "typeRoots": [
18
+ "./.wix/types",
19
+ "./typescript/types",
20
+ "./node_modules/@types"
21
+ ],
22
+ "outDir": "./src",
23
+ "resolveJsonModule": true,
24
+ "jsx": "react-jsx",
25
+ "allowJs": false,
26
+
27
+ // --- Declaration File Settings (Crucial for this error) ---
28
+ "declaration": true,
29
+ "declarationMap": true,
30
+
31
+ // --- Strictness and Checks ---
32
+ "strict": true,
12
33
  "allowSyntheticDefaultImports": true,
13
34
  "skipLibCheck": true,
14
- "declaration": false,
15
- "strict": true,
16
- "alwaysStrict": false,
35
+ "forceConsistentCasingInFileNames": true,
36
+ "alwaysStrict": false,
17
37
  "noImplicitAny": true,
18
38
  "noImplicitReturns": true,
19
39
  "noImplicitThis": true,
20
40
  "strictNullChecks": true,
41
+ "exactOptionalPropertyTypes": true,
21
42
  "strictBindCallApply": true,
22
43
  "strictFunctionTypes": true,
23
44
  "strictPropertyInitialization": true,
24
- "exactOptionalPropertyTypes": true,
25
- "noEmit": true,
45
+
46
+ // --- Advanced ---
47
+ "composite": false,
48
+ "preserveConstEnums": true,
26
49
  "plugins": [
27
50
  {
28
51
  "name": "@styled/typescript-styled-plugin"
@@ -31,26 +54,19 @@
31
54
  "name": "typescript-eslint-language-service"
32
55
  }
33
56
  ],
34
- "paths": {
35
- "public/*": ["./public/*"],
36
- "backend/*": ["./backend/*"],
37
- "pages/*": ["./pages/*"],
38
- "types/*": ["./types/*"]
39
- },
40
- "typeRoots": [
41
- "./types",
42
- "../node_modules/@types"
43
- ]
44
57
  },
45
- "exclude": ["../node_modules", "../.wix", "node_modules", "./wix", "./**/*.spec.ts", "../src/**/*"],
46
- "include":[
47
- "!*.d.ts",
48
- "public/**/*.tsx",
49
- "**/*.ts"
58
+ "include": [
59
+ "./**/*.ts"
60
+ ],
61
+ "exclude": [
62
+ "../node_modules",
63
+ "../.wix",
64
+ "../src",
65
+ "**/*.spec.ts"
50
66
  ],
51
67
  "references": [
52
68
  {
53
69
  "path": "../jsconfig.json"
54
70
  }
55
71
  ]
56
- }
72
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "lucy-cli",
4
- "version": "1.0.15",
4
+ "version": "1.1.0",
5
5
  "description": "Lucy Framework for WIX Studio Editor",
6
6
  "main": ".dist/index.js",
7
7
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "composite": false,
4
- "declaration": false,
4
+ "noEmit": true,
5
5
  "experimentalDecorators": true,
6
6
  "noUncheckedIndexedAccess": true,
7
7
  "jsx": "react-jsx",
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "strict": true,
4
- "strictNullChecks": true,
5
4
  "composite": false,
6
- "declaration": false,
5
+ "noEmit": true,
6
+ "strictNullChecks": true,
7
7
  "jsx": "react-jsx",
8
- "noEmit": false,
9
8
  "noUncheckedIndexedAccess": true,
10
9
  "paths": {
11
10
  "backend/*.web.js": [],
12
11
  "backend/*.web": [],
13
12
  "backend/*.jsw": [],
13
+ "backend/*": [],
14
14
  "public/*": [],
15
15
  "wix-types/*": ["../wix-code-types/dist/types/*"],
16
16
  "types/*": []
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "composite": false,
4
- "declaration": false,
5
3
  "strict": true,
6
4
  "strictNullChecks": true,
5
+ "composite": false,
6
+ "noEmit": true,
7
7
  "experimentalDecorators": true,
8
8
  "jsx": "react-jsx",
9
- "noEmit": false,
10
9
  "noUncheckedIndexedAccess": true,
11
10
  "paths": {
12
11
  "backend/*.web.js": [],
13
12
  "backend/*.web": [],
14
13
  "backend/*.jsw": [],
14
+ "backend/*": [],
15
15
  "public/*": [],
16
16
  "wix-types/*": ["../wix-code-types/dist/types/*"],
17
17
  "types/*": []
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "composite": false,
4
- "declaration": false,
5
3
  "experimentalDecorators": true,
6
- "noEmit": false,
7
4
  "noUncheckedIndexedAccess": true,
8
5
  "strict": true,
6
+ "composite": false,
7
+ "noEmit": true,
9
8
  "jsx": "react-jsx",
10
9
  "strictNullChecks": true,
11
10
  "paths": {
12
11
  "backend/*.web.js": [],
13
12
  "backend/*.web": [],
14
13
  "backend/*.jsw": [],
14
+ "backend/*": [],
15
15
  "mocks": [],
16
16
  "public/*": [],
17
17
  "types/*": [],
package/src/Gulpfile.ts CHANGED
@@ -39,6 +39,7 @@ export type TaskOptions = {
39
39
  publicSettings: typeof publicSettings,
40
40
  modulesSync: Record<string, string> | undefined;
41
41
  cwd: string;
42
+ isWatching?: boolean;
42
43
  }
43
44
 
44
45
  export interface File {
@@ -68,6 +69,8 @@ const taskOptions: TaskOptions = {
68
69
  modulesSync: getModulesSync(),
69
70
  }
70
71
 
72
+ const watchTaskOptions: TaskOptions = { ...taskOptions, isWatching: true };
73
+
71
74
  gulp.task('check-ts', gulp.parallel(
72
75
  checkTs(taskOptions),
73
76
  ));
@@ -104,6 +107,16 @@ gulp.task('test', function () {
104
107
  console.log("šŸ’©" + red.underline.bold(' => Error in test task!'));
105
108
  });
106
109
  });
110
+ gulp.task('test-ci', function () {
111
+ return shell.task(
112
+ ['yarn test --run'],
113
+ { ignoreErrors: true }
114
+ )().then(() => {
115
+ console.log("šŸ•" + blue.underline.bold(' => Exited test task!'));
116
+ }).catch(err => {
117
+ console.log("šŸ’©" + red.underline.bold(' => Error in test task!'));
118
+ });
119
+ });
107
120
 
108
121
  gulp.task('sync-types', shell.task([
109
122
  'yarn postinstall',
@@ -149,9 +162,10 @@ gulp.task('build', gulp.parallel(
149
162
  gulp.task('build-pipeline', gulp.series(
150
163
  cleanSrc(taskOptions),
151
164
  'set-production',
165
+ 'check-ts',
152
166
  'fix-wixtypes',
153
167
  'add-wix-types',
154
- // 'test',
168
+ 'test-ci',
155
169
  'build',
156
170
  ));
157
171
 
@@ -160,6 +174,8 @@ gulp.task('build-prod', gulp.series(
160
174
  cleanSrc(taskOptions),
161
175
  'set-production',
162
176
  'fix-wix',
177
+ 'check-ts',
178
+ 'test-ci',
163
179
  'build-backend',
164
180
  'build-public',
165
181
  buildPages(taskOptions),
@@ -170,9 +186,10 @@ gulp.task('build-prod', gulp.series(
170
186
 
171
187
 
172
188
  gulp.task('start-dev-env', gulp.parallel(
173
- watchAll(taskOptions),
189
+ watchAll(watchTaskOptions),
174
190
  'test',
175
191
  'start-wix',
192
+ 'check-ts',
176
193
  (done) => checkPages(false, taskOptions.moduleSettings?.force ?? false).then(() => done(), (err) => done(err)),
177
194
  ));
178
195
 
@@ -18,7 +18,7 @@ const swcOptions = {
18
18
  preserveAllComments: false,
19
19
  minify: {
20
20
  compress: true // equivalent to {}
21
- }
21
+ }
22
22
  },
23
23
  };
24
24
 
@@ -2,6 +2,7 @@ import * as fs from 'fs';
2
2
  import glob from 'glob';
3
3
 
4
4
  import * as path from 'path';
5
+ import typescript from 'typescript';
5
6
  import gulp from 'gulp';
6
7
  import ts from 'gulp-typescript';
7
8
  import { blue, green, magenta, orange, red, yellow } from '../index.js';
@@ -158,6 +159,32 @@ export async function checkPages(fail: boolean, force: boolean) {
158
159
  });
159
160
  }
160
161
 
162
+ const customReporter: ts.reporter.Reporter = {
163
+ error: (error, tsInstance) => {
164
+ if (!error.diagnostic) {
165
+ console.log(red(error.message));
166
+ return;
167
+ }
168
+ const { fullFilename, startPosition } = error;
169
+ const relativePath = path.relative(process.cwd(), fullFilename ?? '');
170
+ const line = startPosition ? startPosition.line + 1 : 0;
171
+ const col = startPosition ? startPosition.character + 1 : 0;
172
+
173
+ const message = tsInstance.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n');
174
+
175
+ console.log(
176
+ `${blue.underline(relativePath)}:${yellow(String(line))}:${yellow(String(col))}`
177
+ );
178
+ console.log(` ${red('error')} ${yellow(`TS${error.diagnostic.code}`)}: ${message}`);
179
+ },
180
+ finish: (results) => {
181
+ const errorCount = results.transpileErrors + results.semanticErrors + results.declarationErrors;
182
+ if (errorCount > 0) {
183
+ console.log(`\nšŸ’„ ${red.bold(`Found ${errorCount} error${errorCount > 1 ? 's' : ''}.`)}`);
184
+ }
185
+ },
186
+ };
187
+
161
188
  export function checkTs(options: TaskOptions) {
162
189
  const folders = ['typescript'];
163
190
  if (options.modulesSync){
@@ -168,22 +195,32 @@ export function checkTs(options: TaskOptions) {
168
195
 
169
196
  // Create tasks for each folder
170
197
  const tasks = folders.map((folder) => {
171
- const tsProject = ts.createProject(`./${folder}/tsconfig.json`, { noEmit: true });
198
+ const tsProject = ts.createProject(`./local.tsconfig.json`, { noEmit: true, declaration: false, skipDefaultLibCheck: true });
172
199
 
173
200
  const taskName = `test-${folder}`; // Create a unique name for each task
174
201
 
175
- const task = () =>
176
- gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`], { cwd: folder })
177
- .pipe(tsProject(ts.reporter.fullReporter(true)))
178
- .on('error', function (e: Error) {
179
- console.log("šŸ’©" + red.underline.bold(` => Typescriptcheck for ${orange(folder)} failed!`));
180
- console.log("šŸ’©" + red.underline.bold(` => Error: ${orange(e.message)}`));
202
+ const task = () => {
203
+ let hasError = false;
204
+ const stream = gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`])
205
+ .pipe(tsProject(customReporter))
206
+ .on('error', () => {
207
+ hasError = true;
208
+ });
209
+
210
+ if (options.isWatching) {
211
+ stream.on('error', function (this: NodeJS.ReadWriteStream) {
181
212
  this.emit('end');
182
- })
183
-
184
- .on('end', function () {
185
- console.log("🐶" + blue.underline(` => Typescriptcheck for ${orange(folder)} succeeded!`));
186
213
  });
214
+ }
215
+
216
+ stream.on('end', () => {
217
+ if (!hasError) {
218
+ console.log("🐶" + blue.underline(` => Typescriptcheck for ${orange(folder)} succeeded!`));
219
+ }
220
+ });
221
+
222
+ return stream;
223
+ };
187
224
 
188
225
  // Register the task with Gulp
189
226
  Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
package/src/gulp/types.ts CHANGED
@@ -25,6 +25,7 @@ export function updateWixTypes(options: TaskOptions) {
25
25
  // Add module to publicSettings
26
26
  publicSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
27
27
  publicSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
28
+ publicSettings.compilerOptions.paths['backend/*'] = [ "../../../typescript/backend/*.web.ts" ] as never;
28
29
  publicSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
29
30
  publicSettings.compilerOptions.paths.mocks = [ "../../../typescript/__mocks__/*" ] as never;
30
31
  publicSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
@@ -50,6 +51,7 @@ export function updateWixTypes(options: TaskOptions) {
50
51
  // Add module to masterSettings
51
52
  masterSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
52
53
  masterSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
54
+ masterSettings.compilerOptions.paths['backend/*'] = [ "../../../typescript/backend/*.web.ts" ] as never;
53
55
  masterSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
54
56
  masterSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
55
57
  masterSettings.include = [
@@ -62,6 +64,7 @@ export function updateWixTypes(options: TaskOptions) {
62
64
  // Add module to pageSettings
63
65
  pageSettings.compilerOptions.paths['backend/*.web'] = [ "../../../typescript/backend/*.web.ts" ] as never;
64
66
  pageSettings.compilerOptions.paths['backend/*.web.js'] = [ "../../../typescript/backend/*.web.ts" ] as never;
67
+ pageSettings.compilerOptions.paths['backend/*'] = [ "../../../typescript/backend/*.web.ts" ] as never;
65
68
  pageSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
66
69
  pageSettings.compilerOptions.paths['types/*'] = [ "../../../typescript/types/*" ] as never;
67
70
  pageSettings.compilerOptions.paths['backend/*.jsw'] = [ "../../../typescript/backend/*.jsw.ts" ] as never;
@@ -78,6 +81,7 @@ export function updateWixTypes(options: TaskOptions) {
78
81
  // Add module to publicSettings
79
82
  publicSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
80
83
  publicSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
84
+ publicSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts` as never);
81
85
  publicSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
82
86
  publicSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
83
87
  publicSettings.compilerOptions.paths.mocks.push(...[ `../../../${name}/__mocks__/*` as never ]);
@@ -105,6 +109,7 @@ export function updateWixTypes(options: TaskOptions) {
105
109
  // Add module to masterSettings
106
110
  masterSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
107
111
  masterSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
112
+ masterSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts` as never);
108
113
  masterSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
109
114
  masterSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
110
115
  masterSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
@@ -118,6 +123,7 @@ export function updateWixTypes(options: TaskOptions) {
118
123
  // Add module to pageSettings
119
124
  pageSettings.compilerOptions.paths['backend/*.web.js'].push(`../../../${name}/backend/*.web.ts` as never);
120
125
  pageSettings.compilerOptions.paths['backend/*.web'].push(`../../../${name}/backend/*.web.ts` as never);
126
+ pageSettings.compilerOptions.paths['backend/*'].push(`../../../${name}/backend/*.web.ts` as never);
121
127
  pageSettings.compilerOptions.paths['backend/*.jsw'].push(`../../../${name}/backend/*.jsw.ts` as never);
122
128
  pageSettings.compilerOptions.paths['public/*'].push(`../../../${name}/public/*` as never);
123
129
  pageSettings.compilerOptions.paths['types/*'].push(`../../../${name}/types/*` as never);
@@ -182,44 +188,47 @@ export function updateWixTypes(options: TaskOptions) {
182
188
  }
183
189
 
184
190
  export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback): NodeJS.ReadWriteStream {
185
- const { replaceOptions } = options;
186
- // const processPages = gulp.src(['./.wix/types/wix-code-types/dist/types/page/$w.d.ts'])
187
- // .pipe(replace('declare namespace \\$w {', ' declare namespace $w{\nconst api: $w.Api;\n', replaceOptions))
188
- // .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/page/'));
191
+ const { replaceOptions } = options;
189
192
 
190
- const exportTypes = gulp.src(['./.wix/types/wix-code-types/dist/types/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
191
- .pipe(replace('interface ', 'export interface ', replaceOptions))
192
- .pipe(replace('enum ', 'export enum ', replaceOptions))
193
- .pipe(replace('type ', 'export type ', replaceOptions))
194
- .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
193
+ // Regex to match keywords at the beginning of a line, capturing any leading whitespace.
194
+ // The 'm' flag is for multiline matching (^ matches start of line).
195
+ // The 'g' flag is for global matching (replace all instances).
196
+ const interfaceRegex = /^(\s*)interface\s/gm;
197
+ const enumRegex = /^(\s*)enum\s/gm;
198
+ const typeRegex = /^(\s*)type\s/gm;
195
199
 
196
- const exportTypesBeta = gulp.src(['./.wix/types/wix-code-types/dist/types/beta/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/beta/common/$w.d.ts'])
197
- .pipe(replace('interface ', 'export interface ', replaceOptions))
198
- .pipe(replace('enum ', 'export enum ', replaceOptions))
199
- .pipe(replace('type ', 'export type ', replaceOptions))
200
- .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/beta/common/'));
200
+ const exportTypes = gulp.src(['./.wix/types/wix-code-types/dist/types/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
201
+ // The replacement string '$1export...' uses the captured whitespace to preserve indentation.
202
+ .pipe(replace(interfaceRegex, 'export interface ', replaceOptions))
203
+ .pipe(replace(enumRegex, 'export enum ', replaceOptions))
204
+ .pipe(replace(typeRegex, 'export type ', replaceOptions))
205
+ .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
201
206
 
202
- const processCommon = gulp.src(['./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
203
- .pipe(insert.prepend("import '@total-typescript/ts-reset';\n"))
204
- // .pipe(replace('namespace \\$w {', 'declare namespace $w{\ntype Api = FrontendAPI;\n', replaceOptions))
205
- .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
207
+ const exportTypesBeta = gulp.src(['./.wix/types/wix-code-types/dist/types/beta/common/*.d.ts', '!./.wix/types/wix-code-types/dist/types/beta/common/$w.d.ts'])
208
+ .pipe(replace(interfaceRegex, '$1export interface ', replaceOptions))
209
+ .pipe(replace(enumRegex, 'export enum ', replaceOptions))
210
+ .pipe(replace(typeRegex, 'export type ', replaceOptions))
211
+ .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/beta/common/'));
206
212
 
207
- return merge(
208
- // processPages,
209
- processCommon,
210
- exportTypesBeta,
211
- exportTypes,
212
- )
213
- .on('error', function(e: Error) {
214
- console.log("šŸ’©" + red.underline.bold(' => Updating WIX failed!'));
215
- console.log("šŸ’©" + red.underline.bold(` => Error: ${orange(e.message)}`));
216
- this.emit('end');
217
- done();
218
- })
219
- .on('end', function() {
220
- console.log("🐶" + blue.underline(' => Updating WIX succeeded!'));
221
- done();
222
- });
213
+ const processCommon = gulp.src(['./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
214
+ .pipe(insert.prepend("import '@total-typescript/ts-reset';\n"))
215
+ .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
216
+
217
+ return merge(
218
+ processCommon,
219
+ exportTypesBeta,
220
+ exportTypes,
221
+ )
222
+ .on('error', function(e: Error) {
223
+ console.log("šŸ’©" + red.underline.bold(' => Updating WIX failed!'));
224
+ console.log("šŸ’©" + red.underline.bold(` => Error: ${orange(e.message)}`));
225
+ this.emit('end');
226
+ done();
227
+ })
228
+ .on('end', function() {
229
+ console.log("🐶" + blue.underline(' => Updating WIX succeeded!'));
230
+ done();
231
+ });
223
232
  };
224
233
 
225
234
  function makeHashable(obj: any): any {