-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,30 +9,39 @@ jobs: | |
|
||
build-all: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '14' | ||
|
||
- run: | | ||
pwd | ||
cd ${{ github.repository }} | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm install | ||
run: npm ic | ||
|
||
- name: Run build | ||
run: npm run build | ||
run: | | ||
mkdir dist | ||
npm run build | ||
npm run build:csgo | ||
- name: Switch to build branch | ||
run: git checkout build | ||
- name: Configure git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Action" | ||
git fetch --all | ||
git checkout --track origin/build | ||
- name: Copy files | ||
run: cp "./dist/*" "./" | ||
run: cp -r ./dist/* ./ | ||
|
||
- name: Commit files | ||
run: | | ||
git add *.d.ts | ||
git commit -m "Build for ${{ github.ref }}" | ||
git push | ||
git commit -m "Automated build on ${{ github.ref }}" | ||
git push origin build | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
import { createReadStream, createWriteStream, readFileSync } from 'fs'; | ||
import { glob } from 'glob'; | ||
import { createReadStream, createWriteStream, readFileSync, readdirSync } from 'fs'; | ||
import MultiStream from 'multistream'; | ||
import ReplaceStream from 'replacestream'; | ||
|
||
const header = readFileSync('src/header.d.ts', { encoding: 'utf-8' }) | ||
.replace('$npm_package_version$', process.env.npm_package_version); | ||
|
||
function build(files, out_name) { | ||
function build(files, out_name, replace_chaos=false) { | ||
const output = createWriteStream(`dist/${out_name}.d.ts`, { encoding: 'utf-8' }); | ||
output.write(header); | ||
|
||
const streams = files.map(x => createReadStream(x, { encoding: 'utf-8' })); | ||
new MultiStream(streams).pipe(output); | ||
const ms = new MultiStream(streams); | ||
|
||
if (!replace_chaos) ms.pipe(output); | ||
else ms.pipe(ReplaceStream('Chaos', 'CSGO')).pipe(output); | ||
} | ||
|
||
async function eval_globs(sources) { | ||
function list_files(sources) { | ||
const files = []; | ||
|
||
for (const source of sources) | ||
files.push(...await glob(`src/${source}/*.d.ts`)); | ||
|
||
return files; | ||
for (const source of sources) { | ||
const root_dir = `src/${source}/`; | ||
const rawlist = readdirSync(root_dir, { recursive: true }); | ||
const remapped = rawlist.map(x => root_dir+x.replace(/\\\\/, '/')); | ||
files.push(...remapped); | ||
} | ||
return files.filter(x => x.endsWith('.d.ts')); | ||
} | ||
|
||
if (process.argv.length !== 4) throw('Argument count must equal 4!'); | ||
const sources = process.argv[2].split(','); | ||
const files = await eval_globs(sources); | ||
build(files, process.argv[3]); | ||
const files = list_files(sources); | ||
|
||
const filename = process.argv[3]; | ||
build(files, filename, filename === 'csgo'); |
Oops, something went wrong.