lucy-cli 0.0.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,7 +1,7 @@
1
- import chalk from 'chalk';
2
1
  import gulp from 'gulp';
3
2
  import { createGulpEsbuild } from 'gulp-esbuild';
4
3
  import * as path from 'path';
4
+ import { blue, red } from '../index.js';
5
5
  export function buildPublic(options) {
6
6
  const { outputDir, enableIncrementalBuild } = options;
7
7
  const gulpEsbuild = createGulpEsbuild({
@@ -14,14 +14,17 @@ export function buildPublic(options) {
14
14
  ])
15
15
  .pipe(gulpEsbuild({
16
16
  bundle: false,
17
+ loader: {
18
+ '.tsx': 'tsx',
19
+ },
17
20
  }))
18
21
  .pipe(gulp.dest(path.join(outputDir, 'public')))
19
22
  .on('error', function () {
20
- console.log(chalk.red.underline.bold('Build of Public TS files failed!'));
23
+ console.log("💩" + red.underline.bold(' => Build of Public TS files failed!'));
21
24
  this.emit('end');
22
25
  })
23
26
  .on('end', function () {
24
- console.log(chalk.blueBright.underline('Build of Public TS files succeeded!'));
27
+ console.log("🐶" + blue.underline(' => Build of Public TS files succeeded!'));
25
28
  });
26
29
  };
27
30
  }
@@ -32,19 +35,22 @@ export function buildPublicLib(options) {
32
35
  });
33
36
  return () => {
34
37
  return gulp.src([
35
- 'wix-lucy-lib/src/public/**/*.ts',
36
- 'wix-lucy-lib/src/public/**/*.tsx'
38
+ 'lucy-lib/public/**/*.ts',
39
+ 'lucy-lib/public/**/*.tsx'
37
40
  ])
38
41
  .pipe(gulpEsbuild({
39
42
  bundle: false,
43
+ loader: {
44
+ '.tsx': 'tsx',
45
+ },
40
46
  }))
41
47
  .pipe(gulp.dest(path.join(outputDir, 'public')))
42
48
  .on('error', function () {
43
- console.log(chalk.red.underline.bold('Build of Public (LIB) TS files failed!'));
49
+ console.log("💩" + red.underline.bold(' => Build of Public (LIB) TS files failed!'));
44
50
  this.emit('end');
45
51
  })
46
52
  .on('end', function () {
47
- console.log(chalk.blueBright.underline('Build of Public (LIB) TS files succeeded!'));
53
+ console.log("🐶" + blue.underline(' => Build of Public (LIB) TS files succeeded!'));
48
54
  });
49
55
  };
50
56
  }
@@ -1,17 +1,17 @@
1
1
  import gulp from 'gulp';
2
- import chalk from 'chalk';
2
+ import { blue, red } from '../index.js';
3
3
  export function compileScss(options) {
4
4
  const { sass, outputDir } = options;
5
5
  return () => {
6
6
  return gulp.src(['typescript/styles/global.scss'])
7
7
  .pipe(sass().on('error', sass.logError))
8
- .pipe(gulp.dest(`${outputDir}/public/css`))
8
+ .pipe(gulp.dest(`${outputDir}/styles`))
9
9
  .on('error', function () {
10
- console.log(chalk.red.underline.bold('Compiling of scss files failed!'));
10
+ console.log("💩" + red.underline.bold(' => Compiling of scss files failed!'));
11
11
  this.emit('end');
12
12
  })
13
13
  .on('end', function () {
14
- console.log(chalk.blueBright.underline('Compiling of scss files succeeded!'));
14
+ console.log("🐶" + blue.underline(' => Compiling of scss files succeeded!'));
15
15
  });
16
16
  };
17
17
  }
@@ -1 +1,2 @@
1
1
  export declare function previewTemplates(): () => any;
2
+ export declare function previewTemplatesLib(): () => any;
@@ -1,6 +1,6 @@
1
1
  import gulp from 'gulp';
2
- import chalk from 'chalk';
3
2
  import exec from 'gulp-exec';
