File tree Expand file tree Collapse file tree 5 files changed +41
-8
lines changed
packages/monorepo/src/monorepo Expand file tree Collapse file tree 5 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @icebreakers/monorepo " : patch
3+ ---
4+
5+ fix: add setChangeset for ` script:init `
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -2,16 +2,18 @@ import fs from 'fs-extra'
22import path from 'pathe'
33import 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
1315export 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 )
Original file line number Diff line number Diff line change 11import { createContext } from './context'
2+ import setChangeset from './setChangeset'
23import setPkgJson from './setPkgJson'
34import setReadme from './setReadme'
45
56export 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments