From dddc0bcfc36e359e88593e6ec3f9d4e38ebc311d Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Mon, 8 Aug 2022 13:45:07 -0700 Subject: [PATCH 01/24] Work in progress toward linking reactor-ts as an npm module --- org.lflang/src/lib/ts/package.json | 8 ++--- org.lflang/src/lib/ts/reactor-ts | 2 +- .../org/lflang/generator/ts/TSFileConfig.kt | 15 ++++++++++ .../org/lflang/generator/ts/TSGenerator.kt | 30 +++++++++++++++++-- .../generator/ts/TSImportPreambleGenerator.kt | 24 +++++++-------- 5 files changed, 58 insertions(+), 21 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index f8ea477625..fb8a2e23ec 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -8,12 +8,8 @@ }, "license": "BSD-2-Clause", "dependencies": { - "command-line-args": "^5.1.1", - "command-line-usage": "^6.1.0", - "microtime": "^3.0.0", - "ulog": "^2.0.0-beta.7", - "google-protobuf": "^3.7.4", - "uuid": "^8.3.2" + "reactor-ts": "^0.1.0", + "command-line-usage": "^6.1.0" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index e5c9020c39..9a24ce4b05 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit e5c9020c3971868b0670b0d78116e38ca64741a5 +Subproject commit 9a24ce4b0589e09bfc58c196736075217ff2fffa diff --git a/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt b/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt index 7549d2c78b..915184a97b 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt @@ -58,6 +58,21 @@ class TSFileConfig( */ fun tsSrcGenPath(): Path = srcGenPath.resolve("src") + /** + * + */ + fun tsRuntimePath(): Path = outPath.resolve("lib").resolve("reactor-ts") + + /** + * + */ + fun tsRuntimeSrcPath(): Path = tsRuntimePath().resolve("src") + + /** + * + */ + fun tsRuntimeSrcCorePath(): Path = tsRuntimeSrcPath().resolve("core") + /** * Path to TypeScript core source code. */ diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index 9cb49f4f7b..e34c5cd957 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -57,6 +57,7 @@ import org.lflang.lf.Type import org.lflang.lf.VarRef import org.lflang.scoping.LFGlobalScopeProvider import org.lflang.util.FileUtil +import java.nio.file.FileSystems import java.nio.file.Files import java.nio.file.Path import java.nio.file.StandardCopyOption @@ -91,6 +92,8 @@ class TSGenerator( */ val CONFIG_FILES = arrayOf("package.json", "tsconfig.json", "babel.config.js", ".eslintrc.json") + val RT_CONFIG_FILES = arrayOf("package.json", "package-lock.json", "tsconfig.json", ".babelrc") + /** * Files to be copied from the reactor-ts submodule into the generated * source directory. @@ -155,6 +158,7 @@ class TSGenerator( clean(context) copyRuntime() + buildRuntime() copyConfigFiles() val codeMaps = HashMap() @@ -216,9 +220,31 @@ class TSGenerator( for (runtimeFile in RUNTIME_FILES) { FileUtil.copyFileFromClassPath( "$LIB_PATH/reactor-ts/src/core/$runtimeFile", - tsFileConfig.tsCoreGenPath().resolve(runtimeFile) + tsFileConfig.tsRuntimeSrcCorePath().resolve(runtimeFile) ) } + for (configFile in RT_CONFIG_FILES) { + FileUtil.copyFileFromClassPath( + "$LIB_PATH/reactor-ts/$configFile", + tsFileConfig.tsRuntimePath().resolve(configFile) + ) + } + } + + private fun buildRuntime() { + (commandFactory.createCommand( + "npm", + listOf("install"), + tsFileConfig.tsRuntimePath(), + false // only produce a warning if command is not found + )).run() + + (commandFactory.createCommand( + "npm", + listOf("link"), + tsFileConfig.tsRuntimePath(), + false // only produce a warning if command is not found + )).run() } /** @@ -237,7 +263,7 @@ class TSGenerator( "No '" + configFile + "' exists in " + fileConfig.srcPath + ". Using default configuration." ) - FileUtil.copyFileFromClassPath("$LIB_PATH/$configFile", configFileDest) + FileUtil.copyFileFromClassPath("$LIB_PATH/$configFile", configFileDest) // FIXME: use resolve } } } diff --git a/org.lflang/src/org/lflang/generator/ts/TSImportPreambleGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSImportPreambleGenerator.kt index 2855be06ad..7fa9c26e22 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSImportPreambleGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSImportPreambleGenerator.kt @@ -51,18 +51,18 @@ class TSImportPreambleGenerator( const val DEFAULT_IMPORTS = """ |import commandLineArgs from 'command-line-args' |import commandLineUsage from 'command-line-usage' - |import {Parameter as __Parameter, Timer as __Timer, Reactor as __Reactor, App as __App} from './core/reactor' - |import {Action as __Action, Startup as __Startup, FederatePortAction as __FederatePortAction} from './core/action' - |import {Bank as __Bank} from './core/bank' - |import {FederatedApp as __FederatedApp} from './core/federation' - |import {InPort as __InPort, OutPort as __OutPort, Port as __Port} from './core/port' - |import {InMultiPort as __InMultiPort, OutMultiPort as __OutMultiPort} from './core/multiport' - |import {Reaction as __Reaction} from './core/reaction' - |import {State as __State} from './core/state' - |import {TimeUnit, TimeValue, Tag as __Tag, Origin as __Origin} from './core/time' - |import {Args as __Args, Variable as __Variable, Triggers as __Triggers, Present, Read, Write, ReadWrite, MultiReadWrite, Sched} from './core/types' - |import {Log} from './core/util' - |import {ProcessedCommandLineArgs as __ProcessedCommandLineArgs, CommandLineOptionDefs as __CommandLineOptionDefs, CommandLineUsageDefs as __CommandLineUsageDefs, CommandLineOptionSpec as __CommandLineOptionSpec, unitBasedTimeValueCLAType as __unitBasedTimeValueCLAType, booleanCLAType as __booleanCLAType} from './core/cli' + |import {Parameter as __Parameter, Timer as __Timer, Reactor as __Reactor, App as __App} from 'reactor-ts' + |import {Action as __Action, Startup as __Startup, FederatePortAction as __FederatePortAction} from 'reactor-ts' + |import {Bank as __Bank} from 'reactor-ts' + |import {FederatedApp as __FederatedApp} from 'reactor-ts' + |import {InPort as __InPort, OutPort as __OutPort, Port as __Port} from 'reactor-ts' + |import {InMultiPort as __InMultiPort, OutMultiPort as __OutMultiPort} from 'reactor-ts' + |import {Reaction as __Reaction} from 'reactor-ts' + |import {State as __State} from 'reactor-ts' + |import {TimeUnit, TimeValue, Tag as __Tag, Origin as __Origin} from 'reactor-ts' + |import {Args as __Args, Variable as __Variable, Triggers as __Triggers, Present, Read, Write, ReadWrite, MultiReadWrite, Sched} from 'reactor-ts' + |import {Log} from 'reactor-ts' + |import {ProcessedCommandLineArgs as __ProcessedCommandLineArgs, CommandLineOptionDefs as __CommandLineOptionDefs, CommandLineUsageDefs as __CommandLineUsageDefs, CommandLineOptionSpec as __CommandLineOptionSpec, unitBasedTimeValueCLAType as __unitBasedTimeValueCLAType, booleanCLAType as __booleanCLAType} from 'reactor-ts' |""" } From a6abfb7e47f1100b0e5fbe06b9280140d8281877 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Tue, 9 Aug 2022 00:16:38 -0700 Subject: [PATCH 02/24] Link to files rather than use npm link --- org.lflang/src/lib/ts/package.json | 2 +- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index fb8a2e23ec..a24c7881df 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -8,7 +8,7 @@ }, "license": "BSD-2-Clause", "dependencies": { - "reactor-ts": "^0.1.0", + "reactor-ts": "file:../../lib/reactor-ts", "command-line-usage": "^6.1.0" }, "devDependencies": { diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index e34c5cd957..5ad5945754 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -238,13 +238,6 @@ class TSGenerator( tsFileConfig.tsRuntimePath(), false // only produce a warning if command is not found )).run() - - (commandFactory.createCommand( - "npm", - listOf("link"), - tsFileConfig.tsRuntimePath(), - false // only produce a warning if command is not found - )).run() } /** From d58685ef8322ed85c4e251a077f1278232dc23c0 Mon Sep 17 00:00:00 2001 From: You-Ri Su Date: Wed, 17 Aug 2022 17:00:21 -0700 Subject: [PATCH 03/24] work in progress --- org.lflang/src/lib/ts/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index a24c7881df..f8b075882c 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -8,8 +8,9 @@ }, "license": "BSD-2-Clause", "dependencies": { - "reactor-ts": "file:../../lib/reactor-ts", - "command-line-usage": "^6.1.0" + "@types/reactor-ts": "file:../../lib/reactor-ts", + "command-line-usage": "^6.1.0", + "command-line-args": "^5.1.1" }, "devDependencies": { "@babel/cli": "^7.8.4", From e8d43c431203fe425d223b629a8c0841155d99a4 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Mon, 22 Aug 2022 16:57:36 -0700 Subject: [PATCH 04/24] Work around inability to use declaration files. See https://github.com/microsoft/TypeScript/issues/35822 --- org.lflang/src/lib/ts/package.json | 2 ++ org.lflang/src/lib/ts/reactor-ts | 2 +- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index f8b075882c..3d7911721d 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -2,12 +2,14 @@ "name": "LinguaFrancaDefault", "version": "0.0.1", "description": "A default Lingua Franca project for the TypeScript target", + "type": "commonjs", "repository": { "type": "git", "url": "https://github.com/icyphy/lingua-franca" }, "license": "BSD-2-Clause", "dependencies": { + "reactor-ts": "file:../../lib/reactor-ts", "@types/reactor-ts": "file:../../lib/reactor-ts", "command-line-usage": "^6.1.0", "command-line-args": "^5.1.1" diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 9a24ce4b05..6b7134bfd2 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 9a24ce4b0589e09bfc58c196736075217ff2fffa +Subproject commit 6b7134bfd229ead4f34b074297c49b55775bf175 diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index 5ad5945754..a67fd4ebb7 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -101,7 +101,7 @@ class TSGenerator( val RUNTIME_FILES = arrayOf("action.ts", "bank.ts", "cli.ts", "command-line-args.d.ts", "command-line-usage.d.ts", "component.ts", "event.ts", "federation.ts", "internal.ts", "reaction.ts", "reactor.ts", "microtime.d.ts", "multiport.ts", "nanotimer.d.ts", "port.ts", - "state.ts", "strings.ts", "time.ts", "trigger.ts", "types.ts", "ulog.d.ts", "util.ts") + "state.ts", "strings.ts", "time.ts", "trigger.ts", "types.ts", "ulog.d.ts", "util.ts", "index.ts") private val VG = ExpressionGenerator(::timeInTargetLanguage) { param -> "this.${param.name}.get()" } From 3eee04b4577c7bec10b24372ddab6e9896a70be1 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Mon, 22 Aug 2022 18:56:18 -0700 Subject: [PATCH 05/24] Copy reactor-ts freely. This change is made out of pure laziness. Human time is worth more than computer time -- and disk space. --- org.lflang/src/lib/ts/package.json | 4 +-- org.lflang/src/lib/ts/tsconfig.json | 2 +- .../org/lflang/generator/ts/TSFileConfig.kt | 23 +++------------- .../org/lflang/generator/ts/TSGenerator.kt | 27 ++++++------------- test/README.md | 2 +- 5 files changed, 16 insertions(+), 42 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index 3d7911721d..9074d5676a 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -9,8 +9,8 @@ }, "license": "BSD-2-Clause", "dependencies": { - "reactor-ts": "file:../../lib/reactor-ts", - "@types/reactor-ts": "file:../../lib/reactor-ts", + "reactor-ts": "file:./reactor-ts", + "@types/reactor-ts": "file:./reactor-ts", "command-line-usage": "^6.1.0", "command-line-args": "^5.1.1" }, diff --git a/org.lflang/src/lib/ts/tsconfig.json b/org.lflang/src/lib/ts/tsconfig.json index af0b62567e..dcd0f1ec7d 100644 --- a/org.lflang/src/lib/ts/tsconfig.json +++ b/org.lflang/src/lib/ts/tsconfig.json @@ -14,6 +14,6 @@ "strictFunctionTypes": true, }, "include": [ - "src/**/*", + "src/**/*" ] } diff --git a/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt b/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt index 915184a97b..b2687848df 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSFileConfig.kt @@ -58,37 +58,22 @@ class TSFileConfig( */ fun tsSrcGenPath(): Path = srcGenPath.resolve("src") - /** - * - */ - fun tsRuntimePath(): Path = outPath.resolve("lib").resolve("reactor-ts") - - /** - * - */ - fun tsRuntimeSrcPath(): Path = tsRuntimePath().resolve("src") - - /** - * - */ - fun tsRuntimeSrcCorePath(): Path = tsRuntimeSrcPath().resolve("core") - /** * Path to TypeScript core source code. */ - fun tsCoreGenPath(): Path = tsSrcGenPath().resolve("core") + fun reactorTsPath(): Path = srcGenPath.resolve("reactor-ts") /** * Path to the generated docker file */ fun tsDockerFilePath(tsFileName: String): Path { - return srcGenPath.resolve(tsFileName + ".Dockerfile") + return srcGenPath.resolve("$tsFileName.Dockerfile") } - + /** * Path to the generated docker compose file */ fun tsDockerComposeFilePath(): Path { return srcGenPath.resolve("docker-compose.yml") } -} \ No newline at end of file +} diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index a67fd4ebb7..de9322a42d 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -57,7 +57,6 @@ import org.lflang.lf.Type import org.lflang.lf.VarRef import org.lflang.scoping.LFGlobalScopeProvider import org.lflang.util.FileUtil -import java.nio.file.FileSystems import java.nio.file.Files import java.nio.file.Path import java.nio.file.StandardCopyOption @@ -83,7 +82,7 @@ class TSGenerator( ) : GeneratorBase(tsFileConfig, errorReporter) { companion object { - /** Path to the Cpp lib directory (relative to class path) */ + /** Path to the TS lib directory (relative to class path) */ const val LIB_PATH = "/lib/ts" /** @@ -94,15 +93,6 @@ class TSGenerator( val RT_CONFIG_FILES = arrayOf("package.json", "package-lock.json", "tsconfig.json", ".babelrc") - /** - * Files to be copied from the reactor-ts submodule into the generated - * source directory. - */ - val RUNTIME_FILES = arrayOf("action.ts", "bank.ts", "cli.ts", "command-line-args.d.ts", - "command-line-usage.d.ts", "component.ts", "event.ts", "federation.ts", "internal.ts", - "reaction.ts", "reactor.ts", "microtime.d.ts", "multiport.ts", "nanotimer.d.ts", "port.ts", - "state.ts", "strings.ts", "time.ts", "trigger.ts", "types.ts", "ulog.d.ts", "util.ts", "index.ts") - private val VG = ExpressionGenerator(::timeInTargetLanguage) { param -> "this.${param.name}.get()" } @@ -217,16 +207,15 @@ class TSGenerator( * Copy the TypeScript runtime so that it is accessible to the generated code. */ private fun copyRuntime() { - for (runtimeFile in RUNTIME_FILES) { - FileUtil.copyFileFromClassPath( - "$LIB_PATH/reactor-ts/src/core/$runtimeFile", - tsFileConfig.tsRuntimeSrcCorePath().resolve(runtimeFile) - ) - } + FileUtil.copyDirectoryFromClassPath( + "$LIB_PATH/reactor-ts/src/core", + tsFileConfig.reactorTsPath().resolve("src").resolve("core"), + true + ) for (configFile in RT_CONFIG_FILES) { FileUtil.copyFileFromClassPath( "$LIB_PATH/reactor-ts/$configFile", - tsFileConfig.tsRuntimePath().resolve(configFile) + tsFileConfig.reactorTsPath().resolve(configFile) ) } } @@ -235,7 +224,7 @@ class TSGenerator( (commandFactory.createCommand( "npm", listOf("install"), - tsFileConfig.tsRuntimePath(), + tsFileConfig.reactorTsPath(), false // only produce a warning if command is not found )).run() } diff --git a/test/README.md b/test/README.md index 6198dc3ebe..284706e6b6 100644 --- a/test/README.md +++ b/test/README.md @@ -9,7 +9,7 @@ The simplest way to run the regression tests is to use a Bash script called `run run-lf-tests C run-lf-tests Cpp run-lf-tests Python -run-lf-tests TS +run-lf-tests TypeScript ``` You can also selectively run just some of the tests. For example, to run the system tests for an individual target language, do this: From e165600c9c4247a5c8b62cc2afff8ece2a6d05d9 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Mon, 22 Aug 2022 22:56:45 -0700 Subject: [PATCH 06/24] Make build more portable. --- org.lflang/src/lib/ts/package.json | 2 +- org.lflang/src/lib/ts/reactor-ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index 9074d5676a..92c25a4498 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -36,6 +36,6 @@ }, "scripts": { "check-types": "tsc", - "build": "rimraf dist && babel src --out-dir dist --extensions .ts,.js" + "build": "npx rimraf dist && npx babel src --out-dir dist --extensions .ts,.js" } } diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 6b7134bfd2..3e2972d599 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 6b7134bfd229ead4f34b074297c49b55775bf175 +Subproject commit 3e2972d599607f080b15790c54c9a153f785f0f8 From 664965e809ade9a0ffdcdb28943de1571d426908 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Tue, 23 Aug 2022 12:01:14 -0700 Subject: [PATCH 07/24] Try again to run Babel. --- org.lflang/src/lib/ts/package.json | 10 +++++----- org.lflang/src/lib/ts/reactor-ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index 92c25a4498..f53f4473e4 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -11,10 +11,6 @@ "dependencies": { "reactor-ts": "file:./reactor-ts", "@types/reactor-ts": "file:./reactor-ts", - "command-line-usage": "^6.1.0", - "command-line-args": "^5.1.1" - }, - "devDependencies": { "@babel/cli": "^7.8.4", "@babel/core": "^7.8.7", "@babel/node": "^7.8.7", @@ -24,13 +20,17 @@ "@babel/plugin-transform-modules-commonjs": "^7.8.3", "@babel/preset-env": "^7.8.7", "@babel/preset-typescript": "^7.8.3", + "command-line-usage": "^6.1.0", + "command-line-args": "^5.1.1", + "rimraf": "^3.0.2" + }, + "devDependencies": { "@types/google-protobuf": "^3.7.4", "@types/node": "^13.9.2", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "eslint": "^8.5.0", - "rimraf": "^3.0.2", "typescript": "^3.8.3", "ts-protoc-gen": "^0.12.0" }, diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 3e2972d599..441ae635da 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 3e2972d599607f080b15790c54c9a153f785f0f8 +Subproject commit 441ae635da6a0a111e2367c0c916639301678c22 From 2022f294bd35e72116feed1dd0313ca0252274fe Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Tue, 23 Aug 2022 22:04:22 -0700 Subject: [PATCH 08/24] Handle ulog type declaration more portably. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 441ae635da..f3a05223a6 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 441ae635da6a0a111e2367c0c916639301678c22 +Subproject commit f3a05223a6a5a5c4615dc74e1f3add068231f81b From 0925573a8d0063024c011b31e98924a59c4f5860 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Tue, 23 Aug 2022 22:24:41 -0700 Subject: [PATCH 09/24] Fix version due to bad typescript-eslint release. https://github.com/typescript-eslint/typescript-eslint/issues/5525 --- org.lflang/src/lib/ts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index f53f4473e4..5b02ca52a1 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -28,7 +28,7 @@ "@types/google-protobuf": "^3.7.4", "@types/node": "^13.9.2", "@types/uuid": "^8.3.4", - "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/eslint-plugin": "5.33.0", "@typescript-eslint/parser": "^5.8.1", "eslint": "^8.5.0", "typescript": "^3.8.3", From 03c239b2ca84f813461adacab264f56304fedbe4 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Tue, 23 Aug 2022 23:36:26 -0700 Subject: [PATCH 10/24] Fix broken references to declaration files. --- .gitignore | 1 + org.lflang/src/lib/ts/reactor-ts | 2 +- org.lflang/src/lib/ts/tsconfig.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f73759d797..e4699ebfab 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,7 @@ buildNumber.properties .flattened-pom.xml ### VisualStudioCode ### +.vscode .vscode/* !.vscode/settings.json !.vscode/tasks.json diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index f3a05223a6..aa81d50d36 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit f3a05223a6a5a5c4615dc74e1f3add068231f81b +Subproject commit aa81d50d36d85f8a98352d3eea7f9e0dadbb2920 diff --git a/org.lflang/src/lib/ts/tsconfig.json b/org.lflang/src/lib/ts/tsconfig.json index dcd0f1ec7d..cb3372bc0b 100644 --- a/org.lflang/src/lib/ts/tsconfig.json +++ b/org.lflang/src/lib/ts/tsconfig.json @@ -12,6 +12,7 @@ "strictBindCallApply": true, "strictNullChecks": true, "strictFunctionTypes": true, + "typeRoots": ["./node_modules/@types/", "./node_modules/reactor-ts/src/core"] }, "include": [ "src/**/*" From bf5a4a1a65134a5e733c610c1c66fd1e90f77a08 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Thu, 25 Aug 2022 18:33:35 -0700 Subject: [PATCH 11/24] Use pnpm instead of npm where possible. --- .../org/lflang/generator/ts/TSGenerator.kt | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index de9322a42d..7c21755ed0 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -148,7 +148,7 @@ class TSGenerator( clean(context) copyRuntime() - buildRuntime() + collectDependencies(resource, context, tsFileConfig.reactorTsPath()) copyConfigFiles() val codeMaps = HashMap() @@ -166,7 +166,7 @@ class TSGenerator( context.reportProgress( "Code generation complete. Collecting dependencies...", IntegratedBuilder.GENERATED_PERCENT_PROGRESS ) - if (shouldCollectDependencies(context)) collectDependencies(resource, context) + if (shouldCollectDependencies(context)) collectDependencies(resource, context, tsFileConfig.srcGenPkgPath) if (errorsOccurred()) { context.unsuccessfulFinish(); return; @@ -220,15 +220,6 @@ class TSGenerator( } } - private fun buildRuntime() { - (commandFactory.createCommand( - "npm", - listOf("install"), - tsFileConfig.reactorTsPath(), - false // only produce a warning if command is not found - )).run() - } - /** * For each configuration file that is not present in the same directory * as the source file, copy a default version from $LIB_PATH/. @@ -365,16 +356,11 @@ class TSGenerator( * which to report any errors * @param context The context of this build. */ - private fun collectDependencies(resource: Resource, context: LFGeneratorContext) { + private fun collectDependencies(resource: Resource, context: LFGeneratorContext, path: Path) { Files.createDirectories(fileConfig.srcGenPkgPath) // may throw - val pnpmInstall = commandFactory.createCommand( - "pnpm", - listOf("install"), - fileConfig.srcGenPkgPath, - false // only produce a warning if command is not found - ) + val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install"), path, false) // Attempt to use pnpm, but fall back on npm if it is not available. if (pnpmInstall != null) { @@ -389,7 +375,7 @@ class TSGenerator( errorReporter.reportWarning( "Falling back on npm. To prevent an accumulation of replicated dependencies, " + "it is highly recommended to install pnpm globally (npm install -g pnpm).") - val npmInstall = commandFactory.createCommand("npm", listOf("install"), fileConfig.srcGenPkgPath) + val npmInstall = commandFactory.createCommand("npm", listOf("install"), path) if (npmInstall == null) { errorReporter.reportError(NO_NPM_MESSAGE) From 86b14fa416da67725eccd263f9e95216175154f2 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Thu, 25 Aug 2022 18:35:58 -0700 Subject: [PATCH 12/24] Update submodule. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index aa81d50d36..b3df0490c0 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit aa81d50d36d85f8a98352d3eea7f9e0dadbb2920 +Subproject commit b3df0490c023f39e82d6e28d0d91c7abde117240 From aa7b6841d82afa96ed62ca5487ccccfe8fdf46e7 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Fri, 26 Aug 2022 20:33:34 -0700 Subject: [PATCH 13/24] Address unresolved peer dep. --- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index 7c21755ed0..f3a5bdfdcb 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -360,7 +360,7 @@ class TSGenerator( Files.createDirectories(fileConfig.srcGenPkgPath) // may throw - val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install"), path, false) + val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install", "--prod"), path, false) // Attempt to use pnpm, but fall back on npm if it is not available. if (pnpmInstall != null) { @@ -375,7 +375,7 @@ class TSGenerator( errorReporter.reportWarning( "Falling back on npm. To prevent an accumulation of replicated dependencies, " + "it is highly recommended to install pnpm globally (npm install -g pnpm).") - val npmInstall = commandFactory.createCommand("npm", listOf("install"), path) + val npmInstall = commandFactory.createCommand("npm", listOf("install", "--production"), path) if (npmInstall == null) { errorReporter.reportError(NO_NPM_MESSAGE) From a02d6166b7e159d26470be3016f5ac9712e557dd Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sat, 27 Aug 2022 12:58:58 -0700 Subject: [PATCH 14/24] Try again to resolve unresolved peer deps issue. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index b3df0490c0..e4c1e607c7 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit b3df0490c023f39e82d6e28d0d91c7abde117240 +Subproject commit e4c1e607c7fce106526fcd77801e58d64f4ba2fa From 920be23bc0fb0802b41b2c6bf9fedd2cd57a9ca5 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sat, 27 Aug 2022 13:56:11 -0700 Subject: [PATCH 15/24] Address failing serialization tests. --- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index f3a5bdfdcb..c96ce8b317 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -148,7 +148,7 @@ class TSGenerator( clean(context) copyRuntime() - collectDependencies(resource, context, tsFileConfig.reactorTsPath()) + collectDependencies(resource, context, tsFileConfig.reactorTsPath(), true) copyConfigFiles() val codeMaps = HashMap() @@ -166,7 +166,7 @@ class TSGenerator( context.reportProgress( "Code generation complete. Collecting dependencies...", IntegratedBuilder.GENERATED_PERCENT_PROGRESS ) - if (shouldCollectDependencies(context)) collectDependencies(resource, context, tsFileConfig.srcGenPkgPath) + if (shouldCollectDependencies(context)) collectDependencies(resource, context, tsFileConfig.srcGenPkgPath, false) if (errorsOccurred()) { context.unsuccessfulFinish(); return; @@ -356,11 +356,11 @@ class TSGenerator( * which to report any errors * @param context The context of this build. */ - private fun collectDependencies(resource: Resource, context: LFGeneratorContext, path: Path) { + private fun collectDependencies(resource: Resource, context: LFGeneratorContext, path: Path, production: Boolean) { Files.createDirectories(fileConfig.srcGenPkgPath) // may throw - val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install", "--prod"), path, false) + val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install", if (production) "--prod" else ""), path, false) // Attempt to use pnpm, but fall back on npm if it is not available. if (pnpmInstall != null) { @@ -375,7 +375,7 @@ class TSGenerator( errorReporter.reportWarning( "Falling back on npm. To prevent an accumulation of replicated dependencies, " + "it is highly recommended to install pnpm globally (npm install -g pnpm).") - val npmInstall = commandFactory.createCommand("npm", listOf("install", "--production"), path) + val npmInstall = commandFactory.createCommand("npm", listOf("install", if (production) "--production" else ""), path) if (npmInstall == null) { errorReporter.reportError(NO_NPM_MESSAGE) From 49c2847d8fdd9ff1c7e5965f5c6539caa97d3173 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sat, 27 Aug 2022 14:00:15 -0700 Subject: [PATCH 16/24] Update submodule. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index e4c1e607c7..1e0859978e 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit e4c1e607c7fce106526fcd77801e58d64f4ba2fa +Subproject commit 1e0859978e870e6971a3d27475ca9e41ff937196 From 6a60cb34d3ee35c3d18fe86970ecd521dd721150 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sat, 27 Aug 2022 14:19:19 -0700 Subject: [PATCH 17/24] Clean up after previous commit. --- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index c96ce8b317..f203ef79ee 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -360,7 +360,7 @@ class TSGenerator( Files.createDirectories(fileConfig.srcGenPkgPath) // may throw - val pnpmInstall = commandFactory.createCommand("pnpm", listOf("install", if (production) "--prod" else ""), path, false) + val pnpmInstall = commandFactory.createCommand("pnpm", if (production) listOf("install", "--prod") else listOf("install"), path, false) // Attempt to use pnpm, but fall back on npm if it is not available. if (pnpmInstall != null) { @@ -375,7 +375,7 @@ class TSGenerator( errorReporter.reportWarning( "Falling back on npm. To prevent an accumulation of replicated dependencies, " + "it is highly recommended to install pnpm globally (npm install -g pnpm).") - val npmInstall = commandFactory.createCommand("npm", listOf("install", if (production) "--production" else ""), path) + val npmInstall = commandFactory.createCommand("npm", if (production) listOf("install", "--production") else listOf("install"), path) if (npmInstall == null) { errorReporter.reportError(NO_NPM_MESSAGE) From 1a9419cd6849569317965d403835c42ac1914d12 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 00:52:38 -0700 Subject: [PATCH 18/24] Repair references to declaration files. --- org.lflang/src/lib/ts/reactor-ts | 2 +- org.lflang/src/lib/ts/tsconfig.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 1e0859978e..97bccd80bc 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 1e0859978e870e6971a3d27475ca9e41ff937196 +Subproject commit 97bccd80bca124ffff29418dfceedcda6f820e91 diff --git a/org.lflang/src/lib/ts/tsconfig.json b/org.lflang/src/lib/ts/tsconfig.json index cb3372bc0b..104b89a4c2 100644 --- a/org.lflang/src/lib/ts/tsconfig.json +++ b/org.lflang/src/lib/ts/tsconfig.json @@ -3,6 +3,7 @@ "allowJs": true, "noEmit": true, "target": "esnext", + "types": ["node", "reactor-ts", "ulog", "microtime", "command-line-args", "command-line-usage"], "esModuleInterop": true, "isolatedModules": true, "lib": ["esnext", "dom"], @@ -12,7 +13,7 @@ "strictBindCallApply": true, "strictNullChecks": true, "strictFunctionTypes": true, - "typeRoots": ["./node_modules/@types/", "./node_modules/reactor-ts/src/core"] + "typeRoots": ["./node_modules/@types/", "./node_modules/reactor-ts/src/core/@types/"] }, "include": [ "src/**/*" From bed094484df709a87840813a3b35e180bd0e2b42 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 02:15:11 -0700 Subject: [PATCH 19/24] Update submodule with changes from master. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 97bccd80bc..29da4124db 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 97bccd80bca124ffff29418dfceedcda6f820e91 +Subproject commit 29da4124db643b2ac651d1b90dd63c6541b56c87 From c4de4decd912b85ef868e3de31005bf1d299df01 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 09:33:49 -0700 Subject: [PATCH 20/24] Comments only. There is no need to use resolve because we are copying from class path, where paths are standardized to use / as a separator. --- org.lflang/src/org/lflang/generator/ts/TSGenerator.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt index f203ef79ee..58eb3cef79 100644 --- a/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt +++ b/org.lflang/src/org/lflang/generator/ts/TSGenerator.kt @@ -236,7 +236,7 @@ class TSGenerator( "No '" + configFile + "' exists in " + fileConfig.srcPath + ". Using default configuration." ) - FileUtil.copyFileFromClassPath("$LIB_PATH/$configFile", configFileDest) // FIXME: use resolve + FileUtil.copyFileFromClassPath("$LIB_PATH/$configFile", configFileDest) } } } @@ -355,6 +355,8 @@ class TSGenerator( * @param resource The Lingua Franca source file at * which to report any errors * @param context The context of this build. + * @param path The directory for which to get dependencies. + * @param production Whether to get production dependencies only. */ private fun collectDependencies(resource: Resource, context: LFGeneratorContext, path: Path, production: Boolean) { From 69c8c8f05e45aa58ac0c32db8b82d4f7b730149b Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 09:47:02 -0700 Subject: [PATCH 21/24] Update submodule. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 29da4124db..283b921f2a 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 29da4124db643b2ac651d1b90dd63c6541b56c87 +Subproject commit 283b921f2a371b4788da0d0d3f5f4b06c9a612e5 From c37fc18e09f81d8b4b3e15776e9f2e4760b14407 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 10:54:32 -0700 Subject: [PATCH 22/24] Update submodule; keep TS and typedoc in sync. --- org.lflang/src/lib/ts/package.json | 2 +- org.lflang/src/lib/ts/reactor-ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/lib/ts/package.json b/org.lflang/src/lib/ts/package.json index 5b02ca52a1..75897da3e7 100644 --- a/org.lflang/src/lib/ts/package.json +++ b/org.lflang/src/lib/ts/package.json @@ -31,7 +31,7 @@ "@typescript-eslint/eslint-plugin": "5.33.0", "@typescript-eslint/parser": "^5.8.1", "eslint": "^8.5.0", - "typescript": "^3.8.3", + "typescript": "~4.8.2", "ts-protoc-gen": "^0.12.0" }, "scripts": { diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 283b921f2a..25f093e43d 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 283b921f2a371b4788da0d0d3f5f4b06c9a612e5 +Subproject commit 25f093e43db9adb1b544620b20129df58b9c2e24 From fb838c64ea3399eef65a35a4ec0b13909dbcf31a Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 12:17:29 -0700 Subject: [PATCH 23/24] Update submodule. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index 25f093e43d..a322f95f81 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit 25f093e43db9adb1b544620b20129df58b9c2e24 +Subproject commit a322f95f8189cf400b1d5834e3b0b05e5e629257 From a1799aa8c1a47c5acd5ae98d243088ab2681044a Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Sun, 28 Aug 2022 16:01:19 -0700 Subject: [PATCH 24/24] Update submodule. --- org.lflang/src/lib/ts/reactor-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/ts/reactor-ts b/org.lflang/src/lib/ts/reactor-ts index a322f95f81..d8356fb0d7 160000 --- a/org.lflang/src/lib/ts/reactor-ts +++ b/org.lflang/src/lib/ts/reactor-ts @@ -1 +1 @@ -Subproject commit a322f95f8189cf400b1d5834e3b0b05e5e629257 +Subproject commit d8356fb0d78b1f546837bda6611cc19ec8dfca12