Skip to content
Merged
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
20 changes: 20 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
13 changes: 2 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true
},
rules: {
}
};
extends: ['peopledoc/ember-addon']
}
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
---
language: node_js
node_js:
- "4"
- "6"
- "8"
- "10"
- "12"
- "14"

sudo: false

cache:
yarn: true

install:
- yarn install --no-lockfile
- yarn install --non-interactive --pure-lockfile

script:
- yarn test
131 changes: 66 additions & 65 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
/*eslint-env node*/
'use strict';
/* eslint-env node*/
'use strict'

const RSVP = require('rsvp');
const fs = require('fs');
const path = require('path');
const minimatch = require('minimatch');
const jsonfile = require('jsonfile');
const DeployPluginBase = require('ember-cli-deploy-plugin');
const RSVP = require('rsvp')
const path = require('path')
const minimatch = require('minimatch')
const jsonfile = require('jsonfile')
const DeployPluginBase = require('ember-cli-deploy-plugin')

// removes the md5 hash from the filename
function getOriginalFilename(filename) {
return filename.replace(/(-[a-f0-9]{32})(\..+)$/g, '$2');
return filename.replace(/(-[a-f0-9]{32})(\..+)$/g, '$2')
}

module.exports = {
name: 'ember-cli-deploy-index-json',

createDeployPlugin: function(options) {
createDeployPlugin(options) {
let DeployPlugin = DeployPluginBase.extend({
name: options.name,

Expand All @@ -26,89 +25,91 @@ module.exports = {
* http://ember-cli-deploy.com/docs/v1.0.x/creating-a-plugin/#validating-plugin-config
*/

defaultConfig: {
filePattern: '**/*.{js,css,png,gif,ico,jpg,map,xml,txt,svg,swf,eot,ttf,woff,woff2}',
fileIgnorePattern: null,
indexPath: 'index.json',
distDir: function(context) {
return context.distDir;
},
distFiles: function(context) {
return context.distFiles || [];
}
},
defaultConfig: { // eslint-disable-line ember/avoid-leaking-state-in-ember-objects
filePattern: '**/*.{js,css,png,gif,ico,jpg,map,xml,txt,svg,swf,eot,ttf,woff,woff2}',
fileIgnorePattern: null,
indexPath: 'index.json',
distDir(context) {
return context.distDir
},

distFiles(context) {
return context.distFiles || []
}
},

/*
* Implement any pipeline hooks here
*
* http://ember-cli-deploy.com/docs/v1.0.x/pipeline-hooks/
*/

//configure(context) {
// configure(context) {
// let configProp = this.readConfig('foo'); // this is how you access plugin config
//},
// },

//setup(context) {
// setup(context) {
// // Return an object with values you'd like merged in to the context to be accessed by other pipeline hooks and plugins
// return {
// someProp: 'someValue'
// };
//},
// },

willUpload: function(/* context */) {
let filePattern = this.readConfig('filePattern');
let distDir = this.readConfig('distDir');
let distFiles = this.readConfig('distFiles');
let indexPath = this.readConfig('indexPath');
let fileIgnorePattern = this.readConfig('fileIgnorePattern');
willUpload(/* context */) {
let filePattern = this.readConfig('filePattern')
let distDir = this.readConfig('distDir')
let distFiles = this.readConfig('distFiles')
let indexPath = this.readConfig('indexPath')
let fileIgnorePattern = this.readConfig('fileIgnorePattern')

this.log('generating manifest at `' + indexPath + '`', { verbose: true });
this.log(`generating manifest at \`${ indexPath }\``, { verbose: true })
try {
let filesToInclude = distFiles.filter(minimatch.filter(filePattern, { matchBase: true }));
let filesToInclude = distFiles.filter(minimatch.filter(filePattern, { matchBase: true }))
if (fileIgnorePattern != null) {
filesToInclude = filesToInclude.filter(function(path) {
return !minimatch(path, fileIgnorePattern, { matchBase: true });
});
return !minimatch(path, fileIgnorePattern, { matchBase: true })
})
}
filesToInclude.sort();
let mappedFilesToInclude = {};

filesToInclude.sort()
let mappedFilesToInclude = {}
filesToInclude.forEach((filename)=> {
mappedFilesToInclude[getOriginalFilename(filename)] = filename;
});
let outputPath = path.join(distDir, indexPath);
jsonfile.writeFileSync(outputPath, mappedFilesToInclude, { spaces: 2 });
this.log('generated manifest including ' + filesToInclude.length + ' files ok', { verbose: true });
return { indexPath };
} catch (error) {
this.log(error, { color: 'red' });
return RSVP.reject(error);
mappedFilesToInclude[getOriginalFilename(filename)] = filename
})
let outputPath = path.join(distDir, indexPath)
jsonfile.writeFileSync(outputPath, mappedFilesToInclude, { spaces: 2 })
this.log(`generated manifest including ${ filesToInclude.length } files ok`, { verbose: true })
return { indexPath }
} catch(error) {
this.log(error, { color: 'red' })
return RSVP.reject(error)
}
}

//willBuild(context) {},
//build(context) {},
//didBuild(context) {},
// willBuild(context) {},
// build(context) {},
// didBuild(context) {},

//willPrepare(context) {},
//prepare(context) {},
//didPrepare(context) {},
// willPrepare(context) {},
// prepare(context) {},
// didPrepare(context) {},

//willUpload(context) {},
//upload(context) {},
//didUpload(context) {},
// willUpload(context) {},
// upload(context) {},
// didUpload(context) {},

//willActivate(context) {},
//activate(context) {},
//didActivate(context) {},
// willActivate(context) {},
// activate(context) {},
// didActivate(context) {},

//fetchInitialRevisions(context) {},
//fetchRevisions(context) {},
// fetchInitialRevisions(context) {},
// fetchRevisions(context) {},

//didDeploy(context) {},
// didDeploy(context) {},

//teardown(context) {},
});
// teardown(context) {},
})

