diff --git a/Jenkinsfile b/Jenkinsfile index 7240a61..d06b5d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { } stage('Build') { steps { - sh './gradlew build typedoc eslint' + sh './gradlew build typedoc eslint typescriptDist' } post { success { diff --git a/src/main/ts/.gitignore b/src/main/ts/.gitignore index ccb2c80..e2dd579 100644 --- a/src/main/ts/.gitignore +++ b/src/main/ts/.gitignore @@ -1,2 +1,3 @@ node_modules/ -package-lock.json \ No newline at end of file +package-lock.json +lib/ \ No newline at end of file diff --git a/src/main/ts/package.json b/src/main/ts/package.json index 04bf7d0..dabdc14 100644 --- a/src/main/ts/package.json +++ b/src/main/ts/package.json @@ -1,5 +1,6 @@ { - "name": "scriptcraft", + "name": "minecraft", + "types": "lib/minecraft/index.d.ts", "devDependencies": { "@typescript-eslint/eslint-plugin": "latest", "@typescript-eslint/parser": "latest", diff --git a/src/main/ts/src/types/scriptcraft/index.d.ts b/src/main/ts/src/types/scriptcraft-core/index.d.ts similarity index 100% rename from src/main/ts/src/types/scriptcraft/index.d.ts rename to src/main/ts/src/types/scriptcraft-core/index.d.ts diff --git a/src/main/ts/tsconfig.json b/src/main/ts/tsconfig.json index 06a8c38..ec25cf7 100644 --- a/src/main/ts/tsconfig.json +++ b/src/main/ts/tsconfig.json @@ -12,7 +12,10 @@ "baseUrl": "src", "paths": { "minecraft": ["minecraft/index"] - } + }, + "outDir": "lib/ts", + "declaration": true, + "declarationDir": "lib/dts" }, "include": [ "src/**/*.ts" diff --git a/src/main/ts/typedoc.json b/src/main/ts/typedoc.json index af09caa..edd08b6 100644 --- a/src/main/ts/typedoc.json +++ b/src/main/ts/typedoc.json @@ -5,5 +5,6 @@ "excludeExternals": true, "excludeNotExported": true, "excludePrivate": true, - "stripInternal": true + "stripInternal": true, + "out": "lib/typedoc" } \ No newline at end of file diff --git a/typescript.build.gradle b/typescript.build.gradle index 5ff0455..5495b1e 100644 --- a/typescript.build.gradle +++ b/typescript.build.gradle @@ -1,30 +1,42 @@ -def typescriptOut = new File(buildDir, 'generated/typescript') - def typescriptRoot = 'src/main/ts' def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot) -task typescript(group: 'build') { +def typescriptOut = new File(typescriptRootFile, 'lib/ts') +def dtsOut = new File(typescriptRootFile, 'lib/dts') + +task typescript(group: 'typescript', type: Exec) { inputs.dir typescriptRootFile - outputs.dir typescriptOut + outputs.dirs typescriptOut, dtsOut + + workingDir typescriptRootFile + + executable 'npm' + + args 'run', 'build' doFirst { project.delete { - delete typescriptOut - } - typescriptOut.mkdirs() - - project.exec { - workingDir typescriptRootFile - - executable 'npm' - - args 'run', 'build', '--' - args '--outDir', typescriptOut.absolutePath + delete typescriptOut, dtsOut } } } -task eslint(group: 'verification', type: Exec) { +task typescriptDist(group: 'typescript', type: Tar) { + into('/types') { + from new File(typescriptRootFile as File, 'src/types') + } + into('/lib') { + from dtsOut + } + + archiveName 'typescript-dist.tar.gz' + destinationDir new File(buildDir, 'libs') + compression Compression.GZIP +} + +typescriptDist.dependsOn typescript + +task eslint(group: 'typescript', type: Exec) { workingDir typescriptRootFile executable 'npm' @@ -34,26 +46,22 @@ task eslint(group: 'verification', type: Exec) { processResources.dependsOn typescript -def typedocOut = new File(buildDir, 'typedoc') +def typedocOut = new File(typescriptRootFile, 'lib/typedoc') -task typedoc(group: 'documentation') { +task typedoc(group: 'typescript', type: Exec) { inputs.dir typescriptRootFile outputs.dir typedocOut + workingDir typescriptRootFile + + executable 'npm' + + args 'run', 'typedoc' + doFirst { project.delete { delete typedocOut } - typedocOut.mkdirs() - - project.exec { - workingDir typescriptRootFile - - executable 'npm' - - args 'run', 'typedoc', '--' - args '--out', typedocOut.absolutePath - } } }