Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename packageJsons to filesToBump #209

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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