From ebcc31abd0337580ffe5770453699da4fb0f455d Mon Sep 17 00:00:00 2001 From: Raven Rothkopf Date: Tue, 15 Nov 2022 12:08:39 -0500 Subject: [PATCH 1/2] add pcre to docker image --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9682535..ff3102e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,13 +24,13 @@ ENV DEBIAN_FRONTEND noninteractive # [START cloudrun_system_package_alpine] # [START run_system_package_alpine] #RUN apk --no-cache add graphviz ttf-ubuntu-font-family -RUN apt-get update -y && apt-get install -y \ +RUN apt-get update -y && apt-get install -y\ nodejs npm \ wget git \ && apt-get clean # [END run_system_package_alpine] # [END cloudrun_system_package_alpine] - +RUN apt-get install libpcre3 libpcre3-dev -y RUN wget -qO- https://get.haskellstack.org/ | sh RUN git clone https://github.com/Barnard-PL-Labs/tsltools RUN cd tsltools && make @@ -40,7 +40,6 @@ RUN echo 'deb http://www.lrde.epita.fr/repo/debian/ stable/' >> /etc/apt/sources RUN apt-get update RUN apt-get install -y spot - # Copy application dependency manifests to the container image. # A wildcard is used to ensure both package.json AND package-lock.json are copied. # Copying this separately prevents re-running npm install on every code change. From 633131e1810dd4fd6a25772d44a5e2232fcd0ebf Mon Sep 17 00:00:00 2001 From: Raven Rothkopf Date: Wed, 16 Nov 2022 11:31:48 -0500 Subject: [PATCH 2/2] call tslminrealizable --- app.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app.js b/app.js index 890f887..67fe1ca 100644 --- a/app.js +++ b/app.js @@ -47,6 +47,23 @@ app.get('/tslsynth', (req, res) => { } } }); + +app.get('/tslminrealizable', (req, res) => { + try { + const synthResult = createMinDiagram(req.query.tsl); + res.setHeader('Content-Type', 'text/plain'); + res.setHeader('Cache-Control', 'public, max-age=86400'); + res.send(synthResult); + } catch (err) { + console.error(`error: ${err.message}`); + const errDetails = (err.stderr || err.message).toString(); + if (errDetails.includes('syntax')) { + res.status(400).send(`Bad Request: ${err.message}`); + } else { + res.status(500).send('Internal Server Error'); + } + } +}); // [END run_system_package_handler] // [END cloudrun_system_package_handler] @@ -70,10 +87,32 @@ const createDiagram = (tsl, target) => { cwd: "./tsltools", input: tsl, }); + + console.log("synthResult"); + console.log(String(synthResult)); + + return synthResult; +}; + +const createMinDiagram = (tsl) => { + if (!tsl) { + throw new Error('syntax: no tsl spec provided'); + } + try { + fs.writeFileSync('tsltools/tmp.tsl', tsl) + } catch (err) { + console.error(err) + } + + const synthResult = execSync(`./tslminrealizable tmp.tsl -r /usr/src/app/tsltools/tlsfSynth_stdin.sh`, { + cwd: "./tsltools", + input: tsl, + }); console.log("synthResult"); console.log(String(synthResult)); return synthResult; }; + // [END run_system_package_exec] // [END cloudrun_system_package_exec]