Skip to content
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
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:node/recommended",
"plugin:prettier/recommended"
"plugin:n/recommended",
"plugin:prettier/recommended",
],
plugins: ["prettier"],
env: {
node: true
node: true,
},
rules: {
"prettier/prettier": ["error"]
}
"prettier/prettier": ["error"],
},
};
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## What Changed & Why
Explain what changed and why.

## Related issues
Link to related issues in this or other repositories (if any)

## PR Checklist
- [ ] Add tests
- [ ] Add documentation
- [ ] Prefix documentation-only commits with [DOC]

## People
Mention people who would be interested in the changeset (if any)
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches:
- master
pull_request:

env:
NODE_VERSION: '14.x'

jobs:
test:
name: Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- uses: actions/setup-node@v2-beta
with:
node-version: '${{ env.NODE_VERSION }}'

- name: Get package manager's global cache path
id: global-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache package manager's global cache and node_modules
id: cache-dependencies
uses: actions/cache@v2
with:
path: |
${{ steps.global-cache-dir-path.outputs.dir }}
node_modules
key: v1-${{ runner.os }}-${{ matrix.node-version }}-${{
hashFiles('**/yarn.lock'
) }}
restore-keys: |
v1-${{ runner.os }}-${{ matrix.node-version }}-

- name: Install Dependencies
run: yarn install --no-lockfile
if: |
steps.cache-dependencies.outputs.cache-hit != 'true'

- name: Test
run: yarn test


19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var EmberAddon = require("ember-cli/lib/broccoli/ember-addon"); // eslint-disable-line node/no-unpublished-require
var EmberAddon = require("ember-cli/lib/broccoli/ember-addon"); // eslint-disable-line n/no-unpublished-require

module.exports = function(defaults) {
module.exports = function (defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ var git = require("./lib/git");
module.exports = {
name: "ember-cli-deploy-git",

createDeployPlugin: function(options) {
createDeployPlugin: function (options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
configure: function(context) {
configure: function (context) {
var pluginConfig = context.config[this.name] || {};
return getMyRepo(context)
.then(function(myRepo) {
.then(function (myRepo) {
var worktreePath =
pluginConfig.worktreePath || defaultWorktree(context);
return {
Expand All @@ -23,41 +23,41 @@ module.exports = {
destDir: path.resolve(worktreePath, pluginConfig.destDir || ""),
repo: pluginConfig.repo || myRepo,
branch: pluginConfig.branch || "gh-pages",
commitMessage: pluginConfig.commitMessage || "Deployed %@"
}
commitMessage: pluginConfig.commitMessage || "Deployed %@",
},
};
})
.catch(showStderr(context.ui));
},
prepare: function(context) {
prepare: function (context) {
var d = context.gitDeploy;
this.log("preparing git in " + d.worktreePath, { verbose: true });
return git
.prepareTree(d.worktreePath, d.myRepo, d.repo, d.branch)
.catch(showStderr(context.ui));
},
upload: function(context) {
upload: function (context) {
var d = context.gitDeploy;
var distDir =
context.distDir || path.join(context.project.root, "dist");
return git
.replaceTree(d.destDir, distDir, d.commitMessage)
.then(function(didCommit) {
.then(function (didCommit) {
if (didCommit) {
return git.push(d.worktreePath, d.repo, d.branch);
} else {
console.log("Nothing to deploy");
}
})
.catch(showStderr(context.ui));
}
},
});
return new DeployPlugin();
}
},
};

function showStderr(ui) {
return function(err) {
return function (err) {
if (err.stderr) {
ui.write(err.stderr);
}
Expand Down
36 changes: 18 additions & 18 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ var copy = fs.copy;

function supportsWorktree() {
return run("git", ["help", "worktree"]).then(
function() {
function () {
return true;
},
function() {
function () {
return false;
}
);
}

function currentRevision() {
return run("git", ["rev-parse", "--short", "HEAD"]).then(function(output) {
return run("git", ["rev-parse", "--short", "HEAD"]).then(function (output) {
return output.stdout;
});
}

function prepareTree(targetDir, myRepo, repo, branch) {
return stat(targetDir).then(
function() {
function () {
return run("git", ["reset", "--hard"], { cwd: targetDir }).then(
function() {
function () {
return run("git", ["pull"], { cwd: targetDir });
}
);
},
function(err) {
function (err) {
if (err.code !== "ENOENT") {
throw err;
}
return supportsWorktree().then(function(useWorktree) {
return supportsWorktree().then(function (useWorktree) {
if (useWorktree && myRepo === repo) {
return run("git", ["worktree", "prune"]).then(function() {
return run("git", ["worktree", "prune"]).then(function () {
return run("git", ["worktree", "add", targetDir, branch]);
});
} else {
Expand All @@ -49,33 +49,33 @@ function prepareTree(targetDir, myRepo, repo, branch) {
function replaceTree(targetDir, ourDir, commitMessage) {
return fs
.ensureDir(targetDir)
.then(function() {
.then(function () {
return run("git", ["rm", "--ignore-unmatch", "-r", "."], {
cwd: targetDir
cwd: targetDir,
});
})
.then(function() {
.then(function () {
return copy(ourDir, targetDir, { stopOnErr: true });
})
.then(function() {
.then(function () {
return run("git", ["add", "-A"], { cwd: targetDir });
})
.then(function() {
.then(function () {
return currentRevision();
})
.then(function(revision) {
.then(function (revision) {
commitMessage = commitMessage.replace(/%@/g, revision);

return run("git", ["commit", "-m", commitMessage], {
cwd: targetDir
}).catch(function(err) {
cwd: targetDir,
}).catch(function (err) {
if (/nothing to commit/.test(err.stdout)) {
return false;
}
throw err;
});
})
.then(function() {
.then(function () {
return true;
});
}
Expand All @@ -85,7 +85,7 @@ function push(targetDir, repo, branch) {
}

function origin(targetDir) {
return run("git", ["remote", "-v"], { cwd: targetDir }).then(function(
return run("git", ["remote", "-v"], { cwd: targetDir }).then(function (
output
) {
var m = /origin\s+(\S+)/.exec(output.stdout);
Expand Down
8 changes: 4 additions & 4 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ var RSVP = require("rsvp");
var spawn = require("child_process").spawn;

function run(command, args, opts) {
return new RSVP.Promise(function(resolve, reject) {
return new RSVP.Promise(function (resolve, reject) {
var p = spawn(command, args, opts || {});
var stderr = "";
var stdout = "";
p.stdout.on("data", function(output) {
p.stdout.on("data", function (output) {
stdout += output;
});
p.stderr.on("data", function(output) {
p.stderr.on("data", function (output) {
stderr += output;
});
p.on("close", function(code) {
p.on("close", function (code) {
if (code !== 0) {
var err = new Error(
command + " " + args.join(" ") + " exited with nonzero status"
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
"author": "Edward Faulkner <ef@alum.mit.edu>",
"license": "MIT",
"devDependencies": {
"ember-cli": "2.18.1",
"ember-cli-dependency-checker": "^2.1.0",
"eslint": "^6.3.0",
"eslint-config-prettier": "^6.2.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2"
"ember-cli": "4.12.1",
"ember-cli-dependency-checker": "^3.3.1",
"ember-source": "~3.28.8",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8"
},
"keywords": [
"ember-addon",
Expand All @@ -34,10 +35,11 @@
"github pages"
],
"dependencies": {
"ember-cli-babel": "^6.11.0",
"ember-cli-babel": "^7.26.11",
"ember-cli-deploy-plugin": "^0.2.9",
"fs-extra": "^5.0.0",
"rsvp": "^4.8.1"
"ember-cli-htmlbars": "^6.2.0",
"fs-extra": "^11.1.1",
"rsvp": "^4.8.5"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
Loading