3
+ import { blue, red } from '../index.js';
4
4
  export function previewTemplates() {
5
5
  const options = {
6
6
  continueOnError: true,
@@ -13,9 +13,27 @@ export function previewTemplates() {
13
13
  ])
14
14
  .pipe(exec((file) => `npx ts-node-esm -T ${file.path}`, options))
15
15
  .on('error', function () {
16
- console.log(chalk.red.underline.bold('Render of Template failed!'));
16
+ console.log("💩" + red.underline.bold(' => Render of Template failed!'));
17
17
  this.emit('end');
18
18
  })
19
- .on('end', function () { console.log(chalk.blueBright.underline('Render of Template succeeded!')); });
19
+ .on('end', function () { console.log("🐶" + blue.underline(' => Render of Template succeeded!')); });
20
+ };
21
+ }
22
+ export function previewTemplatesLib() {
23
+ const options = {
24
+ continueOnError: true,
25
+ };
26
+ return () => {
27
+ return gulp.src([
28
+ 'lucy-lib/backend/templates/**/*.tsx',
29
+ 'lucy-lib/backend/templates/data/*.json',
30
+ '!lucy-lib/backend/templates/render.ts',
31
+ ])
32
+ .pipe(exec((file) => `npx ts-node-esm -T ${file.path}`, options))
33
+ .on('error', function () {
34
+ console.log("💩" + red.underline.bold(' => Render of Template (LIB) failed!'));
35
+ this.emit('end');
36
+ })
37
+ .on('end', function () { console.log("🐶" + blue.underline(' => Render of Template (LIB) succeeded!')); });
20
38
  };
21
39
  }
@@ -0,0 +1,2 @@
1
+ export declare function test(): () => any;
2
+ export declare function testLib(): () => any;
@@ -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
+ export function test() {
6
+ return () => {
7
+ return gulp.src([
8
+ 'typescript/backend/**/*.spec.ts',
9
+ ])
10
+ .pipe(jest({
11
+ verbose: true,
12
+ extensionsToTreatAsEsm: ['.ts'],
13
+ transform: {
14
+ '^.+\\.tsx?$': [
15
+ 'ts-jest',
16
+ {
17
+ tsconfig: './typescript/tsconfig.json',
18
+ usESM: true,
19
+ },
20
+ ],
21
+ },
22
+ preset: 'ts-jest',
23
+ setupFilesAfterEnv: [],
24
+ testEnvironment: 'node',
25
+ collectCoverage: true,
26
+ coverageDirectory: '../coverage',
27
+ coverageReporters: ['clover', 'json', 'lcov', 'text'],
28
+ rootDir: './typescript',
29
+ testMatch: ['**/*.spec.ts'],
30
+ passWithNoTests: true,
31
+ moduleNameMapper: {
32
+ 'public/(.*)': '<rootDir>/public/$1'
33
+ }
34
+ }))
35
+ .on('error', function () {
36
+ console.log("💩" + red.underline.bold(' => Tests failed!'));
37
+ this.emit('end');
38
+ })
39
+ .on('end', function () {
40
+ console.log("🐶" + blue.underline(' => Test succeeded!'));
41
+ });
42
+ };
43
+ }
44
+ export function testLib() {
45
+ return () => {
46
+ return gulp.src([
47
+ 'lucy-lib/backend/**/*.spec.ts',
48
+ ])
49
+ .pipe(jest({
50
+ verbose: true,
51
+ extensionsToTreatAsEsm: ['.ts'],
52
+ transform: {
53
+ '^.+\\.tsx?$': [
54
+ 'ts-jest',
55
+ {
56
+ tsconfig: './lucy-lib/tsconfig.json',
57
+ usESM: true,
58
+ },
59
+ ],
60
+ },
61
+ preset: 'ts-jest',
62
+ setupFilesAfterEnv: [],
63
+ testEnvironment: 'node',
64
+ collectCoverage: true,
65
+ passWithNoTests: true,
66
+ coverageDirectory: './coverage',
67
+ coverageReporters: ['clover', 'json', 'lcov', 'text'],
68
+ rootDir: './lucy-lib',
69
+ testMatch: ['**/*.spec.ts'],
70
+ moduleNameMapper: {
71
+ 'public/(.*)': '<rootDir>/public/$1'
72
+ }
73
+ }))
74
+ .on('error', function () {
75
+ console.log("💩" + red.underline.bold(' => Test (LIB) failed!'));
76
+ this.emit('end');
77
+ })
78
+ .on('end', function () {
79
+ console.log("🐶" + blue.underline(' => Test (LIB) succeeded!'));
80
+ });
81
+ };
82
+ }
@@ -1,4 +1,3 @@
1
- import chalk from 'chalk';
2
1
  import gulp from 'gulp';
