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
@@ -0,0 +1,30 @@
1
+ import gulp from 'gulp';
2
+ import * as path from 'path';
3
+ import { File } from '../Gulpfile';
4
+ import replace from 'gulp-string-replace';
5
+ import { blue, red } from '../index.js';
6
+
7
+ export function setProdConfig() {
8
+ const droneTag = process.env.DRONE_TAG || 'development';
9
+ const regexGit = /gitTag:\s*(.*),/g;
10
+ const regexDev = /devMode:\s*(.*),/g;
11
+
12
+ return () => {
13
+ return gulp
14
+ .src(['./typescript/public/constants/config.ts'])
15
+ .pipe(replace(regexGit, `gitTag: '${droneTag}',`))
16
+ .pipe(replace(regexDev, `devMode: false,`))
17
+ .pipe(gulp.dest((file: File) => {
18
+ const filePath = file.dirname;
19
+ const outputDir = path.dirname(filePath);
20
+
21
+ return path.join(`${outputDir}/constants`);
22
+ }))
23
+ .on('error', function () {
24
+ console.log("💩" + red.underline.bold(' => Setting the git tag failed!'));
25
+ this.emit('end');
26
+ })
27
+ .on('end', function() { console.log("🐶" + blue.underline(' => Setting the git tag succeeded!'));
28
+ });
29
+ }
30
+ }
@@ -1,16 +1,16 @@
1
- import chalk from 'chalk';
2
1
  import gulp from 'gulp';
3
2
  import { createGulpEsbuild } from 'gulp-esbuild';
4
3
 
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 buildPublic(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/public/**/*.ts',
@@ -18,37 +18,45 @@ export function buildPublic(options: TaskOptions) {
18
18
  ])
19
19
  .pipe(gulpEsbuild({
20
20
  bundle: false,
21
+ loader: {
22
+ '.tsx': 'tsx',
23
+ },
21
24
  }))
22
25
  .pipe(gulp.dest(path.join(outputDir, 'public')))
23
26
  .on('error', function () {
24
- console.log(chalk.red.underline.bold('Build of Public TS files failed!'));
27
+ console.log("💩" + red.underline.bold(' => Build of Public TS files failed!'));
25
28
  this.emit('end');
26
29
  })
27
30
  .on('end', function () {
28
- console.log(chalk.blueBright.underline('Build of Public TS files succeeded!'));
31
+ console.log("🐶" + blue.underline(' => Build of Public TS files succeeded!'));
29
32
  });
30
33
  };
31
34
  }
35
+
32
36
  export function buildPublicLib(options: TaskOptions) {
33
37
  const { outputDir, enableIncrementalBuild } = options;
34
38
  const gulpEsbuild = createGulpEsbuild({
35
39
  incremental: enableIncrementalBuild,
36
40
  });
41
+
37
42
  return () => {
38
43
  return gulp.src([
39
- 'wix-lucy-lib/src/public/**/*.ts',
40
- 'wix-lucy-lib/src/public/**/*.tsx'
44
+ 'lucy-lib/public/**/*.ts',
45
+ 'lucy-lib/public/**/*.tsx'
41
46
  ])
42
47
  .pipe(gulpEsbuild({
43
48
  bundle: false,
49
+ loader: {
50
+ '.tsx': 'tsx',
51
+ },
44
52
  }))
45
53
  .pipe(gulp.dest(path.join(outputDir, 'public')))
46
54
  .on('error', function () {
47
- console.log(chalk.red.underline.bold('Build of Public (LIB) TS files failed!'));
55
+ console.log("💩" + red.underline.bold(' => Build of Public (LIB) TS files failed!'));
48
56
  this.emit('end');
49
57
  })
50
58
  .on('end', function () {
51
- console.log(chalk.blueBright.underline('Build of Public (LIB) TS files succeeded!'));
59
+ console.log("🐶" + blue.underline(' => Build of Public (LIB) TS files succeeded!'));
52
60
  });
53
61
  };
54
62
  }
@@ -1,20 +1,21 @@
1
1
  import gulp from 'gulp';
2
2
  import chalk from 'chalk';
3
3
  import { TaskOptions } from '../Gulpfile';
4
-
4
+ import { blue, red } from '../index.js';
5
5
 
6
6
  export function compileScss(options: TaskOptions) {
7
7
  const { sass, outputDir} = options;
8
+
8
9
  return () => {
9
- return gulp.src(['typescript/styles/global.scss' ])
10
+ return gulp.src(['typescript/styles/global.scss'])
10
11
  .pipe(sass().on('error', sass.logError))
11
- .pipe(gulp.dest(`${outputDir}/public/css`))
12
+ .pipe(gulp.dest(`${outputDir}/styles`))
12
13
  .on('error', function () {
13
- console.log(chalk.red.underline.bold('Compiling of scss files failed!'));
14
+ console.log("💩" + red.underline.bold(' => Compiling of scss files failed!'));
14
15
  this.emit('end');
15
16
  })
16
17
  .on('end', function () {
17
- console.log(chalk.blueBright.underline('Compiling of scss files succeeded!'));
18
+ console.log("🐶" + blue.underline(' => Compiling of scss files succeeded!'));
18
19
  });
19
20
  };
20
21
  }
@@ -1,14 +1,13 @@
1
1
  import gulp from 'gulp';
2
- import chalk from 'chalk';
3
2
  import { File } from '../Gulpfile';
4
- import { createGulpEsbuild } from 'gulp-esbuild';
5
- import * as path from 'path';
6
3
  import exec from 'gulp-exec';
4
+ import { blue, red } from '../index.js';
7
5
 
8
6
  export function previewTemplates() {
9
7
  const options = {
10
8
  continueOnError: true,
11
9
  };
10
+
12
11
  return () => {
13
12
  return gulp.src([
14
13
  'typescript/backend/templates/**/*.tsx',
@@ -17,9 +16,29 @@ export function previewTemplates() {
17
16
  ])
18
17
  .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, options))
19
18
  .on('error', function () {
20
- console.log(chalk.red.underline.bold('Render of Template failed!'));
19
+ console.log("💩" + red.underline.bold(' => Render of Template failed!'));
20
+ this.emit('end');
21
+ })
22
+ .on('end', function() { console.log("🐶" + blue.underline(' => Render of Template succeeded!')); });
23
+ };
24
+ }
25
+
26
+ export function previewTemplatesLib() {
27
+ const options = {
28
+ continueOnError: true,
29
+ };
30
+
31
+ return () => {
32
+ return gulp.src([
33
+ 'lucy-lib/backend/templates/**/*.tsx',
34
+ 'lucy-lib/backend/templates/data/*.json',
35
+ '!lucy-lib/backend/templates/render.ts',
36
+ ])
37
+ .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, options))
38
+ .on('error', function () {
39
+ console.log("💩" + red.underline.bold(' => Render of Template (LIB) failed!'));
21
40
  this.emit('end');
22
41
  })
23
- .on('end', function() { console.log(chalk.blueBright.underline('Render of Template succeeded!')); });
42
+ .on('end', function() { console.log("🐶" + blue.underline(' => Render of Template (LIB) succeeded!')); });
24
43
  };
25
44
  }
