Skip to content

Commit a166c2c

Browse files
committed
build(init): add dot-files and build scripts
1 parent ce9e102 commit a166c2c

9 files changed

+2168
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
node_modules/
3+
dist/

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "none",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": true,
6+
"printWidth": 120
7+
}

package-lock.json

Lines changed: 2048 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "@nutgaard/data-pack",
3+
"version": "0.0.1",
4+
"description": "Utility pack for working with random data",
5+
"keywords": [
6+
"data",
7+
"utility"
8+
],
9+
"author": "Nicklas Utgaard",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/nutgaard/data-pack"
14+
},
15+
"engines": {
16+
"node": ">=14.0.0"
17+
},
18+
"files": [
19+
"dist"
20+
],
21+
"main": "dist/index.js",
22+
"typings": "dist/index.d.ts",
23+
"scripts": {
24+
"build": "npm run build-ts && npm run build-tsc",
25+
"build-ts": "node scripts/esbuild.js",
26+
"dev-ts": "node scripts/esbuild.js --watch",
27+
"build-tsc": "tsc",
28+
"dev-tsc": "tsc --watch",
29+
"test": "ts-node test",
30+
"commit": "git-cz",
31+
"prepare": "husky install",
32+
"prettier": "prettier {test,src}/**/*.{js,css,md,ts} --write"
33+
},
34+
"devDependencies": {
35+
"@types/node": "^16.11.10",
36+
"chokidar": "^3.5.2",
37+
"commitizen": "^4.2.4",
38+
"esbuild": "^0.13.15",
39+
"esbuild-node-externals": "^1.4.0",
40+
"husky": "^7.0.4",
41+
"lint-staged": "^12.1.2",
42+
"prettier": "^2.4.1",
43+
"ts-node": "^10.4.0",
44+
"typescript": "^4.5.2"
45+
},
46+
"lint-staged": {
47+
"*.{js,css,md,ts}": "prettier --write"
48+
},
49+
"config": {
50+
"commitizen": {
51+
"path": "node_modules/cz-conventional-changelog"
52+
}
53+
}
54+
}

scripts/esbuild.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const esbuild = require('esbuild');
2+
const chokidar = require('chokidar');
3+
const { nodeExternalsPlugin } = require('esbuild-node-externals');
4+
5+
function build() {
6+
console.time('build');
7+
esbuild
8+
.build({
9+
entryPoints: ['./src/index.ts'],
10+
outfile: 'dist/index.js',
11+
bundle: true,
12+
minify: true,
13+
platform: 'node',
14+
sourcemap: true,
15+
target: 'node14',
16+
plugins: [nodeExternalsPlugin()]
17+
})
18+
.catch(() => process.exit(1))
19+
.finally(() => {
20+
console.timeEnd('build');
21+
});
22+
}
23+
24+
build();
25+
if (process.argv.includes('--watch')) {
26+
const fsWatch = chokidar.watch(['./src']);
27+
fsWatch.on('change', (file) => {
28+
console.log('Detected change to', file);
29+
build();
30+
});
31+
}

tmux-dev.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/sh
2+
3+
tmux new-window \; \
4+
rename-window 'data-pack-build' \; \
5+
send-keys 'npm run dev-ts' C-m \; \
6+
split-window -v \; \
7+
send-keys 'npm run dev-tsc' C-m \;

tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"emitDeclarationOnly": true,
4+
"declaration": true,
5+
"lib": ["ES2020"],
6+
"module": "CommonJS",
7+
"target": "ES2020",
8+
"noImplicitAny": true,
9+
"moduleResolution": "Node",
10+
"outDir": "dist"
11+
},
12+
"include": ["src/**/*"]
13+
}

0 commit comments

Comments
 (0)