return new DeployPlugin();
return new DeployPlugin()
}
};
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "tests"
},
"scripts": {
"test": "node tests/runner.js && ./node_modules/.bin/eslint index.js tests/**/*.js"
"test": "node tests/runner.js && ./node_modules/.bin/eslint index.js tests/**/*.js",
"lint": "eslint ."
},
"repository": "https://github.com/peopledoc/ember-cli-deploy-index-json",
"engines": {
Expand All @@ -16,16 +17,18 @@
"author": "The Peopledoc JS Team",
"license": "MIT",
"dependencies": {
"babel-eslint": "^10.1.0",
"ember-cli-deploy-plugin": "^0.2.9",
"eslint-config-peopledoc": "^2.0.2",
"jsonfile": "^4.0.0",
"minimatch": "^3.0.4",
"rsvp": "^3.5.0"
},
"devDependencies": {
"chai-as-promised": "^6.0.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"ember-cli": "^2.12.0",
"eslint": "^4.18.2",
"eslint": "^7.0.0",
"glob": "^7.1.1",
"mocha": "^3.2.0"
},
Expand Down
11 changes: 6 additions & 5 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = {
globals: {
"describe": true,
"before": true,
"beforeEach": true,
"it": true
'describe': true,
'before': true,
'beforeEach': true,
'it': true
},

env: {
embertest: true
}
};
}
10 changes: 5 additions & 5 deletions tests/helpers/assert.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint-env node*/
const chai = require('chai');
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
/* eslint-env node*/
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised)

module.exports = chai.assert;
module.exports = chai.assert
23 changes: 11 additions & 12 deletions tests/runner.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/*eslint-env node*/
'use strict';
/* eslint-env node*/
'use strict'

const glob = require('glob');
const Mocha = require('mocha');
const glob = require('glob')
const Mocha = require('mocha')

const mocha = new Mocha({
reporter: 'spec'
});
})

const arg = process.argv[2];
const root = 'tests/';
const root = 'tests/'

function addFiles(mocha, files) {
glob.sync(root + files).forEach(mocha.addFile.bind(mocha));
glob.sync(root + files).forEach(mocha.addFile.bind(mocha))
}

addFiles(mocha, '/**/*-test.js');
addFiles(mocha, '/**/*-test.js')

mocha.run(function(failures) {
process.on('exit', function() {
process.exit(failures);
});
});
process.exit(failures)
})
})
Loading