Commit a4ff1329 authored by Janka Uryga's avatar Janka Uryga

ci: enable typescript in some CI scripts

parent 8eba6007
// @ts-check
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const { existsSync } = require('fs') const { existsSync } = require('fs')
...@@ -102,7 +103,9 @@ module.exports = (actionInfo) => { ...@@ -102,7 +103,9 @@ module.exports = (actionInfo) => {
continue continue
} }
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath)) const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, 'utf-8')
)
const { name: packageName } = packageJson const { name: packageName } = packageJson
pkgDatas.set(packageName, { pkgDatas.set(packageName, {
...@@ -196,7 +199,7 @@ module.exports = (actionInfo) => { ...@@ -196,7 +199,7 @@ module.exports = (actionInfo) => {
return packingSpan return packingSpan
.traceChild('handle-package', { packageName }) .traceChild('handle-package', { packageName })
.traceAsyncFn(async (handlePackageSpan) => { .traceAsyncFn(async (handlePackageSpan) => {
/** @type {null | () => Promise<void>} */ /** @type {null | (() => Promise<void>)} */
let cleanup = null let cleanup = null
if (packageName === '@next/swc') { if (packageName === '@next/swc') {
......
// @ts-check
const os = require('os') const os = require('os')
const path = require('path') const path = require('path')
const _glob = require('glob') const _glob = require('glob')
...@@ -5,7 +6,12 @@ const { existsSync } = require('fs') ...@@ -5,7 +6,12 @@ const { existsSync } = require('fs')
const fsp = require('fs/promises') const fsp = require('fs/promises')
const nodeFetch = require('node-fetch') const nodeFetch = require('node-fetch')
const vercelFetch = require('@vercel/fetch') const vercelFetch = require('@vercel/fetch')
const fetch = vercelFetch(nodeFetch)
/** @type {import('@vercel/fetch').Fetch} */
const fetch =
// @ts-expect-error: TS doesn't understand default exports
vercelFetch(nodeFetch)
const { promisify } = require('util') const { promisify } = require('util')
const { Sema } = require('async-sema') const { Sema } = require('async-sema')
const { spawn, exec: execOrig } = require('child_process') const { spawn, exec: execOrig } = require('child_process')
...@@ -16,6 +22,7 @@ const core = require('@actions/core') ...@@ -16,6 +22,7 @@ const core = require('@actions/core')
const { getTestFilter } = require('./test/get-test-filter') const { getTestFilter } = require('./test/get-test-filter')
const mockSpan = require('./.github/actions/next-stats-action/src/util/mock-trace') const mockSpan = require('./.github/actions/next-stats-action/src/util/mock-trace')
// @ts-expect-error: missing type declarations for yargs
let argv = require('yargs/yargs')(process.argv.slice(2)) let argv = require('yargs/yargs')(process.argv.slice(2))
.string('type') .string('type')
.string('test-pattern') .string('test-pattern')
...@@ -313,6 +320,7 @@ async function main() { ...@@ -313,6 +320,7 @@ async function main() {
const groupTotal = parseInt(groupParts[1], 10) const groupTotal = parseInt(groupParts[1], 10)
if (prevTimings) { if (prevTimings) {
/** @type {TestFile[][]} */
const groups = [[]] const groups = [[]]
const groupTimes = [0] const groupTimes = [0]
...@@ -459,7 +467,9 @@ ${ENDGROUP}`) ...@@ -459,7 +467,9 @@ ${ENDGROUP}`)
// Format the output of junit report to include the test name // Format the output of junit report to include the test name
// For the debugging purpose to compare actual run list to the generated reports // For the debugging purpose to compare actual run list to the generated reports
// [NOTE]: This won't affect if junit reporter is not enabled // [NOTE]: This won't affect if junit reporter is not enabled
JEST_JUNIT_OUTPUT_NAME: test.file.replaceAll('/', '_'), JEST_JUNIT_OUTPUT_NAME:
// @ts-expect-error missing lib: es2021
test.file.replaceAll('/', '_'),
// Specify suite name for the test to avoid unexpected merging across different env / grouped tests // Specify suite name for the test to avoid unexpected merging across different env / grouped tests
// This is not individual suites name (corresponding 'describe'), top level suite name which have redundant names by default // This is not individual suites name (corresponding 'describe'), top level suite name which have redundant names by default
// [NOTE]: This won't affect if junit reporter is not enabled // [NOTE]: This won't affect if junit reporter is not enabled
...@@ -546,9 +556,12 @@ ${ENDGROUP}`) ...@@ -546,9 +556,12 @@ ${ENDGROUP}`)
} }
outputSema.release() outputSema.release()
} }
const err = new Error( const err = new Error(
code ? `failed with code: ${code}` : `failed with signal: ${signal}` code ? `failed with code: ${code}` : `failed with signal: ${signal}`
) )
// @ts-expect-error
err.output = outputChunks err.output = outputChunks
.map(({ chunk }) => chunk.toString()) .map(({ chunk }) => chunk.toString())
.join('') .join('')
......
// @ts-check
const os = require('os') const os = require('os')
const path = require('path') const path = require('path')
const execa = require('execa') const execa = require('execa')
...@@ -117,6 +118,7 @@ async function createNextInstall({ ...@@ -117,6 +118,7 @@ async function createNextInstall({
.traceAsyncFn((span) => .traceAsyncFn((span) =>
linkPackages({ linkPackages({
repoDir: tmpRepoDir, repoDir: tmpRepoDir,
nextSwcVersion: null,
parentSpan: span, parentSpan: span,
}) })
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment