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

Extract CLI into separate module #249

Merged
merged 3 commits into from
Nov 26, 2019
Merged

Extract CLI into separate module #249

merged 3 commits into from
Nov 26, 2019

Conversation

Gregoor
Copy link
Contributor

@Gregoor Gregoor commented Nov 25, 2019

So I tried to keep it minimal-ish for now, the changes basically come down:

  • new cli module with only one command atm, running ssr
    • defines options that can be passed to it, yet gets the defaults from the SSR module itself...
  • ...as I allowed that to still be run directly as well, so it also needs the same defaults
  • also refactored some small things here and there (e.g. moved the progress-bar to a separate file)

I created two commits as it seemed that git otherwise thinks that the new cli-module"s index.js is the ssr module"s (as it was previously named cli), hence no file history tracking. Unfortunately that didn"t seem to have done the trick :/

@@ -8,7 +8,8 @@ module.exports = {
entry: "./index.js",
output: {
path: distPath,
filename: "cli.js"
filename: "ssr.js",
libraryTarget: "commonjs2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why/what is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise the ssr module can"t be imported by our cli module. Webpack doesn"t create importable bundles by default.

Gregor Weber added 3 commits November 25, 2019 17:52
(don"t squash this commit, it temporarily names the cli module "new-cli", so that git"s file tracking algorithm doesn"t get confused)
Copy link
Contributor

@peterbe peterbe left a comment

Choose a reason for hiding this comment

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

It looks gorgeous!
Can you figure out why yarn test is broken first?

▶ yarn test
yarn run v1.19.1
$ yarn prettier-check && yarn workspace ssr test && yarn workspace client test
$ prettier --check **/*.{js,json,scss,html}
Checking formatting...
All matched files use Prettier code style!
$ jest
 FAIL  ./syntax-highlighter.test.js
  ● Test suite failed to run

    /Users/peterbe/dev/MOZILLA/MDN/stumptown-renderer/ssr/syntax-highlighter.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import cheerio from "cheerio";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | const { fixSyntaxHighlighting } = require("./syntax-highlighter");
        |                                   ^
      2 |
      3 | test("adds 1 + 2 to equal 3", () => {
      4 |   expect(sum(1, 2)).toBe(3);

      at ScriptTransformer._transformAndBuildScript (../node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (../node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.require (syntax-highlighter.test.js:1:35)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.396s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/Cellar/node/12.12.0/bin/node
Arguments: /usr/local/Cellar/yarn/1.19.1/libexec/lib/cli.js test
Directory: /Users/peterbe/dev/MOZILLA/MDN/stumptown-renderer/ssr
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Copy link
Contributor

@peterbe peterbe left a comment

Choose a reason for hiding this comment

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

Actually, we were never testing yarn test before. We"ll have to fix that some other day.

@peterbe peterbe merged commit d692fa2 into master Nov 26, 2019
@Gregoor
Copy link
Contributor Author

Gregoor commented Nov 26, 2019

Oh yeah I was wondering whether we might want to rename end-to-end-test to test, given that it"s a quasi-standard in node land.

@peterbe
Copy link
Contributor

peterbe commented Nov 26, 2019

rename end-to-end-test to test

?? The end-to-end tests do very different things. It basically tests from bash whereas test is a script target for running jest. No?

@Gregoor
Copy link
Contributor Author

Gregoor commented Nov 26, 2019

Oh right, forgot that we"re running the workspace tests in there already. I guess I was wondering whether we want that command to also run the end-to-end test, feels natural to me to have the root test test the whole project.

@peterbe peterbe deleted the new-cli branch July 2, 2020 15:30
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.

2 participants