mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +00:00
refactor: Use reliable packages
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
fe248a03af
commit
6688cdf96d
11 changed files with 97 additions and 102 deletions
|
|
@ -1 +0,0 @@
|
||||||
module.exports = require('@remy/eslint')('node');
|
|
||||||
|
|
@ -1,26 +1,27 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html id="home" lang="en">
|
<html id="home" lang="en">
|
||||||
<%- include('components/header') %>
|
<%- include('components/header') %>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<article>
|
<article>
|
||||||
<%- gravatar %>
|
<%- gravatar %>
|
||||||
<h1>The ISC License (ISC)</h1>
|
<h1>The ISC License (ISC)</h1>
|
||||||
|
|
||||||
<p>Copyright © <%- info %></p>
|
<p>Copyright © <%- info %></p>
|
||||||
|
|
||||||
<p>Permission to use, copy, modify, and/or distribute this software for any
|
<p>Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
copyright notice and this permission notice appear in all copies.</p>
|
copyright notice and this permission notice appear in all copies.</p>
|
||||||
|
|
||||||
<p>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
<p>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</p>
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</p>
|
||||||
</article>
|
</article>
|
||||||
<%- include('components/footer') %>
|
<%- include('components/footer') %>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,33 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html id="home" lang="en">
|
<html id="home" lang="en">
|
||||||
<%- include('components/header') %>
|
<%- include('components/header') %>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<article>
|
<article>
|
||||||
<%- gravatar %>
|
<%- gravatar %>
|
||||||
<h1>The MIT License (MIT)</h1>
|
<h1>The MIT License (MIT)</h1>
|
||||||
|
|
||||||
<p>Copyright © <%- info %></p>
|
<p>Copyright © <%- info %></p>
|
||||||
|
|
||||||
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
|
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the “Software”), to deal
|
of this software and associated documentation files (the “Software”), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:</p>
|
furnished to do so, subject to the following conditions:</p>
|
||||||
|
|
||||||
<p>The above copyright notice and this permission notice shall be included in
|
<p>The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.</p>
|
all copies or substantial portions of the Software.</p>
|
||||||
|
|
||||||
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.</p>
|
THE SOFTWARE.</p>
|
||||||
</article>
|
</article>
|
||||||
<%- include('components/footer') %>
|
<%- include('components/footer') %>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<footer>
|
<footer>
|
||||||
<p><a target="_blank" rel="noopener" href="https://github.com/remy/mit-license">Fork this project to create your own MIT license that you can always link to.</a></p>
|
<p><a target="_blank" rel="noopener" href="https://github.com/remy/mit-license">Fork this project to create your own
|
||||||
|
MIT license that you can always link to.</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,37 @@
|
||||||
<head>
|
<head>
|
||||||
<title>MIT License</title>
|
<title>MIT License</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<meta name="description" content="The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology. As a permissive license, it puts only very limited restriction on reuse and has, therefore, an excellent license compatibility.">
|
<meta name="description"
|
||||||
<!--
|
content="The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology. As a permissive license, it puts only very limited restriction on reuse and has, therefore, an excellent license compatibility.">
|
||||||
Welcome fellow open source developer. This project is here for you to
|
<!--
|
||||||
link to if you're like me and keep forgetting to include the
|
Welcome fellow open source developer. This project is here for you to
|
||||||
MIT-license.txt file.
|
link to if you're like me and keep forgetting to include the
|
||||||
|
MIT-license.txt file.
|
||||||
|
|
||||||
Fork this project and send a pull request on:
|
Fork this project and send a pull request on:
|
||||||
|
|
||||||
https://github.com/remy/mit-license
|
https://github.com/remy/mit-license
|
||||||
|
|
||||||
By adding a new JSON file to the users directory, it will yield an
|
By adding a new JSON file to the users directory, it will yield an
|
||||||
MIT License on a CNAME, for example:
|
MIT License on a CNAME, for example:
|
||||||
|
|
||||||
{ "copyright": "Remy Sharp, https://remysharp.com" }
|
{ "copyright": "Remy Sharp, https://remysharp.com" }
|
||||||
|
|
||||||
Means visiting https://rem.mit-license.org/ shows "Remy Sharp" as the
|
Means visiting https://rem.mit-license.org/ shows "Remy Sharp" as the
|
||||||
copyright holder. Namespaces will be on a first come first serve basis,
|
copyright holder. Namespaces will be on a first come first serve basis,
|
||||||
and I'm open to folk joining the GitHub project.
|
and I'm open to folk joining the GitHub project.
|
||||||
|
|
||||||
For more options see the README in the github hosted project.
|
For more options see the README in the github hosted project.
|
||||||
|
|
||||||
Hope you find this useful too!
|
Hope you find this useful too!
|
||||||
|
|
||||||
- @rem
|
|
||||||
|
|
||||||
|
- @rem
|
||||||
-->
|
-->
|
||||||
<!-- for HTML5 el styling -->
|
<script>
|
||||||
<script>
|
document.createElement('article');
|
||||||
document.createElement('article');
|
document.createElement('footer');
|
||||||
document.createElement('footer');
|
</script>
|
||||||
</script>
|
<link rel="stylesheet" href="/themes/<%= theme %>.css">
|
||||||
<link rel="stylesheet" href="/themes/<%= theme %>.css">
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
||||||
24
package.json
24
package.json
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"author": "Remy Sharp <remy@leftlogic.com> (http://remysharp.com/)",
|
|
||||||
"name": "mit-licence",
|
"name": "mit-licence",
|
||||||
"description": "Hosted MIT License with details controlled through this repo",
|
"description": "Hosted MIT License with details controlled through this repo",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|
@ -12,12 +11,7 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
},
|
||||||
"husky": {
|
"author": "Remy Sharp <remy@leftlogic.com> (http://remysharp.com/)",
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "npm run lint",
|
|
||||||
"pre-push": "npm test"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"dev": "nodemon .",
|
"dev": "nodemon .",
|
||||||
|
|
@ -30,28 +24,38 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@octokit/rest": "^16.36.0",
|
"@octokit/rest": "^16.41.0",
|
||||||
|
"@sindresorhus/is": "^2.0.0",
|
||||||
|
"any-size": "^1.0.0",
|
||||||
"btoa": "^1.2.1",
|
"btoa": "^1.2.1",
|
||||||
"ejs": "^3.0.1",
|
"ejs": "^3.0.1",
|
||||||
|
"escape-html": "^1.0.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-minify": "^1.0.0",
|
"express-minify": "^1.0.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"lodash": "^4.17.15",
|
"html-text": "^1.0.1",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
"postcss-middleware": "^1.1.4",
|
"postcss-middleware": "^1.1.4",
|
||||||
"postcss-preset-env": "^6.7.0",
|
"postcss-preset-env": "^6.7.0",
|
||||||
"serve-favicon": "^2.5.0",
|
"serve-favicon": "^2.5.0",
|
||||||
"temp-dir": "^2.0.0",
|
"temp-dir": "^2.0.0",
|
||||||
|
"unescape-html": "^1.1.0",
|
||||||
"yn": "^4.0.0"
|
"yn": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"css": "^2.2.4",
|
"css": "^2.2.4",
|
||||||
"has-flag": "^4.0.0",
|
"has-flag": "^4.0.0",
|
||||||
"husky": "^4.0.7",
|
"husky": "^4.2.1",
|
||||||
"nodemon": "^2.0.2",
|
"nodemon": "^2.0.2",
|
||||||
"standard": "^14.3.1"
|
"standard": "^14.3.1"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"postcss-middleware/vinyl-fs/glob-stream/micromatch/braces": "^3.0.2"
|
"postcss-middleware/vinyl-fs/glob-stream/micromatch/braces": "^3.0.2"
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "npm run lint",
|
||||||
|
"pre-push": "npm test"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
const md5 = require('md5')
|
const md5 = require('md5')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { stripTags, escapeTags, unescapeTags } = require('./utils')
|
const escapeTags = require('escape-html')
|
||||||
const _ = require('lodash')
|
const unescapeTags = require('unescape-html')
|
||||||
|
const stripTags = require('html-text')
|
||||||
|
const is = require('@sindresorhus/is')
|
||||||
|
|
||||||
function getCopyrightHTML (user, plain) {
|
function getCopyrightHTML (user, plain) {
|
||||||
let html = ''
|
let html = ''
|
||||||
|
|
||||||
const name = _.isString(user)
|
const name = is.string(user)
|
||||||
? user
|
? user
|
||||||
: plain
|
: plain
|
||||||
? user.name || user.copyright
|
? user.name || user.copyright
|
||||||
|
|
@ -34,9 +36,9 @@ module.exports = (req, res) => {
|
||||||
|
|
||||||
// No error and valid
|
// No error and valid
|
||||||
if (user.copyright) {
|
if (user.copyright) {
|
||||||
if (_.isString(user.copyright)) {
|
if (is.string(user.copyright)) {
|
||||||
name = getCopyrightHTML(user, options.format !== 'html')
|
name = getCopyrightHTML(user, options.format !== 'html')
|
||||||
} else if (_.isArray(user.copyright) && user.copyright.every(val => _.isString(val))) {
|
} else if (is.array(user.copyright) && user.copyright.every(val => is.string(val))) {
|
||||||
// Supports: ['Remy Sharp', 'Richie Bendall']
|
// Supports: ['Remy Sharp', 'Richie Bendall']
|
||||||
name = user.copyright
|
name = user.copyright
|
||||||
.map(v => (options.format !== 'html' ? v : escapeTags(v)))
|
.map(v => (options.format !== 'html' ? v : escapeTags(v)))
|
||||||
|
|
@ -51,7 +53,7 @@ module.exports = (req, res) => {
|
||||||
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
||||||
user.email.trim().toLowerCase()
|
user.email.trim().toLowerCase()
|
||||||
)}" />`
|
)}" />`
|
||||||
} else if (_.isObject(user.copyright[0]) && user.gravatar) {
|
} else if (is.object(user.copyright[0]) && user.gravatar) {
|
||||||
// Supports multi-user format
|
// Supports multi-user format
|
||||||
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
||||||
user.copyright[0].email.trim().toLowerCase()
|
user.copyright[0].email.trim().toLowerCase()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const btoa = require('btoa')
|
const btoa = require('btoa')
|
||||||
const { version } = require(path.join(__dirname, '..', 'package.json'))
|
const { version } = require(path.join(__dirname, '..', 'package.json'))
|
||||||
const _ = require('lodash')
|
const size = require('any-size')
|
||||||
const github = require('@octokit/rest')({
|
const github = require('@octokit/rest')({
|
||||||
// GitHub personal access token
|
// GitHub personal access token
|
||||||
auth: process.env.github_token,
|
auth: process.env.github_token,
|
||||||
|
|
@ -10,14 +10,15 @@ const github = require('@octokit/rest')({
|
||||||
userAgent: `mit-license v${version}`
|
userAgent: `mit-license v${version}`
|
||||||
})
|
})
|
||||||
const yn = require('yn')
|
const yn = require('yn')
|
||||||
|
const is = require('@sindresorhus/is')
|
||||||
|
|
||||||
const { validDomainId } = require('./utils')
|
const { validDomainId } = require('./utils')
|
||||||
|
|
||||||
function getUserData ({ query, body }) {
|
function getUserData ({ query, body }) {
|
||||||
// If query parameters provided
|
// If query parameters provided
|
||||||
if (_.size(query) > 0) return query
|
if (size(query) > 0) return query
|
||||||
// If the data parsed as {'{data: "value"}': ''}
|
// If the data parsed as {'{data: "value"}': ''}
|
||||||
if (_.size(body) === 1 && !_.first(_.values(body))) return JSON.parse(_.first(_.keys(body)))
|
if (size(body) === 1 && !Object.values(body)[0]) return JSON.parse(Object.keys(body)[0])
|
||||||
// Fallback
|
// Fallback
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +39,7 @@ module.exports = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the name from the URL
|
// Extract the name from the URL
|
||||||
const id = _.first(params)
|
const id = params[0]
|
||||||
|
|
||||||
if (!validDomainId(id)) {
|
if (!validDomainId(id)) {
|
||||||
// Return a vague error intentionally
|
// Return a vague error intentionally
|
||||||
|
|
@ -65,7 +66,7 @@ module.exports = async (req, res) => {
|
||||||
if (userData.gravatar) {
|
if (userData.gravatar) {
|
||||||
// Parse the string version of a boolean or similar
|
// Parse the string version of a boolean or similar
|
||||||
userData.gravatar = yn(userData.gravatar, { lenient: true })
|
userData.gravatar = yn(userData.gravatar, { lenient: true })
|
||||||
if (_.isUndefined(userData.gravatar)) {
|
if (is.undefined(userData.gravatar)) {
|
||||||
res
|
res
|
||||||
.status(400)
|
.status(400)
|
||||||
.send(
|
.send(
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,3 @@
|
||||||
const _ = require('lodash')
|
|
||||||
|
|
||||||
const tags = {
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'&': '&'
|
|
||||||
}
|
|
||||||
const untags = _.invert(tags)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
escapeTags: str => (str || '').replace(/[<>&]/g, m => tags[m]),
|
|
||||||
unescapeTags: str =>
|
|
||||||
(str || '').replace(/(<|>|&)/g, m => untags[m]),
|
|
||||||
stripTags: str => (str || '').replace(/<(?:.|\n)*?>/gm, ''),
|
|
||||||
validDomainId: str => /^[\w-_]+$/.test(str)
|
validDomainId: str => /^[\w-_]+$/.test(str)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ const express = require('express')
|
||||||
const minify = require('express-minify')
|
const minify = require('express-minify')
|
||||||
const favicon = require('serve-favicon')
|
const favicon = require('serve-favicon')
|
||||||
const postcssMiddleware = require('postcss-middleware')
|
const postcssMiddleware = require('postcss-middleware')
|
||||||
const tmpdir = require('temp-dir')
|
const tempdir = require('temp-dir')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
|
|
@ -19,7 +19,7 @@ var PORT = process.env.PORT || 8080
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use(
|
app.use(
|
||||||
minify({
|
minify({
|
||||||
cache: tmpdir
|
cache: tempdir
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
app.use(favicon(path.join(__dirname, 'favicon.ico')))
|
app.use(favicon(path.join(__dirname, 'favicon.ico')))
|
||||||
|
|
|
||||||
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue