lucy-cli 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/.drone/.drone.yml +156 -0
  2. package/.drone/mail_prod_build.hbs +319 -0
  3. package/.drone/mail_prod_deploy.hbs +309 -0
  4. package/.drone/mail_satges.hbs +309 -0
  5. package/.drone/telegram_prod_build.tpl +23 -0
  6. package/.drone/telegram_prod_deploy.tpl +20 -0
  7. package/.drone/telegram_stages.tpl +20 -0
  8. package/.eslintrc.cjs +96 -0
  9. package/.eslintrc.json +3 -0
  10. package/.nvmrc +1 -0
  11. package/.yarnrc.yml +5 -0
  12. package/README.md +1 -0
  13. package/dist/Gulpfile.d.ts +28 -0
  14. package/dist/Gulpfile.js +179 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +44 -0
  17. package/dist/dev.d.ts +1 -0
  18. package/dist/dev.js +14 -0
  19. package/dist/gulp/backend copy.d.ts +4 -0
  20. package/dist/gulp/backend copy.js +50 -0
  21. package/dist/gulp/backend.d.ts +4 -0
  22. package/dist/gulp/backend.js +49 -0
  23. package/dist/gulp/checks.d.ts +3 -0
  24. package/dist/gulp/checks.js +119 -0
  25. package/dist/gulp/clean copy.d.ts +2 -0
  26. package/dist/gulp/clean copy.js +19 -0
  27. package/dist/gulp/clean.d.ts +1 -0
  28. package/dist/gulp/clean.js +14 -0
  29. package/dist/gulp/copy.d.ts +3 -0
  30. package/dist/gulp/copy.js +22 -0
  31. package/dist/gulp/pages copy.d.ts +3 -0
  32. package/dist/gulp/pages copy.js +22 -0
  33. package/dist/gulp/pages.d.ts +3 -0
  34. package/dist/gulp/pages.js +22 -0
  35. package/dist/gulp/public.d.ts +4 -0
  36. package/dist/gulp/public.js +50 -0
  37. package/dist/gulp/styles.d.ts +3 -0
  38. package/dist/gulp/styles.js +17 -0
  39. package/dist/gulp/templates.d.ts +1 -0
  40. package/dist/gulp/templates.js +21 -0
  41. package/dist/gulp/types.d.ts +5 -0
  42. package/dist/gulp/types.js +73 -0
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.js +88 -0
  45. package/dist/init.d.ts +7 -0
  46. package/dist/init.js +176 -0
  47. package/dist/settings.json +91 -0
  48. package/files/.drone/.drone.yml +156 -0
  49. package/files/.drone/mail_prod_build.hbs +319 -0
  50. package/files/.drone/mail_prod_deploy.hbs +309 -0
  51. package/files/.drone/mail_satges.hbs +309 -0
  52. package/files/.drone/telegram_prod_build.tpl +23 -0
  53. package/files/.drone/telegram_prod_deploy.tpl +20 -0
  54. package/files/.drone/telegram_stages.tpl +20 -0
  55. package/files/.eslintrc.cjs +96 -0
  56. package/files/.eslintrc.json +3 -0
  57. package/files/.nvmrc +1 -0
  58. package/files/.yarnrc.yml +5 -0
  59. package/files/currents.config.js +5 -0
  60. package/files/cypress.config.ts +12 -0
  61. package/files/docs.tsconfig.json +37 -0
  62. package/files/jest.config.ts +28 -0
  63. package/files/lucy.json +5 -0
  64. package/files/tsconfig.json +51 -0
  65. package/files/typedoc.json +19 -0
  66. package/files/typescript/.eslintrc.json +35 -0
  67. package/files/typescript/__mocks__/.gitkeep +0 -0
  68. package/files/typescript/backend/index.ts +0 -0
  69. package/files/typescript/backend/permissions.json +0 -0
  70. package/files/typescript/pages/.gitkeep +0 -0
  71. package/files/typescript/public/index.ts +0 -0
  72. package/files/typescript/styles/.gitkeep +0 -0
  73. package/files/typescript/styles/global.scss +0 -0
  74. package/files/typescript/tsconfig.json +45 -0
  75. package/files/typescript/types/.gitkeep +0 -0
  76. package/package.json +83 -0
  77. package/settings/backend-settings.json +19 -0
  78. package/settings/master-settings.json +17 -0
  79. package/settings/page-settings.json +18 -0
  80. package/settings/public-settings.json +21 -0
  81. package/src/Gulpfile.ts +271 -0
  82. package/src/dev.ts +20 -0
  83. package/src/gulp/backend.ts +52 -0
  84. package/src/gulp/checks.ts +127 -0
  85. package/src/gulp/clean.ts +21 -0
  86. package/src/gulp/copy.ts +26 -0
  87. package/src/gulp/pages.ts +25 -0
  88. package/src/gulp/public.ts +56 -0
  89. package/src/gulp/styles.ts +20 -0
  90. package/src/gulp/templates.ts +25 -0
  91. package/src/gulp/types.ts +87 -0
  92. package/src/index.ts +132 -0
  93. package/src/init.ts +191 -0
  94. package/src/settings.json +91 -0
  95. package/src/types.d.ts +5 -0
  96. package/tsconfig.json +34 -0
