New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emdaer

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emdaer - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

.emdaer.yml

110

index.js

@@ -8,66 +8,62 @@ #! /usr/bin/env node

const { safeLoad } = require('js-yaml');
const inquirer = require('inquirer');
const fieldFormatters = {
contributors: (entry, { author, contributors = [] }) => {
const people = [author].concat(contributors);
const result = ['## Contributors\n'];
result.push(people.map(({ name, id }) => `![${name}](https://avatars.githubusercontent.com/u/${id}?s=130)`).join(' | '));
result.push(people.map(() => '---').join(' | '));
result.push(people.map(({ name, url }) => `[${name}](${url})`).join(' | '));
return result.join('\n');
},
include: ({ include }) => {
let result;
try {
result = readFileSync(include, 'utf8');
} catch (error) {
process.stdout.write(`Could not read \`${include}\`!\n`);
}
return result;
},
license: (entry, { author: { name, url }, license }) => {
const result = ['## License\n'];
result.push(`${license}${name && url && ` @ [${name}](${url})` || ''}`);
return result.join('\n');
},
shields: ({ shields: { shields, style } }) => {
const baseURL = 'https://img.shields.io/';
return `${shields.map(({ alt = '', image = '', link = '' }) => (
`[![${alt}](${baseURL}${image}${style ? `?style=${style}` : ''})](${link})`
)).join('\n')}\n`;
},
text: ({ text }) => `${text}\n`,
title: ({ title }, { name }) => `# ${name}\n`,
};
const writeREADME = content => writeFileSync('README.md', `${content}\n`);
let packageJSON;
const defaults = {};
let config;
try {
packageJSON = JSON.parse(readFileSync('package.json'));
defaults.title = packageJSON.name;
defaults.version = packageJSON.version;
defaults.description = packageJSON.description;
packageJSON = JSON.parse(readFileSync('package.json', 'utf8'));
} catch (error) {
process.stdout.write('You might want to run npm init first!');
process.stdout.write('You might want to run `npm init` first!\n');
}
const questions = safeLoad(readFileSync(`${__dirname}/questions.yml`, 'utf8')).map(question => {
let result = question;
if (defaults[question.name]) {
result = Object.assign(result, {
default: defaults[question.name],
});
try {
config = safeLoad(readFileSync('./.emdaer.yml', 'utf8')).map(entry => Object.assign(entry, {
type: Object.keys(entry)[0],
}));
} catch (error) {
process.stdout.write('You need an `.emdaer.yml` to use emdaer!\n');
}
const content = [];
config.forEach(entry => {
if (fieldFormatters[entry.type]) {
content.push(fieldFormatters[entry.type](entry, packageJSON));
} else {
process.stdout.write(`\`${entry.type}\` is not a supported type!\n`);
}
if (question.when) {
result = Object.assign(result, {
when: !!packageJSON[question.when],
});
}
return result;
});
const onComplete = answers => {
const output = [];
if (answers.title) {
output.push(`# ${answers.title}\n`);
}
if (answers.description) {
output.push(answers.description);
}
if (answers.bin) {
output.push('\n## CLI\n');
Object.keys(packageJSON.bin).forEach(id => {
output.push('```sh');
output.push(`$ npm install -g ${packageJSON.name}`);
output.push(`$ ${id}`);
output.push('```');
});
}
if (answers.scripts) {
output.push(`\n## Scripts\n`);
Object.keys(packageJSON.scripts).forEach(script => {
output.push(`### ${script}\n`);
output.push('```sh');
output.push(`$ npm run ${script}`);
output.push('```');
});
}
if (answers.scripts) {
output.push(`\n## License\n`);
const author = packageJSON.author.name && packageJSON.author.url
&& ` @ [${packageJSON.author.name}](${packageJSON.author.url})`;
output.push(`${packageJSON.license}${author || ''}`);
}
writeFileSync('README.md', `${output.join('\n')}\n`);
};
inquirer.prompt(questions).then(onComplete);
writeREADME(content.join('\n'));
process.stdout.write('Ayy, wrote you a README.md!\n');
{
"name": "emdaer",
"version": "0.0.3",
"version": "0.1.0",
"description": "does a README.md",
"repository": "flipactual/emdaer",
"author": {
"name": "Flip",
"url": "http://flipactual.com"
"url": "http://github.com/flipactual",
"id": 1306968
},

@@ -20,7 +22,6 @@ "license": "MIT",

"dependencies": {
"inquirer": "^1.0.3",
"js-yaml": "^3.6.1",
"prompt": "^1.0.0"
"js-yaml": "^3.6.1"
},
"devDependencies": {
"babel-eslint": "^6.0.4",
"eslint": "^2.11.1",

@@ -27,0 +28,0 @@ "eslint-config-airbnb-base": "^3.0.1",

# emdaer
[![Travis](https://img.shields.io/travis/flipactual/emdaer.svg?style=flat-square)](https://travis-ci.org/flipactual/emdaer/)
[![Node](https://img.shields.io/node/v/emdaer.svg?style=flat-square)](http://npmjs.com/package/emdaer)
[![NPM](https://img.shields.io/npm/v/emdaer.svg?style=flat-square)](http://npmjs.com/package/emdaer)
does a README.md

@@ -7,17 +11,126 @@

You can install `emdaer` globally:
```sh
$ npm install -g emdaer
$ npm i -g emdaer
$ cd ~/your-project/
$ emdaer
```
## Scripts
Or you can save `emdaer` to specific projects:
### start
```sh
$ npm run start
$ cd ~/your-project
$ npm i -D emdaer
$ ./node_modules/.bin/emdaer
```
Either way, invoking `emdaer` requires the presence of a valid `.emdaer.yml` configuration file in the current directory.
## Configuration
```yml
- title: true
- shields:
style: 'flat-square'
shields:
- alt: Travis
image: 'travis/flipactual/emdaer.svg'
link: 'https://travis-ci.org/flipactual/emdaer/'
- text: 'does a README.md'
- include: './docs/bin.md'
- include: './docs/configuration.md'
- license: true
```
`emdaer` iterates over the array in `.emdaer.yml` and creates a `README.md` including the listed elements in the order they're provided.
`.emdaer.yml` supports the following field types:
#### `title`
type: `boolean`
If `true`, pulls title from the `name` field in the project's `package.json` and includes as a level one heading.
If you'd like to use a different title, use `text` instead:
```yml
- text: '# My Title'
```
#### `text`
type: `string`
A string to insert into the README. Can include markdown formatting.
#### `include`
type: `string`
The path to a file to include in the README.
#### `license`
type: `string`
If `true`, pulls `license` and `author` information from `package.json` to include:
```md
## License
MIT @ [Flip](http://flipactual.com)
<license> @ [<author.name>](<author.url>)
```
For any other formatting, use `text` or `include`.
#### `contributors`
type: `boolean`
If `true`, creates a table including the `author` and `contributors` from `package.json`.
You must include the GitHub ID of each user:
```json
"author": {
"name": "Flip",
"url": "http://github.com/flipactual",
"id": 1306968
},
```
#### `shields`
type: `object`
Configuration and list of [Shields](http://shields.io) to use.
##### `shields.style`
type: `string`
The style of shields to use. Supports `plastic`, `flat`, `flat-square`, or `social`.
##### `shields.shields`
type: `array`
A list of shields to include.
###### `shields.shields[n].alt`
type: `string`
The alt text for the Shield.
###### `shields.shields[n].image`
type: `string`
The path to the Shield image (eg `travis/flipactual/emdaer.svg`).
###### `shields.shields[n].link`
type: `string`
The link to open when clicking the Shield.
## Contributors
![Flip](https://avatars.githubusercontent.com/u/1306968?s=130)
---
[Flip](http://github.com/flipactual)
## License
MIT @ [Flip](http://github.com/flipactual)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc