lucy-cli 0.0.4 → 0.5.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.
Files changed (63) hide show
  1. package/.yarnrc.yml +0 -2
  2. package/config.json +1 -0
  3. package/dist/Gulpfile.js +24 -115
  4. package/dist/dev.d.ts +2 -1
  5. package/dist/dev.js +2 -3
  6. package/dist/gulp/backend.d.ts +2 -0
  7. package/dist/gulp/backend.js +52 -8
  8. package/dist/gulp/checks.d.ts +3 -3
  9. package/dist/gulp/checks.js +37 -27
  10. package/dist/gulp/clean.d.ts +2 -0
  11. package/dist/gulp/clean.js +15 -3
  12. package/dist/gulp/copy.d.ts +1 -0
  13. package/dist/gulp/copy.js +24 -4
  14. package/dist/gulp/docs.d.ts +2 -0
  15. package/dist/gulp/docs.js +27 -0
  16. package/dist/gulp/pages.js +3 -3
  17. package/dist/gulp/pipeline.d.ts +1 -0
  18. package/dist/gulp/pipeline.js +27 -0
  19. package/dist/gulp/public.js +13 -7
  20. package/dist/gulp/styles.js +4 -4
  21. package/dist/gulp/templates.d.ts +1 -0
  22. package/dist/gulp/templates.js +21 -3
  23. package/dist/gulp/test.d.ts +2 -0
  24. package/dist/gulp/test.js +82 -0
  25. package/dist/gulp/types.js +7 -8
  26. package/dist/gulp/watchers.d.ts +17 -0
  27. package/dist/gulp/watchers.js +94 -0
  28. package/dist/index.d.ts +23 -1
  29. package/dist/index.js +46 -46
  30. package/dist/init.d.ts +2 -1
  31. package/dist/init.js +27 -55
  32. package/dist/settings.json +4 -1
  33. package/dist/sync.d.ts +2 -0
  34. package/dist/sync.js +5 -0
  35. package/files/lucy.json +1 -1
  36. package/files/typedoc.json +2 -2
  37. package/package.json +9 -3
  38. package/settings/backend-settings.json +13 -3
  39. package/settings/master-settings.json +10 -3
  40. package/settings/page-settings.json +11 -3
  41. package/settings/public-settings.json +13 -4
  42. package/src/Gulpfile.ts +75 -145
  43. package/src/dev.ts +4 -3
  44. package/src/gulp/backend.ts +57 -9
  45. package/src/gulp/checks.ts +36 -29
  46. package/src/gulp/clean.ts +17 -7
  47. package/src/gulp/copy.ts +27 -5
  48. package/src/gulp/pages.ts +4 -4
  49. package/src/gulp/pipeline.ts +30 -0
  50. package/src/gulp/public.ts +16 -8
  51. package/src/gulp/styles.ts +6 -5
  52. package/src/gulp/templates.ts +24 -5
  53. package/src/gulp/test.ts +82 -0
  54. package/src/gulp/types.ts +9 -12
  55. package/src/gulp/watchers.ts +175 -0
  56. package/src/index.ts +59 -68
  57. package/src/init.ts +28 -62
  58. package/src/settings.json +4 -1
  59. package/src/sync.ts +10 -0
  60. package/src/types.d.ts +2 -1
  61. package/.eslintrc.json +0 -3
  62. package/files/jest.config.ts +0 -28
  63. package/files/tsconfig.json +0 -51
package/src/Gulpfile.ts CHANGED
@@ -1,23 +1,7 @@
1
- import chalk from 'chalk';
2
- import * as fs from 'fs';
3
- import glob from 'glob';
4
1
  import gulp from 'gulp';
5
- import clean from 'gulp-clean';
6
- import { createGulpEsbuild } from 'gulp-esbuild';
7
- import exec from 'gulp-exec';
8
- import foreach from 'gulp-foreach';
9
- import * as insert from 'gulp-insert';
10
- import jeditor from 'gulp-json-editor';
11
- import rename from 'gulp-rename';
12
2
  import gulpSass from 'gulp-sass';
13
3
  import shell from 'gulp-shell';
14
- import replace from 'gulp-string-replace';
15
- import * as tap from 'gulp-tap';
16
- import ts from 'gulp-typescript';
17
- import * as wait from 'gulp-wait';
18
- import merge from 'merge-stream';
19
4
  import * as os from 'os';
