Level / awesome

An open list of awesome Level modules and resources.
MIT License
289 stars 22 forks source link

Automation [squash on merge] #11

Closed vweevers closed 6 years ago

vweevers commented 6 years ago

Took more code than I thought, and I want to move some stuff out. But it works :)

This moves the modules to JSON files as the source of truth and adds npm run awesome to:

vweevers commented 6 years ago

Added levelup compatibility badges to the bundles. This is specified in the JSON as:

https://github.com/Level/awesome/blob/cfa7d4fa90b62e28d2be2eafcd411030b9f938a1/modules/bundles.json#L6-L9

And jsondown now uses that same generic mechanism:

https://github.com/Level/awesome/blob/cfa7d4fa90b62e28d2be2eafcd411030b9f938a1/modules/stores.json#L23-L30

vweevers commented 6 years ago

The following files are now generic enough to be moved to their own npm packages:

But I prefer to first merge this PR and pull in more modules from the wiki (#1, which is much easier now) to see if there are any gaps in the tooling.

@ralphtheninja WDYT?

vweevers commented 6 years ago

Also, would you mind testing npm run awesome to avoid "works on my machine"? You can manually remove one of the tables from README before npm run awesome to see that it regenerates.

ralphtheninja commented 6 years ago

Also, would you mind testing npm run awesome to avoid "works on my machine"? You can manually remove one of the tables from README before npm run awesome to see that it regenerates.

Tried removing the first table but seems links are broken since no back ticks are inserted:

screenshot from 2018-04-29 14-02-35

diff --git a/README.md b/README.md
index 066d7bb..3aff8b6 100644
--- a/README.md
+++ b/README.md
@@ -20,14 +20,14 @@

 ## Bundles

-Convenience modules that bundle [a store](#stores) with [`levelup`] and [`encoding-down`].
+Convenience modules that bundle [a store](#stores) with [levelup] and [encoding-down].

 Name | Compatibility | Dependencies | Description
 :--- | :------------ | :----------- | :----------
-**[`level`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level.svg?label=%E2%99%A5)](https://david-dm.org/level/level) | Bundle for [`leveldown`].<br>Main entry point for beginners.
-**[`level-mem`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level-mem.svg?label=%E2%99%A5)](https://david-dm.org/level/level-mem) | Bundle for [`memdown`].
-**[`level-rocksdb`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level-rocksdb.svg?label=%E2%99%A5)](https://david-dm.org/level/level-rocksdb) | Bundle for [`rocksdb`].
-**[`level-browserify`]** | ![levelup](https://img.shields.io/badge/levelup-1.3-orange.svg) | [![dependencies](https://img.shields.io/david/level/level-browserify.svg?label=%E2%99%A5)](https://david-dm.org/level/level-browserify) | Bundle for [`level-js`].
+**[`level`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level.svg?label=%E2%99%A5)](https://david-dm.org/level/level) | Bundle for [leveldown].<br>Main entry point for beginners.
+**[`level-mem`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level-mem.svg?label=%E2%99%A5)](https://david-dm.org/level/level-mem) | Bundle for [memdown].
+**[`level-rocksdb`]** | ![levelup](https://img.shields.io/badge/levelup-2.0-brightgreen.svg) | [![dependencies](https://img.shields.io/david/level/level-rocksdb.svg?label=%E2%99%A5)](https://david-dm.org/level/level-rocksdb) | Bundle for [rocksdb].
+**[`level-browserify`]** | ![levelup](https://img.shields.io/badge/levelup-1.3-orange.svg) | [![dependencies](https://img.shields.io/david/level/level-browserify.svg?label=%E2%99%A5)](https://david-dm.org/level/level-browserify) | Bundle for [level-js].
ralphtheninja commented 6 years ago

Also, db.open() looks slightly odd:

screenshot from 2018-04-29 13-58-27

Maybe write Click to expand or something.

vweevers commented 6 years ago

Also, db.open() looks slightly odd:

I did not mean to keep that haha. Will fix.

Tried removing the first table but seems links are broken since no back ticks are inserted:

I'll see if I can replicate.

vweevers commented 6 years ago

@ralphtheninja which node version are you on?

ralphtheninja commented 6 years ago

@ralphtheninja which node version are you on?

node 10

ralphtheninja commented 6 years ago

@vweevers I can switch to another version just to see if that's the problem. Which one are you on?

vweevers commented 6 years ago

I just tried node 10, works for me. I was on node 8.6.0. Can you try it with the latest commit (https://github.com/Level/awesome/pull/11/commits/1bc21d477812311eaf885cdedf08a62482897ad9)?

vweevers commented 6 years ago

Found the issue, I think. I'm using the wrong node type for the link content. Instead of text I should use inlineCode.

ralphtheninja commented 6 years ago

Still have the same issues. I get the same error when running npm run awesome even without removing the first table. Also, if I remove the Core table it doesn't re-generate.

vweevers commented 6 years ago

:(

ralphtheninja commented 6 years ago

It's weird that you can't reproduce it :open_mouth:

ralphtheninja commented 6 years ago

If I only do npm run awesome (without changing anything). I get the following output:

$ npm run awesome 

> level-awesome@0.0.1 awesome /home/lms/src/level/awesome
> node src README.md modules/*

README.md
  1:12-1:23  warning  dead reference: leveldown      remark-bookmarks
  1:12-1:21  warning  dead reference: memdown        remark-bookmarks
  1:12-1:21  warning  dead reference: rocksdb        remark-bookmarks
  1:12-1:22  warning  dead reference: level-js       remark-bookmarks
  1:57-1:66  warning  dead reference: levelup        remark-bookmarks
  1:71-1:86  warning  dead reference: encoding-down  remark-bookmarks

⚠ 6 warnings
vweevers commented 6 years ago

Can you apply the following patch and send me the output?

diff --git a/src/index.js b/src/index.js
index bbab71a..073c195 100644
--- a/src/index.js
+++ b/src/index.js
@@ -23,8 +23,20 @@ remark()
     summary: () => 'Click to expand'
   })
   .use(github)
+
+  .use(() => (tree) => {
+    console.log('BEFORE')
+    console.log(JSON.stringify(tree, null, 2))
+  })
+
   .use(bookmarks, { modules })

+  .use(() => (tree) => {
+    console.log('AFTER')
+    console.log(JSON.stringify(tree, null, 2))
+    process.exit()
+  })
+
   // Disable padding to lessen diff noise
   .use(stringify, { paddedTable: false, looseTable: true })
ralphtheninja commented 6 years ago

output.txt

vweevers commented 6 years ago

The difference is this:

{
  "vince-before": {
    "identifier": "riakdown",
    "referenceType": "shortcut",
    "type": "linkReference",
    "children": [
      [{
        "type": "inlineCode",
        "value": "riakdown"
      }]
    ]
  },
  "magnus-before": {
    "identifier": "`riakdown`",
    "referenceType": "shortcut",
    "type": "linkReference",
    "children": [{
      "type": "inlineCode",
      "value": "riakdown",
      "position": ..
    }],
    "position": ..
  }
}

The presence of position on the nodes suggests that these are the parsed nodes of the original markdown, rather than newly generated nodes. Which means src/remark-generator.js doesn't do anything in your case.

And I found out why :) Your shell expands the glob pattern in node src README.md modules/* which is incompatible with:

https://github.com/Level/awesome/blob/491c7b52d5fd9ca931271dd7602149aa186eeb0d/src/index.js#L15

That's my bad. Fix coming in a bit.

vweevers commented 6 years ago

Fixed. There's one final thing I want to do: the bookmarks plugins should behave the same on parsed nodes and generated nodes. I.e. if you do node src README.md modules/core.json it should leave the other sections intact.

ralphtheninja commented 6 years ago

@vweevers Works fine now!

vweevers commented 6 years ago

I.e. if you do node src README.md modules/core.json it should leave the other sections intact.

Done.

ralphtheninja commented 6 years ago

@vweevers Maybe we could have a similar approach to documentation for e.g. leveldown, levelup, level, level-mem, level-rocksdb etc.

vweevers commented 6 years ago

@ralphtheninja yeah, def. I was thinking we could create a preset (see https://github.com/unifiedjs/unified#example-1) with a bunch of remark plugins, and use it everywhere.

ralphtheninja commented 6 years ago

@ralphtheninja yeah, def. I was thinking we could create a preset (see https://github.com/unifiedjs/unified#example-1) with a bunch of remark plugins, and use it everywhere.

Feel free to create some issues on it and break it down. Maybe it's even possible to use across the board? I'm thinking mainly on keeping the same "level style" in all READMEs.

ralphtheninja commented 6 years ago

@vweevers Side note; What's the "next step" for level? I'm thinking we should try to push through the latest abstract-leveldown into dependents to make this readme a little more green.

Maybe we can also use the level badge in related projects?

vweevers commented 6 years ago

I'm thinking we should try to push through the latest abstract-leveldown into dependents to make this readme a little more green.

Yes, starting with level-js. That's been waiting too long

vweevers commented 6 years ago

(Airtap work can wait, no?)

ralphtheninja commented 6 years ago

(Airtap work can wait, no?)

I feel airtap works rather well right now.

vweevers commented 6 years ago

Maybe we can also use the level badge in related projects?

What do you mean?

ralphtheninja commented 6 years ago

Sort of like the awesome badge. There are many awesome projects scattered across github, but they all (or most of them) use the awesome badge. If that makes sense.

vweevers commented 6 years ago

You mean adding the badge to projects like subleveldown (outside the level org)? Sure :)