fear: bumped `ts` version and added check for `.d.ts` files (#828)

* fix: added CI check for build files

* fix: fixed node version in worklflows

* chore: revert code-push-ci.yml
This commit is contained in:
Saurav Aggarwal 2023-11-08 21:22:37 +05:30 коммит произвёл GitHub
Родитель d8b071852f
Коммит c6815bf340
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 52 добавлений и 6 удалений

45
.github/scripts/check-for-declaration.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,45 @@
import fs from "fs";
import path from "path";
type ResultType = {
js : Record<string , boolean>
ts : Record<string , boolean>
}
const result: ResultType = {js:{} , ts:{}}
const readThroughDirectory = (directory: string): void => {
const __directoryPath = directory
const files = fs.readdirSync(__directoryPath);
files.forEach((file) => {
const filePath = path.join(__directoryPath, file);
const stats = fs.statSync(filePath);
if (stats.isDirectory()) {
readThroughDirectory(filePath);
return
}
if(filePath.endsWith('.js')){
const name = filePath.split('.')
name.pop()
result.js[name.join('.')] = true
}
if(filePath.endsWith('.d.ts')){
const name = filePath.split('.')
name.pop()
name.pop()
result.ts[name.join('.')] = true
}
});
Object.keys(result.js).forEach(file => {
if(!result.ts[file]){
throw new Error(`Declaration File Missing for ${file}.js`)
}
})
};
readThroughDirectory(path.join(process.env.INIT_CWD ?? '', './bin'))

10
.github/workflows/code-push-ci.yml поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
name: Сode-push CI
on:
pull_request:
on:
pull_request:
branches:
- master
@ -15,10 +15,10 @@ jobs:
- name: Setup NodeJs
uses: actions/setup-node@v1
with:
node-version: '14.x'
node-version: "14.x"
- name: Setup dependencies
run: npm run setup
- name: Build
run: npm run build
- name: Run tests
run: npm run build
- name: Run tests
run: npm run test

Просмотреть файл

@ -10,7 +10,8 @@
"prebuild": "npm run clean",
"build": "tsc && npm run content",
"prebuild:release": "npm run clean",
"build:release": "tsc -p ./tsconfig-release.json && npm run content",
"build:release": "tsc -p ./tsconfig-release.json && npm run check:release && npm run content",
"check:release" : "npx ts-node .github/scripts/check-for-declaration.ts",
"test": "npm run build && mocha --recursive bin/test",
"test:debugger": "mocha --recursive --inspect-brk=0.0.0.0 bin/test",
"content": "shx cp {README.md,package.json,.npmignore} bin"