Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/typegpu-cli/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
type ProjectTemplate,
} from './options.ts';

const GRADIENT_START = [0.831, 0.553, 1.0] as const;
const GRADIENT_END = [0.32, 0.4, 0.95] as const;
const GRADIENT_START = [0.867, 0.663, 1.0] as const;
const GRADIENT_END = [0.384, 0.439, 0.964] as const;

const coloredLabelsTemplates = PROJECT_TEMPLATES.map((template, i) => {
const t = i / (PROJECT_TEMPLATES.length - 1);
Expand Down Expand Up @@ -54,8 +54,6 @@ export async function createProject(cwd: string, options?: CreateProjectOptions)
options?.projectDir ??
(nonInteractive ? DEFAULT_PROJECT_DIR : await getProjectName(DEFAULT_PROJECT_DIR));

const root = await prepareDirectory(cwd, projectName, { interactive: !nonInteractive });

const packageName =
getDefaultPackageName(cwd, projectName) ??
(nonInteractive ? undefined : await getPackageName());
Expand All @@ -72,6 +70,8 @@ export async function createProject(cwd: string, options?: CreateProjectOptions)

p.log.step(`Scaffolding project in ${projectName}...`);

const root = await prepareDirectory(cwd, projectName, { interactive: !nonInteractive });
Comment thread
cieplypolar marked this conversation as resolved.

const templateDir = path.resolve(
import.meta.dirname,
'../templates',
Expand Down
5 changes: 4 additions & 1 deletion packages/typegpu-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import {
parsePackageManager,
parseTemplate,
} from './options.ts';
import { failAndExit } from './utils/prompts.ts';
import { colorsEnabled, failAndExit } from './utils/prompts.ts';
import { typegpuPkgs } from './utils/pkg.ts';
import { typegpuAsciiLogoColor, typegpuAsciiLogoNoColor } from './utils/logo.ts';

function formatHelpEntries(entries: readonly { value: string; label?: string; hint?: string }[]) {
const maxLength = Math.max(...entries.map((entry) => entry.value.length));
Expand Down Expand Up @@ -74,6 +75,8 @@ const commonOptions = {
...(packageManager ? { packageManager } : {}),
};

console.log(colorsEnabled ? typegpuAsciiLogoColor : typegpuAsciiLogoNoColor);

if (argv.enhance) {
const targetDir = positionals[0] ? path.resolve(cwd, positionals[0]) : cwd;
if (!fs.existsSync(targetDir) || !fs.statSync(targetDir).isDirectory()) {
Expand Down
5 changes: 5 additions & 0 deletions packages/typegpu-cli/src/utils/logo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const typegpuAsciiLogoColor =
'\n \x1b[38;2;221;169;255m /|\x1b[0m\n \x1b[38;2;207;159;255m \\|____\x1b[0m\n \x1b[38;2;176;145;255m , `\\ \\\x1b[0m\n \x1b[38;2;147;136;255m/ `\\ \\ \\\x1b[0m\n \x1b[38;2;113;124;255m\\ `\\| /\x1b[0m\n \x1b[38;2;95;112;255m \\_____/\x1b[0m\n';

export const typegpuAsciiLogoNoColor =
'\n /|\n \\|____\n , `\\ \\\n / `\\ \\ \\\n \\ `\\| /\n \\_____/\n';
4 changes: 4 additions & 0 deletions packages/typegpu-cli/src/utils/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { styleText } from 'node:util';
import * as p from '@clack/prompts';

export const colorsEnabled = styleText('red', '_', { stream: process.stdout }) !== '_';

export function cancelExit(): never {
p.cancel('Operation cancelled.');
process.exit(0);
Expand All @@ -22,5 +25,6 @@ export async function confirmStep(message: string, initialValue?: boolean) {

// 0-255 range
export function rgbText(text: string, r: number, g: number, b: number) {
if (!colorsEnabled) return text;
return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
}
Loading