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

Added Bitbucket support #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ Because your `CRAFT_PLUGINS` are added as submodules, when you want to `git clon

If you want to update the submodules in your repo, do `git submodule foreach git pull origin master` and it'll update all of your submodules for you.

### BITBUCKET_ACCOUNT

To use Bitbucket to store your site in a git repo, add your Bitbucket information to `BITBUCKET_ACCTOUNT`. This will create the repo on Bitbucket—using your `appName`—and make the first commit.

By default, this creates a private repo, but you can change this in the settings. Here's an example:

```
"BITBUCKET_ACCOUNT": [
{
"user": "username",
"password": "password",
"repoOwner": "repoowner",
"isPrivate": "true",
"forkPolicy": "no_public_forks"
}
],
```

### END_INSTALL_COMMANDS

A list of arbitrary shell commands to execute in sequence at the [ End ] phase of the generator
Expand Down
27 changes: 27 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,33 @@ module.exports = yo.generators.Base.extend({
console.log(chalk.green('> Pushing git repository to origin master'));
child_process.execSync('git push origin master');
}

/* -- Create a repository on BitBucket */

for (var i = 0; i < this.install.BITBUCKET_ACCOUNT.length; i++) {
var bitbucket = this.install.BITBUCKET_ACCOUNT[i];

console.log(chalk.green('> Creating BitBucket repo'));
child_process.execSync('curl -X POST -v -u ' + bitbucket.user + ':' + bitbucket.password + ' -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/' + bitbucket.repoOwner + '/' + this.answers.appName.toLowerCase() + ' -d \'{"scm": "git", "is_private": "' + bitbucket.isPrivate + '", "fork_policy": "' + bitbucket.forkPolicy + '" }\'');

/* -- Initialize the local git directory, add all of the files, commit them, and push them to origin master */

console.log(chalk.green('> Making first commit'));
child_process.execSync('git init');
child_process.execSync('git remote add origin https://' + bitbucket.user + '@bitbucket.org/' + bitbucket.repoOwner + '/' + this.answers.appName.toLowerCase() + '.git');
for (var i = 0; i < this.install.CRAFT_PLUGINS.length; i++) {
var plugin = this.install.CRAFT_PLUGINS[i];
console.log('+ ' + chalk.green(plugin.name) + ' added as submodule');
child_process.execSync('git submodule add -f ' + plugin.url + ' ' + plugin.path);
}
console.log(chalk.green('> Adding project files to git repository'));
child_process.execSync('git add -A');
child_process.execSync('git add -f craft/storage/.gitignore');
console.log(chalk.green('> Doing initial commit to git repository'));
child_process.execSync('git commit -m "initial commit"');
console.log(chalk.green('> Pushing git repository to origin master'));
child_process.execSync('git push origin master');
}

/* -- Install Bower modules */

Expand Down
2 changes: 2 additions & 0 deletions app/templates/advanced_craft_install.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
}
],
"REMOTE_GIT_ORIGIN": "",
"BITBUCKET_ACCOUNT": [
],
"BOWER_OPTIONS": [
],
"NPM_OPTIONS": [
Expand Down
2 changes: 2 additions & 0 deletions app/templates/basic_craft_install.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"CRAFT_PLUGINS": [
],
"REMOTE_GIT_ORIGIN": "",
"BITBUCKET_ACCOUNT": [
],
"BOWER_OPTIONS": [
],
"NPM_OPTIONS": [
Expand Down