Skip to content

Commit

Permalink
fix(ci): wrong ‘node' and ‘deploy' workflows
Browse files Browse the repository at this point in the history
Error:
- In the `node` workflow, the `npm ci` command needs the `package-lock.json` file to work, but this file is removed before running `npm install` with the npm `preinstall` script.
- In the `node` workflow, the version 16 check does not work because the `console.log` is not allowed by eslint in the `EditorJson.vue` file.

Solution:
- Update the `preinstall` npm script to make it faster.
- In the `node` workflow, use the `npm install` command instead of `npm ci`, this command auto runs the npm `preinstall` script which already does a clean install, removing the `node_modules` folder and the `package-lock.json` file.
- Disables the `no-console` slint rule in the `EditorJson.vue` file.

Resolutions:
- https://stackoverflow.com/a/68095189/10855837
- https://stackoverflow.com/a/53325242/10855837
- rogeriochaves/npm-force-resolutions#17
- https://www.npmjs.com/package/force-resolutions
  • Loading branch information
beatrizsmerino committed Jul 6, 2022
1 parent 625a904 commit 25163e5
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 62 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gh-pages-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x

- name: Checkout branch
uses: actions/checkout@v3

- name: Clean install dependencies
run: npm ci
- name: Clean install dependencies (install:clean)
run: npm install

- name: Run deploy script
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm install
- run: npm run build --if-present
- run: npm test --if-present
106 changes: 53 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
"preinstall": "rm -rf node_modules package-lock.json && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
"install:clean": "rm -rf node_modules package-lock.json",
"install:fix": "npx npm-force-resolutions",
"preinstall": "npm run install:clean && npm install --package-lock-only --ignore-scripts && npm run install:fix",
"postinstall": "npm run lint",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
Expand Down Expand Up @@ -61,7 +63,7 @@
"nth-check": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz"
},
"volta": {
"node": "14.19.3",
"node": "16.15.1",
"npm": "6.14.17"
}
}
8 changes: 6 additions & 2 deletions src/components/EditorJSON.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
},
methods: {
onJsonChange(value) {
/* eslint-disable no-alert, no-console, no-debugger */
console.log('value:', value);
/* eslint-enable no-alert, no-console */
},
getPikachu() {
const url = 'https://pokeapi.co/api/v2/pokemon/pikachu';
Expand All @@ -72,13 +74,15 @@
});
},
onCopy() {
// eslint-disable-next-line no-alert
/* eslint-disable no-alert, no-console, no-debugger */
alert('Copied JSON to the clipboard');
/* eslint-enable no-alert, no-console */
},
onError(e) {
// eslint-disable-next-line no-alert, no-console
/* eslint-disable no-alert, no-console, no-debugger */
alert('Failed to copy JSON to the clipboard');
console.log(e);
/* eslint-enable no-alert, no-console */
},
onSave() {
localStorage.setItem('editor-json', JSON.stringify(this.json));
Expand Down

0 comments on commit 25163e5

Please sign in to comment.