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
package/dist/args.d.ts
ADDED
package/dist/args.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/commands.js
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Effect } from "effect";
|
2
|
+
import { 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
|
+
const exec = promisify(execCallback);
|
8
|
+
export const init_expo = () => Effect.gen(function* () {
|
9
|
+
const format = "{{.ID}}\\t{{.Name}}\\t{{.Mode}}\\t{{.Replicas}}\\t{{.Image}}\\t{{.Ports}}";
|
10
|
+
const command = `docker service ls --format "${format}"`;
|
11
|
+
const res = yield* Effect.retry(Effect.tryPromise({
|
12
|
+
try: () => exec(command, { encoding: 'utf8' }),
|
13
|
+
catch: (error) => new AppError({ cause: parse_error(error), message: "Error getting services" })
|
14
|
+
}), default_docker_retry);
|
15
|
+
if (res.stderr) {
|
16
|
+
yield* Effect.logError(`Command "${command}" produced stderr: ${res.stderr}`);
|
17
|
+
}
|
18
|
+
});
|
package/dist/config.d.ts
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Context, Layer } from "effect";
|
2
|
+
import { get_args } from "./args.js";
|
3
|
+
type Action = 'init';
|
4
|
+
type Actions = {
|
5
|
+
action: Action;
|
6
|
+
type: 'velo' | 'expo' | 'blocks' | undefined;
|
7
|
+
};
|
8
|
+
declare const Config_base: Context.TagClass<Config, "Config", {
|
9
|
+
readonly config: {
|
10
|
+
readonly action: Actions;
|
11
|
+
readonly cwd: string;
|
12
|
+
readonly packageRoot: string;
|
13
|
+
readonly filesFolder: string;
|
14
|
+
readonly packageJson: any;
|
15
|
+
};
|
16
|
+
}>;
|
17
|
+
export declare class Config extends Config_base {
|
18
|
+
}
|
19
|
+
export declare const ConfigLayer: (args: Awaited<ReturnType<typeof get_args>>) => Layer.Layer<Config, never, never>;
|
20
|
+
export {};
|
package/dist/config.js
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Context, Layer } from "effect";
|
2
|
+
import { dirname, join } from "path";
|
3
|
+
import { fileURLToPath } from "url";
|
4
|
+
import { readFileSync, existsSync } from "fs";
|
5
|
+
export class Config extends Context.Tag("Config")() {
|
6
|
+
}
|
7
|
+
// In an ES module, `__dirname` is not available by default.
|
8
|
+
// We can replicate it using `import.meta.url`.
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
10
|
+
const __dirname = dirname(__filename);
|
11
|
+
// Assuming your compiled output is in a 'dist' folder at the project root,
|
12
|
+
// and your source `config.ts` is in `src`, the running `config.js` will be
|
13
|
+
// in something like `dist/src`. To get to the package root, we go up two levels.
|
14
|
+
const packageRoot = join(__dirname, "..");
|
15
|
+
export const ConfigLayer = (args) => {
|
16
|
+
let packageJson = '{}';
|
17
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
18
|
+
try {
|
19
|
+
if (existsSync(packageJsonPath)) {
|
20
|
+
const raw = readFileSync(packageJsonPath, 'utf-8');
|
21
|
+
packageJson = JSON.parse(raw);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
catch (error) {
|
25
|
+
console.error("Error reading package.json:", error);
|
26
|
+
}
|
27
|
+
return Layer.succeed(Config, Config.of({
|
28
|
+
config: {
|
29
|
+
action: {
|
30
|
+
type: args.type,
|
31
|
+
action: args._[0]
|
32
|
+
},
|
33
|
+
cwd: process.cwd(),
|
34
|
+
packageRoot: packageRoot,
|
35
|
+
filesFolder: join(packageRoot, 'files'),
|
36
|
+
packageJson
|
37
|
+
}
|
38
|
+
}));
|
39
|
+
};
|
package/dist/error.d.ts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
declare const AppError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
2
|
+
readonly _tag: "AppError";
|
3
|
+
} & Readonly<A>;
|
4
|
+
export declare class AppError extends AppError_base<{
|
5
|
+
cause: Error;
|
6
|
+
message: string;
|
7
|
+
}> {
|
8
|
+
}
|
9
|
+
declare const ScaleError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
10
|
+
readonly _tag: "ScaleError";
|
11
|
+
} & Readonly<A>;
|
12
|
+
export declare class ScaleError extends ScaleError_base<{
|
13
|
+
cause: Error;
|
14
|
+
message: string;
|
15
|
+
}> {
|
16
|
+
}
|
17
|
+
export {};
|
package/dist/error.js
ADDED
package/dist/helpers.d.ts
CHANGED
@@ -1,32 +1 @@
|
|
1
|
-
|
2
|
-
export declare function installPackages(wixPackages: Record<string, string>, devPackages: Record<string, string>, cwd: string, locked: boolean): Promise<void>;
|
3
|
-
export declare function gitInit(cwd: string, modules: LucySettings['modules'] | undefined, force: boolean): Promise<void>;
|
4
|
-
export declare function runGulp(moduleSettings: ModuleSettings, projectSettings: ProjectSettings, task: string): Promise<void>;
|
5
|
-
/**
|
6
|
-
* Clean up and run a command before exiting the process.
|
7
|
-
*/
|
8
|
-
export declare function cleanupWatchers(): void;
|
9
|
-
/**
|
10
|
-
* Kill all processes matching a specific substring in their command, with a fallback for Windows.
|
11
|
-
* @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
|
12
|
-
*/
|
13
|
-
export declare function killAllProcesses(processPattern: string): void;
|
14
|
-
export interface VeloSyncConfig {
|
15
|
-
siteUrl: string;
|
16
|
-
secret: string;
|
17
|
-
}
|
18
|
-
export declare function saveConfig(config: VeloSyncConfig, file: string): Promise<void>;
|
19
|
-
export declare function readConfig(file: string): Promise<VeloSyncConfig>;
|
20
|
-
export declare function createTemplateFolder(moduleSettings: ModuleSettings): Promise<void>;
|
21
|
-
export type PackageJson = {
|
22
|
-
dependencies?: Record<string, string>;
|
23
|
-
devDependencies?: Record<string, string>;
|
24
|
-
[key: string]: any;
|
25
|
-
};
|
26
|
-
/**
|
27
|
-
* Updates a lucy.json file with dependencies from a package.json file.
|
28
|
-
* It replaces 'wixPackages' with 'dependencies' and 'devPackages' with 'devDependencies'.
|
29
|
-
* @param {string} packageJsonPath - Path to the package.json file.
|
30
|
-
* @param {string} lucyConfigPath - Path to the lucy.json file.
|
31
|
-
*/
|
32
|
-
export declare function updateLucyConfigFromPackageJson(packageJsonPath: string, lucyConfigPath: string): Promise<void>;
|
1
|
+
export declare function parse_error(error: unknown): Error;
|
package/dist/helpers.js
CHANGED
@@ -1,266 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
// https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
|
5
|
-
import path, { join } from 'path';
|
6
|
-
import { fileURLToPath } from 'url';
|
7
|
-
import os from 'os';
|
8
|
-
import fs, { mkdirSync } from 'fs';
|
9
|
-
import fse from 'fs-extra';
|
10
|
-
import { writeFile } from 'fs/promises';
|
11
|
-
import { blue, green, orange, red, yellow, magenta } from './index.js';
|
12
|
-
export async function installPackages(wixPackages, devPackages, cwd, locked) {
|
13
|
-
if (locked)
|
14
|
-
console.log("🐕" + blue.underline(` => Installing & version locked packages!`));
|
15
|
-
const wixPackageNames = Object.keys(wixPackages);
|
16
|
-
const wixPackageVersions = Object.values(wixPackages);
|
17
|
-
const wixPackageNamesAndVersions = wixPackageNames.map((name, index) => `${name}@${wixPackageVersions[index]}`);
|
18
|
-
const devPackageNames = Object.keys(devPackages);
|
19
|
-
const devPackageVersions = Object.values(devPackages);
|
20
|
-
const devPackageNamesAndVersions = devPackageNames.map((name, index) => `${name}@${devPackageVersions[index]}`);
|
21
|
-
let success = true;
|
22
|
-
// Dev packages are installed all at once with yarn.
|
23
|
-
if (devPackageNames.length > 0) {
|
24
|
-
console.log(`🐕 => Installing dev packages with yarn...`);
|
25
|
-
const packagesToInstall = locked ? devPackageNamesAndVersions.join(' ') : devPackageNames.join(' ');
|
26
|
-
const yarnAdd = `yarn add -D ${packagesToInstall}`;
|
27
|
-
const yarnRes = spawnSync(yarnAdd, { shell: true, stdio: 'inherit' });
|
28
|
-
if (yarnRes.error) {
|
29
|
-
success = false;
|
30
|
-
console.log((`💩 ${red.underline.bold("=> Failed to install dev packages =>")} ${orange(yarnRes.error.message)}`));
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
console.log("🐕" + blue.underline(` => Dev packages installed!`));
|
34
|
-
}
|
1
|
+
export function parse_error(error) {
|
2
|
+
if (error instanceof Error) {
|
3
|
+
return error;
|
35
4
|
}
|
36
|
-
|
37
|
-
|
38
|
-
console.log(`🐕 => Installing packages with yarn...`);
|
39
|
-
const packagesToInstall = locked ? wixPackageNamesAndVersions.join(' ') : wixPackageNames.join(' ');
|
40
|
-
const yarnAdd = `yarn add ${packagesToInstall}`;
|
41
|
-
const yarnRes = spawnSync(yarnAdd, { shell: true, stdio: 'inherit' });
|
42
|
-
if (yarnRes.error) {
|
43
|
-
success = false;
|
44
|
-
console.log((`💩 ${red.underline.bold("=> Failed to install packages =>")} ${orange(yarnRes.error.message)}`));
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
console.log("🐕" + blue.underline(` => Packages installed!`));
|
48
|
-
}
|
49
|
-
}
|
50
|
-
// Wix packages are installed one by one.
|
51
|
-
if (wixPackageNames.length > 0) {
|
52
|
-
wixPackageNames.forEach((name, index) => {
|
53
|
-
console.log(`🐕 => Installing wix package ${orange(name)}`);
|
54
|
-
const wixInstall = locked ? `wix install ${wixPackageNamesAndVersions[index]}` : `wix install ${name}`;
|
55
|
-
const wixres = spawnSync(wixInstall, { shell: true, stdio: 'inherit' });
|
56
|
-
if (wixres.error) {
|
57
|
-
console.log((`💩 ${red.underline.bold("=> Failed to install wix package =>")} ${orange(wixres.error.message)}`));
|
58
|
-
success = false;
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
console.log("🐕" + blue.underline(` => Wix package ${orange(name)} installed!`));
|
62
|
-
}
|
63
|
-
});
|
64
|
-
}
|
65
|
-
if (success) {
|
66
|
-
console.log("🐕" + blue.underline(` => All Packages installed!`));
|
5
|
+
else if (typeof error === 'string') {
|
6
|
+
return new Error(error);
|
67
7
|
}
|
68
8
|
else {
|
69
|
-
|
70
|
-
}
|
71
|
-
}
|
72
|
-
async function isSubmoduleRegistered(git, submoduleName) {
|
73
|
-
try {
|
74
|
-
const urlConfig = await git.getConfig(`submodule.${submoduleName}.url`);
|
75
|
-
return !!urlConfig.value;
|
76
|
-
}
|
77
|
-
catch (e) {
|
78
|
-
// simple-git throws an error if the config key doesn't exist
|
79
|
-
return false;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
export async function gitInit(cwd, modules, force) {
|
83
|
-
const git = simpleGit({ baseDir: cwd });
|
84
|
-
if (!(await git.checkIsRepo())) {
|
85
|
-
console.log(chalk.yellow('Project is not a git repository. Initializing...'));
|
86
|
-
await git.init();
|
87
|
-
}
|
88
|
-
if (!modules) {
|
89
|
-
console.log(chalk.yellow('No submodules defined in settings, skipping.'));
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
const dotGitmodulesPath = path.join(cwd, '.gitmodules');
|
93
|
-
for (const [name, repo] of Object.entries(modules)) {
|
94
|
-
console.log(chalk.green.underline.bold(`Processing submodule ${name}`));
|
95
|
-
const clonePath = repo.path || name;
|
96
|
-
try {
|
97
|
-
const isRegistered = await isSubmoduleRegistered(git, clonePath);
|
98
|
-
// Check that .gitmodules exists AND contains the entry for this specific submodule.
|
99
|
-
const isConfiguredInFile = fs.existsSync(dotGitmodulesPath) &&
|
100
|
-
fs.readFileSync(dotGitmodulesPath, 'utf-8').includes(`[submodule "${clonePath}"]`);
|
101
|
-
// Add/repair if not configured in .gitmodules, or if forced by the user.
|
102
|
-
if (!isConfiguredInFile || force) {
|
103
|
-
console.log(`🐕 ${blue.underline(`Adding/updating submodule ${name} at ${clonePath}...`)}`);
|
104
|
-
// If git already has a config entry, we must use --force to repair it.
|
105
|
-
const submoduleArgs = ['add', ...(force || isRegistered ? ['--force'] : []), repo.url, clonePath];
|
106
|
-
await git.subModule(submoduleArgs);
|
107
|
-
}
|
108
|
-
else {
|
109
|
-
console.log(`🐕 ${blue.underline(`Submodule ${name} at ${clonePath} already registered. Skipping add.`)}`);
|
110
|
-
}
|
111
|
-
await git.submoduleUpdate(['--init', '--recursive', clonePath]);
|
112
|
-
await simpleGit({ baseDir: path.join(cwd, clonePath) }).checkout(repo.branch);
|
113
|
-
}
|
114
|
-
catch (err) {
|
115
|
-
console.log((`💩 ${red.underline.bold(`=> Command failed for submodule ${name} =>`)} ${orange(err)}`));
|
116
|
-
}
|
117
|
-
}
|
118
|
-
console.log("🐶" + green.underline(' => All modules processed!'));
|
119
|
-
}
|
120
|
-
export async function runGulp(moduleSettings, projectSettings, task) {
|
121
|
-
// Get the directory name of the current module
|
122
|
-
const __filename = fileURLToPath(import.meta.url);
|
123
|
-
const __dirname = path.dirname(__filename);
|
124
|
-
// Resolve the path to the Gulpfile
|
125
|
-
const gulpfilePath = path.resolve(__dirname, 'Gulpfile.js');
|
126
|
-
// Dynamically import the Gulpfile
|
127
|
-
const gulpfile = await import(`file://${gulpfilePath}`);
|
128
|
-
// Check if 'dev' task exists
|
129
|
-
gulpfile.runTask(task, moduleSettings, projectSettings);
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* Clean up and run a command before exiting the process.
|
133
|
-
*/
|
134
|
-
export function cleanupWatchers() {
|
135
|
-
console.log(`🧹 ${magenta.underline('Cleaning up Watchman watchers...')}`);
|
136
|
-
const cwd = process.cwd();
|
137
|
-
const command = `watchman watch-del "${cwd}"`; // Adjust for Windows paths
|
138
|
-
exec(command, (error, stdout, stderr) => {
|
139
|
-
if (error) {
|
140
|
-
console.error(`💩 ${red.underline('Failed to run cleanup:')} ${orange(error.message)}`);
|
141
|
-
return;
|
142
|
-
}
|
143
|
-
if (stderr) {
|
144
|
-
console.error(`⚠️ ${yellow.underline('Watchman stderr:')} ${stderr}`);
|
145
|
-
}
|
146
|
-
console.log(`✅ ${green.underline('Watchman cleanup success:')} ${stdout}`);
|
147
|
-
});
|
148
|
-
}
|
149
|
-
/**
|
150
|
-
* Kill all processes matching a specific substring in their command, with a fallback for Windows.
|
151
|
-
* @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
|
152
|
-
*/
|
153
|
-
export function killAllProcesses(processPattern) {
|
154
|
-
const isWindows = os.platform() === 'win32';
|
155
|
-
const command = isWindows
|
156
|
-
? `tasklist /FI "IMAGENAME eq node.exe" /FO CSV | findstr "${processPattern}"` // Adjust for Node.js processes
|
157
|
-
: `ps -eo pid,command | grep "${processPattern}" | grep -v grep`;
|
158
|
-
exec(command, (error, stdout, stderr) => {
|
159
|
-
if (error) {
|
160
|
-
console.error(`💩 ${red.underline('Failed to find processes:')} ${orange(error.message)}`);
|
161
|
-
return;
|
162
|
-
}
|
163
|
-
if (stderr) {
|
164
|
-
console.error(`⚠️ ${yellow.underline('Error output:')} ${stderr}`);
|
165
|
-
}
|
166
|
-
if (!stdout.trim()) {
|
167
|
-
console.log(`ℹ️ ${blue.underline(`No processes found matching pattern:`)} ${orange(processPattern)}`);
|
168
|
-
return;
|
169
|
-
}
|
170
|
-
console.log(`📝 ${magenta.underline('Found matching processes:')}\n${stdout}`);
|
171
|
-
const lines = stdout.trim().split('\n');
|
172
|
-
const pids = isWindows
|
173
|
-
? lines.map(line => line.match(/"(\d+)"/)?.[1]) // Extract PID from Windows tasklist output
|
174
|
-
: lines.map(line => line.trim().split(/\s+/)[0]).filter(pid => !isNaN(Number(pid)));
|
175
|
-
pids.forEach(pid => {
|
176
|
-
if (!pid)
|
177
|
-
return;
|
178
|
-
try {
|
179
|
-
const killCommand = isWindows
|
180
|
-
? `taskkill /PID ${pid} /T /F` // Forcefully terminate the process on Windows
|
181
|
-
: `kill -SIGTERM ${pid}`;
|
182
|
-
exec(killCommand, (killError) => {
|
183
|
-
if (killError) {
|
184
|
-
console.error(`⚠️ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
185
|
-
}
|
186
|
-
else {
|
187
|
-
console.log(`✅ ${green.underline('Killed process with PID:')} ${orange(pid)}`);
|
188
|
-
}
|
189
|
-
});
|
190
|
-
// Schedule SIGKILL fallback for non-Windows platforms
|
191
|
-
if (!isWindows) {
|
192
|
-
setTimeout(() => {
|
193
|
-
try {
|
194
|
-
process.kill(parseInt(pid, 10), 'SIGKILL');
|
195
|
-
console.log(`🔪 ${red.underline('Sent SIGKILL to process with PID:')} ${orange(pid)} (fallback).`);
|
196
|
-
}
|
197
|
-
catch (killError) {
|
198
|
-
if (killError.code === 'ESRCH') {
|
199
|
-
console.log(`✅ ${green.underline('Process with PID')} ${orange(pid)} ${green.underline('already terminated.')}`);
|
200
|
-
}
|
201
|
-
else {
|
202
|
-
console.error(`⚠️ ${yellow.underline('Failed to send SIGKILL to process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}, 10000);
|
206
|
-
}
|
207
|
-
}
|
208
|
-
catch (err) {
|
209
|
-
console.error(`⚠️ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(err.message)}`);
|
210
|
-
}
|
211
|
-
});
|
212
|
-
});
|
213
|
-
}
|
214
|
-
export async function saveConfig(config, file) {
|
215
|
-
await fs.promises.writeFile(file, JSON.stringify(config));
|
216
|
-
}
|
217
|
-
export async function readConfig(file) {
|
218
|
-
let content = await fs.promises.readFile(file, 'utf-8');
|
219
|
-
return JSON.parse(content);
|
220
|
-
}
|
221
|
-
export async function createTemplateFolder(moduleSettings) {
|
222
|
-
const templatesPath = join(os.homedir(), '.lucy-cli');
|
223
|
-
try {
|
224
|
-
mkdirSync(templatesPath);
|
225
|
-
const defaultTemplatePath = join(templatesPath, 'default');
|
226
|
-
mkdirSync(defaultTemplatePath);
|
227
|
-
const sourceFilesPath = join(moduleSettings.packageRoot, 'files');
|
228
|
-
const defaultTemplateFilesPath = join(defaultTemplatePath, 'files');
|
229
|
-
await fse.copy(sourceFilesPath, defaultTemplateFilesPath);
|
230
|
-
const defaultTemplateSettingsPath = join(defaultTemplatePath, 'settings.json');
|
231
|
-
await writeFile(defaultTemplateSettingsPath, JSON.stringify(moduleSettings.settings, null, 2));
|
232
|
-
console.log(green('✅ Default template created successfully!'));
|
233
|
-
}
|
234
|
-
catch (e) {
|
235
|
-
console.log((`💩 ${red.underline.bold("=> Error creating default template =>")} ${orange(e)}`));
|
236
|
-
return;
|
237
|
-
}
|
238
|
-
}
|
239
|
-
/**
|
240
|
-
* Updates a lucy.json file with dependencies from a package.json file.
|
241
|
-
* It replaces 'wixPackages' with 'dependencies' and 'devPackages' with 'devDependencies'.
|
242
|
-
* @param {string} packageJsonPath - Path to the package.json file.
|
243
|
-
* @param {string} lucyConfigPath - Path to the lucy.json file.
|
244
|
-
*/
|
245
|
-
export async function updateLucyConfigFromPackageJson(packageJsonPath, lucyConfigPath) {
|
246
|
-
try {
|
247
|
-
console.log(`🐕 Reading package definitions from ${orange(packageJsonPath)}...`);
|
248
|
-
const pkgJsonContent = await fs.promises.readFile(packageJsonPath, 'utf-8');
|
249
|
-
const packageJson = JSON.parse(pkgJsonContent);
|
250
|
-
console.log(`🐕 Reading Lucy configuration from ${orange(lucyConfigPath)}...`);
|
251
|
-
const lucyConfigContent = await fs.promises.readFile(lucyConfigPath, 'utf-8');
|
252
|
-
const lucyConfig = JSON.parse(lucyConfigContent);
|
253
|
-
const { dependencies = {}, devDependencies = {} } = packageJson;
|
254
|
-
// Note: `wixPackages` are installed using `wix install`. If your `dependencies`
|
255
|
-
// contain packages that are not Wix packages, `lucy-cli install` might fail.
|
256
|
-
lucyConfig.wixPackages = dependencies;
|
257
|
-
lucyConfig.devPackages = devDependencies;
|
258
|
-
console.log(`🐕 Writing updated configuration to ${orange(lucyConfigPath)}...`);
|
259
|
-
await fs.promises.writeFile(lucyConfigPath, JSON.stringify(lucyConfig, null, 2));
|
260
|
-
console.log(green.underline('✅ Lucy configuration updated successfully!'));
|
261
|
-
}
|
262
|
-
catch (error) {
|
263
|
-
console.error(`💩 ${red.underline.bold('=> Error updating lucy.json from package.json:')} ${orange(error.message)}`);
|
264
|
-
throw error; // re-throw to allow caller to handle
|
9
|
+
return new Error('Unknown error');
|
265
10
|
}
|
266
11
|
}
|
package/dist/index.d.ts
CHANGED
@@ -1,59 +1,2 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
packageRoot: string;
|
4
|
-
targetFolder: string;
|
5
|
-
args: string[];
|
6
|
-
settings: LucySettings;
|
7
|
-
};
|
8
|
-
export type LucySettings = {
|
9
|
-
modules: {
|
10
|
-
[libName: string]: {
|
11
|
-
url: string;
|
12
|
-
branch: string;
|
13
|
-
path?: string;
|
14
|
-
noCompile?: boolean;
|
15
|
-
};
|
16
|
-
};
|
17
|
-
wixSettings: {
|
18
|
-
compilerOptions: {
|
19
|
-
composite: boolean;
|
20
|
-
noEmit: boolean;
|
21
|
-
lib: string[];
|
22
|
-
jsx: string;
|
23
|
-
};
|
24
|
-
exclude: string[];
|
25
|
-
};
|
26
|
-
initialized: boolean;
|
27
|
-
wixPackages: {
|
28
|
-
[packageName: string]: string;
|
29
|
-
};
|
30
|
-
devPackages: {
|
31
|
-
[packageName: string]: string;
|
32
|
-
};
|
33
|
-
scripts: {
|
34
|
-
[commandName: string]: string;
|
35
|
-
};
|
36
|
-
};
|
37
|
-
export type ModuleSettings = {
|
38
|
-
packageRoot: string;
|
39
|
-
targetFolder: string;
|
40
|
-
args: string[];
|
41
|
-
wixConfigPath: string;
|
42
|
-
lucyConfigPath: string;
|
43
|
-
packageJsonPath: string;
|
44
|
-
settings: LucySettings;
|
45
|
-
lockVersion: boolean;
|
46
|
-
force: boolean;
|
47
|
-
veloConfigName: string;
|
48
|
-
};
|
49
|
-
export type ProjectSettings = {
|
50
|
-
modules?: Record<string, string>;
|
51
|
-
lucySettings?: LucySettings;
|
52
|
-
packageJSON?: Record<string, any>;
|
53
|
-
};
|
54
|
-
export declare const orange: import("chalk").ChalkInstance;
|
55
|
-
export declare const blue: import("chalk").ChalkInstance;
|
56
|
-
export declare const green: import("chalk").ChalkInstance;
|
57
|
-
export declare const red: import("chalk").ChalkInstance;
|
58
|
-
export declare const yellow: import("chalk").ChalkInstance;
|
59
|
-
export declare const magenta: import("chalk").ChalkInstance;
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import 'dotenv/config';
|