Comments (6)
Hi @chenxinfeng4 it's probably easiest to use the command line interface for that. It runs on node.js and can be installed with node.js's default package manager.
I have no experience with calling node programs from python or c++, but I guess the thing that enables calling executables from an os
or system
package should do the trick.
state-machine-cat.js.org doesn't run an API - it's only a 'static' website...
from state-machine-cat.
Is it possible to deploy all the dependence into one folder? I can just access the smcat.exe
to get all the functions. I don't want consumer to manully install the nodejs or npm. It's easy to deploy python program or java program, I have no idea how to deploy nodejs.
from state-machine-cat.
Hi @chenxinfeng4 I've heard of solutions that bundle node applications, including the node.js run time & libs into single executables, but I have no experience with them.
from state-machine-cat.
Sad, something went wrong when I packaged the cmcat.
$ npm install --global pkg
$ pkg -t node18 bin\smcat.mjs -d
[email protected]
[debug] Bytecode of C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin\smcat.mjs is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin\smcat.mjs is added to queue.
Warning Babel parse has failed: 'await' is only allowed within async functions and at the top levels of modules. (5:0)
[debug] Directory C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin is added to queue.
[debug] Directory C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat is added to queue.
[debug] Directory C:\Users\666\AppData\Roaming\npm\node_modules is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming\npm\node_modules is added to queue.
[debug] Directory C:\Users\666\AppData\Roaming\npm is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming\npm is added to queue.
[debug] Directory C:\Users\666\AppData\Roaming is added to queue.
[debug] Stat info of C:\Users\666\AppData\Roaming is added to queue.
[debug] Directory C:\Users\666\AppData is added to queue.
[debug] Stat info of C:\Users\666\AppData is added to queue.
[debug] Directory C:\Users\666 is added to queue.
[debug] Stat info of C:\Users\666 is added to queue.
[debug] Directory C:\Users is added to queue.
[debug] Stat info of C:\Users is added to queue.
[debug] Directory C:\ is added to queue.
[debug] Stat info of C:\ is added to queue.
[debug] Deleting record file : C:
[debug] Deleting record file : C:\Users
[debug] Deleting record file : C:\Users\666
[debug] Deleting record file : C:\Users\666\AppData
[debug] Deleting record file : C:\Users\666\AppData\Roaming
[debug] Deleting record file : C:\Users\666\AppData\Roaming\npm
[debug] Deleting record file : C:\Users\666\AppData\Roaming\npm\node_modules
[debug] The file was included as bytecode (no sources)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin\smcat.mjs
[debug] The file was included as bytecode (no sources)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin\smcat.mjs
[debug] files & folders deduped =
smcat.mjs
[debug] The directory files list was included (1 item)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin
[debug] The directory files list was included (1 item)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\bin
[debug] files & folders deduped =
bin
[debug] The directory files list was included (1 item)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat
[debug] The directory files list was included (1 item)
C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat
[debug] Targets:
[
{
"nodeRange": "node18",
"platform": "win",
"arch": "x64",
"output": "C:\Users\666\AppData\Roaming\npm\node_modules\state-machine-cat\smcat.exe",
"forceBuild": false,
"fabricator": {
"nodeRange": "node18",
"platform": "win",
"arch": "x64",
"binaryPath": "C:\Users\666\.pkg-cache\v3.4\fetched-v18.5.0-win-x64"
},
"binaryPath": "C:\Users\666\.pkg-cache\v3.4\fetched-v18.5.0-win-x64"
}
]
C:\snapshot\node_modules\state-machine-cat\bin\smcat.mjs:3
import executeCommandLine from "../dist/cli/execute-command-line.mjs";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at new Script (node:vm:102:7)
at Socket. ([eval]:18:19)
at Socket.emit (node:events:537:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
Node.js v18.5.0
from state-machine-cat.
Hi @chenxinfeng4 it seems that pkg
doesn't support modern javascript. As state-machine-cat uses modern javascript, that probably means pkg is not suitable to package it.
I've searched a bit for alternatives for single executable applications on nodejs, but it turns out none of the ones I found will work.
- nexe is one, but that hasn't seen maintenance in a while.
- node.js has experimental support to generate single executable applications out of the box as well, however it's limited to old-fashioned javascript only at the moment (from https://nodejs.org/api/single-executable-applications.html: The single executable application feature currently only supports running a single embedded script using the CommonJS module system.)
Alternatively, if you want to run a modern node module from a single folder this should work:
- install the module (e.g.
npm i state-machine-cat
) in that folder - copy the node executable to that folder (which, on windows, you apparently do like this:
node -e "require('fs').copyFileSync(process.execPath, 'my-node.exe')"
- source: node.js documentation )
All you need to run state-machine-cat should now be in that folder. To run it, in that folder:
my-node.exe node_modules/state-machine-cat/bin/smcat.mjs
Note
I have tried this on my own machine only, which is not a windows machine
hope this helps.
from state-machine-cat.
That seems a great solution, thanks for your kind help.
from state-machine-cat.
Related Issues (20)
- Weighted Edges HOT 4
- TypeError with v9.0.0 HOT 10
- Grammar railroad diagram HOT 4
- Add support for doActivities in SCXML model representation HOT 9
- sm cat syntax does not allow to define multiple initital pseudo-states
- Multiple internal transitions are not rendered nicely HOT 3
- Vim syntax support HOT 3
- Having issue reusing smcat online interpreter
- Add an ESM distribution in addition to CommonJS HOT 3
- Export to png and pdf option HOT 5
- Advantages over PlantUML? HOT 1
- bump fast-xml-parser to >=4.1.2
- [Feature request] Package to anaconda HOT 5
- No "exports" main defined HOT 1
- Example in the documentation for a composite state with history, entry and exit actions and a set of substates HOT 3
- Error while using state-machine-cat in NUXT application HOT 1
- sweep(slow): replace the chai assertion library with node:assert statements HOT 3
- Initial state HOT 2
- Is there a way to get a transition note to render inside its parent component? See attached screenshot HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from state-machine-cat.