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

Hotfix/scoped package support #3453

Merged

Conversation

daankets
Copy link
Contributor

@daankets daankets commented Feb 7, 2018

Please always submit pull requests on the development branch.

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? sometimes - issue on Node 6 (tests fail every now and then)
Fixed tickets #3451
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

This fix ensures that you can install scoped modules correctly. It's mainly a fix for the canonicalisation of the module name, when it has a form of @scope/name. Before, the routine that separated the module name separated at the last slash. Secondly, the module name was incorrectly split (assuming the @ was the start of a tag).

Note: Never mind the 2nd commit. It was reverted during the merge. I originally tested locally with an increased hotfix version.

@CLAassistant
Copy link

CLAassistant commented Feb 7, 2018

CLA assistant check
All committers have signed the CLA.

@wallet77
Copy link
Contributor

wallet77 commented Feb 7, 2018

Hi @daankets,

I'm waiting for your feedback about my comments, I think tests will passed after some changes.

Thank you for your contribution !

@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

@wallet77 Where can I find these comments?? I didn't get any notification nor can I find anything in this thread...

@@ -18,7 +18,7 @@ describe('Utility', function() {
assert(Utility.getCanonicModuleName('ma-zal/pm2-slack') === 'pm2-slack');
assert(Utility.getCanonicModuleName('ma-zal/pm2-slack#own-branch') === 'pm2-slack');
assert(Utility.getCanonicModuleName('pm2-slack') === 'pm2-slack');
assert(Utility.getCanonicModuleName('@org/pm2-slack') === 'pm2-slack');
assert(Utility.getCanonicModuleName('@org/pm2-slack') === '@org/pm2-slack');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just add a test with multiple @.
Like @org/[email protected]
Just to ensure we test all cases.

lib/Utility.js Outdated
if(canonic_module_name.indexOf('@') !== -1) {
canonic_module_name = canonic_module_name.split('@')[0];
//pm2 install @somescope/[email protected]
if(canonic_module_name.lastIndexOf('@') !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to have > 0 instead of !==0.
Otherwise if you have a simple module name (without @, / etc) condition will be evaluated as true because lastIndexOf('@') will return -1.
This is why tests are failing.

@wallet77
Copy link
Contributor

wallet77 commented Feb 8, 2018

Sorry my mistake, review wasn't submitted ;)

- Additional test case for @scope/module@tag
- Fixed a bug for checking the position of the last @ in the module name, that could trigger on -1.
@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

@wallet77 I've updated the pull after your remarks (agree with both, but I did test the case with @scope/module@additionalTag though ;-))

lib/Utility.js Outdated
@@ -223,12 +223,14 @@ var Utility = module.exports = {

//pm2 install username/module
else if(canonic_module_name.indexOf('/') !== -1) {
canonic_module_name = canonic_module_name.split('/')[1];
if (!canonic_module_name.startsWith("@")){
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests on 0.12 failed cause startsWidth is not supported :(
I think we should write test just like this :
if (canonic_module_name[0] !== "@"){

@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018 via email

@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

@wallet77 The build now fails on Node 6 only, but I don't know the code base enough to understand why (without a hint). It's in the aggregator mocha tests. They rune fine on other node versions though.

@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

@wallet77 Just noticed they don't ALWAYS fail. If I rerun the tests on node 6, they succeed more than they fail.

@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

This test failed on the CI with node 6. However, it runs fine here (90% of the time)

/usr/local/opt/node@6/bin/node /Users/daankets/Projects/pm2/node_modules/mocha/bin/_mocha --ui bdd --reporter "/Users/daankets/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/173.4548.30/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js" /Users/daankets/Projects/pm2/test/interface/aggregator.mocha.js --grep "Transactions Aggregator "
2018-02-08T12:24:39.205Z pm2:aggregator spans is null
2018-02-08T12:24:39.333Z pm2:aggregator Packet malformated null
2018-02-08T12:24:39.455Z pm2:aggregator Reseting agg for app:appname meta:{}
2018-02-08T12:24:39.467Z pm2:aggregator Reseting agg for app:appname meta:{"name":"appname"}
2018-02-08T12:24:39.467Z pm2:aggregator Reseting initialization timeout app:appname
2018-02-08T12:24:39.469Z pm2:aggregator Reseting agg for app:APP2 meta:{"name":"APP2","server":"test","rev":"xxx"}

Process finished with exit code 0

@wallet77
Copy link
Contributor

wallet77 commented Feb 8, 2018

@daankets if they passed one time then it's ok.
Indeed sometimes travis failed but it's not related to your PR.
I will merge it when all tests are green :)

@wallet77 wallet77 merged commit 974f9bf into Unitech:development Feb 8, 2018
@daankets daankets deleted the hotfix/scoped-package-support branch February 8, 2018 13:28
@daankets
Copy link
Contributor Author

daankets commented Feb 8, 2018

@wallet77 Thanks. Any idea when the next release is planned? I can't wait to start using this feature ;-)

@wallet77
Copy link
Contributor

wallet77 commented Feb 8, 2018

No precise date for now but during February I think.
@Unitech when do we expect a release ?

inerc pushed a commit to inerc/pm2 that referenced this pull request Feb 11, 2020
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.

3 participants