outdated commit hints in ci!! (#101)
This commit is contained in:
parent
889e652455
commit
aafdb64694
7 changed files with 77 additions and 33 deletions
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
|
@ -10,7 +10,10 @@ jobs:
|
|||
uses: actions/checkout@master
|
||||
- name: Install pnpm
|
||||
run: npm i -g pnpm
|
||||
# todo this needs investigating fixing
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
# cache: "pnpm"
|
||||
- run: pnpm install
|
||||
- run: pnpm lint
|
||||
- run: pnpm check-build
|
||||
|
|
@ -24,3 +27,7 @@ jobs:
|
|||
with:
|
||||
name: cypress-images
|
||||
path: cypress/integration/__image_snapshots__/
|
||||
- run: node scripts/outdatedGitPackages.mjs
|
||||
# if: github.ref == 'refs/heads/next'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@
|
|||
"prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
|
||||
"minecraft-protocol": "github:zardoy/minecraft-protocol#everything",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"updateConfig": {
|
||||
"ignoreDependencies": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"postinstall": "pnpm generate-textures && node buildWorker.mjs",
|
||||
"generate-textures": "tsx viewer/prepare/generateTextures.ts"
|
||||
"generate-textures": "tsx viewer/prepare/postinstall.ts"
|
||||
},
|
||||
"author": "PrismarineJS",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'path'
|
||||
import { makeBlockTextureAtlas } from './atlas'
|
||||
import { McAssets, prepareBlocksStates } from './modelsBuilder'
|
||||
import { prepareBlocksStates } from './modelsBuilder'
|
||||
import mcAssets from 'minecraft-assets'
|
||||
import fs from 'fs-extra'
|
||||
import { prepareMoreGeneratedBlocks } from './moreGeneratedBlocks'
|
||||
|
|
@ -9,10 +9,6 @@ import { generateItemsAtlases } from './genItemsAtlas'
|
|||
const publicPath = path.resolve(__dirname, '../../public')
|
||||
|
||||
const texturesPath = path.join(publicPath, 'textures')
|
||||
if (fs.existsSync(texturesPath) && !process.argv.includes('-f')) {
|
||||
console.log('textures folder already exists, skipping...')
|
||||
process.exit(0)
|
||||
}
|
||||
fs.mkdirSync(texturesPath, { recursive: true })
|
||||
|
||||
const blockStatesPath = path.join(publicPath, 'blocksStates')
|
||||
|
|
|
|||
12
prismarine-viewer/viewer/prepare/postinstall.ts
Normal file
12
prismarine-viewer/viewer/prepare/postinstall.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
|
||||
const publicPath = path.resolve(__dirname, '../../public')
|
||||
const texturesPath = path.join(publicPath, 'textures')
|
||||
|
||||
if (fs.existsSync(texturesPath) && !process.argv.includes('-f')) {
|
||||
console.log('textures folder already exists, skipping...')
|
||||
process.exit(0)
|
||||
} else {
|
||||
import('./generateTextures')
|
||||
}
|
||||
52
scripts/outdatedGitPackages.mjs
Normal file
52
scripts/outdatedGitPackages.mjs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// pnpm bug workaround
|
||||
import fs from 'fs'
|
||||
import { parse } from 'yaml'
|
||||
import _ from 'lodash'
|
||||
|
||||
const lockfile = parse(fs.readFileSync('./pnpm-lock.yaml', 'utf8'))
|
||||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'))
|
||||
const depsKeys = ['dependencies', 'devDependencies']
|
||||
|
||||
const githubToken = process.env.GITHUB_TOKEN
|
||||
const ignoreDeps = packageJson.pnpm?.updateConfig?.ignoreDependencies ?? []
|
||||
|
||||
const outdatedDeps = []
|
||||
|
||||
const allDepsObj = {}
|
||||
|
||||
for (const [key, val] of Object.entries(lockfile.importers)) {
|
||||
// Object.assign(allDepsObj, val)
|
||||
_.merge(allDepsObj, val)
|
||||
}
|
||||
|
||||
for (const [depsKey, deps] of Object.entries(allDepsObj)) {
|
||||
for (const [depName, { specifier, version }] of Object.entries(deps)) {
|
||||
if (ignoreDeps.includes(depName)) continue
|
||||
if (!specifier.startsWith('github:')) continue
|
||||
// console.log('checking github:', depName, version, specifier)
|
||||
|
||||
let possiblyBranch = specifier.match(/#(.*)$/)?.[1] ?? ''
|
||||
if (possiblyBranch) possiblyBranch = `/${possiblyBranch}`
|
||||
const sha = version.split('/').slice(3).join('/').replace(/\(.+/, '')
|
||||
const repo = version.split('/').slice(1, 3).join('/')
|
||||
|
||||
const lastCommitJson = await fetch(`https://api.github.com/repos/${repo}/commits${possiblyBranch}?per_page=1`, {
|
||||
headers: {
|
||||
Authorization: githubToken ? `token ${githubToken}` : undefined,
|
||||
},
|
||||
}).then(res => res.json())
|
||||
|
||||
const lastCommitActual = lastCommitJson ?? lastCommitJson[0]
|
||||
const lastCommitActualSha = Array.isArray(lastCommitActual) ? lastCommitActual[0]?.sha : lastCommitActual?.sha
|
||||
if (lastCommitActualSha === undefined) debugger
|
||||
if (sha !== lastCommitActualSha) {
|
||||
// console.log(`Outdated ${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha} (${lastCommitActual.commit.message})`)
|
||||
outdatedDeps.push({ depName, repo, sha, lastCommitActualSha })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (outdatedDeps.length) {
|
||||
throw new Error(`Outdated dependencies found: \n${outdatedDeps.map(({ depName, repo, sha, lastCommitActualSha }) => `${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha}`).join('\n')}`)
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// pnpm bug workaround
|
||||
import fs from 'fs'
|
||||
import { parse } from 'yaml'
|
||||
|
||||
const lockfile = parse(fs.readFileSync('./pnpm-lock.yaml', 'utf8'))
|
||||
|
||||
const depsKeys = ['dependencies', 'devDependencies']
|
||||
|
||||
for (const importer of Object.values(lockfile.importers)) {
|
||||
for (const depsKey of depsKeys) {
|
||||
for (const [depName, { specifier, version }] of Object.entries(importer[depsKey])) {
|
||||
if (!specifier.startsWith('github:')) continue
|
||||
let branch = specifier.match(/#(.*)$/)?.[1] ?? ''
|
||||
if (branch) branch = `/${branch}`
|
||||
const sha = version.split('/').slice(3).join('/').replace(/\(.+/, '')
|
||||
const repo = version.split('/').slice(1, 3).join('/')
|
||||
const lastCommitJson = await fetch(`https://api.github.com/repos/${repo}/commits${branch}?per_page=1`).then(res => res.json())
|
||||
const lastCommitActual = lastCommitJson ?? lastCommitJson[0]
|
||||
const lastCommitActualSha = lastCommitActual?.sha
|
||||
if (lastCommitActualSha === undefined) debugger
|
||||
if (sha !== lastCommitActualSha) {
|
||||
console.log(`Outdated ${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha} (${lastCommitActual.commit.message})`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue