mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 16:26:28 +00:00
build system
This commit is contained in:
parent
88e502562a
commit
3af5d0ef1a
@ -6,12 +6,13 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.cjs --watch",
|
||||
"build": "rm -rf ./dist && tsc && esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.cjs",
|
||||
"package": "node ./build.js",
|
||||
"dev": "./scripts/build.js --watch",
|
||||
"build": "./scripts/build.js",
|
||||
"package": "./scripts/package.js",
|
||||
"bin": "run-s build package",
|
||||
"prepublishOnly": "run-s build"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"bin": {
|
||||
"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'
|
||||
|
||||
const targets = [
|
@ -21,6 +21,9 @@ const minutes = new Option('-m --minutes <number>', 'Minutes before the note exp
|
||||
// Node 18 guard
|
||||
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 }) {
|
||||
const { views, minutes } = constrains
|
||||
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.`)
|
||||
}
|
||||
|
||||
program.name('cryptgeon').version('1.0.0').configureHelp({ showGlobalOptions: true })
|
||||
program.name('cryptgeon').version(version).configureHelp({ showGlobalOptions: true })
|
||||
|
||||
program
|
||||
.command('info')
|
||||
|
Loading…
Reference in New Issue
Block a user