20
- import * as path from 'path';
21
5
  import * as dartSass from 'sass';
22
6
 
23
7
  import backendSettings from '../settings/backend-settings.json' assert { type: 'json' };
@@ -26,14 +10,18 @@ import pageSettings from '../settings/page-settings.json' assert { type: 'json'
26
10
  import publicSettings from '../settings/public-settings.json' assert { type: 'json' };
27
11
 
28
12
  import { buildPublic, buildPublicLib } from './gulp/public.js';
29
- import { buildBackend, buildBackendJSW } from './gulp/backend.js';
13
+ import { buildBackend, buildBackendJSW, buildBackendJSWLib, buildBackendLib } from './gulp/backend.js';
30
14
  import { checkPages, checkTs, checkTsLib } from './gulp/checks.js';
31
15
  import { compileScss } from './gulp/styles.js';
32
16
  import { buildPages } from './gulp/pages.js';
33
- import { previewTemplates } from './gulp/templates.js';
34
- import { copyFiles } from './gulp/copy.js';
35
- import { cleanWix } from './gulp/clean.js';
17
+ import { previewTemplates, previewTemplatesLib } from './gulp/templates.js';
18
+ import { copyFiles, copyFilesLib } from './gulp/copy.js';
19
+ import { cleanSrc, cleanWix } from './gulp/clean.js';
36
20
  import { addTypes, updateWixTypes } from './gulp/types.js';
21
+ import { setProdConfig } from './gulp/pipeline.js';
22
+ import { watchAll } from './gulp/watchers.js';
23
+ import { green, magenta, orange, red } from './index.js';
24
+ import { testLib, test } from './gulp/test.js';
37
25
 
38
26
  const sass = gulpSass(dartSass);
39
27
 
@@ -56,7 +44,6 @@ export interface File {
56
44
  // other properties...
57
45
  }
58
46
 
59
- let enableIncrementalBuild = false;
60
47
  const outputDir = './src';
61
48
  const userHomeDir = os.homedir();
62
49
  const replaceOpions = {
@@ -66,7 +53,7 @@ const replaceOpions = {
66
53
  };
67
54
 
68
55
  const taskOptions: TaskOptions = {
69
- enableIncrementalBuild,
56
+ enableIncrementalBuild: false,
70
57
  outputDir,
71
58
  sass,
72
59
  userHomeDir,
@@ -78,10 +65,6 @@ const taskOptions: TaskOptions = {
78
65
  cwd: process.cwd(),
79
66
  }
80
67
 
81
- gulp.task('check-pages', gulp.parallel(
82
- checkPages
83
- ));
84
-
85
68
  gulp.task('check-ts', gulp.parallel(
86
69
  checkTs(),
87
70
  checkTsLib(),
@@ -91,12 +74,11 @@ gulp.task('scss', gulp.parallel(
91
74
  compileScss(taskOptions),
92
75
  ));
93
76
 
94
- gulp.task('build-jsw', gulp.parallel(
95
- buildBackendJSW(taskOptions),
96
- ));
97
-
98
77
  gulp.task('build-backend', gulp.parallel(
99
78
  buildBackend(taskOptions),
79
+ buildBackendLib(taskOptions),
80
+ buildBackendJSW(taskOptions),
81
+ buildBackendJSWLib(taskOptions),
100
82
  ));
101
83
 
102
84
  gulp.task('build-public', gulp.parallel(
@@ -104,24 +86,23 @@ gulp.task('build-public', gulp.parallel(
104
86
  buildPublicLib(taskOptions),
105
87
  ));
106
88
 
107
- gulp.task('build-pages', gulp.parallel(
108
- buildPages(taskOptions),
109
- ));
110
-
111
89
  gulp.task('preview-templates', gulp.parallel(
112
- previewTemplates()
90
+ previewTemplates(),
91
+ previewTemplatesLib()
113
92
  ));
114
93
 
115
94
  gulp.task('copy-files', gulp.parallel(
116
- copyFiles(taskOptions)
95
+ copyFiles(taskOptions),
96
+ copyFilesLib(taskOptions)
117
97
  ));
118
98
 
119
- gulp.task('clean-wix',gulp.parallel(
120
- cleanWix()
99
+ gulp.task('test', gulp.parallel(
100
+ test(),
101
+ testLib(),
121
102
  ));
122
103
 
123
104
  gulp.task('sync-types', shell.task([
124
- // 'yarn postinstall',
105
+ 'yarn postinstall',
125
106
  ]));
126
107
 
127
108
  gulp.task('fix-wixtypes', gulp.parallel(
@@ -132,120 +113,71 @@ gulp.task('add-wix-types', function(done: gulp.TaskFunctionCallback) {
132
113
  return addTypes(taskOptions, done);
133
114
  });
134
115
 
135
- gulp.task('clean-src', async () => {
136
- return gulp.src([`${outputDir}/pages`, `${outputDir}/public`, `${outputDir}/backend`], { read: false, allowEmpty: true })
137
- .pipe(clean({ force: true }))
138
- .on('error', function () {
139
- console.log(chalk.red.underline.bold('Cleaning of output files failed!'));
140
- this.emit('end');
141
- })
142
- .on('end', function() { console.log(chalk.blueBright.underline('Cleaning of output files succeeded!')); });
143
- });
144
-
145
- gulp.task('set-production', function () {
146
- const droneTag = process.env.DRONE_TAG || 'development';
147
- const regexGit = /gitTag:\s*(.*),/g;
148
- const regexDev = /devMode:\s*(.*),/g;
149
-
150
- return gulp
151
- .src(['./typescript/public/constants/config.ts'])
152
- .pipe(replace(regexGit, `gitTag: '${droneTag}',`))
153
- .pipe(replace(regexDev, `devMode: false,`))
154
- .pipe(gulp.dest((file: File) => {
155
- const filePath = file.dirname;
156
- const outputDir = path.dirname(filePath);
157
-
158
- return path.join(`${outputDir}/constants`);
159
- }))
160
- .on('error', function () {
161
- console.log(chalk.red.underline.bold('Setting the git tag failed!'));
162
- this.emit('end');
163
- })
164
- .on('end', function() { console.log(chalk.blueBright.underline('Setting the git tag succeeded!')); });
165
- });
116
+ gulp.task('set-production', gulp.parallel(
117
+ setProdConfig()
118
+ ));
166
119
 
167
120
  gulp.task('start-wix', shell.task([
168
121
  'yarn wix:dev',
169
122
  ]));
170
123
 
171
- gulp.task('test-watch', shell.task([
172
- 'sleep 10; yarn test --watch',
173
- ]));
174
-
175
- gulp.task('test', shell.task([
176
- 'sleep 2; yarn test',
177
- ]));
178
-
179
124
  gulp.task('gen-docs', shell.task([
180
125
  'yarn docs',
181
126
  ]));
182
127
 
183
- gulp.task('watch-scss', () => {
184
- gulp.watch(['typescript/public/scss/**/*.scss'], gulp.series('scss'));
185
- });
186
-
187
- gulp.task('watch-jsw', () => {
188
- enableIncrementalBuild = true;
189
- gulp.watch(['typescript/backend/**/frontend.*.ts', 'wix-lucy-lib/backend/**/frontend.*.ts'], gulp.series('check-ts', 'build-jsw', 'test'));
190
- });
191
- gulp.task('watch-backend', () => {
192
- enableIncrementalBuild = true;
193
- gulp.watch([
194
- 'typescript/backend/**/*.ts',
195
- 'typescript/backend/**/*.tsx',
196
- '!typescript/backend/**/*.spec.ts',
197
- ], gulp.series('check-ts', 'build-backend', 'test'));
198
- });
199
- gulp.task('watch-public', () => {
200
- enableIncrementalBuild = true;
201
- gulp.watch([
202
- 'typescript/public/**/*.ts',
203
- 'typescript/public/**/*.tsx',
204
- 'wix-lucy-lib/src/public/**/*.ts',
205
- 'wix-lucy-lib/src/public/**/*.tsx'
206
- ], gulp.series('check-ts', 'build-public', 'test'));
207
- });
208
- gulp.task('watch-templates', () => {
209
- gulp.watch([
210
- 'typescript/backend/templates/**/*.tsx',
211
- 'typescript/backend/templates/data/*.json',
212
- '!typescript/backend/templates/render.ts',
213
- ], gulp.series('preview-templates'));
214
- });
215
-
216
- gulp.task('watch-pages', () => {
217
- enableIncrementalBuild = true;
218
- gulp.watch('typescript/pages/**/*.ts', gulp.series('check-ts', 'build-pages', 'test'));
219
- });
220
-
221
- gulp.task('watch-files', () => {
222
- enableIncrementalBuild = true;
223
- gulp.watch([
224
- 'typescript/backend/**/*',
225
- 'typescript/public/**/*',
226
- 'typescript/pages/**/*',
227
- '!typescript/**/*.ts',
228
- ], gulp.series('copy-files'));
229
- });
128
+ gulp.task('fix-wix', gulp.series(
129
+ cleanWix(),
130
+ 'sync-types',
131
+ 'fix-wixtypes',
132
+ 'add-wix-types'
133
+ ));
230
134
 
231
- gulp.task('watch-types', () => {
232
- enableIncrementalBuild = true;
233
- gulp.watch(['./.wix/types/**/*.d.ts', '!./.wix/types/wix-code-types'], gulp.series('fix-wixtypes'));
234
- });
135
+ gulp.task('build', gulp.parallel(
136
+ 'build-backend',
137
+ 'build-public',
138
+ buildPages(taskOptions),
139
+ compileScss(taskOptions),
140
+ 'copy-files'
141
+ )
142
+ );
143
+
144
+ gulp.task('build-pipeline', gulp.series(
145
+ cleanSrc(taskOptions),
146
+ 'set-production',
147
+ 'fix-wixtypes',
148
+ 'add-wix-types',
149
+ 'test',
150
+ 'build',
151
+ ));
235
152
 
236
- gulp.task('fix-wix', gulp.series('clean-wix', 'sync-types', 'fix-wixtypes', 'add-wix-types'));
237
- gulp.task('clean', gulp.series('clean-src'));
153
+ gulp.task('build-prod', gulp.series(
154
+ (done) => checkPages(true).then(() => done(), (err) => done(err)),
155
+ cleanSrc(taskOptions),
156
+ 'set-production',
157
+ 'fix-wix',
158
+ 'build-backend',
159
+ 'build-public',
160
+ buildPages(taskOptions),
161
+ 'copy-files',
162
+ compileScss(taskOptions),
163
+ 'gen-docs'
164
+ ));
238
165
 
239
- gulp.task('watch', gulp.parallel('watch-types', 'watch-jsw', 'watch-backend', 'watch-public', 'watch-pages', 'watch-files', 'watch-scss', 'watch-templates'));
240
- gulp.task('build-prod', gulp.series('clean', 'set-production', 'fix-wix', 'check-pages', 'build-jsw', 'build-backend', 'build-public', 'build-pages', 'copy-files', 'scss', 'gen-docs'));
241
- gulp.task('build', gulp.series('clean', 'fix-wix', 'check-ts', 'build-jsw', 'build-backend', 'build-public', 'build-pages', 'scss', 'copy-files'));
242
166
 
243
- gulp.task('fix-for-test', gulp.series('fix-wixtypes', 'add-wix-types'));
244
- gulp.task('build-pipeline', gulp.series('clean', 'set-production', 'build-jsw', 'build-backend', 'build-public', 'build-pages', 'copy-files', 'scss', 'gen-docs'));
167
+ gulp.task('start-dev-env', gulp.parallel(
168
+ watchAll(taskOptions),
169
+ 'test',
170
+ 'start-wix',
171
+ (done) => checkPages(false).then(() => done(), (err) => done(err)),
172
+ ));
245
173
 
246
- gulp.task('start-dev-env', gulp.parallel('watch', 'check-pages'));
247
- gulp.task('dev', gulp.series('build', 'start-dev-env', 'test-watch'));
248
- gulp.task('default', gulp.series('dev'));
174
+ gulp.task('dev', gulp.series(
175
+ cleanSrc(taskOptions),
176
+ 'fix-wix',
177
+ 'build',
178
+ 'start-dev-env',
179
+ )
180
+ );
249
181
 
250
182
  async function gulpTaskRunner(task: string) {
251
183
  return new Promise(function (resolve, reject) {
@@ -253,7 +185,7 @@ async function gulpTaskRunner(task: string) {
253
185
  resolve(true);
254
186
  done();
255
187
  })(function (err) {
256
- console.log('gulpTaskRunner', err);
188
+ console.log((`💩 ${red.underline.bold("=> Error starting tasks =>")} ${orange(err)}`));
257
189
  if (err) {
258
190
  reject(err);
259
191
  }
@@ -262,10 +194,8 @@ async function gulpTaskRunner(task: string) {
262
194
  }
263
195
 
264
196
  export async function runTask(task: string, cwd: string) {
265
- console.log('runTask', {task, cwd});
266
197
  taskOptions.cwd = cwd;
267
- console.log('runTask', {task, cwd});
268
- console.log('start');
198
+ console.log("🐕" + magenta.underline(' => Starting Task => ' + orange(task)));
269
199
  await gulpTaskRunner(task);
270
- console.log('end');
271
- }
200
+ console.log("🐶" + green.underline.bold(' => Task completed: ' + task));
201
+ }
package/src/dev.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  import gulp from 'gulp';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
+ import { ModuleSettings, ProjectSettings } from '.';
5
6
 
6
- export async function dev(cwd: string, arg: string[]) {
7
- console.log('dev', {cwd, arg});
7
+
8
+ export async function dev(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
8
9
  // Get the directory name of the current module
9
10
  const __filename = fileURLToPath(import.meta.url);
10
11
  const __dirname = path.dirname(__filename);
@@ -16,5 +17,5 @@ export async function dev(cwd: string, arg: string[]) {
16
17
  const gulpfile = await import(`file://${gulpfilePath}`);
17
18
 
18
19
  // Check if 'dev' task exists
19
- gulpfile.runTask('dev', cwd)
20
+ gulpfile.runTask('dev', moduleSettings.targetFolder)
20
21
  }
@@ -1,21 +1,21 @@
1
- import chalk from 'chalk';
2
1
  import gulp from 'gulp';
3
2
  import { createGulpEsbuild } from 'gulp-esbuild';
4
3
  import rename from 'gulp-rename';
5
4
  import * as path from 'path';
6
5
  import { TaskOptions } from '../Gulpfile';
7
-
6
+ import { blue, red } from '../index.js';
8
7
 
9
8
  export function buildBackend(options: TaskOptions) {
10
9
  const { outputDir, enableIncrementalBuild } = options;
11
10
  const gulpEsbuild = createGulpEsbuild({
12
11
  incremental: enableIncrementalBuild,
13
12
  });
13
+
14
14
  return () => {
15
15
  return gulp.src([
16
16
  'typescript/backend/**/*.ts',
17
17
  'typescript/backend/**/*.tsx',
18
- '!typescript/backend/**/frontend.*.ts',
18
+ '!typescript/backend/**/*.jsw.ts',
19
19
  '!typescript/backend/**/*.spec.ts',
20
20
  ])
21
21
  .pipe(gulpEsbuild({
@@ -23,10 +23,36 @@ export function buildBackend(options: TaskOptions) {
23
23
  }))
24
24
  .pipe(gulp.dest(path.join(outputDir, 'backend')))
25
25
  .on('error', function () {
26
- console.log(chalk.red.underline.bold('Build of Backend TS files failed!'));
26
+ console.log("💩" + red.underline.bold(' => Build of Backend TS files failed!'));
27
+ this.emit('end');
28
+ })
29
+ .on('end', function() { console.log("🐶" + blue.underline(' => Build of Backend TS files succeeded!'));
30
+ }
31
+ )}
32
+ }
33
+
34
+ export function buildBackendLib(options: TaskOptions) {
35
+ const { outputDir, enableIncrementalBuild } = options;
36
+ const gulpEsbuild = createGulpEsbuild({
37
+ incremental: enableIncrementalBuild,
38
+ });
39
+
40
+ return () => {
41
+ return gulp.src([
42
+ 'lucy-lib/backend/**/*.ts',
43
+ 'lucy-lib/backend/**/*.tsx',
44
+ '!lucy-lib/backend/**/*.jsw.ts',
45
+ '!lucy-lib/backend/**/*.spec.ts',
46
+ ])
47
+ .pipe(gulpEsbuild({
48
+ bundle: false,
49
+ }))
50
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
51
+ .on('error', function () {
52
+ console.log("💩" + red.underline.bold(' => Build of Backend TS (LIB) files failed!'));
27
53
  this.emit('end');
28
54
  })
29
- .on('end', function() { console.log(chalk.blueBright.underline('Build of Backend TS files succeeded!'));
55
+ .on('end', function() { console.log("🐶" + blue.underline(' => Build of Backend TS (LIB) files succeeded!'));
30
56
  }
31
57
  )}
32
58
  }
@@ -36,17 +62,39 @@ export function buildBackendJSW(options: TaskOptions) {
36
62
  const gulpEsbuild = createGulpEsbuild({
37
63
  incremental: enableIncrementalBuild,
38
64
  });
65
+
66
+ return () => {
67
+ return gulp.src(['typescript/backend/**/*.jsw.ts'])
68
+ .pipe(gulpEsbuild({
69
+ bundle: false,
70
+ }))
71
+ .pipe(rename({ extname: '' }))
72
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
73
+ .on('error', function () {
74
+ console.log("💩" + red.underline.bold(' => Build of JSW files failed!'));
75
+ this.emit('end');
76
+ })
77
+ .on('end', function() { console.log("🐶" + blue.underline(' => Build of (JSW) files succeeded!'))})
78
+ }
79
+ }
80
+
81
+ export function buildBackendJSWLib(options: TaskOptions) {
82
+ const { outputDir, enableIncrementalBuild } = options;
83
+ const gulpEsbuild = createGulpEsbuild({
84
+ incremental: enableIncrementalBuild,
85
+ });
86
+
39
87
  return () => {
40
- return gulp.src(['typescript/backend/**/*.jsw.ts', 'wix-lucy-lib/backend/**/*.jsw.ts'])
88
+ return gulp.src(['lucy-lib/backend/**/*.jsw.ts'])
41
89
  .pipe(gulpEsbuild({
42
90
  bundle: false,
43
91
  }))
44
- .pipe(rename({ extname: '.jsw' }))
92
+ .pipe(rename({ extname: '' }))
45
93
  .pipe(gulp.dest(path.join(outputDir, 'backend')))
46
94
  .on('error', function () {
47
- console.log(chalk.red.underline.bold('Build of JSW files failed!'));
95
+ console.log("💩" + red.underline.bold(' => Build of JSW (LIB) files failed!'));
48
96
  this.emit('end');
49
97
  })
50
- .on('end', function() { console.log(chalk.blueBright.underline('Build of JSW files succeeded!'))});
98
+ .on('end', function() { console.log("🐶" + blue.underline(' => Build of JSW (LIB) files succeeded!'))})
51
99
  }
52
100
  }
@@ -1,9 +1,9 @@
1
- import chalk from 'chalk';
2
1
  import * as fs from 'fs';
3
2
  import glob from 'glob';
4
3
  import * as path from 'path';
5
4
  import gulp from 'gulp';
6
5
  import ts from 'gulp-typescript';
6
+ import { blue, green, red, yellow } from '../index.js';
7
7
 
8
8
  /**
9
9
  * Extracts a match from a file
@@ -74,54 +74,61 @@ function readFilesInFolder(folderPath: string, pattern: string | null, globPatte
74
74
  });
75
75
  }
76
76
 
77
- export async function checkPages() {
78
- console.log(chalk.blueBright.underline.bold('Checking pages...'));
79
- const sourcePages = await readFilesInFolder('./.wix/types/', '\\/pages\\/(?<page>.*\\.ts)', '**/*.json',) as string[];
80
- const tsPages = await readFilesInFolder('./typescript/pages', null, '**/*.ts',) as string[];
81
-
82
- const sourcePagesSet = new Set(sourcePages);
83
- const tsPagesSet = new Set(tsPages);
84
- const missingInTs = Array.from(sourcePagesSet).filter((item: string) => !tsPages.includes(item));
85
- const obsoleteInTs = Array.from(tsPagesSet).filter((item: string) => !sourcePages.includes(item));
86
- if (missingInTs.length > 0){
87
- console.log(chalk.yellow.underline.bold('Missing in ts folder: '), '\n', missingInTs);
88
- throw new Error('Missing in ts folder');
89
- }
90
- if (obsoleteInTs.length > 0){
91
- console.log(chalk.yellow.underline.bold('Obsolete in ts folder'), '\n', obsoleteInTs);
92
- throw new Error('Obsolete in ts folder');
93
- }
94
- if (missingInTs.length === 0 || obsoleteInTs.length === 0) console.log(chalk.blueBright.underline.bold('Files are insync!'));
77
+ export async function checkPages(fail: boolean) {
78
+ console.log("🐕" + green.underline.bold(' => Checking pages...'));
79
+ return new Promise<void>(async (resolve, reject) => {
80
+ try {
81
+ const sourcePages = await readFilesInFolder('./.wix/types/', '\\/pages\\/(?<page>.*\\.ts)', '**/*.json',) as string[];
82
+ const tsPages = await readFilesInFolder('./typescript/pages', null, '**/*.ts',) as string[];
83
+
84
+ const sourcePagesSet = new Set(sourcePages);
85
+ const tsPagesSet = new Set(tsPages);
86
+ const missingInTs = Array.from(sourcePagesSet).filter((item: string) => !tsPages.includes(item));
87
+ const obsoleteInTs = Array.from(tsPagesSet).filter((item: string) => !sourcePages.includes(item));
88
+ if (missingInTs.length > 0){
89
+ console.log("🦴" + yellow.underline.bold(' => Missing in ts folder: '), '\n', missingInTs);
90
+ }
91
+ if (obsoleteInTs.length > 0){
92
+ console.log("🦴" + yellow.underline.bold(' => Obsolete in ts folder'), '\n', obsoleteInTs);
93
+ }
94
+ if (missingInTs.length === 0 || obsoleteInTs.length === 0) {
95
+ console.log("🐶" + blue.underline.bold(' => Pages are insync!'))
96
+ } else if(fail){
97
+ process.exit(1);
98
+ };
99
+ } catch (error) {
100
+ reject(error);
101
+ }
102
+ });
95
103
  }
96
104
 
97
105
  export function checkTs() {
98
- const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
99
-
106
+ const tsProject = ts.createProject('./lucy-lib/tsconfig.json', { noEmit: true });
100
107
  return () => {
101
- return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
108
+ return gulp.src(['lucy-lib/typescript/**/*.ts', '!lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
102
109
  .pipe(tsProject(ts.reporter.fullReporter()))
103
110
  .on('error', function () {
104
- console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
111
+ console.log("💩" + red.underline.bold(' => Typescript error!'));
105
112
  this.emit('end');
106
113
  })
107
114
  .on('end', function () {
108
- console.log(chalk.blueBright.underline('Typescript check succeeded!'));
115
+ console.log("🐶" + blue.underline(' => Typescriptcheck succeeded!'));
109
116
  });
110
117
  };
111
118
  }
112
119
 
113
120
  export function checkTsLib() {
114
- const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
115
-
121
+ const tsProject = ts.createProject('./lucy-lib/tsconfig.json', { noEmit: true });
122
+
116
123
  return () => {
117
- return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
124
+ return gulp.src(['lucy-lib/typescript/**/*.ts', '!lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
118
125
  .pipe(tsProject(ts.reporter.fullReporter()))
119
126
  .on('error', function () {
120
- console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
127
+ console.log("💩" + red.underline.bold(' => Typescript (LIB) error!'));
121
128
  this.emit('end');
122
129
  })
123
130
  .on('end', function () {
124
- console.log(chalk.blueBright.underline('Typescript check (LIB) succeeded!'));
131
+ console.log("🐶" + blue.underline(' => Typescript check (LIB) succeeded!'));
125
132
  });
126
133
  };
127
134
  }
package/src/gulp/clean.ts CHANGED
@@ -1,21 +1,31 @@
1
1
  import chalk from 'chalk';
2
2
  import gulp from 'gulp';
3
- import { createGulpEsbuild } from 'gulp-esbuild';
4
- import rename from 'gulp-rename';
5
- import * as path from 'path';
6
3
  import { TaskOptions } from '../Gulpfile';
7
4
  import clean from 'gulp-clean';
5
+ import { blue, red } from '../index.js';
8
6
 
9
-
10
- export function cleanWix() {
7
+ export function cleanWix() {
11
8
  return () => {
12
9
  return gulp.src('./.wix', { read: false, allowEmpty: true })
13
10
  .pipe(clean({ force: true }))
14
11
  .on('error', function () {
15
- console.log(chalk.red.underline.bold('Cleaning of .wix failed!'));
12
+ console.log("💩" + red.underline.bold(' => Cleaning of .wix failed!'));
16
13
  this.emit('end');
17
14
  })
18
- .on('end', function() { console.log(chalk.blueBright.underline('Cleaning of .wix succeeded!')); });
15
+ .on('end', function() { console.log("🐶" + blue.underline(' => Cleaning of .wix succeeded!')); });
19
16
  }
20
17
  }
21
18
 
19
+ export function cleanSrc(options: TaskOptions) {
20
+ const { outputDir } = options;
21
+
22
+ return () => {
23
+ return gulp.src([`${outputDir}/pages`, `${outputDir}/public`, `${outputDir}/backend`], { read: false, allowEmpty: true })
24
+ .pipe(clean({ force: true }))
25
+ .on('error', function () {
26
+ console.log("💩" + red.underline.bold('Cleaning of output files failed!'));
27
+ this.emit('end');
28
+ })
29
+ .on('end', function() { console.log("🐶" + blue.underline(' => Cleaning of .src succeeded!')); });
30
+ }
31
+ }
package/src/gulp/copy.ts CHANGED
@@ -1,11 +1,33 @@
1
1
  import gulp from 'gulp';
2
2
  import chalk from 'chalk';
3
3
  import { TaskOptions } from '../Gulpfile';
4
- import { createGulpEsbuild } from 'gulp-esbuild';
5
- import * as path from 'path';
4
+ import { blue, red } from '../index.js';
6
5
 
7
6
  export function copyFiles(options: TaskOptions) {
8
7
  const { outputDir} = options;
8
+
9
+ return () => {
10
+ return gulp.src([
11
+ 'typescript/**/*',
12
+ '!typescript/*tsconfig.json',
13
+ '!typescript/**/*.ts',
14
+ '!typescript/**/*.tsx',
15
+ '!typescript/types/**/**',
16
+ '!typescript/__mocks__/**/**',
17
+ '!typescript/styles/**',
18
+ ])
19
+ .pipe(gulp.dest(outputDir))
20
+ .on('error', function () {
21
+ console.log("💩" + red.underline.bold(' => Copy of files failed!'));
22
+ this.emit('end');
23
+ })
24
+ .on('end', function() { console.log("🐶" + blue.underline(' => Copy of files succeeded!')); });
25
+ }
26
+ }
27
+
28
+ export function copyFilesLib(options: TaskOptions) {
29
+ const { outputDir} = options;
30
+
9
31
  return () => {
10
32
  return gulp.src([
11
33
  'typescript/**/*',
@@ -14,13 +36,13 @@ export function copyFiles(options: TaskOptions) {
14
36
  '!typescript/**/*.tsx',
15
37
  '!typescript/types/**/**',
16
38
  '!typescript/__mocks__/**/**',
17
- '!typescript/public/scss/**',
39
+ '!typescript/styles/**',
18
40
  ])
19
41
  .pipe(gulp.dest(outputDir))
20
42
  .on('error', function () {
21
- console.log(chalk.red.underline.bold('Copy of files failed!'));
43
+ console.log("💩" + red.underline.bold(' => Copy of files (LIB) failed!'));
22
44
  this.emit('end');
23
45
  })
24
- .on('end', function() { console.log(chalk.blueBright.underline('Copy of files succeeded!')); });
46
+ .on('end', function() { console.log("🐶" + blue.underline(' => Copy of files (LIB) succeeded!')); });
25
47
  }
26
48
  }
package/src/gulp/pages.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import gulp from 'gulp';
2
- import chalk from 'chalk';
3
2
  import { TaskOptions } from '../Gulpfile';
4
3
  import { createGulpEsbuild } from 'gulp-esbuild';
5
4
  import * as path from 'path';
5
+ import { blue, red } from '../index.js';
6
6
 
7
7
  export function buildPages(options: TaskOptions) {
8
8
  const { outputDir, enableIncrementalBuild} = options;
9
9
  const gulpEsbuild = createGulpEsbuild({
10
10
  incremental: enableIncrementalBuild, // enables the esbuild's incremental build
11
11
  });
12
-
12
+
13
13
  return () => {
14
14
  return gulp.src('typescript/pages/*.ts')
15
15
  .pipe(gulpEsbuild({
@@ -17,9 +17,9 @@ export function buildPages(options: TaskOptions) {
17
17
  }))
18
18
  .pipe(gulp.dest(path.join(outputDir, 'pages')))
19
19
  .on('error', function () {
20
- console.log(chalk.red.underline.bold('Build of Pages TS files failed!'));
20
+ console.log("💩" + red.underline.bold(' => Build of Pages TS files failed!'));
21
21
  this.emit('end');
22
22
  })
23
- .on('end', function() { console.log(chalk.blueBright.underline('Build of Pages TS files succeeded!')); });
23
+ .on('end', function() { console.log("🐶" + blue.underline(' => Build of Pages TS files succeeded!')); });
24
24
  };
25
25
  }