lucy-cli 1.2.5 → 2.0.0-alpha.10
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 +269 -158
- 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/.nvmrc +1 -0
- package/files/expo/.prettierignore +23 -0
- package/files/expo/.prettierrc.js +16 -0
- package/files/expo/.yarnrc +1 -0
- package/files/expo/.yarnrc.yml +3 -0
- package/files/expo/README.md +45 -0
- package/files/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/files/expo/assets/images/adaptive-icon.png +0 -0
- package/files/expo/assets/images/favicon.png +0 -0
- package/files/expo/assets/images/icon.png +0 -0
- package/files/expo/assets/images/splash-icon.png +0 -0
- package/files/expo/babel.config.js +10 -0
- package/files/expo/constants/theme.ts +18 -0
- package/files/expo/eas.json +32 -0
- package/files/expo/eslint.config.mjs +181 -0
- package/files/expo/global.css +47 -0
- package/files/expo/hooks/useColorScheme.ts +17 -0
- package/files/expo/index.ts +11 -0
- package/files/expo/lib/data.ts +48 -0
- package/files/expo/lib/utils/index.ts +11 -0
- package/files/expo/lib/utils/polyfills.ts +29 -0
- package/files/expo/lib/wix/client.ts +12 -0
- package/files/expo/lib/wix/error.ts +3 -0
- package/files/expo/lib/wix/index.ts +2 -0
- package/files/expo/lucy.json +8 -0
- package/files/expo/metro.config.js +57 -0
- package/files/expo/nativewind-env.d.ts +1 -0
- package/files/expo/scripts/reset-project.ts +116 -0
- package/files/expo/tailwind.config.js +63 -0
- package/files/expo/tsconfig.json +46 -0
- package/files/expo/types/reset.d.ts +1 -0
- package/files/velo/typescript/public/scss/app.scss +0 -0
- package/files/velo/typescript/styles/.gitkeep +0 -0
- package/files/velo/typescript/styles/global.scss +0 -0
- package/package.json +16 -12
- 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 +386 -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__ → expo/components}/.gitkeep +0 -0
- /package/files/{typescript/pages → expo/components/ui}/.gitkeep +0 -0
- /package/files/{typescript/backend/data.ts → 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/public → velo/typescript/__mocks__}/.gitkeep +0 -0
- /package/files/{typescript/backend/events.ts → velo/typescript/backend/data.ts} +0 -0
- /package/files/{typescript/public/scss/app.scss → 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/styles → velo/typescript/pages}/.gitkeep +0 -0
- /package/files/{typescript/styles/global.scss → velo/typescript/public/.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
@@ -0,0 +1,116 @@
|
|
1
|
+
#!/usr/bin/env ts-node
|
2
|
+
/* eslint-disable no-console */
|
3
|
+
|
4
|
+
/**
|
5
|
+
* This script is used to reset the project to a blank state.
|
6
|
+
* It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file.
|
7
|
+
* You can remove the `reset-project` script from package.json and safely delete this file after running it.
|
8
|
+
*/
|
9
|
+
|
10
|
+
import fs from 'fs';
|
11
|
+
import path from 'path';
|
12
|
+
import { createInterface } from 'readline/promises';
|
13
|
+
|
14
|
+
const root = process.cwd();
|
15
|
+
const oldDirs = ['app', 'components', 'hooks', 'constants', 'scripts'];
|
16
|
+
const exampleDir = 'app-example';
|
17
|
+
const newAppDir = 'app';
|
18
|
+
const exampleDirPath = path.join(root, exampleDir);
|
19
|
+
|
20
|
+
const indexContent = `import { Text, View } from "react-native";
|
21
|
+
|
22
|
+
export default function Index() {
|
23
|
+
return (
|
24
|
+
<View
|
25
|
+
style={{
|
26
|
+
flex: 1,
|
27
|
+
justifyContent: "center",
|
28
|
+
alignItems: "center",
|
29
|
+
}}
|
30
|
+
>
|
31
|
+
<Text>Edit app/index.tsx to edit this screen.</Text>
|
32
|
+
</View>
|
33
|
+
);
|
34
|
+
}
|
35
|
+
`;
|
36
|
+
|
37
|
+
const layoutContent = `import { Stack } from "expo-router";
|
38
|
+
|
39
|
+
export default function RootLayout() {
|
40
|
+
return <Stack />;
|
41
|
+
}
|
42
|
+
`;
|
43
|
+
|
44
|
+
const moveDirectories = async (userInput: string) => {
|
45
|
+
if (userInput === 'y') {
|
46
|
+
// Create the app-example directory
|
47
|
+
await fs.promises.mkdir(exampleDirPath, { recursive: true });
|
48
|
+
console.log(`📁 /${exampleDir} directory created.`);
|
49
|
+
}
|
50
|
+
|
51
|
+
// Move old directories to new app-example directory or delete them
|
52
|
+
for (const dir of oldDirs) {
|
53
|
+
const oldDirPath = path.join(root, dir);
|
54
|
+
if (fs.existsSync(oldDirPath)) {
|
55
|
+
if (userInput === 'y') {
|
56
|
+
const newDirPath = path.join(root, exampleDir, dir);
|
57
|
+
await fs.promises.rename(oldDirPath, newDirPath);
|
58
|
+
console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`);
|
59
|
+
} else {
|
60
|
+
await fs.promises.rm(oldDirPath, { recursive: true, force: true });
|
61
|
+
console.log(`❌ /${dir} deleted.`);
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
console.log(`➡️ /${dir} does not exist, skipping.`);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
// Create new /app directory
|
69
|
+
const newAppDirPath = path.join(root, newAppDir);
|
70
|
+
await fs.promises.mkdir(newAppDirPath, { recursive: true });
|
71
|
+
console.log('\n📁 New /app directory created.');
|
72
|
+
|
73
|
+
// Create index.tsx
|
74
|
+
const indexPath = path.join(newAppDirPath, 'index.tsx');
|
75
|
+
await fs.promises.writeFile(indexPath, indexContent);
|
76
|
+
console.log('📄 app/index.tsx created.');
|
77
|
+
|
78
|
+
// Create _layout.tsx
|
79
|
+
const layoutPath = path.join(newAppDirPath, '_layout.tsx');
|
80
|
+
await fs.promises.writeFile(layoutPath, layoutContent);
|
81
|
+
console.log('📄 app/_layout.tsx created.');
|
82
|
+
|
83
|
+
console.log('\n✅ Project reset complete. Next steps:');
|
84
|
+
console.log(
|
85
|
+
`1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${
|
86
|
+
userInput === 'y'
|
87
|
+
? `\n3. Delete the /${exampleDir} directory when you're done referencing it.`
|
88
|
+
: ''
|
89
|
+
}`
|
90
|
+
);
|
91
|
+
};
|
92
|
+
|
93
|
+
const main = async () => {
|
94
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
95
|
+
try {
|
96
|
+
const answer = await rl.question('Do you want to move existing files to /app-example instead of deleting them? (Y/n): ');
|
97
|
+
const userInput = answer.trim().toLowerCase() || 'y';
|
98
|
+
if (userInput === 'y' || userInput === 'n') {
|
99
|
+
await moveDirectories(userInput);
|
100
|
+
} else {
|
101
|
+
console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
|
102
|
+
process.exit(1);
|
103
|
+
}
|
104
|
+
} catch (error) {
|
105
|
+
if (error instanceof Error) {
|
106
|
+
console.error(`❌ Error during script execution: ${error.message}`);
|
107
|
+
} else {
|
108
|
+
console.error('❌ An unexpected error occurred:', error);
|
109
|
+
}
|
110
|
+
process.exit(1);
|
111
|
+
} finally {
|
112
|
+
rl.close();
|
113
|
+
}
|
114
|
+
};
|
115
|
+
|
116
|
+
void main();
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { hairlineWidth } from 'nativewind/theme';
|
2
|
+
|
3
|
+
export const darkMode = 'class';
|
4
|
+
export const content = ['./app/**/*.{ts,tsx}', './components/**/*.{ts,tsx}'];
|
5
|
+
export const presets = [require('nativewind/preset')];
|
6
|
+
|
7
|
+
export const theme = {
|
8
|
+
extend: {
|
9
|
+
colors: {
|
10
|
+
border: 'hsl(var(--border))',
|
11
|
+
input: 'hsl(var(--input))',
|
12
|
+
ring: 'hsl(var(--ring))',
|
13
|
+
background: 'hsl(var(--background))',
|
14
|
+
foreground: 'hsl(var(--foreground))',
|
15
|
+
primary: {
|
16
|
+
DEFAULT: 'hsl(var(--primary))',
|
17
|
+
foreground: 'hsl(var(--primary-foreground))',
|
18
|
+
},
|
19
|
+
secondary: {
|
20
|
+
DEFAULT: 'hsl(var(--secondary))',
|
21
|
+
foreground: 'hsl(var(--secondary-foreground))',
|
22
|
+
},
|
23
|
+
destructive: {
|
24
|
+
DEFAULT: 'hsl(var(--destructive))',
|
25
|
+
foreground: 'hsl(var(--destructive-foreground))',
|
26
|
+
},
|
27
|
+
muted: {
|
28
|
+
DEFAULT: 'hsl(var(--muted))',
|
29
|
+
foreground: 'hsl(var(--muted-foreground))',
|
30
|
+
},
|
31
|
+
accent: {
|
32
|
+
DEFAULT: 'hsl(var(--accent))',
|
33
|
+
foreground: 'hsl(var(--accent-foreground))',
|
34
|
+
},
|
35
|
+
popover: {
|
36
|
+
DEFAULT: 'hsl(var(--popover))',
|
37
|
+
foreground: 'hsl(var(--popover-foreground))',
|
38
|
+
},
|
39
|
+
card: {
|
40
|
+
DEFAULT: 'hsl(var(--card))',
|
41
|
+
foreground: 'hsl(var(--card-foreground))',
|
42
|
+
},
|
43
|
+
},
|
44
|
+
borderWidth: {
|
45
|
+
hairline: hairlineWidth(),
|
46
|
+
},
|
47
|
+
keyframes: {
|
48
|
+
'accordion-down': {
|
49
|
+
from: { height: '0' },
|
50
|
+
to: { height: 'var(--radix-accordion-content-height)' },
|
51
|
+
},
|
52
|
+
'accordion-up': {
|
53
|
+
from: { height: 'var(--radix-accordion-content-height)' },
|
54
|
+
to: { height: '0' },
|
55
|
+
},
|
56
|
+
},
|
57
|
+
animation: {
|
58
|
+
'accordion-down': 'accordion-down 0.2s ease-out',
|
59
|
+
'accordion-up': 'accordion-up 0.2s ease-out',
|
60
|
+
},
|
61
|
+
},
|
62
|
+
};
|
63
|
+
export const plugins = [require('tailwindcss-animate')];
|
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"extends": "expo/tsconfig.base",
|
3
|
+
"compilerOptions": {
|
4
|
+
"strict": true,
|
5
|
+
"allowSyntheticDefaultImports": true,
|
6
|
+
"skipLibCheck": true,
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
8
|
+
"alwaysStrict": false,
|
9
|
+
"noImplicitAny": true,
|
10
|
+
"noImplicitReturns": true,
|
11
|
+
"noImplicitThis": true,
|
12
|
+
"strictNullChecks": true,
|
13
|
+
"exactOptionalPropertyTypes": true,
|
14
|
+
"strictBindCallApply": true,
|
15
|
+
"strictFunctionTypes": true,
|
16
|
+
"strictPropertyInitialization": true,
|
17
|
+
// --- Advanced ---
|
18
|
+
"preserveConstEnums": true,
|
19
|
+
"plugins": [
|
20
|
+
{
|
21
|
+
"name": "@styled/typescript-styled-plugin"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "typescript-eslint-language-service"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"paths": {
|
28
|
+
"@/*": [
|
29
|
+
"./*"
|
30
|
+
]
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"include": [
|
34
|
+
"**/*.ts",
|
35
|
+
"**/*.tsx",
|
36
|
+
".expo/types/**/*.ts",
|
37
|
+
"expo-env.d.ts",
|
38
|
+
"nativewind-env.d.ts",
|
39
|
+
"metro.config.js",
|
40
|
+
"eslint.config.mjs",
|
41
|
+
"tailwind.config.js",
|
42
|
+
"babel.config.js",
|
43
|
+
".prettierrc.js",
|
44
|
+
"expo-env.d.ts",
|
45
|
+
]
|
46
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import "@total-typescript/ts-reset";
|
File without changes
|
File without changes
|
File without changes
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"type": "module",
|
3
3
|
"name": "lucy-cli",
|
4
|
-
"version": "
|
4
|
+
"version": "2.0.0-alpha.10",
|
5
5
|
"description": "Lucy Framework for WIX Studio Editor",
|
6
6
|
"main": ".dist/index.js",
|
7
7
|
"scripts": {
|
@@ -32,15 +32,16 @@
|
|
32
32
|
"registry": "https://registry.npmjs.org"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
+
"@effect/platform": "^0.90.0",
|
36
|
+
"@effect/platform-node": "^0.94.0",
|
35
37
|
"@swc/core": "^1.9.3",
|
36
38
|
"@wix/cli": "^1.0.83",
|
37
39
|
"@wix/eslint-plugin-cli": "^1.0.1",
|
38
40
|
"chalk": "^5.3.0",
|
39
|
-
"
|
40
|
-
"cypress-cloud": "^1.9.3",
|
41
|
+
"effect": "^3.17.1",
|
41
42
|
"enquirer": "^2.4.1",
|
42
|
-
"glob": "
|
43
|
-
"gulp": "
|
43
|
+
"glob": "11.0.3",
|
44
|
+
"gulp": "5.0.1",
|
44
45
|
"gulp-clean": "^0.4.0",
|
45
46
|
"gulp-cli": "3.0.0",
|
46
47
|
"gulp-concat": "^2.6.1",
|
@@ -52,7 +53,7 @@
|
|
52
53
|
"gulp-json-editor": "2.6.0",
|
53
54
|
"gulp-plumber": "^1.2.1",
|
54
55
|
"gulp-rename": "^2.0.0",
|
55
|
-
"gulp-sass": "
|
56
|
+
"gulp-sass": "6.0.1",
|
56
57
|
"gulp-shell": "^0.8.0",
|
57
58
|
"gulp-string-replace": "^1.1.2",
|
58
59
|
"gulp-swc": "^2.2.0",
|
@@ -60,7 +61,7 @@
|
|
60
61
|
"gulp-typedoc": "^3.0.2",
|
61
62
|
"gulp-typescript": "5.0.1",
|
62
63
|
"gulp-wait": "^0.0.2",
|
63
|
-
"jest": "
|
64
|
+
"jest": "30.0.5",
|
64
65
|
"merge-stream": "^2.0.0",
|
65
66
|
"merge2": "^1.4.1",
|
66
67
|
"optimist": "^0.6.1",
|
@@ -71,11 +72,12 @@
|
|
71
72
|
"ts-node": "^10.9.1",
|
72
73
|
"typedoc": "0.26.11",
|
73
74
|
"typescript": "^5.6.3",
|
74
|
-
"velo-sync": "^0.0.9"
|
75
|
+
"velo-sync": "^0.0.9",
|
76
|
+
"yargs": "^18.0.0"
|
75
77
|
},
|
76
78
|
"devDependencies": {
|
77
79
|
"@types/fs-extra": "^11.0.4",
|
78
|
-
"@types/glob": "
|
80
|
+
"@types/glob": "9.0.0",
|
79
81
|
"@types/gulp": "^4.0.17",
|
80
82
|
"@types/gulp-concat": "^0.0.37",
|
81
83
|
"@types/gulp-insert": "^0.5.13",
|
@@ -84,20 +86,22 @@
|
|
84
86
|
"@types/gulp-rename": "^2.0.6",
|
85
87
|
"@types/gulp-sass": "^5.0.4",
|
86
88
|
"@types/gulp-tap": "^1.0.5",
|
87
|
-
"@types/jest": "
|
89
|
+
"@types/jest": "30.0.0",
|
88
90
|
"@types/merge-stream": "2.0.0",
|
89
91
|
"@types/merge2": "^1.4.4",
|
90
92
|
"@types/optimist": "^0.0.33",
|
93
|
+
"@types/yargs": "^17.0.33",
|
91
94
|
"@typescript-eslint/eslint-plugin": "8.14.0",
|
92
95
|
"@typescript-eslint/parser": "8.14.0",
|
93
96
|
"@typescript-eslint/utils": "8.14.0",
|
94
97
|
"eslint": "9.14.0",
|
95
98
|
"eslint-plugin-import": "^2.27.5",
|
96
|
-
"eslint-plugin-jsdoc": "
|
99
|
+
"eslint-plugin-jsdoc": "51.4.1",
|
97
100
|
"eslint-plugin-named-import-spacing": "^1.0.3",
|
98
101
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
99
102
|
"i": "^0.3.7",
|
100
103
|
"npm": "^11.0.0",
|
101
104
|
"ts-node": "^10.9.1"
|
102
|
-
}
|
105
|
+
},
|
106
|
+
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
103
107
|
}
|
package/src/args.ts
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import yargs from "yargs";
|
2
|
+
import { hideBin } from "yargs/helpers";
|
3
|
+
|
4
|
+
// It's a good practice to define an interface for your arguments
|
5
|
+
// for type safety throughout your application.
|
6
|
+
export interface LucyArgs {
|
7
|
+
[x: string]: unknown;
|
8
|
+
// This will hold the command used, e.g., 'init'
|
9
|
+
_: (string | number)[];
|
10
|
+
$0: string;
|
11
|
+
// Arguments for the 'init' command
|
12
|
+
type?: 'velo' | 'expo' | 'blocks';
|
13
|
+
}
|
14
|
+
|
15
|
+
export async function get_args(): Promise<LucyArgs> {
|
16
|
+
const argv = await yargs(hideBin(process.argv))
|
17
|
+
.usage('Usage: $0 <command> [options]')
|
18
|
+
.command('init <type>', 'Initialize a new Lucy project', (yargs) => {
|
19
|
+
return yargs.positional('type', {
|
20
|
+
describe: 'The type of project to initialize',
|
21
|
+
choices: ['velo', 'expo', 'blocks'] as const,
|
22
|
+
demandOption: true, // Makes this positional argument required
|
23
|
+
});
|
24
|
+
})
|
25
|
+
// Enforce that a command must be provided (e.g., 'init')
|
26
|
+
.demandCommand(1, 'You need to provide a command. Use --help for a list of commands.')
|
27
|
+
.help()
|
28
|
+
.alias('h', 'help')
|
29
|
+
.strict()
|
30
|
+
.wrap(yargs().terminalWidth()) // Wrap help text to terminal width
|
31
|
+
.epilogue('For more information, visit https://github.com/your-repo/wix-lucy-cli') // Example of a relevant epilogue
|
32
|
+
.parseAsync();
|
33
|
+
|
34
|
+
// The cast is now safer with the defined interface.
|
35
|
+
return argv as LucyArgs;
|
36
|
+
}
|
package/src/commands.ts
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Effect, Schema } from "effect";
|
2
|
+
import { execSync, exec as execCallback } from "child_process";
|
3
|
+
import { AppError } from "./error.js";
|
4
|
+
import { parse_error } from "./helpers.js";
|
5
|
+
import { promisify } from 'util';
|
6
|
+
import { default_docker_retry } from "./policy.js";
|
7
|
+
|
8
|
+
const exec = promisify(execCallback);
|
9
|
+
|
10
|
+
export const init_expo = () => Effect.gen(function* () {
|
11
|
+
const format = "{{.ID}}\\t{{.Name}}\\t{{.Mode}}\\t{{.Replicas}}\\t{{.Image}}\\t{{.Ports}}";
|
12
|
+
const command = `docker service ls --format "${format}"`;
|
13
|
+
const res =yield* Effect.retry(Effect.tryPromise({
|
14
|
+
try: () => exec(command, { encoding: 'utf8'}),
|
15
|
+
catch: (error) => new AppError({cause: parse_error(error), message: "Error getting services"})
|
16
|
+
}), default_docker_retry);
|
17
|
+
if (res.stderr) {
|
18
|
+
yield* Effect.logError(`Command "${command}" produced stderr: ${res.stderr}`);
|
19
|
+
}
|
20
|
+
|
21
|
+
})
|
package/src/config.ts
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
import { Context, Layer } from "effect"
|
2
|
+
import { get_args } from "./args.js";
|
3
|
+
import { dirname, join } from "path";
|
4
|
+
import { fileURLToPath } from "url";
|
5
|
+
import { readFileSync, existsSync } from "fs";
|
6
|
+
type Action = 'init';
|
7
|
+
|
8
|
+
type Actions = {
|
9
|
+
action: Action;
|
10
|
+
type: 'velo' | 'expo' | 'blocks' | undefined;
|
11
|
+
}
|
12
|
+
export class Config extends Context.Tag("Config")<
|
13
|
+
Config,
|
14
|
+
{
|
15
|
+
readonly config: {
|
16
|
+
readonly action: Actions;
|
17
|
+
readonly cwd: string;
|
18
|
+
readonly packageRoot: string;
|
19
|
+
readonly filesFolder: string;
|
20
|
+
readonly packageJson: any;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
>() {}
|
24
|
+
|
25
|
+
// In an ES module, `__dirname` is not available by default.
|
26
|
+
// We can replicate it using `import.meta.url`.
|
27
|
+
const __filename = fileURLToPath(import.meta.url);
|
28
|
+
const __dirname = dirname(__filename);
|
29
|
+
|
30
|
+
// Assuming your compiled output is in a 'dist' folder at the project root,
|
31
|
+
// and your source `config.ts` is in `src`, the running `config.js` will be
|
32
|
+
// in something like `dist/src`. To get to the package root, we go up two levels.
|
33
|
+
const packageRoot = join(__dirname, "..");
|
34
|
+
|
35
|
+
export const ConfigLayer = (args: Awaited<ReturnType<typeof get_args>>) => {
|
36
|
+
let packageJson = '{}';
|
37
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
38
|
+
try {
|
39
|
+
if (existsSync(packageJsonPath)) {
|
40
|
+
const raw = readFileSync(packageJsonPath, 'utf-8');
|
41
|
+
packageJson = JSON.parse(raw);
|
42
|
+
}
|
43
|
+
} catch (error) {
|
44
|
+
console.error("Error reading package.json:", error);
|
45
|
+
}
|
46
|
+
return Layer.succeed(
|
47
|
+
Config,
|
48
|
+
Config.of({
|
49
|
+
config: {
|
50
|
+
action: {
|
51
|
+
type: args.type,
|
52
|
+
action: args._[0] as Action
|
53
|
+
},
|
54
|
+
cwd: process.cwd(),
|
55
|
+
packageRoot: packageRoot,
|
56
|
+
filesFolder: join(packageRoot, 'files'),
|
57
|
+
packageJson
|
58
|
+
}
|
59
|
+
})
|
60
|
+
);
|
61
|
+
}
|
package/src/error.ts
ADDED