lucy-cli 1.2.5 → 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/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 -59
- 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 -369
- 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 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 -34
- package/dist/Gulpfile.js +0 -115
- 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 -91
- package/dist/gulp/checks.d.ts +0 -3
- package/dist/gulp/checks.js +0 -204
- 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 -33
- package/dist/gulp/docs.d.ts +0 -2
- package/dist/gulp/docs.js +0 -27
- package/dist/gulp/helpers.d.ts +0 -2
- package/dist/gulp/helpers.js +0 -24
- 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 -49
- package/dist/gulp/styles.d.ts +0 -2
- package/dist/gulp/styles.js +0 -39
- package/dist/gulp/templates.d.ts +0 -2
- package/dist/gulp/templates.js +0 -32
- 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/{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}/Gulpfile.ts +0 -0
- /package/{src → src copy}/gulp/backend.ts +0 -0
- /package/{src → src copy}/gulp/checks.ts +0 -0
- /package/{src → src copy}/gulp/clean.ts +0 -0
- /package/{src → src copy}/gulp/copy.ts +0 -0
- /package/{src → src copy}/gulp/helpers.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/public.ts +0 -0
- /package/{src → src copy}/gulp/styles.ts +0 -0
- /package/{src → src copy}/gulp/templates.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/src/init.ts
CHANGED
@@ -1,183 +1,351 @@
|
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
+
|
12
|
+
import { Effect, Schema } from "effect/index"
|
13
|
+
import { Config } from "./config.js";
|
14
|
+
import { Command, Terminal, FileSystem, Path } from "@effect/platform"
|
15
|
+
import { config } from "yargs";
|
16
|
+
import { JsonSchema } from "./schemas/index.js";
|
17
|
+
|
18
|
+
// const { Select } = enquirer as any;
|
19
|
+
// /**
|
20
|
+
// * Init Lucy project
|
21
|
+
// * @param {string} cwd Current working directory
|
22
|
+
// * @param {string} packageRoot Package root directory
|
23
|
+
// * @returns {void}
|
24
|
+
// */
|
25
|
+
// export async function init(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
const templatesPath = join(os.homedir(), '.lucy-cli');
|
27
|
-
if (!existsSync(templatesPath)) {
|
28
|
-
console.log(chalk.yellow(`Templates folder not found at ${orange(templatesPath)}. Creating it with a default template...`));
|
29
|
-
await createTemplateFolder(moduleSettings);
|
30
|
-
}
|
31
|
-
|
32
|
-
const templateChoices = (await fs.readdir(templatesPath, { withFileTypes: true }))
|
33
|
-
.filter(dirent => dirent.isDirectory())
|
34
|
-
.map(dirent => dirent.name);
|
35
|
-
|
36
|
-
if (templateChoices.length === 0) {
|
37
|
-
console.log((`💩 ${red.underline.bold("=> No templates found in =>")} ${orange(templatesPath)}`));
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
|
41
|
-
const prompt = new Select({
|
42
|
-
name: 'template',
|
43
|
-
message: 'Select a project template',
|
44
|
-
choices: templateChoices
|
45
|
-
});
|
46
|
-
|
47
|
-
const selectedTemplate = await prompt.run();
|
48
|
-
const templateDir = join(templatesPath, selectedTemplate);
|
49
|
-
const templateFilesDir = join(templateDir, 'files');
|
50
|
-
const templateSettingsPath = join(templateDir, 'settings.json');
|
51
|
-
|
52
|
-
if (!existsSync(templateSettingsPath)) {
|
53
|
-
console.log((`💩 ${red.underline.bold("=> Template is missing settings.json at =>")} ${orange(templateSettingsPath)}`));
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
try {
|
58
|
-
const templateSettingsRaw = await fs.readFile(templateSettingsPath, 'utf8');
|
59
|
-
moduleSettings.settings = JSON.parse(templateSettingsRaw);
|
60
|
-
} catch (e) {
|
61
|
-
console.log((`💩 ${red.underline.bold("=> Error reading or parsing template settings =>")} ${orange(e)}`));
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
|
65
|
-
await copyFolder(templateFilesDir, moduleSettings.targetFolder);
|
66
|
-
|
67
|
-
await editJson(moduleSettings.packageJsonPath, ['type', 'scripts'], ['module', moduleSettings.settings.scripts ]);
|
68
|
-
await stringReplace(join(moduleSettings.targetFolder, 'currents.config.js'), ['__ProjectName__'], [path.basename(moduleSettings.targetFolder)]);
|
69
|
-
|
70
|
-
await installPackages(moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
|
71
|
-
|
72
|
-
await editJson(join(moduleSettings.targetFolder, 'jsconfig.json'), ['compilerOptions', 'exclude'], [moduleSettings.settings.wixSettings.compilerOptions, moduleSettings.settings.wixSettings.exclude]);
|
73
|
-
await editJson(join(moduleSettings.targetFolder, 'typedoc.json'), ['name'], [path.basename(moduleSettings.targetFolder)]);
|
74
|
-
|
75
|
-
await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules, moduleSettings.force);
|
76
|
-
|
77
|
-
moduleSettings.settings.initialized = true;
|
78
|
-
|
79
|
-
const eslintrcPath = join(moduleSettings.targetFolder, '.eslintrc.json');
|
80
|
-
if(existsSync(eslintrcPath)) {
|
81
|
-
console.log((`🐕 ${blue.underline.bold("=> Deleting .eslintrc.json")}`));
|
82
|
-
await fs.rm(join(eslintrcPath), { recursive: false }).catch(e => {
|
83
|
-
console.log((`💩 ${red.underline.bold("=> Could not delete .eslintrc.json ")} ${red.bold("=> ", e)}`));
|
84
|
-
});
|
85
|
-
}
|
86
|
-
|
87
|
-
console.log((`🐕 ${blue.underline.bold("=> Writing settings to lucy.json")}`));
|
88
|
-
await fs.writeFile(join(moduleSettings.targetFolder, 'lucy.json'), JSON.stringify(moduleSettings.settings, null, 2));
|
89
|
-
|
90
|
-
console.log(chalk.greenBright.underline('🐶 => Initialization done!'));
|
91
|
-
}
|
27
|
+
// if(projectSettings.packageJSON && projectSettings.packageJSON.wixLucy?.initialized && !moduleSettings.args.includes('-f')) {
|
28
|
+
// console.log((`💩 ${red.underline.bold("=> This project is already initialized =>")} ${orange(moduleSettings.targetFolder)}`));
|
29
|
+
// return;
|
30
|
+
// }
|
92
31
|
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
32
|
+
// const templatesPath = join(os.homedir(), '.lucy-cli');
|
33
|
+
// if (!existsSync(templatesPath)) {
|
34
|
+
// console.log(chalk.yellow(`Templates folder not found at ${orange(templatesPath)}. Creating it with a default template...`));
|
35
|
+
// await createTemplateFolder(moduleSettings);
|
36
|
+
// }
|
37
|
+
|
38
|
+
// const templateChoices = (await fs.readdir(templatesPath, { withFileTypes: true }))
|
39
|
+
// .filter(dirent => dirent.isDirectory())
|
40
|
+
// .map(dirent => dirent.name);
|
41
|
+
|
42
|
+
// if (templateChoices.length === 0) {
|
43
|
+
// console.log((`💩 ${red.underline.bold("=> No templates found in =>")} ${orange(templatesPath)}`));
|
44
|
+
// return;
|
45
|
+
// }
|
46
|
+
|
47
|
+
// const prompt = new Select({
|
48
|
+
// name: 'template',
|
49
|
+
// message: 'Select a project template',
|
50
|
+
// choices: templateChoices
|
51
|
+
// });
|
52
|
+
|
53
|
+
// const selectedTemplate = await prompt.run();
|
54
|
+
// const templateDir = join(templatesPath, selectedTemplate);
|
55
|
+
// const templateFilesDir = join(templateDir, 'files');
|
56
|
+
// const templateSettingsPath = join(templateDir, 'settings.json');
|
57
|
+
|
58
|
+
// if (!existsSync(templateSettingsPath)) {
|
59
|
+
// console.log((`💩 ${red.underline.bold("=> Template is missing settings.json at =>")} ${orange(templateSettingsPath)}`));
|
60
|
+
// return;
|
61
|
+
// }
|
62
|
+
|
63
|
+
// try {
|
64
|
+
// const templateSettingsRaw = await fs.readFile(templateSettingsPath, 'utf8');
|
65
|
+
// moduleSettings.settings = JSON.parse(templateSettingsRaw);
|
66
|
+
// } catch (e) {
|
67
|
+
// console.log((`💩 ${red.underline.bold("=> Error reading or parsing template settings =>")} ${orange(e)}`));
|
68
|
+
// return;
|
69
|
+
// }
|
70
|
+
|
71
|
+
// await copyFolder(templateFilesDir, moduleSettings.targetFolder);
|
72
|
+
|
73
|
+
// await editJson(moduleSettings.packageJsonPath, ['type', 'scripts'], ['module', moduleSettings.settings.scripts ]);
|
74
|
+
// await stringReplace(join(moduleSettings.targetFolder, 'currents.config.js'), ['__ProjectName__'], [path.basename(moduleSettings.targetFolder)]);
|
75
|
+
|
76
|
+
// await installPackages(moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
|
77
|
+
|
78
|
+
// await editJson(join(moduleSettings.targetFolder, 'jsconfig.json'), ['compilerOptions', 'exclude'], [moduleSettings.settings.wixSettings.compilerOptions, moduleSettings.settings.wixSettings.exclude]);
|
79
|
+
// await editJson(join(moduleSettings.targetFolder, 'typedoc.json'), ['name'], [path.basename(moduleSettings.targetFolder)]);
|
80
|
+
|
81
|
+
// await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules, moduleSettings.force);
|
82
|
+
|
83
|
+
// moduleSettings.settings.initialized = true;
|
84
|
+
|
85
|
+
// const eslintrcPath = join(moduleSettings.targetFolder, '.eslintrc.json');
|
86
|
+
// if(existsSync(eslintrcPath)) {
|
87
|
+
// console.log((`🐕 ${blue.underline.bold("=> Deleting .eslintrc.json")}`));
|
88
|
+
// await fs.rm(join(eslintrcPath), { recursive: false }).catch(e => {
|
89
|
+
// console.log((`💩 ${red.underline.bold("=> Could not delete .eslintrc.json ")} ${red.bold("=> ", e)}`));
|
90
|
+
// });
|
91
|
+
// }
|
92
|
+
|
93
|
+
// console.log((`🐕 ${blue.underline.bold("=> Writing settings to lucy.json")}`));
|
94
|
+
// await fs.writeFile(join(moduleSettings.targetFolder, 'lucy.json'), JSON.stringify(moduleSettings.settings, null, 2));
|
95
|
+
|
96
|
+
// console.log(chalk.greenBright.underline('🐶 => Initialization done!'));
|
97
|
+
// }
|
98
|
+
|
99
|
+
// /**
|
100
|
+
// * Copy files from source to target
|
101
|
+
// * @param {string} source Source folder
|
102
|
+
// * @param {string} target Target folder
|
103
|
+
// * @returns {Promise<void>}
|
104
|
+
// */
|
105
|
+
// async function copyFolder(source: string, target: string): Promise<void> {
|
106
|
+
// if (!existsSync(target)){
|
107
|
+
// console.log((`💩 ${red.underline.bold("=> Target folder doesn't exist =>")} ${orange(target)}`));
|
108
|
+
// return;
|
109
|
+
// }
|
110
|
+
|
111
|
+
// try {
|
112
|
+
// const files = await fsPromises.readdir(source);
|
113
|
+
// for (const file of files){
|
114
|
+
// const sourcePath = join(source, file);
|
115
|
+
// const targetPath = join(target, file);
|
116
|
+
|
117
|
+
// if (file === 'lucy.json' && existsSync(targetPath)){
|
118
|
+
// continue;
|
119
|
+
// }
|
120
|
+
// const stats = await fsPromises.stat(sourcePath);
|
121
|
+
// if (stats.isDirectory()){
|
122
|
+
// if (!existsSync(file)){
|
123
|
+
// mkdirSync(file);
|
124
|
+
// }
|
125
|
+
// await fse.copySync(sourcePath, targetPath, { overwrite: true });
|
126
|
+
// } else {
|
127
|
+
// fse.copySync(sourcePath, targetPath, { overwrite: true });
|
128
|
+
// }
|
129
|
+
// }
|
130
|
+
// } catch (err){
|
131
|
+
// console.log((`💩 ${red.underline.bold("=> There was an error while copying files =>")} ${orange(err)}`));
|
132
|
+
// } finally {
|
133
|
+
// console.log("🐕" + blue.underline.bold(' => Copy files completed!'));
|
134
|
+
// }
|
135
|
+
// }
|
136
|
+
|
137
|
+
// /**
|
138
|
+
// * Edit Json files
|
139
|
+
// * @param {string} filePath File path
|
140
|
+
// * @param {string[]} keys Keys to edit
|
141
|
+
// * @param {string[]} values Values to edit
|
142
|
+
// * @returns {void}
|
143
|
+
// */
|
144
|
+
// async function editJson(filePath: string, keys: string[], values: string[] | Object[] ) {
|
145
|
+
// try {
|
146
|
+
// const data = await fs.readFile(filePath, 'utf8');
|
147
|
+
|
148
|
+
// let jsonData;
|
149
|
+
// try {
|
150
|
+
// jsonData = JSON.parse(data);
|
151
|
+
// } catch (parseError) {
|
152
|
+
// console.log((`💩 ${red.underline.bold("=> Error parsing JSON =>")} ${orange(parseError)}`));
|
153
|
+
// return;
|
154
|
+
// }
|
155
|
+
|
156
|
+
// for (const key of keys){
|
157
|
+
// const index = keys.indexOf(key);
|
158
|
+
// const value = values[index];
|
159
|
+
// jsonData[key] = value;
|
160
|
+
// }
|
130
161
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
162
|
+
// const updatedJsonData = JSON.stringify(jsonData, null, 2);
|
163
|
+
// await fs.writeFile(filePath, updatedJsonData, 'utf8');
|
164
|
+
// } catch (err) {
|
165
|
+
// console.log((`💩 ${red.underline.bold("=> Error editing JSON Data =>")} ${orange(err)}`));
|
166
|
+
// } finally {
|
167
|
+
// console.log("🐕" + blue.underline(` => Updated file ${orange(filePath)}`));
|
168
|
+
// }
|
169
|
+
// }
|
170
|
+
|
171
|
+
// async function stringReplace(filePath: string, keys: string[], values: string[]) {
|
172
|
+
// try {
|
173
|
+
// let modifiedContent: string = '';
|
174
|
+
// const data = await fs.readFile(filePath, 'utf8');
|
175
|
+
|
176
|
+
// for (const key of keys){
|
177
|
+
// const index = keys.indexOf(key);
|
178
|
+
// const value = values[index];
|
179
|
+
// const regex = new RegExp(`${key}`, 'g');
|
180
|
+
// modifiedContent = data.replace(regex, `${value}`);
|
181
|
+
// }
|
182
|
+
|
183
|
+
// await fs.writeFile(filePath, modifiedContent, 'utf8');
|
184
|
+
// } catch (err) {
|
185
|
+
// console.log((`💩 ${red.underline.bold("=> During string replace =>")} ${orange(err)}`));
|
186
|
+
// } finally {
|
187
|
+
// console.log(blue.underline(`🐕 => Updated file ${orange(filePath)}`));
|
188
|
+
// }
|
189
|
+
// }
|
190
|
+
const yarn = Command.make("yarn").pipe(
|
191
|
+
Command.stdout("inherit"), // Stream stdout to process.stdout
|
192
|
+
Command.exitCode // Get the exit code
|
193
|
+
)
|
194
|
+
|
195
|
+
const init_expo = () => {
|
196
|
+
return Effect.gen(function*() {
|
197
|
+
const config = yield* Config;
|
198
|
+
const terminal = yield* Terminal.Terminal;
|
199
|
+
const fs = yield* FileSystem.FileSystem;
|
200
|
+
const path = yield* Path.Path;
|
201
|
+
|
202
|
+
const yarn = Command.make(
|
203
|
+
"yarn",
|
204
|
+
"add",
|
205
|
+
"nativewind",
|
206
|
+
"react-native-reanimated@~3.17.4",
|
207
|
+
"react-native-safe-area-context@5.4.0",
|
208
|
+
"@wix/sdk",
|
209
|
+
"@wix/data",
|
210
|
+
"expo-standard-web-crypto"
|
211
|
+
).pipe(
|
212
|
+
Command.stdout("inherit"), // Stream stdout to process.stdout
|
213
|
+
Command.exitCode // Get the exit code
|
214
|
+
)
|
215
|
+
|
216
|
+
const yarnDev = Command.make(
|
217
|
+
"yarn",
|
218
|
+
"add",
|
219
|
+
"--dev",
|
220
|
+
"tailwindcss@^3.4.17",
|
221
|
+
"prettier-plugin-tailwindcss@^0.5.11",
|
222
|
+
"@styled/typescript-styled-plugin",
|
223
|
+
"typescript-eslint-language-service",
|
224
|
+
"eslint-config-prettier",
|
225
|
+
"eslint-plugin-jsdoc",
|
226
|
+
"eslint-plugin-named-import-spacing",
|
227
|
+
"eslint-plugin-only-warn",
|
228
|
+
"eslint-plugin-react",
|
229
|
+
"eslint-plugin-react-hooks",
|
230
|
+
"eslint-plugin-simple-import-sort",
|
231
|
+
"@next/eslint-plugin-next",
|
232
|
+
"@styled/typescript-styled-plugin",
|
233
|
+
"@stylelint/postcss-css-in-js",
|
234
|
+
"@typescript-eslint/parser",
|
235
|
+
"typescript-eslint",
|
236
|
+
"typescript-eslint-language-service",
|
237
|
+
"@total-typescript/ts-reset",
|
238
|
+
).pipe(
|
239
|
+
Command.stdout("inherit"), // Stream stdout to process.stdout
|
240
|
+
Command.exitCode // Get the exit code
|
241
|
+
)
|
242
|
+
|
243
|
+
const npx = Command.make(
|
244
|
+
"npx",
|
245
|
+
"expo",
|
246
|
+
"install",
|
247
|
+
"tailwindcss-animate",
|
248
|
+
"class-variance-authority",
|
249
|
+
"clsx",
|
250
|
+
"tailwind-merge",
|
251
|
+
"expo-crypto",
|
252
|
+
).pipe(
|
253
|
+
Command.stdout("inherit"), // Stream stdout to process.stdout
|
254
|
+
Command.exitCode // Get the exit code
|
255
|
+
)
|
256
|
+
|
257
|
+
const projectName = config.config.cwd.split('/').pop() || 'expo-project';
|
258
|
+
|
259
|
+
const appJsonRaw = yield* fs.readFile("app.json").pipe(Effect.catchAll((error) => {
|
260
|
+
return Effect.succeed('{}');
|
261
|
+
}))
|
262
|
+
const lucyJsonRaw = yield* fs.readFile("lucy.json").pipe(Effect.catchAll((error) => {
|
263
|
+
return Effect.succeed('{}');
|
264
|
+
}))
|
265
|
+
const appJSON = Schema.decodeUnknownSync(JsonSchema)(appJsonRaw.toString()) as any;
|
266
|
+
const lucyJSON = Schema.decodeUnknownSync(JsonSchema)(lucyJsonRaw.toString()) as any;
|
267
|
+
|
268
|
+
const expoAppReady = appJSON.expo ? true : false;
|
269
|
+
const lucyInitialized = lucyJSON.initialized ? true : false;
|
270
|
+
const gitPresent = yield* fs.exists(config.config.cwd + '/.git')
|
271
|
+
|
272
|
+
const files = yield* fs.readDirectory(config.config.cwd);
|
273
|
+
const nonGitFiles = files.filter(file => file !== '.git');
|
274
|
+
|
275
|
+
if(!gitPresent) return yield* Effect.logError("No git repository found. Please initialize a git repository before running this command.");
|
276
|
+
if(nonGitFiles.length > 0) return yield* Effect.logError("The current directory is not empty. Please run this command in an empty directory.");
|
277
|
+
|
278
|
+
if(!expoAppReady) {
|
279
|
+
const initExpo = Command.make("npx", "create-expo-app@latest", projectName).pipe(
|
280
|
+
Command.stdout("inherit"), // Stream stdout to process.stdout
|
281
|
+
Command.exitCode // Get the exit code
|
282
|
+
)
|
283
|
+
yield* initExpo
|
284
|
+
|
285
|
+
const projectPath = path.join(config.config.cwd, projectName)
|
286
|
+
|
287
|
+
const projectFiles = yield* fs.readDirectory(projectPath)
|
288
|
+
yield* Effect.forEach(
|
289
|
+
projectFiles.filter(file => file !== '.git'),
|
290
|
+
(file) => fs.copy(path.join(projectPath, file), path.join(config.config.cwd, file), { overwrite: true }),
|
291
|
+
{ discard: true }
|
292
|
+
)
|
293
|
+
yield* fs.remove(projectPath, { recursive: true })
|
294
|
+
}
|
295
|
+
if(lucyInitialized) return yield* Effect.logError("Lucy is already initialized in this project. Please run this command in an empty directory.");
|
296
|
+
|
297
|
+
console.log("Expo project initialized with app.json:", projectName);
|
298
|
+
|
299
|
+
let res = yield* npx
|
300
|
+
res = yield* yarn
|
301
|
+
res = yield* yarnDev
|
302
|
+
|
303
|
+
if (res !== 0) {
|
304
|
+
return yield* Effect.logError("Failed to install Expo dependencies. Please check the error message above.");
|
305
|
+
}
|
306
|
+
|
307
|
+
const baseFiles = yield* fs.readDirectory(config.config.filesFolder + '/expo')
|
308
|
+
yield* Effect.forEach(
|
309
|
+
baseFiles,
|
310
|
+
(file) => fs.copy(path.join(config.config.filesFolder, 'expo', file), path.join(config.config.cwd, file), { overwrite: true })
|
311
|
+
)
|
312
|
+
|
313
|
+
const newScripts = {
|
314
|
+
"dev": "expo start",
|
315
|
+
"start": "expo start",
|
316
|
+
"android": "expo start --android",
|
317
|
+
"ios": "expo start --ios",
|
318
|
+
"web": "expo start --web",
|
319
|
+
"format": "prettier --write \"./*.json\" \"**/*.{ts,tsx,md,json,jsonc,json5}\"",
|
320
|
+
"build:ios": "eas build --platform ios --local --profile preview",
|
321
|
+
"build:android": "eas build --platform android --local --profile preview",
|
322
|
+
"build:web": "eas build --platform web --local --profile preview",
|
323
|
+
}
|
324
|
+
|
325
|
+
const packageJsonPath = path.join(config.config.cwd, "package.json")
|
326
|
+
const packageJsonRaw = yield* fs.readFile(packageJsonPath)
|
327
|
+
const packageJson = Schema.decodeUnknownSync(JsonSchema)(packageJsonRaw.toString()) as any;
|
328
|
+
|
329
|
+
packageJson.scripts = {
|
330
|
+
...packageJson.scripts,
|
331
|
+
...newScripts
|
332
|
+
};
|
333
|
+
yield* fs.writeFileString(path.join(config.config.cwd, 'package.json'), JSON.stringify(packageJson, null, 2));
|
334
|
+
yield* fs.remove(path.join(config.config.cwd, "package-lock.json"), { force: true })
|
335
|
+
|
336
|
+
})
|
163
337
|
}
|
164
338
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
await fs.writeFile(filePath, modifiedContent, 'utf8');
|
178
|
-
} catch (err) {
|
179
|
-
console.log((`💩 ${red.underline.bold("=> During string replace =>")} ${orange(err)}`));
|
180
|
-
} finally {
|
181
|
-
console.log(blue.underline(`🐕 => Updated file ${orange(filePath)}`));
|
182
|
-
}
|
339
|
+
export const init = () => {
|
340
|
+
return Effect.gen(function* (_) {
|
341
|
+
const config = yield* Config;
|
342
|
+
if(config.config.action.type === undefined) {
|
343
|
+
return yield* Effect.fail("No Params Provided");
|
344
|
+
}
|
345
|
+
|
346
|
+
if(config.config.action.type === 'expo') {
|
347
|
+
return yield* init_expo();
|
348
|
+
}
|
349
|
+
|
350
|
+
})
|
183
351
|
}
|
package/src/policy.ts
ADDED
package/src/prepare.ts
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
import chalk from 'chalk';
|
2
|
-
import { ModuleSettings, ProjectSettings, blue, green, orange, red, magenta } from './index.js';
|
3
|
-
import { gitInit, installPackages } from './helpers.js';
|
1
|
+
// import chalk from 'chalk';
|
2
|
+
// import { ModuleSettings, ProjectSettings, blue, green, orange, red, magenta } from './index.js';
|
3
|
+
// import { gitInit, installPackages } from './helpers.js';
|
4
4
|
|
5
|
-
/**
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
export async function prepare(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
|
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
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
// if(!projectSettings.lucySettings?.initialized) {
|
14
|
+
// console.log((`💩 ${red.underline.bold("=> This project is not initialized =>")} ${orange(moduleSettings.targetFolder)}`));
|
15
|
+
// console.log("🐕" + magenta.underline(' => Use init to initialize'));
|
16
|
+
// return;
|
17
|
+
// }
|
18
18
|
|
19
|
-
|
19
|
+
// await installPackages(projectSettings.lucySettings.wixPackages, projectSettings.lucySettings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
|
20
20
|
|
21
|
-
|
21
|
+
// await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules, moduleSettings.force);
|
22
22
|
|
23
|
-
|
24
|
-
}
|
23
|
+
// console.log(chalk.greenBright.underline('🐶 => Prepare done!'));
|
24
|
+
// }
|
package/src/runtime.ts
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
import { Layer, Logger, LogLevel, ManagedRuntime} from "effect"
|
3
|
+
import { ConfigLayer } from "./config.js";
|
4
|
+
import { get_args } from "./args.js";
|
5
|
+
import { NodeInspectState, ServiceInspectState, node_inspect_init, service_inspect_init } from "./states.js";
|
6
|
+
import { NodeContext } from "@effect/platform-node"
|
7
|
+
export const build_runtime = (args: Awaited<ReturnType<typeof get_args>>) => {
|
8
|
+
const log_level = process.env.DEBUG === "true" ? LogLevel.Debug : LogLevel.Info;
|
9
|
+
return ManagedRuntime.make(Layer.mergeAll(
|
10
|
+
ConfigLayer(args),
|
11
|
+
Layer.effect(ServiceInspectState, service_inspect_init),
|
12
|
+
Layer.effect(NodeInspectState, node_inspect_init),
|
13
|
+
NodeContext.layer,
|
14
|
+
Logger.minimumLogLevel(log_level),
|
15
|
+
Logger.replace(Logger.defaultLogger, Logger.prettyLogger({
|
16
|
+
colors: true,
|
17
|
+
mode: 'tty'
|
18
|
+
}))
|
19
|
+
))
|
20
|
+
};
|
File without changes
|
package/src/states.ts
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Context, Ref } from "effect"
|
2
|
+
|
3
|
+
|
4
|
+
export class ServiceInspectState extends Context.Tag("ServiceInspectState")<
|
5
|
+
ServiceInspectState,
|
6
|
+
Ref.Ref<String>
|
7
|
+
>() {}
|
8
|
+
export const service_inspect_init = Ref.make([] as any)
|
9
|
+
|
10
|
+
export class NodeInspectState extends Context.Tag("NodeInspectState")<
|
11
|
+
NodeInspectState,
|
12
|
+
Ref.Ref<String>
|
13
|
+
>() {}
|
14
|
+
export const node_inspect_init = Ref.make([] as any)
|
15
|
+
|