Skip to content

Commit 5b0f078

Browse files
committed
chore: bump version
1 parent 5d0fd3c commit 5b0f078

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

.changeset/few-islands-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@icebreakers/monorepo": patch
3+
---
4+
5+
fix: add setChangeset for `script:init`

apps/website/index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ layout: doc
2929
>
3030
> 什么! 你不会连 [`nodejs`](https://nodejs.org/en) 还没安装吧?
3131
32-
## 清除默认的包(可选)
32+
## 清除不必要的代码
3333

34-
执行 `pnpm script:clean` 命令,可以删去大部分的初始 `repo`,只保留一个 `@icebreakers/bar` 项目作为发包打包模板。
34+
执行 `pnpm script:clean` 命令,可以删去大部分的初始 `repo`,只保留一个 `@icebreakers/foo` 项目作为发包打包模板。
3535

3636
`clean` 命令执行完成之后,再去执行 `pnpm i` 来更新 `pnpm-lock.yaml`, 并提交 `pnpm-lock.yaml` 文件来锁定 `npm` 包的版本。
3737

38+
## 初始化文件
39+
40+
执行 `pnpm script:init` 命令,这个命令会批量修改你关联的配置文件,并生成一份新的 `README.md`
41+
3842
## 模板包介绍
3943

4044
默认模板被放在根目录的 `packages``apps``2` 个目录里面
@@ -105,9 +109,9 @@ layout: doc
105109

106110
## 创建新的项目
107111

108-
`monorepo` 的任意位置,打开命令行,然后执行 `npx monorepo new` 即可创建一个空的类库,默认目录为 `bar`
112+
`monorepo` 的任意位置,打开命令行,然后执行 `npx monorepo new` 即可创建一个空的类库,默认目录为 `foo`
109113

110-
可通过传入 **可选**参数 `path` 进行修改, 比如 `npx monorepo new [path]`, 此时的目录就从 `bar` 变为了 `[path]`
114+
可通过传入 **可选**参数 `path` 进行修改, 比如 `npx monorepo new [path]`, 此时的目录就从 `foo` 变为了 `[path]`
111115

112116
## 配置同步方式
113117

packages/monorepo/src/monorepo/clean.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import fs from 'fs-extra'
22
import path from 'pathe'
33
import set from 'set-value'
44

5-
const dirs = [
5+
const cleanDirs = [
66
'packages/monorepo',
7-
'packages/foo',
7+
'packages/bar',
8+
'packages/ui',
9+
// 'packages/foo',
810
// 'apps/cli',
911
// 'apps/website',
1012
'apps',
1113
]
1214

1315
export async function cleanProjects(cwd: string) {
14-
for (const dir of dirs.map((x) => {
16+
for (const dir of cleanDirs.map((x) => {
1517
return path.resolve(cwd, x)
1618
})) {
1719
await fs.remove(dir)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { createContext } from './context'
2+
import setChangeset from './setChangeset'
23
import setPkgJson from './setPkgJson'
34
import setReadme from './setReadme'
45

56
export async function init(cwd: string) {
67
const ctx = await createContext(cwd)
7-
8+
await setChangeset(ctx)
89
await setPkgJson(ctx)
910
await setReadme(ctx)
1011
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Context } from './context'
2+
import fs from 'fs-extra'
3+
import path from 'pathe'
4+
import set from 'set-value'
5+
6+
export default async function (ctx: Context) {
7+
const { gitUrl, workspaceFilepath } = ctx
8+
9+
if (gitUrl && await fs.exists(workspaceFilepath)) {
10+
const changesetConfigPath = path.resolve(path.dirname(workspaceFilepath), '.changeset/config.json')
11+
if (await fs.exists(changesetConfigPath)) {
12+
const changesetConfig = await fs.readJson(
13+
changesetConfigPath,
14+
)
15+
if (gitUrl.full_name) {
16+
set(changesetConfig, 'changelog.1.repo', gitUrl.full_name)
17+
await fs.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 })
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)