@@ -0,0 +1,82 @@
1
+ import gulp from 'gulp';
2
+ import { blue, red } from '../index.js';
3
+ import gulpJest from 'gulp-jest';
4
+ const jest = gulpJest.default;
5
+
6
+ export function test() {
7
+ return () => {
8
+ return gulp.src([
9
+ 'typescript/backend/**/*.spec.ts',
10
+ ])
11
+ .pipe(jest({
12
+ verbose: true,
13
+ extensionsToTreatAsEsm: ['.ts'],
14
+ transform: {
15
+ '^.+\\.tsx?$': [
16
+ 'ts-jest',
17
+ {
18
+ tsconfig: './typescript/tsconfig.json',
19
+ usESM: true,
20
+ },
21
+ ],
22
+ },
23
+ preset: 'ts-jest',
24
+ setupFilesAfterEnv: [],
25
+ testEnvironment: 'node',
26
+ collectCoverage: true,
27
+ coverageDirectory: '../coverage',
28
+ coverageReporters: ['clover', 'json', 'lcov', 'text'],
29
+ rootDir: './typescript',
30
+ testMatch: ['**/*.spec.ts'],
31
+ passWithNoTests: true,
32
+ moduleNameMapper: {
33
+ 'public/(.*)': '<rootDir>/public/$1'
34
+ }
35
+ }))
36
+ .on('error', function () {
37
+ console.log("💩" + red.underline.bold(' => Tests failed!'));
38
+ this.emit('end');
39
+ })
40
+ .on('end', function() { console.log("🐶" + blue.underline(' => Test succeeded!'));
41
+ }
42
+ )}
43
+ }
44
+
45
+ export function testLib() {
46
+ return () => {
47
+ return gulp.src([
48
+ 'lucy-lib/backend/**/*.spec.ts',
49
+ ])
50
+ .pipe(jest({
51
+ verbose: true,
52
+ extensionsToTreatAsEsm: ['.ts'],
53
+ transform: {
54
+ '^.+\\.tsx?$': [
55
+ 'ts-jest',
56
+ {
57
+ tsconfig: './lucy-lib/tsconfig.json',
58
+ usESM: true,
59
+ },
60
+ ],
61
+ },
62
+ preset: 'ts-jest',
63
+ setupFilesAfterEnv: [],
64
+ testEnvironment: 'node',
65
+ collectCoverage: true,
66
+ passWithNoTests: true,
67
+ coverageDirectory: './coverage',
68
+ coverageReporters: ['clover', 'json', 'lcov', 'text'],
69
+ rootDir: './lucy-lib',
70
+ testMatch: ['**/*.spec.ts'],
71
+ moduleNameMapper: {
72
+ 'public/(.*)': '<rootDir>/public/$1'
73
+ }
74
+ }))
75
+ .on('error', function () {
76
+ console.log("💩" + red.underline.bold(' => Test (LIB) failed!'));
77
+ this.emit('end');
78
+ })
79
+ .on('end', function() { console.log("🐶" + blue.underline(' => Test (LIB) succeeded!'));
80
+ }
81
+ )}
82
+ }
package/src/gulp/types.ts CHANGED
@@ -1,19 +1,17 @@
1
- import chalk from 'chalk';
2
1
  import gulp from 'gulp';
3
- import { createGulpEsbuild } from 'gulp-esbuild';
4
- import rename from 'gulp-rename';
5
2
  import * as path from 'path';
6
3
  import { File, TaskOptions } from '../Gulpfile';
7
- import clean from 'gulp-clean';
8
4
  import replace from 'gulp-string-replace';
9
5
  import foreach from 'gulp-foreach';
10
6
  import jeditor from 'gulp-json-editor';
11
7
  import merge from 'merge-stream';
12
8
  import * as insert from 'gulp-insert';
9
+ import { blue, red, yellow } from '../index.js';
13
10
 
14
11
  export function updateWixTypes(options: TaskOptions) {
15
12
  const { publicSettings, backendSettings, masterSettings, pageSettings, replaceOpions } = options;
16
13
  let count = 0;
14
+
17
15
  return () => {
18
16
  return gulp.src(['./.wix/types/*/*.json', '!./.wix/types/wix-code-types/*.json'])
19
17
  .pipe(foreach(function(stream: NodeJS.ReadableStream, file: File) {
@@ -37,17 +35,16 @@ export function updateWixTypes(options: TaskOptions) {
37
35
  return path.join(outputDir);
38
36
  }))
39
37
  .on('error', function () {
40
- console.log(chalk.red.underline.bold('Modification of WIX configs failed!'));
38
+ console.log("💩" + red.underline.bold('Modification of WIX configs failed!'));
41
39
  this.emit('end');
42
40
  })
43
- .on('end', function() { console.log(chalk.blueBright.underline(`Modification of ${count} WIX configs succeeded!`)); });
41
+ .on('end', function() { console.log("🐶" + blue.underline(`Modification of ${yellow(count)} WIX configs succeeded!`)); });
44
42
  }
45
43
  }
46
44
 
47
-
48
45
  export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback): NodeJS.ReadWriteStream {
49
- const { replaceOpions, cwd } = options;
50
- console.log('CWD', cwd);
46
+ const { replaceOpions } = options;
47
+
51
48
  const processPages = gulp.src(['./.wix/types/wix-code-types/dist/types/page/$w.d.ts'])
52
49
  .pipe(replace('declare namespace \\$w {', ' declare namespace $w{\nconst api: $w.Api;\n', replaceOpions))
53
50
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/page/'));
@@ -65,7 +62,7 @@ export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback):
65
62
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/beta/common/'));
66
63
 
