mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-23 00:36:28 +00:00
build system
This commit is contained in:
parent
88e502562a
commit
3af5d0ef1a
@ -6,12 +6,13 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.cjs --watch",
|
"dev": "./scripts/build.js --watch",
|
||||||
"build": "rm -rf ./dist && tsc && esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.cjs",
|
"build": "./scripts/build.js",
|
||||||
"package": "node ./build.js",
|
"package": "./scripts/package.js",
|
||||||
"bin": "run-s build package",
|
"bin": "run-s build package",
|
||||||
"prepublishOnly": "run-s build"
|
"prepublishOnly": "run-s build"
|
||||||
},
|
},
|
||||||
|
"main": "./dist/index.cjs",
|
||||||
"bin": {
|
"bin": {
|
||||||
"cryptgeon": "./dist/index.cjs"
|
"cryptgeon": "./dist/index.cjs"
|
||||||
},
|
},
|
||||||
|
17
packages/cli/scripts/build.js
Executable file
17
packages/cli/scripts/build.js
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { build, context } from 'esbuild'
|
||||||
|
import pkg from '../package.json' assert { type: 'json' }
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
entryPoints: ['./src/index.ts'],
|
||||||
|
bundle: true,
|
||||||
|
minify: true,
|
||||||
|
platform: 'node',
|
||||||
|
outfile: './dist/index.cjs',
|
||||||
|
define: { VERSION: `"${pkg.version}"` },
|
||||||
|
}
|
||||||
|
|
||||||
|
const watch = process.argv.slice(2)[0] === '--watch'
|
||||||
|
if (watch) (await context(options)).watch()
|
||||||
|
else await build(options)
|
2
packages/cli/build.js → packages/cli/scripts/package.js
Normal file → Executable file
2
packages/cli/build.js → packages/cli/scripts/package.js
Normal file → Executable file
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { exec } from 'pkg'
|
import { exec } from 'pkg'
|
||||||
|
|
||||||
const targets = [
|
const targets = [
|
@ -21,6 +21,9 @@ const minutes = new Option('-m --minutes <number>', 'Minutes before the note exp
|
|||||||
// Node 18 guard
|
// Node 18 guard
|
||||||
parseInt(process.version.slice(1).split(',')[0]) < 18 && exit('Node 18 or higher is required')
|
parseInt(process.version.slice(1).split(',')[0]) < 18 && exit('Node 18 or higher is required')
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const version: string = VERSION
|
||||||
|
|
||||||
async function checkConstrains(constrains: { views?: number; minutes?: number }) {
|
async function checkConstrains(constrains: { views?: number; minutes?: number }) {
|
||||||
const { views, minutes } = constrains
|
const { views, minutes } = constrains
|
||||||
if (views && minutes) exit('cannot set view and minutes constrains simultaneously')
|
if (views && minutes) exit('cannot set view and minutes constrains simultaneously')
|
||||||
@ -33,7 +36,7 @@ async function checkConstrains(constrains: { views?: number; minutes?: number })
|
|||||||
exit(`Only a maximum of ${response.max_expiration} minutes allowed. ${minutes} given.`)
|
exit(`Only a maximum of ${response.max_expiration} minutes allowed. ${minutes} given.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
program.name('cryptgeon').version('1.0.0').configureHelp({ showGlobalOptions: true })
|
program.name('cryptgeon').version(version).configureHelp({ showGlobalOptions: true })
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('info')
|
.command('info')
|
||||||
|
Loading…
Reference in New Issue
Block a user