@@ -0,0 +1,271 @@
1
+ import chalk from 'chalk';
2
+ import * as fs from 'fs';
3
+ import glob from 'glob';
4
+ 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
+ import gulpSass from 'gulp-sass';
13
+ 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
+ import * as os from 'os';
20
+ import * as path from 'path';
21
+ import * as dartSass from 'sass';
22
+
23
+ import backendSettings from '../settings/backend-settings.json' assert { type: 'json' };
24
+ import masterSettings from '../settings/master-settings.json' assert { type: 'json' };
25
+ import pageSettings from '../settings/page-settings.json' assert { type: 'json' };
26
+ import publicSettings from '../settings/public-settings.json' assert { type: 'json' };
27
+
28
+ import { buildPublic, buildPublicLib } from './gulp/public.js';
29
+ import { buildBackend, buildBackendJSW } from './gulp/backend.js';
30
+ import { checkPages, checkTs, checkTsLib } from './gulp/checks.js';
31
+ import { compileScss } from './gulp/styles.js';
32
+ 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';
36
+ import { addTypes, updateWixTypes } from './gulp/types.js';
37
+
38
+ const sass = gulpSass(dartSass);
39
+
40
+ export type TaskOptions = {
41
+ enableIncrementalBuild: boolean;
42
+ outputDir: string;
43
+ sass: ReturnType<typeof gulpSass>;
44
+ userHomeDir: string;
45
+ replaceOpions: typeof replaceOpions;
46
+ backendSettings: typeof backendSettings,
47
+ masterSettings: typeof masterSettings,
48
+ pageSettings: typeof pageSettings,
49
+ publicSettings: typeof publicSettings,
50
+ cwd: string;
51
+ }
52
+
53
+ export interface File {
54
+ path: string;
55
+ dirname: string;
56
+ // other properties...
57
+ }
58
+
59
+ let enableIncrementalBuild = false;
60
+ const outputDir = './src';
61
+ const userHomeDir = os.homedir();
62
+ const replaceOpions = {
63
+ logs: {
64
+ enabled: false
65
+ }
66
+ };
67
+
68
+ const taskOptions: TaskOptions = {
69
+ enableIncrementalBuild,
70
+ outputDir,
71
+ sass,
72
+ userHomeDir,
73
+ pageSettings,
74
+ publicSettings,
75
+ backendSettings,
76
+ masterSettings,
77
+ replaceOpions,
78
+ cwd: process.cwd(),
79
+ }
80
+
81
+ gulp.task('check-pages', gulp.parallel(
82
+ checkPages
83
+ ));
84
+
85
+ gulp.task('check-ts', gulp.parallel(
86
+ checkTs(),
87
+ checkTsLib(),
88
+ ));
89
+
90
+ gulp.task('scss', gulp.parallel(
91
+ compileScss(taskOptions),
92
+ ));
93
+
94
+ gulp.task('build-jsw', gulp.parallel(
95
+ buildBackendJSW(taskOptions),
96
+ ));
97
+
98
+ gulp.task('build-backend', gulp.parallel(
99
+ buildBackend(taskOptions),
100
+ ));
101
+
102
+ gulp.task('build-public', gulp.parallel(
103
+ buildPublic(taskOptions),
104
+ buildPublicLib(taskOptions),
105
+ ));
106
+
107
+ gulp.task('build-pages', gulp.parallel(
108
+ buildPages(taskOptions),
109
+ ));
110
+
111
+ gulp.task('preview-templates', gulp.parallel(
112
+ previewTemplates()
113
+ ));
114
+
115
+ gulp.task('copy-files', gulp.parallel(
116
+ copyFiles(taskOptions)
117
+ ));
118
+
119
+ gulp.task('clean-wix',gulp.parallel(
120
+ cleanWix()
121
+ ));
122
+
123
+ gulp.task('sync-types', shell.task([
124
+ // 'yarn postinstall',
125
+ ]));
126
+
127
+ gulp.task('fix-wixtypes', gulp.parallel(
128
+ updateWixTypes(taskOptions)
129
+ ));
130
+
131
+ gulp.task('add-wix-types', function(done: gulp.TaskFunctionCallback) {
132
+ return addTypes(taskOptions, done);
133
+ });
134
+
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
+ });
166
+
167
+ gulp.task('start-wix', shell.task([
168
+ 'yarn wix:dev',
169
+ ]));
170
+
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
+ gulp.task('gen-docs', shell.task([
180
+ 'yarn docs',
181
+ ]));
182
+
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
+ });
230
+
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
+ });
235
+
236
+ gulp.task('fix-wix', gulp.series('clean-wix', 'sync-types', 'fix-wixtypes', 'add-wix-types'));
237
+ gulp.task('clean', gulp.series('clean-src'));
238
+
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
+
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'));
245
+
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'));
249
+
250
+ async function gulpTaskRunner(task: string) {
251
+ return new Promise(function (resolve, reject) {
252
+ gulp.series(task, (done) => {
253
+ resolve(true);
254
+ done();
255
+ })(function (err) {
256
+ console.log('gulpTaskRunner', err);
257
+ if (err) {
258
+ reject(err);
259
+ }
260
+ });
261
+ });
262
+ }
263
+
264
+ export async function runTask(task: string, cwd: string) {
265
+ console.log('runTask', {task, cwd});
266
+ taskOptions.cwd = cwd;
267
+ console.log('runTask', {task, cwd});
268
+ console.log('start');
269
+ await gulpTaskRunner(task);
270
+ console.log('end');
271
+ }
package/src/dev.ts ADDED
@@ -0,0 +1,20 @@
1
+ // https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
2
+ import gulp from 'gulp';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ export async function dev(cwd: string, arg: string[]) {
7
+ console.log('dev', {cwd, arg});
8
+ // Get the directory name of the current module
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ // Resolve the path to the Gulpfile
13
+ const gulpfilePath = path.resolve(__dirname, 'Gulpfile.js');
14
+
15
+ // Dynamically import the Gulpfile
16
+ const gulpfile = await import(`file://${gulpfilePath}`);
17
+
18
+ // Check if 'dev' task exists
19
+ gulpfile.runTask('dev', cwd)
20
+ }
@@ -0,0 +1,52 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import { createGulpEsbuild } from 'gulp-esbuild';
4
+ import rename from 'gulp-rename';
5
+ import * as path from 'path';
6
+ import { TaskOptions } from '../Gulpfile';
7
+
8
+
9
+ export function buildBackend(options: TaskOptions) {
10
+ const { outputDir, enableIncrementalBuild } = options;
11
+ const gulpEsbuild = createGulpEsbuild({
12
+ incremental: enableIncrementalBuild,
13
+ });
14
+ return () => {
15
+ return gulp.src([
16
+ 'typescript/backend/**/*.ts',
17
+ 'typescript/backend/**/*.tsx',
18
+ '!typescript/backend/**/frontend.*.ts',
19
+ '!typescript/backend/**/*.spec.ts',
20
+ ])
21
+ .pipe(gulpEsbuild({
22
+ bundle: false,
23
+ }))
24
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
25
+ .on('error', function () {
26
+ console.log(chalk.red.underline.bold('Build of Backend TS files failed!'));
27
+ this.emit('end');
28
+ })
29
+ .on('end', function() { console.log(chalk.blueBright.underline('Build of Backend TS files succeeded!'));
30
+ }
31
+ )}
32
+ }
33
+
34
+ export function buildBackendJSW(options: TaskOptions) {
35
+ const { outputDir, enableIncrementalBuild } = options;
36
+ const gulpEsbuild = createGulpEsbuild({
37
+ incremental: enableIncrementalBuild,
38
+ });
39
+ return () => {
40
+ return gulp.src(['typescript/backend/**/*.jsw.ts', 'wix-lucy-lib/backend/**/*.jsw.ts'])
41
+ .pipe(gulpEsbuild({
42
+ bundle: false,
43
+ }))
44
+ .pipe(rename({ extname: '.jsw' }))
45
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
46
+ .on('error', function () {
47
+ console.log(chalk.red.underline.bold('Build of JSW files failed!'));
48
+ this.emit('end');
49
+ })
50
+ .on('end', function() { console.log(chalk.blueBright.underline('Build of JSW files succeeded!'))});
51
+ }
52
+ }
@@ -0,0 +1,127 @@
1
+ import chalk from 'chalk';
2
+ import * as fs from 'fs';
3
+ import glob from 'glob';
4
+ import * as path from 'path';
5
+ import gulp from 'gulp';
6
+ import ts from 'gulp-typescript';
7
+
8
+ /**
9
+ * Extracts a match from a file
10
+ * @param {string} filePath File path
11
+ * @param {string} pattern Pattern to match
12
+ */
13
+ function extractMatchFromFile(filePath: string, pattern: string) {
14
+ return new Promise((resolve, reject) => {
15
+ fs.readFile(filePath, 'utf8', (err, data) => {
16
+ if (err){
17
+ reject(err);
18
+
19
+ return;
20
+ }
21
+ const regex = new RegExp(pattern);
22
+ const match = regex.exec(data);
23
+ const capturedGroup = match ? match.groups?.page : null;
24
+ resolve(capturedGroup);
25
+ });
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Reads files in a folder
31
+ * @param {string} folderPath Folder path
32
+ * @param {string} pattern Pattern to match
33
+ * @param {string} globPattern Glob pattern
34
+ */
35
+ function readFilesInFolder(folderPath: string, pattern: string | null, globPattern: string,) {
36
+ return new Promise((resolve, reject) => {
37
+ glob(path.join(folderPath, globPattern), (err: unknown, files: string[]) => {
38
+ if (err){
39
+ reject(err);
40
+
41
+ return;
42
+ }
43
+ const filenameList: Object[] = [];
44
+ /**
45
+ * Traverse files
46
+ * @param {number} index Index
47
+ */
48
+ function traverseFiles(index: number) {
49
+ if (index === files.length){
50
+ resolve(filenameList);
51
+
52
+ return;
53
+ }
54
+ const file = files[index];
55
+ if(pattern){
56
+ if(!file) return
57
+ extractMatchFromFile(file, pattern)
58
+ .then((capturedGroup) => {
59
+ if (capturedGroup){
60
+ filenameList.push(capturedGroup);
61
+ }
62
+ traverseFiles(index + 1);
63
+ })
64
+ .catch(reject);
65
+ }
66
+ if(!pattern){
67
+ if(!file) return
68
+ filenameList.push(path.basename(file));
69
+ traverseFiles(index + 1);
70
+ }
71
+ }
72
+ traverseFiles(0);
73
+ });
74
+ });
75
+ }
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!'));
95
+ }
96
+
97
+ export function checkTs() {
98
+ const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
99
+
100
+ return () => {
101
+ return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
102
+ .pipe(tsProject(ts.reporter.fullReporter()))
103
+ .on('error', function () {
104
+ console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
105
+ this.emit('end');
106
+ })
107
+ .on('end', function () {
108
+ console.log(chalk.blueBright.underline('Typescript check succeeded!'));
109
+ });
110
+ };
111
+ }
112
+
113
+ export function checkTsLib() {
114
+ const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
115
+
116
+ return () => {
117
+ return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
118
+ .pipe(tsProject(ts.reporter.fullReporter()))
119
+ .on('error', function () {
120
+ console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
121
+ this.emit('end');
122
+ })
123
+ .on('end', function () {
124
+ console.log(chalk.blueBright.underline('Typescript check (LIB) succeeded!'));
125
+ });
126
+ };
127
+ }
@@ -0,0 +1,21 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import { createGulpEsbuild } from 'gulp-esbuild';
4
+ import rename from 'gulp-rename';
5
+ import * as path from 'path';
6
+ import { TaskOptions } from '../Gulpfile';
7
+ import clean from 'gulp-clean';
8
+
9
+
10
+ export function cleanWix() {
11
+ return () => {
12
+ return gulp.src('./.wix', { read: false, allowEmpty: true })
13
+ .pipe(clean({ force: true }))
14
+ .on('error', function () {
15
+ console.log(chalk.red.underline.bold('Cleaning of .wix failed!'));
16
+ this.emit('end');
17
+ })
18
+ .on('end', function() { console.log(chalk.blueBright.underline('Cleaning of .wix succeeded!')); });
19
+ }
20
+ }
21
+
@@ -0,0 +1,26 @@
1
+ import gulp from 'gulp';
2
+ import chalk from 'chalk';
3
+ import { TaskOptions } from '../Gulpfile';
4
+ import { createGulpEsbuild } from 'gulp-esbuild';
5
+ import * as path from 'path';
6
+
7
+ export function copyFiles(options: TaskOptions) {
8
+ const { outputDir} = options;
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/public/scss/**',
18
+ ])
19
+ .pipe(gulp.dest(outputDir))
20
+ .on('error', function () {
21
+ console.log(chalk.red.underline.bold('Copy of files failed!'));
22
+ this.emit('end');
23
+ })
24
+ .on('end', function() { console.log(chalk.blueBright.underline('Copy of files succeeded!')); });
25
+ }
26
+ }
@@ -0,0 +1,25 @@
1
+ import gulp from 'gulp';
2
+ import chalk from 'chalk';
3
+ import { TaskOptions } from '../Gulpfile';
4
+ import { createGulpEsbuild } from 'gulp-esbuild';
5
+ import * as path from 'path';
6
+
7
+ export function buildPages(options: TaskOptions) {
8
+ const { outputDir, enableIncrementalBuild} = options;
9
+ const gulpEsbuild = createGulpEsbuild({
10
+ incremental: enableIncrementalBuild, // enables the esbuild's incremental build
11
+ });
12
+
13
+ return () => {
14
+ return gulp.src('typescript/pages/*.ts')
15
+ .pipe(gulpEsbuild({
16
+ bundle: false,
17
+ }))
18
+ .pipe(gulp.dest(path.join(outputDir, 'pages')))
19
+ .on('error', function () {
20
+ console.log(chalk.red.underline.bold('Build of Pages TS files failed!'));
21
+ this.emit('end');
22
+ })
23
+ .on('end', function() { console.log(chalk.blueBright.underline('Build of Pages TS files succeeded!')); });
24
+ };
25
+ }
@@ -0,0 +1,56 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import { createGulpEsbuild } from 'gulp-esbuild';
4
+
5
+ import * as path from 'path';
6
+ import { TaskOptions } from '../Gulpfile';
7
+
8
+
9
+ export function buildPublic(options: TaskOptions) {
10
+ const { outputDir, enableIncrementalBuild } = options;
11
+ const gulpEsbuild = createGulpEsbuild({
12
+ incremental: enableIncrementalBuild,
13
+ });
14
+ return () => {
15
+ return gulp.src([
16
+ 'typescript/public/**/*.ts',
17
+ 'typescript/public/**/*.tsx',
18
+ ])
19
+ .pipe(gulpEsbuild({
20
+ bundle: false,
21
+ }))
22
+ .pipe(gulp.dest(path.join(outputDir, 'public')))
23
+ .on('error', function () {
24
+ console.log(chalk.red.underline.bold('Build of Public TS files failed!'));
25
+ this.emit('end');
26
+ })
27
+ .on('end', function () {
28
+ console.log(chalk.blueBright.underline('Build of Public TS files succeeded!'));
29
+ });
30
+ };
31
+ }
32
+ export function buildPublicLib(options: TaskOptions) {
33
+ const { outputDir, enableIncrementalBuild } = options;
34
+ const gulpEsbuild = createGulpEsbuild({
35
+ incremental: enableIncrementalBuild,
36
+ });
37
+ return () => {
38
+ return gulp.src([
39
+ 'wix-lucy-lib/src/public/**/*.ts',
40
+ 'wix-lucy-lib/src/public/**/*.tsx'
41
+ ])
42
+ .pipe(gulpEsbuild({
43
+ bundle: false,
44
+ }))
45
+ .pipe(gulp.dest(path.join(outputDir, 'public')))
46
+ .on('error', function () {
47
+ console.log(chalk.red.underline.bold('Build of Public (LIB) TS files failed!'));
48
+ this.emit('end');
49
+ })
50
+ .on('end', function () {
51
+ console.log(chalk.blueBright.underline('Build of Public (LIB) TS files succeeded!'));
52
+ });
53
+ };
54
+ }
55
+
56
+
@@ -0,0 +1,20 @@
1
+ import gulp from 'gulp';
2
+ import chalk from 'chalk';
3
+ import { TaskOptions } from '../Gulpfile';
4
+
5
+
6
+ export function compileScss(options: TaskOptions) {
7
+ const { sass, outputDir} = options;
8
+ return () => {
9
+ return gulp.src(['typescript/styles/global.scss' ])
10
+ .pipe(sass().on('error', sass.logError))
11
+ .pipe(gulp.dest(`${outputDir}/public/css`))
12
+ .on('error', function () {
13
+ console.log(chalk.red.underline.bold('Compiling of scss files failed!'));
14
+ this.emit('end');
15
+ })
16
+ .on('end', function () {
17
+ console.log(chalk.blueBright.underline('Compiling of scss files succeeded!'));
18
+ });
19
+ };
20
+ }
@@ -0,0 +1,25 @@
1
+ import gulp from 'gulp';
2
+ import chalk from 'chalk';
3
+ import { File } from '../Gulpfile';
4
+ import { createGulpEsbuild } from 'gulp-esbuild';
5
+ import * as path from 'path';
6
+ import exec from 'gulp-exec';
7
+
8
+ export function previewTemplates() {
9
+ const options = {
10
+ continueOnError: true,
11
+ };
12
+ return () => {
13
+ return gulp.src([
14
+ 'typescript/backend/templates/**/*.tsx',
15
+ 'typescript/backend/templates/data/*.json',
16
+ '!typescript/backend/templates/render.ts',
17
+ ])
18
+ .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, options))
19
+ .on('error', function () {
20
+ console.log(chalk.red.underline.bold('Render of Template failed!'));
21
+ this.emit('end');
22
+ })
23
+ .on('end', function() { console.log(chalk.blueBright.underline('Render of Template succeeded!')); });
24
+ };
25
+ }