67
64
  const processCommon = gulp.src(['./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
68
- .pipe(insert.prepend("import { FrontendAPISchema } from '../../../../../../typescript/public/models/common/frontendApi.model';\nimport '@total-typescript/ts-reset';\n"))
65
+ .pipe(insert.prepend("import { FrontendAPISchema } from '../../../../../../lucy-lib/public/models/common/frontendApi.model';\nimport '@total-typescript/ts-reset';\n"))
69
66
  .pipe(replace('namespace \\$w {', 'declare namespace $w{\ntype Api = FrontendAPISchema;\n', replaceOpions))
70
67
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
71
68
 
@@ -76,12 +73,12 @@ export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback):
76
73
  exportTypes,
77
74
  )
78
75
  .on('error', function() {
79
- console.log(chalk.red.underline.bold('Add of new Types (store & Global) failed!'));
76
+ console.log("💩" + red.underline.bold(' => Updating WIX failed!'));
80
77
  this.emit('end');
81
78
  done();
82
79
  })
83
80
  .on('end', function() {
84
- console.log(chalk.blueBright.underline('Add of new Types (store & Global) succeeded!'));
81
+ console.log("🐶" + blue.underline(' => Updating WIX succeeded!'));
85
82
  done();
86
83
  });
87
84
  };
