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

Fix compatibility with [email protected]+ #362

Merged
merged 3 commits into from
Apr 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
110 changes: 47 additions & 63 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,56 @@
name: Node CI

on: [push,pull_request]
on:
push:
branches:
- master
- 'v*' # prior release branches (e.g. `v0.30.x` branch)
tags:
- 'v*'
pull_request:

jobs:
build:
discover_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v1
- uses: rwjblue/setup-volta@v1
with:
node-version: '14'
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
- name: eslint
run: for name in `ls packages/*/.eslintrc.js`; do dirname $name; done | xargs npx eslint --
- id: set-matrix
working-directory: test-scenarios
run: echo "::set-output name=matrix::$(npm run --silent test:list -- --matrix)"

build:
needs: discover_matrix
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
eai_scenario: [2.18, stable, beta, canary]
suite:
- 'cd packages/sample-direct && yarn test'
- 'cd packages/sample-direct && yarn test'
- 'cd packages/sample-direct && yarn test:fastboot'
- 'cd packages/sample-direct && yarn test:prod'
- 'cd packages/sample-direct && yarn test:custom-bundles'
- 'cd packages/sample-direct && yarn test:custom-bundles-top'
- 'cd packages/sample-direct && yarn test:custom-bundles-fastboot'
- 'cd packages/sample-direct && yarn test:custom-csp'
- 'cd packages/sample-indirect && yarn test'
- 'cd packages/sample-indirect && yarn test:fastboot'
- 'cd packages/sample-indirect && yarn test:custom-csp'
- 'cd packages/sample-addon && yarn test'
- 'cd packages/sample-failure && yarn test'
- 'cd packages/sample-merged && yarn test'
- 'cd packages/sample-conflict && yarn test'
- 'cd packages/sample-babel7 && yarn test'
- 'cd packages/sample-typescript && yarn test'
- 'cd packages/sample-typescript2 && yarn test'
- 'cd packages/sample-typescript4 && yarn test'
- 'cd packages/sample-noconflict && yarn test'
- 'cd packages/sample-noparse && yarn test'
- 'cd packages/ember-auto-import && yarn test'
- 'cd packages/sample-es-latest && yarn test'
- 'cd packages/sample-skip-babel && yarn test'
- 'cd packages/ember-auto-import && yarn test:node'
exclude:
- suite: 'cd packages/sample-direct && yarn test:custom-bundles'
eai_scenario: 2.18
- suite: 'cd packages/sample-direct && yarn test:custom-bundles-top'
eai_scenario: 2.18
- suite: 'cd packages/sample-direct && yarn test:custom-bundles-fastboot'
eai_scenario: 2.18
include:
- suite: 'for name in `ls packages/*/.eslintrc.js`; do dirname $name; done | xargs yarn eslint'
eai_scenario: ""

