lucy-cli 1.2.4 → 2.0.0-alpha.1
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.
- package/README.md +4 -3
- package/dist/args.d.ts +7 -0
- package/dist/args.js +23 -0
- package/dist/commands.d.ts +3 -0
- package/dist/commands.js +18 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.js +39 -0
- package/dist/error.d.ts +17 -0
- package/dist/error.js +5 -0
- package/dist/helpers.d.ts +1 -32
- package/dist/helpers.js +6 -261
- package/dist/index.d.ts +2 -52
- package/dist/index.js +25 -282
- package/dist/init.d.ts +4 -8
- package/dist/init.js +245 -160
- package/dist/params.d.ts +7 -0
- package/dist/params.js +23 -0
- package/dist/policy.d.ts +3 -0
- package/dist/policy.js +5 -0
- package/dist/prepare.d.ts +0 -8
- package/dist/prepare.js +20 -19
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +11 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/types.js +1 -0
- package/dist/states.d.ts +10 -0
- package/dist/states.js +7 -0
- package/files/expo/.env +1 -0
- package/files/expo/.nvmrc +1 -0
- package/files/expo/.prettierignore +23 -0
- package/files/expo/.prettierrc.json +16 -0
- package/files/expo/.yarnrc +1 -0
- package/files/expo/.yarnrc.yml +3 -0
- package/files/expo/app/(tabs)/_layout.tsx +45 -0
- package/files/expo/app/_layout.tsx +45 -0
- package/files/expo/babel.config.js +9 -0
- package/files/expo/constants/Colors.ts +27 -0
- package/files/expo/constants/theme.ts +18 -0
- package/files/expo/eas.json +26 -0
- package/files/expo/eslint.config.js +185 -0
- package/files/expo/global.css +47 -0
- package/files/expo/hooks/useColorScheme.ts +11 -0
- package/files/expo/hooks/useColorScheme.web.ts +21 -0
- package/files/expo/hooks/useColorSchemeRN.ts +1 -0
- package/files/expo/hooks/useThemeColor.ts +21 -0
- package/files/expo/lib/data.ts +45 -0
- package/files/expo/lib/utils/index.ts +6 -0
- package/files/expo/lib/utils/polyfills.ts +29 -0
- package/files/expo/lib/wix/client.ts +14 -0
- package/files/expo/lib/wix/index.ts +1 -0
- package/files/expo/lucy.json +8 -0
- package/files/expo/readme.md +45 -0
- package/files/expo/tailwind.config.js +198 -0
- package/files/expo/tsconfig.json +40 -0
- package/files/expo/types/nativewind-env.d.ts +1 -0
- package/files/expo/types/reset.d.ts +1 -0
- package/files/velo/typescript/styles/global.scss +0 -0
- package/package.json +14 -11
- package/src/args.ts +36 -0
- package/src/commands.ts +21 -0
- package/src/config.ts +61 -0
- package/src/error.ts +4 -0
- package/src/helpers.ts +7 -305
- package/src/index.ts +29 -362
- package/src/init.ts +345 -177
- package/src/policy.ts +6 -0
- package/src/prepare.ts +19 -19
- package/src/runtime.ts +20 -0
- package/src/schemas/index.ts +3 -0
- package/src/schemas/types.ts +0 -0
- package/src/states.ts +15 -0
- package/{src/Gulpfile.ts → src copy/Gulpfile.ts } +3 -1
- package/{src/gulp/backend.ts → src copy/gulp/backend.ts } +3 -12
- package/{src/gulp/checks.ts → src copy/gulp/checks.ts } +2 -6
- package/{src/gulp/copy.ts → src copy/gulp/copy.ts } +1 -6
- package/src copy/gulp/helpers.ts +26 -0
- package/{src/gulp/public.ts → src copy/gulp/public.ts } +1 -6
- package/{src/gulp/styles.ts → src copy/gulp/styles.ts } +2 -7
- package/{src/gulp/templates.ts → src copy/gulp/templates.ts } +1 -6
- package/src copy/helpers.ts +307 -0
- package/src copy/index.ts +379 -0
- package/src copy/init.ts +183 -0
- package/src copy/models.ts +35 -0
- package/src copy/prepare.ts +24 -0
- package/src copy/schemas/index.ts +0 -0
- package/src copy/schemas/types.ts +0 -0
- package/src copy/settings.json +67 -0
- package/src copy/types.d.ts +8 -0
- package/dist/Gulpfile.d.ts +0 -33
- package/dist/Gulpfile.js +0 -114
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -44
- package/dist/dev.d.ts +0 -2
- package/dist/dev.js +0 -14
- package/dist/gulp/backend copy.d.ts +0 -4
- package/dist/gulp/backend copy.js +0 -50
- package/dist/gulp/backend.d.ts +0 -3
- package/dist/gulp/backend.js +0 -101
- package/dist/gulp/checks.d.ts +0 -3
- package/dist/gulp/checks.js +0 -209
- package/dist/gulp/clean copy.d.ts +0 -2
- package/dist/gulp/clean copy.js +0 -19
- package/dist/gulp/clean.d.ts +0 -3
- package/dist/gulp/clean.js +0 -28
- package/dist/gulp/copy.d.ts +0 -2
- package/dist/gulp/copy.js +0 -38
- package/dist/gulp/docs.d.ts +0 -2
- package/dist/gulp/docs.js +0 -27
- package/dist/gulp/helpers.d.ts +0 -1
- package/dist/gulp/helpers.js +0 -7
- package/dist/gulp/pages copy.d.ts +0 -3
- package/dist/gulp/pages copy.js +0 -22
- package/dist/gulp/pages.d.ts +0 -2
- package/dist/gulp/pages.js +0 -36
- package/dist/gulp/pipeline.d.ts +0 -1
- package/dist/gulp/pipeline.js +0 -28
- package/dist/gulp/public.d.ts +0 -2
- package/dist/gulp/public.js +0 -54
- package/dist/gulp/styles.d.ts +0 -2
- package/dist/gulp/styles.js +0 -44
- package/dist/gulp/templates.d.ts +0 -2
- package/dist/gulp/templates.js +0 -37
- package/dist/gulp/test.d.ts +0 -2
- package/dist/gulp/test.js +0 -26
- package/dist/gulp/types.d.ts +0 -4
- package/dist/gulp/types.js +0 -288
- package/dist/gulp/watchers.d.ts +0 -9
- package/dist/gulp/watchers.js +0 -58
- package/dist/init copy.d.ts +0 -8
- package/dist/init copy.js +0 -167
- package/dist/install.d.ts +0 -2
- package/dist/install.js +0 -53
- package/dist/settings.json +0 -67
- package/dist/start_gulp.d.ts +0 -2
- package/dist/start_gulp.js +0 -14
- package/dist/sync.d.ts +0 -2
- package/dist/sync.js +0 -87
- package/src/gulp/helpers.ts +0 -9
- /package/{files/.gitmodules → dist/schemas/types.d.ts} +0 -0
- /package/files/{typescript/__mocks__/.gitkeep → velo/.gitmodules} +0 -0
- /package/files/{.madgerc → velo/.madgerc} +0 -0
- /package/files/{.nvmrc → velo/.nvmrc} +0 -0
- /package/files/{.stylelintrc.js → velo/.stylelintrc.js} +0 -0
- /package/files/{.yarnrc.yml → velo/.yarnrc.yml} +0 -0
- /package/files/{currents.config.js → velo/currents.config.js} +0 -0
- /package/files/{cypress → velo/cypress}/e2e/base/base.cy.ts +0 -0
- /package/files/{cypress → velo/cypress}/fixtures/example.json +0 -0
- /package/files/{cypress → velo/cypress}/support/commands.ts +0 -0
- /package/files/{cypress → velo/cypress}/support/e2e.ts +0 -0
- /package/files/{cypress → velo/cypress}/tsconfig.json +0 -0
- /package/files/{cypress.config.mjs → velo/cypress.config.mjs} +0 -0
- /package/files/{eslint.config.mjs → velo/eslint.config.mjs} +0 -0
- /package/files/{local.tsconfig.json → velo/local.tsconfig.json} +0 -0
- /package/files/{typedoc.json → velo/typedoc.json} +0 -0
- /package/files/{typescript/pages → velo/typescript/__mocks__}/.gitkeep +0 -0
- /package/files/{typescript → velo/typescript}/backend/data.ts +0 -0
- /package/files/{typescript → velo/typescript}/backend/events.ts +0 -0
- /package/files/{typescript → velo/typescript}/backend/http-functions.ts +0 -0
- /package/files/{typescript → velo/typescript}/backend/lib/http-functions/sync.ts +0 -0
- /package/files/{typescript → velo/typescript}/backend/permissions.json +0 -0
- /package/files/{typescript/public → velo/typescript/pages}/.gitkeep +0 -0
- /package/files/{typescript/styles → velo/typescript/public}/.gitkeep +0 -0
- /package/files/{typescript → velo/typescript}/public/scss/app.scss +0 -0
- /package/files/{typescript/styles/global.scss → velo/typescript/styles/.gitkeep} +0 -0
- /package/files/{typescript → velo/typescript}/tsconfig.json +0 -0
- /package/files/{vitest.config.ts → velo/vitest.config.ts} +0 -0
- /package/{src → src copy}/gulp/clean.ts +0 -0
- /package/{src → src copy}/gulp/pages.ts +0 -0
- /package/{src → src copy}/gulp/pipeline.ts +0 -0
- /package/{src → src copy}/gulp/types.ts +0 -0
- /package/{src → src copy}/gulp/watchers.ts +0 -0
- /package/{src → src copy}/sync.ts +0 -0
package/dist/init.js
CHANGED
@@ -1,164 +1,249 @@
|
|
1
|
-
import chalk from 'chalk';
|
2
|
-
import { existsSync, mkdirSync, promises as fsPromises } from 'fs';
|
3
|
-
import fse from 'fs-extra';
|
4
|
-
import { join } from 'path';
|
5
|
-
import fs from 'fs/promises';
|
6
|
-
import path from 'path';
|
7
|
-
import os from 'os';
|
8
|
-
import enquirer from 'enquirer';
|
9
|
-
import { blue, orange, red } from './index.js';
|
10
|
-
import { createTemplateFolder, gitInit, installPackages } from './helpers.js';
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
}
|
113
|
-
/**
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
async function editJson(filePath, keys, values) {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
1
|
+
// import chalk from 'chalk';
|
2
|
+
// import { existsSync, mkdirSync, promises as fsPromises } from 'fs';
|
3
|
+
// import fse from 'fs-extra';
|
4
|
+
// import { join } from 'path';
|
5
|
+
// import fs from 'fs/promises';
|
6
|
+
// import path from 'path';
|
7
|
+
// import os from 'os';
|
8
|
+
// import enquirer from 'enquirer';
|
9
|
+
// import { ModuleSettings, ProjectSettings, blue, green, orange, red } from './index.js';
|
10
|
+
// import { createTemplateFolder, gitInit, installPackages } from './helpers.js';
|
11
|
+
import { Effect, Schema } from "effect/index";
|
12
|
+
import { Config } from "./config.js";
|
13
|
+
import { Command, Terminal, FileSystem, Path } from "@effect/platform";
|
14
|
+
import { JsonSchema } from "./schemas/index.js";
|
15
|
+
// const { Select } = enquirer as any;
|
16
|
+
// /**
|
17
|
+
// * Init Lucy project
|
18
|
+
// * @param {string} cwd Current working directory
|
19
|
+
// * @param {string} packageRoot Package root directory
|
20
|
+
// * @returns {void}
|
21
|
+
// */
|
22
|
+
// export async function init(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
|
23
|
+
// if(projectSettings.packageJSON && projectSettings.packageJSON.wixLucy?.initialized && !moduleSettings.args.includes('-f')) {
|
24
|
+
// console.log((`💩 ${red.underline.bold("=> This project is already initialized =>")} ${orange(moduleSettings.targetFolder)}`));
|
25
|
+
// return;
|
26
|
+
// }
|
27
|
+
// const templatesPath = join(os.homedir(), '.lucy-cli');
|
28
|
+
// if (!existsSync(templatesPath)) {
|
29
|
+
// console.log(chalk.yellow(`Templates folder not found at ${orange(templatesPath)}. Creating it with a default template...`));
|
30
|
+
// await createTemplateFolder(moduleSettings);
|
31
|
+
// }
|
32
|
+
// const templateChoices = (await fs.readdir(templatesPath, { withFileTypes: true }))
|
33
|
+
// .filter(dirent => dirent.isDirectory())
|
34
|
+
// .map(dirent => dirent.name);
|
35
|
+
// if (templateChoices.length === 0) {
|
36
|
+
// console.log((`💩 ${red.underline.bold("=> No templates found in =>")} ${orange(templatesPath)}`));
|
37
|
+
// return;
|
38
|
+
// }
|
39
|
+
// const prompt = new Select({
|
40
|
+
// name: 'template',
|
41
|
+
// message: 'Select a project template',
|
42
|
+
// choices: templateChoices
|
43
|
+
// });
|
44
|
+
// const selectedTemplate = await prompt.run();
|
45
|
+
// const templateDir = join(templatesPath, selectedTemplate);
|
46
|
+
// const templateFilesDir = join(templateDir, 'files');
|
47
|
+
// const templateSettingsPath = join(templateDir, 'settings.json');
|
48
|
+
// if (!existsSync(templateSettingsPath)) {
|
49
|
+
// console.log((`💩 ${red.underline.bold("=> Template is missing settings.json at =>")} ${orange(templateSettingsPath)}`));
|
50
|
+
// return;
|
51
|
+
// }
|
52
|
+
// try {
|
53
|
+
// const templateSettingsRaw = await fs.readFile(templateSettingsPath, 'utf8');
|
54
|
+
// moduleSettings.settings = JSON.parse(templateSettingsRaw);
|
55
|
+
// } catch (e) {
|
56
|
+
// console.log((`💩 ${red.underline.bold("=> Error reading or parsing template settings =>")} ${orange(e)}`));
|
57
|
+
// return;
|
58
|
+
// }
|
59
|
+
// await copyFolder(templateFilesDir, moduleSettings.targetFolder);
|
60
|
+
// await editJson(moduleSettings.packageJsonPath, ['type', 'scripts'], ['module', moduleSettings.settings.scripts ]);
|
61
|
+
// await stringReplace(join(moduleSettings.targetFolder, 'currents.config.js'), ['__ProjectName__'], [path.basename(moduleSettings.targetFolder)]);
|
62
|
+
// await installPackages(moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
|
63
|
+
// await editJson(join(moduleSettings.targetFolder, 'jsconfig.json'), ['compilerOptions', 'exclude'], [moduleSettings.settings.wixSettings.compilerOptions, moduleSettings.settings.wixSettings.exclude]);
|
64
|
+
// await editJson(join(moduleSettings.targetFolder, 'typedoc.json'), ['name'], [path.basename(moduleSettings.targetFolder)]);
|
65
|
+
// await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules, moduleSettings.force);
|
66
|
+
// moduleSettings.settings.initialized = true;
|
67
|
+
// const eslintrcPath = join(moduleSettings.targetFolder, '.eslintrc.json');
|
68
|
+
// if(existsSync(eslintrcPath)) {
|
69
|
+
// console.log((`🐕 ${blue.underline.bold("=> Deleting .eslintrc.json")}`));
|
70
|
+
// await fs.rm(join(eslintrcPath), { recursive: false }).catch(e => {
|
71
|
+
// console.log((`💩 ${red.underline.bold("=> Could not delete .eslintrc.json ")} ${red.bold("=> ", e)}`));
|
72
|
+
// });
|
73
|
+
// }
|
74
|
+
// console.log((`🐕 ${blue.underline.bold("=> Writing settings to lucy.json")}`));
|
75
|
+
// await fs.writeFile(join(moduleSettings.targetFolder, 'lucy.json'), JSON.stringify(moduleSettings.settings, null, 2));
|
76
|
+
// console.log(chalk.greenBright.underline('🐶 => Initialization done!'));
|
77
|
+
// }
|
78
|
+
// /**
|
79
|
+
// * Copy files from source to target
|
80
|
+
// * @param {string} source Source folder
|
81
|
+
// * @param {string} target Target folder
|
82
|
+
// * @returns {Promise<void>}
|
83
|
+
// */
|
84
|
+
// async function copyFolder(source: string, target: string): Promise<void> {
|
85
|
+
// if (!existsSync(target)){
|
86
|
+
// console.log((`💩 ${red.underline.bold("=> Target folder doesn't exist =>")} ${orange(target)}`));
|
87
|
+
// return;
|
88
|
+
// }
|
89
|
+
// try {
|
90
|
+
// const files = await fsPromises.readdir(source);
|
91
|
+
// for (const file of files){
|
92
|
+
// const sourcePath = join(source, file);
|
93
|
+
// const targetPath = join(target, file);
|
94
|
+
// if (file === 'lucy.json' && existsSync(targetPath)){
|
95
|
+
// continue;
|
96
|
+
// }
|
97
|
+
// const stats = await fsPromises.stat(sourcePath);
|
98
|
+
// if (stats.isDirectory()){
|
99
|
+
// if (!existsSync(file)){
|
100
|
+
// mkdirSync(file);
|
101
|
+
// }
|
102
|
+
// await fse.copySync(sourcePath, targetPath, { overwrite: true });
|
103
|
+
// } else {
|
104
|
+
// fse.copySync(sourcePath, targetPath, { overwrite: true });
|
105
|
+
// }
|
106
|
+
// }
|
107
|
+
// } catch (err){
|
108
|
+
// console.log((`💩 ${red.underline.bold("=> There was an error while copying files =>")} ${orange(err)}`));
|
109
|
+
// } finally {
|
110
|
+
// console.log("🐕" + blue.underline.bold(' => Copy files completed!'));
|
111
|
+
// }
|
112
|
+
// }
|
113
|
+
// /**
|
114
|
+
// * Edit Json files
|
115
|
+
// * @param {string} filePath File path
|
116
|
+
// * @param {string[]} keys Keys to edit
|
117
|
+
// * @param {string[]} values Values to edit
|
118
|
+
// * @returns {void}
|
119
|
+
// */
|
120
|
+
// async function editJson(filePath: string, keys: string[], values: string[] | Object[] ) {
|
121
|
+
// try {
|
122
|
+
// const data = await fs.readFile(filePath, 'utf8');
|
123
|
+
// let jsonData;
|
124
|
+
// try {
|
125
|
+
// jsonData = JSON.parse(data);
|
126
|
+
// } catch (parseError) {
|
127
|
+
// console.log((`💩 ${red.underline.bold("=> Error parsing JSON =>")} ${orange(parseError)}`));
|
128
|
+
// return;
|
129
|
+
// }
|
130
|
+
// for (const key of keys){
|
131
|
+
// const index = keys.indexOf(key);
|
132
|
+
// const value = values[index];
|
133
|
+
// jsonData[key] = value;
|
134
|
+
// }
|
135
|
+
// const updatedJsonData = JSON.stringify(jsonData, null, 2);
|
136
|
+
// await fs.writeFile(filePath, updatedJsonData, 'utf8');
|
137
|
+
// } catch (err) {
|
138
|
+
// console.log((`💩 ${red.underline.bold("=> Error editing JSON Data =>")} ${orange(err)}`));
|
139
|
+
// } finally {
|
140
|
+
// console.log("🐕" + blue.underline(` => Updated file ${orange(filePath)}`));
|
141
|
+
// }
|
142
|
+
// }
|
143
|
+
// async function stringReplace(filePath: string, keys: string[], values: string[]) {
|
144
|
+
// try {
|
145
|
+
// let modifiedContent: string = '';
|
146
|
+
// const data = await fs.readFile(filePath, 'utf8');
|
147
|
+
// for (const key of keys){
|
148
|
+
// const index = keys.indexOf(key);
|
149
|
+
// const value = values[index];
|
150
|
+
// const regex = new RegExp(`${key}`, 'g');
|
151
|
+
// modifiedContent = data.replace(regex, `${value}`);
|
152
|
+
// }
|
153
|
+
// await fs.writeFile(filePath, modifiedContent, 'utf8');
|
154
|
+
// } catch (err) {
|
155
|
+
// console.log((`💩 ${red.underline.bold("=> During string replace =>")} ${orange(err)}`));
|
156
|
+
// } finally {
|
157
|
+
// console.log(blue.underline(`🐕 => Updated file ${orange(filePath)}`));
|
158
|
+
// }
|
159
|
+
// }
|
160
|
+
const yarn = Command.make("yarn").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
|
161
|
+
Command.exitCode // Get the exit code
|
162
|
+
);
|
163
|
+
const init_expo = () => {
|
164
|
+
return Effect.gen(function* () {
|
165
|
+
const config = yield* Config;
|
166
|
+
const terminal = yield* Terminal.Terminal;
|
167
|
+
const fs = yield* FileSystem.FileSystem;
|
168
|
+
const path = yield* Path.Path;
|
169
|
+
const yarn = Command.make("yarn", "add", "nativewind", "react-native-reanimated@~3.17.4", "react-native-safe-area-context@5.4.0", "@wix/sdk", "@wix/data", "expo-standard-web-crypto").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
|
170
|
+
Command.exitCode // Get the exit code
|
171
|
+
);
|
172
|
+
const yarnDev = Command.make("yarn", "add", "--dev", "tailwindcss@^3.4.17", "prettier-plugin-tailwindcss@^0.5.11", "@styled/typescript-styled-plugin", "typescript-eslint-language-service", "eslint-config-prettier", "eslint-plugin-jsdoc", "eslint-plugin-named-import-spacing", "eslint-plugin-only-warn", "eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-simple-import-sort", "@next/eslint-plugin-next", "@styled/typescript-styled-plugin", "@stylelint/postcss-css-in-js", "@typescript-eslint/parser", "typescript-eslint", "typescript-eslint-language-service", "@total-typescript/ts-reset").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
|
173
|
+
Command.exitCode // Get the exit code
|
174
|
+
);
|
175
|
+
const npx = Command.make("npx", "expo", "install", "tailwindcss-animate", "class-variance-authority", "clsx", "tailwind-merge", "expo-crypto").pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
|
176
|
+
Command.exitCode // Get the exit code
|
177
|
+
);
|
178
|
+
const projectName = config.config.cwd.split('/').pop() || 'expo-project';
|
179
|
+
const appJsonRaw = yield* fs.readFile("app.json").pipe(Effect.catchAll((error) => {
|
180
|
+
return Effect.succeed('{}');
|
181
|
+
}));
|
182
|
+
const lucyJsonRaw = yield* fs.readFile("lucy.json").pipe(Effect.catchAll((error) => {
|
183
|
+
return Effect.succeed('{}');
|
184
|
+
}));
|
185
|
+
const appJSON = Schema.decodeUnknownSync(JsonSchema)(appJsonRaw.toString());
|
186
|
+
const lucyJSON = Schema.decodeUnknownSync(JsonSchema)(lucyJsonRaw.toString());
|
187
|
+
const expoAppReady = appJSON.expo ? true : false;
|
188
|
+
const lucyInitialized = lucyJSON.initialized ? true : false;
|
189
|
+
const gitPresent = yield* fs.exists(config.config.cwd + '/.git');
|
190
|
+
const files = yield* fs.readDirectory(config.config.cwd);
|
191
|
+
const nonGitFiles = files.filter(file => file !== '.git');
|
192
|
+
if (!gitPresent)
|
193
|
+
return yield* Effect.logError("No git repository found. Please initialize a git repository before running this command.");
|
194
|
+
if (nonGitFiles.length > 0)
|
195
|
+
return yield* Effect.logError("The current directory is not empty. Please run this command in an empty directory.");
|
196
|
+
if (!expoAppReady) {
|
197
|
+
const initExpo = Command.make("npx", "create-expo-app@latest", projectName).pipe(Command.stdout("inherit"), // Stream stdout to process.stdout
|
198
|
+
Command.exitCode // Get the exit code
|
199
|
+
);
|
200
|
+
yield* initExpo;
|
201
|
+
const projectPath = path.join(config.config.cwd, projectName);
|
202
|
+
const projectFiles = yield* fs.readDirectory(projectPath);
|
203
|
+
yield* Effect.forEach(projectFiles.filter(file => file !== '.git'), (file) => fs.copy(path.join(projectPath, file), path.join(config.config.cwd, file), { overwrite: true }), { discard: true });
|
204
|
+
yield* fs.remove(projectPath, { recursive: true });
|
126
205
|
}
|
127
|
-
|
128
|
-
|
129
|
-
|
206
|
+
if (lucyInitialized)
|
207
|
+
return yield* Effect.logError("Lucy is already initialized in this project. Please run this command in an empty directory.");
|
208
|
+
console.log("Expo project initialized with app.json:", projectName);
|
209
|
+
let res = yield* npx;
|
210
|
+
res = yield* yarn;
|
211
|
+
res = yield* yarnDev;
|
212
|
+
if (res !== 0) {
|
213
|
+
return yield* Effect.logError("Failed to install Expo dependencies. Please check the error message above.");
|
130
214
|
}
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
215
|
+
const baseFiles = yield* fs.readDirectory(config.config.filesFolder + '/expo');
|
216
|
+
yield* Effect.forEach(baseFiles, (file) => fs.copy(path.join(config.config.filesFolder, 'expo', file), path.join(config.config.cwd, file), { overwrite: true }));
|
217
|
+
const newScripts = {
|
218
|
+
"dev": "expo start",
|
219
|
+
"start": "expo start",
|
220
|
+
"android": "expo start --android",
|
221
|
+
"ios": "expo start --ios",
|
222
|
+
"web": "expo start --web",
|
223
|
+
"format": "prettier --write \"./*.json\" \"**/*.{ts,tsx,md,json,jsonc,json5}\"",
|
224
|
+
"build:ios": "eas build --platform ios --local --profile preview",
|
225
|
+
"build:android": "eas build --platform android --local --profile preview",
|
226
|
+
"build:web": "eas build --platform web --local --profile preview",
|
227
|
+
};
|
228
|
+
const packageJsonPath = path.join(config.config.cwd, "package.json");
|
229
|
+
const packageJsonRaw = yield* fs.readFile(packageJsonPath);
|
230
|
+
const packageJson = Schema.decodeUnknownSync(JsonSchema)(packageJsonRaw.toString());
|
231
|
+
packageJson.scripts = {
|
232
|
+
...packageJson.scripts,
|
233
|
+
...newScripts
|
234
|
+
};
|
235
|
+
yield* fs.writeFileString(path.join(config.config.cwd, 'package.json'), JSON.stringify(packageJson, null, 2));
|
236
|
+
yield* fs.remove(path.join(config.config.cwd, "package-lock.json"), { force: true });
|
237
|
+
});
|
238
|
+
};
|
239
|
+
export const init = () => {
|
240
|
+
return Effect.gen(function* (_) {
|
241
|
+
const config = yield* Config;
|
242
|
+
if (config.config.action.type === undefined) {
|
243
|
+
return yield* Effect.fail("No Params Provided");
|
135
244
|
}
|
136
|
-
|
137
|
-
|
138
|
-
}
|
139
|
-
catch (err) {
|
140
|
-
console.log((`💩 ${red.underline.bold("=> Error editing JSON Data =>")} ${orange(err)}`));
|
141
|
-
}
|
142
|
-
finally {
|
143
|
-
console.log("🐕" + blue.underline(` => Updated file ${orange(filePath)}`));
|
144
|
-
}
|
145
|
-
}
|
146
|
-
async function stringReplace(filePath, keys, values) {
|
147
|
-
try {
|
148
|
-
let modifiedContent = '';
|
149
|
-
const data = await fs.readFile(filePath, 'utf8');
|
150
|
-
for (const key of keys) {
|
151
|
-
const index = keys.indexOf(key);
|
152
|
-
const value = values[index];
|
153
|
-
const regex = new RegExp(`${key}`, 'g');
|
154
|
-
modifiedContent = data.replace(regex, `${value}`);
|
245
|
+
if (config.config.action.type === 'expo') {
|
246
|
+
return yield* init_expo();
|
155
247
|
}
|
156
|
-
|
157
|
-
|
158
|
-
catch (err) {
|
159
|
-
console.log((`💩 ${red.underline.bold("=> During string replace =>")} ${orange(err)}`));
|
160
|
-
}
|
161
|
-
finally {
|
162
|
-
console.log(blue.underline(`🐕 => Updated file ${orange(filePath)}`));
|
163
|
-
}
|
164
|
-
}
|
248
|
+
});
|
249
|
+
};
|
package/dist/params.d.ts
ADDED
package/dist/params.js
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import yargs from "yargs";
|
2
|
+
import { hideBin } from "yargs/helpers";
|
3
|
+
export async function get_args() {
|
4
|
+
const argv = await yargs(hideBin(process.argv))
|
5
|
+
.usage('Usage: $0 <command> [options]')
|
6
|
+
.command('init <type>', 'Initialize a new Lucy project', (yargs) => {
|
7
|
+
return yargs.positional('type', {
|
8
|
+
describe: 'The type of project to initialize',
|
9
|
+
choices: ['velo', 'expo', 'blocks'],
|
10
|
+
demandOption: true, // Makes this positional argument required
|
11
|
+
});
|
12
|
+
})
|
13
|
+
// Enforce that a command must be provided (e.g., 'init')
|
14
|
+
.demandCommand(1, 'You need to provide a command. Use --help for a list of commands.')
|
15
|
+
.help()
|
16
|
+
.alias('h', 'help')
|
17
|
+
.strict()
|
18
|
+
.wrap(yargs().terminalWidth()) // Wrap help text to terminal width
|
19
|
+
.epilogue('For more information, visit https://github.com/your-repo/wix-lucy-cli') // Example of a relevant epilogue
|
20
|
+
.parseAsync();
|
21
|
+
// The cast is now safer with the defined interface.
|
22
|
+
return argv;
|
23
|
+
}
|
package/dist/policy.d.ts
ADDED
package/dist/policy.js
ADDED
package/dist/prepare.d.ts
CHANGED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { ModuleSettings, ProjectSettings } from './index.js';
|
2
|
-
/**
|
3
|
-
* Init Lucy project
|
4
|
-
* @param {string} cwd Current working directory
|
5
|
-
* @param {string} packageRoot Package root directory
|
6
|
-
* @returns {void}
|
7
|
-
*/
|
8
|
-
export declare function prepare(moduleSettings: ModuleSettings, projectSettings: ProjectSettings): Promise<void>;
|
package/dist/prepare.js
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
"use strict";
|
2
|
+
// import chalk from 'chalk';
|
3
|
+
// import { ModuleSettings, ProjectSettings, blue, green, orange, red, magenta } from './index.js';
|
4
|
+
// import { gitInit, installPackages } from './helpers.js';
|
5
|
+
// /**
|
6
|
+
// * Init Lucy project
|
7
|
+
// * @param {string} cwd Current working directory
|
8
|
+
// * @param {string} packageRoot Package root directory
|
9
|
+
// * @returns {void}
|
10
|
+
// */
|
11
|
+
// export async function prepare(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
|
12
|
+
// if(!projectSettings.lucySettings?.initialized) {
|
13
|
+
// console.log((`💩 ${red.underline.bold("=> This project is not initialized =>")} ${orange(moduleSettings.targetFolder)}`));
|
14
|
+
// console.log("🐕" + magenta.underline(' => Use init to initialize'));
|
15
|
+
// return;
|
16
|
+
// }
|
17
|
+
// await installPackages(projectSettings.lucySettings.wixPackages, projectSettings.lucySettings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
|
18
|
+
// await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules, moduleSettings.force);
|
19
|
+
// console.log(chalk.greenBright.underline('🐶 => Prepare done!'));
|
20
|
+
// }
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ManagedRuntime } from "effect";
|
2
|
+
import { get_args } from "./args.js";
|
3
|
+
import { NodeInspectState, ServiceInspectState } from "./states.js";
|
4
|
+
import { NodeContext } from "@effect/platform-node";
|
5
|
+
export declare const build_runtime: (args: Awaited<ReturnType<typeof get_args>>) => ManagedRuntime.ManagedRuntime<import("./config.js").Config | ServiceInspectState | NodeInspectState | NodeContext.NodeContext, never>;
|
package/dist/runtime.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Layer, Logger, LogLevel, ManagedRuntime } from "effect";
|
2
|
+
import { ConfigLayer } from "./config.js";
|
3
|
+
import { NodeInspectState, ServiceInspectState, node_inspect_init, service_inspect_init } from "./states.js";
|
4
|
+
import { NodeContext } from "@effect/platform-node";
|
5
|
+
export const build_runtime = (args) => {
|
6
|
+
const log_level = process.env.DEBUG === "true" ? LogLevel.Debug : LogLevel.Info;
|
7
|
+
return ManagedRuntime.make(Layer.mergeAll(ConfigLayer(args), Layer.effect(ServiceInspectState, service_inspect_init), Layer.effect(NodeInspectState, node_inspect_init), NodeContext.layer, Logger.minimumLogLevel(log_level), Logger.replace(Logger.defaultLogger, Logger.prettyLogger({
|
8
|
+
colors: true,
|
9
|
+
mode: 'tty'
|
10
|
+
}))));
|
11
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
package/dist/states.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Context, Ref } from "effect";
|
2
|
+
declare const ServiceInspectState_base: Context.TagClass<ServiceInspectState, "ServiceInspectState", Ref.Ref<String>>;
|
3
|
+
export declare class ServiceInspectState extends ServiceInspectState_base {
|
4
|
+
}
|
5
|
+
export declare const service_inspect_init: import("effect/Effect").Effect<Ref.Ref<any>, never, never>;
|
6
|
+
declare const NodeInspectState_base: Context.TagClass<NodeInspectState, "NodeInspectState", Ref.Ref<String>>;
|
7
|
+
export declare class NodeInspectState extends NodeInspectState_base {
|
8
|
+
}
|
9
|
+
export declare const node_inspect_init: import("effect/Effect").Effect<Ref.Ref<any>, never, never>;
|
10
|
+
export {};
|
package/dist/states.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Context, Ref } from "effect";
|
2
|
+
export class ServiceInspectState extends Context.Tag("ServiceInspectState")() {
|
3
|
+
}
|
4
|
+
export const service_inspect_init = Ref.make([]);
|
5
|
+
export class NodeInspectState extends Context.Tag("NodeInspectState")() {
|
6
|
+
}
|
7
|
+
export const node_inspect_init = Ref.make([]);
|
package/files/expo/.env
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
EXPO_PUBLIC_WIX_CLIENT_ID=
|
@@ -0,0 +1 @@
|
|
1
|
+
22
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Dependencies
|
2
|
+
node_modules/
|
3
|
+
|
4
|
+
# Build output
|
5
|
+
dist
|
6
|
+
.next/
|
7
|
+
.wix/
|
8
|
+
build
|
9
|
+
out
|
10
|
+
|
11
|
+
# Turbo cache
|
12
|
+
.turbo
|
13
|
+
|
14
|
+
# Logs
|
15
|
+
*.log
|
16
|
+
npm-debug.log*
|
17
|
+
yarn-debug.log*
|
18
|
+
yarn-error.log*
|
19
|
+
pnpm-debug.log*
|
20
|
+
|
21
|
+
# As per your ESLint config, JS files are not formatted.
|
22
|
+
**/*.js
|
23
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"printWidth": 80,
|
3
|
+
"tabWidth": 4,
|
4
|
+
"useTabs": true,
|
5
|
+
"singleQuote": true,
|
6
|
+
"trailingComma": "all",
|
7
|
+
"plugins": ["prettier-plugin-tailwindcss"],
|
8
|
+
"overrides": [
|
9
|
+
{
|
10
|
+
"files": ["**/*.{json,jsonc,json5}", "*.{json,jsonc,json5}"],
|
11
|
+
"options": {
|
12
|
+
"useTabs": true
|
13
|
+
}
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
node-options=--max-old-space-size=16384
|