Skip to content

Commit f2275f3

Browse files
authored
chore: Upgrade from yarn classic (v1.22) to pnpm v10 (#66)
* 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
1 parent 80f373a commit f2275f3

22 files changed

+15295
-12142
lines changed

.github/workflows/run-tests.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,45 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222
- uses: volta-cli/action@v4
23+
- uses: pnpm/action-setup@v4
24+
- id: pnpm-cache-path
25+
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
2326
- uses: actions/cache@v4
24-
id: node-cache
2527
with:
26-
path: "**/node_modules"
27-
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}
28+
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
29+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
2830
- name: Install Dependencies
29-
if: steps.node-cache.outputs.cache-hit != 'true'
30-
run: yarn --frozen-lockfile
31+
run: pnpm install
3132
- name: Lint Addon
3233
working-directory: addon
33-
run: yarn run lint
34+
run: pnpm run lint
3435
- name: Lint Test App
3536
working-directory: test-app
36-
run: yarn run lint
37+
run: pnpm run lint
3738
- name: Lint Docs App
3839
working-directory: docs-app
39-
run: yarn run lint
40+
run: pnpm run lint
4041

4142
test-docs:
4243
name: Test Docs
4344
runs-on: ubuntu-latest
4445
steps:
4546
- uses: actions/checkout@v4
4647
- uses: volta-cli/action@v4
48+
- uses: pnpm/action-setup@v4
49+
- id: pnpm-cache-path
50+
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
4751
- uses: actions/cache@v4
4852
with:
49-
path: "**/node_modules"
50-
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}
51-
- run: yarn --frozen-lockfile
53+
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
54+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
55+
- name: Install Dependencies
56+
run: pnpm install
5257
- working-directory: addon
53-
run: yarn run build
58+
run: pnpm run build
5459
- name: Run Tests
5560
working-directory: docs-app
56-
run: yarn run test
61+
run: pnpm run test
5762

5863
test:
5964
name: Run Ember Tests
@@ -74,15 +79,17 @@ jobs:
7479
steps:
7580
- uses: actions/checkout@v4
7681
- uses: volta-cli/action@v4
82+
- uses: pnpm/action-setup@v4
83+
- id: pnpm-cache-path
84+
run: echo "pnpm_cache_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
7785
- uses: actions/cache@v4
7886
with:
79-
path: "**/node_modules"
80-
key: ${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}-${{ matrix.ember-version }}
81-
restore-keys: |
82-
${{ runner.os }}-ci-yarn-${{ hashFiles('**/yarn.lock') }}-
83-
- run: yarn --frozen-lockfile
87+
path: ${{ steps.pnpm-cache-path.outputs.pnpm_cache_path }}
88+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
89+
- name: Install Dependencies
90+
run: pnpm install
8491
- working-directory: addon
85-
run: yarn run build
92+
run: pnpm run build
8693
- name: Run Tests
8794
working-directory: test-app
8895
run: ./node_modules/.bin/ember try:one ${{ matrix.ember-version }} --skip-cleanup

CONTRIBUTING.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
11
# How To Contribute
22

3+
This repo is a monorepo, for additional instructions, refer to the package.json files in the workspaces,
4+
or refer to the Github Workflow that runs CI.
5+
36
## Installation
47

5-
* `git clone <repository-url>`
6-
* `cd ember-json-viewer`
7-
* `npm install`
8+
- `git clone <repository-url>`
9+
- `cd ember-json-viewer`
10+
- `pnpm install`
811

912
## Linting
1013

11-
* `npm run lint:hbs`
12-
* `npm run lint:js`
13-
* `npm run lint:js -- --fix`
14+
Each workspace has a `lint` run-script.
15+
You can run them all via:
16+
17+
```
18+
pnpm --filter '*' lint
19+
```
1420

1521
## Running tests
1622

17-
* `ember test` – Runs the test suite on the current Ember version
18-
* `ember test --server` – Runs the test suite in "watch mode"
19-
* `ember try:each` – Runs the test suite against multiple Ember versions
23+
In one terminal, start the addon build:
24+
25+
```
26+
cd addon/ && pnpm start
27+
```
28+
29+
In another terminal, start the test-app build:
30+
31+
```
32+
cd test-app/ && pnpm start
33+
```
34+
35+
Visit the tests in the browser at localhost:4200/tests.
36+
37+
Alternatively, run tests via CLI with: `cd test-app/ && pnpm test`
38+
39+
## Running the docs application
40+
41+
Start the addon build in another terminal window:
2042

21-
## Running the dummy application
43+
```
44+
cd addon/ && pnpm start
45+
```
2246

23-
* `ember serve`
24-
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
47+
Then start the docs app:
2548

26-
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
49+
```
50+
cd docs-app/ && pnpm start
51+
```

addon/.eslintignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

addon/.eslintrc.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

addon/.template-lintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'recommended',
4+
plugins: ['ember-template-lint-plugin-prettier'],
5+
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
56
rules: {
67
'no-triple-curlies': false,
78
'no-invalid-interactive': false,

addon/eslint.config.mjs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* Debugging:
3+
* https://eslint.org/docs/latest/use/configure/debug
4+
* ----------------------------------------------------
5+
*
6+
* Print a file's calculated configuration
7+
*
8+
* npx eslint --print-config path/to/file.js
9+
*
10+
* Inspecting the config
11+
*
12+
* npx eslint --inspect-config
13+
*
14+
*/
15+
import globals from "globals";
16+
import js from "@eslint/js";
17+
18+
import ember from "eslint-plugin-ember/recommended";
19+
import prettier from "eslint-plugin-prettier/recommended";
20+
import n from "eslint-plugin-n";
21+
22+
import babelParser from "@babel/eslint-parser";
23+
24+
const esmParserOptions = {
25+
ecmaFeatures: { modules: true },
26+
ecmaVersion: "latest",
27+
requireConfigFile: false,
28+
babelOptions: {
29+
plugins: [
30+
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
31+
],
32+
},
33+
};
34+
35+
export default [
36+
js.configs.recommended,
37+
prettier,
38+
ember.configs.base,
39+
ember.configs.gjs,
40+
/**
41+
* Ignores must be in their own object
42+
* https://eslint.org/docs/latest/use/configure/ignore
43+
*/
44+
{
45+
ignores: ["dist/", "node_modules/", "coverage/", "!**/.*"],
46+
},
47+
/**
48+
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
49+
*/
50+
{
51+
linterOptions: {
52+
reportUnusedDisableDirectives: "error",
53+
},
54+
},
55+
{
56+
files: ["**/*.js"],
57+
languageOptions: {
58+
parser: babelParser,
59+
},
60+
},
61+
{
62+
files: ["**/*.{js,gjs}"],
63+
languageOptions: {
64+
parserOptions: esmParserOptions,
65+
globals: {
66+
...globals.browser,
67+
},
68+
},
69+
},
70+
/**
71+
* CJS node files
72+
*/
73+
{
74+
files: [
75+
"**/*.cjs",
76+
"config/**/*.js",
77+
"testem.js",
78+
"testem*.js",
79+
".prettierrc.js",
80+
".stylelintrc.js",
81+
".template-lintrc.js",
82+
"ember-cli-build.js",
83+
"addon-main.js",
84+
],
85+
plugins: {
86+
n,
87+
},
88+
89+
languageOptions: {
90+
sourceType: "script",
91+
ecmaVersion: "latest",
92+
globals: {
93+
...globals.node,
94+
},
95+
},
96+
},
97+
/**
98+
* ESM node files
99+
*/
100+
{
101+
files: ["**/*.mjs"],
102+
plugins: {
103+
n,
104+
},
105+
106+
languageOptions: {
107+
sourceType: "module",
108+
ecmaVersion: "latest",
109+
parserOptions: esmParserOptions,
110+
globals: {
111+
...globals.node,
112+
},
113+
},
114+
},
115+
];

addon/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"lint:js:fix": "eslint . --fix",
3434
"build": "rollup --config",
3535
"prepublishOnly": "rollup --config",
36-
"start": "rollup --config --watch"
36+
"start": "rollup --config --watch",
37+
"test": "echo 'v2 addons do not have tests, run tests for the test-app instead'"
3738
},
3839
"dependencies": {
3940
"@embroider/addon-shim": "^1.9.0",
@@ -45,14 +46,17 @@
4546
"@babel/plugin-proposal-decorators": "^7.25.9",
4647
"@babel/plugin-transform-class-properties": "^7.25.9",
4748
"@embroider/addon-dev": "^7.1.1",
49+
"@eslint/js": "^9.17.0",
4850
"@rollup/plugin-babel": "^6.0.4",
4951
"concurrently": "^9.1.0",
50-
"eslint": "^8.0.0",
52+
"ember-template-lint": "^6.0.0",
53+
"ember-template-lint-plugin-prettier": "^5.0.0",
54+
"eslint": "^9.17.0",
5155
"eslint-config-prettier": "^9.1.0",
5256
"eslint-plugin-ember": "^12.3.3",
5357
"eslint-plugin-n": "^17.15.1",
5458
"eslint-plugin-prettier": "^5.2.1",
55-
"eslint-plugin-qunit": "^8.1.2",
59+
"globals": "^15.14.0",
5660
"prettier": "^3.4.2",
5761
"rollup": "^4.30.1"
5862
},

0 commit comments

Comments
 (0)