Skip to content

Commit ddefa33

Browse files
committed
feat(create-rstack): add library templates
1 parent a01779f commit ddefa33

19 files changed

Lines changed: 291 additions & 10 deletions

File tree

packages/create-rstack/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ npx create-rstack -d my-project -t app-ts
2323

2424
- `app-js` - JavaScript application
2525
- `app-ts` - TypeScript application
26+
- `lib-js` - JavaScript Node.js library
27+
- `lib-ts` - TypeScript Node.js library
2628

2729
## Documentation
2830

packages/create-rstack/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
1414
return `${type}-${language}`;
1515
}
1616

17+
const projectType = checkCancel<string>(
18+
await select({
19+
message: 'Select project type',
20+
options: [
21+
{ value: 'app', label: 'Web Application' },
22+
{ value: 'lib', label: 'Library' },
23+
],
24+
}),
25+
);
26+
1727
const language = checkCancel<string>(
1828
await select({
1929
message: 'Select language',
@@ -24,7 +34,7 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
2434
}),
2535
);
2636

27-
return `app-${language}`;
37+
return `${projectType}-${language}`;
2838
};
2939

3040
const mapESLintTemplate = (templateName: string): ESLintTemplateName =>
@@ -36,7 +46,7 @@ const mapRslintTemplate = (templateName: string): RslintTemplateName =>
3646
await create({
3747
root: path.join(import.meta.dirname, '..'),
3848
name: 'rstack',
39-
templates: ['app-js', 'app-ts'],
49+
templates: ['app-js', 'app-ts', 'lib-js', 'lib-ts'],
4050
builtinTools: [],
4151
getTemplateName,
4252
mapESLintTemplate,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGENTS.md
2+
3+
## Commands
4+
5+
- `{{ packageManager }} run dev` - Start the development server
6+
- `{{ packageManager }} run build` - Build the app for production
7+
- `{{ packageManager }} run preview` - Preview the production build locally
8+
9+
## Docs
10+
11+
- Rsbuild: https://rsbuild.rs/llms.txt
12+
- Rspack: https://rspack.rs/llms.txt
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGENTS.md
2+
3+
## Commands
4+
5+
- `{{ packageManager }} run dev` - Start the development server
6+
- `{{ packageManager }} run build` - Build the app for production
7+
- `{{ packageManager }} run preview` - Preview the production build locally
8+
9+
## Docs
10+
11+
- Rsbuild: https://rsbuild.rs/llms.txt
12+
- Rspack: https://rspack.rs/llms.txt
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# AGENTS.md
22

3-
You are an expert in JavaScript, Rstack, and web application development. You write maintainable, performant, and accessible code.
4-
53
## Commands
64

7-
- `{{ packageManager }} run dev` - Start the development server
8-
- `{{ packageManager }} run build` - Build the app for production
9-
- `{{ packageManager }} run preview` - Preview the production build locally
10-
115
## Docs
126

137
- Rstack: https://rstack.rs/llms.txt
14-
- Rsbuild: https://rsbuild.rs/llms.txt
15-
- Rspack: https://rspack.rs/llms.txt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# AGENTS.md
2+
3+
## Commands
4+
5+
- `{{ packageManager }} run build` - Build the library for production
6+
- `{{ packageManager }} run dev` - Rebuild the library when source files change
7+
- `{{ packageManager }} run test` - Run tests
8+
- `{{ packageManager }} run test:watch` - Run tests in watch mode
9+
10+
## Docs
11+
12+
- Rslib: https://rslib.rs/llms.txt
13+
- Rspack: https://rspack.rs/llms.txt
14+
- Rstest: https://rstest.rs/llms.txt
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Rstack library
2+
3+
## Setup
4+
5+
Install the dependencies:
6+
7+
```bash
8+
{{ packageManager }} install
9+
```
10+
11+
## Get started
12+
13+
Build the library:
14+
15+
```bash
16+
{{ packageManager }} run build
17+
```
18+
19+
Build the library in watch mode:
20+
21+
```bash
22+
{{ packageManager }} run dev
23+
```
24+
25+
Run tests:
26+
27+
```bash
28+
{{ packageManager }} run test
29+
```
30+
31+
Run tests in watch mode:
32+
33+
```bash
34+
{{ packageManager }} run test:watch
35+
```
36+
37+
## Learn more
38+
39+
- [Rstack documentation](https://rstack.rs)
40+
- [Rslib documentation](https://rslib.rs)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "rstack-lib-js",
3+
"version": "0.0.0",
4+
"sideEffects": false,
5+
"type": "module",
6+
"exports": {
7+
".": {
8+
"default": "./dist/index.js"
9+
}
10+
},
11+
"files": [
12+
"dist",
13+
"README.md"
14+
],
15+
"scripts": {
16+
"build": "rs lib",
17+
"dev": "rs lib --watch",
18+
"test": "rs test",
19+
"test:watch": "rs test --watch"
20+
},
21+
"devDependencies": {
22+
"rstack": "^0.3.5"
23+
},
24+
"engines": {
25+
"node": ">=22.12.0"
26+
},
27+
"publishConfig": {
28+
"access": "public"
29+
}
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @ts-check
2+
// Rstack configuration guide: https://rstack.rs/config
3+
import { define } from 'rstack';
4+
5+
define.lib({
6+
syntax: ['node 22'],
7+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const squared = (n) => n * n;

0 commit comments

Comments
 (0)