@@ -0,0 +1,175 @@
1
+ import gulp from 'gulp';
2
+ import { TaskOptions } from '../Gulpfile.js';
3
+ import { green } from '../index.js';
4
+ import { buildBackend, buildBackendJSW, buildBackendJSWLib, buildBackendLib } from './backend.js';
5
+ import { buildPublic, buildPublicLib } from './public.js';
6
+ import { buildPages } from './pages.js';
7
+ import { copyFiles, copyFilesLib } from './copy.js';
8
+ import { previewTemplates, previewTemplatesLib } from './templates.js';
9
+ import { checkPages, checkTs, checkTsLib } from './checks.js';
10
+ import { testLib, test } from './test.js';
11
+
12
+ let taskOptions: TaskOptions;
13
+
14
+ export function watchSCSS() {
15
+ return gulp.watch([
16
+ 'typescript/styles/**/*.scss',
17
+ 'lucy-lib/styles/**/*.scss'],
18
+ gulp.parallel('scss')
19
+ );
20
+ }
21
+
22
+ export function watchBackend() {
23
+ return gulp.watch([
24
+ 'typescript/backend/**/*.ts',
25
+ 'typescript/backend/**/*.tsx',
26
+ '!typescript/backend/**/*.spec.ts',
27
+ '!typescript/backend/**/*.jsw.ts',
28
+ ], gulp.parallel(
29
+ test(),
30
+ checkTs(),
31
+ buildBackend(taskOptions),
32
+ )
33
+ );
34
+ }
35
+
36
+ export function watchBackendLib() {
37
+ return gulp.watch([
38
+ 'lucy-lib/backend/**/*.ts',
39
+ 'lucy-lib/backend/**/*.tsx',
40
+ '!lucy-lib/backend/**/*.spec.ts',
41
+ '!lucy-lib/backend/**/*.jsw.ts',
42
+ ], gulp.parallel(
43
+ testLib(),
44
+ checkTsLib(),
45
+ buildBackendLib(taskOptions)
46
+ )
47
+ );
48
+ }
49
+
50
+ export function watchJSW() {
51
+ return gulp.watch(['typescript/backend/**/*.jsw.ts'],
52
+ gulp.parallel(
53
+ test(),
54
+ checkTs(),
55
+ buildBackendJSW(taskOptions)
56
+ )
57
+ );
58
+ }
59
+
60
+ export function watchJSWLib() {
61
+ return gulp.watch(['lucy-lib/backend/**/*.jsw.ts'],
62
+ gulp.parallel(
63
+ testLib(),
64
+ checkTsLib(),
65
+ buildBackendJSWLib(taskOptions)
66
+ )
67
+ );
68
+ }
69
+
70
+ export function watchPublic() {
71
+ return gulp.watch([
72
+ 'typescript/public/**/*.ts',
73
+ 'typescript/public/**/*.tsx',
74
+ ], gulp.parallel(
75
+ test(),
76
+ checkTs(),
77
+ buildPublic(taskOptions),
78
+ )
79
+ );
80
+ }
81
+
82
+ export function watchPublicLib() {
83
+ return gulp.watch([
84
+ 'lucy-lib/public/**/*.ts',
85
+ 'lucy-lib/public/**/*.tsx',
86
+ ], gulp.parallel(
87
+ testLib(),
88
+ checkTsLib(),
89
+ buildPublicLib(taskOptions),
90
+ )
91
+ );
92
+ }
93
+
94
+ export function watchPages() {
95
+ return gulp.watch('typescript/pages/**/*.ts',
96
+ gulp.parallel(
97
+ checkTs(),
98
+ buildPages(taskOptions),
99
+ )
100
+ );
101
+ }
102
+
103
+ export function watchFiles() {
104
+ return gulp.watch([
105
+ 'typescript/backend/**/*',
106
+ 'typescript/public/**/*',
107
+ 'typescript/pages/**/*',
108
+ '!typescript/**/*.ts',
109
+ ], gulp.parallel(copyFiles(taskOptions)));
110
+ }
111
+
112
+ export function watchFilesLib() {
113
+ return gulp.watch([
114
+ 'lucy-lib/backend/**/*',
115
+ 'lucy-lib/public/**/*',
116
+ 'lucy-lib/pages/**/*',
117
+ '!lucy-lib/**/*.ts',
118
+ ], gulp.parallel(copyFilesLib(taskOptions)));
119
+ }
120
+
121
+ export function watchTemplates() {
122
+ return gulp.watch([
123
+ 'typescript/backend/templates/**/*.tsx',
124
+ 'typescript/backend/templates/data/*.json',
125
+ '!typescript/backend/templates/render.ts',
126
+ ], gulp.parallel(
127
+ previewTemplates(),
128
+ test()
129
+ )
130
+ );
131
+ }
132
+
133
+ export function watchTemplatesLib() {
134
+ return gulp.watch([
135
+ 'lucy-lib/backend/templates/**/*.tsx',
136
+ 'lucy-lib/backend/templates/data/*.json',
137
+ '!lucy-lib/backend/templates/render.ts',
138
+ ], gulp.parallel(
139
+ previewTemplatesLib(),
140
+ testLib(),
141
+ )
142
+ );
143
+ }
144
+
145
+ export function watchTypes() {
146
+ return gulp.watch([
147
+ './.wix/types/**/*.d.ts',
148
+ '!./.wix/types/wix-code-types'
149
+ ],
150
+ gulp.series(
151
+ 'fix-wixtypes'
152
+ )
153
+ );
154
+ }
155
+
156
+ export function watchAll(options: TaskOptions) {
157
+ taskOptions = options;
158
+ console.log("🐕" + green.underline.bold(' => Adding watchers...'));
159
+
160
+ return gulp.parallel(
161
+ watchSCSS,
162
+ watchBackend,
163
+ watchBackendLib,
164
+ watchJSW,
165
+ watchJSWLib,
166
+ watchPublic,
167
+ watchPublicLib,
168
+ watchPages,
169
+ watchFilesLib,
170
+ watchFiles,
171
+ watchTemplates,
172
+ watchTemplatesLib,
173
+ watchTypes,
174
+ );
175
+ }