Skip to content

Commit

Permalink
chore: Upgrade from yarn classic (v1.22) to pnpm v10 (#66)
Browse files Browse the repository at this point in the history
* Install pnpm using instructions from https://pnpm.io/installation

* add preinstall script to prevent non-pnpm usage

* add pnpm workspace yaml

* package.json: remove workspace since pnpm is used instead

* run pnpm import

* remove yarn.lock

* change specifiers to use workspace: prefix

* mv rollup config to .mjs ext

* Switch to pnpm for ci

* continue-on-error for lint steps

* add missing ember-template-lint devdep to addon pkg

* add missing eslint/js devdep to test-app

* Revert "continue-on-error for lint steps"

This reverts commit f61b164.

* test-app: empty app.css file to avoid build-time warning about missing test-app.css file

* addon: package.json add test script that explains tests are elsewhere

* use broccoli-side-watch to sync test/doc-app rebuilds

* addon: upgrade eslint 8 -> 9

* for side-watch, lookup name from package.json

* update contributing.md

* addon: use ember-template-lint-plugin-prettier to run prettier on hbs files

* addon: add missing "globals" pkg for eslint

* use volta in cli

* add volta pin

* workflow: remove temp print of pnpm,node version

* workflow: enable pnpm caching

* minor update to contrib doc

* workflow: enable pnpm caching, fix

* workflow: enable pnpm caching for all jobs

* workflow: dedupe the volta env by moving it to the workflow level rather than per-job

* corepack use pnpm@10

* workflow: drop volta pnpm env var

* add setup-pnpm action
  • Loading branch information
bantic authored Jan 14, 2025
1 parent 80f373a commit f2275f3
Show file tree
Hide file tree
Showing 22 changed files with 15,295 additions and 12,142 deletions.
45 changes: 26 additions & 19 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,45 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v4
- id: pnpm-cache-path
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: node-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Dependencies
if: steps.node-cache.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: pnpm install
- name: Lint Addon
working-directory: addon
run: yarn run lint
run: pnpm run lint
- name: Lint Test App
working-directory: test-app
run: yarn run lint
run: pnpm run lint
- name: Lint Docs App
working-directory: docs-app
run: yarn run lint
run: pnpm run lint

test-docs:
name: Test Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v4
- id: pnpm-cache-path
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Dependencies
run: pnpm install
- working-directory: addon
run: yarn run build
run: pnpm run build
- name: Run Tests
working-directory: docs-app
run: yarn run test
run: pnpm run test

test:
name: Run Ember Tests
Expand All @@ -74,15 +79,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v4
- id: pnpm-cache-path
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}-${{ matrix.ember-version }}
restore-keys: |
${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}-
- run: yarn --frozen-lockfile
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Dependencies
run: pnpm install
- working-directory: addon
run: yarn run build
run: pnpm run build
- name: Run Tests
working-directory: test-app
run: ./node_modules/.bin/ember try:one ${{ matrix.ember-version }} --skip-cleanup
51 changes: 38 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
# How To Contribute

This repo is a monorepo, for additional instructions, refer to the package.json files in the workspaces,
or refer to the Github Workflow that runs CI.

## Installation

* `git clone <repository-url>`
* `cd ember-json-viewer`
* `npm install`
- `git clone <repository-url>`
- `cd ember-json-viewer`
- `pnpm install`

## Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`
Each workspace has a `lint` run-script.
You can run them all via:

```
pnpm --filter '*' lint
```

## Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions
In one terminal, start the addon build:

```
cd addon/ && pnpm start
```

In another terminal, start the test-app build:

```
cd test-app/ && pnpm start
```

Visit the tests in the browser at localhost:4200/tests.

Alternatively, run tests via CLI with: `cd test-app/ && pnpm test`

## Running the docs application

Start the addon build in another terminal window:

## Running the dummy application
```
cd addon/ && pnpm start
```

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
Then start the docs app:

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
```
cd docs-app/ && pnpm start
```
14 changes: 0 additions & 14 deletions addon/.eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions addon/.eslintrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion addon/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

module.exports = {
extends: 'recommended',
plugins: ['ember-template-lint-plugin-prettier'],
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
rules: {
'no-triple-curlies': false,
'no-invalid-interactive': false,
Expand Down
115 changes: 115 additions & 0 deletions addon/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* npx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* npx eslint --inspect-config
*
*/
import globals from "globals";
import js from "@eslint/js";

import ember from "eslint-plugin-ember/recommended";
import prettier from "eslint-plugin-prettier/recommended";
import n from "eslint-plugin-n";

import babelParser from "@babel/eslint-parser";

const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: "latest",
requireConfigFile: false,
babelOptions: {
plugins: [
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
],
},
};

export default [
js.configs.recommended,
prettier,
ember.configs.base,
ember.configs.gjs,
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
ignores: ["dist/", "node_modules/", "coverage/", "!**/.*"],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
},
{
files: ["**/*.js"],
languageOptions: {
parser: babelParser,
},
},
{
files: ["**/*.{js,gjs}"],
languageOptions: {
parserOptions: esmParserOptions,
globals: {
...globals.browser,
},
},
},
/**
* CJS node files
*/
{
files: [
"**/*.cjs",
"config/**/*.js",
"testem.js",
"testem*.js",
".prettierrc.js",
".stylelintrc.js",
".template-lintrc.js",
"ember-cli-build.js",
"addon-main.js",
],
plugins: {
n,
},

languageOptions: {
sourceType: "script",
ecmaVersion: "latest",
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
files: ["**/*.mjs"],
plugins: {
n,
},

languageOptions: {
sourceType: "module",
ecmaVersion: "latest",
parserOptions: esmParserOptions,
globals: {
...globals.node,
},
},
},
];
10 changes: 7 additions & 3 deletions addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"lint:js:fix": "eslint . --fix",
"build": "rollup --config",
"prepublishOnly": "rollup --config",
"start": "rollup --config --watch"
"start": "rollup --config --watch",
"test": "echo 'v2 addons do not have tests, run tests for the test-app instead'"
},
"dependencies": {
"@embroider/addon-shim": "^1.9.0",
Expand All @@ -45,14 +46,17 @@
"@babel/plugin-proposal-decorators": "^7.25.9",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@embroider/addon-dev": "^7.1.1",
"@eslint/js": "^9.17.0",
"@rollup/plugin-babel": "^6.0.4",
"concurrently": "^9.1.0",
"eslint": "^8.0.0",
"ember-template-lint": "^6.0.0",
"ember-template-lint-plugin-prettier": "^5.0.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-qunit": "^8.1.2",
"globals": "^15.14.0",
"prettier": "^3.4.2",
"rollup": "^4.30.1"
},
Expand Down
Loading

0 comments on commit f2275f3

Please sign in to comment.