From 9b04a92df29872d263180694df077321ce61815f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 18 Dec 2019 12:53:13 +1000 Subject: [PATCH] add typescript to build --- Makefile | 12 +++++++++++- ts/.gitignore | 1 + ts/package-lock.json | 35 +++++++++++++++++++++++++++++++++++ ts/package.json | 18 ++++++++++++++++++ ts/tsconfig.json | 21 +++++++++++++++++++++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 ts/.gitignore create mode 100644 ts/package-lock.json create mode 100644 ts/package.json create mode 100644 ts/tsconfig.json diff --git a/Makefile b/Makefile index 0c24d7d03..914e09c24 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ uninstall: clean: rm -rf .build -build: .build/ui +build: .build/ui js .build/ui: $(shell find designer -name '*.ui') ./tools/build_ui.sh @@ -84,3 +84,13 @@ pytype: .build/pytype .build/pytype: $(CHECKDEPS) pytype --config pytype.conf touch $@ + +.PHONY: js + +TSDEPS := $(wildcard ts/*.ts) +JSDEPS := $(patsubst ts/%.ts, web/%.js, $(TSDEPS)) + +js: $(JSDEPS) + +web/%.js: ts/%.ts + (cd ts && ./node_modules/.bin/tsc $(notdir $<) --outFile ../web/$(notdir $@)) diff --git a/ts/.gitignore b/ts/.gitignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/ts/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/ts/package-lock.json b/ts/package-lock.json new file mode 100644 index 000000000..afd442f36 --- /dev/null +++ b/ts/package-lock.json @@ -0,0 +1,35 @@ +{ + "name": "anki-dtop-js", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/jquery": { + "version": "3.3.31", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.31.tgz", + "integrity": "sha512-Lz4BAJihoFw5nRzKvg4nawXPzutkv7wmfQ5121avptaSIXlDNJCUuxZxX/G+9EVidZGuO0UBlk+YjKbwRKJigg==", + "dev": true, + "requires": { + "@types/sizzle": "*" + } + }, + "@types/mathjax": { + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/@types/mathjax/-/mathjax-0.0.36.tgz", + "integrity": "sha512-TqDJc2GWuTqd/m+G/FbNkN+/TF2OCCHvcawmhIrUaZkdVquMdNZmNiNUkupNg9qctorXXkVLVSogZv1DhmgLmg==", + "dev": true + }, + "@types/sizzle": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", + "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==", + "dev": true + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", + "dev": true + } + } +} diff --git a/ts/package.json b/ts/package.json new file mode 100644 index 000000000..4f0100257 --- /dev/null +++ b/ts/package.json @@ -0,0 +1,18 @@ +{ + "name": "anki-dtop-js", + "version": "1.0.0", + "description": "Anki desktop js support files", + "directories": { + "test": "tests" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Ankitects Pty Ltd", + "license": "AGPL-3.0-or-later", + "devDependencies": { + "@types/jquery": "^3.3.31", + "@types/mathjax": "0.0.36", + "typescript": "^3.7.3" + } +} diff --git a/ts/tsconfig.json b/ts/tsconfig.json new file mode 100644 index 000000000..d4a7c73f2 --- /dev/null +++ b/ts/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "target": "es6", + "noImplicitAny": true, + "moduleResolution": "node", + "sourceMap": false, + "baseUrl": ".", + "paths": { + "*": [ + "node_modules/*", + "src/types/*" + ] + } + }, + "include": [ + "src/**/*" + ] +} \ No newline at end of file