Skip to content

Commit ed57aad

Browse files
authored
fix(create-rslib): merge AGENTS.md in different tools (#1356)
1 parent a98ed00 commit ed57aad

File tree

11 files changed

+53
-7
lines changed

11 files changed

+53
-7
lines changed

packages/create-rslib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"type-check": "tsc --noEmit"
3131
},
3232
"dependencies": {
33-
"create-rstack": "1.7.9"
33+
"create-rstack": "1.7.11"
3434
},
3535
"devDependencies": {
3636
"@rslib/tsconfig": "workspace:*",

packages/create-rslib/src/helpers.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
4-
import { copyFolder } from 'create-rstack';
4+
import {
5+
collectAgentsFiles,
6+
copyFolder,
7+
mergeAgentsFiles,
8+
} from 'create-rstack';
59

610
const __filename = fileURLToPath(import.meta.url);
711
const __dirname = path.dirname(__filename);
@@ -53,16 +57,26 @@ export function genTemplate({
5357
isMergePackageJson: true,
5458
});
5559

60+
const agentsMdSearchDirs = [];
61+
5662
if (tools) {
5763
for (const tool of toolKeys) {
5864
const toolDir = getTool({ toolDir: tools[tool]! });
65+
agentsMdSearchDirs.push(toolDir);
5966
copyFolder({
6067
from: toolDir,
6168
to: target,
6269
isMergePackageJson: true,
6370
});
6471
}
6572
}
73+
74+
if (agentsMdSearchDirs.length > 1) {
75+
const agentsFiles = collectAgentsFiles(agentsMdSearchDirs);
76+
const mergedAgents = mergeAgentsFiles(agentsFiles);
77+
const agentsPath = path.join(target, 'AGENTS.md');
78+
fs.writeFileSync(agentsPath, `${mergedAgents}\n`);
79+
}
6680
}
6781

6882
interface Template {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Rstest
4+
5+
- Run `{{ packageManager }} run test` to test your code
6+
37
### Storybook
48

59
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Rstest
4+
5+
- Run `{{ packageManager }} run test` to test your code
6+
37
### Storybook
48

59
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Storybook
4+
5+
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
6+
37
### Vitest
48

59
- Run `{{ packageManager }} run test` to test your code
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Storybook
4+
5+
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
6+
37
### Vitest
48

59
- Run `{{ packageManager }} run test` to test your code
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Rstest
4+
5+
- Run `{{ packageManager }} run test` to test your code
6+
37
### Storybook
48

59
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Rstest
4+
5+
- Run `{{ packageManager }} run test` to test your code
6+
37
### Storybook
48

59
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Storybook
4+
5+
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
6+
37
### Vitest
48

59
- Run `{{ packageManager }} run test` to test your code
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Tools
22

3+
### Storybook
4+
5+
- Run `{{ packageManager }} run storybook` to start the Storybook dev server
6+
37
### Vitest
48

59
- Run `{{ packageManager }} run test` to test your code

0 commit comments

Comments
 (0)