Skip to content

Commit c4fbcca

Browse files
committed
feat: add build and types command
1 parent 9601dc4 commit c4fbcca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+626
-168
lines changed

.github/workflows/package.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Typescript Package CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
workflow_dispatch:
12+
inputs:
13+
beta_release:
14+
description: Create beta release
15+
required: true
16+
type: boolean
17+
18+
jobs:
19+
typescript:
20+
uses: skyleague/node-standards/.github/workflows/reusable-typescript.yml@main
21+
secrets:
22+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
24+
release:
25+
needs: [typescript]
26+
uses: skyleague/node-standards/.github/workflows/reusable-release.yml@main
27+
with:
28+
build_artifact_name: ${{ needs.typescript.outputs.artifact-name }}
29+
beta_release: ${{ inputs.beta_release || false }}
30+
secrets:
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

bin/run.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run.js" %*

bin/run.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env node
2+
import { spawn } from 'node:child_process'
3+
import fs from 'node:fs'
4+
import path from 'node:path'
5+
import { fileURLToPath } from 'node:url'
6+
7+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
8+
9+
const project = path.join(__dirname, '../tsconfig.json')
10+
const dev = fs.existsSync(project) && process.env.DEBUG !== 'false'
11+
12+
if (dev && !process.env.NODE_OPTIONS?.includes('--import tsx/esm')) {
13+
await new Promise((resolve, reject) => {
14+
const subprocess = spawn(process.argv[0], [...process.argv.slice(1)], {
15+
cwd: process.cwd(),
16+
env: { ...process.env, NODE_OPTIONS: `--import tsx/esm --enable-source-maps ${process.env.NODE_OPTIONS ?? ''}` },
17+
stdio: 'inherit',
18+
})
19+
20+
subprocess.on('exit', (code) => {
21+
if (code === 0) {
22+
resolve()
23+
} else {
24+
reject(process.exit(code))
25+
}
26+
})
27+
28+
subprocess.on('error', (err) => {
29+
reject(err)
30+
})
31+
})
32+
process.exit(0)
33+
}
34+
35+
const { run } = dev ? await import('../src/index.ts') : await import('../.dist/index.js')
36+
await run().catch(console.error)

0 commit comments

Comments
 (0)