Skip to content

Commit

Permalink
temporarily combine config code in one file
Browse files Browse the repository at this point in the history
  • Loading branch information
blefnk committed Jan 10, 2025
1 parent 25c0bd8 commit fc4a155
Show file tree
Hide file tree
Showing 139 changed files with 2,108 additions and 2,217 deletions.
2 changes: 1 addition & 1 deletion build.optim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { globby } from "globby";
import path from "pathe";
import { fileURLToPath } from "url";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

// Parse command-line arguments to check for '--jsr' flag
const args: string[] = process.argv.slice(2);
Expand Down
2 changes: 1 addition & 1 deletion build.publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { globby } from "globby";
import mri from "mri";
import path from "pathe";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

function showHelp() {
relinka(
Expand Down
Binary file modified bun.lockb
Binary file not shown.
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import eslint from "@eslint/js";
import json from "@eslint/json";
import markdown from "@eslint/markdown";
import stylistic from "@stylistic/eslint-plugin";
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
import perfectionist from "eslint-plugin-perfectionist";
import path from "node:path";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -34,6 +35,7 @@ const config = tseslint.config(
perfectionist,
// @ts-expect-error wrong issue
"@stylistic": stylistic,
"no-relative-import-paths": noRelativeImportPaths,
},
rules: {
"@typescript-eslint/restrict-template-expressions": "off",
Expand Down Expand Up @@ -86,6 +88,10 @@ const config = tseslint.config(
"@stylistic/quotes": "off",
"@stylistic/quote-props": "off",
"@stylistic/indent-binary-ops": "off",
"no-relative-import-paths/no-relative-import-paths": [
"warn",
{ allowSameFolder: true, rootDir: "src", prefix: "~" },
],
},
},
{
Expand Down Expand Up @@ -127,6 +133,12 @@ const config = tseslint.config(
],
},
},
{
files: ["**/reliverseConfig.ts"],
rules: {
"max-lines": "off",
},
},
);

export default config;
2 changes: 1 addition & 1 deletion jsr.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reliverse/cli",
"version": "1.4.19",
"version": "1.4.20",
"author": "blefnk",
"license": "MIT",
"exports": "./dist-jsr/main.ts",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reliverse/cli",
"version": "1.4.19",
"version": "1.4.20",
"author": "blefnk",
"type": "module",
"description": "This superapp CLI tool can help you easily create new web projects, manage existing projects, and automatically make advanced codebase modifications, with more features coming soon.",
Expand Down Expand Up @@ -134,6 +134,7 @@
"@types/strip-comments": "^2.0.4",
"drizzle-kit": "^0.30.1",
"eslint": "^9.17.0",
"eslint-plugin-no-relative-import-paths": "^1.6.1",
"eslint-plugin-perfectionist": "^4.6.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
Expand Down
2 changes: 1 addition & 1 deletion publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { defineCommand, errorHandler, runMain } from "@reliverse/prompts";
import { execa } from "execa";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

