From aadcf83883aec4e305dd459d28941841a167b4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 9 Feb 2023 21:28:58 +0100 Subject: [PATCH] Remove usage of Dukat Dukat results are still very suboptimal and in Kotlin 1.8.20-Beta it was disabled. As most usages were already replaced by kotlin-wrappers or self-written class, now the last remaining three classes are hand-written too and Dukat is not necessary, including the massive post-processing just to make it compile. This will save the time for running Dukat, for doing the post processing, and for compiling quite some unncessary classes. If Dukat is improved and added back to the Gradle plugin integration, this decision can be reconsidered, but for now it saves much time and is better future proof in the light of 1.8.20-Beta. --- .../kotlin/net/kautler/ncc_packer.gradle.kts | 2 +- .../main/kotlin/net/kautler/node.gradle.kts | 129 +--------- .../util/DependencyHandlerExtension.kt | 6 +- gradle/libs.versions.toml | 3 - kotlin-js-store/yarn.lock | 13 - resources/dukat-cli-0.0.12.js | 203 ---------------- resources/dukat-cli-0.5.7.js | 223 ------------------ src/main/kotlin/NullWritable.kt | 21 ++ src/main/kotlin/SemVer.kt | 19 ++ 9 files changed, 44 insertions(+), 575 deletions(-) delete mode 100644 resources/dukat-cli-0.0.12.js delete mode 100644 resources/dukat-cli-0.5.7.js create mode 100644 src/main/kotlin/NullWritable.kt create mode 100644 src/main/kotlin/SemVer.kt diff --git a/gradle/build-logic/src/main/kotlin/net/kautler/ncc_packer.gradle.kts b/gradle/build-logic/src/main/kotlin/net/kautler/ncc_packer.gradle.kts index c2b14553..c4d1e9b7 100644 --- a/gradle/build-logic/src/main/kotlin/net/kautler/ncc_packer.gradle.kts +++ b/gradle/build-logic/src/main/kotlin/net/kautler/ncc_packer.gradle.kts @@ -85,5 +85,5 @@ dependencies { implementation(platform(libs.kotlin.wrappers.bom)) implementation(libs.kotlin.wrapper.js) implementation(libs.kotlin.wrapper.node) - implementation(npm(libs.build.vercel.ncc, generateExternals = false)) + implementation(npm(libs.build.vercel.ncc)) } diff --git a/gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts b/gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts index 3541d9c1..e1326ea2 100644 --- a/gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts +++ b/gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts @@ -16,12 +16,9 @@ package net.kautler -import java.security.MessageDigest -import kotlin.text.RegexOption.MULTILINE import net.kautler.dao.action.GitHubAction import net.kautler.util.npm import org.gradle.accessors.dm.LibrariesForLibs -import org.jetbrains.kotlin.gradle.targets.js.dukat.IntegratedDukatTask import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.yaml.snakeyaml.Yaml @@ -83,50 +80,6 @@ val libs = the() configure { nodeVersion = libs.versions.build.node.get() - versions.dukat.version = libs.versions.build.dukat.get() - - // work-around for https://github.com/Kotlin/dukat/issues/103 - npmInstallTaskProvider!!.configure { - val patchedDukat0012CliJs = layout - .projectDirectory - .file("resources/dukat-cli-0.0.12.js") - - val patchedDukat057CliJs = layout - .projectDirectory - .file("resources/dukat-cli-0.5.7.js") - - inputs - .files(patchedDukat0012CliJs, patchedDukat057CliJs) - .withPropertyName("patched dukat-cli.js files") - - doLast { - val dukatCliJs = rootPackageDir.resolve("node_modules/dukat/bin/dukat-cli.js") - - if (dukatCliJs.exists()) { - val sha256 = MessageDigest - .getInstance("SHA-256") - .digest(dukatCliJs.readBytes()) - .joinToString("") { "%02x".format(it) } - - when (sha256) { - // already a patched version - "32b7c91ecf8c94b8f1e554da870a617437e421db07e40d558dbb959bd221cb5e", - "e16d684be9b90c2d5d78f90077dc9690253fd4d7bc6b48f94bbd48b1692bf2d5" -> - return@doLast - - // original 0.0.12 version - "ceebdfbb94d103eb44da265b572e51fb69ff4bb1c524b94f621c6a6e94716ac8" -> - patchedDukat0012CliJs.asFile.copyTo(dukatCliJs, overwrite = true) - - // original 0.5.7 version - "12645e1491b68638d2c1c4146502ae9ed5037baa82cc12e6c55070471d962187" -> - patchedDukat057CliJs.asFile.copyTo(dukatCliJs, overwrite = true) - - else -> throw RuntimeException("dukat-cli.js has unexpected checksum $sha256") - } - } - } - } } dependencies { @@ -135,94 +88,14 @@ dependencies { implementation(libs.kotlin.wrapper.actions.toolkit) implementation(libs.kotlin.wrapper.js) implementation(libs.kotlin.wrapper.node) - implementation(npm(libs.types.semver)) - implementation(npm(libs.semver, generateExternals = false)) + implementation(npm(libs.semver)) implementation(npm(libs.nullWritable)) } -tasks.withType(IntegratedDukatTask::class).configureEach { - doLast { - // work-around for https://github.com/Kotlin/dukat/issues/397 - deleteExternalsFiles( - this, - "*.module_node.kt", - "*.nonDeclarations.kt" - ) - fixExternalsFiles( - this, - "lib.dom.kt" to listOf( - """\Qimport url.URL as _URL\E$""" to "import node.url.URL as _URL", - """\Qimport url.URLSearchParams as _URLSearchParams\E$""" to "import node.url.URLSearchParams as _URLSearchParams", - """\Qoverride fun addEventListener(type: String, listener: EventListenerObject\E""" to "fun addEventListener(type: String, listener: EventListenerObject", - """\Qoverride fun removeEventListener(type: String, callback: EventListenerObject\E""" to "fun removeEventListener(type: String, callback: EventListenerObject", - """\Q`T$19`\E""" to """`T\$19`""" - ), - // work-around for https://github.com/Kotlin/dukat/issues/402 - "lib.es2018.asynciterable.module_dukat.kt" to listOf( - """\Qval `return`: ((value: TReturn) -> Promise | IteratorReturnResult */>)?\E$""" to "val `return`: ((value: dynamic) -> Promise | IteratorReturnResult */>)?", - """\Qval `return`: ((value: PromiseLike) -> Promise | IteratorReturnResult */>)?\E\r?\n\Q get() = definedExternally\E\r?\n""" to "" - ), - "lib.es2020.bigint.module_dukat.kt" to listOf( - """\Q : RelativeIndexable\E""" to "" - ), - "lib.es5.kt" to listOf( - """\Qimport NodeJS.CallSite\E$""" to "import node.CallSite", - """\Qval resolve: ((specified: String, parent: URL) -> Promise)?\E$""" to "val resolve2: ((specified: String, parent: URL) -> Promise)?" - ), - // work-around for https://github.com/Kotlin/dukat/issues/401 - "null-writable.module_null-writable.kt" to listOf( - """\Qimport stream.internal.`T$17`\E$""" to "", - """\Qimport stream.internal.Writable\E$""" to "import node.stream.Writable", - """\Qoverride fun _write(_chunk: Any, _encoding: String, callback: (error: Error?) -> Unit)\E$""" to "override fun _write(chunk: Any, encoding: node.buffer.BufferEncoding, callback: (error: Error?) -> Unit)", - """\Qopen fun _writev(_chunks: Array<`T$3`>, callback: (error: Error?) -> Unit)\E$""" to "", - """\Qoverride fun _writev(chunks: Array<`T$17`>, callback: (error: Error?) -> Unit)\E$""" to "" - ), - "semver.module_semver.kt" to listOf( - """\Q@JsModule("semver")\E$""" to """@JsModule("semver/classes/semver")""" - ) - ) - } -} - tasks.assemble { dependsOn(project(":ncc-packer").tasks.named("nodeProductionRun")) } -fun deleteExternalsFiles(task: Task, vararg files: String) { - if (files.isNotEmpty()) { - task - .outputs - .files - .asFileTree - .matching { - for (file in files) { - include("**/$file") - } - } - .forEach { it.delete() } - } -} - -fun fixExternalsFiles(task: Task, vararg pairs: Pair>>) { - for ((file, fixups) in pairs) { - task - .outputs - .files - .asFileTree - .matching { include("**/$file") } - .singleFile - .apply { - writeText( - fixups - .map { (pattern, replacement) -> pattern.toRegex(MULTILINE) to replacement } - .fold(readText()) { current, (regex, replacement) -> - regex.replace(current, replacement) - } - ) - } - } -} - fun plugin(plugin: Provider) = plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version.requiredVersion}" } diff --git a/gradle/build-logic/src/main/kotlin/net/kautler/util/DependencyHandlerExtension.kt b/gradle/build-logic/src/main/kotlin/net/kautler/util/DependencyHandlerExtension.kt index 6bfc035b..c1b6297b 100644 --- a/gradle/build-logic/src/main/kotlin/net/kautler/util/DependencyHandlerExtension.kt +++ b/gradle/build-logic/src/main/kotlin/net/kautler/util/DependencyHandlerExtension.kt @@ -23,13 +23,11 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependencyExtension fun DependencyHandler.npm( - dependency: Provider, - generateExternals: Boolean = true + dependency: Provider ): NpmDependency { val dep = dependency.get() return (extensions.getByName("npm") as NpmDependencyExtension)( name = if (dep.group == "") dep.name else "@${dep.group}/${dep.name}", - version = dep.version!!, - generateExternals = generateExternals + version = dep.version!! ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 07baeead..c7875eff 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,6 @@ # limitations under the License. [versions] -build-dukat = "0.5.7" build-github-api = "1.117" build-gradle-plugin-dependency-analysis = "1.19.0" build-gradle-plugin-github = "1.4.0" @@ -32,7 +31,6 @@ kotlin-wrappers = "1.0.0-pre.498" kotlinx-coroutines = "1.6.4" nullWritable = "1.0.5" semver = "7.3.8" -types-semver = "7.3.13" workflows-kotlin = "1.8.10" [libraries] @@ -50,7 +48,6 @@ kotlin-wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers- kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } nullWritable = { module = ":null-writable", version.ref = "nullWritable" } semver = { module = ":semver", version.ref = "semver" } -types-semver = { module = "types:semver", version.ref = "types-semver" } workflows-kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "workflows-kotlin" } workflows-kotlin-main-kts = { module = "org.jetbrains.kotlin:kotlin-main-kts", version.ref = "workflows-kotlin" } workflows-kotlin-scripting-compiler = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler", version.ref = "workflows-kotlin" } diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 11819f76..a94a884f 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -210,11 +210,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850" integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg== -"@types/semver@7.3.13": - version "7.3.13" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" - integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw== - "@types/tunnel@^0.0.3": version "0.0.3" resolved "https://registry.yarnpkg.com/@types/tunnel/-/tunnel-0.0.3.tgz#f109e730b072b3136347561fc558c9358bb8c6e9" @@ -399,14 +394,6 @@ diff@5.0.0: resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== -dukat@0.5.7: - version "0.5.7" - resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.7.tgz#4b3981f3fbde993546cc6f674b9027923f7293c6" - integrity sha512-PBM+B1oIE/aHbcrtdqX8yHfwdfdJ5ejJzkbU2LOW7bbAC3r1EcEyrS9ytFdHMPv06gVkF2QO77zGcMbGcsmXaA== - dependencies: - google-protobuf "3.12.2" - typescript "3.9.5" - dukat@0.5.8-rc.4: version "0.5.8-rc.4" resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.4.tgz#90384dcb50b14c26f0e99dae92b2dea44f5fce21" diff --git a/resources/dukat-cli-0.0.12.js b/resources/dukat-cli-0.0.12.js deleted file mode 100644 index f96e251f..00000000 --- a/resources/dukat-cli-0.0.12.js +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env node - -var execSync = require('child_process').execSync; -var spawn = require('child_process').spawn; -var path = require('path'); -var fs = require('fs'); - -var createBundle = require("../lib/converter").createBundle; -var Readable = require('stream').Readable; -var EventEmitter = require('events'); - -var printError = function (errorMessage) { - if (typeof errorMessage !== "string") { - console.error("ERROR:"); - console.error(errorMessage) - } else { - console.error("ERROR: " + errorMessage); - } -}; - -function run(command, args) { - var child = spawn(command, args); - process.stdin.pipe(child.stdin); - - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - - return child; -} - -function printInvalidJavaHome() { - printError("Your \"JAVA_HOME\" environment variable points to an invalid directory."); - printError("As of now \"dukat\" requires Java Runtime Environment to be installed."); - printError("Either set \"JAVA_HOME\" to a proper Java installation,"); - printError("or make sure \"java\" is callable from commandline and unset \"JAVA_HOME\"."); -} - -function printNoJava() { - printError("\"java\" is not callable from commandline and no \"JAVA_HOME\" environment variable is set."); - printError("As of now \"dukat\" requires Java Runtime Environment to be installed."); - printError("Either set \"JAVA_HOME\" to a proper Java installation,"); - printError("or make sure \"java\" is callable from commandline."); -} - -function findJavaExecutable() { - var javaHome = process.env.JAVA_HOME - var result = javaHome ? path.join(javaHome, "bin", "java") : "java" - try { - execSync('"' + result + "\" -version", { - stdio: ['pipe', 'ignore', 'pipe'] - }); - } catch (error) { - printError(error) - if (javaHome) { - printInvalidJavaHome(); - } else { - printNoJava(); - } - process.exit(1); - } - return result -} - -function createReadable() { - var readable = new Readable(); - readable._read = function(chunk) {}; - - return readable -} - -function getStdLib() { - return path.resolve(__dirname, "..", "d.ts.libs/lib.es6.d.ts"); -} - -function processArgs(args) { - var skip_2args = new Set(["-d", "-p", "-m", "-r"]); - var ordinary_args = new Set(["--descriptors"]); - var count = 0; - - var binaryOutput = null; - var stdlib = getStdLib(); - - while (count < args.length) { - var arg = args[count]; - if(arg == "-b") { - binaryOutput = args[count + 1]; - count += 2; - } else if(arg == "-l") { - stdlib = args[count + 1]; - count += 2; - } else if (skip_2args.has(arg)) { - count += 2; - } else if (ordinary_args.has(arg)) { - count++; - } else { - break; - } - } - - var files = []; - if (count < args.length) { - files = args.slice(count).map(function(arg) { - return path.resolve(arg); - }); - } - - var res = { - stdlib: stdlib, - binaryOutput: binaryOutput, - files: files - }; - - return res; -} - -function endsWith(str, postfix) { - return str.lastIndexOf(postfix) == (str.length - postfix.length); -} - - -function createBinaryStream(stdlib, files, onData, onEnd) { - var bundle = createBundle(stdlib, files); - - var readable = createReadable(); - - if (typeof onData == "function") { - readable.on("data", onData); - } - - if (typeof onEnd == "function") { - readable.on("end", onEnd); - } - - readable.push(bundle.serializeBinary()); - readable.push(null); - - return readable; -} - -function cliMode(args) { - var packageDir = path.resolve(__dirname, ".."); - - if (args[0] == "-v" || args[0] == "version") { - var version = require(path.resolve(packageDir, "package.json")).version; - console.log("dukat version " + version); - return; - } - - var runtimePath = path.resolve(packageDir, "build/runtime"); - var jsPath = path.resolve(runtimePath, "js.jar"); - var cliPath = path.resolve(runtimePath, "dukat-cli.jar"); - var classPath = [jsPath, cliPath].join(path.delimiter); - - var java = findJavaExecutable(); - - var argsProcessed = processArgs(args); - - var files = argsProcessed.files; - var is_ts = files.every(function(file) { return endsWith(file, ".d.ts")}); - var is_idl = files.every(function(file) { return endsWith(file, ".idl") || endsWith(file, ".webidl")}); - - if (is_ts) { - var inputStream = createBinaryStream(argsProcessed.stdlib, files); - - if (typeof argsProcessed.binaryOutput == "string") { - inputStream.pipe(fs.createWriteStream(argsProcessed.binaryOutput)); - return null; - } - - var commandArgs = [ - "-Ddukat.cli.internal.packagedir=" + packageDir, - "-cp", classPath, "org.jetbrains.dukat.cli.CliKt"].concat(args); - - var dukatProcess = run(java, commandArgs); - inputStream.pipe(dukatProcess.stdin); - return dukatProcess; - } else if (is_idl) { - var commandArgs = [ - "-Ddukat.cli.internal.packagedir=" + packageDir, - "-cp", classPath, "org.jetbrains.dukat.cli.CliKt"].concat(args); - - return run(java, commandArgs); - } - - process.exit(1); -} - -var main = function (args) { - var childProcess = cliMode(args); - if (childProcess instanceof EventEmitter) { - childProcess.on("exit", function() { - process.exit(); - }); - } -}; - -if (require.main === module) { - main(process.argv.slice(2)); -} - -exports.translate = main; -exports.createBinaryStream = createBinaryStream; -exports.getStdLib = getStdLib; \ No newline at end of file diff --git a/resources/dukat-cli-0.5.7.js b/resources/dukat-cli-0.5.7.js deleted file mode 100644 index 824f686f..00000000 --- a/resources/dukat-cli-0.5.7.js +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/env node - -var execSync = require('child_process').execSync; -var spawn = require('child_process').spawn; -var path = require('path'); -var fs = require('fs'); - -var createSourceSet = require("../lib/converter").createSourceSet; -var Readable = require('stream').Readable; -var EventEmitter = require('events'); - -var printError = function (errorMessage) { - if (typeof errorMessage !== "string") { - console.error("ERROR:"); - console.error(errorMessage) - } else { - console.error("ERROR: " + errorMessage); - } -}; - -function run(command, args) { - var child = spawn(command, args); - process.stdin.pipe(child.stdin); - - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - - return child; -} - -function printInvalidJavaHome() { - printError("Your \"JAVA_HOME\" environment variable points to an invalid directory."); - printError("As of now \"dukat\" requires Java Runtime Environment to be installed."); - printError("Either set \"JAVA_HOME\" to a proper Java installation,"); - printError("or make sure \"java\" is callable from commandline and unset \"JAVA_HOME\"."); -} - -function printNoJava() { - printError("\"java\" is not callable from commandline and no \"JAVA_HOME\" environment variable is set."); - printError("As of now \"dukat\" requires Java Runtime Environment to be installed."); - printError("Either set \"JAVA_HOME\" to a proper Java installation,"); - printError("or make sure \"java\" is callable from commandline."); -} - -function findJavaExecutable() { - var javaHome = process.env.JAVA_HOME - var result = javaHome ? path.join(javaHome, "bin", "java") : "java" - try { - execSync('"' + result + "\" -version", { - stdio: ['pipe', 'ignore', 'pipe'] - }); - } catch (error) { - printError(error) - if (javaHome) { - printInvalidJavaHome(); - } else { - printNoJava(); - } - process.exit(1); - } - return result -} - -function createReadable() { - var readable = new Readable(); - readable._read = function(chunk) {}; - - return readable -} - -function getStdLib() { - return path.resolve(__dirname, "..", "d.ts.libs/lib.es6.d.ts"); -} - -function processArgs(args) { - var skip_2args = new Set(["-d", "-p", "-m", "-r"]); - var ordinary_args = new Set(["--descriptors"]); - var count = 0; - - var binaryOutput = null; - var stdlib = getStdLib(); - var tsConfig = null; - - while (count < args.length) { - var arg = args[count]; - if (arg == "-b") { - binaryOutput = args[count + 1]; - count += 2; - } else if (arg == "--ts-config") { - tsConfig = args[count + 1]; - count += 2; - } else if(arg == "-l") { - stdlib = args[count + 1]; - count += 2; - } else if (skip_2args.has(arg)) { - count += 2; - } else if (ordinary_args.has(arg)) { - count++; - } else { - break; - } - } - - var files = []; - if (count < args.length) { - files = args.slice(count).map(function(arg) { - return path.resolve(arg); - }); - } - - return { - stdlib: stdlib, - binaryOutput: binaryOutput, - files: files, - tsConfig: tsConfig - }; -} - -function endsWith(str, postfix) { - return str.lastIndexOf(postfix) == (str.length - postfix.length); -} - - - -function createBinary(tsConfig, stdlib, emitDiagnostics, files) { - return createSourceSet(tsConfig, stdlib, emitDiagnostics, files); -} - -function createReadableStream(binary, onData, onEnd) { - var readable = createReadable(); - - if (typeof onData == "function") { - readable.on("data", onData); - } - - if (typeof onEnd == "function") { - readable.on("end", onEnd); - } - - readable.push(binary.serializeBinary()); - readable.push(null); - - return readable; -} - -function cliMode(args) { - var packageDir = path.resolve(__dirname, ".."); - - if (args[0] == "-v" || args[0] == "version") { - var version = require(path.resolve(packageDir, "package.json")).version; - console.log("dukat version " + version); - return; - } - - var runtimePath = path.resolve(packageDir, "build/runtime"); - var cliPath = path.resolve(runtimePath, "dukat-cli.jar"); - var classPath = [cliPath].join(path.delimiter); - - var java = findJavaExecutable(); - - var argsProcessed = processArgs(args); - - var files = argsProcessed.files; - var is_ts = files.every(function(file) { return endsWith(file, ".d.ts") || endsWith(file, ".ts")}); - var is_idl = files.every(function(file) { return endsWith(file, ".idl") || endsWith(file, ".webidl")}); - var is_js = files.every(function(file) { return endsWith(file, ".js")}); - - if (is_ts || is_js) { - try { - let bundle = createBinary(argsProcessed.tsConfig, argsProcessed.stdlib, false, files); - - var inputStream = createReadableStream(bundle); - - if (typeof argsProcessed.binaryOutput == "string") { - inputStream.pipe(fs.createWriteStream(argsProcessed.binaryOutput)); - return null; - } - - var commandArgs = [ - "-Ddukat.cli.internal.packagedir=" + packageDir, - "-cp", classPath, "org.jetbrains.dukat.cli.CliKt"].concat(args); - - var dukatProcess = run(java, commandArgs); - inputStream.pipe(dukatProcess.stdin); - return dukatProcess; - } catch (e) { - if (e.hasOwnProperty("tsDiagnostic")) { - console.log(`failed to parse tsconfig: ${argsProcessed.tsConfig}`); - } else { - console.log("unresolved exception"); - } - console.log(e); - process.exit(1); - } - - } else if (is_idl) { - var commandArgs = [ - "-Ddukat.cli.internal.packagedir=" + packageDir, - "-cp", classPath, "org.jetbrains.dukat.cli.CliKt"].concat(args); - - return run(java, commandArgs); - } - - process.exit(1); -} - -var main = function (args) { - var childProcess = cliMode(args); - if (childProcess instanceof EventEmitter) { - childProcess.on("exit", function() { - process.exit(); - }); - } -}; - -if (require.main === module) { - main(process.argv.slice(2)); -} - -exports.translate = main; -exports.createBinary = createBinary; -exports.createReadableStream = createReadableStream; -exports.getStdLib = getStdLib; \ No newline at end of file diff --git a/src/main/kotlin/NullWritable.kt b/src/main/kotlin/NullWritable.kt new file mode 100644 index 00000000..98fa7158 --- /dev/null +++ b/src/main/kotlin/NullWritable.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2020-2023 Björn Kautler + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:JsModule("null-writable") + +import node.stream.Writable + +external class NullWritable : Writable diff --git a/src/main/kotlin/SemVer.kt b/src/main/kotlin/SemVer.kt new file mode 100644 index 00000000..e1406d7b --- /dev/null +++ b/src/main/kotlin/SemVer.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2020-2023 Björn Kautler + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@JsModule("semver/classes/semver") +external class SemVer(version: String, options: RangeOptions) +external interface RangeOptions