```
my-new-package/
- - package.yash
+ - README.md (package info in frontmatter)
- releases.js
- install.sh
- install.bat
Just copy the format from any of the existing packages. It's like this:
-`package.yash`:
+`README.md`:
-````
-# title: Node.js
-# homepage: https://nodejs.org
-# tagline: JavaScript V8 runtime
-# description: |
-# Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
-# examples: |
-# ```bash
-# node -e 'console.log("Hello, World!")'
-# > Hello, World!
-# ```
-
-END
-````
-
-This is a dumb format. We know. Historical accident (originally these were in
-bash comments).
+````md
+---
+title: Node.js
+homepage: https://nodejs.org
+tagline: JavaScript V8 runtime
+description: |
+ Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
+---
-It's in the TODOs to replace this with either YAML or Markdown.
+```bash
+node -e 'console.log("Hello, World!")'
+> Hello, World!
+```
+````
### 1. Fetch Releases
--- /dev/null
+'use strict';
+
+var fs = require('fs');
+var marked = require('marked');
+
+var frontmatter = '---';
+var keyValRe = /(\w+): (.*)/;
+
+function parseYamlish(txt) {
+ var end = false;
+ var cfg = { title: '', tagline: '', description: '', examples: '' };
+ var block = false;
+
+ var lines = txt.trim().split('\n');
+ var moreRe = /\s+/;
+ var last;
+
+ if (frontmatter !== lines.shift()) {
+ throw new Error('no frontmatter marker at beginning of file');
+ }
+
+ function unblock() {
+ cfg[block] = marked(cfg[block]);
+ block = false;
+ }
+
+ lines.some(function (line, i) {
+ if (frontmatter === line) {
+ // end of frontmatter
+ end = true;
+ return;
+ }
+
+ if (end) {
+ if (line.trim()) {
+ throw new Error('missing newline after frontmatter');
+ }
+ last = i;
+ return true;
+ }
+
+ if (!line[0]) {
+ if (block) {
+ cfg[block] += '\n';
+ } else {
+ throw new Error('invalid blank line in frontmatter');
+ }
+ }
+
+ if (block) {
+ if (!line || ' ' === line.slice(0, 2)) {
+ cfg[block] += line.slice(2) + '\n';
+ return;
+ }
+ unblock();
+ }
+
+ var m = line.match(keyValRe);
+ if (!m) {
+ throw new Error(
+ 'invalid key format for: ' + JSON.stringify(line) + ' ' + i
+ );
+ }
+ if ('|' === m[2]) {
+ block = m[1];
+ return;
+ }
+ cfg[m[1]] = m[2];
+ });
+
+ if (block) {
+ cfg[block] = marked(cfg[block]);
+ }
+ cfg.examples = marked(lines.slice(last).join('\n'));
+
+ return cfg;
+}
+
+module.exports.parse = parseYamlish;
+
+if (require.main === module) {
+ console.info(
+ parseYamlish(
+ fs.readFileSync(__dirname + '/../node/README.md', 'utf8')
+ )
+ );
+}
'use strict';
+var frontmarker = require('./frontmarker.js');
var shmatter = require('shmatter');
var fs = require('fs');
var path = require('path');
.readFile(readme, 'utf-8')
.then(function (txt) {
// TODO
- //return frontmarker.parse(txt);
+ return frontmarker.parse(txt);
})
.catch(function (e) {
if ('ENOENT' !== e.code && 'ENOTDIR' !== e.code) {
}
})
]).then(function (items) {
- var meta = items[1];
+ var meta = items[0] || items[1];
if (!meta) {
// doesn't exist
return;
var maxLen = 0;
console.info('');
console.info('Has the necessary files?');
-['package.yash', 'releases.js', 'install.sh', 'install.bat']
+['README.md', 'releases.js', 'install.sh', 'install.bat']
.map(function (node) {
maxLen = Math.max(maxLen, node.length);
return node;
--- /dev/null
+---
+title: Caddy
+homepage: https://github.com/caddyserver/caddy
+tagline: |
+ Caddy is a fast, multi-platform web server with automatic HTTPS.
+description: |
+ Caddy makes it easy to use Let's Encrypt to handle HTTPS (TLS/SSL) and to reverse proxy APIs and WebSockets to other apps - such as those written node, Go, python, ruby, and PHP.
+---
+
+```bash
+caddy start
+```
+++ /dev/null
-# title: Caddy
-# homepage: https://github.com/caddyserver/caddy
-# tagline: |
-# Caddy is a fast, multi-platform web server with automatic HTTPS.
-# description: |
-# Caddy makes it easy to use Let's Encrypt to handle HTTPS (TLS/SSL) and to reverse proxy APIs and WebSockets to other apps - such as those written node, Go, python, ruby, and PHP.
-# examples: |
-# ```bash
-# caddy start
-# ```
-
-This is a comment... because... poor choices I made.
-
-Don't worry, this will be yaml or markdown in the... sometime... future
--- /dev/null
+---
+title: Deno
+homepage: https://github.com/denoland/deno
+tagline: |
+ Deno: A secure runtime for JavaScript and TypeScript.
+description: |
+ Deno proves that lightning does strike twice. It's the ease of use of node, the intentional tooling of Go, and built in Rust.
+---
+
+The obligatory Hello World
+
+```bash
+deno run https://deno.land/std/examples/welcome.ts
+```
+
+Run a local file
+
+```bash
+deno run ./hello.ts
+```
+
+Enable [permissions](https://deno.land/manual/getting_started/permissions)
+
+```bash
+deno run --allow-read=./data,./public --allow-write=./data \
+ --allow-net=example.com,example.net ./hello.ts
+```
+
+Format source code, recursively
+
+```bash
+deno fmt ./my-project
+```
+++ /dev/null
-# title: Deno
-# homepage: https://github.com/denoland/deno
-# tagline: |
-# Deno: A secure runtime for JavaScript and TypeScript.
-# description: |
-# Deno proves that lightning does strike twice. It's the ease of use of node, the intentional tooling of Go, and built in Rust.
-# examples: |
-# The obligatory Hello World
-#
-# ```bash
-# deno run https://deno.land/std/examples/welcome.ts
-# ```
-#
-# Run a local file
-#
-# ```bash
-# deno run ./hello.ts
-# ```
-#
-# Enable [permissions](https://deno.land/manual/getting_started/permissions)
-#
-# ```bash
-# deno run --allow-read=./data,./public --allow-write=./data \
-# --allow-net=example.com,example.net ./hello.ts
-# ```
-#
-# Format source code, recursively
-#
-# ```bash
-# deno fmt ./my-project
-# ```
-#
-
-
-This is a comment... because... poor choices I made.
-
-Don't worry, this will be yaml or markdown in the... sometime... future
--- /dev/null
+---
+title: Node.js
+homepage: https://nodejs.org
+tagline: |
+ Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
+description: |
+ Node is great for simple, snappy HTTP(S) servers, and for stitching APIs together with minimal fuss or muss.
+---
+
+Hello World
+
+```bash
+node -e 'console.log("Hello, World!")'
+> Hello, World!
+```
+
+A Simple Web Server
+
+`server.js`:
+
+```bash
+var http = require('http');
+var app = function (req, res) {
+ res.end('Hello, World!');
+};
+http.createServer(app).listen(8080, function () {
+ console.info('Listening on', this.address());
+});
+```
+
+```bash
+node server.js
+```
+
+An Express App
+
+```bash
+mkdir my-server
+pushd my-server
+npm init
+npm install --save express
+```
+
+`app.js`:
+
+```js
+'use strict';
+
+var express = require('express');
+var app = express();
+
+app.use('/', function (req, res, next) {
+ res.end("Hello, World!");
+});
+
+module.exports = app;</code></pre>
+```
+
+`server.js`:
+
+```js
+'use strict';
+
+var http = require('http');
+var app = require('./app.js');
+
+http.createServer(app).listen(8080, function () {
+ console.info('Listening on', this.address());
+});
+```
+
+```bash
+npm start
+```
+++ /dev/null
-#
-# title: Node.js
-# homepage: https://nodejs.org
-# tagline: |
-# Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
-# description: |
-# Node is great for simple, snappy HTTP(S) servers, and for stitching APIs together with minimal fuss or muss.
-# examples: |
-#
-# ### Hello World
-#
-# ```bash
-# node -e 'console.log("Hello, World!")'
-# > Hello, World!
-# ```
-#
-# ### A Simple Web Server
-#
-# `server.js`:
-#
-# ```bash
-# var http = require('http');
-# var app = function (req, res) {
-# res.end('Hello, World!');
-# };
-# http.createServer(app).listen(8080, function () {
-# console.info('Listening on', this.address());
-# });
-# ```
-#
-# ```bash
-# node server.js
-# ```
-#
-# ### An Express App
-#
-# ```bash
-# mkdir my-server
-# pushd my-server
-# npm init
-# npm install --save express
-# ```
-#
-# `app.js`:
-#
-# ```js
-# 'use strict';
-#
-# var express = require('express');
-# var app = express();
-#
-# app.use('/', function (req, res, next) {
-# res.end("Hello, World!");
-# });
-#
-# module.exports = app;</code></pre>
-# ```
-#
-# `server.js`:
-#
-# ```js
-# 'use strict';
-#
-# var http = require('http');
-# var app = require('./app.js');
-#
-# http.createServer(app).listen(8080, function () {
-# console.info('Listening on', this.address());
-# });
-# ```
-#
-# ```bash
-# npm start
-# ```
-#
-
-This is a comment... because... poor choices I made.
-
-Don't worry, this will be yaml or markdown in the... sometime... future
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz",
"integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ=="
+ },
+ "marked": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz",
+ "integrity": "sha512-EkE7RW6KcXfMHy2PA7Jg0YJE1l8UPEZE8k45tylzmZM30/r1M1MUXWQfJlrSbsTeh7m/XTwHbWUENvAJZpp1YA=="
+ },
+ "shmatter": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/shmatter/-/shmatter-1.0.1.tgz",
+ "integrity": "sha512-bBAvHI8640XcMDsShK2HOR8WOkF65hMprXr7Rsqb3z+26/5qna3jZfP7VZScItGoULUYyNeen9isD60KxtD2hQ==",
+ "requires": {
+ "marked": "^1.0.0"
+ }
}
}
}
},
"homepage": "https://github.com/webinstall/packages#readme",
"dependencies": {
- "@root/request": "^1.6.1"
+ "@root/request": "^1.6.1",
+ "shmatter": "^1.0.1"
}
}