lucy-cli 0.0.4

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 (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
package/.eslintrc.cjs ADDED
@@ -0,0 +1,96 @@
1
+ module.exports = {
2
+ extends: ['eslint:recommended', 'plugin:import/recommended', 'plugin:jsdoc/recommended', 'plugin:@typescript-eslint/recommended'],
3
+ plugins: ['simple-import-sort', 'eslint-plugin-named-import-spacing', '@typescript-eslint'],
4
+ parser: '@typescript-eslint/parser',
5
+ ignorePatterns: ['src/**/*', 'typescript/types/backend/**/*', 'typescript/types/pages/**/*', 'typescript/types/public/**/*', 'typescript/types/node/**/*', '.wix/**/*', 'coverage/**/*', 'docs/**/*'],
6
+ rules: {
7
+ quotes: [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
8
+ curly: ['error', 'multi-line'],
9
+ 'simple-import-sort/imports': 'error',
10
+ 'simple-import-sort/exports': 'error',
11
+ indent: ['error', 'tab'],
12
+ 'no-tabs': 0,
13
+ 'semi-style': ['error', 'last'],
14
+ semi: [2, 'always'],
15
+ 'object-curly-spacing': ['error', 'always'],
16
+ 'space-in-parens': ['error', 'never'],
17
+ 'newline-before-return': 'error',
18
+ 'space-before-blocks': ['error', { functions: 'always', keywords: 'never', classes: 'always' }],
19
+ 'comma-spacing': ['error', { before: false, after: true }],
20
+ 'no-multi-spaces': ['error'],
21
+ 'import/newline-after-import': ['error', { count: 1 }],
22
+ 'named-import-spacing/named-import-spacing': 2,
23
+ 'no-unused-vars': 'warn',
24
+ 'import/no-unresolved': [0],
25
+ 'no-forbidden-relative-imports': [0],
26
+ '@typescript-eslint/triple-slash-reference': 'off',
27
+ '@typescript-eslint/member-ordering': [
28
+ 'error',
29
+ { classes: ['constructor', 'private-instance-field', 'protected-instance-field', 'public-instance-field', 'public-instance-method', 'private-instance-method'] }
30
+ ],
31
+ '@typescript-eslint/naming-convention': [
32
+ 'error',
33
+ {
34
+ selector: ['variable', 'function'],
35
+ format: ['camelCase'],
36
+ leadingUnderscore: 'allow'
37
+ },
38
+ {
39
+ selector: ['objectLiteralProperty'],
40
+ format: null,
41
+ leadingUnderscore: 'allow'
42
+ },
43
+ {
44
+ selector: 'memberLike',
45
+ modifiers: ['private'],
46
+ format: ['camelCase'],
47
+ leadingUnderscore: 'require'
48
+ },
49
+ {
50
+ selector: 'memberLike',
51
+ modifiers: ['protected'],
52
+ format: ['camelCase'],
53
+ leadingUnderscore: 'require'
54
+ },
55
+ {
56
+ selector: 'memberLike',
57
+ modifiers: ['public'],
58
+ format: ['camelCase'],
59
+ leadingUnderscore: 'forbid'
60
+ },
61
+ {
62
+ selector: ['parameterProperty', 'parameter'],
63
+ format: ['camelCase'],
64
+ leadingUnderscore: 'forbid'
65
+ },
66
+ {
67
+ selector: 'default',
68
+ format: ['UPPER_CASE'],
69
+ leadingUnderscore: 'forbid',
70
+ trailingUnderscore: 'forbid',
71
+ custom: {
72
+ regex: '^[A-Z_]+$',
73
+ match: true
74
+ }
75
+ },
76
+ {
77
+ selector: 'typeLike',
78
+ format: ['PascalCase']
79
+ },
80
+ // Custom rule added
81
+ {
82
+ selector: 'function',
83
+ format: ['UPPER_CASE']
84
+ }
85
+ ],
86
+ },
87
+ root: true,
88
+ env: {
89
+ es6: true,
90
+ browser: true,
91
+ node: true
92
+ },
93
+ globals: {
94
+ $w: 'readonly'
95
+ }
96
+ };
package/.eslintrc.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["plugin:@wix/cli/recommended"]
3
+ }
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 20
package/.yarnrc.yml ADDED
@@ -0,0 +1,5 @@
1
+ nodeLinker: node-modules
2
+
3
+ npmRegistryServer: "https://registry.npmjs.org/"
4
+
5
+ yarnPath: .yarn/releases/yarn-3.7.0.cjs
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # wix-lucy
@@ -0,0 +1,28 @@
1
+ import gulpSass from 'gulp-sass';
2
+ import backendSettings from '../settings/backend-settings.json';
3
+ import masterSettings from '../settings/master-settings.json';
4
+ import pageSettings from '../settings/page-settings.json';
5
+ import publicSettings from '../settings/public-settings.json';
6
+ export type TaskOptions = {
7
+ enableIncrementalBuild: boolean;
8
+ outputDir: string;
9
+ sass: ReturnType<typeof gulpSass>;
10
+ userHomeDir: string;
11
+ replaceOpions: typeof replaceOpions;
12
+ backendSettings: typeof backendSettings;
13
+ masterSettings: typeof masterSettings;
14
+ pageSettings: typeof pageSettings;
15
+ publicSettings: typeof publicSettings;
16
+ cwd: string;
17
+ };
18
+ export interface File {
19
+ path: string;
20
+ dirname: string;
21
+ }
22
+ declare const replaceOpions: {
23
+ logs: {
24
+ enabled: boolean;
25
+ };
26
+ };
27
+ export declare function runTask(task: string, cwd: string): Promise<void>;
28
+ export {};
@@ -0,0 +1,179 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import clean from 'gulp-clean';
4
+ import gulpSass from 'gulp-sass';
5
+ import shell from 'gulp-shell';
6
+ import replace from 'gulp-string-replace';
7
+ import * as os from 'os';
8
+ import * as path from 'path';
9
+ import * as dartSass from 'sass';
10
+ import backendSettings from '../settings/backend-settings.json' assert { type: 'json' };
11
+ import masterSettings from '../settings/master-settings.json' assert { type: 'json' };
12
+ import pageSettings from '../settings/page-settings.json' assert { type: 'json' };
13
+ import publicSettings from '../settings/public-settings.json' assert { type: 'json' };
14
+ import { buildPublic, buildPublicLib } from './gulp/public.js';
15
+ import { buildBackend, buildBackendJSW } from './gulp/backend.js';
16
+ import { checkPages, checkTs, checkTsLib } from './gulp/checks.js';
17
+ import { compileScss } from './gulp/styles.js';
18
+ import { buildPages } from './gulp/pages.js';
19
+ import { previewTemplates } from './gulp/templates.js';
20
+ import { copyFiles } from './gulp/copy.js';
21
+ import { cleanWix } from './gulp/clean.js';
22
+ import { addTypes, updateWixTypes } from './gulp/types.js';
23
+ const sass = gulpSass(dartSass);
24
+ let enableIncrementalBuild = false;
25
+ const outputDir = './src';
26
+ const userHomeDir = os.homedir();
27
+ const replaceOpions = {
28
+ logs: {
29
+ enabled: false
30
+ }
31
+ };
32
+ const taskOptions = {
33
+ enableIncrementalBuild,
34
+ outputDir,
35
+ sass,
36
+ userHomeDir,
37
+ pageSettings,
38
+ publicSettings,
39
+ backendSettings,
40
+ masterSettings,
41
+ replaceOpions,
42
+ cwd: process.cwd(),
43
+ };
44
+ gulp.task('check-pages', gulp.parallel(checkPages));
45
+ gulp.task('check-ts', gulp.parallel(checkTs(), checkTsLib()));
46
+ gulp.task('scss', gulp.parallel(compileScss(taskOptions)));
47
+ gulp.task('build-jsw', gulp.parallel(buildBackendJSW(taskOptions)));
48
+ gulp.task('build-backend', gulp.parallel(buildBackend(taskOptions)));
49
+ gulp.task('build-public', gulp.parallel(buildPublic(taskOptions), buildPublicLib(taskOptions)));
50
+ gulp.task('build-pages', gulp.parallel(buildPages(taskOptions)));
51
+ gulp.task('preview-templates', gulp.parallel(previewTemplates()));
52
+ gulp.task('copy-files', gulp.parallel(copyFiles(taskOptions)));
53
+ gulp.task('clean-wix', gulp.parallel(cleanWix()));
54
+ gulp.task('sync-types', shell.task([
55
+ // 'yarn postinstall',
56
+ ]));
57
+ gulp.task('fix-wixtypes', gulp.parallel(updateWixTypes(taskOptions)));
58
+ gulp.task('add-wix-types', function (done) {
59
+ return addTypes(taskOptions, done);
60
+ });
61
+ gulp.task('clean-src', async () => {
62
+ return gulp.src([`${outputDir}/pages`, `${outputDir}/public`, `${outputDir}/backend`], { read: false, allowEmpty: true })
63
+ .pipe(clean({ force: true }))
64
+ .on('error', function () {
65
+ console.log(chalk.red.underline.bold('Cleaning of output files failed!'));
66
+ this.emit('end');
67
+ })
68
+ .on('end', function () { console.log(chalk.blueBright.underline('Cleaning of output files succeeded!')); });
69
+ });
70
+ gulp.task('set-production', function () {
71
+ const droneTag = process.env.DRONE_TAG || 'development';
72
+ const regexGit = /gitTag:\s*(.*),/g;
73
+ const regexDev = /devMode:\s*(.*),/g;
74
+ return gulp
75
+ .src(['./typescript/public/constants/config.ts'])
76
+ .pipe(replace(regexGit, `gitTag: '${droneTag}',`))
77
+ .pipe(replace(regexDev, `devMode: false,`))
78
+ .pipe(gulp.dest((file) => {
79
+ const filePath = file.dirname;
80
+ const outputDir = path.dirname(filePath);
81
+ return path.join(`${outputDir}/constants`);
82
+ }))
83
+ .on('error', function () {
84
+ console.log(chalk.red.underline.bold('Setting the git tag failed!'));
85
+ this.emit('end');
86
+ })
87
+ .on('end', function () { console.log(chalk.blueBright.underline('Setting the git tag succeeded!')); });
88
+ });
89
+ gulp.task('start-wix', shell.task([
90
+ 'yarn wix:dev',
91
+ ]));
92
+ gulp.task('test-watch', shell.task([
93
+ 'sleep 10; yarn test --watch',
94
+ ]));
95
+ gulp.task('test', shell.task([
96
+ 'sleep 2; yarn test',
97
+ ]));
98
+ gulp.task('gen-docs', shell.task([
99
+ 'yarn docs',
100
+ ]));
101
+ gulp.task('watch-scss', () => {
102
+ gulp.watch(['typescript/public/scss/**/*.scss'], gulp.series('scss'));
103
+ });
104
+ gulp.task('watch-jsw', () => {
105
+ enableIncrementalBuild = true;
106
+ gulp.watch(['typescript/backend/**/frontend.*.ts', 'wix-lucy-lib/backend/**/frontend.*.ts'], gulp.series('check-ts', 'build-jsw', 'test'));
107
+ });
108
+ gulp.task('watch-backend', () => {
109
+ enableIncrementalBuild = true;
110
+ gulp.watch([
111
+ 'typescript/backend/**/*.ts',
112
+ 'typescript/backend/**/*.tsx',
113
+ '!typescript/backend/**/*.spec.ts',
114
+ ], gulp.series('check-ts', 'build-backend', 'test'));
115
+ });
116
+ gulp.task('watch-public', () => {
117
+ enableIncrementalBuild = true;
118
+ gulp.watch([
119
+ 'typescript/public/**/*.ts',
120
+ 'typescript/public/**/*.tsx',
121
+ 'wix-lucy-lib/src/public/**/*.ts',
122
+ 'wix-lucy-lib/src/public/**/*.tsx'
123
+ ], gulp.series('check-ts', 'build-public', 'test'));
124
+ });
125
+ gulp.task('watch-templates', () => {
126
+ gulp.watch([
127
+ 'typescript/backend/templates/**/*.tsx',
128
+ 'typescript/backend/templates/data/*.json',
129
+ '!typescript/backend/templates/render.ts',
130
+ ], gulp.series('preview-templates'));
131
+ });
132
+ gulp.task('watch-pages', () => {
133
+ enableIncrementalBuild = true;
134
+ gulp.watch('typescript/pages/**/*.ts', gulp.series('check-ts', 'build-pages', 'test'));
135
+ });
136
+ gulp.task('watch-files', () => {
137
+ enableIncrementalBuild = true;
138
+ gulp.watch([
139
+ 'typescript/backend/**/*',
140
+ 'typescript/public/**/*',
141
+ 'typescript/pages/**/*',
142
+ '!typescript/**/*.ts',
143
+ ], gulp.series('copy-files'));
144
+ });
145
+ gulp.task('watch-types', () => {
146
+ enableIncrementalBuild = true;
147
+ gulp.watch(['./.wix/types/**/*.d.ts', '!./.wix/types/wix-code-types'], gulp.series('fix-wixtypes'));
148
+ });
149
+ gulp.task('fix-wix', gulp.series('clean-wix', 'sync-types', 'fix-wixtypes', 'add-wix-types'));
150
+ gulp.task('clean', gulp.series('clean-src'));
151
+ gulp.task('watch', gulp.parallel('watch-types', 'watch-jsw', 'watch-backend', 'watch-public', 'watch-pages', 'watch-files', 'watch-scss', 'watch-templates'));
152
+ 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'));
153
+ gulp.task('build', gulp.series('clean', 'fix-wix', 'check-ts', 'build-jsw', 'build-backend', 'build-public', 'build-pages', 'scss', 'copy-files'));
154
+ gulp.task('fix-for-test', gulp.series('fix-wixtypes', 'add-wix-types'));
155
+ gulp.task('build-pipeline', gulp.series('clean', 'set-production', 'build-jsw', 'build-backend', 'build-public', 'build-pages', 'copy-files', 'scss', 'gen-docs'));
156
+ gulp.task('start-dev-env', gulp.parallel('watch', 'check-pages'));
157
+ gulp.task('dev', gulp.series('build', 'start-dev-env', 'test-watch'));
158
+ gulp.task('default', gulp.series('dev'));
159
+ async function gulpTaskRunner(task) {
160
+ return new Promise(function (resolve, reject) {
161
+ gulp.series(task, (done) => {
162
+ resolve(true);
163
+ done();
164
+ })(function (err) {
165
+ console.log('gulpTaskRunner', err);
166
+ if (err) {
167
+ reject(err);
168
+ }
169
+ });
170
+ });
171
+ }
172
+ export async function runTask(task, cwd) {
173
+ console.log('runTask', { task, cwd });
174
+ taskOptions.cwd = cwd;
175
+ console.log('runTask', { task, cwd });
176
+ console.log('start');
177
+ await gulpTaskRunner(task);
178
+ console.log('end');
179
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import { helloWorld } from './index.js';
3
+ const args = process.argv.slice(2);
4
+ const cwd = process.cwd();
5
+ /**
6
+ *
7
+ */
8
+ function main() {
9
+ console.log({ args, cwd });
10
+ if (args.includes('help') || args.includes('-h')) {
11
+ console.log('Help is on the way!');
12
+ return;
13
+ }
14
+ if (args.includes('version') || args.includes('-v')) {
15
+ console.log('1.0.0');
16
+ return;
17
+ }
18
+ if (args.includes('init')) {
19
+ helloWorld();
20
+ return;
21
+ }
22
+ if (args.includes('sync')) {
23
+ console.log('Hello serve');
24
+ return;
25
+ }
26
+ }
27
+ main();
28
+ // const fs = require("fs"),
29
+ // path = require("path")
30
+ // /** Parse the command line */
31
+ // var args = process.argv.slice(2);
32
+ // // Validate input
33
+ // if (args.length !== 2) {
34
+ // console.log("Warning: Requires 2 arguments");
35
+ // console.log("node index.js [path/source.html] [targetfile]");
36
+ // process.exit();
37
+ // }
38
+ // const src = args[0];
39
+ // const target = args[1];
40
+ // const dirsrc = path.dirname(src);
41
+ // if (!fs.existsSync(src)) {
42
+ // console.log("Error: Source file doesn't exist. Given: ", src);
43
+ // process.exit();
44
+ // }
package/dist/dev.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function dev(cwd: string, arg: string[]): Promise<void>;
package/dist/dev.js ADDED
@@ -0,0 +1,14 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ export async function dev(cwd, arg) {
4
+ console.log('dev', { cwd, arg });
5
+ // Get the directory name of the current module
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ // Resolve the path to the Gulpfile
9
+ const gulpfilePath = path.resolve(__dirname, 'Gulpfile.js');
10
+ // Dynamically import the Gulpfile
11
+ const gulpfile = await import(`file://${gulpfilePath}`);
12
+ // Check if 'dev' task exists
13
+ gulpfile.runTask('dev', cwd);
14
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { TaksOptions } from '../Gulpfile';
3
+ export declare function buildPublic(options: TaksOptions): () => NodeJS.ReadWriteStream;
4
+ export declare function buildPublicLib(options: TaksOptions): () => NodeJS.ReadWriteStream;
@@ -0,0 +1,50 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import { createGulpEsbuild } from 'gulp-esbuild';
4
+ import * as path from 'path';
5
+ export function buildPublic(options) {
6
+ const { outputDir, enableIncrementalBuild } = options;
7
+ const gulpEsbuild = createGulpEsbuild({
8
+ incremental: enableIncrementalBuild,
9
+ });
10
+ return () => {
11
+ return gulp.src([
12
+ 'typescript/public/**/*.ts',
13
+ 'typescript/public/**/*.tsx',
14
+ ])
15
+ .pipe(gulpEsbuild({
16
+ bundle: false,
17
+ }))
18
+ .pipe(gulp.dest(path.join(outputDir, 'public')))
19
+ .on('error', function () {
20
+ console.log(chalk.red.underline.bold('Build of Public TS files failed!'));
21
+ this.emit('end');
22
+ })
23
+ .on('end', function () {
24
+ console.log(chalk.blueBright.underline('Build of Public TS files succeeded!'));
25
+ });
26
+ };
27
+ }
28
+ export function buildPublicLib(options) {
29
+ const { outputDir, enableIncrementalBuild } = options;
30
+ const gulpEsbuild = createGulpEsbuild({
31
+ incremental: enableIncrementalBuild,
32
+ });
33
+ return () => {
34
+ return gulp.src([
35
+ 'wix-lucy-lib/src/public/**/*.ts',
36
+ 'wix-lucy-lib/src/public/**/*.tsx'
37
+ ])
38
+ .pipe(gulpEsbuild({
39
+ bundle: false,
40
+ }))
41
+ .pipe(gulp.dest(path.join(outputDir, 'public')))
42
+ .on('error', function () {
43
+ console.log(chalk.red.underline.bold('Build of Public (LIB) TS files failed!'));
44
+ this.emit('end');
45
+ })
46
+ .on('end', function () {
47
+ console.log(chalk.blueBright.underline('Build of Public (LIB) TS files succeeded!'));
48
+ });
49
+ };
50
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { TaskOptions } from '../Gulpfile';
3
+ export declare function buildBackend(options: TaskOptions): () => NodeJS.ReadWriteStream;
4
+ export declare function buildBackendJSW(options: TaskOptions): () => NodeJS.ReadWriteStream;
@@ -0,0 +1,49 @@
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
+ export function buildBackend(options) {
7
+ const { outputDir, enableIncrementalBuild } = options;
8
+ const gulpEsbuild = createGulpEsbuild({
9
+ incremental: enableIncrementalBuild,
10
+ });
11
+ return () => {
12
+ return gulp.src([
13
+ 'typescript/backend/**/*.ts',
14
+ 'typescript/backend/**/*.tsx',
15
+ '!typescript/backend/**/frontend.*.ts',
16
+ '!typescript/backend/**/*.spec.ts',
17
+ ])
18
+ .pipe(gulpEsbuild({
19
+ bundle: false,
20
+ }))
21
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
22
+ .on('error', function () {
23
+ console.log(chalk.red.underline.bold('Build of Backend TS files failed!'));
24
+ this.emit('end');
25
+ })
26
+ .on('end', function () {
27
+ console.log(chalk.blueBright.underline('Build of Backend TS files succeeded!'));
28
+ });
29
+ };
30
+ }
31
+ export function buildBackendJSW(options) {
32
+ const { outputDir, enableIncrementalBuild } = options;
33
+ const gulpEsbuild = createGulpEsbuild({
34
+ incremental: enableIncrementalBuild,
35
+ });
36
+ return () => {
37
+ return gulp.src(['typescript/backend/**/*.jsw.ts', 'wix-lucy-lib/backend/**/*.jsw.ts'])
38
+ .pipe(gulpEsbuild({
39
+ bundle: false,
40
+ }))
41
+ .pipe(rename({ extname: '.jsw' }))
42
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
43
+ .on('error', function () {
44
+ console.log(chalk.red.underline.bold('Build of JSW files failed!'));
45
+ this.emit('end');
46
+ })
47
+ .on('end', function () { console.log(chalk.blueBright.underline('Build of JSW files succeeded!')); });
48
+ };
49
+ }
@@ -0,0 +1,3 @@
1
+ export declare function checkPages(): Promise<void>;
2
+ export declare function checkTs(): () => import("gulp-typescript/release/project").ICompileStream;
3
+ export declare function checkTsLib(): () => import("gulp-typescript/release/project").ICompileStream;
@@ -0,0 +1,119 @@
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
+ * Extracts a match from a file
9
+ * @param {string} filePath File path
10
+ * @param {string} pattern Pattern to match
11
+ */
12
+ function extractMatchFromFile(filePath, pattern) {
13
+ return new Promise((resolve, reject) => {
14
+ fs.readFile(filePath, 'utf8', (err, data) => {
15
+ if (err) {
16
+ reject(err);
17
+ return;
18
+ }
19
+ const regex = new RegExp(pattern);
20
+ const match = regex.exec(data);
21
+ const capturedGroup = match ? match.groups?.page : null;
22
+ resolve(capturedGroup);
23
+ });
24
+ });
25
+ }
26
+ /**
27
+ * Reads files in a folder
28
+ * @param {string} folderPath Folder path
29
+ * @param {string} pattern Pattern to match
30
+ * @param {string} globPattern Glob pattern
31
+ */
32
+ function readFilesInFolder(folderPath, pattern, globPattern) {
33
+ return new Promise((resolve, reject) => {
34
+ glob(path.join(folderPath, globPattern), (err, files) => {
35
+ if (err) {
36
+ reject(err);
37
+ return;
38
+ }
39
+ const filenameList = [];
40
+ /**
41
+ * Traverse files
42
+ * @param {number} index Index
43
+ */
44
+ function traverseFiles(index) {
45
+ if (index === files.length) {
46
+ resolve(filenameList);
47
+ return;
48
+ }
49
+ const file = files[index];
50
+ if (pattern) {
51
+ if (!file)
52
+ return;
53
+ extractMatchFromFile(file, pattern)
54
+ .then((capturedGroup) => {
55
+ if (capturedGroup) {
56
+ filenameList.push(capturedGroup);
57
+ }
58
+ traverseFiles(index + 1);
59
+ })
60
+ .catch(reject);
61
+ }
62
+ if (!pattern) {
63
+ if (!file)
64
+ return;
65
+ filenameList.push(path.basename(file));
66
+ traverseFiles(index + 1);
67
+ }
68
+ }
69
+ traverseFiles(0);
70
+ });
71
+ });
72
+ }
73
+ export async function checkPages() {
74
+ console.log(chalk.blueBright.underline.bold('Checking pages...'));
75
+ const sourcePages = await readFilesInFolder('./.wix/types/', '\\/pages\\/(?<page>.*\\.ts)', '**/*.json');
76
+ const tsPages = await readFilesInFolder('./typescript/pages', null, '**/*.ts');
77
+ const sourcePagesSet = new Set(sourcePages);
78
+ const tsPagesSet = new Set(tsPages);
79
+ const missingInTs = Array.from(sourcePagesSet).filter((item) => !tsPages.includes(item));
80
+ const obsoleteInTs = Array.from(tsPagesSet).filter((item) => !sourcePages.includes(item));
81
+ if (missingInTs.length > 0) {
82
+ console.log(chalk.yellow.underline.bold('Missing in ts folder: '), '\n', missingInTs);
83
+ throw new Error('Missing in ts folder');
84
+ }
85
+ if (obsoleteInTs.length > 0) {
86
+ console.log(chalk.yellow.underline.bold('Obsolete in ts folder'), '\n', obsoleteInTs);
87
+ throw new Error('Obsolete in ts folder');
88
+ }
89
+ if (missingInTs.length === 0 || obsoleteInTs.length === 0)
90
+ console.log(chalk.blueBright.underline.bold('Files are insync!'));
91
+ }
92
+ export function checkTs() {
93
+ const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
94
+ return () => {
95
+ return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
96
+ .pipe(tsProject(ts.reporter.fullReporter()))
97
+ .on('error', function () {
98
+ console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
99
+ this.emit('end');
100
+ })
101
+ .on('end', function () {
102
+ console.log(chalk.blueBright.underline('Typescript check succeeded!'));
103
+ });
104
+ };
105
+ }
106
+ export function checkTsLib() {
107
+ const tsProject = ts.createProject('./wix-lucy-lib/tsconfig.json', { noEmit: true });
108
+ return () => {
109
+ return gulp.src(['wix-lucy-lib/typescript/**/*.ts', '!wix-lucy-lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
110
+ .pipe(tsProject(ts.reporter.fullReporter()))
111
+ .on('error', function () {
112
+ console.log(chalk.red.underline.bold('Typescript (LIB) error!'));
113
+ this.emit('end');
114
+ })
115
+ .on('end', function () {
116
+ console.log(chalk.blueBright.underline('Typescript check (LIB) succeeded!'));
117
+ });
118
+ };
119
+ }
@@ -0,0 +1,2 @@
1
+ import { TaksOptions } from '../Gulpfile';
2
+ export declare function cleanWix(options: TaksOptions): () => any;
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import { createGulpEsbuild } from 'gulp-esbuild';
4
+ import clean from 'gulp-clean';
5
+ export function cleanWix(options) {
6
+ const { outputDir, enableIncrementalBuild } = options;
7
+ const gulpEsbuild = createGulpEsbuild({
8
+ incremental: enableIncrementalBuild,
9
+ });
10
+ return () => {
11
+ return gulp.src('./.wix', { read: false, allowEmpty: true })
12
+ .pipe(clean({ force: true }))
13
+ .on('error', function () {
14
+ console.log(chalk.red.underline.bold('Cleaning of .wix failed!'));
15
+ this.emit('end');
16
+ })
17
+ .on('end', function () { console.log(chalk.blueBright.underline('Cleaning of .wix succeeded!')); });
18
+ };
19
+ }
@@ -0,0 +1 @@
1
+ export declare function cleanWix(): () => any;
@@ -0,0 +1,14 @@
1
+ import chalk from 'chalk';
2
+ import gulp from 'gulp';
3
+ import clean from 'gulp-clean';
4
+ export function cleanWix() {
5
+ return () => {
6
+ return gulp.src('./.wix', { read: false, allowEmpty: true })
7
+ .pipe(clean({ force: true }))
8
+ .on('error', function () {
9
+ console.log(chalk.red.underline.bold('Cleaning of .wix failed!'));
10
+ this.emit('end');
11
+ })
12
+ .on('end', function () { console.log(chalk.blueBright.underline('Cleaning of .wix succeeded!')); });
13
+ };
14
+ }