Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npx staticrypt fails #146

Closed
cumbriasingers opened this issue Nov 23, 2022 · 8 comments
Closed

npx staticrypt fails #146

cumbriasingers opened this issue Nov 23, 2022 · 8 comments

Comments

@cumbriasingers
Copy link

My standard build script:

bundle exec jekyll build && npx staticrypt _site/thisfile.html myuniquepassword --salt 9872346ef723ab374 -o _site/thisfile.html -f "_includes/extensions/password_template.html"

fails with error message

fs.readFileSync(...).replaceAll is not a function

This is the first time it has failed after the best part of a year of regular use. Has something changed?

@robinmoisson
Copy link
Owner

robinmoisson commented Nov 23, 2022

Thanks for reporting - which version of staticrypt are you using? If you're on >=2.2 there has been some changes to the code in the past few weeks and lots of refactoring, an edge case bug might have gone through.

I tried to copy your directory structure but can't reproduce your issue so far. Where are you calling the npx command from, is that the root directory of your project?

I did noticed there was a function that didn't handle filepath exactly properly, I couldn't hit a bug with it but maybe that caused an issue in your case. I've made the function more resilient and added more verbose logging to the error you encountered - I've just pushed it to 2.3.1 on npm. Can you update and let me know how it goes?

If you need to have a working version asap you can also downgrade to <2.2 (~2.1.1), which is before the recent changes, but I'd be interested to understand what's going wrong in your case.

@AnzuTwo
Copy link

AnzuTwo commented Nov 23, 2022

Hi Robin - I am also running into the same issue.

Coincidentally I was trying to debug the same problem only a few minutes before you posted your comment above.
I've just updated and I am still seeing the issue that the user above mentioned.

+ staticrypt@2.3.1 updated 1 package and audited 29 packages in 0.36s

staticrypt .\proveYourself.html <MyPasswordHere>
C:\Users\<MyUserName>\AppData\Roaming\npm\node_modules\staticrypt\lib\formater.js:17 .replaceAll(/^.*\brequire\(.*$\n/gm, ""); ^

Thank you for all your help!

@robinmoisson
Copy link
Owner

robinmoisson commented Nov 23, 2022

Hi @AnzuTwo - thanks for sharing your details. Interesting to see the problem appears in a simple file structure as well.

Same question, are you calling the command from your project root directory? I don't see the npx in the npx staticrypt command, are you calling the a globally installed staticrypt?

The error you're posting is pretty weird for that version - I've moved the method in 2.3.1, and the line containing .replaceAll(/^.*\brequire\(.*$\n/gm, ""); isn't in formater.js any more (and it should also give a more verbose error message now). Are you sure you are calling the latest version when running the command?

@AnzuTwo
Copy link

AnzuTwo commented Nov 23, 2022

Sorry - It looks like I was in fact using 2.3.0. I've updated to 2.3.1, I think. (As you can clearly tell, I am not at all a software developer haha)

I added npx to the command but I'm still seeing the same error. It does reference the new helpers.js file now though.

PS C:\Users\<UserName>\Documents\<Folder>\new> staticrypt --version
2.3.1

PS C:\Users\<UserName>\Documents\<Folder>\new> npx staticrypt .\proveYourself.html <Password>
C:\Users\<UserName>\Documents\<Folder>\new\node_modules\staticrypt\cli\helpers.js:123 .replaceAll(/^.*\brequire\(.*$\n/gm, ""); ^

TypeError: fs.readFileSync(...).replaceAll is not a function

@robinmoisson
Copy link
Owner

robinmoisson commented Nov 23, 2022

Got it! I think. What's your node version, is it lower than 16?

I could reproduce in node 12, it looks like String.replaceAll doesn't exist in this node version.

I've just uploaded the patch in 2.3.2 - let me know if that fixes it for you.

@AnzuTwo
Copy link

AnzuTwo commented Nov 23, 2022

Node version is v12.19.0.

I updated to 2.3.2, tried again, and it worked! I have the encrypted file!

Thanks a lot for the help, this was fun. Very glad I was able to find this thread (:

@robinmoisson
Copy link
Owner

Awesome! Thank you both for updating & posting the detail of your errors, this is helping others too.

@cumbriasingers
Copy link
Author

Better than awesome. All working perfectly this morning - thanks so much for your swift response. And, of course, for all the work hitherto!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants