Skip to content

upgrade generators to use the latest yeoman-generator - #363

Merged
jannyHou merged 3 commits into
masterfrom
update/yeoman-generator
Aug 30, 2018
Merged

upgrade generators to use the latest yeoman-generator#363
jannyHou merged 3 commits into
masterfrom
update/yeoman-generator

Conversation

@jannyHou

@jannyHou jannyHou commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

Review

Appreciate all your patient on reviewing the huge code change :)

  • Most of test cases pass except 4-5 to investigate(skipped at this moment), since the code change is huge I put the PR in review and am fixing the skipped ones at the same time.
  • There are 14 generators upgraded, I break down them into multiple commits, roughly 1 commit updates 1 generator.
  • Some commits may contain comment/debug/console.log, while they are removed in the next commits.
  • All the linting errors are fixed in the last commit.

Description

Here is a list of items to do/finished:

  • Updated the acl generator to extend the latest yeoman generator class
  • Updated the tests for acl generator to use yeoman-test
  • Update loopback-cli to create the env from yeoman-environment, see PR feat: switch to yeoman-env loopback-cli#71
  • Fix the help option
  • Update all generators
    • app (bluemix tbd)
    • bluemix
    • boot-script
    • datasource (bluemix tbd)
    • export-api-def
    • middleware
    • model
    • oracle
    • property
    • relation
    • remote-method
    • soap
    • swagger
    • zosconnectee

Related issues

connect to #355

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

Comment thread .eslintrc Outdated
}]
},
"parserOptions": {
"ecmaVersion": 8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We cannot use async functions in generator-loopback yet, we need to keep support for Node.js 6.x.

Please revert this change.

@jannyHou jannyHou Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's great. I was going to update all the this.async() places to use async await.
Reverting it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the idea of getting rid of this.async() - if you like to do that then I fully support you in that change!

The trick is to use Promise APIs instead of async functions.

For example:

async function foo() {
  await bar();
  return 'result';
}

needs to be written in Promise-only styler as follows:

function foo() {
  return bar
    .then(() => 'result');
}

Comment thread acl/index.js Outdated
// }

loadModels: actions.loadModels,
async ACLloadProject() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto, we cannot use async functions in generator-loopback yet.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 379cdda to 6d79c28 Compare August 1, 2018 19:41
Comment thread app/index.js
// Export it for strong-cli to use
module.exports._package = pkg.name + ': ' + pkg.version;
module.exports._yeoman = yeoman;
module.exports._yeomanEnv = require('yeoman-environment');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is related to strongloop and loopback-cli

Comment thread app/index.js Outdated
var bluemix = require('../bluemix/helpers');
var fs = require('fs');
var actions = require('../lib/actions');
// var actions = require('../lib/actions');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the first commit, please DO NOT review the change in file app/index.js.

I have to update it to test the acl generator from cli, while the app generator is not finished.

Comment thread app/index.js Outdated

// Export it for strong-cli to use
module.exports._package = pkg.name + ': ' + pkg.version;
module.exports._yeoman = yeoman;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need to export yeoman? Isn't _yeomanEnv all that loopback-cli needs?

@jannyHou

jannyHou commented Aug 2, 2018

Copy link
Copy Markdown
Contributor Author

FYI yeoman-generator has an additional default option called --force-install, I feel it's ok to have it for each generator so I didn't remove it.

@jannyHou jannyHou changed the title WIP: upgrade acl generator WIP: upgrade generators to use the latest yeoman-generator Aug 9, 2018
@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from c522b4e to bf89bdd Compare August 16, 2018 15:14
@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 3d06c10 to df36e65 Compare August 20, 2018 15:09
@jannyHou jannyHou changed the title WIP: upgrade generators to use the latest yeoman-generator upgrade generators to use the latest yeoman-generator Aug 20, 2018
@jannyHou jannyHou self-assigned this Aug 20, 2018
Comment thread .eslintrc Outdated
}]
}
}
} No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pls add a new line

Comment thread acl/index.js
}

