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

Dependencies and format #64

Merged
merged 26 commits into from
Feb 4, 2022

Conversation

ath0mas
Copy link
Contributor

@ath0mas ath0mas commented Jan 31, 2022

More dependencies update (fix #63): correct version in package-lock, xcode v3, @xmldom/xmldom
+ Some formatting mostly to cleanup js whitespaces and indents

Used and everything is fine for both android and ios in my case 👍

(you should toggle "Hide whitespace" or look at each commit separately for easier review)


Dependencies:

  • fs-extra: replaced by node fs + smaller single-responsibility mkdirp
  • iconv-lite: removed, node 'utf8' default encoding to write files is fine
  • lodash: replaced by underscore, same api, smaller bundle
  • xcode: updated from v0.9 to v3
  • xml-writerremoved, unused
  • xml2js: ok
  • xmldom: removed, unique use replaced by regex matching
  • path: removed, node path is fine
  • glob: ok

Still OK for both android and ios in my test project.

Maybe add a line inside Readme about "new" node version "compatibility" in 4.0.0? reviewing package-lock.json "engines" may help.
=> "node": ">=10" for mkdirp and xcode v3

@rodrigograca31
Copy link
Collaborator

Looks good! Thanks and thanks for testing!

@rodrigograca31
Copy link
Collaborator

I will merge and publish as 4.0.0 as soon as I solve an issue with my npm account which isnt letting me publish... 😭

@ath0mas
Copy link
Contributor Author

ath0mas commented Feb 1, 2022

I will have some more cleanup and minor rewrites to suggest later today ; in this PR or a new one after this one merged?

@rodrigograca31
Copy link
Collaborator

I think its fine if you keep it in this one. like I said I will review and publish everything in the end as 4.0.0

@ath0mas
Copy link
Contributor Author

ath0mas commented Feb 2, 2022

Done for me - ready for review

@@ -196,7 +196,7 @@ function processResult(context, lang, langJson, stringXmlJson) {
_.forEach(langJsonToProcess, function (val, key) {
// positional string format is in Mac OS X format. change to android format
val = val.replace(/\$@/gi, '$s');
val = val.replace(/\'/gi, "\\'");
val = val.replace(/'/gi, "\\'");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this doesnt break stuff. probably wont but I dont know regex well enought. 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE detected it as a "Redundant character escape in RegExp" and indeed quotes are not reserved characters.

if (platforms.indexOf('android') >= 0) {
promises.push(android_script(context));
}

if (platforms.indexOf('ios') >= 0) {
Copy link
Collaborator

@rodrigograca31 rodrigograca31 Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this re-order was necessary ... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but alpha order as much as common order in Cordova plugins to deal with Android before iOS.

package.json Outdated
@@ -29,7 +29,6 @@
"glob": "^7.2.0",
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"path": "^0.12.7",
Copy link
Collaborator

@rodrigograca31 rodrigograca31 Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 less dependency! yay! 🥳 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! :) and more after all ; I am going to edit PR description to give detail about what changed here with all those newer commits added.

if (err) throw err;
fs.writeFileSync(fd, buffer);
});
fs.writeFileSync(path.join(lProjPath, fileName), stringToWrite);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering exactly this! I didnt understand why there was encoding going on.... thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that, before #35, the encoding used to write file was 'utf16' (requiring iconv-lite and buffer).
Back to using 'utf8' means we can simply use writeFile 👍 .

package.json Outdated
@@ -29,7 +29,6 @@
"glob": "^7.2.0",
"lodash": "^4.17.21",
"xcode": "^3.0.1",
"xml-writer": "^1.7.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another one!? 😮 great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one was never required nor used yes

@rodrigograca31
Copy link
Collaborator

rodrigograca31 commented Feb 2, 2022

Let me ask you for just one last "fix"
Can you take a look at the use of fs-extra ?

seems its used to use fs.ensureDir because as far as I know the other functions (fs.readFile, fs.writeFile, etc) are in "normal" fs (from node)... can you replace it and remove fs-extra ?

You did a great job so far! The community really appreciates it!

@ath0mas
Copy link
Contributor Author

ath0mas commented Feb 3, 2022

Let me ask you for just one last "fix" Can you take a look at the use of fs-extra ?

seems its used to use fs.ensureDir because as far as I know the other functions (fs.readFile, fs.writeFile, etc) are in "normal" fs (from node)... can you replace it and remove fs-extra ?

You did a great job so far! The community really appreciates it!

:) I saw it too yesterday, only basic fs methods except these two ensureDir as you say ; so I let it go.

But I went back to it today as you asked for: fs for everything + install and use of mkdirp for this precise need (a small and single-responsibility package ; thought about make-dir too but chose this one).

@rodrigograca31 rodrigograca31 merged commit 998a220 into kelvinhokk:master Feb 4, 2022
@rodrigograca31
Copy link
Collaborator

I will now tag it as 4.0.0 but cant push to npm yet....

@rodrigograca31
Copy link
Collaborator

4.0.0 was published to npm! 🥳 🎉

(will now add "node": ">=10")

@ath0mas ath0mas deleted the dependencies-and-format branch February 6, 2022 12:28
@pklaes
Copy link
Contributor

pklaes commented Feb 7, 2022

Great! Thanks a lot, guys!

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

Successfully merging this pull request may close these issues.

npm audit failes with 5 vulnerabilities (4 low, 1 moderate)
3 participants