Skip to content

Commit

Permalink
Write output repo update as JavaScript (Bash 🤕).
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Sep 25, 2019
1 parent 80c68ff commit c5e6483
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 1,235 deletions.
10 changes: 1 addition & 9 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,7 @@ ember serve

### Update Artifacts

* if normal release
* run `./dev/add-to-output-repos.sh`
* if incremental beta release
* run `./dev/add-to-output-repos.sh beta`
* if promoting canary to beta
* run `./dev/add-to-output-repos.sh beta fork`
* copy the [`ember new` diff] and [`ember addon` diff] lines from the previous
release changelog and paste into the current, then update the url with the
newer tags
* run `node ./dev/update-output-repos.js`

### Publish

Expand Down
63 changes: 0 additions & 63 deletions dev/add-to-output-repos.sh

This file was deleted.

68 changes: 68 additions & 0 deletions dev/update-output-repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use strict';

const fs = require('fs-extra');
const path = require('path');
const execa = require('execa');
const tmp = require('tmp');
tmp.setGracefulCleanup();

const currentVersion = require('../package').version;
const EMBER_PATH = require.resolve('../bin/ember');
const isStable = !currentVersion.includes('-beta');

let tmpdir = tmp.dirSync();

async function updateRepo(repoName) {
let command = repoName === 'ember-new-output' ? 'new' : 'addon';
let name = repoName === 'ember-new-output' ? 'my-app' : 'my-addon';
let outputRepoPath = path.join(tmpdir.name, repoName);

let outputRepoBranch = isStable ? 'stable' : 'master';
let shouldUpdateMasterFromStable = currentVersion.endsWith('-beta.1');
let branchToClone = shouldUpdateMasterFromStable ? 'stable' : outputRepoBranch;

console.log(`cloning ${repoName}`);
await execa('git', ['clone', `git@github.com:ember-cli/${repoName}.git`, `--branch=${branchToClone}`], {
cwd: tmpdir.name,
});

console.log(`clearing ${repoName}`);
await execa(`git`, [`rm`, `-rf`, `.`], {
cwd: path.join(tmpdir.name, repoName),
});

let updatedOutputTmpDir = tmp.dirSync();
console.log(`Running ember ${command} ${name}`);
await execa(EMBER_PATH, [command, name, `--skip-bower`, `--skip-npm`, `--skip-git`], {
cwd: updatedOutputTmpDir.name,
});

let generatedOutputPath = path.join(updatedOutputTmpDir.name, name);

console.log('copying generated contents to output repo');
await fs.copy(generatedOutputPath, outputRepoPath);

if (shouldUpdateMasterFromStable) {
await execa('git', ['checkout', '-B', 'master'], { cwd: outputRepoPath });
}

console.log('commiting updates');
await execa('git', ['add', '--all'], { cwd: outputRepoPath });
await execa('git', ['commit', '-m', currentVersion], { cwd: outputRepoPath });
await execa('git', ['tag', `v${currentVersion}`], { cwd: outputRepoPath });

console.log('pushing commit & tag');
await execa('git', ['push', 'origin', `v${currentVersion}`], { cwd: outputRepoPath });
await execa('git', ['push', '--force', 'origin', outputRepoBranch], { cwd: outputRepoPath });
}

async function main() {
try {
await updateRepo('ember-new-output');
await updateRepo('ember-addon-output');
} catch (error) {
console.log(error);
}
}

main();
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"broccoli-middleware": "^2.1.0",
"broccoli-module-normalizer": "^1.3.0",
"broccoli-module-unification-reexporter": "^1.0.0",
"broccoli-source": "^3.0.0",
"broccoli-slow-trees": "^3.0.1",
"broccoli-source": "^3.0.0",
"broccoli-stew": "^3.0.0",
"calculate-cache-key-for-tree": "^2.0.0",
"capture-exit": "^2.0.0",
Expand Down Expand Up @@ -154,8 +154,9 @@
"rimraf": "^2.6.3",
"strip-ansi": "^5.2.0",
"supertest": "^4.0.2",
"testdouble": "^3.12.2",
"websocket": "^1.0.29",
"testdouble": "^3.12.4",
"tmp": "^0.1.0",
"websocket": "^1.0.30",
"which": "1.3.1",
"yuidoc-ember-cli-theme": "^1.0.4",
"yuidocjs": "0.10.2"
Expand Down
Loading

0 comments on commit c5e6483

Please sign in to comment.