diff --git a/packages/create-typegpu/README.md b/packages/create-typegpu/README.md new file mode 100644 index 0000000000..7cf1b84742 --- /dev/null +++ b/packages/create-typegpu/README.md @@ -0,0 +1,22 @@ +# create-typegpu + +This package is a proxy for the [`@typegpu/cli`](https://github.com/software-mansion/TypeGPU/tree/main/packages/typegpu-cli), and allows you to +spin up new TypeGPU projects with the `npm create typegpu` command. + +```sh +npx @typegpu/cli@latest + +# Alternate ways to invoke the CLI: +npx typegpu@latest +npm create typegpu +``` + +## TypeGPU is created by Software Mansion + +[![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=typegpu-github 'Software Mansion')](https://swmansion.com) + +Since 2012 [Software Mansion](https://swmansion.com) is a software agency with +experience in building web and mobile apps. We are Core React Native +Contributors and experts in dealing with all kinds of React Native issues. We +can help you build your next dream product – +[Hire us](https://swmansion.com/contact/projects?utm_source=typegpu&utm_medium=readme). diff --git a/packages/create-typegpu/bin.mjs b/packages/create-typegpu/bin.mjs new file mode 100644 index 0000000000..902a719c0a --- /dev/null +++ b/packages/create-typegpu/bin.mjs @@ -0,0 +1,36 @@ +#!/usr/bin/env node +// @ts-check + +import { spawn } from 'node:child_process'; + +function asyncSpawn(/** @type {Parameters} */ ...args) { + return new Promise((resolve, reject) => { + const child = spawn(...args); + + child.on('exit', (code, signal) => { + if (signal) { + process.kill(process.pid, signal); + return; + } + + resolve(code ?? 0); + }); + + child.on('error', (err) => { + reject(err); + }); + }); +} + +(async () => { + const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx'; + try { + const code = await asyncSpawn(npxCommand, ['@typegpu/cli@latest', ...process.argv.slice(2)], { + stdio: 'inherit', + }); + process.exit(code); + } catch (err) { + console.error('Failed to run @typegpu/cli via npx:', err); + process.exit(1); + } +})(); diff --git a/packages/create-typegpu/package.json b/packages/create-typegpu/package.json new file mode 100644 index 0000000000..cd1c29a849 --- /dev/null +++ b/packages/create-typegpu/package.json @@ -0,0 +1,33 @@ +{ + "name": "create-typegpu", + "version": "0.0.1", + "description": "A CLI tool for bootstrapping TypeGPU projects.", + "homepage": "https://typegpu.com", + "bugs": { + "url": "https://github.com/software-mansion/TypeGPU/issues" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/software-mansion/TypeGPU.git#main", + "directory": "packages/create-typegpu" + }, + "bin": { + "create-typegpu": "./bin.mjs" + }, + "files": [ + "bin.mjs" + ], + "type": "module", + "scripts": { + "test:types": "tsc --p ./tsconfig.json --noEmit" + }, + "devDependencies": { + "@types/node": "catalog:types", + "typescript": "catalog:types" + }, + "engines": { + "node": ">=22.0.0" + }, + "packageManager": "pnpm@11.1.2+sha512.415a1cc25974731e75455c1468371be74c5aa5fb7621b50d4056d222451609f11412f23fd602e6169f1e060466641f798597e1be961a10688836a67b16569499" +} diff --git a/packages/create-typegpu/tsconfig.json b/packages/create-typegpu/tsconfig.json new file mode 100644 index 0000000000..a0d7c79db9 --- /dev/null +++ b/packages/create-typegpu/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "types": ["@types/node"] + }, + "include": ["bin.mjs"], + "exclude": ["node_modules", "dist"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1f2fb169d7..d756bba56c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -484,6 +484,15 @@ importers: specifier: ^2.8.3 version: 2.8.3 + packages/create-typegpu: + devDependencies: + '@types/node': + specifier: ^24.10.0 + version: 24.10.0 + typescript: + specifier: npm:tsover@^6.0.2 + version: tsover@6.0.2 + packages/eslint-plugin: dependencies: '@typescript-eslint/utils':