Skip to content

Commit

Permalink
fix scaffolding using default flow and config
Browse files Browse the repository at this point in the history
  • Loading branch information
blefnk committed Dec 29, 2024
1 parent 29e44b1 commit 0e47cd0
Show file tree
Hide file tree
Showing 144 changed files with 1,458 additions and 711 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist-npm/
.DS_Store
merged.txt
.eslintcache
.cursorrules
node_modules/
addons/premium/
addons/**/premium/
Expand Down
2 changes: 1 addition & 1 deletion .reliverse
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ignoreDependencies": [],

// Config revalidation (1h | 1d | 2d | 7d)
"configLastRevalidate": "2024-12-25T13:06:12.128Z",
"configLastRevalidate": "2024-12-29T20:57:03.697Z",
"configRevalidateFrequency": "2d",

// Custom rules for Reliverse AI
Expand Down
30 changes: 28 additions & 2 deletions build.optim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ const npmFilesToDelete: string[] = [
"types/internal.d.ts",
"**/*.temp.js",
"**/*.temp.d.ts",
"**/*.txt",
];

const jsrFilesToDelete: string[] = ["**/*.test.ts", "**/*.temp.ts", "**/*.txt"];
const jsrFilesToDelete: string[] = ["**/*.test.ts", "**/*.temp.ts"];

/**
* Deletes files matching the provided patterns within the base directory.
Expand Down Expand Up @@ -241,6 +240,31 @@ async function copySrcToOutput(): Promise<void> {
}
}

/**
* Renames all .tsx files to -tsx.txt in the specified directory and its subdirectories.
* @param dir - The directory to process.
*/
async function renameTsxFiles(dir: string): Promise<void> {
try {
const files = await globby("**/*.tsx", {
cwd: dir,
absolute: true,
});

for (const filePath of files) {
const newPath = filePath.replace(/\.tsx$/, "-tsx.txt");
await fs.rename(filePath, newPath);
relinka("info-verbose", `Renamed: ${filePath} -> ${newPath}`);
}
} catch (error) {
relinka(
"error",
"Error renaming .tsx files:",
error instanceof Error ? error.message : String(error),
);
}
}

/**
* Optimizes the build for production by processing files and deleting unnecessary ones.
* @param dir - The directory to optimize.
Expand All @@ -256,6 +280,8 @@ async function optimizeBuildForProduction(dir: string): Promise<void> {
await copySrcToOutput();
relinka("info", "Processing copied files to replace import paths...");
await processFiles(outputDir); // Process files after copying
relinka("info", "Renaming .tsx files to -tsx.txt for JSR compatibility...");
await renameTsxFiles(outputDir);
} else {
relinka("info", "Creating an optimized production build...");
await processFiles(dir);
Expand Down
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"version": "0.2",
"language": "en",
"import": [
"@cspell/dict-npm/cspell-ext.json"
],
"ignorePaths": [
"**/*.lock",
"**/*.txt",
Expand Down Expand Up @@ -46,6 +43,7 @@
"continuar",
"cristal",
"cronvel",
"crossplatform",
"datepart",
"dateparts",
"deafult",
Expand Down Expand Up @@ -99,6 +97,7 @@
"mkdist",
"Mkey",
"montag",
"moonrepo",
"Nazar",
"Nazarii",
"nenc",
Expand Down Expand Up @@ -149,6 +148,7 @@
"termkit",
"tseslint",
"Tully",
"turborepo",
"turso",
"typebox",
"typecheck",
Expand All @@ -164,6 +164,7 @@
"valign",
"venv",
"versator",
"VITE",
"Vous",
"vsprintf",
"Whoo",
Expand Down
4 changes: 2 additions & 2 deletions jsr.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reliverse/cli",
"version": "1.4.3",
"version": "1.4.8",
"author": "blefnk",
"license": "MIT",
"exports": "./dist-jsr/main.ts",
Expand Down Expand Up @@ -34,4 +34,4 @@
"tests-runtime/**"
]
}
}
}
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reliverse/cli",
"version": "1.4.3",
"version": "1.4.8",
"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 @@ -44,9 +44,17 @@
"url": "https://github.com/reliverse/cli/issues",
"email": "[email protected]"
},
"files": ["package.json", "README.md", "LICENSE.md", "dist-npm"],
"files": [
"package.json",
"README.md",
"LICENSE.md",
"dist-npm"
],
"homepage": "https://github.com/reliverse/cli",
"keywords": ["cli", "reliverse"],
"keywords": [
"cli",
"reliverse"
],
"license": "MIT",
"dependencies": {
"@clack/core": "^0.4.0",
Expand All @@ -71,8 +79,8 @@
"drizzle-orm": "^0.38.3",
"execa": "^9.5.2",
"fs-extra": "^11.2.0",
"geist": "^1.3.1",
"globby": "^14.0.2",
"gradient-string": "^3.0.0",
"magic-regexp": "^0.8.0",
"nanoid": "^5.0.9",
"node-emoji": "^2.2.0",
Expand Down Expand Up @@ -104,6 +112,7 @@
"@planetscale/database": "^1.19.0",
"@prisma/adapter-planetscale": "^6.1.0",
"@prisma/client": "^6.1.0",
"@react-router/dev": "^7.1.1",
"@stylistic/eslint-plugin": "^2.12.1",
"@swc/core": "^1.10.3",
"@t3-oss/env-nextjs": "^0.11.1",
Expand All @@ -118,7 +127,6 @@
"@types/cross-spawn": "^6.0.6",
"@types/eslint__js": "^8.42.3",
"@types/fs-extra": "^11.0.4",
"@types/gradient-string": "^1.1.6",
"@types/node": "^22.10.2",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
Expand Down Expand Up @@ -152,4 +160,4 @@
"vitest": "^2.1.8",
"zod": "^3.24.1"
}
}
}
3 changes: 3 additions & 0 deletions src/app/db/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import path from "pathe";
import { fileURLToPath } from "url";