3
2
  import * as path from 'path';
4
3
  import replace from 'gulp-string-replace';
@@ -6,6 +5,7 @@ import foreach from 'gulp-foreach';
6
5
  import jeditor from 'gulp-json-editor';
7
6
  import merge from 'merge-stream';
8
7
  import * as insert from 'gulp-insert';
8
+ import { blue, red, yellow } from '../index.js';
9
9
  export function updateWixTypes(options) {
10
10
  const { publicSettings, backendSettings, masterSettings, pageSettings, replaceOpions } = options;
11
11
  let count = 0;
@@ -33,15 +33,14 @@ export function updateWixTypes(options) {
33
33
  return path.join(outputDir);
34
34
  }))
35
35
  .on('error', function () {
36
- console.log(chalk.red.underline.bold('Modification of WIX configs failed!'));
36
+ console.log("💩" + red.underline.bold('Modification of WIX configs failed!'));
37
37
  this.emit('end');
38
38
  })
39
- .on('end', function () { console.log(chalk.blueBright.underline(`Modification of ${count} WIX configs succeeded!`)); });
39
+ .on('end', function () { console.log("🐶" + blue.underline(`Modification of ${yellow(count)} WIX configs succeeded!`)); });
40
40
  };
41
41
  }
42
42
  export function addTypes(options, done) {
43
- const { replaceOpions, cwd } = options;
44
- console.log('CWD', cwd);
43
+ const { replaceOpions } = options;
45
44
  const processPages = gulp.src(['./.wix/types/wix-code-types/dist/types/page/$w.d.ts'])
46
45
  .pipe(replace('declare namespace \\$w {', ' declare namespace $w{\nconst api: $w.Api;\n', replaceOpions))
47
46
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/page/'));
@@ -56,17 +55,17 @@ export function addTypes(options, done) {
56
55
  .pipe(replace('type ', 'export type ', replaceOpions))
57
56
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/beta/common/'));
58
57
  const processCommon = gulp.src(['./.wix/types/wix-code-types/dist/types/common/$w.d.ts'])
59
- .pipe(insert.prepend("import { FrontendAPISchema } from '../../../../../../typescript/public/models/common/frontendApi.model';\nimport '@total-typescript/ts-reset';\n"))
58
+ .pipe(insert.prepend("import { FrontendAPISchema } from '../../../../../../lucy-lib/public/models/common/frontendApi.model';\nimport '@total-typescript/ts-reset';\n"))
60
59
  .pipe(replace('namespace \\$w {', 'declare namespace $w{\ntype Api = FrontendAPISchema;\n', replaceOpions))
61
60
  .pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
62
61
  return merge(processPages, processCommon, exportTypesBeta, exportTypes)
63
62
  .on('error', function () {
64
- console.log(chalk.red.underline.bold('Add of new Types (store & Global) failed!'));
63
+ console.log("💩" + red.underline.bold(' => Updating WIX failed!'));
65
64
  this.emit('end');
66
65
  done();
67
66
  })
68
67
  .on('end', function () {
69
- console.log(chalk.blueBright.underline('Add of new Types (store & Global) succeeded!'));
68
+ console.log("🐶" + blue.underline(' => Updating WIX succeeded!'));
70
69
  done();
71
70
  });
72
71
  }
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="undertaker" />
3
+ import { TaskOptions } from '../Gulpfile.js';
4
+ export declare function watchSCSS(): import("fs").FSWatcher;
5
+ export declare function watchBackend(): import("fs").FSWatcher;
6
+ export declare function watchBackendLib(): import("fs").FSWatcher;
7
+ export declare function watchJSW(): import("fs").FSWatcher;
8
+ export declare function watchJSWLib(): import("fs").FSWatcher;
9
+ export declare function watchPublic(): import("fs").FSWatcher;
10
+ export declare function watchPublicLib(): import("fs").FSWatcher;
11
+ export declare function watchPages(): import("fs").FSWatcher;
12
+ export declare function watchFiles(): import("fs").FSWatcher;
13
+ export declare function watchFilesLib(): import("fs").FSWatcher;
14
+ export declare function watchTemplates(): import("fs").FSWatcher;
15
+ export declare function watchTemplatesLib(): import("fs").FSWatcher;
16
+ export declare function watchTypes(): import("fs").FSWatcher;
17
+ export declare function watchAll(options: TaskOptions): import("undertaker").TaskFunction;
@@ -0,0 +1,94 @@
1
+ import gulp from 'gulp';
2
+ import { green } from '../index.js';
3
+ import { buildBackend, buildBackendJSW, buildBackendJSWLib, buildBackendLib } from './backend.js';
4
+ import { buildPublic, buildPublicLib } from './public.js';
5
+ import { buildPages } from './pages.js';
6
+ import { copyFiles, copyFilesLib } from './copy.js';
7
+ import { previewTemplates, previewTemplatesLib } from './templates.js';
8
+ import { checkTs, checkTsLib } from './checks.js';
9
+ import { testLib, test } from './test.js';
10
+ let taskOptions;
11
+ export function watchSCSS() {
12
+ return gulp.watch([
13
+ 'typescript/styles/**/*.scss',
14
+ 'lucy-lib/styles/**/*.scss'
15
+ ], gulp.parallel('scss'));
16
+ }
17
+ export function watchBackend() {
18
+ return gulp.watch([
19
+ 'typescript/backend/**/*.ts',
20
+ 'typescript/backend/**/*.tsx',
21
+ '!typescript/backend/**/*.spec.ts',
22
+ '!typescript/backend/**/*.jsw.ts',
23
+ ], gulp.parallel(test(), checkTs(), buildBackend(taskOptions)));
24
+ }
25
+ export function watchBackendLib() {
26
+ return gulp.watch([
27
+ 'lucy-lib/backend/**/*.ts',
28
+ 'lucy-lib/backend/**/*.tsx',
29
+ '!lucy-lib/backend/**/*.spec.ts',
30
+ '!lucy-lib/backend/**/*.jsw.ts',
31
+ ], gulp.parallel(testLib(), checkTsLib(), buildBackendLib(taskOptions)));
32
+ }
33
+ export function watchJSW() {
34
+ return gulp.watch(['typescript/backend/**/*.jsw.ts'], gulp.parallel(test(), checkTs(), buildBackendJSW(taskOptions)));
35
+ }
36
+ export function watchJSWLib() {
37
+ return gulp.watch(['lucy-lib/backend/**/*.jsw.ts'], gulp.parallel(testLib(), checkTsLib(), buildBackendJSWLib(taskOptions)));
38
+ }
39
+ export function watchPublic() {
40
+ return gulp.watch([
41
+ 'typescript/public/**/*.ts',
42
+ 'typescript/public/**/*.tsx',
43
+ ], gulp.parallel(test(), checkTs(), buildPublic(taskOptions)));
44
+ }
45
+ export function watchPublicLib() {
46
+ return gulp.watch([
47
+ 'lucy-lib/public/**/*.ts',
48
+ 'lucy-lib/public/**/*.tsx',
49
+ ], gulp.parallel(testLib(), checkTsLib(), buildPublicLib(taskOptions)));
50
+ }
51
+ export function watchPages() {
52
+ return gulp.watch('typescript/pages/**/*.ts', gulp.parallel(checkTs(), buildPages(taskOptions)));
53
+ }
54
+ export function watchFiles() {
55
+ return gulp.watch([
56
+ 'typescript/backend/**/*',
57
+ 'typescript/public/**/*',
58
+ 'typescript/pages/**/*',
59
+ '!typescript/**/*.ts',
60
+ ], gulp.parallel(copyFiles(taskOptions)));
61
+ }
62
+ export function watchFilesLib() {
63
+ return gulp.watch([
64
+ 'lucy-lib/backend/**/*',
65
+ 'lucy-lib/public/**/*',
66
+ 'lucy-lib/pages/**/*',
67
+ '!lucy-lib/**/*.ts',
68
+ ], gulp.parallel(copyFilesLib(taskOptions)));
69
+ }
70
+ export function watchTemplates() {
71
+ return gulp.watch([
72
+ 'typescript/backend/templates/**/*.tsx',
73
+ 'typescript/backend/templates/data/*.json',
74
+ '!typescript/backend/templates/render.ts',
75
+ ], gulp.parallel(previewTemplates(), test()));
76
+ }
77
+ export function watchTemplatesLib() {
78
+ return gulp.watch([
79
+ 'lucy-lib/backend/templates/**/*.tsx',
80
+ 'lucy-lib/backend/templates/data/*.json',
81
+ '!lucy-lib/backend/templates/render.ts',
82
+ ], gulp.parallel(previewTemplatesLib(), testLib()));
83
+ }
84
+ export function watchTypes() {
85
+ return gulp.watch([
86
+ './.wix/types/**/*.d.ts',
87
+ '!./.wix/types/wix-code-types'
88
+ ], gulp.series('fix-wixtypes'));
89
+ }
90
+ export function watchAll(options) {
91
+ taskOptions = options;
92
+ console.log("🐕" + green.underline.bold(' => Adding watchers...'));
93
+ return gulp.parallel(watchSCSS, watchBackend, watchBackendLib, watchJSW, watchJSWLib, watchPublic, watchPublicLib, watchPages, watchFilesLib, watchFiles, watchTemplates, watchTemplatesLib, watchTypes);
94
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,24 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import settings from './settings.json';
3
+ export type ModuleSettings = {
4
+ packageRoot: string;
5
+ targetFolder: string;
6
+ args: string[];
7
+ wixConfigPath: string;
8
+ lucyConfigPath: string;
9
+ packageJonPath: string;
10
+ settings: typeof settings;
11
+ };
12
+ export type ProjectSettings = {
13
+ packages?: Record<string, string>;
14
+ modules?: Record<string, string>;
15
+ lucySettings?: Record<string, string>;
16
+ packageJSON?: Record<string, any>;
17
+ lucyJSON?: Record<string, any>;
18
+ };
19
+ export declare const orange: import("chalk").ChalkInstance;
20
+ export declare const blue: import("chalk").ChalkInstance;
21
+ export declare const green: import("chalk").ChalkInstance;
22
+ export declare const red: import("chalk").ChalkInstance;
23
+ export declare const yellow: import("chalk").ChalkInstance;
24
+ export declare const magenta: import("chalk").ChalkInstance;
package/dist/index.js CHANGED
@@ -3,86 +3,86 @@ import { dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { existsSync } from 'fs';
5
5
  import chalk from 'chalk';
6
+ import settings from './settings.json' assert { type: 'json' };
6
7
  import { join } from 'path';
7
8
  import fs from 'fs/promises';
8
9
  import { init } from './init.js';
9
10
  import { dev } from './dev.js';
11
+ import { sync } from './sync.js';
12
+ export const orange = chalk.hex('#FFA500');
13
+ export const blue = chalk.blueBright;
14
+ export const green = chalk.greenBright;
15
+ export const red = chalk.redBright;
16
+ export const yellow = chalk.yellow;
17
+ export const magenta = chalk.magentaBright;
10
18
  // eslint-disable-next-line @typescript-eslint/naming-convention
11
19
  const __filename = fileURLToPath(import.meta.url);
12
20
  // eslint-disable-next-line @typescript-eslint/naming-convention
13
21
  const __dirname = dirname(__filename);
14
22
  /**
15
- *
23
+ * Main function
24
+ * @returns {Promise<void>}
16
25
  */
17
26
  async function main() {
18
27
  const moduleSettings = {
19
28
  packageRoot: dirname(__dirname),
20
29
  targetFolder: process.cwd(),
21
30
  args: process.argv.slice(2),
31
+ settings,
22
32
  wixConfigPath: join(process.cwd(), 'wix.config.json'),
23
- lucyConfigPath: join(process.cwd(), 'lucy.json')
33
+ lucyConfigPath: join(process.cwd(), 'lucy.json'),
34
+ packageJonPath: join(process.cwd(), 'package.json'),
24
35
  };
25
- let projectSettings;
36
+ let projectSettings = {};
37
+ if (moduleSettings.args.includes('version') || moduleSettings.args.includes('-v')) {
38
+ console.log("🐾" + blue.bold(' => 1.0.0'));
39
+ return;
40
+ }
41
+ if (moduleSettings.args.includes('help') || moduleSettings.args.includes('-h')) {
42
+ console.log("🦮" + green.underline.bold(' => Lucy CLI Help'));
43
+ return;
44
+ }
26
45
  if (!existsSync(moduleSettings.wixConfigPath)) {
27
- console.log(chalk.red.underline.bold(`This is not a WIX project ${moduleSettings.targetFolder}`));
46
+ console.log((`💩 ${red.underline.bold("=> This is not a WIX project =>")} ${orange(moduleSettings.targetFolder)}`));
28
47
  return;
29
48
  }
30
- const packageJSONraw = await fs.readFile(join(moduleSettings.targetFolder, 'package.json'), 'utf8');
31
- const packageJSON = JSON.parse(packageJSONraw);
49
+ if (existsSync(moduleSettings.packageJonPath)) {
50
+ const packageJSONraw = await fs.readFile(join(moduleSettings.packageJonPath), 'utf8');
51
+ try {
52
+ projectSettings.packageJSON = JSON.parse(packageJSONraw);
53
+ }
54
+ catch (parseError) {
55
+ console.log((`💩 ${red.underline.bold("=> Error parsing package.json =>")} ${orange(parseError)}`));
56
+ return;
57
+ }
58
+ }
32
59
  if (existsSync(moduleSettings.lucyConfigPath)) {
33
60
  try {
34
61
  const data = await fs.readFile(moduleSettings.lucyConfigPath, 'utf8');
35
- projectSettings = JSON.parse(data);
62
+ projectSettings.lucySettings = JSON.parse(data);
36
63
  }
37
64
  catch (parseError) {
38
- console.error(chalk.red.underline.bold('Error parsing Lucy.json', parseError));
65
+ console.log((`💩 ${red.underline.bold("=> Error parsing Lucy.json =>")} ${orange(parseError)}`));
39
66
  }
40
67
  }
41
68
  else {
42
- console.log(chalk.blueBright.underline.bold('Project not Intialized!'));
43
- return;
44
- }
45
- if (packageJSON?.wixLucy?.intialized && !args.includes('-f')) {
46
- console.error(chalk.red.underline.bold(`This project is already initialized ${moduleSettings.targetFolder}`));
47
- return;
48
- }
49
- console.log({ args, cwd });
50
- if (args.includes('help') || args.includes('-h')) {
51
- console.log('Help is on the way!');
52
- return;
53
- }
54
- if (args.includes('version') || args.includes('-v')) {
55
- console.log('1.0.0');
56
- return;
69
+ if (!moduleSettings.args.includes('init')) {
70
+ return console.log(yellow.underline.bold('🐶 => Project not Intialized! Please initialize using "lucy-cli init"'));
71
+ }
72
+ ;
57
73
  }
58
- if (args.includes('init')) {
59
- init(cwd, packageRoot, args);
74
+ if (moduleSettings.args.includes('init')) {
75
+ console.log("🐕" + magenta.underline(' => Initializing project'));
76
+ init(moduleSettings, projectSettings);
60
77
  return;
61
78
  }
62
- if (args.includes('dev')) {
63
- dev(cwd, args);
79
+ if (moduleSettings.args.includes('dev')) {
80
+ dev(moduleSettings, projectSettings);
64
81
  return;
65
82
  }
66
- if (args.includes('sync')) {
67
- console.log('Hello serve');
83
+ if (moduleSettings.args.includes('sync')) {
84
+ sync(moduleSettings, projectSettings);
68
85
  return;
69
86
  }
70
87
  }
71
88
  main();
72
- // const fs = require("fs"),
73
- // path = require("path")
74
- // /** Parse the command line */
75
- // var args = process.argv.slice(2);
76
- // // Validate input
77
- // if (args.length !== 2) {
78
- // console.log("Warning: Requires 2 arguments");
79
- // console.log("node index.js [path/source.html] [targetfile]");
80
- // process.exit();
81
- // }
82
- // const src = args[0];
83
- // const target = args[1];
84
- // const dirsrc = path.dirname(src);
85
- // if (!fs.existsSync(src)) {
86
- // console.log("Error: Source file doesn't exist. Given: ", src);
87
- // process.exit();
88
- // }
package/dist/init.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { ModuleSettings, ProjectSettings } from './index.js';
1
2
  /**
2
3
  * Init Lucy project
3
4
  * @param {string} cwd Current working directory
4
5
  * @param {string} packageRoot Package root directory
5
6
  * @returns {void}
6
7
  */
7
- export declare function init(cwd: string, packageRoot: string, args: string[]): Promise<void>;
8
+ export declare function init(moduleSettings: ModuleSettings, projectSettings: ProjectSettings): Promise<void>;