Skip to content

Commit 70381e3

Browse files
committed
patch: always patch nested projects
1 parent 66a347c commit 70381e3

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

src/bump.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export function monoRepoConfigs(folder: string, includingSelf = true) {
115115
)
116116
}
117117

118-
function collectCurrentVersion(prj: mkc.Project) {
119-
const configs = monoRepoConfigs(prj.directory, true)
118+
function collectCurrentVersion(configs: string[]) {
120119
let version = "0.0.0"
121120
for (const config of configs) {
122121
const cfg = JSON.parse(fs.readFileSync(config, "utf8"))
@@ -139,19 +138,18 @@ export async function bumpAsync(
139138
await needsGitCleanAsync()
140139
await runGitAsync("pull")
141140
}
142-
const cfg = prj.mainPkg.config
143-
const currentVersion = collectCurrentVersion(prj)
141+
const configs = monoRepoConfigs(prj.directory, true)
142+
const currentVersion = collectCurrentVersion(configs)
144143
let newV = currentVersion
145144
if (release)
146145
newV = inc(currentVersion, release)
147146
else
148147
newV = await queryAsync("New version", newV)
149148
const newTag = "v" + newV
150-
cfg.version = newV
151-
152149
mkc.log(`new version: ${newV}`)
153150

154151
if (versionFile) {
152+
const cfg = prj.mainPkg.config
155153
mkc.log(`writing version in ${versionFile}`)
156154
const versionSrc = `
157155
// Auto-generated file: do not edit.
@@ -168,28 +166,13 @@ namespace ${cfg.name
168166
fs.writeFileSync(versionFile, versionSrc, { encoding: "utf-8" })
169167
}
170168

171-
const configs = monoRepoConfigs(prj.directory, false)
172-
if (configs.length > 0) {
173-
if (
174-
(await queryAsync(
175-
`Also update sub-packages (${configs.length}) in this repo?`,
176-
"y"
177-
)) == "y"
178-
) {
179-
for (const fn of configs) {
180-
const cfg0 = JSON.parse(fs.readFileSync(fn, "utf8"))
181-
cfg0.version = newV
182-
fs.writeFileSync(fn, mkc.stringifyConfig(cfg0))
183-
}
184-
}
169+
for (const fn of configs) {
170+
const cfg0 = JSON.parse(fs.readFileSync(fn, "utf8"))
171+
cfg0.version = newV
172+
mkc.debug(`updating ${fn}`)
173+
fs.writeFileSync(fn, mkc.stringifyConfig(cfg0))
185174
}
186175

187-
await files.writeFilesAsync(
188-
prj.directory,
189-
{ "pxt.json": mkc.stringifyConfig(cfg) },
190-
true
191-
)
192-
193176
if (!stage) {
194177
await runGitAsync("commit", "-a", "-m", newV)
195178
await runGitAsync("tag", newTag)

test/pxt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"microbit"
1717
],
1818
"binaryonly": true,
19-
"version": "0.0.1"
19+
"version": "0.7.0"
2020
}

0 commit comments

Comments
 (0)