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

feat(cli): add vscode config files #1336

Merged
merged 1 commit into from
Jun 1, 2018
Merged

feat(cli): add vscode config files #1336

merged 1 commit into from
Jun 1, 2018

Conversation

shimks
Copy link
Contributor

@shimks shimks commented May 16, 2018

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

"dist*/test/**/*.js",
"-t",
"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 don't think we have tests for hello-world.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, this should be there in case users want to build on top of hello-world

"cwd": "${workspaceRoot}",
"args": [
"--opts",
"${workspaceRoot}/test/mocha.opts",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have test/mocha.opts for this module.

"args": [
"--opts",
"${workspaceRoot}/test/mocha.opts",
"dist*/test/**/*.js",
Copy link
Member

Choose a reason for hiding this comment

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

This will not work. npm run build produces both dist8 and dist10 directories. Your wildcard will match both Node.js 8.x and 10.x dist files, therefore each test will be run twice, and if you run on Node.js 8.x, the 10.x tests will fail on unsupported syntax/APIs.

"args": [
"--opts",
"${workspaceRoot}/test/mocha.opts",
"dist*/test/**/*.js",
Copy link
Member

Choose a reason for hiding this comment

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

Ditto, dist* will not work well.

"pretest": "npm run clean && npm run build:current",
"test": "lb-mocha --allow-console-logs \"DIST/test\"",
"posttest": "npm run lint",
"test:dev": "lb-dist mocha DIST/test/**/*.js && npm run lint",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should be using lb-mocha instead of lb-dist mocha in all test:dev scripts, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed

@shimks shimks force-pushed the cli/vscode branch 2 times, most recently from 0b1f63c to ce132b6 Compare May 18, 2018 19:17
"name": "Run Mocha tests",
<% if (project.loopbackBuild) { -%>
"autoAttachChildProcesses": true,
"program": "${workspaceRoot}/node_modules/.bin/lb-mocha",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a problem here where if we were using this config to debug and we end up hitting the restart button, we get timed out with an ECONNREFUSED error. The problem seems to be that the processes and its child processes don't exit out properly. I'd like to get some help with this if possible.

Copy link
Member

Choose a reason for hiding this comment

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

IIRC, you need to invoke _mocha directly if you want to debug the tests.

lb-mocha creates a child process that creates another node process mocha which creates the third child process `_mocha.

Maybe we should add a new option to lb-mocha to tell our wrapper to start mocha in a debug mode? I am not sure if that would work with VS Code inspector though.

Copy link
Member

Choose a reason for hiding this comment

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

If it's easier, then I am ok with leaving out launch.json configuration from this initial pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can already start mocha in debug mode by passing in --inspect as an argument, but that doesn't seem to fix the problem of the timeout issue when restarting. This might be fixable if lb-mocha calls _mocha instead of mocha, but I think I'd rather address this in a separate issue.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough 👍 Looks like you already understand this matter better than I do 😄

Copy link
Contributor

@virkt25 virkt25 left a comment

Choose a reason for hiding this comment

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

Great start. For the examples/* projects there is a lot of repetition on prettierrc and prettierignore files. Can we include these in @loopback/build and then pass in the path to prettier via flags:

--config ./node_modules/@loopback/build/config/prettier/.prettierrc and
--ignore-path ./node_modules/@loopback/build/config/prettier/.prettierignore in package.json

this way if we change config it only needs to happen in one place.

"label": "Build, Test and Lint",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "test:dev"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 'advocated' development pattern according to DEVELOPING.md was to have build:watch running and then running the tests without building (since build:watch takes care of that). test:dev is just npm t without the build step

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. Makes sense. 👍

"label": "Watch and Compile Project",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "build:watch"],
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no matching build:watch in package.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

LGTM as far as I am concerned, please work with @virkt25 to iron out the details he pointed out.

"pretest": "npm run clean && npm run build:current",
"test": "lb-mocha --allow-console-logs \"DIST/test\"",
"posttest": "npm run lint",
"test:dev": "lb-mocha DIST/test/**/*.js && npm run lint",
Copy link
Contributor

Choose a reason for hiding this comment

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

Change npm run lint to npm run posttest -- this will help ensure consistency with the test command.

I think doing npm run test -- --skip-scripts && npm run posttest might be an overkill possible but will ensure the greatest consistency between the scripts.

Copy link
Contributor Author

@shimks shimks May 25, 2018

Choose a reason for hiding this comment

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

I like the npm run posttest idea, but I'm a bit tripped up on the npm run test -- --skip-scripts. Is the intention of that to skip the build process?

Nvm, figured out what you meant. Unfortunately, --skip-scripts also disables npm test because it's also considered a script. I know what consistency you want though, so I'm going to find out if there's a way to disable hooks from tests any other way. If there isn't, 🤷‍♂️

@shimks
Copy link
Contributor Author

shimks commented May 25, 2018

@virkt25 The use case for prettier config files IMO is for the users when they lb4 example the apps with the config files in them. With .prettierrc and .prettierignore provided for them, they should be able to easily configure the linter however they want with the added bonus of being able to be used by the prettier extension from VSCode (I think this is the big one).

@shimks shimks merged commit 3738b9c into master Jun 1, 2018
@shimks shimks deleted the cli/vscode branch June 1, 2018 14:45
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.

Enable tsc watch in projects scaffolded by lb4 CLI tool
4 participants