Skip to content

Commit

Permalink
feat(eslint): migrate sdk gh action release package (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-crouzet authored Nov 7, 2024
2 parents 71e0994 + 2ec84c6 commit ada814d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 49 deletions.
17 changes: 0 additions & 17 deletions tools/github-actions/release/.eslintrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions tools/github-actions/release/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import shared from '../../../eslint.shared.config.mjs';
import local from './eslint.local.config.mjs';

export default [
...shared,
...local
];
36 changes: 36 additions & 0 deletions tools/github-actions/release/eslint.local.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
dirname
} from 'node:path';
import {
fileURLToPath
} from 'node:url';
import globals from 'globals';

const __filename = fileURLToPath(import.meta.url);
// __dirname is not defined in ES module scope
const __dirname = dirname(__filename);

export default [
{
name: '@o3r/new-version-gh-action/projects',
languageOptions: {
sourceType: 'module',
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'tsconfig.build.json',
'tsconfig.eslint.json'
]
},
globals: {
...globals.node
}
}
},
{
name: '@o3r/audit-gh-action/ignores',
ignores: [
'**/packaged-action/**'
]
}
];
25 changes: 15 additions & 10 deletions tools/github-actions/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@
"tslib": "^2.6.2"
},
"devDependencies": {
"@angular-eslint/eslint-plugin": "~18.3.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@nx/eslint-plugin": "~19.5.0",
"@o3r/eslint-config-otter": "workspace:~",
"@o3r/eslint-config": "workspace:~",
"@o3r/eslint-plugin": "workspace:~",
"@stylistic/eslint-plugin-ts": "~2.4.0",
"@stylistic/eslint-plugin": "~2.7.0",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@typescript-eslint/utils": "^7.14.1",
"@typescript-eslint/parser": "~8.12.2",
"@vercel/ncc": "~0.38.0",
"eslint": "^8.57.0",
"angular-eslint": "~18.3.0",
"eslint": "^9.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-import-newlines": "^1.4.0",
"eslint-plugin-jest": "~28.8.0",
"eslint-plugin-jsdoc": "~48.11.0",
"eslint-plugin-jsdoc": "~50.2.0",
"eslint-plugin-prefer-arrow": "~1.2.3",
"eslint-plugin-unicorn": "^54.0.0",
"eslint-plugin-sort-export-all": "^1.4.1",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.9.0",
"jsonc-eslint-parser": "~2.4.0",
"typescript": "~5.5.4"
"typescript": "~5.5.4",
"typescript-eslint": "~8.12.2"
},
"engines": {
"node": "^18.19.1 || ^20.11.1 || >=22.0.0"
Expand Down
8 changes: 1 addition & 7 deletions tools/github-actions/release/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
}
},
"lint": {
"options": {
"eslintConfig": "tools/github-actions/release/.eslintrc.js",
"lintFilePatterns": [
"tools/github-actions/release/src/**/*.ts",
"tools/github-actions/release/package.json"
]
}
"executor": "nx:run-commands"
}
},
"tags": []
Expand Down
17 changes: 12 additions & 5 deletions tools/github-actions/release/src/get-previous-version.cts
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
#!/usr/bin/env node
import { valid, gt, lt } from 'semver';
import * as minimist from 'minimist';
import {
gt,
lt,
valid
} from 'semver';

const argv = minimist(process.argv.slice(2));
const version = valid(argv._.at(0));

let data = '';

async function main() {
for await (const chunk of process.stdin) data += chunk;
for await (const chunk of process.stdin) {
data += chunk;
}

if (!version) {
// eslint-disable-next-line no-console -- only logger available
console.error('Invalid version provided');
process.exit(1);
}

const previousVersion = (JSON.parse(data) as string[])
.filter((tag) => !!tag)
.map((tag) => ({tag, version: valid(tag)}))
.filter((item): item is { tag: string, version: string } => !!item.version)
.reduce<{tag: string, version: string} | undefined>((acc, item) => {
.map((tag) => ({ tag, version: valid(tag) }))
.filter((item): item is { tag: string; version: string } => !!item.version)
.reduce<{ tag: string; version: string } | undefined>((acc, item) => {
if (lt(item.version, version) && (!acc || gt(item.version, acc.version))) {
acc = item;
}
Expand Down
25 changes: 15 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8596,7 +8596,7 @@ __metadata:
languageName: unknown
linkType: soft

"@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter, @o3r/eslint-config-otter@workspace:~":
"@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter":
version: 0.0.0-use.local
resolution: "@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter"
dependencies:
Expand Down Expand Up @@ -31279,28 +31279,33 @@ __metadata:
version: 0.0.0-use.local
resolution: "release-gh-action@workspace:tools/github-actions/release"
dependencies:
"@angular-eslint/eslint-plugin": "npm:~18.3.0"
"@eslint-community/eslint-plugin-eslint-comments": "npm:^4.4.0"
"@nx/eslint-plugin": "npm:~19.5.0"
"@o3r/eslint-config-otter": "workspace:~"
"@o3r/eslint-config": "workspace:~"
"@o3r/eslint-plugin": "workspace:~"
"@stylistic/eslint-plugin-ts": "npm:~2.4.0"
"@stylistic/eslint-plugin": "npm:~2.7.0"
"@types/minimist": "npm:^1.2.2"
"@types/node": "npm:^20.0.0"
"@types/semver": "npm:^7.3.13"
"@typescript-eslint/eslint-plugin": "npm:^7.14.1"
"@typescript-eslint/parser": "npm:^7.14.1"
"@typescript-eslint/utils": "npm:^7.14.1"
"@typescript-eslint/parser": "npm:~8.12.2"
"@vercel/ncc": "npm:~0.38.0"
eslint: "npm:^8.57.0"
angular-eslint: "npm:~18.3.0"
eslint: "npm:^9.0.0"
eslint-plugin-import: "npm:^2.31.0"
eslint-plugin-import-newlines: "npm:^1.4.0"
eslint-plugin-jest: "npm:~28.8.0"
eslint-plugin-jsdoc: "npm:~48.11.0"
eslint-plugin-jsdoc: "npm:~50.2.0"
eslint-plugin-prefer-arrow: "npm:~1.2.3"
eslint-plugin-unicorn: "npm:^54.0.0"
eslint-plugin-sort-export-all: "npm:^1.4.1"
eslint-plugin-unicorn: "npm:^55.0.0"
eslint-plugin-unused-imports: "npm:^4.1.4"
globals: "npm:^15.9.0"
jsonc-eslint-parser: "npm:~2.4.0"
minimist: "npm:^1.2.6"
semver: "npm:^7.5.2"
tslib: "npm:^2.6.2"
typescript: "npm:~5.5.4"
typescript-eslint: "npm:~8.12.2"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit ada814d

Please sign in to comment.