lucy-cli 2.0.0-beta.13 → 2.0.0-beta.14

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 (172) hide show
  1. package/package.json +7 -2
  2. package/.cursorignore +0 -4
  3. package/.eslintrc.cjs +0 -96
  4. package/.github/funding.yml +0 -2
  5. package/.nvmrc +0 -1
  6. package/.stylelintrc.js +0 -8
  7. package/.wix/debug.log +0 -10
  8. package/.yarnrc.yml +0 -2
  9. package/files/sync-data/data/test.csv +0 -17
  10. package/files/sync-data/files/lucy.jpg +0 -0
  11. package/files/sync-data/schema/test.json +0 -11
  12. package/lucy.jpg +0 -0
  13. package/mitarbeiter-login.html +0 -188
  14. package/old/Gulpfile.d.ts +0 -34
  15. package/old/Gulpfile.js +0 -116
  16. package/old/Gulpfile.js.map +0 -1
  17. package/old/Gulpfile.ts +0 -231
  18. package/old/gulp/backend.d.ts +0 -3
  19. package/old/gulp/backend.js +0 -92
  20. package/old/gulp/backend.js.map +0 -1
  21. package/old/gulp/backend.ts +0 -109
  22. package/old/gulp/checks.d.ts +0 -3
  23. package/old/gulp/checks.js +0 -205
  24. package/old/gulp/checks.js.map +0 -1
  25. package/old/gulp/checks.ts +0 -228
  26. package/old/gulp/clean.d.ts +0 -3
  27. package/old/gulp/clean.js +0 -29
  28. package/old/gulp/clean.js.map +0 -1
  29. package/old/gulp/clean.ts +0 -33
  30. package/old/gulp/copy.d.ts +0 -2
  31. package/old/gulp/copy.js +0 -34
  32. package/old/gulp/copy.js.map +0 -1
  33. package/old/gulp/copy.ts +0 -42
  34. package/old/gulp/helpers.d.ts +0 -2
  35. package/old/gulp/helpers.js +0 -25
  36. package/old/gulp/helpers.js.map +0 -1
  37. package/old/gulp/helpers.ts +0 -26
  38. package/old/gulp/pages.d.ts +0 -2
  39. package/old/gulp/pages.js +0 -37
  40. package/old/gulp/pages.js.map +0 -1
  41. package/old/gulp/pages.ts +0 -40
  42. package/old/gulp/pipeline.d.ts +0 -1
  43. package/old/gulp/pipeline.js +0 -29
  44. package/old/gulp/pipeline.js.map +0 -1
  45. package/old/gulp/pipeline.ts +0 -31
  46. package/old/gulp/public.d.ts +0 -2
  47. package/old/gulp/public.js +0 -50
  48. package/old/gulp/public.js.map +0 -1
  49. package/old/gulp/public.ts +0 -59
  50. package/old/gulp/styles.d.ts +0 -2
  51. package/old/gulp/styles.js +0 -40
  52. package/old/gulp/styles.js.map +0 -1
  53. package/old/gulp/styles.ts +0 -46
  54. package/old/gulp/templates.d.ts +0 -2
  55. package/old/gulp/templates.js +0 -33
  56. package/old/gulp/templates.js.map +0 -1
  57. package/old/gulp/templates.ts +0 -39
  58. package/old/gulp/types.d.ts +0 -4
  59. package/old/gulp/types.js +0 -289
  60. package/old/gulp/types.js.map +0 -1
  61. package/old/gulp/types.ts +0 -311
  62. package/old/gulp/watchers.d.ts +0 -9
  63. package/old/gulp/watchers.js +0 -59
  64. package/old/gulp/watchers.js.map +0 -1
  65. package/old/gulp/watchers.ts +0 -105
  66. package/old/helpers.d.ts +0 -32
  67. package/old/helpers.js +0 -267
  68. package/old/helpers.js.map +0 -1
  69. package/old/helpers.ts +0 -307
  70. package/old/index.d.ts +0 -59
  71. package/old/index.js +0 -288
  72. package/old/index.js.map +0 -1
  73. package/old/index.ts +0 -379
  74. package/old/init.d.ts +0 -8
  75. package/old/init.js +0 -165
  76. package/old/init.js.map +0 -1
  77. package/old/init.ts +0 -183
  78. package/old/models.d.ts +0 -37
  79. package/old/models.js +0 -2
  80. package/old/models.js.map +0 -1
  81. package/old/models.ts +0 -35
  82. package/old/prepare.d.ts +0 -8
  83. package/old/prepare.js +0 -20
  84. package/old/prepare.js.map +0 -1
  85. package/old/prepare.ts +0 -24
  86. package/old/schemas/index.d.ts +0 -0
  87. package/old/schemas/index.js +0 -2
  88. package/old/schemas/index.js.map +0 -1
  89. package/old/schemas/index.ts +0 -0
  90. package/old/schemas/types.d.ts +0 -0
  91. package/old/schemas/types.js +0 -2
  92. package/old/schemas/types.js.map +0 -1
  93. package/old/schemas/types.ts +0 -0
  94. package/old/settings.json +0 -67
  95. package/old/sync.d.ts +0 -2
  96. package/old/sync.js +0 -88
  97. package/old/sync.js.map +0 -1
  98. package/old/sync.ts +0 -97
  99. package/old/types.d.ts +0 -8
  100. package/pnpm-workspace.yaml +0 -6
  101. package/settings/backend-settings.json +0 -19
  102. package/settings/master-settings.json +0 -20
  103. package/settings/page-settings.json +0 -21
  104. package/settings/public-settings.json +0 -22
  105. package/src/args.ts +0 -121
  106. package/src/commands/checks.ts +0 -51
  107. package/src/commands/cleanup.ts +0 -11
  108. package/src/commands/copy.ts +0 -29
  109. package/src/commands/edit.ts +0 -81
  110. package/src/commands/exec.ts +0 -73
  111. package/src/commands/git.ts +0 -152
  112. package/src/commands/home.ts +0 -20
  113. package/src/commands/install.ts +0 -269
  114. package/src/commands/read.ts +0 -45
  115. package/src/commands/write.ts +0 -45
  116. package/src/commands.ts +0 -21
  117. package/src/config.ts +0 -142
  118. package/src/error.ts +0 -3
  119. package/src/helpers.ts +0 -93
  120. package/src/index.ts +0 -113
  121. package/src/init/blocks.ts +0 -85
  122. package/src/init/cargo.ts +0 -25
  123. package/src/init/expo.ts +0 -69
  124. package/src/init/gitModules.ts +0 -15
  125. package/src/init/index.ts +0 -86
  126. package/src/init/monorepo.ts +0 -72
  127. package/src/init/prepareVelo.ts +0 -19
  128. package/src/init/tauri.ts +0 -42
  129. package/src/init/templates.ts +0 -98
  130. package/src/init/velo.ts +0 -66
  131. package/src/policy.ts +0 -6
  132. package/src/prepare.ts +0 -24
  133. package/src/runtime.ts +0 -21
  134. package/src/schemas/gulp.ts +0 -31
  135. package/src/schemas/index.ts +0 -17
  136. package/src/schemas/lucy.ts +0 -43
  137. package/src/schemas/tsconfig.ts +0 -35
  138. package/src/schemas/types.ts +0 -40
  139. package/src/settings.json +0 -67
  140. package/src/states.ts +0 -15
  141. package/src/tasks/Gulpfile.ts +0 -207
  142. package/src/tasks/gulp/backend.ts +0 -113
  143. package/src/tasks/gulp/checks.ts +0 -219
  144. package/src/tasks/gulp/clean.ts +0 -38
  145. package/src/tasks/gulp/copy.ts +0 -38
  146. package/src/tasks/gulp/helpers.ts +0 -18
  147. package/src/tasks/gulp/pages.ts +0 -43
  148. package/src/tasks/gulp/pipeline.ts +0 -31
  149. package/src/tasks/gulp/public.ts +0 -61
  150. package/src/tasks/gulp/styles.ts +0 -47
  151. package/src/tasks/gulp/templates.ts +0 -53
  152. package/src/tasks/gulp/types.ts +0 -310
  153. package/src/tasks/gulp/watchers.ts +0 -97
  154. package/src/tasks/index.ts +0 -24
  155. package/src/tasks/syncSettings.ts +0 -21
  156. package/src/types.d.ts +0 -8
  157. package/src/utils/index.ts +0 -0
  158. package/src/utils/logger.ts +0 -40
  159. package/src/wix-sdk/check.ts +0 -24
  160. package/src/wix-sdk/client.ts +0 -18
  161. package/src/wix-sdk/index.ts +0 -17
  162. package/src/wix-sdk/init.ts +0 -54
  163. package/src/wix-sdk/run.ts +0 -56
  164. package/src/wix-sync/client.ts +0 -6
  165. package/src/wix-sync/export.ts +0 -19
  166. package/src/wix-sync/import.ts +0 -27
  167. package/src/wix-sync/index.ts +0 -36
  168. package/src/wix-sync/init.ts +0 -77
  169. package/src/wix-sync/is-alive.ts +0 -25
  170. package/src/wix-sync/migrate.ts +0 -23
  171. package/src/wix-sync/sync.ts +0 -27
  172. package/tsconfig.json +0 -34
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "composite": false,
5
- "noEmit": true,
6
- "strictNullChecks": true,
7
- "jsx": "react-jsx",
8
- "noUncheckedIndexedAccess": true,
9
- "paths": {
10
- "backend/*.web.js": [],
11
- "backend/*.web": [],
12
- "backend/*.jsw": [],
13
- "backend/*": [],
14
- "public/*": [],
15
- "wix-types/*": ["../wix-code-types/dist/types/*"],
16
- "types/*": []
17
- }
18
- },
19
- "include": []
20
- }
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "strictNullChecks": true,
5
- "composite": false,
6
- "noEmit": true,
7
- "experimentalDecorators": true,
8
- "jsx": "react-jsx",
9
- "noUncheckedIndexedAccess": true,
10
- "paths": {
11
- "backend/*.web.js": [],
12
- "backend/*.web": [],
13
- "backend/*.jsw": [],
14
- "backend/*": [],
15
- "public/*": [],
16
- "wix-types/*": ["../wix-code-types/dist/types/*"],
17
- "types/*": []
18
- }
19
- },
20
- "include": []
21
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "experimentalDecorators": true,
4
- "noUncheckedIndexedAccess": true,
5
- "strict": true,
6
- "composite": false,
7
- "noEmit": true,
8
- "jsx": "react-jsx",
9
- "strictNullChecks": true,
10
- "paths": {
11
- "backend/*.web.js": [],
12
- "backend/*.web": [],
13
- "backend/*.jsw": [],
14
- "backend/*": [],
15
- "mocks": [],
16
- "public/*": [],
17
- "types/*": [],
18
- "wix-types/*": ["../wix-code-types/dist/types/*"]
19
- }
20
- },
21
- "include": []
22
- }
package/src/args.ts DELETED
@@ -1,121 +0,0 @@
1
- import yargs from "yargs";
2
- import { hideBin } from "yargs/helpers";
3
- import { initTypes, LucyArgs, taskNames, syncActions } from "./schemas/types.js";
4
- import { createRequire } from "node:module";
5
-
6
- const require = createRequire(import.meta.url);
7
- const pkg = require("../package.json");
8
-
9
- export async function get_args(): Promise<LucyArgs> {
10
- const argv = await yargs(hideBin(process.argv))
11
- .usage('Usage: $0 <command> [options]')
12
- .command('init <initType>', 'Initialize a new Lucy project', (yargs) => {
13
- return yargs.positional('initType', {
14
- describe: 'The type of project to initialize',
15
- choices: initTypes,
16
- demandOption: true,
17
- })
18
- }).option('force', {
19
- alias: 'f',
20
- type: 'boolean',
21
- description: 'Run with force'
22
- })
23
- .command('open', 'Open the Lucy home directory')
24
- .command('task <tasksName>', 'Run a task', (yargs) => {
25
- return yargs.positional('tasksName', {
26
- describe: 'The task to run',
27
- choices: taskNames,
28
- demandOption: true,
29
- })
30
- })
31
- .command('wix-sync <syncAction>', 'Run a velo-sync action', (yargs) => {
32
- return yargs.positional("syncAction", {
33
- describe: "The velo-sync action to run",
34
- choices: syncActions,
35
- demandOption: true,
36
- })
37
- .option('input', {
38
- alias: 'i',
39
- type: 'string',
40
- describe: 'The CSV file to import',
41
- demandOption: false,
42
- })
43
- .option('c', {
44
- alias: 'collection',
45
- type: 'string',
46
- describe: 'The name of the collection to import data into',
47
- demandOption: false,
48
- })
49
- .option('s', {
50
- alias: 'schema',
51
- type: 'string',
52
- describe: 'The schema file',
53
- demandOption: false,
54
- })
55
- .option('d', {
56
- type: 'boolean',
57
- describe: 'Run in dry-run mode',
58
- demandOption: false,
59
- });
60
- })
61
- .command('wix-sdk <wixSDKAction>', 'Run a velo-sync action', (yargs) => {
62
- return yargs.positional("wixSDKAction", {
63
- describe: "The velo-sync action to run",
64
- choices: syncActions,
65
- demandOption: true,
66
- });
67
- })
68
- .demandCommand(1, 'You need to provide a command. Use --help for a list of commands.')
69
- .version('v', 'Show version number', pkg.version)
70
- .alias('v', 'version')
71
- .help()
72
- .alias('h', 'help')
73
- .strict()
74
- .wrap(yargs().terminalWidth())
75
- .epilogue(`
76
- 🦮 Lucy CLI - Complete Command Overview
77
-
78
- 📋 Available Commands:
79
- init <type> Initialize a new Lucy project (types: ${initTypes.join(', ')})
80
- open Open the Lucy home directory
81
- task <name> Run a task (tasks: ${taskNames.join(', ')})
82
- wix-sync <action> Run velo-sync actions (actions: ${syncActions.join(', ')})
83
- wix-sdk <action> Run Wix SDK actions
84
-
85
- 🔧 Available Tasks:
86
- dev Start development environment
87
- build Build the project
88
- build-prod Build for production
89
- build-pipeline Build pipeline
90
- sync-settings Sync settings
91
-
92
- 🔄 Wix Sync Actions:
93
- sync Synchronize collections
94
- import Import data from CSV
95
- init Initialize sync configuration
96
- is-alive Check if sync is alive
97
- migrate Migrate data
98
- export Export data
99
-
100
- ⚙️ Global Options:
101
- -h, --help Show this help message
102
- -v, --version Show version number
103
- -f, --force Force execution (use with caution)
104
-
105
- 📁 Project Types:
106
- velo Wix Velo project
107
- expo React Native with Expo
108
- blocks Wix Blocks
109
- monorepo Monorepo setup
110
- tauri Tauri desktop app
111
- cargo Rust project
112
- wix-sdk Wix SDK setup
113
-
114
- For more information, visit https://github.com/Sunnyside-UP-GmbH/lucy-cli
115
- `)
116
- .parseAsync();
117
-
118
- // The cast is now safer with the defined interface.
119
-
120
- return argv as LucyArgs;
121
- }
@@ -1,51 +0,0 @@
1
- import { Effect, Schema } from "effect/index";
2
- import { FileSystem, Path } from "@effect/platform"
3
- import { Config, lucyJsonName } from "../config.js";
4
- import { logger } from "../utils/logger.js";
5
- import { AppError } from "../error.js";
6
- import { JsonSchema } from "../schemas/index.js";
7
-
8
- export const isDirectoryClean =(excludes: string[] = []) => {
9
- return Effect.gen(function*() {
10
- const fs = yield* FileSystem.FileSystem;
11
- const config = yield* Config;
12
-
13
- const files = yield* fs.readDirectory(config.config.cwd);
14
- const allExcludes = [...excludes, '.git', lucyJsonName];
15
- const filteredFiles = files.filter(file => !allExcludes.includes(file));
16
-
17
- return filteredFiles.length > 0 ? false : true;
18
- });
19
- }
20
-
21
- export const checkForDirty = (excludes: string[] = []) => {
22
- return Effect.gen(function*() {
23
- const config = yield* Config;
24
- const clean = yield* isDirectoryClean(excludes);
25
- if(!clean && !config.config.force) {
26
- logger.alert("The current directory is not empty. Please run this command in an empty directory.")
27
- yield* Effect.fail(new AppError({ message: "Directory is not clean", cause: new Error("Directory is not clean") }));
28
- return;
29
- }
30
- if(config.config.lucySettings.initialized && !config.config.force) {
31
- logger.alert("Lucy is already initialized in this directory. Use --force to reinitialize.")
32
- yield* Effect.fail(new AppError({ message: "Lucy is already initialized in this directory", cause: new Error("Lucy is already initialized in this directory") }));
33
- return;
34
- }
35
-
36
- if ((!clean && config.config.force) || (config.config.lucySettings.initialized && config.config.force)) logger.alert("Forced initialization!")
37
- });
38
- }
39
- export const checkForVelo = () => {
40
- return Effect.gen(function*() {
41
- const config = yield* Config;
42
- const fs = yield* FileSystem.FileSystem;
43
- const path = yield* Path.Path;
44
-
45
- const wixConfigPath = path.join(config.config.cwd, 'wix.config.json');
46
- const wixConfigRaw = yield* fs.readFileString(wixConfigPath);
47
- const wixConfigJSON =( yield* Schema.decodeUnknown(JsonSchema)(wixConfigRaw)) as any;
48
-
49
- if(!(wixConfigJSON.siteId)) return yield* Effect.fail(new AppError({ message: "This directory is not a Velo project. Please run this command in a Velo project directory.", cause: new Error("Not a Velo project") }));
50
- });
51
- }
@@ -1,11 +0,0 @@
1
- import { Effect } from "effect/index";
2
- import { Config } from "../config.js";
3
- import { FileSystem, Path } from "@effect/platform"
4
-
5
- export const cleanup = Effect.gen(function* () {
6
- const config = yield* Config;
7
- const fs = yield* FileSystem.FileSystem;
8
- const path = yield* Path.Path;
9
-
10
- yield* fs.remove(path.join(config.config.cwd, "package-lock.json"), { force: true })
11
- });
@@ -1,29 +0,0 @@
1
- import { Effect } from "effect/index";
2
- import { Path } from "@effect/platform"
3
- import { FileSystem } from "@effect/platform"
4
- import { Config, syncDataName, syncFilesSource } from "../config.js";
5
-
6
- export const copyTemplateFiles = Effect.gen(function*() {
7
- const fs = yield* FileSystem.FileSystem;
8
- const config = yield* Config;
9
- const path = yield * Path.Path;
10
-
11
- const templateFiles = yield* fs.readDirectory(config.config.templateFiles)
12
- yield* Effect.forEach(
13
- templateFiles,
14
- (file) => fs.copy(path.join(config.config.templateFiles, file), path.join(config.config.cwd, file), { overwrite: true })
15
- )
16
- })
17
-
18
- export const copySyncFiles = Effect.gen(function*() {
19
- const fs = yield* FileSystem.FileSystem;
20
- const config = yield* Config;
21
- const path = yield * Path.Path;
22
-
23
- const synDataFiles = yield* fs.readDirectory(syncFilesSource)
24
- yield* fs.makeDirectory(path.join(config.config.cwd, syncDataName));
25
- yield* Effect.forEach(
26
- synDataFiles,
27
- (file) => fs.copy(path.join(syncFilesSource, file), path.join(config.config.cwd, syncDataName, file), { overwrite: true })
28
- )
29
- })
@@ -1,81 +0,0 @@
1
- import { Effect, Schema } from "effect/index";
2
- import { Config, lucyJsonPath } from "../config.js";
3
- import { FileSystem, Path } from "@effect/platform"
4
- import { logger } from "../utils/logger.js";
5
- import { JsonSchema } from "../schemas/index.js";
6
- import { LucySettings } from "../schemas/lucy.js";
7
-
8
- export const editJson = (json: any, keys: string[], values: string[] | Object[]) => {
9
- return Effect.gen(function*() {
10
- const config = yield* Config;
11
-
12
- for (const key of keys){
13
- const index = keys.indexOf(key);
14
- const value = values[index];
15
- json[key] = value;
16
- }
17
- })
18
- }
19
-
20
- export const mergeLucySettings2PackageJson = Effect.gen(function*() {
21
- const config = yield* Config;
22
- const lucySettings = config.config.lucySettings;
23
- const packageJson = config.config.packageJson;
24
-
25
- if (Object.keys(lucySettings.scripts).length > 0) {
26
- yield* editJson(packageJson, ['scripts'], [{...packageJson.scripts, ...lucySettings.scripts}]);
27
- }
28
- })
29
-
30
- export const setModule = Effect.gen(function*() {
31
- const config = yield* Config;
32
- const lucySettings = config.config.lucySettings;
33
- const packageJson = config.config.packageJson;
34
-
35
- yield* editJson(packageJson, ['type'], ['module']);
36
- })
37
-
38
- export const mergeAdditions = Effect.gen(function*() {
39
- const config = yield* Config;
40
- const lucySettings = config.config.lucySettings;
41
- const packageJson = config.config.packageJson;
42
-
43
- config.config.packageJson = {
44
- ...packageJson,
45
- ...lucySettings.additionalPkgProps,
46
- }
47
- })
48
-
49
- export const setProjectName = Effect.gen(function*() {
50
- const config = yield* Config;
51
- const packageJson = config.config.packageJson;
52
-
53
- yield * editJson(packageJson, ["name"], [config.config.projectName]);
54
- })
55
-
56
- export const setInitialized = Effect.gen(function*() {
57
- const fs = yield* FileSystem.FileSystem;
58
- const lucyRaw = yield* fs.readFileString(lucyJsonPath);
59
- const lucyJSON = (yield* Schema.decodeUnknown(JsonSchema)(lucyRaw)) as any;
60
- lucyJSON.initialized = true;
61
-
62
- yield* fs.writeFileString(lucyJsonPath, JSON.stringify(lucyJSON, null, 2));
63
- })
64
-
65
- export const stringReplace = (filePath: string, keys: string[], values: string[]) => {
66
- return Effect.gen(function*() {
67
- const fs = yield* FileSystem.FileSystem;
68
- let modifiedContent: string = '';
69
-
70
- logger.action(`Replacing ${keys} with ${values} in ${filePath}`);
71
- const data = yield* fs.readFileString(filePath, 'utf8');
72
- for (const key of keys){
73
- const index = keys.indexOf(key);
74
- const value = values[index];
75
- const regex = new RegExp(`${key}`, 'g');
76
- modifiedContent = data.replace(regex, `${value}`);
77
- }
78
- yield* fs.writeFileString(filePath, modifiedContent);
79
- logger.info(`Updated file ${filePath}`);
80
- })
81
- }
@@ -1,73 +0,0 @@
1
- import { Effect, Schema } from "effect/index";
2
- import { Config } from "../config.js";
3
- import { Command } from "@effect/platform/index";
4
- import { logger } from "../utils/logger.js";
5
- import { FileSystem } from "@effect/platform"
6
- import Enquirer from "enquirer";
7
- import { AppError } from "../error.js";
8
- import { editors } from "../schemas/index.js";
9
-
10
- export const execCommand = Effect.gen(function*() {
11
- const config = yield* Config;
12
- const cmds = config.config.lucySettings.additionalCommands ?? [];
13
- logger.info("Executing additional commands...", cmds);
14
- if (cmds.length > 0) {
15
- logger.info("Executing additional commands");
16
- yield *
17
- Effect.all([
18
- ...cmds.map((cmd) => {
19
- return Command.make(cmd[0], ...cmd.slice(1))
20
- .pipe()
21
- .pipe(Command.stdout("inherit"), Command.stderr("inherit"), Command.exitCode);
22
- }),
23
- ]);
24
- }
25
- })
26
-
27
- export const open = Effect.scoped(Effect.gen(function*() {
28
- const config = yield* Config;
29
- const fs = yield* FileSystem.FileSystem
30
- console.log("Opening Lucy home directory:", config.config.lucyHome);
31
- let command: ReturnType<typeof Command.make>;
32
- switch (process.platform) {
33
- case 'darwin': command = Command.make('open', config.config.lucyHome); break;
34
- case 'win32': command = Command.make('start', config.config.lucyHome); break;
35
- default: command = Command.make('xdg-open', config.config.lucyHome); break;
36
- }
37
-
38
- command.pipe().pipe(Command.stdout("inherit"), Command.stderr("inherit"), Command.exitCode);
39
- yield* command.pipe().pipe(Command.stdout("inherit"), Command.stderr("inherit"), Command.exitCode);
40
- }))
41
-
42
- export const openEditor = Effect.gen(function*() {
43
- const config = yield* Config;
44
-
45
- const editorQuestion = new Enquirer();
46
- const openEditorQuestion = yield* Effect.tryPromise({
47
- try: () => editorQuestion.prompt({
48
- type: 'select',
49
- name: 'openEditor',
50
- message: `Do you want to open the project in a supported editor?`,
51
- choices: [...editors, 'No'],
52
- }),
53
- catch: (e) => {
54
- return new AppError({
55
- cause: e,
56
- message: "Error opening VSCode",
57
- });
58
- }
59
- })
60
- const choice = yield* Schema.decodeUnknown(Schema.Struct({ openEditor: Schema.Literal(...editors, 'No') }))(openEditorQuestion);
61
-
62
- const open = Command.make(
63
- choice.openEditor,
64
- config.config.cwd,
65
- ).pipe(
66
- Command.stdout("inherit"), // Stream stdout to process.stdout
67
- Command.stderr("inherit"), // Stream stderr to process.stderr
68
- Command.exitCode // Get the exit code
69
- )
70
- if (choice.openEditor !== 'No') {
71
- yield* open
72
- }
73
- })
@@ -1,152 +0,0 @@
1
- import { Effect } from 'effect/index';
2
- import { simpleGit, SimpleGit } from 'simple-git';
3
- import { Config } from '../config.js';
4
- import { AppError } from '../error.js';
5
- import { logger } from '../utils/logger.js';
6
- import { FileSystem, Path } from "@effect/platform"
7
-
8
- export const isSubmoduleRegistered = (git: SimpleGit, submoduleName: string) => Effect.gen(function* () {
9
- const value = yield* Effect.tryPromise({
10
- try: () => git.getConfig(`submodule.${submoduleName}.url`),
11
- catch: (error) => {
12
- return new AppError({
13
- cause: error,
14
- message: "Failed to get submodule url",
15
- });
16
- }
17
- })
18
- return !!value.value;
19
- })
20
-
21
- export const gitInit = (update: boolean = false) => Effect.gen(function* () {
22
- const config = yield* Config;
23
- const git = simpleGit({ baseDir: config.config.cwd });
24
- const path = yield * Path.Path;
25
-
26
- const isGit = yield* Effect.tryPromise({
27
- try: () => git.checkIsRepo(),
28
- catch: (error) => {
29
- return new AppError({
30
- cause: error,
31
- message: "Failed to check if the directory is a git repository",
32
- });
33
- }
34
- })
35
-
36
- if(!isGit) {
37
- yield* Effect.tryPromise({
38
- try: () => git.init(),
39
- catch: (error) => {
40
- return new AppError({
41
- cause: error,
42
- message: "Failed to initialize git repository",
43
- });
44
- }
45
- })
46
- }
47
-
48
- if (!config.config.lucySettings.modules) {
49
- logger.alert('No submodules defined in settings, skipping.');
50
- return;
51
- }
52
- yield* initSubmodules(update);
53
- })
54
-
55
- export const initSubmodules = (update: boolean = false) => Effect.gen(function* () {
56
- const config = yield* Config;
57
- const git = simpleGit({ baseDir: config.config.cwd });
58
- const path = yield* Path.Path;
59
- const fs = yield* FileSystem.FileSystem;
60
- const gitmodulesPath = path.join(config.config.cwd, ".gitmodules");
61
-
62
- for (const [name, repo] of Object.entries(config.config.lucySettings.modules)) {
63
- logger.action(`Processing submodule ${name}`);
64
- const clonePath = repo.path || path.join(config.config.lucySettings.defaultModulePath ?? '', name);
65
-
66
- const isRegistered = yield* isSubmoduleRegistered(git, clonePath);
67
- const isConfiguredInFile = (yield* fs.exists(gitmodulesPath)) && (yield* fs.readFileString(gitmodulesPath, 'utf-8')).includes(`[submodule "${clonePath}"]`);
68
-
69
- if (!isConfiguredInFile || config.config.force) {
70
- logger.action(`Adding/updating submodule ${name} at ${clonePath}...`);
71
- // If git already has a config entry, we must use --force to repair it.
72
- const submoduleArgs = () => {
73
- if (update) {
74
- return ['add', '--force', repo.source, clonePath];
75
- }
76
- return ['add', ...(config.config.force || isRegistered ? ['--force'] : []), repo.source, clonePath];
77
- }
78
- // await git.subModule(submoduleArgs);
79
- yield* Effect.tryPromise({
80
- try: () => git.subModule(submoduleArgs()),
81
- catch: (error) => {
82
- return new AppError({
83
- cause: error,
84
- message: "Failed to add submodule",
85
- });
86
- }
87
- })
88
- } else {
89
- logger.alert(`Submodule ${name} at ${clonePath} already registered. Skipping add.`);
90
- }
91
-
92
- yield* Effect.tryPromise({
93
- try: () => git.submoduleUpdate(['--init', '--recursive', clonePath]),
94
- catch: (error) => {
95
- return new AppError({
96
- cause: error,
97
- message: "Failed to update submodule",
98
- });
99
- }
100
- })
101
- yield* Effect.tryPromise({
102
- try: () => simpleGit({ baseDir: path.join(config.config.cwd, clonePath) }).checkout(repo.branch),
103
- catch: (error) => {
104
- return new AppError({
105
- cause: error,
106
- message: `Failed to checkout submodule ${repo} branch ${repo.branch}`,
107
- });
108
- }
109
- })
110
- }
111
- logger.success("All modules processed!");
112
-
113
- })
114
-
115
- export const gitSyncTemplates = (update: boolean = false) => Effect.gen(function* () {
116
- const config = yield* Config;
117
- const path = yield * Path.Path;
118
- const templatesPath = path.join(config.config.lucyHome, 'templates');
119
- const fs = yield* FileSystem.FileSystem
120
-
121
- const exists = yield* fs.exists(templatesPath)
122
-
123
- if(!exists) {
124
- const git = simpleGit({ baseDir: path.join(config.config.lucyHome) });
125
- console.log('cloning templates repository');
126
- yield* Effect.tryPromise({
127
- try: () => git.clone('https://github.com/Sunnyside-UP-GmbH/lucy-templates.git', 'templates'),
128
- catch: (error) => {
129
- console.log(error);
130
- return new AppError({
131
- cause: error,
132
- message: "Failed to clone templates repository",
133
- });
134
- }
135
- })
136
- }
137
-
138
- if(exists) {
139
- const git = simpleGit({ baseDir: path.join(config.config.lucyHome, 'templates') });
140
- yield* Effect.tryPromise({
141
- try: () => git.pull(),
142
- catch: (error) => {
143
- console.log(error);
144
- return new AppError({
145
- cause: error,
146
- message: "Failed to pull templates repository",
147
- });
148
- }
149
- })
150
- }
151
-
152
- })
@@ -1,20 +0,0 @@
1
- import { Effect } from "effect/index";
2
- import { Config } from "../config.js";
3
- import { FileSystem, Path } from "@effect/platform"
4
- import { logger, orange } from "../utils/logger.js";
5
- import path, { join } from 'path';
6
- import { gitSyncTemplates } from "./git.js";
7
-
8
- export const createLucyHome = () => {
9
- return Effect.gen(function*() {
10
- const config = yield* Config
11
- const fs = yield* FileSystem.FileSystem
12
- const p = yield* Path.Path
13
-
14
- if(!(yield* fs.exists(config.config.lucyHome))) {
15
- logger.action(`Creating Lucy home directory at ${orange(config.config.lucyHome)}`);
16
- yield* fs.makeDirectory(config.config.lucyHome, { recursive: true });
17
- }
18
- yield* gitSyncTemplates();
19
- });
20
- }