lonekorean / wordpress-export-to-markdown

Converts a WordPress export XML file into Markdown files.
MIT License
1.07k stars 216 forks source link

`punycode` deprecated; `psl` and `tough-cookie` packages causing issues #119

Closed tarihala closed 3 months ago

tarihala commented 3 months ago

Issue Looks like the punycode module, used in the dependencies psl and tough-cookie are deprecated, causing the wizard and package to fail.

Recreate

  1. Attempt to run following instructions $ npx wordpress-to-markdown produces error:
    (node:5946) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)

Investigation

  1. $ npm install wordpress-to-markdown
  2. Add to package json the --trace-deprecation flag
    {
    "dependencies": {
    "wordpress-export-to-markdown": "^2.3.7"
    },
    "scripts": {
    "trace": "NODE_OPTIONS='--trace-deprecation' wordpress-export-to-markdown"
    },
    }
  3. $ npm run trace shows me there is an issue with psl package, and when I fix, also with tough-cookie package.

Temporary fix to get to run Add a trailing forward to slash to two files;

  1. ./node_modules/psl/index.js Change line 5, from: var Punycode = require('punycode'); to var Punycode = require('punycode/');

  2. ./node_modules/tough-cookie/lib/cookie.js Change line 43, from: punycode = require('punycode'); to punycode = require('punycode/');

Following these changes, the package works.

Thoughts Looks like both psl and tough-cookie packages need updating, patches need to be made, or alternative dependencies are required. Until then, these temporary fixes got it working for me.

P.S. Thanks @lonekorean for sharing your work!

tarihala commented 3 months ago

Using: wordpress-export-tomarkdown 2.3.7 macOS Sonoma 14.5 node 22.2.0 npm 10.7.0

lonekorean commented 3 months ago

Hi @tarihala, thanks for bringing this to my attention and digging into it!

That scary looking deprecation warning is a downstream result of me using this deprecated package. I knew that one day it would cause a problem. Looks like today is that day. 😄

I ripped it out and replaced it with a different package and updated some code. If you have time, can try running it again with this branch?

Should be able to just:

git fetch
git checkout deprecation-fix
npm install

Then run as before.

I'll merge and release a new version soon, but would make me feel better to know it runs smoothly on your computer.

tarihala commented 3 months ago

@lonekorean that was fast! Looks great! That branch works fine on my computer and with my export.xml file. Nice work! 🎸

lonekorean commented 3 months ago

Awesome, fix released in v2.4.0. Closing this out, thank you!