Skip to content

Commit

Permalink
Merge branch 'remove-global-builds-switch-to-web-test-runner-update-p…
Browse files Browse the repository at this point in the history
…rettier'

* remove-global-builds-switch-to-web-test-runner-update-prettier: (29 commits)
  feat: fallback to loading jest globals in test-runner from the hoisted node_modules location if it is not located in lume/cli's node_modules
  BREAKING: add a check to ensure that the repo is not modified before versioning during release. Repo author should be sure to commit build outputs, or fix the build so no changes happen during build that are not tracked.
  undo testing in firefox and safari for now, some lume code needs fixing
  BREAKING: besides Chromium, also run tests in Firefox and Safari in CI. Migration: If you didn't test those browsers before, you might have to update any code that is not compatible. Alternatively, make sure there is no CI env var set and it will test in Chrome only.
  update test-runner port range to avoid ports denylisted by Chrome
  install web test-runner's playwright launcher, and use that to run tests in Chrome in CI
  run tests on a random port to avoid collisions when running tests in parallel for multiple projects at the same time
  BREAKING: migrate from Karma to `@web/test-runner`. This removed a lot of dependencies (namely Webpack needed for the Karma setup), greatly reduces maintenance burden, speeds tests up, provides a much simpler and better test development and debugging experience with minimal configuration compared to with Karma, and ensures longevity of test code by ensuring that they run as standard JavaScript modules. 🎉 The `webpackConfigs` and `testSpecFormat` options for `lume.config.cjs` have been removed. Migration: Delete any webpack configs, all code should be vanilla JavaScript (ES) modules. There is only one test spec format now (Mocha `describe()`/`it()` and Jest `expect()`). Test syntax is mostly the same, and most tests will remain as-is. A few things need to be changed from Jasmine's `expect()` API to Jest's very similar `expect()` API. For example, `expect(true).toBeTrue()` needs to be changed to `expect(true).toBe(true)`. `jasmine.*` API is removed, f.e. `jasmine.createSpy` can be replaced with `sinon.spy()`. Try running tests, see what broke, then look up the way to do it with Jest or with Sinon, etc. Also tests are executed as vanilla ES Modules in a browser, and an `importMap` field will need to be defined in `lume.config.js` to handle bare specifiers (f.e. the `foo` in `import something from 'foo'`). Only ES Modules are supported, so if any libraries are CommonJS, those will not work and alternatives will be needed. The CLI can be forked though, and `@web/test-runner`'s config can be expanded to use its built-in `esbuild` plugin, along with Rollup plugins for any non-vanilla-ESM use cases.
  BREAKING: instead of trying to stash changes and continuing with versioning and publishing, exit non-zero if the working directory is dirty. Migration: clear your git repo of changes, then try again.
  update version scripts to avoid an issue with workspaces and linked dependencies (npm/cli#5687, npm/cli#4787)
  BREAKING: remove the global build feature, from now on we output and publish only JS modules for simplicity. Migration: @lume/cli will no longer output global.js files for use with non-module script tags, instead any code depending on your @lume/cli-managed package should use `import` syntax to import your package.
  port karma bash script to Node so it works in Windows too
  ensure line endings match with the rest of our tooling (all work in LF)
  ensure that we also get tsc, babel, and prettier bins with Node module lookup to avoid relying on PATH (Yarn and NPM set PATH differently, see Yarn issue 5800)
  update exec calls to find binaries using node_module resolution instead of relying on PATH to prevent cross-platform issues with Windows, and make the noFailOnError option use || echo '' instead of || true for cross-platform support
  prevent duplicate solid-js libs. Its ok to hard code this one case, because solid-js is a key dependency of lume
  Avoid error with fs.mkdir if dir already exists. Why is it so difficult?
  ensure dist/ is created before we copy assets to hopefully solve a problem with this in Windows CI (https://github.com/lume/lume/actions/runs/6519881972/job/17706893670)
  update prettier to 3.0.3
  infra: add .gitattributes with rules to enforce that code is checked out with LF line endings only, which prevents Prettier from failing in Windows
  ...
  • Loading branch information
trusktr committed Nov 5, 2023
2 parents 9fd2042 + aaba325 commit 0784d45
Show file tree
Hide file tree
Showing 22 changed files with 449 additions and 875 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
306 changes: 124 additions & 182 deletions README.md

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ cli.option('-V, --verbose', 'Show verbose output.')

cli.option('--noFail', 'Prevent build commands from failing on non-zero exit codes.', false)

cli.command('clean').description('Remove all build outputs.').action(commands.clean)
cli.command('clean').description('Remove all build outputs (deletes dist/).').action(commands.clean)

cli.command('build').description('Build the project in which this command is being ran.').action(commands.build)
cli
.command('build')
.description('Build the project in which this command is being ran.')
.option('-c, --clean', 'Remove all build outputs first (deletes dist/).')
.option('-n, --noFail', 'Exit successfully even on build failure.')
.action(commands.build)

cli
.command('dev')
Expand All @@ -37,16 +42,6 @@ cli
await commands.buildTs()
})

cli
.command('buildGlobal')
.description('Build the global version of the project for simple usage with browser script tags.')
.action(commands.buildGlobal)

cli
.command('buildGlobalWatch')
.description('Build the global version of the project in watch mode any time files change.')
.action(commands.buildGlobalWatch)

cli.command('showName').description('Output the project name to console.').action(commands.showName)

cli
Expand All @@ -59,9 +54,18 @@ cli
.description('Run a typecheck of TypeScript source code without compiling output, in watch mode.')
.action(commands.typecheckWatch)

cli.command('test').description('Run tests.').action(commands.test)
cli
.command('test')
.description('Run tests.')
.option('-w, --watch', 'Run tests in watch mode, with an interactive debug menu.')
.action(commands.test)

cli
.command('install-browsers')
.description('Install browsers used for testing by Playwright in @web/test-runner.')
.action(commands.installBrowsers)

cli.command('testDebug').description('Run tests with GUI debugger.').action(commands.testDebug)
cli.command('testDebug').description('Removed, use test --watch instead.').action(commands.testDebug)

cli
.command('releasePre')
Expand Down

0 comments on commit 0784d45

Please sign in to comment.