metapak-sencrop
Advanced tools
Comparing version 3.0.2 to 4.0.0
@@ -6,6 +6,4 @@ | ||
'use strict'; | ||
module.exports = { | ||
extends: 'eslint-config-simplifield/lib/backend', | ||
extends: 'eslint:recommended', | ||
parserOptions: { | ||
@@ -15,9 +13,12 @@ sourceType: 'script', | ||
}, | ||
globals: { | ||
expect: true, | ||
env: { | ||
es6: true, | ||
node: true, | ||
jest: true, | ||
mocha: true, | ||
}, | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-magic-numbers': 0, | ||
'prettier/prettier': 'error', | ||
}, | ||
}; |
@@ -0,1 +1,11 @@ | ||
<a name="4.0.0"></a> | ||
# [4.0.0](https://github.com/sencrop/metapak-sencrop/compare/v3.0.2...v4.0.0) (2018-02-01) | ||
### Features | ||
* **Prettier:** Add prettier and update dependencies ([67b3fa6](https://github.com/sencrop/metapak-sencrop/commit/67b3fa6)) | ||
<a name="3.0.2"></a> | ||
@@ -2,0 +12,0 @@ ## [3.0.2](https://github.com/sencrop/metapak-sencrop/compare/v3.0.1...v3.0.2) (2017-11-08) |
{ | ||
"name": "metapak-sencrop", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"description": "A `metapak` plugin for Sencrop projects", | ||
@@ -11,3 +11,4 @@ "main": "index.js", | ||
"readme", | ||
"oss" | ||
"oss", | ||
"eslint" | ||
], | ||
@@ -26,2 +27,3 @@ "data": { | ||
"postinstall": "npm run metapak --silent", | ||
"prettier": "prettier --write src/**/*.js", | ||
"preversion": "npm t && npm run lint", | ||
@@ -46,10 +48,11 @@ "test": "jest --config=.jest.config.js", | ||
"commitizen": "^2.9.6", | ||
"conventional-changelog-cli": "^1.3.4", | ||
"cz-conventional-changelog": "^2.0.0", | ||
"eslint": "3.16.0", | ||
"eslint-config-simplifield": "4.1.1", | ||
"istanbul": "0.4.5", | ||
"jest": "20.0.4", | ||
"conventional-changelog-cli": "^1.3.8", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"eslint": "^4.16.0", | ||
"eslint-plugin-prettier": "^2.5.0", | ||
"istanbul": "^0.4.5", | ||
"jest": "^22.1.4", | ||
"metapak": "0.0.21", | ||
"sinon": "2.3.8" | ||
"prettier": "^1.10.2", | ||
"sinon": "^4.2.2" | ||
}, | ||
@@ -56,0 +59,0 @@ "engines": { |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
module.exports = { | ||
extends: 'eslint-config-simplifield/lib/backend', | ||
extends: 'eslint:recommended', | ||
parserOptions: { | ||
@@ -9,9 +7,12 @@ sourceType: 'script', | ||
}, | ||
globals: { | ||
expect: true, | ||
env: { | ||
es6: true, | ||
node: true, | ||
jest: true, | ||
mocha: true, | ||
}, | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-magic-numbers': 0, | ||
'prettier/prettier': 'error', | ||
}, | ||
}; |
@@ -1,20 +0,25 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = (packageConf) => { | ||
const metapakData = packageConf.metapak && packageConf.metapak.data ? | ||
packageConf.metapak.data : | ||
{}; | ||
// Let's add my handy scripts | ||
module.exports = packageConf => { | ||
const metapakData = | ||
packageConf.metapak && packageConf.metapak.data | ||
? packageConf.metapak.data | ||
: {}; | ||
if (!metapakData.files) { | ||
throw new Error("E_NO_FILES"); | ||
} | ||
packageConf.scripts = packageConf.scripts || {}; | ||
packageConf.scripts.lint = `eslint ${metapakData.files}`; | ||
packageConf.scripts.lint = "eslint " + metapakData.files; | ||
packageConf.scripts.prettier = "prettier --write " + metapakData.files; | ||
// Add the MUST HAVE dependencies: | ||
packageConf.dependencies = packageConf.dependencies || {}; | ||
// Add the MUST HAVE dev dependencies | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.eslint = '3.16.0'; | ||
packageConf.devDependencies['eslint-config-simplifield'] = '4.1.1'; | ||
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,18 +0,19 @@ | ||
'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', () => { | ||
expect(packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: 'lol.js', | ||
}, | ||
}, | ||
})) | ||
.toMatchSnapshot(); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
expect( | ||
packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: "lol.js" | ||
} | ||
} | ||
}) | ||
).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); | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_ARCHITECTURE); | ||
return hooks; | ||
}; |
@@ -1,33 +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', () => { | ||
assert.deepEqual( | ||
hooksTransformer({}), | ||
{ | ||
'pre-commit': [ | ||
PRE_COMMIT_ARCHITECTURE, | ||
], | ||
} | ||
); | ||
describe("Architecture", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"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] | ||
} | ||
@@ -34,0 +24,0 @@ ); |
@@ -1,16 +0,18 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = (packageConf) => { | ||
const metapakData = packageConf.metapak && packageConf.metapak.data ? | ||
packageConf.metapak.data : | ||
{}; | ||
module.exports = packageConf => { | ||
const metapakData = | ||
packageConf.metapak && packageConf.metapak.data | ||
? packageConf.metapak.data | ||
: {}; | ||
// Adding documentation generation script | ||
packageConf.scripts = packageConf.scripts || {}; | ||
packageConf.scripts.architecture = 'jsarch ' + metapakData.files + ' > ARCHITECTURE.md'; | ||
packageConf.scripts.architecture = | ||
"jsarch " + metapakData.files + " > ARCHITECTURE.md"; | ||
// Add doc deps | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.jsarch = '1.2.2'; | ||
packageConf.devDependencies.jsarch = "1.2.7"; | ||
return packageConf; | ||
}; |
@@ -1,18 +0,19 @@ | ||
'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', () => { | ||
expect(packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: 'yolo.js', | ||
}, | ||
}, | ||
})) | ||
.toMatchSnapshot(); | ||
describe("Architecture", () => { | ||
describe("Package transformer for jsdocs", () => { | ||
it("should work with an empty package.json", () => { | ||
expect( | ||
packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: "yolo.js" | ||
} | ||
} | ||
}) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
@@ -1,10 +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); | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_DOC); | ||
return hooks; | ||
}; |
@@ -1,34 +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', () => { | ||
assert.deepEqual( | ||
hooksTransformer({}), | ||
{ | ||
'pre-commit': [ | ||
PRE_COMMIT_DOC, | ||
], | ||
} | ||
); | ||
describe("JSDocs", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"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] | ||
} | ||
@@ -35,0 +24,0 @@ ); |
@@ -1,19 +0,23 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = (packageConf) => { | ||
const metapakData = packageConf.metapak && packageConf.metapak.data ? | ||
packageConf.metapak.data : | ||
{}; | ||
module.exports = packageConf => { | ||
const metapakData = | ||
packageConf.metapak && packageConf.metapak.data | ||
? packageConf.metapak.data | ||
: {}; | ||
// Adding documentation generation script | ||
packageConf.scripts = packageConf.scripts || {}; | ||
packageConf.scripts.doc = 'mkdir -p .readme;' + | ||
packageConf.scripts.doc = | ||
"mkdir -p .readme;" + | ||
' echo "# API" > .readme/API.md;' + | ||
' jsdoc2md ' + metapakData.files + ' >> .readme/API.md'; | ||
" jsdoc2md " + | ||
metapakData.files + | ||
" >> .readme/API.md"; | ||
// Add doc deps | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies['jsdoc-to-markdown'] = '^3.0.0'; | ||
packageConf.devDependencies["jsdoc-to-markdown"] = "^4.0.1"; | ||
return packageConf; | ||
}; |
@@ -1,18 +0,19 @@ | ||
'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', () => { | ||
expect(packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: 'yolo.js', | ||
}, | ||
}, | ||
})) | ||
.toMatchSnapshot(); | ||
describe("JSDocs", () => { | ||
describe("Package transformer for jsdocs", () => { | ||
it("should work with an empty package.json", () => { | ||
expect( | ||
packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: "yolo.js" | ||
} | ||
} | ||
}) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
@@ -1,7 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
const config = require('../config.js'); | ||
const config = require("../config.js"); | ||
const TEXT_SNIPPET = | ||
`# This file is automatically generated by a | ||
const TEXT_SNIPPET = `# This file is automatically generated by a | ||
# \`metapak\` module. Do NOT change it in | ||
@@ -16,52 +15,46 @@ # place, your changes would be overriden. | ||
`; | ||
const JS_SNIPPET = TEXT_SNIPPET.replace(/(\n|^)# /g, '\n// '); | ||
const JS_SNIPPET = TEXT_SNIPPET.replace(/(\n|^)# /g, "\n// "); | ||
module.exports = (file, packageConf) => { | ||
const metapakData = packageConf.metapak && | ||
packageConf.metapak.data ? | ||
packageConf.metapak.data : | ||
{}; | ||
const metapakData = | ||
packageConf.metapak && packageConf.metapak.data | ||
? packageConf.metapak.data | ||
: {}; | ||
// 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)) { | ||
file.data = file.data.replace(/<lastNodeLTS>/mg, config.lastNodeLTS); | ||
if ([".github/ISSUE_TEMPLATE.md"].includes(file.name)) { | ||
file.data = file.data.replace(/<lastNodeLTS>/gm, config.lastNodeLTS); | ||
} | ||
// Add snippets | ||
if( | ||
file.name.endsWith('.gitignore') && | ||
if ( | ||
file.name.endsWith(".gitignore") && | ||
metapakData.ignore && | ||
metapakData.ignore.length | ||
) { | ||
file.data = file.data + | ||
'# Project custom ignored file\n' + | ||
metapakData.ignore.join('\n') + '\n'; | ||
file.data = | ||
file.data + | ||
"# 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') | ||
} 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.data = TEXT_SNIPPET + file.data; | ||
} else if( | ||
file.name.endsWith('.js') | ||
) { | ||
} else if (file.name.endsWith(".js")) { | ||
file.data = JS_SNIPPET + file.data; | ||
@@ -68,0 +61,0 @@ } |
@@ -1,27 +0,33 @@ | ||
'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', | ||
data: 'The MIT License (MIT)\nCopyright © 2017 <copyright holders>\n', | ||
}, {}) | ||
) | ||
.toMatchSnapshot(); | ||
assetsTransformer( | ||
{ | ||
name: "LICENSE", | ||
data: | ||
"The MIT License (MIT)\nCopyright © 2017 <copyright holders>\n" | ||
}, | ||
{} | ||
) | ||
).toMatchSnapshot(); | ||
}); | ||
it('should let pass other files', () => { | ||
it("should let pass other files", () => { | ||
assert.deepEqual( | ||
assetsTransformer({ | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
}, {}), | ||
assetsTransformer( | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
}, | ||
{} | ||
), | ||
{ | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
} | ||
@@ -28,0 +34,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); | ||
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); | ||
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,22 +17,14 @@ 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', () => { | ||
assert.deepEqual( | ||
hooksTransformer({}), | ||
{ | ||
'pre-commit': [ | ||
PRE_COMMIT_METAPAK_RUN, | ||
PRE_COMMIT_QUALITY_CHECK, | ||
], | ||
'commit-msg': [ | ||
COMMIT_MSG_COMMITIZEN_CHECK, | ||
], | ||
} | ||
); | ||
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] | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,20 +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) => { | ||
const metapakData = packageConf.metapak && packageConf.metapak.data ? | ||
packageConf.metapak.data : | ||
{}; | ||
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 }; | ||
@@ -26,27 +21,23 @@ // 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" | ||
} | ||
}; | ||
// Add the changelog stuffs | ||
packageConf.scripts.changelog = 'conventional-changelog -p angular -i CHANGELOG.md -s'; | ||
packageConf.scripts.version = 'npm run changelog && git add CHANGELOG.md'; | ||
packageConf.scripts.changelog = | ||
"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"'; | ||
packageConf.scripts.preversion = ( | ||
packageConf.scripts.preversion ? | ||
packageConf.scripts.preversion + | ||
( | ||
/(^| && )npm run lint($| && )/ | ||
.test(packageConf.scripts.preversion) ? | ||
'' : | ||
' && npm run lint' | ||
) : | ||
'npm run lint' | ||
); | ||
packageConf.scripts.preversion = packageConf.scripts.preversion | ||
? packageConf.scripts.preversion + | ||
(/(^| && )npm run lint($| && )/.test(packageConf.scripts.preversion) | ||
? "" | ||
: " && npm run lint") | ||
: "npm run lint"; | ||
// Add the MUST HAVE dependencies: | ||
@@ -57,18 +48,18 @@ packageConf.dependencies = packageConf.dependencies || {}; | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.commitizen = '^2.9.6'; | ||
packageConf.devDependencies['cz-conventional-changelog'] = '^2.0.0'; | ||
packageConf.devDependencies['conventional-changelog-cli'] = '^1.3.4'; | ||
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) { | ||
const [, userName, repositoryName] = GITHUB_REPOSITORY_REGEXP.exec( | ||
packageConf.repository.url | ||
) || []; | ||
if(userName && repositoryName) { | ||
if (packageConf.repository && "git" === packageConf.repository.type) { | ||
const [, userName, repositoryName] = | ||
GITHUB_REPOSITORY_REGEXP.exec(packageConf.repository.url) || []; | ||
if (userName && repositoryName) { | ||
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'; | ||
packageConf.homepage = | ||
packageConf.homepage || | ||
"https://github.com/" + userName + "/" + repositoryName + "#readme"; | ||
} | ||
@@ -75,0 +66,0 @@ } |
@@ -1,18 +0,19 @@ | ||
'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', () => { | ||
expect(packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: 'lol.js', | ||
}, | ||
}, | ||
})) | ||
.toMatchSnapshot(); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
expect( | ||
packageTransformer({ | ||
metapak: { | ||
data: { | ||
files: "lol.js" | ||
} | ||
} | ||
}) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
@@ -1,7 +0,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = (packageConf) => { | ||
packageConf.license = 'MIT'; | ||
module.exports = packageConf => { | ||
packageConf.license = "MIT"; | ||
return packageConf; | ||
}; |
@@ -1,12 +0,11 @@ | ||
'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', () => { | ||
expect(packageTransformer({})) | ||
.toMatchSnapshot(); | ||
describe("Main", () => { | ||
describe("Package transformer", () => { | ||
test("should work with an empty package.json", () => { | ||
expect(packageTransformer({})).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
@@ -1,23 +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) { | ||
if ("README.md" === file.name) { | ||
// Header | ||
file.data += '# ' + packageConf.name + '\n'; | ||
if(packageConf.description) { | ||
file.data += '> ' + packageConf.description + '\n'; | ||
file.data += "# " + packageConf.name + "\n"; | ||
if (packageConf.description) { | ||
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 }), | ||
]).then((chunks) => { | ||
file.data = chunks.filter(_identity).join('\n') + '\n'; | ||
file.data += '# License\n' + | ||
'[' + packageConf.license + '](https://github.com/' + | ||
ORGANISATION_NAME + '/' + packageConf.name + '/blob/master/LICENSE.md)\n'; | ||
_getAPIContents({ PROJECT_DIR, fs, log }) | ||
]).then(chunks => { | ||
file.data = chunks.filter(_identity).join("\n") + "\n"; | ||
file.data += | ||
"# License\n" + | ||
"[" + | ||
packageConf.license + | ||
"](https://github.com/" + | ||
ORGANISATION_NAME + | ||
"/" + | ||
packageConf.name + | ||
"/blob/master/LICENSE.md)\n"; | ||
return file; | ||
@@ -31,8 +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; | ||
@@ -43,12 +48,13 @@ }); | ||
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 ""; | ||
}); | ||
} | ||
function _identity(me) { return me; } | ||
function _identity(me) { | ||
return me; | ||
} |
@@ -1,51 +0,60 @@ | ||
'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 | ||
}; | ||
fs.readFileAsync.onFirstCall().returns(Promise.resolve('## Usage\nJust require me\n')); | ||
fs.readFileAsync.onSecondCall().returns(Promise.resolve('')); | ||
fs.readFileAsync | ||
.onFirstCall() | ||
.returns(Promise.resolve("## Usage\nJust require me\n")); | ||
fs.readFileAsync.onSecondCall().returns(Promise.resolve("")); | ||
assetsTransformer({ | ||
name: 'README.md', | ||
data: '<!-- something -->\n', | ||
}, { | ||
name: 'module', | ||
description: 'A great module!', | ||
devDependencies: {}, | ||
license: 'MIT', | ||
}, { | ||
PROJECT_DIR, | ||
fs, | ||
log, | ||
}) | ||
.then((file) => { | ||
expect(file) | ||
.toMatchSnapshot(); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
assetsTransformer( | ||
{ | ||
name: "README.md", | ||
data: "<!-- something -->\n" | ||
}, | ||
{ | ||
name: "module", | ||
description: "A great module!", | ||
devDependencies: {}, | ||
license: "MIT" | ||
}, | ||
{ | ||
PROJECT_DIR, | ||
fs, | ||
log | ||
} | ||
) | ||
.then(file => { | ||
expect(file).toMatchSnapshot(); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
it('should let pass other files', () => { | ||
it("should let pass other files", () => { | ||
assert.deepEqual( | ||
assetsTransformer({ | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
}, {}, {}), | ||
assetsTransformer( | ||
{ | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
}, | ||
{}, | ||
{} | ||
), | ||
{ | ||
name: 'YOLO', | ||
data: 'Carpe diem\n', | ||
name: "YOLO", | ||
data: "Carpe diem\n" | ||
} | ||
@@ -52,0 +61,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); | ||
module.exports = hooks => { | ||
hooks["pre-commit"] = hooks["pre-commit"] || []; | ||
hooks["pre-commit"].push(PRE_COMMIT_TEST_CHECK); | ||
return hooks; | ||
}; |
@@ -1,20 +0,15 @@ | ||
'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', () => { | ||
assert.deepEqual( | ||
hooksTransformer({}), | ||
{ | ||
'pre-commit': [ | ||
PRE_COMMIT_TEST_CHECK, | ||
], | ||
} | ||
); | ||
describe("Tests", () => { | ||
describe("Hooks transformer", () => { | ||
it("should add pre-commit hooks", () => { | ||
assert.deepEqual(hooksTransformer({}), { | ||
"pre-commit": [PRE_COMMIT_TEST_CHECK] | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,27 +0,22 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = (packageConf) => { | ||
module.exports = packageConf => { | ||
// Let's add test scripts | ||
packageConf.scripts = packageConf.scripts || {}; | ||
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' | ||
); | ||
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"; | ||
// Add the testing dev dependencies | ||
packageConf.devDependencies = packageConf.devDependencies || {}; | ||
packageConf.devDependencies.jest = '20.0.4'; | ||
packageConf.devDependencies.sinon = '2.3.8'; | ||
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,12 +0,11 @@ | ||
'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', () => { | ||
expect(packageTransformer({})) | ||
.toMatchSnapshot(); | ||
describe("Tests", () => { | ||
describe("Package transformer", () => { | ||
it("should work with an empty package.json", () => { | ||
expect(packageTransformer({})).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
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
42195
10
600
1