maxime1992 / dev.to

[Template] My dev.to articles
58 stars 12 forks source link

Added a tool to create posts and setting up everything #8

Closed ramclen closed 3 years ago

ramclen commented 4 years ago

Hello, I added a new script to the project to automate how we create posts and setting up everything on the project.

To use the tool you need to add your dev.to key on the config.json.dist and remove .dist extension from the file. After that you run the command: ./tools/create-post.js "My new titlte"

What the script does:

marioarranzr commented 4 years ago

Really good stuff!

jikuja commented 4 years ago

Cool idea. I cherry-picked this for my repo and run into some problems:

ramclen commented 4 years ago
  • maxime1992/dev-to-git#19

Cool idea. I cherry-picked this for my repo and run into some problems:

  • New dependencies are missing from package.json and package-lock.json
  • Project is already using got. Using axios does unneeded production dependency size increase
  • tools/config.json shoud be added into .gitignore for safety reasons
  • POST fails with {"error":"Body markdown is too short (minimum is 0 characters)","status":422}

    • Looks like body_markdown is required even dev.to API documantion does not mention it as required data
  • The body must contain some data, otherwise article updater will fail: maxime1992/dev-to-git#19

Great points @jikuja. I am going to made the changes and update this branch. As you said, it is important to have the config on .gitignore for security reasons, I have on my repo but I forgot to add this change in this PR.

Hopefully @maxime1992 could give us his point too and have this PR merge

maxime1992 commented 4 years ago

Hi guys, sorry it took me so long to get back to you and thanks for the interest on the lib!

First of all, congrats for having a go at this :smile_cat:!

I like the idea here but... I'm not sure this is the best place to implement it.
This repository is just a template and this is not where I'd reimplement the authentication to dev.to and using an http lib like got directly.

I think something slightly more robust could be built on the CLI I wrote to push articles to dev.to (and which I'm using on this "maxime1992/dev.to" template): https://github.com/maxime1992/dev-to-git

There's already an issue for that here: https://github.com/maxime1992/dev-to-git/issues/8

Assuming the proposed command got implemented and we could do something like the following:

dev-to-git create-article "My amazing new blog post"

I think on the template side it'd be as simple as having a node script just calling the CLI and once we receive a good HTTP response, then simply create an empty folder.

To give a summary of my thinking here:

maxime1992 commented 3 years ago

As per my comment above I'll go ahead and close this