Skip to content

Commit 793c138

Browse files
authored
chore(scripts): replace tsc by esbuild (#3425)
1 parent 8171dd3 commit 793c138

File tree

15 files changed

+597
-249
lines changed

15 files changed

+597
-249
lines changed

eslint/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"name": "eslint-plugin-automation-custom",
33
"version": "1.0.0",
44
"description": "Custom rules for eslint",
5-
"main": "dist/src/index.js",
5+
"main": "dist/index.js",
66
"files": [
77
"src/**.ts"
88
],
99
"scripts": {
10-
"build": "rm -rf dist/ && tsc",
10+
"build": "esbuild --bundle --minify --platform=node --outdir=dist --log-level=error src/index.ts",
1111
"lint": "eslint --ext=ts .",
1212
"lint:fix": "eslint --ext=ts --fix .",
1313
"test": "jest"
@@ -17,6 +17,7 @@
1717
"@babel/preset-env": "7.24.8",
1818
"@babel/preset-typescript": "7.24.7",
1919
"@types/jest": "29.5.12",
20+
"esbuild": "0.23.0",
2021
"eslint": "8.57.0",
2122
"jest": "29.7.0",
2223
"typescript": "5.5.3"

scripts/ci/actions/restore-artifacts/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ inputs:
1111
List of languages to restore (use the pipe character to put each language on its own line)
1212
runs:
1313
using: 'node20'
14-
main: './builddir/index.js'
14+
main: './builddir/index.cjs'

scripts/ci/actions/restore-artifacts/builddir/index.cjs

Lines changed: 256 additions & 0 deletions
Large diffs are not rendered by default.

scripts/ci/actions/restore-artifacts/builddir/index.js

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

scripts/ci/actions/restore-artifacts/builddir/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/ci/actions/restore-artifacts/builddir/package.json

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

scripts/ci/actions/restore-artifacts/builddir/sourcemap-register.cjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/ci/githubActions/createMatrix.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { setOutput } from '@actions/core';
44
import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common.js';
55
import { getLanguageFolder, getTestExtension, getTestOutputFolder } from '../../config.js';
66

7-
import { COMMON_DEPENDENCIES, DEPENDENCIES } from './setRunVariables.js';
87
import type { ClientMatrix, CreateMatrix, ToRunMatrix } from './types.js';
9-
import { isBaseChanged } from './utils.js';
8+
import { COMMON_DEPENDENCIES, DEPENDENCIES, isBaseChanged } from './utils.js';
109

1110
// This empty matrix is required by the CI, otherwise it throws
1211
const EMPTY_MATRIX = { client: ['no-run'] };

scripts/ci/githubActions/setRunVariables.ts

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,7 @@
11
/* eslint-disable no-console */
22
import * as core from '@actions/core';
33

4-
import { LANGUAGES } from '../../common.js';
5-
import { getLanguageFolder } from '../../config.js';
6-
import type { Language } from '../../types.js';
7-
8-
import { isBaseChanged } from './utils.js';
9-
10-
export const COMMON_DEPENDENCIES = {
11-
GITHUB_ACTIONS_CHANGED: ['.github/actions', '.github/workflows'],
12-
SCRIPTS_CHANGED: [
13-
'scripts',
14-
'eslint',
15-
'yarn.lock',
16-
'.eslintrc.cjs',
17-
'config/generation.config.mjs',
18-
'config/clients.config.json',
19-
'config/release.config.json',
20-
'generators',
21-
'tests/CTS',
22-
'.nvmrc',
23-
],
24-
COMMON_SPECS_CHANGED: ['specs/common'],
25-
};
26-
27-
export function getVersionFileForLanguage(lang: Language): string {
28-
// js rely on the nvmrc of the repo
29-
if (lang === 'javascript') {
30-
return '.nvmrc';
31-
}
32-
33-
// jvm lang rely on the same java version
34-
if (lang === 'kotlin' || lang === 'java' || lang === 'scala') {
35-
return 'config/.java-version';
36-
}
37-
38-
return `config/.${lang}-version`;
39-
}
40-
41-
/**
42-
* This dependency array is generated to match the "external" dependencies of a generated client.
43-
*
44-
* Those variables are used to determine if jobs should run, based on the changes
45-
* made in their respective dependencies.
46-
*
47-
* Negative paths should start with `:!`.
48-
*
49-
* The variable will be accessible in the CI via `steps.diff.outputs.<name>`.
50-
*
51-
* Variables starting by `LANGUAGENAME_` will be used in the `createMatrix` to determine
52-
* if a job should be added.
53-
*/
54-
export const DEPENDENCIES = LANGUAGES.reduce(
55-
(finalDependencies, lang) => {
56-
const key = `${lang.toUpperCase()}_CLIENT_CHANGED`;
57-
const langFolder = getLanguageFolder(lang);
58-
59-
finalDependencies[key] = [
60-
':!**node_modules',
61-
`templates/${lang}`,
62-
// language related files
63-
langFolder,
64-
getVersionFileForLanguage(lang),
65-
`:!${langFolder}/.github`,
66-
`:!${langFolder}/README.md`,
67-
];
68-
69-
return finalDependencies;
70-
},
71-
{ ...COMMON_DEPENDENCIES } as Record<string, string[]>,
72-
);
4+
import { DEPENDENCIES, isBaseChanged } from './utils.js';
735

746
/**
757
* Outputs variables used in the CI to determine if a job should run.

scripts/ci/githubActions/utils.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,75 @@
11
/* eslint-disable no-console */
22
import * as core from '@actions/core';
33

4+
import { LANGUAGES } from '../../common.js';
5+
import { getLanguageFolder } from '../../config.js';
6+
import type { Language } from '../../types.js';
47
import { getNbGitDiff } from '../utils.js';
58

9+
export const COMMON_DEPENDENCIES = {
10+
GITHUB_ACTIONS_CHANGED: ['.github/actions', '.github/workflows'],
11+
SCRIPTS_CHANGED: [
12+
'scripts',
13+
'eslint',
14+
'yarn.lock',
15+
'.eslintrc.cjs',
16+
'config/generation.config.mjs',
17+
'config/clients.config.json',
18+
'config/release.config.json',
19+
'generators',
20+
'tests/CTS',
21+
'.nvmrc',
22+
],
23+
COMMON_SPECS_CHANGED: ['specs/common'],
24+
};
25+
26+
/**
27+
* This dependency array is generated to match the "external" dependencies of a generated client.
28+
*
29+
* Those variables are used to determine if jobs should run, based on the changes
30+
* made in their respective dependencies.
31+
*
32+
* Negative paths should start with `:!`.
33+
*
34+
* The variable will be accessible in the CI via `steps.diff.outputs.<name>`.
35+
*
36+
* Variables starting by `LANGUAGENAME_` will be used in the `createMatrix` to determine
37+
* if a job should be added.
38+
*/
39+
export const DEPENDENCIES = LANGUAGES.reduce(
40+
(finalDependencies, lang) => {
41+
const key = `${lang.toUpperCase()}_CLIENT_CHANGED`;
42+
const langFolder = getLanguageFolder(lang);
43+
44+
finalDependencies[key] = [
45+
':!**node_modules',
46+
`templates/${lang}`,
47+
// language related files
48+
langFolder,
49+
getVersionFileForLanguage(lang),
50+
`:!${langFolder}/.github`,
51+
`:!${langFolder}/README.md`,
52+
];
53+
54+
return finalDependencies;
55+
},
56+
{ ...COMMON_DEPENDENCIES } as Record<string, string[]>,
57+
);
58+
59+
function getVersionFileForLanguage(lang: Language): string {
60+
// js rely on the nvmrc of the repo
61+
if (lang === 'javascript') {
62+
return '.nvmrc';
63+
}
64+
65+
// jvm lang rely on the same java version
66+
if (lang === 'kotlin' || lang === 'java' || lang === 'scala') {
67+
return 'config/.java-version';
68+
}
69+
70+
return `config/.${lang}-version`;
71+
}
72+
673
/**
774
* Determines if changes have been found in the `dependencies`, compared to the `baseBranch`.
875
*

0 commit comments

Comments
 (0)