matrix: ${{fromJson(needs.discover_matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: pick version and install
run: ./scripts/change-ember-cli-version.sh
env:
EAI_SCENARIO: ${{ matrix.eai_scenario }}
- name: test
run: ${{ matrix.suite }}

- uses: actions/checkout@v1
- uses: rwjblue/setup-volta@v1
with:
node-version: '14'
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
- name: test
run: ${{ matrix.command }}
working-directory: ${{ matrix.dir }}
168 changes: 89 additions & 79 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,91 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Build sample-direct",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-direct",
"args": [
"build"
]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-babel7",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-babel7",
"args": [
"build"
]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-indirect",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-indirect",
"preLaunchTask": "tsc: build - tsconfig.json",
"args": [
"build"
]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-merged",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-merged",
"args": [
"build"
],
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Build sample-addon",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-addon",
"args": [
"build"
]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-conflict",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-conflict",
"args": [
"build"
]
},
{
"type": "node",
"request": "launch",
"name": "Run node tests",
"program": "${workspaceFolder}/node_modules/.bin/qunit",
"cwd": "${workspaceFolder}/packages/ember-auto-import",
"args": [
"js/tests",
"--filter", "safe url example: import('//example.com/thing')"
]
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Build sample-direct",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-direct",
"args": ["build"]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-babel7",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-babel7",
"args": ["build"]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-indirect",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-indirect",
"preLaunchTask": "tsc: build - tsconfig.json",
"args": ["build"]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-merged",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-merged",
"args": ["build"],
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Build sample-addon",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-addon",
"args": ["build"]
},
{
"type": "node",
"request": "launch",
"name": "Build sample-conflict",
"program": "${workspaceFolder}/node_modules/.bin/ember",
"cwd": "${workspaceFolder}/packages/sample-conflict",
"args": ["build"]
},
{
"type": "node",
"request": "launch",
"name": "Run node tests",
"program": "${workspaceFolder}/node_modules/.bin/qunit",
"cwd": "${workspaceFolder}/packages/ember-auto-import",
"args": ["js/tests", "--filter", "safe url example: import('//example.com/thing')"]
},
{
"type": "node",
"request": "launch",
"name": "Run test-scenarios",
"program": "${workspaceFolder}/node_modules/.bin/qunit",
"cwd": "${workspaceFolder}/test-scenarios",
"args": ["--require", "ts-node/register", "*-test.ts", "--filter", "lts-addon-dev-dep"],
"env": {
"JOBS": "1"
},
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Build a pre-emitted test-scenario",
"program": "${workspaceFolder}/node_modules/ember-cli/bin/ember",
"cwd": "${workspaceFolder}/test-scenarios/output",
"args": ["build"],
"env": {
"JOBS": "1"
},
"outputCapture": "std",
"nodeVersionHint": 10
}
]
}
39 changes: 16 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
Contributing
------------------------------------------------------------------------------
## Contributing

### Code organization

The actual ember addon is in `./packages/ember-auto-import`. The other packages exist to let us test with many different app scenarios with differing dependencies.
The actual ember addon is in `./packages/ember-auto-import`.

Our tests are driven through a system of layered scenarios in `./test-scenarios`. Those scenarios are built off `./packages/app-template` and `./packages/addon-template` which are nearly-empty examples of an Ember app and addon.

### Installation

* `git clone <repository-url>`
* `cd ember-auto-import/packages/ember-auto-import`
* `yarn install`
- Install [Volta](https://volta.sh/) to ensure you're using matching node and NPM version.
- `git clone <repository-url>`
- `cd ember-auto-import`
- `npm install`

### Building

You can build the TypeScript into Javascript with
You'll need to run the typescript compiler if you're making changes:

yarn compile

If you're making interactive changes, you can leave the compiler watching:

yarn compile --watch
```
npm run watch
```

### Running tests

Our test setup is not typical for an Ember addon. While there is a normal Ember addon dummy app that you can run the normal way (with `ember test`), we also have multiple other apps under `/packages`. This lets us test how ember-auto-import gets integrated under multiple scenarios.

The test apps are all yarn workspaces, no need to run separate npm installs for them. They should get symlinked to each other automatically when you install. You can also `cd` directly into any of the test apps and run its tests like a normal Ember app.

The top-level test runner script (`/scripts/test.sh`) probably only works under Unix-like environments, because it relies on GNU parallel to run all the apps at once.

Index of test apps:
Use these commands in the `./test-scenarios` directory.

- sample-direct: an app that directly uses ember-auto-import
- sample-addon: an addon that uses ember-auto-import to implement a feature that will be used in apps, and also exercises auto-import for devDependencies in its dummy app.
- sample-indirect: an app that uses sample-addon but does not directly depend on ember-auto-import
- sample-failure: an addon that should refuse to build due to importing a devDependency from addon code
- `npm run test` runs all test scenarios. This is a lot of scenarios, and it may be easier to let GitHub actions run them for your in parallel.

- `npm test:list` list the names of all scenarios.

- `npm run test -- --filter $SCENARIO_NAME` run one scenario by name
- `npm run test:output -- --scenario $SCENARIO_NAME` writes out the scenario as a real on-disk app that you can inspect, run, and debug.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# TODO:

audit ember-auto-import's devDependencies (lodash-es & moment I think were only there to support tests that have moved)

# ember-auto-import

Just `import` from NPM, with zero configuration.
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.