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

Better monorepo support. Use @embroider/addon-blueprint #37

Merged
merged 5 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"notes": {
"overall config docs": "https://github.com/changesets/changesets/blob/main/docs/config-file-options.md",
"changelog customization": "https://github.com/changesets/changesets/blob/main/docs/modifying-changelog-format.md"
},
"changelog": [
"@changesets/changelog-github",
{ "repo": "NullVoxPopuli/ember-addon-migrator" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["tests"]
}
12 changes: 12 additions & 0 deletions .changeset/lemon-drinks-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"ember-addon-migrator": major
---

Support running the migrator in existing monorepos, at any depth.

Additionally, support for

- npm, yarn, pnpm
- typescript

(because the migration is now powered by the v2 addon blueprint)
10 changes: 9 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ const config = configs.nodeTS();

module.exports = {
...config,
overrides: [...config.overrides],
overrides: [
...config.overrides,
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
};
17 changes: 17 additions & 0 deletions .github/actions/pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup node and pnpm
description: Setup node and install dependencies using pnpm
runs:
using: "composite"
steps:
- uses: volta-cli/action@v1
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- uses: pnpm/[email protected]
with:
version: 7.11.0
run_install: true
140 changes: 74 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,80 @@ on:

env:
CI: true
CACHE_PATH: '**/node_modules'

jobs:
install_dependencies:
name: Install Dependencies
name: Install
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm

lint_js:
name: Lint JS
runs-on: ubuntu-latest
needs: [install_dependencies]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- name: ESLint
run: pnpm lint

lint_tests:
name: Lint Tests
runs-on: ubuntu-latest
needs: [install_dependencies]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- name: ESLint
run: pnpm lint
working-directory: tests

types_library:
name: "Types: Library"
runs-on: ubuntu-latest
timeout-minutes: 2
needs: [install_dependencies]

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- run: tsc --build --clean && tsc --build
continue-on-error: true

types_tests:
name: "Types: Tests"
runs-on: ubuntu-latest
timeout-minutes: 2
needs: [install_dependencies]

steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/cache@v2
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: "${{ runner.os }}-modules-"
- run: yarn global add pnpm
- run: yarn install
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- run: tsc --build --clean && tsc --build
continue-on-error: true
working-directory: tests

tests:
name: "Tests"
runs-on: ubuntu-latest
needs: [install_dependencies]
strategy:
matrix:
# all tests like this are slow
slow-test:
- basic conversion
- snapshots conversion

steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/[email protected]
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- run: |
yarn install
yarn global add pnpm
yarn global add ember-cli
pnpm add --global ember-cli
- name: Tests
run: yarn test
working-directory: 'tests'
run: pnpm vitest --testNamePattern "${{ matrix.slow-test }}"

tooling:
name: Tooling
Expand All @@ -55,62 +92,33 @@ jobs:
needs: [install_dependencies]

steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/[email protected]
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- run: yarn install
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- name: Semantic Release
run: yarn publish:dry-run
run: pnpm publish:dry-run
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
# https://github.com/changesets/action
release:
name: Release
timeout-minutes: 5
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [tests]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: volta-cli/action@v1
- run: yarn install

- name: Release
run: yarn publish:release
- uses: ./.github/actions/pnpm
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_USER: 'semantic-release'
GIT_AUTHOR_NAME: '@semantic-release'
GIT_COMMITTER_NAME: '@semantic-release'


# deployed with cloudflare pages so we can have deploy previews and such
# docs:
# name: Publish Docs
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
# needs: [publish]

# steps:
# - uses: actions/checkout@v2
# with:
# persist-credentials: false
# - uses: volta-cli/action@v1
# - run: yarn install
# - run: |
# cd projects/docs
# yarn docs:collect

# - name: Deploy 🚀
# uses: JamesIves/[email protected]
# with:
# branch: gh-pages
# folder: projects/docs/dist
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
73 changes: 0 additions & 73 deletions .github/workflows/quality.yml

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ test-app/

_Additional tweaking may be required after the migrator runs_.

## Parameters

Parameters follow naming of args used in the [v2 addon blueprint](https://github.com/embroider-build/addon-blueprint)

### `--addon-location`

Places the addon in `--addon-location` instead of `{addon-name}`

## Compatibility

- Node 16+
Expand Down
57 changes: 56 additions & 1 deletion bin.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
#!/usr/bin/env node

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import { info } from './src/log.js';
import run from './src/index.js';
import reset from './src/git-reset.js';

/**
* TODO:
* - monorepo
* - detect lockfile
* - no root package.json (by default)
* - inherit volta in test-app/package.json
*/
yargs(hideBin(process.argv))
.command(
'reset',
'resets the git workspace -- useful in case of error and you need to re-run' +
' the migrator. Each step is not idempotent, so resetting continuing after' +
' an error is not always possible. This runs `git clean -f -d; git checkout .',
() => {},
async () => {
info(`Resetting git repo to clean state...`);

await reset();

run();
info('Done! ✨');
}
)
.command(
['run', '$0 [addon-location]'],
'the default command -- runs the addon migrator.',
(yargs) => {
yargs.option('addon-location', {
describe: 'the folder to place the addon package. defaults to the package name.',
type: 'string',
});
yargs.option('test-app-location', {
describe: 'the folder to place the test-app package.',
type: 'string',
default: 'test-app',
});
yargs.option('test-app-name', {
describe: 'the name of the test-app package.',
type: 'string',
default: 'test-app',
});
yargs.option('directory', {
describe: 'the directory to run the migration in. defaults to the current directory',
type: 'string',
default: process.cwd(),
});
},
(args) => {
return run(args);
}
)
.help().argv;
Loading