const main = defineCommand({
meta: {
Expand Down
15 changes: 8 additions & 7 deletions src/app/app-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ import { pm, selectPrompt } from "@reliverse/prompts";
import fs from "fs-extra";
import path from "pathe";

import type { ReliverseConfig, ReliverseMemory } from "~/types.js";
import type { ReliverseMemory } from "~/types.js";

import { getMainMenuOptions } from "~/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/getMainMenuOptions.js";
import { showDetectedProjectsMenu } from "~/app/menu/create-project/cp-modules/cli-main-modules/detections/detectedProjectsMenu.js";
import {
detectProject,
detectProjectsWithReliverse,
} from "~/app/menu/create-project/cp-modules/cli-main-modules/detections/detectReliverseProjects.js";
import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import {
showEndPrompt,
showStartPrompt,
} from "~/app/menu/create-project/cp-modules/cli-main-modules/modules/showStartEndPrompt.js";
import { showDevToolsMenu } from "~/dev.js";
import { relinka } from "~/utils/loggerRelinka.js";
import {
detectProject,
detectProjectsWithReliverse,
type ReliverseConfig,
} from "~/utils/reliverseConfig.js";

import { showDevToolsMenu } from "../dev.js";
import {
randomReliverseMenuTitle,
randomWelcomeMessages,
Expand Down
12 changes: 8 additions & 4 deletions src/app/app-mod.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defineCommand } from "@reliverse/prompts";

import { getReliverseConfig } from "~/app/menu/create-project/cp-modules/cli-main-modules/configs/miscellaneousConfigHelpers.js";
import { getCurrentWorkingDirectory } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/terminal.js";
import { showStartPrompt } from "~/app/menu/create-project/cp-modules/cli-main-modules/modules/showStartEndPrompt.js";
import { authCheck } from "~/args/login/impl.js";
import { getReliverseMemory } from "~/utils/reliverseMemory.js";

import { app } from "./app-impl.js";
import { getReliverseMemory } from "./app-utils.js";
import { useLocalhost } from "./constants.js";

export default defineCommand({
Expand All @@ -22,12 +21,17 @@ export default defineCommand({
},
run: async ({ args }) => {
const isDev = args.dev;

await showStartPrompt(isDev);
const cwd = getCurrentWorkingDirectory();
const memory = await getReliverseMemory();
const config = await getReliverseConfig(cwd);

// TODO: fix reliverse config and enable it back
// const config = await getReliverseConfig(cwd);

await authCheck(isDev, memory, useLocalhost);
await app({ cwd, isDev, config, memory });
await app({ cwd, isDev, config: {}, memory });

process.exit(0);
},
});
2 changes: 1 addition & 1 deletion src/app/db/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from "fs-extra";
import os from "os";
import path from "pathe";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

// Use .reliverse directory in user's home directory
const homeDir = os.homedir();
Expand Down
2 changes: 1 addition & 1 deletion src/app/db/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { eq } from "drizzle-orm";

import type { ConfigKey } from "~/types.js";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

import { db } from "./client.js";
import { configKeysTable } from "./schema.js";
Expand Down
23 changes: 11 additions & 12 deletions src/app/menu/create-project/cp-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import pc from "picocolors";
import type {
Behavior,
DeploymentService,
ReliverseConfig,
ReliverseMemory,
TemplateOption,
} from "~/types.js";
import type { ReliverseConfig } from "~/utils/reliverseConfig.js";

import { setupI18nFiles } from "~/app/menu/create-project/cp-modules/cli-main-modules/downloads/downloadI18nFiles.js";
import { extractRepoInfo } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/extractRepoInfo.js";
import { isVSCodeInstalled } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/isAppInstalled.js";
import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { promptPackageJsonScripts } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/promptPackageJsonScripts.js";
import { replaceStringsInFiles } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/replaceStringsInFiles.js";
import { askProjectName } from "~/app/menu/create-project/cp-modules/cli-main-modules/modules/askProjectName.js";
import { askUserName } from "~/app/menu/create-project/cp-modules/cli-main-modules/modules/askUserName.js";
import { promptGitDeploy } from "~/app/menu/create-project/cp-modules/git-deploy-prompts/mod.js";
import { relinka } from "~/utils/loggerRelinka.js";

export type PackageJson = {
name?: string;
Expand Down Expand Up @@ -64,18 +64,18 @@ export async function initializeProjectConfig(
shouldUseDataFromConfig: boolean,
): Promise<ProjectConfig> {
const frontendUsername =
shouldUseDataFromConfig && config?.experimental?.projectAuthor
? config.experimental.projectAuthor
shouldUseDataFromConfig && config?.projectAuthor
? config.projectAuthor
: ((await askUserName(memory)) ?? "");

const projectName =
shouldUseDataFromConfig && config?.experimental?.projectTemplate
? path.basename(config.experimental.projectTemplate)
shouldUseDataFromConfig && config?.projectTemplate
? path.basename(config.projectTemplate)
: ((await askProjectName()) ?? "");

const primaryDomain =
shouldUseDataFromConfig && config?.experimental?.projectDomain
? config.experimental.projectDomain
shouldUseDataFromConfig && config?.projectDomain
? config.projectDomain
: `${projectName}.vercel.app`;

return { frontendUsername, projectName, primaryDomain };
Expand Down Expand Up @@ -129,9 +129,8 @@ export async function setupI18nSupport(
shouldUseDataFromConfig: boolean,
) {
const i18nShouldBeEnabled =
shouldUseDataFromConfig &&
config?.experimental?.features?.i18n !== undefined
? config.experimental.features.i18n
shouldUseDataFromConfig && config?.features?.i18n !== undefined
? config.features.i18n
: await confirmPrompt({
title:
"Do you want to enable i18n (internationalization) for this project?",
Expand All @@ -157,7 +156,7 @@ export async function handleDependencies(
projectPath: string,
config: ReliverseConfig,
) {
const depsBehavior: Behavior = config?.experimental?.depsBehavior ?? "prompt";
const depsBehavior: Behavior = config?.depsBehavior ?? "prompt";

const shouldInstallDeps = await determineShouldInstallDeps(depsBehavior);
let shouldRunDbPush = false;
Expand Down
8 changes: 3 additions & 5 deletions src/app/menu/create-project/cp-mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
generateProjectConfigs,
updateProjectConfig,
} from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/generateProjectConfigs.js";
import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { composeEnvFile } from "~/app/menu/create-project/cp-modules/compose-env-file/mod.js";
import { relinka } from "~/utils/loggerRelinka.js";

import {
initializeProjectConfig,
Expand All @@ -32,8 +32,7 @@ export async function createWebProject({
relinka("info", message);

// Check if we should use data from the config
const shouldUseDataFromConfig =
config?.experimental?.skipPromptsUseAutoBehavior ?? false;
const shouldUseDataFromConfig = config?.skipPromptsUseAutoBehavior ?? false;

// Initialize project configuration
const projectConfig = await initializeProjectConfig(
Expand Down Expand Up @@ -89,14 +88,13 @@ export async function createWebProject({

// Generate initial configs with default deployment service
await generateProjectConfigs(
memory,
projectPath,
projectName,
frontendUsername,
"vercel",
initialDomain,
defaultI18nShouldBeEnabled,
shouldInstallDeps,
frontendUsername,
);

// Handle deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs-extra";
import path from "pathe";
import pc from "picocolors";

import { detectProjectsWithReliverse } from "~/app/menu/create-project/cp-modules/cli-main-modules/detections/detectReliverseProjects.js";
import { detectProjectsWithReliverse } from "~/utils/reliverseConfig.js";

export type MainMenuChoice =
| "create"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs-extra";
import path from "pathe";
import pc from "picocolors";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

export async function getProjectMenuOptions(
cwd: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { selectPrompt, inputPrompt } from "@reliverse/prompts";

import type {
ReliverseConfig,
ReliverseMemory,
TemplateOption,
} from "~/types.js";
import type { ReliverseMemory, TemplateOption } from "~/types.js";
import type { ReliverseConfig } from "~/utils/reliverseConfig.js";

import { createWebProject } from "~/app/menu/create-project/cp-mod.js";
import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { validate } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/validate.js";
import { buildBrandNewThing } from "~/app/menu/menu-mod.js";
import { relinka } from "~/utils/loggerRelinka.js";

export async function installAnyGitRepo(
cwd: string,
Expand Down Expand Up @@ -134,10 +131,8 @@ export async function installAnyGitRepo(
i18nShouldBeEnabled: true,
isDev,
config: {
experimental: {
i18nBehavior: "prompt",
projectFramework: "nextjs",
},
i18nBehavior: "prompt",
projectFramework: "nextjs",
},
memory,
cwd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import pc from "picocolors";

import type { ApptsConfig } from "~/types.js";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import metadata from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/metadata.js";
import { relinka } from "~/utils/loggerRelinka.js";

export async function configureAppts({ apptsConfig }: ApptsConfig) {
const apptsConfigPath = join(apptsConfig, "app.ts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import fs from "fs-extra";
import path from "pathe";

import { type BiomeConfig, type ConfigPaths } from "~/types.js";

import { relinka } from "../handlers/logger.js";
import { addConfigMetadata } from "./miscellaneousConfigHelpers.js";
import { addConfigMetadata } from "~/utils/configHandler.js";
import { relinka } from "~/utils/loggerRelinka.js";

const BIOME_DEFAULT_CONFIG: BiomeConfig = addConfigMetadata({
$schema: "https://biomejs.dev/schemas/1.5.3/schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from "pathe";

import type { PromptType, Question } from "~/types.js";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { relinka } from "~/utils/loggerRelinka.js";

// TODO: 🐞 Still in development! Please use at own risk!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { selectPrompt } from "@reliverse/prompts";
import fs from "fs-extra";
import path from "pathe";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { type ConfigPaths } from "~/types.js";
import { relinka } from "~/utils/loggerRelinka.js";

const ENV_DEFAULT_CONFIG = `import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { selectPrompt } from "@reliverse/prompts";
import fs from "fs-extra";
import path from "pathe";

import { relinka } from "~/app/menu/create-project/cp-modules/cli-main-modules/handlers/logger.js";
import { type ConfigPaths } from "~/types.js";
import { relinka } from "~/utils/loggerRelinka.js";

const ESLINT_DEFAULT_CONFIG = `// @ts-check
Expand Down
Loading

0 comments on commit fc4a155

Please sign in to comment.