Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions packages/create-rstack/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Rstack contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions packages/create-rstack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# create-rstack

Create a new Rstack project.

## Usage

Using `npm create`:

```bash
npm create rstack@latest
```

Using CLI flags:

```bash
npx create-rstack --dir my-project --template app-ts

# Using abbreviations
npx create-rstack -d my-project -t app-ts
```

## Templates

- `app-js` - JavaScript application
- `app-ts` - TypeScript application

## Documentation

See the [Rstack documentation](https://rstack.rs).

## License

[MIT](https://github.com/rstackjs/rstack-cli/blob/main/LICENSE).
2 changes: 2 additions & 0 deletions packages/create-rstack/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
import './dist/index.js';
52 changes: 52 additions & 0 deletions packages/create-rstack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "create-rstack",
"version": "3.0.0",
"description": "Create a new Rstack project",
"homepage": "https://rstack.rs",
"bugs": {
"url": "https://github.com/rstackjs/rstack-cli/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rstackjs/rstack-cli.git",
"directory": "packages/create-rstack"
},
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"types": "./dist/index.d.ts",
"bin": {
"create-rstack": "./bin.js"
},
"files": [
"template-*/**",
"dist",
"bin.js"
],
"scripts": {
"build": "rs lib",
"dev": "rs lib --watch",
"start": "node ./dist/index.js",
"test": "rs test"
},
"dependencies": {
"@rstackjs/create-toolkit": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
"rstack": "workspace:*",
"typescript": "catalog:"
},
"engines": {
"node": ">=22.12.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
12 changes: 12 additions & 0 deletions packages/create-rstack/rstack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.lib({
syntax: 'es2023',
});
Comment thread
chenjiahan marked this conversation as resolved.

define.test({
source: {
tsconfigPath: './tests/tsconfig.json',
},
});
43 changes: 43 additions & 0 deletions packages/create-rstack/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
type Argv,
checkCancel,
create,
type ESLintTemplateName,
type RslintTemplateName,
select,
} from '@rstackjs/create-toolkit';
import path from 'node:path';

const getTemplateName = async ({ template }: Argv): Promise<string> => {
if (typeof template === 'string') {
const [type, language = 'js'] = template.split('-');
return `${type}-${language}`;
}

const language = checkCancel<string>(
await select({
message: 'Select language',
options: [
{ value: 'ts', label: 'TypeScript' },
{ value: 'js', label: 'JavaScript' },
],
}),
);

return `app-${language}`;
};

const mapESLintTemplate = (templateName: string): ESLintTemplateName =>
templateName.endsWith('-ts') ? 'vanilla-ts' : 'vanilla-js';

const mapRslintTemplate = (templateName: string): RslintTemplateName =>
templateName.endsWith('-ts') ? 'vanilla-ts' : 'vanilla-js';

await create({
root: path.join(import.meta.dirname, '..'),
name: 'rstack',
templates: ['app-js', 'app-ts'],
getTemplateName,
mapESLintTemplate,
mapRslintTemplate,
});
14 changes: 14 additions & 0 deletions packages/create-rstack/template-app-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "rstack-app-js",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rs build",
"dev": "rs dev --open",
"preview": "rs preview"
},
"devDependencies": {
"rstack": "^0.3.5"
}
}
5 changes: 5 additions & 0 deletions packages/create-rstack/template-app-js/rstack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.app({});
26 changes: 26 additions & 0 deletions packages/create-rstack/template-app-js/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
margin: 0;
color: #fff;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
background-image: linear-gradient(to bottom, #020917, #101725);
}

.content {
display: flex;
min-height: 100vh;
line-height: 1.1;
text-align: center;
flex-direction: column;
justify-content: center;
}

.content h1 {
font-size: 3.6rem;
font-weight: 700;
}

.content p {
font-size: 1.2rem;
font-weight: 400;
opacity: 0.5;
}
12 changes: 12 additions & 0 deletions packages/create-rstack/template-app-js/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './index.css';

const rootElement = document.querySelector('#root');

if (rootElement) {
rootElement.innerHTML = `
<main class="content">
<h1>Rstack</h1>
<p>Start building amazing things with Rstack.</p>
</main>
`;
}
16 changes: 16 additions & 0 deletions packages/create-rstack/template-app-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "rstack-app-ts",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rs build",
"dev": "rs dev --open",
"preview": "rs preview"
},
"devDependencies": {
"@types/node": "^24.13.3",
"rstack": "^0.3.5",
"typescript": "^7.0.2"
}
}
4 changes: 4 additions & 0 deletions packages/create-rstack/template-app-ts/rstack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.app({});
26 changes: 26 additions & 0 deletions packages/create-rstack/template-app-ts/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
margin: 0;
color: #fff;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
background-image: linear-gradient(to bottom, #020917, #101725);
}

.content {
display: flex;
min-height: 100vh;
line-height: 1.1;
text-align: center;
flex-direction: column;
justify-content: center;
}

.content h1 {
font-size: 3.6rem;
font-weight: 700;
}

.content p {
font-size: 1.2rem;
font-weight: 400;
opacity: 0.5;
}
12 changes: 12 additions & 0 deletions packages/create-rstack/template-app-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './index.css';

const rootElement = document.querySelector('#root');

if (rootElement) {
rootElement.innerHTML = `
<main class="content">
<h1>Rstack</h1>
<p>Start building amazing things with Rstack.</p>
</main>
`;
}
22 changes: 22 additions & 0 deletions packages/create-rstack/template-app-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"target": "ES2020",
"noEmit": true,
"skipLibCheck": true,
"types": ["rstack/types", "node"],
"useDefineForClassFields": true,

/* modules */
"moduleDetection": "force",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"resolveJsonModule": true,
"allowImportingTsExtensions": true,

/* type checking */
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["src"]
}
15 changes: 15 additions & 0 deletions packages/create-rstack/template-common/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# AGENTS.md

You are an expert in JavaScript, Rstack, and web application development. You write maintainable, performant, and accessible code.

## Commands

- `{{ packageManager }} run dev` - Start the development server
- `{{ packageManager }} run build` - Build the app for production
- `{{ packageManager }} run preview` - Preview the production build locally

## Docs

- Rstack: https://rstack.rs/llms.txt
- Rsbuild: https://rsbuild.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
34 changes: 34 additions & 0 deletions packages/create-rstack/template-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Rstack project

## Setup

Install the dependencies:

```bash
{{ packageManager }} install
```

## Get started

Start the development server:

```bash
{{ packageManager }} run dev
```

Build the app for production:

```bash
{{ packageManager }} run build
```

Preview the production build locally:

```bash
{{ packageManager }} run preview
```

## Learn more

- [Rstack documentation](https://rstack.rs)
- [Rstack GitHub repository](https://github.com/rstackjs/rstack-cli)
13 changes: 13 additions & 0 deletions packages/create-rstack/template-common/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Local
.DS_Store
*.local
*.log*

# Dist
node_modules
dist/

# IDE
.vscode/*
!.vscode/extensions.json
.idea
Loading