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.
- package/package.json +7 -2
- package/.cursorignore +0 -4
- package/.eslintrc.cjs +0 -96
- package/.github/funding.yml +0 -2
- package/.nvmrc +0 -1
- package/.stylelintrc.js +0 -8
- package/.wix/debug.log +0 -10
- package/.yarnrc.yml +0 -2
- package/files/sync-data/data/test.csv +0 -17
- package/files/sync-data/files/lucy.jpg +0 -0
- package/files/sync-data/schema/test.json +0 -11
- package/lucy.jpg +0 -0
- package/mitarbeiter-login.html +0 -188
- package/old/Gulpfile.d.ts +0 -34
- package/old/Gulpfile.js +0 -116
- package/old/Gulpfile.js.map +0 -1
- package/old/Gulpfile.ts +0 -231
- package/old/gulp/backend.d.ts +0 -3
- package/old/gulp/backend.js +0 -92
- package/old/gulp/backend.js.map +0 -1
- package/old/gulp/backend.ts +0 -109
- package/old/gulp/checks.d.ts +0 -3
- package/old/gulp/checks.js +0 -205
- package/old/gulp/checks.js.map +0 -1
- package/old/gulp/checks.ts +0 -228
- package/old/gulp/clean.d.ts +0 -3
- package/old/gulp/clean.js +0 -29
- package/old/gulp/clean.js.map +0 -1
- package/old/gulp/clean.ts +0 -33
- package/old/gulp/copy.d.ts +0 -2
- package/old/gulp/copy.js +0 -34
- package/old/gulp/copy.js.map +0 -1
- package/old/gulp/copy.ts +0 -42
- package/old/gulp/helpers.d.ts +0 -2
- package/old/gulp/helpers.js +0 -25
- package/old/gulp/helpers.js.map +0 -1
- package/old/gulp/helpers.ts +0 -26
- package/old/gulp/pages.d.ts +0 -2
- package/old/gulp/pages.js +0 -37
- package/old/gulp/pages.js.map +0 -1
- package/old/gulp/pages.ts +0 -40
- package/old/gulp/pipeline.d.ts +0 -1
- package/old/gulp/pipeline.js +0 -29
- package/old/gulp/pipeline.js.map +0 -1
- package/old/gulp/pipeline.ts +0 -31
- package/old/gulp/public.d.ts +0 -2
- package/old/gulp/public.js +0 -50
- package/old/gulp/public.js.map +0 -1
- package/old/gulp/public.ts +0 -59
- package/old/gulp/styles.d.ts +0 -2
- package/old/gulp/styles.js +0 -40
- package/old/gulp/styles.js.map +0 -1
- package/old/gulp/styles.ts +0 -46
- package/old/gulp/templates.d.ts +0 -2
- package/old/gulp/templates.js +0 -33
- package/old/gulp/templates.js.map +0 -1
- package/old/gulp/templates.ts +0 -39
- package/old/gulp/types.d.ts +0 -4
- package/old/gulp/types.js +0 -289
- package/old/gulp/types.js.map +0 -1
- package/old/gulp/types.ts +0 -311
- package/old/gulp/watchers.d.ts +0 -9
- package/old/gulp/watchers.js +0 -59
- package/old/gulp/watchers.js.map +0 -1
- package/old/gulp/watchers.ts +0 -105
- package/old/helpers.d.ts +0 -32
- package/old/helpers.js +0 -267
- package/old/helpers.js.map +0 -1
- package/old/helpers.ts +0 -307
- package/old/index.d.ts +0 -59
- package/old/index.js +0 -288
- package/old/index.js.map +0 -1
- package/old/index.ts +0 -379
- package/old/init.d.ts +0 -8
- package/old/init.js +0 -165
- package/old/init.js.map +0 -1
- package/old/init.ts +0 -183
- package/old/models.d.ts +0 -37
- package/old/models.js +0 -2
- package/old/models.js.map +0 -1
- package/old/models.ts +0 -35
- package/old/prepare.d.ts +0 -8
- package/old/prepare.js +0 -20
- package/old/prepare.js.map +0 -1
- package/old/prepare.ts +0 -24
- package/old/schemas/index.d.ts +0 -0
- package/old/schemas/index.js +0 -2
- package/old/schemas/index.js.map +0 -1
- package/old/schemas/index.ts +0 -0
- package/old/schemas/types.d.ts +0 -0
- package/old/schemas/types.js +0 -2
- package/old/schemas/types.js.map +0 -1
- package/old/schemas/types.ts +0 -0
- package/old/settings.json +0 -67
- package/old/sync.d.ts +0 -2
- package/old/sync.js +0 -88
- package/old/sync.js.map +0 -1
- package/old/sync.ts +0 -97
- package/old/types.d.ts +0 -8
- package/pnpm-workspace.yaml +0 -6
- package/settings/backend-settings.json +0 -19
- package/settings/master-settings.json +0 -20
- package/settings/page-settings.json +0 -21
- package/settings/public-settings.json +0 -22
- package/src/args.ts +0 -121
- package/src/commands/checks.ts +0 -51
- package/src/commands/cleanup.ts +0 -11
- package/src/commands/copy.ts +0 -29
- package/src/commands/edit.ts +0 -81
- package/src/commands/exec.ts +0 -73
- package/src/commands/git.ts +0 -152
- package/src/commands/home.ts +0 -20
- package/src/commands/install.ts +0 -269
- package/src/commands/read.ts +0 -45
- package/src/commands/write.ts +0 -45
- package/src/commands.ts +0 -21
- package/src/config.ts +0 -142
- package/src/error.ts +0 -3
- package/src/helpers.ts +0 -93
- package/src/index.ts +0 -113
- package/src/init/blocks.ts +0 -85
- package/src/init/cargo.ts +0 -25
- package/src/init/expo.ts +0 -69
- package/src/init/gitModules.ts +0 -15
- package/src/init/index.ts +0 -86
- package/src/init/monorepo.ts +0 -72
- package/src/init/prepareVelo.ts +0 -19
- package/src/init/tauri.ts +0 -42
- package/src/init/templates.ts +0 -98
- package/src/init/velo.ts +0 -66
- package/src/policy.ts +0 -6
- package/src/prepare.ts +0 -24
- package/src/runtime.ts +0 -21
- package/src/schemas/gulp.ts +0 -31
- package/src/schemas/index.ts +0 -17
- package/src/schemas/lucy.ts +0 -43
- package/src/schemas/tsconfig.ts +0 -35
- package/src/schemas/types.ts +0 -40
- package/src/settings.json +0 -67
- package/src/states.ts +0 -15
- package/src/tasks/Gulpfile.ts +0 -207
- package/src/tasks/gulp/backend.ts +0 -113
- package/src/tasks/gulp/checks.ts +0 -219
- package/src/tasks/gulp/clean.ts +0 -38
- package/src/tasks/gulp/copy.ts +0 -38
- package/src/tasks/gulp/helpers.ts +0 -18
- package/src/tasks/gulp/pages.ts +0 -43
- package/src/tasks/gulp/pipeline.ts +0 -31
- package/src/tasks/gulp/public.ts +0 -61
- package/src/tasks/gulp/styles.ts +0 -47
- package/src/tasks/gulp/templates.ts +0 -53
- package/src/tasks/gulp/types.ts +0 -310
- package/src/tasks/gulp/watchers.ts +0 -97
- package/src/tasks/index.ts +0 -24
- package/src/tasks/syncSettings.ts +0 -21
- package/src/types.d.ts +0 -8
- package/src/utils/index.ts +0 -0
- package/src/utils/logger.ts +0 -40
- package/src/wix-sdk/check.ts +0 -24
- package/src/wix-sdk/client.ts +0 -18
- package/src/wix-sdk/index.ts +0 -17
- package/src/wix-sdk/init.ts +0 -54
- package/src/wix-sdk/run.ts +0 -56
- package/src/wix-sync/client.ts +0 -6
- package/src/wix-sync/export.ts +0 -19
- package/src/wix-sync/import.ts +0 -27
- package/src/wix-sync/index.ts +0 -36
- package/src/wix-sync/init.ts +0 -77
- package/src/wix-sync/is-alive.ts +0 -25
- package/src/wix-sync/migrate.ts +0 -23
- package/src/wix-sync/sync.ts +0 -27
- package/tsconfig.json +0 -34
package/src/index.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Effect, pipe} from "effect";
|
|
2
|
-
import { build_runtime } from "./runtime.js";
|
|
3
|
-
import { get_args } from "./args.js";
|
|
4
|
-
import 'dotenv/config'
|
|
5
|
-
import { Config } from "./config.js";
|
|
6
|
-
import { init } from "./init/index.js";
|
|
7
|
-
import { logger } from "./utils/logger.js";
|
|
8
|
-
import { open } from "./commands/exec.js";
|
|
9
|
-
import { tasks } from "./tasks/index.js";
|
|
10
|
-
import { cleanupWatchers, killAllProcesses } from "./helpers.js";
|
|
11
|
-
import { wix_sync } from "./wix-sync/index.js";
|
|
12
|
-
import { wix_sdk } from "./wix-sdk/index.js";
|
|
13
|
-
|
|
14
|
-
let exitReason: 'SIGINT' | 'SIGTERM' | 'none' = 'none'
|
|
15
|
-
let needsCleanup = false;
|
|
16
|
-
|
|
17
|
-
export function setNeedsCleanup(value: boolean) {
|
|
18
|
-
needsCleanup = value;
|
|
19
|
-
}
|
|
20
|
-
process.on('exit', (code) => {
|
|
21
|
-
if(!needsCleanup) return;
|
|
22
|
-
if(exitReason === 'none') {
|
|
23
|
-
killAllProcesses('@wix/cli/bin/wix.cjs');
|
|
24
|
-
killAllProcesses('wix:dev');
|
|
25
|
-
killAllProcesses('wix dev');
|
|
26
|
-
cleanupWatchers();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
logger.info(`🛑 Process exited with code: ${code}`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
process.on('SIGINT', () => {
|
|
33
|
-
exitReason = "SIGINT";
|
|
34
|
-
|
|
35
|
-
logger.info(`🐕 Received Ctrl+C (SIGINT), cleaning up...`);
|
|
36
|
-
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
|
37
|
-
killAllProcesses('wix:dev');
|
|
38
|
-
killAllProcesses('wix dev');
|
|
39
|
-
cleanupWatchers();
|
|
40
|
-
process.exit(); // Exit explicitly after handling
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
process.on('SIGTERM', () => {
|
|
44
|
-
exitReason = "SIGTERM";
|
|
45
|
-
|
|
46
|
-
logger.info(`🛑 Received termination signal (SIGTERM), cleaning up...`);
|
|
47
|
-
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
|
48
|
-
killAllProcesses('wix:dev');
|
|
49
|
-
killAllProcesses('wix dev');
|
|
50
|
-
cleanupWatchers();
|
|
51
|
-
process.exit(); // Exit explicitly after handling
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const lucyCLI = pipe(
|
|
55
|
-
Effect.gen(function* (_) {
|
|
56
|
-
const config = yield* Config;
|
|
57
|
-
if (config.config.action.action === 'init') {
|
|
58
|
-
return yield* init;
|
|
59
|
-
}
|
|
60
|
-
if (config.config.action.action === 'open') {
|
|
61
|
-
return yield* open;
|
|
62
|
-
}
|
|
63
|
-
if (config.config.action.action === 'task') {
|
|
64
|
-
return yield* tasks;
|
|
65
|
-
}
|
|
66
|
-
if (config.config.action.action === 'wix-sync') {
|
|
67
|
-
return yield* wix_sync;
|
|
68
|
-
}
|
|
69
|
-
if (config.config.action.action === 'wix-sdk') {
|
|
70
|
-
return yield* wix_sdk;
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
73
|
-
).pipe(
|
|
74
|
-
Effect.catchTags({
|
|
75
|
-
BadArgument: (error) => {
|
|
76
|
-
logger.error(JSON.stringify(error, null, 2));
|
|
77
|
-
return Effect.fail(new Error(error.message));
|
|
78
|
-
},
|
|
79
|
-
ParseError: (error) => {
|
|
80
|
-
logger.error("Failed to parse:", JSON.stringify(error, null, 2));
|
|
81
|
-
return Effect.fail(new Error("Failed to parse: " + error.message));
|
|
82
|
-
},
|
|
83
|
-
SystemError: (error) => {
|
|
84
|
-
logger.error("System error:", JSON.stringify(error, null, 2));
|
|
85
|
-
return Effect.fail(new Error("System error: " + error.message));
|
|
86
|
-
},
|
|
87
|
-
AppError: (error) => {
|
|
88
|
-
logger.error("Application error:", JSON.stringify(error, null, 2));
|
|
89
|
-
return Effect.fail(new Error("Application error: " + error.message));
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
async function main() {
|
|
95
|
-
const args = await get_args();
|
|
96
|
-
const runtime= build_runtime(args);
|
|
97
|
-
// The runtime will handle logging failures. This will catch unhandled defects.
|
|
98
|
-
const program = Effect.orDieWith(
|
|
99
|
-
lucyCLI,
|
|
100
|
-
(error) => new Error(`The application failed to run: ${error}`
|
|
101
|
-
)
|
|
102
|
-
)
|
|
103
|
-
await runtime.runPromise(program)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
main().then(() => {
|
|
107
|
-
process.exit(0);
|
|
108
|
-
}).catch((error) => {
|
|
109
|
-
if (error instanceof Error) {
|
|
110
|
-
logger.error(error.message);
|
|
111
|
-
}
|
|
112
|
-
process.exit(1);
|
|
113
|
-
});
|
package/src/init/blocks.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect/index"
|
|
2
|
-
import { Config, lucyJsonName } from "../config.js";
|
|
3
|
-
import { Command, FileSystem, Path } from "@effect/platform"
|
|
4
|
-
import { JsonSchema } from "../schemas/index.js";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { mergeAdditions, mergeLucySettings2PackageJson, setInitialized } from "../commands/edit.js";
|
|
7
|
-
import { writeLucySettings, writePackageJson } from "../commands/write.js";
|
|
8
|
-
import { copyTemplateFiles } from "../commands/copy.js";
|
|
9
|
-
import { readPackageJson } from "../commands/read.js";
|
|
10
|
-
import { execCommand, openEditor } from "../commands/exec.js";
|
|
11
|
-
import { approveBuilds, installPackages } from "../commands/install.js";
|
|
12
|
-
import { AppError } from "../error.js";
|
|
13
|
-
import { cleanup } from "../commands/cleanup.js";
|
|
14
|
-
import { checkForDirty } from "../commands/checks.js";
|
|
15
|
-
|
|
16
|
-
export const init_blocks = () => {
|
|
17
|
-
return Effect.gen(function*() {
|
|
18
|
-
const config = yield* Config;
|
|
19
|
-
const fs = yield* FileSystem.FileSystem;
|
|
20
|
-
const path = yield* Path.Path;
|
|
21
|
-
|
|
22
|
-
logger.action("Initializing Blocks project...");
|
|
23
|
-
|
|
24
|
-
const configJsonRaw = yield* fs.readFile("wix.config.json").pipe(Effect.catchAll((error) => {
|
|
25
|
-
return Effect.succeed('{}');
|
|
26
|
-
}))
|
|
27
|
-
const configJson = Schema.decodeUnknownSync(JsonSchema)(configJsonRaw.toString()) as any;
|
|
28
|
-
const blocksAppReady = configJson.appId ? true : false;
|
|
29
|
-
|
|
30
|
-
yield* checkForDirty();
|
|
31
|
-
|
|
32
|
-
if(!blocksAppReady) {
|
|
33
|
-
const initBlocks = Command.make("npm", "create", "@wix/app@latest", config.config.projectName).pipe(
|
|
34
|
-
Command.stdin("inherit"),
|
|
35
|
-
Command.stdout("inherit"),
|
|
36
|
-
Command.stderr("inherit"),
|
|
37
|
-
Command.exitCode
|
|
38
|
-
)
|
|
39
|
-
if((yield* initBlocks) !== 0) {
|
|
40
|
-
yield* Effect.fail(new AppError({ message: "Failed to initialize Blocks project. Please check the error message above.", cause: new Error("Failed to initialize Blocks project") }));
|
|
41
|
-
}
|
|
42
|
-
const files = yield * fs.readDirectory(config.config.cwd, { recursive: false });
|
|
43
|
-
|
|
44
|
-
const allExcludes = ['.git', lucyJsonName];
|
|
45
|
-
const filteredFiles = files.filter(file => !allExcludes.includes(file));
|
|
46
|
-
|
|
47
|
-
const t = yield* fs.stat(filteredFiles[0]);
|
|
48
|
-
t.type === 'Directory'
|
|
49
|
-
|
|
50
|
-
const directories = yield* Effect.filter(
|
|
51
|
-
filteredFiles,
|
|
52
|
-
(file) => Effect.gen(function*() {
|
|
53
|
-
const fullPath = path.join(config.config.cwd, file);
|
|
54
|
-
const stat = yield* fs.stat(fullPath);
|
|
55
|
-
return stat.type === "Directory";
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
const tempPath = directories[0];
|
|
59
|
-
|
|
60
|
-
const projectFiles = yield* fs.readDirectory(directories[0])
|
|
61
|
-
yield* Effect.forEach(
|
|
62
|
-
projectFiles.filter(file => file !== '.git'),
|
|
63
|
-
(file) => fs.copy(path.join(tempPath, file), path.join(config.config.cwd, file), { overwrite: true }),
|
|
64
|
-
{ discard: true }
|
|
65
|
-
)
|
|
66
|
-
yield* fs.remove(tempPath, { recursive: true })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
yield* readPackageJson;
|
|
70
|
-
yield* mergeLucySettings2PackageJson;
|
|
71
|
-
yield* mergeAdditions;
|
|
72
|
-
yield* writeLucySettings;
|
|
73
|
-
yield* writePackageJson;
|
|
74
|
-
yield* copyTemplateFiles;
|
|
75
|
-
yield* execCommand;
|
|
76
|
-
yield* installPackages();
|
|
77
|
-
yield* approveBuilds;
|
|
78
|
-
yield* cleanup;
|
|
79
|
-
yield* setInitialized;
|
|
80
|
-
|
|
81
|
-
logger.success("Blocks project initialized successfully!");
|
|
82
|
-
|
|
83
|
-
yield* openEditor;
|
|
84
|
-
})
|
|
85
|
-
}
|
package/src/init/cargo.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect/index"
|
|
2
|
-
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { writeLucySettings } from "../commands/write.js";
|
|
4
|
-
import { copyTemplateFiles } from "../commands/copy.js";
|
|
5
|
-
import { gitInit } from "../commands/git.js";
|
|
6
|
-
import { checkForDirty } from "../commands/checks.js";
|
|
7
|
-
import { setInitialized } from "../commands/edit.js";
|
|
8
|
-
import { openEditor } from "../commands/exec.js";
|
|
9
|
-
|
|
10
|
-
export const init_cargo = () => {
|
|
11
|
-
return Effect.gen(function*() {
|
|
12
|
-
logger.action("Initializing Cargo project...");
|
|
13
|
-
|
|
14
|
-
yield* checkForDirty();
|
|
15
|
-
|
|
16
|
-
yield* copyTemplateFiles;
|
|
17
|
-
yield* writeLucySettings;
|
|
18
|
-
yield* gitInit();
|
|
19
|
-
yield* setInitialized;
|
|
20
|
-
|
|
21
|
-
logger.success("Cargo project initialized successfully!");
|
|
22
|
-
|
|
23
|
-
yield* openEditor;
|
|
24
|
-
})
|
|
25
|
-
}
|
package/src/init/expo.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect/index"
|
|
2
|
-
import { Config } from "../config.js";
|
|
3
|
-
import { Command, FileSystem, Path } from "@effect/platform"
|
|
4
|
-
import { JsonSchema } from "../schemas/index.js";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { mergeAdditions, mergeLucySettings2PackageJson, setInitialized } from "../commands/edit.js";
|
|
7
|
-
import { writeLucySettings, writePackageJson } from "../commands/write.js";
|
|
8
|
-
import { copyTemplateFiles } from "../commands/copy.js";
|
|
9
|
-
import { readPackageJson } from "../commands/read.js";
|
|
10
|
-
import { execCommand, openEditor } from "../commands/exec.js";
|
|
11
|
-
import { approveBuilds, installPackages } from "../commands/install.js";
|
|
12
|
-
import { AppError } from "../error.js";
|
|
13
|
-
import { cleanup } from "../commands/cleanup.js";
|
|
14
|
-
import { checkForDirty } from "../commands/checks.js";
|
|
15
|
-
|
|
16
|
-
export const init_expo = () => {
|
|
17
|
-
return Effect.gen(function*() {
|
|
18
|
-
const config = yield* Config;
|
|
19
|
-
const fs = yield* FileSystem.FileSystem;
|
|
20
|
-
const path = yield* Path.Path;
|
|
21
|
-
|
|
22
|
-
logger.action("Initializing Expo project...");
|
|
23
|
-
|
|
24
|
-
const appJsonRaw = yield* fs.readFile("app.json").pipe(Effect.catchAll((error) => {
|
|
25
|
-
return Effect.succeed('{}');
|
|
26
|
-
}))
|
|
27
|
-
const appJSON = Schema.decodeUnknownSync(JsonSchema)(appJsonRaw.toString()) as any;
|
|
28
|
-
const expoAppReady = appJSON.expo ? true : false;
|
|
29
|
-
|
|
30
|
-
yield* checkForDirty();
|
|
31
|
-
|
|
32
|
-
if(!expoAppReady) {
|
|
33
|
-
const initExpo = Command.make("npx", "create-expo-app@latest", config.config.projectName, "--template", "blank-typescript", "--no-install").pipe(
|
|
34
|
-
Command.stdout("inherit"),
|
|
35
|
-
Command.stderr("inherit"),
|
|
36
|
-
Command.exitCode
|
|
37
|
-
)
|
|
38
|
-
if((yield* initExpo) !== 0) {
|
|
39
|
-
yield* Effect.fail(new AppError({ message: "Failed to initialize Expo project. Please check the error message above.", cause: new Error("Failed to initialize Expo project") }));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const tempPath = path.join(config.config.cwd, config.config.projectName)
|
|
43
|
-
|
|
44
|
-
const projectFiles = yield* fs.readDirectory(tempPath)
|
|
45
|
-
yield* Effect.forEach(
|
|
46
|
-
projectFiles.filter(file => file !== '.git'),
|
|
47
|
-
(file) => fs.copy(path.join(tempPath, file), path.join(config.config.cwd, file), { overwrite: true }),
|
|
48
|
-
{ discard: true }
|
|
49
|
-
)
|
|
50
|
-
yield* fs.remove(tempPath, { recursive: true })
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
yield* readPackageJson;
|
|
54
|
-
yield* mergeLucySettings2PackageJson;
|
|
55
|
-
yield* mergeAdditions;
|
|
56
|
-
yield* writeLucySettings;
|
|
57
|
-
yield* writePackageJson;
|
|
58
|
-
yield* copyTemplateFiles;
|
|
59
|
-
yield* execCommand;
|
|
60
|
-
yield* installPackages();
|
|
61
|
-
yield* approveBuilds;
|
|
62
|
-
yield* cleanup;
|
|
63
|
-
yield* setInitialized;
|
|
64
|
-
|
|
65
|
-
logger.success("Expo project initialized successfully!");
|
|
66
|
-
|
|
67
|
-
yield* openEditor;
|
|
68
|
-
})
|
|
69
|
-
}
|
package/src/init/gitModules.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect/index"
|
|
2
|
-
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { setInitialized } from "../commands/edit.js";
|
|
4
|
-
import { gitInit } from "../commands/git.js";
|
|
5
|
-
|
|
6
|
-
export const init_submodules = () => {
|
|
7
|
-
return Effect.gen(function*() {
|
|
8
|
-
logger.action("Initializing Git submodules project...");
|
|
9
|
-
|
|
10
|
-
yield* gitInit(true);
|
|
11
|
-
yield* setInitialized;
|
|
12
|
-
|
|
13
|
-
logger.success("GIT initialized successfully!");
|
|
14
|
-
})
|
|
15
|
-
}
|
package/src/init/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect/index"
|
|
2
|
-
import { Config } from "../config.js";
|
|
3
|
-
import { init_expo } from "./expo.js";
|
|
4
|
-
import { selectTemplate } from "./templates.js";
|
|
5
|
-
import Enquirer from "enquirer";
|
|
6
|
-
import { AppError } from "../error.js";
|
|
7
|
-
import { createLucyHome } from "../commands/home.js";
|
|
8
|
-
import { readLucyJsonFromTemplate } from "../commands/read.js";
|
|
9
|
-
import { init_monorepo } from "./monorepo.js";
|
|
10
|
-
import { init_cargo } from "./cargo.js";
|
|
11
|
-
import { init_blocks } from "./blocks.js";
|
|
12
|
-
import { init_velo } from "./velo.js";
|
|
13
|
-
import { init_submodules } from "./gitModules.js";
|
|
14
|
-
import { init_tauri } from "./tauri.js";
|
|
15
|
-
import { pkgManagers } from "../schemas/lucy.js";
|
|
16
|
-
|
|
17
|
-
export const init = Effect.gen(function* (_) {
|
|
18
|
-
const config = yield* Config;
|
|
19
|
-
if(config.config.action.initType === undefined) {
|
|
20
|
-
return yield* Effect.fail(new AppError({ message: "No init type provided", cause: new Error("No init type provided") }));
|
|
21
|
-
}
|
|
22
|
-
yield* createLucyHome();
|
|
23
|
-
const projectName = config.config.cwd.split('/').pop() || 'expo-project';
|
|
24
|
-
const templateQuestion = new Enquirer();
|
|
25
|
-
const choice = yield* Effect.tryPromise({
|
|
26
|
-
try: () => templateQuestion.prompt({
|
|
27
|
-
type: 'input',
|
|
28
|
-
name: 'projectName',
|
|
29
|
-
message: 'Enter a project name',
|
|
30
|
-
initial: projectName,
|
|
31
|
-
validate: (value: string) => value.trim() !== '' ? true : 'Project name cannot be empty'
|
|
32
|
-
}),
|
|
33
|
-
catch: (e) => {
|
|
34
|
-
return new AppError({ cause: e, message: 'Error selecting template' });
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
const selectedName = yield* Schema.decodeUnknown(Schema.Struct({ projectName: Schema.String }))(choice)
|
|
38
|
-
config.config.projectName = selectedName.projectName.trim();
|
|
39
|
-
yield* selectTemplate();
|
|
40
|
-
yield* readLucyJsonFromTemplate;
|
|
41
|
-
|
|
42
|
-
function supportedPackageManagers() {
|
|
43
|
-
if(config.config.action.initType === 'velo') {
|
|
44
|
-
return pkgManagers.filter(pkgMgr => pkgMgr !== 'pnpm')
|
|
45
|
-
}
|
|
46
|
-
return pkgManagers
|
|
47
|
-
}
|
|
48
|
-
const pkgMgrQuestion = new Enquirer();
|
|
49
|
-
const pkgMgr = yield* Effect.tryPromise({
|
|
50
|
-
try: () => pkgMgrQuestion.prompt({
|
|
51
|
-
type: 'select',
|
|
52
|
-
name: 'packageManager',
|
|
53
|
-
message: 'Select a package manager',
|
|
54
|
-
choices: [...supportedPackageManagers()],
|
|
55
|
-
}),
|
|
56
|
-
catch: (e) => {
|
|
57
|
-
return new AppError({ cause: e, message: 'Error selecting package manager' });
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
const selectedPkgMgr = yield* Schema.decodeUnknown(Schema.Struct({ packageManager: Schema.Literal(...pkgManagers) }))(pkgMgr)
|
|
61
|
-
config.config.lucySettings.packageManager = selectedPkgMgr.packageManager;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if(config.config.action.initType === 'expo') {
|
|
65
|
-
return yield* init_expo();
|
|
66
|
-
}
|
|
67
|
-
if(config.config.action.initType === 'monorepo') {
|
|
68
|
-
return yield* init_monorepo();
|
|
69
|
-
}
|
|
70
|
-
if(config.config.action.initType === 'cargo') {
|
|
71
|
-
return yield* init_cargo();
|
|
72
|
-
}
|
|
73
|
-
if(config.config.action.initType === 'blocks') {
|
|
74
|
-
return yield* init_blocks();
|
|
75
|
-
}
|
|
76
|
-
if(config.config.action.initType === 'tauri') {
|
|
77
|
-
return yield* init_tauri();
|
|
78
|
-
}
|
|
79
|
-
if(config.config.action.initType === 'velo') {
|
|
80
|
-
return yield* init_velo();
|
|
81
|
-
}
|
|
82
|
-
if(config.config.action.initType === 'submodules') {
|
|
83
|
-
return yield* init_submodules();
|
|
84
|
-
}
|
|
85
|
-
yield* Effect.fail(new AppError({ message: `Unsupported init type: ${config.config.action.initType}`, cause: new Error(`Unsupported init type: ${config.config.action.initType}`) }));
|
|
86
|
-
})
|
package/src/init/monorepo.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect/index"
|
|
2
|
-
import { Config } from "../config.js";
|
|
3
|
-
import { Command, FileSystem, Path } from "@effect/platform"
|
|
4
|
-
import { logger } from "../utils/logger.js";
|
|
5
|
-
import { mergeAdditions, mergeLucySettings2PackageJson, setInitialized, setProjectName, stringReplace } from "../commands/edit.js";
|
|
6
|
-
import { writeLucySettings, writePackageJson } from "../commands/write.js";
|
|
7
|
-
import { copyTemplateFiles } from "../commands/copy.js";
|
|
8
|
-
import { readPackageJson } from "../commands/read.js";
|
|
9
|
-
import { approveBuilds, installPackages, runInstall } from "../commands/install.js";
|
|
10
|
-
import { cleanup } from "../commands/cleanup.js";
|
|
11
|
-
import { gitInit } from "../commands/git.js";
|
|
12
|
-
import { checkForDirty } from "../commands/checks.js";
|
|
13
|
-
import { openEditor } from "../commands/exec.js";
|
|
14
|
-
|
|
15
|
-
export const init_monorepo = () => {
|
|
16
|
-
return Effect.gen(function*() {
|
|
17
|
-
const config = yield* Config;
|
|
18
|
-
const path = yield* Path.Path;
|
|
19
|
-
const fs = yield* FileSystem.FileSystem;
|
|
20
|
-
|
|
21
|
-
logger.action("Initializing monorepo...");
|
|
22
|
-
|
|
23
|
-
yield* checkForDirty();
|
|
24
|
-
|
|
25
|
-
const createMonoRepo = Command.make(
|
|
26
|
-
"npx",
|
|
27
|
-
"-y",
|
|
28
|
-
"create-nx-workspace",
|
|
29
|
-
config.config.projectName,
|
|
30
|
-
`--appName=${config.config.projectName}`,
|
|
31
|
-
`--pm=${config.config.lucySettings.packageManager}`,
|
|
32
|
-
"--preset=ts",
|
|
33
|
-
"--g=true",
|
|
34
|
-
"--e2eTestRunner=cypress",
|
|
35
|
-
"--formatter=prettier"
|
|
36
|
-
).pipe(
|
|
37
|
-
Command.stdout("inherit"), // Stream stdout to process.stdout
|
|
38
|
-
Command.stderr("inherit"), // Stream stderr to process.stderr
|
|
39
|
-
Command.exitCode // Get the exit code
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
yield* createMonoRepo;
|
|
43
|
-
|
|
44
|
-
const tempPath = path.join(config.config.cwd, config.config.projectName)
|
|
45
|
-
const projectFiles = yield* fs.readDirectory(tempPath)
|
|
46
|
-
yield* Effect.forEach(
|
|
47
|
-
projectFiles.filter(file => file !== '.git'),
|
|
48
|
-
(file) => fs.copy(path.join(tempPath, file), path.join(config.config.cwd, file), { overwrite: true }),
|
|
49
|
-
{ discard: true }
|
|
50
|
-
)
|
|
51
|
-
yield* fs.remove(tempPath, { recursive: true })
|
|
52
|
-
|
|
53
|
-
yield* copyTemplateFiles;
|
|
54
|
-
yield* stringReplace(path.join(config.config.cwd, 'currents.config.ts'), ['__ProjectName__'], [config.config.projectName]);
|
|
55
|
-
yield* readPackageJson;
|
|
56
|
-
yield* setProjectName;
|
|
57
|
-
yield* mergeLucySettings2PackageJson;
|
|
58
|
-
yield* mergeAdditions;
|
|
59
|
-
yield* writeLucySettings;
|
|
60
|
-
yield* writePackageJson;
|
|
61
|
-
yield* gitInit();
|
|
62
|
-
yield* runInstall;
|
|
63
|
-
yield* installPackages(true);
|
|
64
|
-
yield* approveBuilds;
|
|
65
|
-
yield* cleanup;
|
|
66
|
-
yield* setInitialized;
|
|
67
|
-
|
|
68
|
-
logger.success("Monorepo initialized successfully!");
|
|
69
|
-
|
|
70
|
-
yield* openEditor;
|
|
71
|
-
})
|
|
72
|
-
}
|
package/src/init/prepareVelo.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect/index';
|
|
2
|
-
import { logger } from '../utils/logger.js';
|
|
3
|
-
import { checkForVelo } from '../commands/checks.js';
|
|
4
|
-
import { gitInit } from '../commands/git.js';
|
|
5
|
-
import { installVeloPackages, runInstall } from '../commands/install.js';
|
|
6
|
-
import { setInitialized } from '../commands/edit.js';
|
|
7
|
-
|
|
8
|
-
export const prepareVelo = Effect.gen(function*() {
|
|
9
|
-
logger.action("Initializing Tauri project...");
|
|
10
|
-
yield* checkForVelo();
|
|
11
|
-
|
|
12
|
-
yield* gitInit(true);
|
|
13
|
-
yield* installVeloPackages
|
|
14
|
-
yield* runInstall
|
|
15
|
-
yield* setInitialized;
|
|
16
|
-
|
|
17
|
-
logger.success("Velo Prepared initialized successfully!");
|
|
18
|
-
|
|
19
|
-
})
|
package/src/init/tauri.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect/index"
|
|
2
|
-
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { writeLucySettings } from "../commands/write.js";
|
|
4
|
-
import { copyTemplateFiles } from "../commands/copy.js";
|
|
5
|
-
import { gitInit } from "../commands/git.js";
|
|
6
|
-
import { checkForDirty } from "../commands/checks.js";
|
|
7
|
-
import { setInitialized } from "../commands/edit.js";
|
|
8
|
-
import { Config } from "../config.js";
|
|
9
|
-
import { Command, FileSystem, Path } from "@effect/platform"
|
|
10
|
-
import { AppError } from "../error.js";
|
|
11
|
-
import { approveBuilds, installPackages } from "../commands/install.js";
|
|
12
|
-
import { openEditor } from "../commands/exec.js";
|
|
13
|
-
|
|
14
|
-
export const init_tauri = () => {
|
|
15
|
-
return Effect.gen(function*() {
|
|
16
|
-
const config = yield* Config;
|
|
17
|
-
logger.action("Initializing Tauri project...");
|
|
18
|
-
|
|
19
|
-
yield* checkForDirty();
|
|
20
|
-
|
|
21
|
-
const initTauri = Command.make("yarn", "create", "tauri-app", config.config.projectName).pipe(
|
|
22
|
-
Command.stdin("inherit"),
|
|
23
|
-
Command.stdout("inherit"),
|
|
24
|
-
Command.stderr("inherit"),
|
|
25
|
-
Command.runInShell(true),
|
|
26
|
-
Command.exitCode
|
|
27
|
-
)
|
|
28
|
-
if((yield* initTauri) !== 0) {
|
|
29
|
-
yield* Effect.fail(new AppError({ message: "Failed to initialize Tauri project. Please check the error message above.", cause: new Error("Failed to initialize Tauri project") }));
|
|
30
|
-
}
|
|
31
|
-
yield* copyTemplateFiles;
|
|
32
|
-
yield* installPackages();
|
|
33
|
-
yield* approveBuilds;
|
|
34
|
-
yield* writeLucySettings;
|
|
35
|
-
yield* gitInit();
|
|
36
|
-
yield* setInitialized;
|
|
37
|
-
|
|
38
|
-
logger.success("Tauri project initialized successfully!");
|
|
39
|
-
|
|
40
|
-
yield* openEditor;
|
|
41
|
-
})
|
|
42
|
-
}
|
package/src/init/templates.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect/index";
|
|
2
|
-
import { Config, lucyJsonName, lucyJsonPath } from "../config.js";
|
|
3
|
-
import { orange, red, green, logger } from "../utils/logger.js";
|
|
4
|
-
import { FileSystem } from "@effect/platform"
|
|
5
|
-
import path, { join } from 'path';
|
|
6
|
-
import fsp from 'fs/promises';
|
|
7
|
-
import Enquirer from 'enquirer';
|
|
8
|
-
import { AppError } from "../error.js";
|
|
9
|
-
import { lucySettings } from "../schemas/lucy.js";
|
|
10
|
-
import { JsonSchema } from "../schemas/index.js";
|
|
11
|
-
|
|
12
|
-
export const selectTemplate = () => {
|
|
13
|
-
return Effect.gen(function*() {
|
|
14
|
-
const config = yield* Config
|
|
15
|
-
const fs = yield* FileSystem.FileSystem;
|
|
16
|
-
const templatesPath = join(config.config.lucyHome, 'templates');
|
|
17
|
-
const files = yield* Effect.tryPromise({
|
|
18
|
-
try: () => fsp.readdir(templatesPath, { withFileTypes: true }),
|
|
19
|
-
catch: (e) => {
|
|
20
|
-
console.log((`💩 ${red.underline.bold("=> Templates folder not found at =>")} ${orange(templatesPath)}`));
|
|
21
|
-
return new AppError({ cause: e, message: 'Templates folder not found' });
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const templateChoices: string[] = [];
|
|
26
|
-
for (const dirent of files.filter((file) => !file.name.startsWith('.') && file.isDirectory())) {
|
|
27
|
-
if (dirent.isDirectory()) {
|
|
28
|
-
const lucyRaw = yield* fs.readFileString(join(templatesPath, dirent.name, lucyJsonName));
|
|
29
|
-
const lucySettingsJSON = yield* Schema.decodeUnknown(JsonSchema)(lucyRaw);
|
|
30
|
-
const lucySetting = yield* Schema.decodeUnknown(lucySettings)(lucySettingsJSON)
|
|
31
|
-
if (lucySetting.type === config.config.action.initType) {
|
|
32
|
-
templateChoices.push(dirent.name);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (templateChoices.length === 0) {
|
|
38
|
-
console.log((`💩 ${red.underline.bold("=> No templates found in =>")} ${orange(templatesPath)}`));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const templateQuestion = new Enquirer();
|
|
43
|
-
const choice = yield* Effect.tryPromise({
|
|
44
|
-
try: () => templateQuestion.prompt({
|
|
45
|
-
type: 'select',
|
|
46
|
-
name: 'template',
|
|
47
|
-
message: 'Select a project template',
|
|
48
|
-
choices: templateChoices
|
|
49
|
-
}),
|
|
50
|
-
catch: (e) => {
|
|
51
|
-
return new AppError({ cause: e, message: 'Error selecting template' });
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const selectedTemplate = yield* Schema.decodeUnknown(Schema.Struct({ template: Schema.String }))(choice)
|
|
56
|
-
const templateDir = join(templatesPath, selectedTemplate.template );
|
|
57
|
-
const templateFilesDir = join(templateDir, 'files');
|
|
58
|
-
config.config.templateDir = templateDir;
|
|
59
|
-
config.config.templateFiles = templateFilesDir;
|
|
60
|
-
|
|
61
|
-
const templateSettingsPath = join(templateDir, lucyJsonName);
|
|
62
|
-
|
|
63
|
-
if (!(yield* fs.exists(templateSettingsPath))) {
|
|
64
|
-
logger.warning((`💩 ${red.underline.bold(`Template is missing ${lucyJsonName} at =>`)} ${orange(templateSettingsPath)}`));
|
|
65
|
-
yield* Effect.fail(new AppError({ message: `Template is missing ${lucyJsonName}`, cause: templateSettingsPath }));
|
|
66
|
-
}
|
|
67
|
-
const lucySettingsRaw = yield* fs.readFileString(templateSettingsPath);
|
|
68
|
-
const newLucySettings = yield* Schema.decodeUnknown(lucySettings)(JSON.parse(lucySettingsRaw));
|
|
69
|
-
if( newLucySettings.type !== config.config.action.initType) return yield* Effect.fail(new AppError({
|
|
70
|
-
message: `Template type ${newLucySettings.type} does not match action type ${config.config.action.initType}`,
|
|
71
|
-
cause: newLucySettings.type
|
|
72
|
-
}));
|
|
73
|
-
if(config.config.lucySettings.initialized) {
|
|
74
|
-
const overwriteQuestion = new Enquirer();
|
|
75
|
-
|
|
76
|
-
const overwrite = yield* Effect.tryPromise({
|
|
77
|
-
try: () => overwriteQuestion.prompt({
|
|
78
|
-
type: 'confirm',
|
|
79
|
-
name: 'overwrite',
|
|
80
|
-
message: `Overwrite existing ${lucyJsonName} settings?`,
|
|
81
|
-
}),
|
|
82
|
-
catch: (e) => {
|
|
83
|
-
return new AppError({
|
|
84
|
-
cause: e,
|
|
85
|
-
message: "Error overwriting settings",
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
const choice = yield* Schema.decodeUnknown(Schema.Struct({ overwrite: Schema.Boolean }))(overwrite);
|
|
90
|
-
if (choice.overwrite) {
|
|
91
|
-
config.config.lucySettings = newLucySettings;
|
|
92
|
-
} else {
|
|
93
|
-
logger.info(`Existing ${lucyJsonName} settings will be used.`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
logger.success(`Selected template: ${green(selectedTemplate.template)}`);
|
|
97
|
-
});
|
|
98
|
-
}
|