export const isVerboseEnabled = false;

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const PKG_ROOT = path.resolve(__dirname, "../../../..");

// File conflict settings, useful for prompting user to resolve conflicts during project setup
Expand Down
72 changes: 43 additions & 29 deletions src/app/menu/askGithubName.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
import { inputPrompt } from "@reliverse/prompts";
import pc from "picocolors";

import {
readReliverseMemory,
updateReliverseMemory,
} from "~/args/memory/impl.js";
import { relinka } from "~/utils/console.js";

export async function askGithubName(): Promise<string> {
const memory = await readReliverseMemory();
export async function askGithubName(): Promise<string | null> {
try {
const memory = await readReliverseMemory();
if (!memory) {
relinka("error", "Failed to read reliverse memory");
return null;
}

let placeholder = "";
let content = "";
if (memory.githubUsername && memory.githubUsername !== "") {
return memory.githubUsername;
}

if (memory.githubUsername) {
placeholder = memory.githubUsername;
content = `Last used GitHub username: ${pc.cyanBright(placeholder)}`;
}
const ghUsername = await inputPrompt({
title: "What's your GitHub username?",
content:
"💡 If you don't have a GitHub account, you can create one for free at https://github.com/signup",
validate: (value: string | undefined) => {
if (!value?.trim()) {
return "GitHub username is required for deployment";
}
if (!/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(value)) {
return "Invalid GitHub username format";
}
return true;
},
});

const githubUsername = await inputPrompt({
title: "What's your GitHub username?",
placeholder,
content,
validate: (value: string | undefined) => {
if (!value?.trim()) {
return "GitHub username is required for deployment";
}
if (!/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(value)) {
return "Invalid GitHub username format";
}
return true;
},
});
if (ghUsername !== "" && ghUsername !== memory.githubUsername) {
await updateReliverseMemory({
githubUsername: ghUsername,
});
} else {
relinka(
"error",
"Something went wrong while saving your GitHub username...",
);
}

if (githubUsername && githubUsername !== placeholder) {
await updateReliverseMemory({
githubUsername,
});
return ghUsername;
} catch (error) {
relinka(
"error",
"Failed to get GitHub username:",
error instanceof Error ? error.message : String(error),
);
return null;
}

return githubUsername;
}
37 changes: 17 additions & 20 deletions src/app/menu/askVercelName.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inputPrompt } from "@reliverse/prompts";
import pc from "picocolors";

import {
readReliverseMemory,
Expand All @@ -10,33 +9,31 @@ export async function askVercelName(): Promise<string> {
const memory = await readReliverseMemory();

let placeholder = "";
let content = "";

if (memory.vercelUsername) {
placeholder = memory.vercelUsername;
content = `Last used Vercel username: ${pc.cyanBright(placeholder)}`;
}

const vercelUsername = await inputPrompt({
title: "What's your Vercel team name?",
placeholder,
content,
validate: (value: string): string | boolean => {
if (!value?.trim()) {
return "Vercel username is required for deployment";
}
if (!/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(value)) {
return "Invalid Vercel username format";
}
return true;
},
});
if (placeholder === "") {
placeholder = await inputPrompt({
title: "What's your Vercel team name?",
validate: (value: string): string | boolean => {
if (!value?.trim()) {
return "Vercel username is required for deployment";
}
if (!/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(value)) {
return "Invalid Vercel username format";
}
return true;
},
});
}

if (vercelUsername && vercelUsername !== placeholder) {
if (placeholder !== "" && placeholder !== memory.vercelUsername) {
await updateReliverseMemory({
vercelUsername,
vercelUsername: placeholder,
});
}

return vercelUsername;
return placeholder;
}
8 changes: 4 additions & 4 deletions src/app/menu/buildBrandNewThing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ export async function buildBrandNewThing(
title: "Should I continue with advanced or simple mode?",
options: [
{
label: "Advanced",
label: pc.bold(pc.greenBright("Advanced")),
value: "recommended",
hint: pc.greenBright("✨ recommended"),
hint: pc.greenBright(pc.reset("✨ STABLE & RECOMMENDED")),
},
{
label: "Simple",
label: pc.dim(pc.red("Simple")),
value: "offline",
hint: pc.redBright("🚨 experimental, offline"),
hint: pc.red("🚨 experimental, offline"),
},
],
});
Expand Down
5 changes: 2 additions & 3 deletions src/app/menu/compose-env-file/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { selectPrompt, inputPrompt, confirmPrompt } from "@reliverse/prompts";
import { execa } from "execa";
import fs from "fs-extra";
import open from "open";
import pc from "picocolors";

import { relinka } from "~/utils/console.js";

Expand Down Expand Up @@ -81,8 +80,8 @@ export async function composeEnvFile(
"Please provide the path to your existing .env file or directory:",
placeholder:
process.platform === "win32"
? `Enter the path (e.g. ${pc.cyanBright("C:\\Users\\name\\project\\.env")} or ${pc.cyanBright("C:\\Users\\name\\project")})`
: `Enter the path (e.g. ${pc.cyanBright("/home/user/project/.env")} or ${pc.cyanBright("/home/user/project")})`,
? `Enter the path (e.g. "C:\\Users\\name\\project\\.env" or "C:\\Users\\name\\project"`
: `Enter the path (e.g. "/home/user/project/.env" or "/home/user/project"`,
content:
"You can provide either the .env file path or the directory containing it.",
contentColor: "yellowBright",
Expand Down
Loading

0 comments on commit 0e47cd0

Please sign in to comment.