Skip to content

Commit

Permalink
feat: rename packageJsons to filesToBump (#209)
Browse files Browse the repository at this point in the history
This is a breaking change, but we're not bumping the major version of Ship.js because we're still in beta.
  • Loading branch information
Eunjae Lee authored Aug 21, 2019
1 parent a4c769c commit 5753300
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Let's say you have the following package.json files:

```js
module.exports = {
packageJsons: [
filesToBump: [
"package.json",
"packages/first-package/package.json",
"packages/second-package/package.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs-lib/src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
remote: 'origin',
packageJsons: ['package.json'],
filesToBump: ['package.json'],
updateChangelog: true,
conventionalChangelogArgs: '-p angular -i CHANGELOG.md -s',
installCommand: ({ isYarn }) => (isYarn ? 'yarn install' : 'npm install'),
Expand Down
4 changes: 2 additions & 2 deletions packages/shipjs-lib/src/lib/util/getAppName.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { resolve } from 'path';
import loadConfig from '../config/loadConfig';

export default function getAppName(dir = '.') {
const { appName, packageJsons } = loadConfig(dir);
const { appName, filesToBump } = loadConfig(dir);
if (appName) {
return appName;
}
const { name } = JSON.parse(readFileSync(resolve(dir, packageJsons[0])));
const { name } = JSON.parse(readFileSync(resolve(dir, filesToBump[0])));
return name;
}
4 changes: 2 additions & 2 deletions packages/shipjs-lib/src/lib/util/getCurrentVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolve } from 'path';
import loadConfig from '../config/loadConfig';

export default function getCurrentVersion(dir = '.') {
const { packageJsons } = loadConfig(dir);
const { version } = JSON.parse(readFileSync(resolve(dir, packageJsons[0])));
const { filesToBump } = loadConfig(dir);
const { version } = JSON.parse(readFileSync(resolve(dir, filesToBump[0])));
return version;
}
6 changes: 3 additions & 3 deletions packages/shipjs-lib/src/lib/util/updateVersion.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';

export default function updateVersion(packageJsons, nextVersion, dir = '.') {
packageJsons.forEach(packageJson => {
const filePath = resolve(dir, packageJson);
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`);
Expand Down
8 changes: 5 additions & 3 deletions packages/shipjs/src/step/prepare/updateVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import wrapExecWithDir from '../../util/wrapExecWithDir';

export default async ({ config, nextVersion, dir, dryRun }) =>
await runStep({ title: 'Updating the version.' }, async ({ print, info }) => {
const { packageJsons, versionUpdated } = config;
const { filesToBump, versionUpdated } = config;
if (dryRun) {
print(`-> ${info(packageJsons.join(', '))}`);
filesToBump.forEach(file => {
print(`-> ${info(file)}`);
});
print(`-> execute ${info('versionUpdated()')} callback.`);
return;
}
updateVersion(packageJsons, nextVersion, dir);
updateVersion(filesToBump, nextVersion, dir);
await versionUpdated({
version: nextVersion,
dir,
Expand Down
2 changes: 1 addition & 1 deletion ship.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
packageJsons: [
filesToBump: [
"package.json",
"packages/shipjs-lib/package.json",
"packages/shipjs/package.json"
Expand Down

0 comments on commit 5753300

Please sign in to comment.