loadProject() {
debug('loading project...');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need those debug messages?

@jannyHou jannyHou Aug 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dhmlau I think the progress info like ^ is fine, since it doesn't contain any variable.
I will double check all the places that prints variables....I don't see any sensitive info in the generator, while some probably prints long nested object. Will remove them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok. I have this question because it may not seem useful in the future for debugging purpose. If you think it's needed, i'm ok to keep it. thanks.

Comment thread app/index.js Outdated

this.argument(g.f('name'), {
desc: g.f('Name of the application to scaffold.'),
this.argument('name', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to keep g.f('name'), otherwise this issue #377 will appear again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

Comment thread app/index.js Outdated

bluemix() {
if (this.options.bluemix) {
this.log('\nBluemix configuration:');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this is out of scope for the task. Tthe string needs to be translated but can do it in another PR. i.e.
this.log(g.f('\nBluemix configuration:'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no problem :)

Comment thread bluemix/index.js Outdated
this.login.apply(this);
};

BMpromptServiceName() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: would it be better to have the function name as BMPromptServiceName instead of BMpromptServiceName?
Same for the functions below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch.

Comment thread datasource/index.js Outdated

this.argument(g.f('name'), {
desc: g.f('Name of the datasource to create.'),
this.argument('name', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to keep g.f('name') instead of 'name'

Comment thread test/bluemix.test.js
ygAssert.file('./server/datasources.bluemix.js');
done();
});
it('should generate datasources.bluemix.js', function() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't need to pass done in the parameter or call done() inside?

@jannyHou jannyHou Aug 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dhmlau ah, don't need to. same as I put in comment loopbackio/loopback-datasource-juggler#1616 (comment), mocha handles it if a Promise returned.

Comment thread test/z-app.test.js
@@ -0,0 +1,391 @@
// Copyright IBM Corp. 2014,2016. All Rights Reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the file name is called z-app.test.js. Is it possible to rename the file name to fit what it's supposed to do?

@jannyHou jannyHou Aug 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dhmlau run the app.test.js first causes other tests fail, unfortunately I couldn't figure it out within one day so I prefer to leave it out of the scope of this PR :( I can create an issue to fix it afterwards.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i see. so the tests in this file is only a temp place to know what tests we're skipping now? i'm good with a follow up PR to handle the rest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not happy about moving renaming this test file from app.test.js to z-app.test.js and back, because it prevents git from rendering a useful diff showing the changes made alongside the transfer.

If it's too difficult to fix these test properly, then I am proposing the following workaround:

  1. In this pull request, keep the file name as app.test.js and mark the tests as skipped via describe.skip at top-level.
  2. In the next pull request, rename the file to z-app.test.js and remove .skip.

Or maybe do both changes in the same pull request, but split them into two commits.

Thoughts?

Also BTW, the test name z-app.test.js does not make this test file the last one, there is still test/zosconnectee.test.js that's run after this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bajtos True the code compare is pretty bad :( skipping it makes sense to me 👌

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from e87d95f to f351d26 Compare August 21, 2018 21:23

@shimks shimks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good work, as the Japanese would say 'Otsukaresama'.

Has linting been run btw? I don't know whether there are going to be any unused variables lying around. I'd also run the thing through prettier

Comment thread app/index.js
}

generateYoRc: function() {
commit() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please document what the point of this function is?

Comment thread app/index.js Outdated
// Export it for strong-cli to use
module.exports._package = pkg.name + ': ' + pkg.version;
module.exports._yeoman = yeoman;
// module.exports._yeoman = yeoman;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be uncommented or removed?

Comment thread lib/actions.js
* @param {String} destination Destination file to write to. Relative to this.destinationRoot()
*/

copy(source, dest) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've noticed that this function and the ones below aren't in the original file. When are these used?

@jannyHou jannyHou Aug 24, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shimks good question. Let me elaborate this breaking change between yeoman-generator@0.x and yeoman-generator@3.x:

0.x has a function directory that copies the files from source to destination for you, see code here. While 3.x doesn't have it and leaves users to do the file moving.
That's why I added our implementation of directory in the actions.js file at the first place, then added the other nested functions it calls:
directory --> copy --> template

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we write tests for these functions or are they already tested as part of the generator specific tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@b-admike We have tests for helper functions but not actions. Testing actions require complicated setup for generator and sandbox.
And honestly I would prefer to not add such overhead effort in this PR :-p
Also, every generator requires file moving, so we have plenty acceptance tests to prove those actions work well :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good to me!

Comment thread oracle/index.js
end: {
requireDriver: function() {
if (this.skip) return;
requireDriver() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The previous file had the requireDriver function nested under an end object. Is this change ok?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think end is a phase that version 0.x allows multiple functions to be executed. So I just refactor it to be a function that gets called in the original sequence. And I don't see a difference from the old generator :-p

Comment thread package.json Outdated
"loopback-soap": "^1.0.0",
"loopback-swagger": "^5.4.0",
"loopback-workspace": "^4.0.0",
"mem-fs-editor": "^5.1.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unused dependency

Comment thread test/help.test.js Outdated

// Jannyhou: to be fixed!
describe('prints right help message for each generator', function() {
// var CMD_NAMES = ['acl'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is not needed

Comment thread test/help.test.js
var helpFilePath = '../fixtures/help-texts/' + helpFileName;
var output = fs.readFileSync(helpFilePath, 'utf8');
assert.equal(output, helpText);
assert.equal(helpText, output);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The arguments are switched

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shimks Yep, the old code was wrong. Read the error message you will see, the first argument is expected result, while the second one is the actual result.

Comment thread test/model.test.js
});

it('should set dataSource to db if it exists', function() {
return new Promise(function(resolve, reject) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can just return wsModels.DataSourceDefinition.create; I'm assuming the method has promise support

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming loopback-workspace is depending on LB 3.x internally (and not on LB 2.x), then yes, methods like create should support promises out of the box.

Comment thread test/model.test.js Outdated
});

describe('with --bluemix', function() {
describe.skip('with --bluemix', function() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From what I remember, this test might supposed to fail when run locally. Try getting rid of the skip and see if the test passes in the CI

@jannyHou jannyHou Aug 22, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh...bad news. I just realized I only fixed the composed bluemix with app and datasource, while there is one with model. Sigh.
I am fixing them ^

Comment thread test/relations.test.js Outdated
});
});

// requires generator-yeoman v0.17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we get rid of these comments now?

@virkt25 virkt25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing work @jannyHou !! Everything looks good to me, just some nitpicks ... I tried pointing them out but figured you can spot them yourselves ... if not let me know and I can point out all the other spots. (; issue and self and some alignment issues for comments).

Comment thread app/index.js Outdated
msgs.push(list.map(it => ' ' + it).join('\n'));
return msgs.join('') + '\n';
},
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: Don't need ;

Comment thread bluemix/helpers.js
type: 'confirm',
default: true,
when: !this.bluemix,
var done = this.async();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@virkt25 It's get called on Line 173

Comment thread bluemix/index.js Outdated
help() {
return helpText.customHelp(this, 'loopback_bluemix_usage.txt');
},
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't need the ;

Comment thread boot-script/index.js Outdated
help() {
return helpText.customHelp(this, 'loopback_boot-script_usage.txt');
},
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You shouldn't need the ;

Comment thread boot-script/index.js Outdated
done();
}.bind(this));
},
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You shouldn't need the ;

Comment thread lib/actions.js Outdated
},
]).then(function(answers) {
var dir = answers.dir;
self.dir = dir;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be able to do this.dir as this function is bound to this.

Comment thread lib/actions.js
};

/**
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alignment

Comment thread lib/actions.js
});
};

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alignment

Comment thread lib/actions.js
/**
* Modify the list of datasources created by {@link loadDataSources}
* and append an item for `null` datasource.
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alignment

Comment thread lib/actions.js Outdated
data || this,
options
);
// memfs.create().copyTpl(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this can be removed.

@bajtos bajtos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am so glad to see all generators updated to the new yeoman version. Thank you @jannyHou for this gigantic effort.

I have few comments to discuss and address, see below.

Comment thread app/index.js
@@ -65,11 +67,12 @@ module.exports = yeoman.Base.extend({
this.option('version', {
desc: g.f('Display version information'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed the first argument, name, is using description property name; while all other options (not arguments!) are still using desc property name. Could you please check which form is the right one and ideally unify the implementation to use the same property name everywhere (if possible)?

@jannyHou jannyHou Aug 27, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bajtos either of them works, see options in yeoman-generator and arguments in yeoman-generator

And our help message generator

But I agree it's better to unify them. I will change description to desc.

Comment thread app/index.js Outdated
}
};
printNextSteps() {
if (!this.options.initBluemix) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use early return here to reduce the level of indentation?

if (this.options.initBluemix) return;

Comment thread datasource/index.js Outdated
}
}.bind(this));
},
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am surprised that eslint and/or prettier did not catch these extra ;. Are we missing an eslint rule in our config?

Comment thread test/app.test.js
@@ -1,391 +0,0 @@
// Copyright IBM Corp. 2014,2016. All Rights Reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 for finding a more robust solution.

Comment thread test/datasource.test.js
// I manually verified that by choosing "install connector",
// the custom module is intalled
// Here it fails since folder `node_modules` is not created
it.skip('should support custom connector', function() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Posting a line-level comment to remind us about a test that's skipped now.

   // Jannyhou: To be fixed (3)!
   // I manually verified that by choosing "install connector",
   // the custom module is intalled
   // Here it fails since folder `node_modules` is not created

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm @bajtos could you elaborate more about what does "line-level comment" mean?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the confusion. By line-level I meant that the comment was attached to a particular source code line (test/datasource.test.js:83) and will be hidden by GitHub once you change that code; as opposed to a "regular" comment that stays in the top-level discussion & expanded forever.

Anyhow, my intention was to point out a comment you have added and which says that a skipped test needs to be fixed. IMO, something needs to be done about that comment before landing this pull request.

If you think fixing the skipped test is out of scope of this PR, then I am totally fine with that, but please reword the comment so that it does not look like something that was slipped through the review process.

For example:

// FIXME(jannyHou) This test fails because folder `node_modules` is not created.
// For now, verify this functionality manually by choosing "install connector"
// and checking that the custom module is installed.

Comment thread test/middleware.test.js Outdated
paths: ['/x', '/y'],
params: '{"z": 1}',
}).then(function() {
// eslint-disable-next-line max-len

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's rewrite the next line so that it fits in our max line length.

const middlewareConfig = readMiddlewaresJsonSync('server');
const newSources = Object.keys(middlewareConfig.routes);

Comment thread test/model.test.js
});

it('should set dataSource to db if it exists', function() {
return new Promise(function(resolve, reject) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming loopback-workspace is depending on LB 3.x internally (and not on LB 2.x), then yes, methods like create should support promises out of the box.

Comment thread test/z-app.test.js
@@ -0,0 +1,391 @@
// Copyright IBM Corp. 2014,2016. All Rights Reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not happy about moving renaming this test file from app.test.js to z-app.test.js and back, because it prevents git from rendering a useful diff showing the changes made alongside the transfer.

If it's too difficult to fix these test properly, then I am proposing the following workaround:

  1. In this pull request, keep the file name as app.test.js and mark the tests as skipped via describe.skip at top-level.
  2. In the next pull request, rename the file to z-app.test.js and remove .skip.

Or maybe do both changes in the same pull request, but split them into two commits.

Thoughts?

Also BTW, the test name z-app.test.js does not make this test file the last one, there is still test/zosconnectee.test.js that's run after this one.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 3c25a00 to c327ed1 Compare August 27, 2018 18:05
@jannyHou

Copy link
Copy Markdown
Contributor Author

@virkt25 Thank you for pointing out those extra semicolons! I feel the eslint definitely has some problem, having the semicolon/removing it both pass npm run lint.

And according to eslint-config-loopback, the expected behaviour is ["error", "always"], which requires the semicolon per statement. What do you think?

If we decide to remove all extra semicolon, I can add rule "semi": ["error", "always"] in .eslintrc as a workaround if fixing the lint takes time.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 69d1a70 to 3768a8f Compare August 27, 2018 19:43
@virkt25

virkt25 commented Aug 27, 2018

Copy link
Copy Markdown
Contributor

I'm indifferent to the rule as long as it's applied consistently to the code base.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from b1a462e to 03bdc82 Compare August 27, 2018 21:23
@jannyHou

Copy link
Copy Markdown
Contributor Author

ok I figured out why eslint didn't report error for those extra semicolons.
FYI
"no-extra-semi": "error" checks the semicolon after each class method.(inside class)
"semi": ["error", "always"] only checks the semicolon after class definition.(outside class)

And removed all extra semicolons in this commit, will keep it as a separate commit when merge PR.

@bajtos bajtos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Few more minor comments to address, none of them blocking this PR from being landed as far as I am concerned.

Comment thread .eslintrc Outdated
"ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)"
}]
}],
"no-extra-semi": "error"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move this configuration to https://github.com/strongloop/eslint-config-loopback so that it's eventually enabled for all LB (3.x) projects/repositories.

Comment thread package.json Outdated
"node": ">=6"
},
"scripts": {
"lint:fix": "eslint --ignore-path .gitignore --fix .",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you considered re-using the cli args from lint script via npm run lint --fix?

Comment thread test/model.test.js Outdated
expect(modelGen.abort).to.eql(true);
done();
});
var ctx = helpers.run(path.join(__dirname, '../model'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread test/model.test.js Outdated
expect(modelGen.abort).to.eql(true);
done();
});
var ctx = helpers.run(path.join(__dirname, '../model'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread test/model.test.js Outdated
.eql('cloudant-demo-service');
done();
});
var ctx = helpers.run(path.join(__dirname, '../model'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread bluemix/helpers.js Outdated

prompts.push(toolchainPrompt, dockerPrompt);

this.prompt(prompts).then(function(answers) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A nitpick: can you rewrite this using an arrow function and remove .bind(this)?

return this.prompt(prompts).then(answers => {
  // ...
});

Comment thread lib/actions.js
* @param {String} destination Destination file to write to. Relative to this.destinationRoot()
*/

copy(source, dest) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we write tests for these functions or are they already tested as part of the generator specific tests?

Comment thread app/index.js Outdated
}

copyFiles: function() {
writing() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: can there be a better function name here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

couldn't remember why I changed the name....reverted it.

Comment thread app/index.js
// from memory to destination folder.
commit() {
var done = this.async();
this.fs.commit(done);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From Yeoman docs:

It is worth noting that although this.fs exposes commit, you should not call it in your generator. Yeoman calls this internally after the conflicts stage of the run loop.

http://yeoman.io/authoring/file-system.html. It's fine if we use it, but I was wondering whether there are alternatives.

@jannyHou jannyHou Aug 28, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@b-admike yep it's a workaround. I eventually calls it because there is no easy better solution for finishing file move before invoke the composed generator :(

Comment thread bluemix/index.js Outdated
this.login.apply(this);
}

BMPromptServiceName() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The method names should be camelCase, such as bmPromptServiceName.

@raymondfeng

Copy link
Copy Markdown
Member

@jannyHou Thank you for the bold efforts! Mostly LGTM.

@b-admike b-admike left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM; Great job Janny! This was a huge undertaking and I'm glad we have these tests up and running with the shiny new version of yeoman-generator 🎉

Comment thread test/app.test.js Outdated
var fs = require('fs');
var rimraf = require('rimraf');

// Rename it to run as the last test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: can we re-phrase this statement to start like this: The test file is named app.test.js as a workaround for...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, it's fixed lol. Let me remove the comment.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from a636ce9 to 7fcd77c Compare August 29, 2018 16:34
Comment thread model/index.js Outdated
// See https://github.com/strongloop/generator-loopback/issues/116
this.invoke = require('yeoman-generator/lib/actions/invoke');
},
// this.invoke = require('yeoman-generator/lib/actions/invoke');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this comment be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep good catch, removed.

@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 7fcd77c to 34d58cc Compare August 29, 2018 19:00
@jannyHou
jannyHou force-pushed the update/yeoman-generator branch from 34d58cc to 21e6135 Compare August 30, 2018 01:54
@jannyHou
jannyHou merged commit e038bce into master Aug 30, 2018
@bajtos
bajtos deleted the update/yeoman-generator branch August 30, 2018 10:53
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.

7 participants