From cae25ddc80c55bbaab8891ffbbbedbf0cad11857 Mon Sep 17 00:00:00 2001 From: Wagner Santos <7467450+wagoid@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:54:11 -0300 Subject: [PATCH] fix: fix backwards compatibility with people using commitlint.config.js --- Dockerfile | 2 +- commitlint.config.mjs => commitlint.config.js | 4 +- entrypoint.sh | 4 +- package-lock.json | 77 +++++++++++++++++++ package.json | 3 +- rollup.config.js | 9 ++- 6 files changed, 90 insertions(+), 9 deletions(-) rename commitlint.config.mjs => commitlint.config.js (90%) diff --git a/Dockerfile b/Dockerfile index 9435dd3..9527a1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ FROM node:20.9.0-alpine3.17 RUN apk --no-cache add git -COPY --from=build dist/run.mjs /run.mjs +COPY --from=build dist/run.js /run.js COPY package*.json / diff --git a/commitlint.config.mjs b/commitlint.config.js similarity index 90% rename from commitlint.config.mjs rename to commitlint.config.js index b1e2a18..68811a6 100644 --- a/commitlint.config.mjs +++ b/commitlint.config.js @@ -1,5 +1,5 @@ /* eslint-disable import/no-extraneous-dependencies */ -import { maxLineLength } from '@commitlint/ensure' +const { maxLineLength } = require('@commitlint/ensure') const bodyMaxLineLength = 100 @@ -14,7 +14,7 @@ const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => { ] } -export default { +module.exports = { extends: ['@commitlint/config-conventional'], plugins: ['commitlint-plugin-function-rules'], rules: { diff --git a/entrypoint.sh b/entrypoint.sh index 2fd7294..ff929ea 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,6 +12,4 @@ fi # Info about the vunlerability: https://github.blog/2022-04-12-git-security-vulnerability-announced/ git config --global --add safe.directory "$GITHUB_WORKSPACE" -export NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" - -node /run.mjs +node /run.js diff --git a/package-lock.json b/package-lock.json index ea57401..731e12d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "@jest/globals": "^29.7.0", "@rollup/plugin-babel": "^5.3.1", "@rollup/plugin-commonjs": "^22.0.2", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^14.1.0", "babel-jest": "^29.7.0", "commit-and-tag-version": "^12.2.0", @@ -5623,6 +5624,54 @@ "rollup": "^2.68.0" } }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-json/node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-json/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/@rollup/plugin-node-resolve": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-14.1.0.tgz", @@ -21574,6 +21623,34 @@ "resolve": "^1.17.0" } }, + "@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.1.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + } + } + }, "@rollup/plugin-node-resolve": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-14.1.0.tgz", diff --git a/package.json b/package.json index 31a096c..65cf177 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "5.4.6", "description": "commitlint github action", "private": true, - "module": "./dist/run.mjs", + "main": "./dist/run.mjs", "scripts": { "postinstall": "husky install", "test": "NODE_PATH=./node_modules NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest", @@ -49,6 +49,7 @@ "@jest/globals": "^29.7.0", "@rollup/plugin-babel": "^5.3.1", "@rollup/plugin-commonjs": "^22.0.2", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^14.1.0", "babel-jest": "^29.7.0", "commit-and-tag-version": "^12.2.0", diff --git a/rollup.config.js b/rollup.config.js index 6264ed1..7a5401a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,13 +2,17 @@ import path from 'path' import { nodeResolve } from '@rollup/plugin-node-resolve' import commonjs from '@rollup/plugin-commonjs' import { babel } from '@rollup/plugin-babel' +import json from '@rollup/plugin-json' import pkg from './package.json' +const bundledDeps = ['node_modules/dargs', '@commitlint', 'import-meta-resolve', 'global-directory'] + export default { input: 'run.mjs', external: (depName) => - depName.includes('node_modules') && !depName.includes('node_modules/dargs'), - output: [{ file: pkg.module, format: 'es' }], + depName.includes('node_modules') && + bundledDeps.every((bundledDep) => !depName.includes(bundledDep)), + output: [{ file: './dist/run.js', format: 'commonjs' }], plugins: [ babel({ babelHelpers: 'bundled', @@ -19,5 +23,6 @@ export default { preferBuiltins: true, }), commonjs(), + json(), ], }