From 01424ca5c129e141493ffe73cff550a521b94ab3 Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Tue, 21 Jan 2025 21:04:11 +1300 Subject: [PATCH] demo building --- R/deploy.R | 2 ++ tests/testthat/sampler/.gitignore | 3 +-- tests/testthat/sampler/app.R | 2 ++ tests/testthat/sampler/app.ts | 2 +- tests/testthat/sampler/package.json | 4 +++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/deploy.R b/R/deploy.R index 7569288..b270512 100644 --- a/R/deploy.R +++ b/R/deploy.R @@ -26,6 +26,8 @@ ts_deploy <- function(f, paste(sapply(init, \(z) sprintf("%s = %s", z, z)), collapse = ",\n ") ) + x <- x[!grepl("library\\(ts\\)", x)] # Remove library(ts) from the app + src <- c( "library(Rserve)", "library(ts)", diff --git a/tests/testthat/sampler/.gitignore b/tests/testthat/sampler/.gitignore index 050e5f1..f0e445f 100644 --- a/tests/testthat/sampler/.gitignore +++ b/tests/testthat/sampler/.gitignore @@ -1,3 +1,2 @@ node_modules -*.rserve.R -*.schema.ts +app.rserve.* diff --git a/tests/testthat/sampler/app.R b/tests/testthat/sampler/app.R index 855ee6b..ebac7d5 100644 --- a/tests/testthat/sampler/app.R +++ b/tests/testthat/sampler/app.R @@ -1,3 +1,5 @@ +library(ts) + fn_mean <- ts_function(mean, x = ts_numeric(), result = ts_numeric(1)) fn_first <- ts_function(function(x = ts_character()) x[1], result = ts_character(1) diff --git a/tests/testthat/sampler/app.ts b/tests/testthat/sampler/app.ts index 42280ab..12a2864 100644 --- a/tests/testthat/sampler/app.ts +++ b/tests/testthat/sampler/app.ts @@ -10,7 +10,7 @@ interface global { global.WebSocket = WebSocket as any; -import appFuns from "./app.schema"; +import appFuns from "./app.rserve"; async function main() { const con = await RserveClient.create({ diff --git a/tests/testthat/sampler/package.json b/tests/testthat/sampler/package.json index c2a0d57..677ba4a 100644 --- a/tests/testthat/sampler/package.json +++ b/tests/testthat/sampler/package.json @@ -5,7 +5,9 @@ "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "node app.js" + "build": "Rscript -e 'ts::ts_compile(\"app.R\"); ts::ts_deploy(\"app.R\")'", + "rserve": "Rscript app.rserve.R", + "start": "ts-node app.ts" }, "author": "", "license": "ISC",