-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: remove filesToBump * feat: update versions on each package * feat: run publish command on each package * fix: fix broken test * feat: add readVersionFrom to monorepo config * docs: update guide
- Loading branch information
Eunjae Lee
authored
Sep 6, 2019
1 parent
acd0f13
commit aa96ca9
Showing
30 changed files
with
230 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ | |
"tw2": "yarn workspace shipjs test:watch", | ||
"bootstrap": "./packages/shipjs-lib/tests/bootstrap.sh", | ||
"release:prepare": "npx shipjs prepare", | ||
"release:trigger": "npx shipjs release" | ||
"release:trigger": "npx shipjs release", | ||
"toc": "npx markdown-toc -i --bullets=\"-\" GUIDE.md" | ||
}, | ||
"author": "Algolia <[email protected]>", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/shipjs-lib/src/lib/util/__tests__/expandPackageList.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import silentExec from '../../shell/silentExec'; | ||
import expandPackageList from '../expandPackageList'; | ||
|
||
describe('expandPackageList', () => { | ||
it('expands package list', () => { | ||
silentExec('./tests/bootstrap-examples/simple-monorepo.sh'); | ||
expect(expandPackageList(['.'], 'sandbox/simple-monorepo')).toEqual([ | ||
`${process.cwd()}/sandbox/simple-monorepo`, | ||
]); | ||
|
||
expect( | ||
expandPackageList(['.', 'packages/*'], 'sandbox/simple-monorepo') | ||
).toEqual([ | ||
`${process.cwd()}/sandbox/simple-monorepo`, | ||
`${process.cwd()}/sandbox/simple-monorepo/packages/package_a`, | ||
`${process.cwd()}/sandbox/simple-monorepo/packages/package_b`, | ||
]); | ||
}); | ||
|
||
it('gets only directories with package.json', () => { | ||
silentExec('./tests/bootstrap-examples/monorepo-with-nonpkg-directory.sh'); | ||
const projectName = 'monorepo-with-nonpkg-directory'; | ||
expect( | ||
expandPackageList(['.', 'packages/*'], `sandbox/${projectName}`) | ||
).toEqual([ | ||
`${process.cwd()}/sandbox/${projectName}`, | ||
`${process.cwd()}/sandbox/${projectName}/packages/package_a`, | ||
`${process.cwd()}/sandbox/${projectName}/packages/package_b`, | ||
]); | ||
}); | ||
}); |
9 changes: 0 additions & 9 deletions
9
packages/shipjs-lib/src/lib/util/__tests__/getCurrentVersion.spec.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { resolve, join } from 'path'; | ||
import { statSync, readdirSync, existsSync } from 'fs'; | ||
|
||
const isDirectory = dir => statSync(dir).isDirectory(); | ||
const getDirectories = dir => | ||
readdirSync(dir) | ||
.map(name => join(dir, name)) | ||
.filter(isDirectory); | ||
const hasPackageJson = dir => existsSync(`${dir}/package.json`); | ||
const flatten = arr => arr.reduce((acc, item) => acc.concat(item), []); | ||
|
||
export default function expandPackageList(list, dir = '.') { | ||
return flatten( | ||
list.map(item => { | ||
if (item.endsWith('/*')) { | ||
const basePath = resolve(dir, item.slice(0, item.length - 2)); | ||
return getDirectories(basePath).filter(hasPackageJson); | ||
} else { | ||
return resolve(dir, item); | ||
} | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import loadConfig from '../config/loadConfig'; | ||
|
||
export default function getCurrentVersion(dir = '.') { | ||
const { filesToBump } = loadConfig(dir); | ||
const { version } = JSON.parse(readFileSync(resolve(dir, filesToBump[0]))); | ||
export default function getCurrentVersion( | ||
dir = '.', | ||
filename = 'package.json' | ||
) { | ||
const { version } = JSON.parse(readFileSync(resolve(dir, filename))); | ||
return version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
export default function updateVersion(filesToBump, nextVersion, dir = '.') { | ||
filesToBump.forEach(file => { | ||
const filePath = resolve(dir, file); | ||
const json = JSON.parse(readFileSync(filePath).toString()); | ||
json.version = nextVersion; | ||
writeFileSync(filePath, `${JSON.stringify(json, null, 2)}\n`); | ||
}); | ||
export default function updateVersion(nextVersion, dir = '.') { | ||
const filePath = resolve(dir, 'package.json'); | ||
const json = JSON.parse(readFileSync(filePath).toString()); | ||
json.version = nextVersion; | ||
writeFileSync(filePath, `${JSON.stringify(json, null, 2)}\n`); | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/shipjs-lib/tests/bootstrap-examples/monorepo-with-nonpkg-directory.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
./tests/bootstrap-examples/empty.sh monorepo-with-nonpkg-directory/ && \ | ||
./tests/bootstrap-examples/empty.sh monorepo-with-nonpkg-directory/packages/package_a && \ | ||
./tests/bootstrap-examples/empty.sh monorepo-with-nonpkg-directory/packages/package_b && \ | ||
mkdir sandbox/monorepo-with-nonpkg-directory/packages/not_a_package |
5 changes: 5 additions & 0 deletions
5
packages/shipjs-lib/tests/bootstrap-examples/simple-monorepo.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
./tests/bootstrap-examples/empty.sh simple-monorepo/ && \ | ||
./tests/bootstrap-examples/empty.sh simple-monorepo/packages/package_a && \ | ||
./tests/bootstrap-examples/empty.sh simple-monorepo/packages/package_b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.