-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write output repo update as JavaScript (Bash 🤕).
- Loading branch information
Showing
5 changed files
with
123 additions
and
1,235 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 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 |
---|---|---|
@@ -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(); |
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.