From 76e144bc2a28d1c130b6c2a53a4ca6ec8c5e67a7 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Wed, 23 Aug 2023 03:20:10 +0000 Subject: [PATCH] feat: add build script (#13) This commit adds pnpm scripts for compiling and running the typocomath package, and a convenience script `pnpm go` that does both in succession. It also configure pnpm to use a shell emulator so that it should work on Windows as well. Finally, it changes the directory for object files from obj to build. Resolves #9. Reviewed-on: https://code.studioinfinity.org/glen/typocomath/pulls/13 Co-authored-by: Glen Whitney Co-committed-by: Glen Whitney --- .gitignore | 2 +- .npmrc | 1 + README.md | 11 +++++------ etc/package.json | 1 + package.json5 | 4 ++++ tsconfig.json | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .npmrc create mode 100644 etc/package.json diff --git a/.gitignore b/.gitignore index d0c9d9e..aeea740 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ *~ # Typescript # emitted code -obj +build # ---> Node # Logs diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..3bd3b7d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +shell-emulator=true diff --git a/README.md b/README.md index 73af828..d626b30 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ A final (?) prototype for a refactor of mathjs, culminating the picomath, pocomath, typomath series. Provides an extensible core with "fuzzy" types for its operations, that can at any time generate exact .d.ts file for its current state. -To build and run the prototype, run: -``` -npx tsc -echo '{"type": "module"}' > obj/package.json -node obj -``` +Convenience scripts: + +* `pnpm build` -- compile the package +* `pnpm exec` -- run the compiled code produced by `pnpm build` +* `pnpm go` -- both of the above in sequence. diff --git a/etc/package.json b/etc/package.json new file mode 100644 index 0000000..6990891 --- /dev/null +++ b/etc/package.json @@ -0,0 +1 @@ +{"type": "module"} diff --git a/package.json5 b/package.json5 index 9cfd021..f233b62 100644 --- a/package.json5 +++ b/package.json5 @@ -5,7 +5,11 @@ main: 'index.ts', scripts: { test: 'echo "Error: no test specified" && exit 1', + build: 'tsc && cp etc/package.json build', + exec: 'node build', + go: 'pnpm --sequential "/build|exec/"', }, + packageManager: 'pnpm', keywords: [ 'math', 'algebra', diff --git a/tsconfig.json b/tsconfig.json index b45999b..13b7b6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "ES2022", "rootDir": "./src", - "outDir": "./obj", + "outDir": "./build", "moduleResolution": "nodenext" } }