Skip to content

Commit

Permalink
Merge pull request #15 from RocketChat/read-config-from-main-repo
Browse files Browse the repository at this point in the history
Move files to update list to origin repo's package.json
  • Loading branch information
rodrigok authored Mar 14, 2019
2 parents bf4e76c + 6994447 commit 135b9d5
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/set-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ octokit.authenticate({
token: process.env.GITHUB_TOKEN
});

const files = [
'./package.json',
'./.sandstorm/sandstorm-pkgdef.capnp',
'./.travis/snap.sh',
'./.circleci/snap.sh',
'./.circleci/update-releases.sh',
'./.docker/Dockerfile',
'./.docker/Dockerfile.rhel',
'./packages/rocketchat-lib/rocketchat.info'
];
const files = [];

const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
Expand Down Expand Up @@ -63,6 +54,21 @@ class Houston {
return files.length === 0 && ahead === 0 && behind === 0;
}

// read repo config
async readConfig() {
const filePath = path.resolve(process.cwd(), './package.json');
const file = JSON.parse(fs.readFileSync(filePath));
if (!file.houston) {
return;
}
const { houston } = file;
if (houston.updateFiles) {
houston.updateFiles.forEach((file) => {
files.push(file);
});
}
}

async getRemote() {
if (this.owner && this.repo) {
return;
Expand Down Expand Up @@ -207,6 +213,7 @@ class Houston {
await this.selectVersionToUpdate({currentVersion: this.version, release: 'patch'});
await this.createAndGoToBranch({branch: `release-${ this.version }`});
console.log('---\nExecute the cherry picks\n---');
await this.shouldContinue();
await this.updateVersionInFiles();
await this.updateHistory();
await this.shouldPushCurrentBranch();
Expand Down Expand Up @@ -383,8 +390,10 @@ class Houston {
}

async updateVersionInFiles() {
await this.readConfig();

await Promise.all(files.map(async(file) => {
let data = await readFile(file, 'utf8');
let data = await readFile(`./${ file }`, 'utf8');
data = data.replace(this.oldVersion, this.version);
if (file.includes('sandstorm-pkgdef.capnp')) {
data = data.replace(/appVersion\s=\s(\d+),\s\s#\sIncrement/, (s, number) => {
Expand Down

0 comments on commit 135b9d5

Please sign in to comment.