metapak-sencrop
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -0,1 +1,11 @@ | ||
<a name="4.0.1"></a> | ||
## [4.0.1](https://github.com/sencrop/metapak-sencrop/compare/v4.0.0...v4.0.1) (2018-02-05) | ||
### Bug Fixes | ||
* **Build:** Fix various issues with the last build ([12a540f](https://github.com/sencrop/metapak-sencrop/commit/12a540f)) | ||
<a name="4.0.0"></a> | ||
@@ -2,0 +12,0 @@ # [4.0.0](https://github.com/sencrop/metapak-sencrop/compare/v3.0.2...v4.0.0) (2018-02-01) |
{ | ||
"name": "metapak-sencrop", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "A `metapak` plugin for Sencrop projects", | ||
@@ -11,4 +11,4 @@ "main": "index.js", | ||
"readme", | ||
"oss", | ||
"eslint" | ||
"eslint", | ||
"oss" | ||
], | ||
@@ -24,5 +24,4 @@ "data": { | ||
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz", | ||
"lint": "echo \"WARNING: No linter configured\"", | ||
"metapak": "metapak || exit 0", | ||
"postinstall": "npm run metapak --silent", | ||
"lint": "eslint src/**/*.js", | ||
"metapak": "metapak", | ||
"prettier": "prettier --write src/**/*.js", | ||
@@ -54,3 +53,3 @@ "preversion": "npm t && npm run lint", | ||
"jest": "^22.1.4", | ||
"metapak": "0.0.21", | ||
"metapak": "^1.0.2", | ||
"prettier": "^1.10.2", | ||
@@ -57,0 +56,0 @@ "sinon": "^4.2.2" |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -10,17 +10,17 @@ module.exports = packageConf => { | ||
if (!metapakData.files) { | ||
throw new Error("E_NO_FILES"); | ||
throw new Error('E_NO_FILES'); | ||
} | ||
packageConf.scripts = packageConf.scripts || {}; | ||
packageConf.scripts.lint = "eslint " + metapakData.files; | ||
packageConf.scripts.prettier = "prettier --write " + metapakData.files; | ||
packageConf.scripts.lint = 'eslint ' + metapakData.files; | ||
packageConf.scripts.prettier = 'prettier --write ' + metapakData.files; | ||
// Add the MUST HAVE dev dependencies | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.eslint = "^4.16.0"; | ||
delete packageConf.devDependencies["eslint-config-simplifield"]; | ||
packageConf.devDependencies.prettier = "^1.10.2"; | ||
packageConf.devDependencies["eslint-plugin-prettier"] = "^2.5.0"; | ||
packageConf.devDependencies.eslint = '^4.16.0'; | ||
delete packageConf.devDependencies['eslint-config-simplifield']; | ||
packageConf.devDependencies.prettier = '^1.10.2'; | ||
packageConf.devDependencies['eslint-plugin-prettier'] = '^2.5.0'; | ||
return packageConf; | ||
}; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
describe('Main', () => { | ||
describe('Package transformer', () => { | ||
test('should work with an empty package.json', () => { | ||
expect( | ||
@@ -12,5 +12,5 @@ packageTransformer({ | ||
data: { | ||
files: "lol.js" | ||
} | ||
} | ||
files: 'lol.js', | ||
}, | ||
}, | ||
}) | ||
@@ -17,0 +17,0 @@ ).toMatchSnapshot(); |
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
'use strict'; | ||
const PRE_COMMIT_ARCHITECTURE = | ||
"npm run architecture && git add ARCHITECTURE.md || exit 1"; | ||
'npm run architecture && git add ARCHITECTURE.md || exit 1'; | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_ARCHITECTURE); | ||
hooks['pre-commit'] = hooks['pre-commit'] || []; | ||
hooks['pre-commit'].push(PRE_COMMIT_ARCHITECTURE); | ||
return hooks; | ||
}; |
@@ -1,23 +0,23 @@ | ||
"use strict"; | ||
'use strict'; | ||
const PRE_COMMIT_ARCHITECTURE = | ||
"npm run architecture && git add ARCHITECTURE.md || exit 1"; | ||
const assert = require("assert"); | ||
const hooksTransformer = require("./hooks"); | ||
'npm run architecture && git add ARCHITECTURE.md || exit 1'; | ||
const assert = require('assert'); | ||
const hooksTransformer = require('./hooks'); | ||
describe("Architecture", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
describe('Architecture', () => { | ||
describe('Hooks transformer', () => { | ||
it('should add pre-commit hooks', () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"pre-commit": [PRE_COMMIT_ARCHITECTURE] | ||
'pre-commit': [PRE_COMMIT_ARCHITECTURE], | ||
}); | ||
}); | ||
it("should leave existing pre-commit hooks", () => { | ||
it('should leave existing pre-commit hooks', () => { | ||
assert.deepEqual( | ||
hooksTransformer({ | ||
"pre-commit": ["npm t"] | ||
'pre-commit': ['npm t'], | ||
}), | ||
{ | ||
"pre-commit": ["npm t", PRE_COMMIT_ARCHITECTURE] | ||
'pre-commit': ['npm t', PRE_COMMIT_ARCHITECTURE], | ||
} | ||
@@ -24,0 +24,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -12,8 +12,8 @@ module.exports = packageConf => { | ||
packageConf.scripts.architecture = | ||
"jsarch " + metapakData.files + " > ARCHITECTURE.md"; | ||
'jsarch ' + metapakData.files + ' > ARCHITECTURE.md'; | ||
// Add doc deps | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.jsarch = "1.2.7"; | ||
packageConf.devDependencies.jsarch = '1.2.7'; | ||
return packageConf; | ||
}; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("Architecture", () => { | ||
describe("Package transformer for jsdocs", () => { | ||
it("should work with an empty package.json", () => { | ||
describe('Architecture', () => { | ||
describe('Package transformer for jsdocs', () => { | ||
it('should work with an empty package.json', () => { | ||
expect( | ||
@@ -12,5 +12,5 @@ packageTransformer({ | ||
data: { | ||
files: "yolo.js" | ||
} | ||
} | ||
files: 'yolo.js', | ||
}, | ||
}, | ||
}) | ||
@@ -17,0 +17,0 @@ ).toMatchSnapshot(); |
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
const PRE_COMMIT_DOC = "npm run doc && git add .readme/API.md"; | ||
const PRE_COMMIT_DOC = 'npm run doc && git add .readme/API.md'; | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_DOC); | ||
hooks['pre-commit'] = hooks['pre-commit'] || []; | ||
hooks['pre-commit'].push(PRE_COMMIT_DOC); | ||
return hooks; | ||
}; |
@@ -1,23 +0,23 @@ | ||
"use strict"; | ||
'use strict'; | ||
const PRE_COMMIT_DOC = "npm run doc && git add .readme/API.md"; | ||
const PRE_COMMIT_DOC = 'npm run doc && git add .readme/API.md'; | ||
const assert = require("assert"); | ||
const hooksTransformer = require("./hooks"); | ||
const assert = require('assert'); | ||
const hooksTransformer = require('./hooks'); | ||
describe("JSDocs", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
describe('JSDocs', () => { | ||
describe('Hooks transformer', () => { | ||
it('should add pre-commit hooks', () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"pre-commit": [PRE_COMMIT_DOC] | ||
'pre-commit': [PRE_COMMIT_DOC], | ||
}); | ||
}); | ||
it("should leave existing pre-commit hooks", () => { | ||
it('should leave existing pre-commit hooks', () => { | ||
assert.deepEqual( | ||
hooksTransformer({ | ||
"pre-commit": ["npm t"] | ||
'pre-commit': ['npm t'], | ||
}), | ||
{ | ||
"pre-commit": ["npm t", PRE_COMMIT_DOC] | ||
'pre-commit': ['npm t', PRE_COMMIT_DOC], | ||
} | ||
@@ -24,0 +24,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -12,13 +12,13 @@ module.exports = packageConf => { | ||
packageConf.scripts.doc = | ||
"mkdir -p .readme;" + | ||
'mkdir -p .readme;' + | ||
' echo "# API" > .readme/API.md;' + | ||
" jsdoc2md " + | ||
' jsdoc2md ' + | ||
metapakData.files + | ||
" >> .readme/API.md"; | ||
' >> .readme/API.md'; | ||
// Add doc deps | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies["jsdoc-to-markdown"] = "^4.0.1"; | ||
packageConf.devDependencies['jsdoc-to-markdown'] = '^4.0.1'; | ||
return packageConf; | ||
}; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("JSDocs", () => { | ||
describe("Package transformer for jsdocs", () => { | ||
it("should work with an empty package.json", () => { | ||
describe('JSDocs', () => { | ||
describe('Package transformer for jsdocs', () => { | ||
it('should work with an empty package.json', () => { | ||
expect( | ||
@@ -12,5 +12,5 @@ packageTransformer({ | ||
data: { | ||
files: "yolo.js" | ||
} | ||
} | ||
files: 'yolo.js', | ||
}, | ||
}, | ||
}) | ||
@@ -17,0 +17,0 @@ ).toMatchSnapshot(); |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
const config = require("../config.js"); | ||
const config = require('../config.js'); | ||
@@ -15,3 +15,3 @@ const TEXT_SNIPPET = `# This file is automatically generated by a | ||
`; | ||
const JS_SNIPPET = TEXT_SNIPPET.replace(/(\n|^)# /g, "\n// "); | ||
const JS_SNIPPET = TEXT_SNIPPET.replace(/(\n|^)# /g, '\n// '); | ||
@@ -25,8 +25,8 @@ module.exports = (file, packageConf) => { | ||
// Rename dot files the right way | ||
if (file.name.startsWith("_dot_")) { | ||
file.name = file.name.replace("_dot_", "."); | ||
if (file.name.startsWith('_dot_')) { | ||
file.name = file.name.replace('_dot_', '.'); | ||
} | ||
// Add NodeJS LTS where needed | ||
if ([".github/ISSUE_TEMPLATE.md"].includes(file.name)) { | ||
if (['.github/ISSUE_TEMPLATE.md'].includes(file.name)) { | ||
file.data = file.data.replace(/<lastNodeLTS>/gm, config.lastNodeLTS); | ||
@@ -37,3 +37,3 @@ } | ||
if ( | ||
file.name.endsWith(".gitignore") && | ||
file.name.endsWith('.gitignore') && | ||
metapakData.ignore && | ||
@@ -44,20 +44,20 @@ metapakData.ignore.length | ||
file.data + | ||
"# Project custom ignored file\n" + | ||
metapakData.ignore.join("\n") + | ||
"\n"; | ||
'# Project custom ignored file\n' + | ||
metapakData.ignore.join('\n') + | ||
'\n'; | ||
} | ||
// Add snippets | ||
if (file.name.endsWith(".md") || file.name.endsWith(".html")) { | ||
if (file.name.endsWith('.md') || file.name.endsWith('.html')) { | ||
file.data = HTML_SNIPPET + file.data; | ||
} else if ( | ||
file.name.endsWith(".yml") || | ||
file.name.endsWith(".sh") || | ||
file.name.endsWith(".txt") || | ||
file.name.endsWith(".editorconfig") || | ||
file.name.endsWith(".gitattributes") || | ||
file.name.endsWith(".gitignore") | ||
file.name.endsWith('.yml') || | ||
file.name.endsWith('.sh') || | ||
file.name.endsWith('.txt') || | ||
file.name.endsWith('.editorconfig') || | ||
file.name.endsWith('.gitattributes') || | ||
file.name.endsWith('.gitignore') | ||
) { | ||
file.data = TEXT_SNIPPET + file.data; | ||
} else if (file.name.endsWith(".js")) { | ||
} else if (file.name.endsWith('.js')) { | ||
file.data = JS_SNIPPET + file.data; | ||
@@ -64,0 +64,0 @@ } |
@@ -1,15 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
const assert = require("assert"); | ||
const assetsTransformer = require("./assets"); | ||
const assert = require('assert'); | ||
const assetsTransformer = require('./assets'); | ||
describe("Main", () => { | ||
describe("Assets transformer", () => { | ||
it("should fill author in the LICENCE file", () => { | ||
describe('Main', () => { | ||
describe('Assets transformer', () => { | ||
it('should fill author in the LICENCE file', () => { | ||
expect( | ||
assetsTransformer( | ||
{ | ||
name: "LICENSE", | ||
name: 'LICENSE', | ||
data: | ||
"The MIT License (MIT)\nCopyright © 2017 <copyright holders>\n" | ||
'The MIT License (MIT)\nCopyright © 2017 <copyright holders>\n', | ||
}, | ||
@@ -21,8 +21,8 @@ {} | ||
it("should let pass other files", () => { | ||
it('should let pass other files', () => { | ||
assert.deepEqual( | ||
assetsTransformer( | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
}, | ||
@@ -32,4 +32,4 @@ {} | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
} | ||
@@ -36,0 +36,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -14,12 +14,12 @@ const COMMIT_MSG_COMMITIZEN_CHECK = ` | ||
fi`; | ||
const PRE_COMMIT_QUALITY_CHECK = "npm run lint || exit 1"; | ||
const PRE_COMMIT_METAPAK_RUN = "npm run metapak || exit 1"; | ||
const PRE_COMMIT_QUALITY_CHECK = 'npm run lint || exit 1'; | ||
const PRE_COMMIT_METAPAK_RUN = 'npm run metapak || exit 1'; | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_METAPAK_RUN); | ||
hooks["pre-commit"].push(PRE_COMMIT_QUALITY_CHECK); | ||
hooks["commit-msg"] = hooks["commit-msg"] || []; | ||
hooks["commit-msg"].push(COMMIT_MSG_COMMITIZEN_CHECK); | ||
hooks['pre-commit'] = hooks['pre-commit'] || []; | ||
hooks['pre-commit'].push(PRE_COMMIT_METAPAK_RUN); | ||
hooks['pre-commit'].push(PRE_COMMIT_QUALITY_CHECK); | ||
hooks['commit-msg'] = hooks['commit-msg'] || []; | ||
hooks['commit-msg'].push(COMMIT_MSG_COMMITIZEN_CHECK); | ||
return hooks; | ||
}; |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
const assert = require("assert"); | ||
const hooksTransformer = require("./hooks"); | ||
const assert = require('assert'); | ||
const hooksTransformer = require('./hooks'); | ||
@@ -17,11 +17,11 @@ const COMMIT_MSG_COMMITIZEN_CHECK = ` | ||
fi`; | ||
const PRE_COMMIT_QUALITY_CHECK = "npm run lint || exit 1"; | ||
const PRE_COMMIT_METAPAK_RUN = "npm run metapak || exit 1"; | ||
const PRE_COMMIT_QUALITY_CHECK = 'npm run lint || exit 1'; | ||
const PRE_COMMIT_METAPAK_RUN = 'npm run metapak || exit 1'; | ||
describe("Main", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
describe('Main', () => { | ||
describe('Hooks transformer', () => { | ||
it('should add pre-commit hooks', () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"pre-commit": [PRE_COMMIT_METAPAK_RUN, PRE_COMMIT_QUALITY_CHECK], | ||
"commit-msg": [COMMIT_MSG_COMMITIZEN_CHECK] | ||
'pre-commit': [PRE_COMMIT_METAPAK_RUN, PRE_COMMIT_QUALITY_CHECK], | ||
'commit-msg': [COMMIT_MSG_COMMITIZEN_CHECK], | ||
}); | ||
@@ -28,0 +28,0 @@ }); |
@@ -1,15 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
const config = require("../config.js"); | ||
const config = require('../config.js'); | ||
const GITHUB_REPOSITORY_REGEXP = /git\+https:\/\/github.com\/([a-zA-Z0-9\-]+)\/([a-zA-Z0-9\-]+)\.git/; | ||
const GITHUB_REPOSITORY_REGEXP = /git\+https:\/\/github.com\/([a-zA-Z0-9-]+)\/([a-zA-Z0-9-]+)\.git/; | ||
module.exports = packageConf => { | ||
packageConf.license = "SEE LICENSE IN LICENSE.md"; | ||
packageConf.license = 'SEE LICENSE IN LICENSE.md'; | ||
// Let's always start with the 0.0.0 version | ||
packageConf.version = packageConf.version || "0.0.0"; | ||
packageConf.version = packageConf.version || '0.0.0'; | ||
// Supporting Node LTS version only | ||
packageConf.engines = { node: ">=" + config.lastNodeLTS }; | ||
packageConf.engines = { node: '>=' + config.lastNodeLTS }; | ||
@@ -21,10 +21,10 @@ // Let's add my handy scripts | ||
// without having global modules | ||
packageConf.scripts.cli = "env NODE_ENV=${NODE_ENV:-cli}"; | ||
packageConf.scripts.cli = 'env NODE_ENV=${NODE_ENV:-cli}'; | ||
// Lets use commitizen | ||
packageConf.scripts.cz = "env NODE_ENV=${NODE_ENV:-cli} git cz"; | ||
packageConf.scripts.cz = 'env NODE_ENV=${NODE_ENV:-cli} git cz'; | ||
packageConf.config = { | ||
commitizen: { | ||
path: "./node_modules/cz-conventional-changelog" | ||
} | ||
path: './node_modules/cz-conventional-changelog', | ||
}, | ||
}; | ||
@@ -34,4 +34,4 @@ | ||
packageConf.scripts.changelog = | ||
"conventional-changelog -p angular -i CHANGELOG.md -s"; | ||
packageConf.scripts.version = "npm run changelog && git add CHANGELOG.md"; | ||
'conventional-changelog -p angular -i CHANGELOG.md -s'; | ||
packageConf.scripts.version = 'npm run changelog && git add CHANGELOG.md'; | ||
packageConf.scripts.lint = 'echo "WARNING: No linter configured"'; | ||
@@ -41,5 +41,5 @@ packageConf.scripts.preversion = packageConf.scripts.preversion | ||
(/(^| && )npm run lint($| && )/.test(packageConf.scripts.preversion) | ||
? "" | ||
: " && npm run lint") | ||
: "npm run lint"; | ||
? '' | ||
: ' && npm run lint') | ||
: 'npm run lint'; | ||
// Add the MUST HAVE dependencies: | ||
@@ -50,9 +50,9 @@ packageConf.dependencies = packageConf.dependencies || {}; | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.commitizen = "^2.9.6"; | ||
packageConf.devDependencies["cz-conventional-changelog"] = "^2.1.0"; | ||
packageConf.devDependencies["conventional-changelog-cli"] = "^1.3.8"; | ||
packageConf.devDependencies.commitizen = '^2.9.6'; | ||
packageConf.devDependencies['cz-conventional-changelog'] = '^2.1.0'; | ||
packageConf.devDependencies['conventional-changelog-cli'] = '^1.3.8'; | ||
// This job is already done by NPM, but once,. | ||
// This allows to do it on old repositories | ||
if (packageConf.repository && "git" === packageConf.repository.type) { | ||
if (packageConf.repository && 'git' === packageConf.repository.type) { | ||
const [, userName, repositoryName] = | ||
@@ -62,7 +62,8 @@ GITHUB_REPOSITORY_REGEXP.exec(packageConf.repository.url) || []; | ||
packageConf.bugs = packageConf.bugs || { | ||
url: "https://github.com/" + userName + "/" + repositoryName + "/issues" | ||
url: | ||
'https://github.com/' + userName + '/' + repositoryName + '/issues', | ||
}; | ||
packageConf.homepage = | ||
packageConf.homepage || | ||
"https://github.com/" + userName + "/" + repositoryName + "#readme"; | ||
'https://github.com/' + userName + '/' + repositoryName + '#readme'; | ||
} | ||
@@ -69,0 +70,0 @@ } |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
describe('Main', () => { | ||
describe('Package transformer', () => { | ||
test('should work with an empty package.json', () => { | ||
expect( | ||
@@ -12,5 +12,5 @@ packageTransformer({ | ||
data: { | ||
files: "lol.js" | ||
} | ||
} | ||
files: 'lol.js', | ||
}, | ||
}, | ||
}) | ||
@@ -17,0 +17,0 @@ ).toMatchSnapshot(); |
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
module.exports = packageConf => { | ||
packageConf.license = "MIT"; | ||
packageConf.license = 'MIT'; | ||
return packageConf; | ||
}; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
describe('Main', () => { | ||
describe('Package transformer', () => { | ||
test('should work with an empty package.json', () => { | ||
expect(packageTransformer({})).toMatchSnapshot(); | ||
@@ -9,0 +9,0 @@ }); |
@@ -1,29 +0,29 @@ | ||
"use strict"; | ||
'use strict'; | ||
const path = require("path"); | ||
const ORGANISATION_NAME = "sencrop"; | ||
const path = require('path'); | ||
const ORGANISATION_NAME = 'sencrop'; | ||
module.exports = (file, packageConf, { PROJECT_DIR, glob, fs, log }) => { | ||
if ("README.md" === file.name) { | ||
module.exports = (file, packageConf, { PROJECT_DIR, fs, log }) => { | ||
if ('README.md' === file.name) { | ||
// Header | ||
file.data += "# " + packageConf.name + "\n"; | ||
file.data += '# ' + packageConf.name + '\n'; | ||
if (packageConf.description) { | ||
file.data += "> " + packageConf.description + "\n"; | ||
file.data += '> ' + packageConf.description + '\n'; | ||
} | ||
file.data += "\n"; | ||
file.data += '\n'; | ||
return Promise.all([ | ||
file.data, | ||
_getReadmeContents({ PROJECT_DIR, fs, log }), | ||
_getAPIContents({ PROJECT_DIR, fs, log }) | ||
_getAPIContents({ PROJECT_DIR, fs, log }), | ||
]).then(chunks => { | ||
file.data = chunks.filter(_identity).join("\n") + "\n"; | ||
file.data = chunks.filter(_identity).join('\n') + '\n'; | ||
file.data += | ||
"# License\n" + | ||
"[" + | ||
'# License\n' + | ||
'[' + | ||
packageConf.license + | ||
"](https://github.com/" + | ||
'](https://github.com/' + | ||
ORGANISATION_NAME + | ||
"/" + | ||
'/' + | ||
packageConf.name + | ||
"/blob/master/LICENSE.md)\n"; | ||
'/blob/master/LICENSE.md)\n'; | ||
return file; | ||
@@ -37,7 +37,7 @@ }); | ||
function _getReadmeContents({ PROJECT_DIR, fs, log }) { | ||
const filePath = path.join(PROJECT_DIR, ".readme", "contents.md"); | ||
const filePath = path.join(PROJECT_DIR, '.readme', 'contents.md'); | ||
return fs.readFileAsync(filePath, "utf8").catch(err => { | ||
log("error", "Cannot read the README.md file contents:", filePath); | ||
log("stack", err.stack); | ||
return fs.readFileAsync(filePath, 'utf8').catch(err => { | ||
log('error', 'Cannot read the README.md file contents:', filePath); | ||
log('stack', err.stack); | ||
throw err; | ||
@@ -48,8 +48,8 @@ }); | ||
function _getAPIContents({ PROJECT_DIR, fs, log }) { | ||
const filePath = path.join(PROJECT_DIR, ".readme", "API.md"); | ||
const filePath = path.join(PROJECT_DIR, '.readme', 'API.md'); | ||
return fs.readFileAsync(filePath, "utf8").catch(err => { | ||
log("debug", "Cannot read the API.md file contents:", filePath); | ||
log("debug", err.stack); | ||
return ""; | ||
return fs.readFileAsync(filePath, 'utf8').catch(err => { | ||
log('debug', 'Cannot read the API.md file contents:', filePath); | ||
log('debug', err.stack); | ||
return ''; | ||
}); | ||
@@ -56,0 +56,0 @@ } |
@@ -1,16 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
const assert = require("assert"); | ||
const sinon = require("sinon"); | ||
const assetsTransformer = require("./assets"); | ||
const assert = require('assert'); | ||
const sinon = require('sinon'); | ||
const assetsTransformer = require('./assets'); | ||
describe("Readme", () => { | ||
describe("Assets transformer for www configs", () => { | ||
it("should build the README.md file", done => { | ||
describe('Readme', () => { | ||
describe('Assets transformer for www configs', () => { | ||
it('should build the README.md file', done => { | ||
const fs = { | ||
readFileAsync: sinon.stub() | ||
readFileAsync: sinon.stub(), | ||
}; | ||
const PROJECT_DIR = "/lol/"; | ||
const PROJECT_DIR = '/lol/'; | ||
const log = { | ||
error: sinon.stub | ||
error: sinon.stub, | ||
}; | ||
@@ -20,15 +20,15 @@ | ||
.onFirstCall() | ||
.returns(Promise.resolve("## Usage\nJust require me\n")); | ||
fs.readFileAsync.onSecondCall().returns(Promise.resolve("")); | ||
.returns(Promise.resolve('## Usage\nJust require me\n')); | ||
fs.readFileAsync.onSecondCall().returns(Promise.resolve('')); | ||
assetsTransformer( | ||
{ | ||
name: "README.md", | ||
data: "<!-- something -->\n" | ||
name: 'README.md', | ||
data: '<!-- something -->\n', | ||
}, | ||
{ | ||
name: "module", | ||
description: "A great module!", | ||
name: 'module', | ||
description: 'A great module!', | ||
devDependencies: {}, | ||
license: "MIT" | ||
license: 'MIT', | ||
}, | ||
@@ -38,3 +38,3 @@ { | ||
fs, | ||
log | ||
log, | ||
} | ||
@@ -49,8 +49,8 @@ ) | ||
it("should let pass other files", () => { | ||
it('should let pass other files', () => { | ||
assert.deepEqual( | ||
assetsTransformer( | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
}, | ||
@@ -61,4 +61,4 @@ {}, | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
} | ||
@@ -65,0 +65,0 @@ ); |
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
const PRE_COMMIT_TEST_CHECK = "npm run test || exit 1"; | ||
const PRE_COMMIT_TEST_CHECK = 'npm run test || exit 1'; | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_TEST_CHECK); | ||
hooks['pre-commit'] = hooks['pre-commit'] || []; | ||
hooks['pre-commit'].push(PRE_COMMIT_TEST_CHECK); | ||
return hooks; | ||
}; |
@@ -1,12 +0,12 @@ | ||
"use strict"; | ||
'use strict'; | ||
const assert = require("assert"); | ||
const hooksTransformer = require("./hooks"); | ||
const PRE_COMMIT_TEST_CHECK = "npm run test || exit 1"; | ||
const assert = require('assert'); | ||
const hooksTransformer = require('./hooks'); | ||
const PRE_COMMIT_TEST_CHECK = 'npm run test || exit 1'; | ||
describe("Tests", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
describe('Tests', () => { | ||
describe('Hooks transformer', () => { | ||
it('should add pre-commit hooks', () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"pre-commit": [PRE_COMMIT_TEST_CHECK] | ||
'pre-commit': [PRE_COMMIT_TEST_CHECK], | ||
}); | ||
@@ -13,0 +13,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,18 +6,18 @@ module.exports = packageConf => { | ||
packageConf.scripts = packageConf.scripts || {}; | ||
packageConf.scripts.test = "jest --config=.jest.config.js"; | ||
packageConf.scripts.cover = "jest --config=.jest.config.js --coverage"; | ||
packageConf.scripts.test = 'jest --config=.jest.config.js'; | ||
packageConf.scripts.cover = 'jest --config=.jest.config.js --coverage'; | ||
packageConf.scripts.preversion = packageConf.scripts.preversion | ||
? packageConf.scripts.preversion + | ||
(/(^| && )npm t($| && )/.test(packageConf.scripts.preversion) | ||
? "" | ||
: " && npm t") | ||
: "npm t"; | ||
? '' | ||
: ' && npm t') | ||
: 'npm t'; | ||
// Add the testing dev dependencies | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.jest = "^22.1.4"; | ||
packageConf.devDependencies.sinon = "^4.2.2"; | ||
packageConf.devDependencies.istanbul = "^0.4.5"; | ||
packageConf.devDependencies.jest = '^22.1.4'; | ||
packageConf.devDependencies.sinon = '^4.2.2'; | ||
packageConf.devDependencies.istanbul = '^0.4.5'; | ||
return packageConf; | ||
}; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
const packageTransformer = require("./package"); | ||
const packageTransformer = require('./package'); | ||
describe("Tests", () => { | ||
describe("Package transformer", () => { | ||
it("should work with an empty package.json", () => { | ||
describe('Tests', () => { | ||
describe('Package transformer', () => { | ||
it('should work with an empty package.json', () => { | ||
expect(packageTransformer({})).toMatchSnapshot(); | ||
@@ -9,0 +9,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
618
0
0
38889
61