@fnet/cli 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/readme.md +33 -82
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e,t,s=require("@flownet/lib-load-fnet-config"),i=require("redis"),r=require("@flownet/lib-is-redis-online"),n=require("express"),o=require("helmet"),l=require("cors"),d=require("path"),c=require("shelljs"),a=require("nanoid"),u=require("request-ip"),h=require("express-session"),w=require("keycloak-connect"),p=require("qs");function _(){if(t)return e;t=1;const s=i,n=r;return e=async()=>{if(!await n({host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}))return;const e=s.createClient({socket:{host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}});return await e.connect(),e}}var b,f,m,y,k={name:"@fnet/cli",version:"0.13.1",files:["dist"],scripts:{start:"node src/index.js",build:"rollup --config --bundleConfigAsCjs",deploy:"npm install && npm run build && npm publish --access public",watch:"rollup --config --watch --sourcemap --bundleConfigAsCjs --environment DEVELOPMENT"},dependencies:{"@flownet/lib-atom-api-js":"^0.1.8","@flownet/lib-bpmn-from-flow":"^0.1.7","@flownet/lib-is-redis-online":"^0.1.13","@flownet/lib-list-npm-versions":"^0.1.31","@flownet/lib-load-fnet-config":"^0.2.1","@flownet/lib-parse-imports-js":"^0.1.35","@flownet/lib-parse-node-url":"^0.1.16","@flownet/lib-pick-npm-versions":"^0.1.12","@flownet/lib-render-templates-dir":"^0.1.12","@flownet/lib-to-electron":"^0.2.1","@flownet/lib-to-gitlab":"^0.1.21","@flownet/lib-to-ios-app":"^0.2.5","@flownet/lib-to-macos-app":"^0.2.3","@flownet/lib-to-nextjs":"^0.1.12","@flownet/lib-to-webos":"^0.2.8","@flownet/lib-upload-files-to-gcs":"^0.1.12","@flownet/template-node-common":"^0.12.0","@flownet/template-node-library":"^0.12.0","@flownet/template-node-workflow":"^0.12.0","@fnet/expression":"^0.1.5","@fnet/shell":"^0.1.9","@node-red/util":"^3.1.0",axios:"^1.5.0",chalk:"^4.1.2",cors:"^2.8.5",express:"^4.18.2","express-session":"^1.17.3","get-value":"^3.0.1",helmet:"^5.1.1",isobject:"^4.0.0","js-yaml":"^4.1.0","keycloak-connect":"^22.0.3","lodash.clonedeep":"^4.5.0","lodash.merge":"^4.6.2",minimist:"^1.2.8",nanoid:"^3.3.6",nunjucks:"^3.2.4",prettier:"^3.0.3",qs:"^6.11.2",redis:"^4.6.10","request-ip":"^3.3.0",semver:"^7.5.4",serve:"^14.2.1","set-value":"^4.1.0",shelljs:"^0.8.5",typescript:"^5.2.2",uuid:"^9.0.1",yaml:"^2.3.2",yargs:"^17.7.2"},bin:{fnet:"dist/builder/wf-cli.js",flib:"dist/builder/lib-cli.js",fsrv:"dist/index.js",fnode:"dist/builder/lib-cli.js"},devDependencies:{"@rollup/plugin-commonjs":"^25.0.4","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.1","@rollup/plugin-replace":"^5.0.2","@rollup/plugin-terser":"^0.4.3",rollup:"^3.29.1"}};const v=process.cwd();s({name:["server","redis"],dir:v,optional:!0}),async function(){const e=await _()();if(!e)throw new Error("Redis is offline.");const t=k,s=n,i=o,r=l,g=function(){if(f)return b;f=1;const e=n,t=d,s=c,{nanoid:i}=a;return b=class{#e;constructor(e){this._keycloak=e.keycloak,this._router=this._initRouter(),this._redis_client=e.redisClient,this._expire_ttl=3600,this._expire_ttl_short=300,this.#e=e.wdir}_initRouter(){let t=e.Router();return t.post("/workflow/builder/create",this._buildHandler.bind(this)),t.post("/workflow/builder/status",this._statusHandler.bind(this)),t.post("/workflow/builder/network",this._networkHandler.bind(this)),t}join(e,t){t.use(e,this._router)}async _cache_set(e,t,s){await this._redis_client.SETEX(e,s||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async _cache_get(e){const t=await this._redis_client.GET(e).catch(console.error);return JSON.parse(t)}_buildHandler(e,t){this._build({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_networkHandler(e,t){this._network({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_statusHandler(e,t){try{const s=e.body.id;if(!s)throw new Error("Build Id is not defined.");const i="BUILD:"+s;this._cache_get(i).then((e=>{t.send(e)})).catch((e=>{t.status(500).send()}))}catch(e){t.status(500).send()}}async _build(e){const r=e.id;if(!r)throw new Error("Workflow Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/wf-cli.js")} build --id=${r} --buildId=${n} --mode=all`;return s.exec(o,{async:!0,cwd:this.#e}),{id:n}}async _network(e){const r=e.id;if(!r)throw new Error("Workflow Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/wf-cli.js")} build --id=${r} --buildId=${n} --mode=bpmn`;s.exec(o,{cwd:this.#e});const l="BUILD:"+n;return await this._cache_get(l)}}}(),j=function(){if(y)return m;y=1;const e=n,t=d,s=c,{nanoid:i}=a;return m=class{#e;constructor(e){this._keycloak=e.keycloak,this._router=this._initRouter(),this._redis_client=e.redisClient,this._expire_ttl=3600,this._expire_ttl_short=300,this.#e=e.wdir}_initRouter(){let t=e.Router();return t.post("/library/builder/create",this._buildHandler.bind(this)),t.post("/library/builder/status",this._statusHandler.bind(this)),t}join(e,t){t.use(e,this._router)}async _cache_set(e,t,s){await this._redis_client.SETEX(e,s||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async _cache_get(e){const t=await this._redis_client.GET(e).catch(console.error);return JSON.parse(t)}_buildHandler(e,t){this._build({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_statusHandler(e,t){try{const s=e.body.id;if(!s)throw new Error("Build Id is not defined.");const i="BUILD:"+s;this._cache_get(i).then((e=>{t.send(e)})).catch((e=>{t.status(500).send()}))}catch(e){t.status(500).send()}}async _build(e){const r=e.id;if(!r)throw new Error("Library Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/lib-cli.js")} build --id=${r} --buildId=${n} --mode=all}`;return s.exec(o,{async:!0,cwd:this.#e}),{id:n}}}}(),E=u,x=h,q=new(0,x.MemoryStore),S=new w({store:q}),I=s(),R=p;I.set("query parser",(function(e){return R.parse(e,{depth:12})})),I.use(x({secret:process.env.SESSION_SECRET,resave:!1,saveUninitialized:!0,store:q})),I.use(r()),I.use(i()),I.use(s.json({limit:"1024kb"})),I.get("/healthz",(function(e,t){t.sendStatus(200)})),I.use(E.mw()),I.use(S.middleware()),new g({keycloak:S,wdir:v,redisClient:e}).join("/v1",I),new j({keycloak:S,wdir:v,redisClient:e}).join("/v1",I),I.listen(process.env.HTTP_PORT||8080),console.log(`[${t.version}] ${t.name} started.`)}().catch((e=>{console.error(e.message),process.exit(1)})),module.exports={};
2
+ "use strict";var e,t,s=require("@flownet/lib-load-fnet-config"),i=require("redis"),r=require("@flownet/lib-is-redis-online"),n=require("express"),o=require("helmet"),l=require("cors"),d=require("path"),c=require("shelljs"),a=require("nanoid"),u=require("request-ip"),h=require("express-session"),w=require("keycloak-connect"),p=require("qs");function _(){if(t)return e;t=1;const s=i,n=r;return e=async()=>{if(!await n({host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}))return;const e=s.createClient({socket:{host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}});return await e.connect(),e}}var b,f,m,y,k={name:"@fnet/cli",version:"0.13.2",files:["dist"],scripts:{start:"node src/index.js",build:"rollup --config --bundleConfigAsCjs",deploy:"npm install && npm run build && npm publish --access public",watch:"rollup --config --watch --sourcemap --bundleConfigAsCjs --environment DEVELOPMENT"},dependencies:{"@flownet/lib-atom-api-js":"^0.1.8","@flownet/lib-bpmn-from-flow":"^0.1.7","@flownet/lib-is-redis-online":"^0.1.13","@flownet/lib-list-npm-versions":"^0.1.31","@flownet/lib-load-fnet-config":"^0.2.1","@flownet/lib-parse-imports-js":"^0.1.35","@flownet/lib-parse-node-url":"^0.1.16","@flownet/lib-pick-npm-versions":"^0.1.12","@flownet/lib-render-templates-dir":"^0.1.12","@flownet/lib-to-electron":"^0.2.1","@flownet/lib-to-gitlab":"^0.1.21","@flownet/lib-to-ios-app":"^0.2.5","@flownet/lib-to-macos-app":"^0.2.3","@flownet/lib-to-nextjs":"^0.1.12","@flownet/lib-to-webos":"^0.2.8","@flownet/lib-upload-files-to-gcs":"^0.1.12","@flownet/template-node-common":"^0.12.0","@flownet/template-node-library":"^0.12.0","@flownet/template-node-workflow":"^0.12.0","@fnet/expression":"^0.1.5","@fnet/shell":"^0.1.9","@node-red/util":"^3.1.0",axios:"^1.5.0",chalk:"^4.1.2",cors:"^2.8.5",express:"^4.18.2","express-session":"^1.17.3","get-value":"^3.0.1",helmet:"^5.1.1",isobject:"^4.0.0","js-yaml":"^4.1.0","keycloak-connect":"^22.0.3","lodash.clonedeep":"^4.5.0","lodash.merge":"^4.6.2",minimist:"^1.2.8",nanoid:"^3.3.6",nunjucks:"^3.2.4",prettier:"^3.0.3",qs:"^6.11.2",redis:"^4.6.10","request-ip":"^3.3.0",semver:"^7.5.4",serve:"^14.2.1","set-value":"^4.1.0",shelljs:"^0.8.5",typescript:"^5.2.2",uuid:"^9.0.1",yaml:"^2.3.2",yargs:"^17.7.2"},bin:{fnet:"dist/builder/wf-cli.js",flib:"dist/builder/lib-cli.js",fsrv:"dist/index.js",fnode:"dist/builder/lib-cli.js"},devDependencies:{"@rollup/plugin-commonjs":"^25.0.4","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.1","@rollup/plugin-replace":"^5.0.2","@rollup/plugin-terser":"^0.4.3",rollup:"^3.29.1"}};const v=process.cwd();s({name:["server","redis"],dir:v,optional:!0}),async function(){const e=await _()();if(!e)throw new Error("Redis is offline.");const t=k,s=n,i=o,r=l,g=function(){if(f)return b;f=1;const e=n,t=d,s=c,{nanoid:i}=a;return b=class{#e;constructor(e){this._keycloak=e.keycloak,this._router=this._initRouter(),this._redis_client=e.redisClient,this._expire_ttl=3600,this._expire_ttl_short=300,this.#e=e.wdir}_initRouter(){let t=e.Router();return t.post("/workflow/builder/create",this._buildHandler.bind(this)),t.post("/workflow/builder/status",this._statusHandler.bind(this)),t.post("/workflow/builder/network",this._networkHandler.bind(this)),t}join(e,t){t.use(e,this._router)}async _cache_set(e,t,s){await this._redis_client.SETEX(e,s||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async _cache_get(e){const t=await this._redis_client.GET(e).catch(console.error);return JSON.parse(t)}_buildHandler(e,t){this._build({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_networkHandler(e,t){this._network({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_statusHandler(e,t){try{const s=e.body.id;if(!s)throw new Error("Build Id is not defined.");const i="BUILD:"+s;this._cache_get(i).then((e=>{t.send(e)})).catch((e=>{t.status(500).send()}))}catch(e){t.status(500).send()}}async _build(e){const r=e.id;if(!r)throw new Error("Workflow Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/wf-cli.js")} build --id=${r} --buildId=${n} --mode=all`;return s.exec(o,{async:!0,cwd:this.#e}),{id:n}}async _network(e){const r=e.id;if(!r)throw new Error("Workflow Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/wf-cli.js")} build --id=${r} --buildId=${n} --mode=bpmn`;s.exec(o,{cwd:this.#e});const l="BUILD:"+n;return await this._cache_get(l)}}}(),j=function(){if(y)return m;y=1;const e=n,t=d,s=c,{nanoid:i}=a;return m=class{#e;constructor(e){this._keycloak=e.keycloak,this._router=this._initRouter(),this._redis_client=e.redisClient,this._expire_ttl=3600,this._expire_ttl_short=300,this.#e=e.wdir}_initRouter(){let t=e.Router();return t.post("/library/builder/create",this._buildHandler.bind(this)),t.post("/library/builder/status",this._statusHandler.bind(this)),t}join(e,t){t.use(e,this._router)}async _cache_set(e,t,s){await this._redis_client.SETEX(e,s||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async _cache_get(e){const t=await this._redis_client.GET(e).catch(console.error);return JSON.parse(t)}_buildHandler(e,t){this._build({...e.body}).then((e=>{t.status(200).send(e)})).catch((e=>{t.status(500).send()}))}_statusHandler(e,t){try{const s=e.body.id;if(!s)throw new Error("Build Id is not defined.");const i="BUILD:"+s;this._cache_get(i).then((e=>{t.send(e)})).catch((e=>{t.status(500).send()}))}catch(e){t.status(500).send()}}async _build(e){const r=e.id;if(!r)throw new Error("Library Id is not defined.");const n=i(24),o=`node ${t.resolve(__dirname,"builder/lib-cli.js")} build --id=${r} --buildId=${n} --mode=all}`;return s.exec(o,{async:!0,cwd:this.#e}),{id:n}}}}(),E=u,x=h,q=new(0,x.MemoryStore),S=new w({store:q}),I=s(),R=p;I.set("query parser",(function(e){return R.parse(e,{depth:12})})),I.use(x({secret:process.env.SESSION_SECRET,resave:!1,saveUninitialized:!0,store:q})),I.use(r()),I.use(i()),I.use(s.json({limit:"1024kb"})),I.get("/healthz",(function(e,t){t.sendStatus(200)})),I.use(E.mw()),I.use(S.middleware()),new g({keycloak:S,wdir:v,redisClient:e}).join("/v1",I),new j({keycloak:S,wdir:v,redisClient:e}).join("/v1",I),I.listen(process.env.HTTP_PORT||8080),console.log(`[${t.version}] ${t.name} started.`)}().catch((e=>{console.error(e.message),process.exit(1)})),module.exports={};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnet/cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
package/readme.md CHANGED
@@ -1,130 +1,82 @@
1
- # Flow Node Project Setup Guide
1
+ # @fnet/cli: Flow Node & Flow Project Setup Guide
2
+
3
+ ## Overview
4
+
5
+ The `@fnet/cli` is a command-line interface tool designed to facilitate the development and deployment of flow-based projects within the Flownet.ai ecosystem. It simplifies the processes of creating, managing, and deploying flow-based projects, acting as a bridge between developers and the Flownet.ai platform.
2
6
 
3
7
  ## Prerequisites
4
8
 
5
- 1. Ensure you have `@fnet/cli` installed globally. If not, install it using:
9
+ Ensure you have `@fnet/cli` installed globally:
6
10
  ```bash
7
11
  npm i @fnet/cli -g
8
12
  ```
9
13
 
10
- 2. Once installed, two binary commands will be available: `fnet` and `fnode`. Use `fnode` for flow node projects.
14
+ Upon installation, two binary commands become available: `fnet` (for flow projects) and `fnode` (for flow node projects).
11
15
 
12
16
  ## Identifying Project Type
13
17
 
14
- - If there's a `node.yaml` in the project directory, it's a flow node project.
15
- - Use `fnode` commands for operations related to flow node projects.
18
+ - Flow Node Project: Presence of `node.yaml`. Use `fnode` commands.
19
+ - Flow Project: Presence of `flow.yaml`. Use `fnet` commands.
16
20
 
17
21
  ## Building the Project
18
22
 
19
- To compile the project, use:
23
+ For Flow Node:
20
24
  ```bash
21
25
  fnode build
22
26
  ```
23
- This will generate a `.workspace` directory containing all necessary files and configurations for debugging, building, and deploying the project.
24
-
25
- ## Watching the Project
26
-
27
- To run the project in development mode, use:
28
- ```bash
29
- fnode watch
30
- ```
31
-
32
- ## Deploying the Project
33
-
34
- Before deploying, ensure the `node.devops.yaml` file has the correct configurations for deployment.
35
-
36
- ### Configuration for NPM Deploy in devops.yaml
37
-
38
- For deploying to npm, ensure your `node.devops.yaml` file has the following structure:
39
-
40
- ```yaml
41
- targets:
42
- - name: npm
43
- enabled: true
44
- params:
45
- name: "NPM PACKAGE NAME IN NPM REPO"
46
- version: "NPM VERSION"
47
- ```
48
-
49
- Replace `"NPM PACKAGE NAME IN NPM REPO"` with the desired npm package name and `"NPM VERSION"` with the desired version.
50
-
51
- To deploy the project as per the configurations, use:
52
- ```bash
53
- fnode deploy
54
- ```
55
-
56
- ### Configuration for NPM Deploy
57
-
58
- For deploying to npm, the tool will look for a `npm.fnet` file under the first `.fnet` directory it finds (in the project root or any parent directory, with a fallback to the user's home directory). The `npm.fnet` file should have the following format:
59
-
60
- ```yaml
61
- version: 1
62
- type: fnet.config
63
- env:
64
- NPM_TOKEN: "YOUR_NPM_TOKEN"
65
- ```
66
27
 
67
- Replace `YOUR_NPM_TOKEN` with your actual npm token for authentication during deployment.
68
-
69
-
70
- # Flow Project Setup Guide
71
-
72
- ## Prerequisites
73
-
74
- 1. Ensure you have `@fnet/cli` installed globally. If not, install it using:
28
+ For Flow:
75
29
  ```bash
76
- npm i @fnet/cli -g
30
+ fnet build
77
31
  ```
78
32
 
79
- 2. Once installed, two binary commands will be available: `fnet` and `fnode`. Use `fnet` for flow projects.
80
-
81
- ## Identifying Project Type
33
+ Both commands generate a `.workspace` directory with files and configurations for debugging, building, and deploying.
82
34
 
83
- - If there's a `flow.yaml` in the project directory, it's a flow project.
84
- - Use `fnet` commands for operations related to flow projects.
35
+ ## Watching the Project (Development Mode)
85
36
 
86
- ## Building the Project
87
-
88
- To compile the project, use:
37
+ For Flow Node:
89
38
  ```bash
90
- fnet build
39
+ fnode watch
91
40
  ```
92
- This will generate a `.workspace` directory containing all necessary files and configurations for debugging, building, and deploying the project.
93
41
 
94
- ## Watching the Project
95
-
96
- To run the project in development mode, use:
42
+ For Flow:
97
43
  ```bash
98
44
  fnet watch
99
45
  ```
100
46
 
101
47
  ## Deploying the Project
102
48
 
103
- Before deploying, ensure the `flow.devops.yaml` file has the correct configurations for deployment.
49
+ Ensure respective `node.devops.yaml` (for Flow Node) or `flow.devops.yaml` (for Flow) has the correct deployment configurations.
104
50
 
105
- ### Configuration for NPM Deploy in flow.devops.yaml
51
+ ### Configuration for NPM Deployment
106
52
 
107
- For deploying to npm, ensure your `flow.devops.yaml` file has the following structure:
53
+ **Structure for devops.yaml:**
108
54
 
109
55
  ```yaml
110
56
  targets:
111
57
  - name: npm
112
58
  enabled: true
113
59
  params:
114
- name: "NPM PACKAGE NAME IN NPM REPO"
115
- version: "NPM VERSION"
60
+ name: "NPM_PACKAGE_NAME"
61
+ version: "NPM_VERSION"
116
62
  ```
63
+ Replace placeholders with desired npm package name and version.
64
+
65
+ For deployment:
117
66
 
118
- Replace `"NPM PACKAGE NAME IN NPM REPO"` with the desired npm package name and `"NPM VERSION"` with the desired version.
67
+ For Flow Node:
68
+ ```bash
69
+ fnode deploy
70
+ ```
119
71
 
120
- To deploy the project as per the configurations, use:
72
+ For Flow:
121
73
  ```bash
122
74
  fnet deploy
123
75
  ```
124
76
 
125
- ### Configuration for NPM Deploy
77
+ **NPM Configuration File:**
126
78
 
127
- For deploying to npm, the tool will look for a `npm.fnet` file under the first `.fnet` directory it finds (in the project root or any parent directory, with a fallback to the user's home directory). The `npm.fnet` file should have the following format:
79
+ The CLI checks for `npm.fnet` under the first `.fnet` directory (in the project root, parent directory, or user's home). The file format:
128
80
 
129
81
  ```yaml
130
82
  version: 1
@@ -132,5 +84,4 @@ type: fnet.config
132
84
  env:
133
85
  NPM_TOKEN: "YOUR_NPM_TOKEN"
134
86
  ```
135
-
136
- Replace `YOUR_NPM_TOKEN` with your actual npm token for authentication during deployment.
87
+ Replace `YOUR_NPM_TOKEN` with your npm token for deployment authentication.