Skip to content

Commit 7dcb51d

Browse files
authored
feat: add create-rstack package (#233)
1 parent af8e2c4 commit 7dcb51d

23 files changed

Lines changed: 490 additions & 0 deletions

‎packages/create-rstack/LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Rstack contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎packages/create-rstack/README.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# create-rstack
2+
3+
Create a new Rstack project.
4+
5+
## Usage
6+
7+
Using `npm create`:
8+
9+
```bash
10+
npm create rstack@latest
11+
```
12+
13+
Using CLI flags:
14+
15+
```bash
16+
npx create-rstack --dir my-project --template app-ts
17+
18+
# Using abbreviations
19+
npx create-rstack -d my-project -t app-ts
20+
```
21+
22+
## Templates
23+
24+
- `app-js` - JavaScript application
25+
- `app-ts` - TypeScript application
26+
27+
## Documentation
28+
29+
See the [Rstack documentation](https://rstack.rs).
30+
31+
## License
32+
33+
[MIT](https://github.com/rstackjs/rstack-cli/blob/main/LICENSE).

‎packages/create-rstack/bin.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import './dist/index.js';
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "create-rstack",
3+
"version": "3.0.0",
4+
"description": "Create a new Rstack project",
5+
"homepage": "https://rstack.rs",
6+
"bugs": {
7+
"url": "https://github.com/rstackjs/rstack-cli/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/rstackjs/rstack-cli.git",
12+
"directory": "packages/create-rstack"
13+
},
14+
"license": "MIT",
15+
"type": "module",
16+
"exports": {
17+
".": {
18+
"types": "./dist/index.d.ts",
19+
"default": "./dist/index.js"
20+
}
21+
},
22+
"types": "./dist/index.d.ts",
23+
"bin": {
24+
"create-rstack": "./bin.js"
25+
},
26+
"files": [
27+
"template-*/**",
28+
"dist",
29+
"bin.js"
30+
],
31+
"scripts": {
32+
"build": "rs lib",
33+
"dev": "rs lib --watch",
34+
"start": "node ./dist/index.js",
35+
"test": "rs test"
36+
},
37+
"dependencies": {
38+
"@rstackjs/create-toolkit": "catalog:"
39+
},
40+
"devDependencies": {
41+
"@types/node": "catalog:",
42+
"rstack": "workspace:*",
43+
"typescript": "catalog:"
44+
},
45+
"engines": {
46+
"node": ">=22.12.0"
47+
},
48+
"publishConfig": {
49+
"access": "public",
50+
"registry": "https://registry.npmjs.org/"
51+
}
52+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Rstack configuration guide: https://rstack.rs/config
2+
import { define } from 'rstack';
3+
4+
define.lib({
5+
syntax: 'es2023',
6+
});
7+
8+
define.test({
9+
source: {
10+
tsconfigPath: './tests/tsconfig.json',
11+
},
12+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
type Argv,
3+
checkCancel,
4+
create,
5+
type ESLintTemplateName,
6+
type RslintTemplateName,
7+
select,
8+
} from '@rstackjs/create-toolkit';
9+
import path from 'node:path';
10+
11+
const getTemplateName = async ({ template }: Argv): Promise<string> => {
12+
if (typeof template === 'string') {
13+
const [type, language = 'js'] = template.split('-');
14+
return `${type}-${language}`;
15+
}
16+
17+
const language = checkCancel<string>(
18+
await select({
19+
message: 'Select language',
20+
options: [
21+
{ value: 'ts', label: 'TypeScript' },
22+
{ value: 'js', label: 'JavaScript' },
23+
],
24+
}),
25+
);
26+
27+
return `app-${language}`;
28+
};
29+
30+
const mapESLintTemplate = (templateName: string): ESLintTemplateName =>
31+
templateName.endsWith('-ts') ? 'vanilla-ts' : 'vanilla-js';
32+
33+
const mapRslintTemplate = (templateName: string): RslintTemplateName =>
34+
templateName.endsWith('-ts') ? 'vanilla-ts' : 'vanilla-js';
35+
36+
await create({
37+
root: path.join(import.meta.dirname, '..'),
38+
name: 'rstack',
39+
templates: ['app-js', 'app-ts'],
40+
getTemplateName,
41+
mapESLintTemplate,
42+
mapRslintTemplate,
43+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "rstack-app-js",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"build": "rs build",
8+
"dev": "rs dev --open",
9+
"preview": "rs preview"
10+
},
11+
"devDependencies": {
12+
"rstack": "^0.3.5"
13+
}
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @ts-check
2+
// Rstack configuration guide: https://rstack.rs/config
3+
import { define } from 'rstack';
4+
5+
define.app({});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
body {
2+
margin: 0;
3+
color: #fff;
4+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
5+
background-image: linear-gradient(to bottom, #020917, #101725);
6+
}
7+
8+
.content {
9+
display: flex;
10+
min-height: 100vh;
11+
line-height: 1.1;
12+
text-align: center;
13+
flex-direction: column;
14+
justify-content: center;
15+
}
16+
17+
.content h1 {
18+
font-size: 3.6rem;
19+
font-weight: 700;
20+
}
21+
22+
.content p {
23+
font-size: 1.2rem;
24+
font-weight: 400;
25+
opacity: 0.5;
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import './index.css';
2+
3+
const rootElement = document.querySelector('#root');
4+
5+
if (rootElement) {
6+
rootElement.innerHTML = `
7+
<main class="content">
8+
<h1>Rstack</h1>
9+
<p>Start building amazing things with Rstack.</p>
10+
</main>
11+
`;
12+
}

0 commit comments

Comments
 (0)