Giter VIP home page Giter VIP logo

godspeed-cli's Introduction

Godspeed CLI

The official Command Line Interface of Godspeed Framework


contributions welcome Discord Website


Godspeed CLI

CLI to create and manage Godspeed projects.

About

Godspeed CLI is the primary way to interact with your Godspeed project from the command line. It provides a bunch of useful functionalities during the project development lifecycle.

How to install

npm install -g @godspeedsystems/godspeed

or

yarn global add @godspeedsystems/godspeed

Once installed, you will have access to Godspeed in your command prompt

Supported Commands & Arguments

Command Options Description
create --from-template, --from-example create a new godspeed project.
dev start the dev server.
clean clean the previous build.
build build the godspeed project.
devops-plugins manage devops plugins for godspeed.
plugins manage eventsource and datasource plugins for godspeed.
gen-crud-api scans your prisma datasources and generate CRUD APIs events and workflows
gen-graphql-schema scans your graphql events and generate graphql schema .

๐Ÿ“– Documentation

You can find the complete documentation of Godspeed here.

Show Your Love โค๏ธ & Support ๐Ÿ™

If you find the Godspeed Node.js Service helpful or interesting, we would greatly appreciate your support by following, starring, and subscribing.

Follow us for updates and news.
Star our repositories to show your support.
Subscribe to our channel for tutorials and demos.

Ask & Answer Questions

Got questions or need help with Godspeed? Join our Discord community. You can ask questions, share knowledge, and assist others.

godspeed-cli's People

Contributors

ashutoshmindgrep avatar avtar-mindgrep avatar avtarops avatar gurjotkaur20 avatar kushal-godspeed avatar mastersilv3r avatar srihari-godspeed avatar sundar-godspeed avatar yaswanth-godspeed avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

godspeed-cli's Issues

OTEL enmable not working

The Problem

The command godspeed otel enable is not working.

On running the command the output came:
image

On running godspeed serve got this error.

{"Body":"OTEL_ENABLED is set, unable to initialize opentelemetry tracing.","Timestamp":"2024-03-15T15:30:28.146Z000000","SeverityNumber":17,"SeverityText":"ERROR","Resource":{"service.name":"unknown_service:node","env":"production"},"Attributes":{}}
{"Body":"Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/dist/index.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/datasources/types/axios.js\n- /home/ayushghai/godspeed/gs-node-service/dist/core/datasourceLoader.js\n- /home/ayushghai/godspeed/gs-node-service/dist/godspeed.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/index.js","Timestamp":"2024-03-15T15:30:28.148Z000000","SeverityNumber":17,"SeverityText":"ERROR","Resource":{"service.name":"unknown_service:node","env":"production"},"Attributes":{"err":{"type":"Error","message":"Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/dist/index.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/datasources/types/axios.js\n- /home/ayushghai/godspeed/gs-node-service/dist/core/datasourceLoader.js\n- /home/ayushghai/godspeed/gs-node-service/dist/godspeed.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/index.js","stack":"Error: Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/dist/index.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/datasources/types/axios.js\n- /home/ayushghai/godspeed/gs-node-service/dist/core/datasourceLoader.js\n- /home/ayushghai/godspeed/gs-node-service/dist/godspeed.js\n- /home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/index.js\n    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)\n    at Module._load (node:internal/modules/cjs/loader:984:27)\n    at Module.require (node:internal/modules/cjs/loader:1234:19)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:167:34)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:167:34)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:167:34)\n    at require (node:internal/modules/helpers:176:18)\n    at Object.<anonymous> (/home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/node_modules/@godspeedsystems/core/dist/godspeed.js:184:9)\n    at Module._compile (node:internal/modules/cjs/loader:1375:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)\n    at Module.load (node:internal/modules/cjs/loader:1206:32)\n    at Module._load (node:internal/modules/cjs/loader:1022:12)\n    at Module.require (node:internal/modules/cjs/loader:1234:19)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at require (node:internal/modules/helpers:176:18)\n    at Object.<anonymous> (/home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/dist/index.js:27:16)\n    at Module._compile (node:internal/modules/cjs/loader:1375:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)\n    at Module.load (node:internal/modules/cjs/loader:1206:32)\n    at Module._load (node:internal/modules/cjs/loader:1022:12)\n    at Module.require (node:internal/modules/cjs/loader:1234:19)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at require (node:internal/modules/helpers:176:18)\n    at Object.<anonymous> (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/datasources/types/axios.js:11:35)\n    at Module._compile (node:internal/modules/cjs/loader:1375:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)\n    at Module.load (node:internal/modules/cjs/loader:1206:32)\n    at Module._load (node:internal/modules/cjs/loader:1022:12)\n    at Module.require (node:internal/modules/cjs/loader:1234:19)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at Hook._require.Module.require (/home/ayushghai/godspeed/projects/gs-node-templates/LOS/node_modules/require-in-the-middle/index.js:188:39)\n    at require (node:internal/modules/helpers:176:18)\n    at /home/ayushghai/godspeed/gs-node-service/dist/core/datasourceLoader.js:218:149\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","code":"MODULE_NOT_FOUND","requireStack":["/home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/node_modules/@godspeedsystems/core/dist/godspeed.js","/home/ayushghai/godspeed/gs-plugins/plugins/axios-as-datasource/dist/index.js","/home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/datasources/types/axios.js","/home/ayushghai/godspeed/gs-node-service/dist/core/datasourceLoader.js","/home/ayushghai/godspeed/gs-node-service/dist/godspeed.js","/home/ayushghai/godspeed/projects/gs-node-templates/LOS/dist/index.js"]}}}
[nodemon] app crashed - waiting for file changes before starting...

SOLUTION

  • When OTEL is enabled the developer should be told what plugin has been installed, and which files have been changed. How to set the endpoint to send tracing? As well a link to documentation on how to scrape metrics and logs. As well how can he revert. A link to documentation of telemetry section with all these details
  • As well this should work!

Godspeed CLI v2

I am writing this document to discuss the the godspeed CLI v2 with the team.

Why godspeed CLI v2 requires a discussion?

godspeed CLI is the entry for a developer to use our framework. And during the lifecycle of complete development it will be used most of the times. So there are few things we need to consider while evolving this specific piece of software. There are some non negotiable feature it should eventually have.

  1. Reliability
  2. Cross-platform

Proposed API for v2:

The new godspeed CLI v2 will have below top level commands.

  1. CREATE - create new godspeed project with interactive mode or with pre defined templates.
# create new project with interactive mode
 godspeed create <project name>

 # create godspeed project from a template
 godspeed create <project name> --from-template=postgres-backend-with-redis-cache

# create new project and dry run the whole process
godspeed create < project name> --dry-run
  1. UPDATE - update already existing godspeed project's dependencies, framework version
 # update existing project, default mode is interactive
 godspeed update
 
 # update gs-node-service version
 godspeed update version
  1. DELETE - delete an existing godspeed project with no trash left. Like deleting docker containers, docker network & project folder associated with that project
 # delete an existing godspeed project, dry run the whole process
 godspeed delete <project name> --dry-run
 
 # delete the current project
 godspeed delete .
  1. VALIDATE - validate an godspeed project for that specific version of godspeed framework version, it can be used to validate building blocks project like events, workflows
# validate all building blocks of framework in the project
 godspeed validate all
 
 # validate all events
 godspeed validate events
 
 # validate workflows
 godspeed validate workflows
 
  1. DEPLOY - deploy the current project to your choice of cloud
  2. BUILD - build the project
 # build godspeed artifact (used only from inside from the container)
  godspeed build 
  1. CLEAN - clean the build directories
 # clean the build artifact (used only from inside from the container)
 godspeed clean 
  1. DEV - run the local development in watch mode
 # start the current project's development server
 godspeed dev
  1. GENERATE - wrapper around different types of generation, like automates test, CRUD apis
 # any kind of auto generation goes inside this
 
 # crud-api
 godspeed generate crud-api
 
 # generate test
 godspeed generate test-suite

Gen-crud-api - responses schema is incorrect

The schema of responses is incorrect as per swagger 3.0 spec when we generate CRUD apis using CLI.

it is like this

responses:
    content:
      '204':
        application/json:
          schema:
            type: object

it should be like this

"responses": {
                        "200": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "type": "array"
                                    }
                                }
                            }
                        }
                }

godspeed commands `serve`, `preview` and `build` don't pick up NODE_ENV variable specified by the user

Version Information

CLI Version: 2.9.1

Environment

Linux

Current Behavior

godspeed commands serve, preview and build don't pick up NODE_ENV variable specified by the user. If we specify NODE_ENV either in .env file or directly export in the terminal, it is always setting NODE_ENV to 'production'.

Expected Behavior

NODE_ENV set by the user should not be overridden.

Possible Solutions or Workarounds

In the index.ts, NODE_ENV is specified and overriding the user specified env variable. This is the sample of build command. Same kind of changes are needed in all the three commands.

  program
    .command("build")
    .description("build the godspeed project. create a production build.")
    .action(async (options) => {
      if (await isAGodspeedProject()) {
        spawnSync("npm", ["run", "build"], {
          stdio: "inherit",
          env: {
            ...process.env,
            NODE_ENV: "production",
          },
        });
      }
    });

`devops-plugin remove` is not working as expected

Version Information

CLI Version: 2.9.1

Environment

Linux

Current Behavior

godspeed devops-plugin remove is not working correctly. it is not removing any devops-plugin.

$ godspeed devops-plugin remove
       ,_,   โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
      (o,o)  โ•‘        Welcome to Godspeed         โ•‘
     ({___}) โ•‘    World's First Meta Framework    โ•‘
       " "   โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
$

Expected Behavior

It should give the list of plugins to remove then remove the selected plugin.

Godspeed CLI: Error while creating project if no DB is selected and only kafka is selected

$ godspeed create test_kafka _ _ __ _ ___ __| | ___ _ __ ___ ___ __| | / _ | / _ \ / | / __| | '_ \ / _ \ / _ \ / _ |
| (
| | | () | | (| | __ \ | |) | | __/ | __/ | (| |
_, | ___/ _,| |/ | ./ _| _| _,|
|__/ ||
projectDir: /home/gurjot/cli-test/test_kafka projectTemplateDir undefined
project created
Do you need mongodb? [y/n] [default: n] n
Do you need postgresdb? [y/n] [default: n]
Do you need kafka? [y/n] [default: n] y
Do you need elastisearch? [y/n] [default: n]
Please enter host port on which you want to run your service [default: 3000]
Fetching release version information...
Please select release version of gs_service from the available list:
latest
1.0.0
1.0.1
1.0.10
1.0.11
1.0.12
1.0.13
1.0.2
1.0.3
1.0.4
1.0.5
1.0.6
1.0.7
1.0.8
1.0.9
base
dev
v1.0.13
Enter your version [default: latest]
Selected version latest
The Compose file './docker-compose.yml' is invalid because:
services.node.depends_on contains an invalid type, it should be an array, or an object
Error in "docker-compose down": undefined
Setting uid/gid 1001
The Compose file './docker-compose.yml' is invalid because:
services.node.depends_on contains an invalid type, it should be an array, or an object
Error in building container: undefined
The Compose file './docker-compose.yml' is invalid because:
services.node.depends_on contains an invalid type, it should be an array, or an object
Error in "docker-compose stop": undefined

godspeed create test_kafka is done.
`

CLI: godspeed update is not pulling the gs_service image on MacOS

Basically, when we execute godspeed update, the image is getting pulled but the code doesn't get reflected in the container. If we check docker images on macOS then it's showing the older images only.
Seems like, the pulled image is not loaded in the system and not reflected in the container also.

This is working fine on Ubuntu, only observed on MacOS for now.

Godspeed CLI v2 | CREATE

Godspeed CREATE

 godspeed create <project name>

Modes

  1. Interactive [default]
  2. From Templates [invoked by --from-template option]
{
  "meta": {
    "createTimestamp": "",
    "lastUpdateTimestamp": "",
    "cliVersionWhileCreation": "",
    "cliVersionWhileLastUpdate": ""
  },
  "projectName": "",
  "mongodb": {
    "dataBaseName": "",
    "clusterMode": true
  },
  "postgresql": {
    "databaseName": "",
    "databasePort": ""
  },
  "kafka": {},
  "elasticgraph": {},
  "redis": {},
  "servicePort": ""
}

Fixes: Handling required properties in definitions generated from Prisma gen-crud-api

The problem

When Prisma schema has a non nullable field which does not have a default setting either, the required property is not being set in the definitions. This means that the required validations of the framework are being bypassed.
Prisma schema

model User {
  id               Int               @id @default(autoincrement()) ///This should not be in required
  email            String            @unique ///This should be in required
  password         String            ///@encrypted ///This should be in required
  name             String?  ///This should not be in required
  loanApplications LoanApplication[]
}

Error

Generated definition of the user

User:
  type: object
  properties:
    email:
      type: string
    password:
      type: string
    name:
      type: string
      nullable: true

The solution

  • If a prisma property does not have @default and if it does not have ? then it must be included in the required attribute of definition generated
  • The correct output will have required set
User:
  type: object
  required: ['email', 'password']
  properties:
    email:
      type: string
    password:
      type: string
    name:
      type: string
      nullable: true

Importing files from source folder into destination

Similar issue in gs-plugins repo.

The problem

Developer often need to reuse existing code and configs. This way companies developer and reuse their infra. This infra could be docker files, helm charts, plugins (datasource, eventsource), sample code, project scaffoldings, READMEs, whole projects itself or anything under the sun.
Currently there is now way for a developer to import files from another folder (a remote git repository, or a local folder). This is useful when importing sample code and configs from a Godspeed plugin, project template or a starter scaffolding.
. The developer should be able to pick up and choose what it wants to use in the project.

For ex. a kafka plugin could have sample docker-compose, .env , config, src, docs, README.md, tsconfig.json, a docs/swagger.json etc. Developer may choose to import selected files and configs.

Developer may choose to do this during plugin installation process or anytime after it is installed.

The (proposed) solution

  • When plugin is installing the developer should be shown what all the plugin exports
    • Compulsory items like src/{datasources/kafka.ts, eventsources/kafka.ts}
    • And optional items like src/{events,functions,mappings}, config/{default,custom-environment-variables}
  • Developer will get the choice to select the files they want to extract,
  • Those paths/files which do not exist in destination folder will get created
  • Those paths/files which already exist in destination folder will be appended (merged) to or overwritten (allow the developer to select the action. Default will be append),
  • Folders will always get merged - i.e., those files which exist in a dest folder but not in src folder, will continue to remain in the dest folders after the merge.

How to solve

  • Define the plugin install process
  • Files import process
    • Write a reusable utility function in godspeed-cli to provide this directory export/import functionality by taking the path of src folder, destination folder, and the exports file
      async function merge(src: Path, dest: Path, exportConfig: Path | JSON): GSStatus {}
    • exportConfig will be a yaml/json file path or a JSON itself). Define a json format in which the importing logic from the source folder is defined (for ex. which files, folder to import. whether to import in append mode or overwrite mode. Can set merge policy per file or for the whole folder. Default merge mode is append mode (in case the file exists in destination folder).
defaults:
  mergePolicy: 'append' # <MergePolicy can be append or overwrite. Default value of this default mergePolicy is append. This applies at a file level.
imports:                # Each array item is either a string or a kay value pair
                        # {[key:String]: <MergePolicy | undefined>} Each entry (as you would express in Typescript)
  - .env: append                              # can leave value as append, overwrrite or undefined. 
                                              # If you leave undefined default merge policy 
                                              # will get executed
  - config: overwrite                         # path can be a folder or a file
  - src/datasources/types/kafka.ts            # use default defaults.mergePolicy
  - src/eventsources/types/kafka.ts           # use default defaults.mergePolicy
  - src/events/kafka/helloworld.ts            # use default defaults.mergePolicy
  - src/functions/kafka/ts/helloworld.ts      # use default defaults.mergePolicy
  - src/functions/kafka/yaml/helloworld.yaml  # use default defaults.mergePolicy
 
  • Reuse this code in the plugin install process. The developer only needs to edit the exports file. This can be done before, during or after the plugin install process (Go back to the 1st point of this list).

Godspeed CLI Script

  1. Install the godspeed command running npm install -g @godspeedsystems/cli on terminal.
  2. This package will install a command line tool godspeed in your machine.
  3. Run godspeed create <projectName> to create a new godspeed project.
[ ] java based micro-service
[ ] NodeJS based micro-service

Choose one, then it will take you to pre-requisites of installing respective runtime with assistance.
4. Ask user to select plugin to be installed in the project. or show user to generate a project from a pre created recipe.
5. Start creating project and on completion, show instructions to navigate and start the project in development mode.
6. Demonstration of godspeed CLI commands to manage the project.

  • godspeed install plugin <pluginName>
  • godspeed start
  • godspeed build
  • godspeed setup devcontainer
  • godspeed deploy
  • godspeed setup observability
  • godspeed generate test
  • godspeed generate crud-api
  • godspeed generate helm-charts
  • godspeed generate ui
  • godspeed update ui

Facing error in executing any cli command once OTEL_ENABLED flag is set to true

Current Behavior

Facing error in executing any cli command once OTEL_ENABLED flag is set to true in the project.

Expected Behavior

It should work properly without any error.

Steps to Reproduce

  1. Enable tracing in the project.
$ godspeed otel enable
       ,_,   โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
      (o,o)  โ•‘        Welcome to Godspeed         โ•‘
     ({___}) โ•‘    World's First Meta Framework    โ•‘
       " "   โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
otel installed successfully!
Observability has been enabled
  1. It sets the flag in the .env file of project.
OTEL_ENABLED=true
  1. Try to execute godspeed cli command again in the project.
$ godspeed 
{"Body":"OTEL_ENABLED is set, unable to initialize opentelemetry tracing.","Timestamp":"undefined000000","SeverityNumber":17,"SeverityText":"ERROR","Resource":{"service.name":"unknown_service:node"},"Attributes":{}}
{"Body":"Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/gurjot/data/cli-test/godspeed-cli/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/utils/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/commands/create/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/index.js","Timestamp":"undefined000000","SeverityNumber":17,"SeverityText":"ERROR","Resource":{"service.name":"unknown_service:node"},"Attributes":{"err":{"type":"Error","message":"Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/gurjot/data/cli-test/godspeed-cli/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/utils/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/commands/create/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/index.js","stack":"Error: Cannot find module '@godspeedsystems/tracing'\nRequire stack:\n- /home/gurjot/data/cli-test/godspeed-cli/node_modules/@godspeedsystems/core/dist/godspeed.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/utils/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/commands/create/index.js\n- /home/gurjot/data/cli-test/godspeed-cli/lib/index.js\n    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)\n    at Function.Module._load (node:internal/modules/cjs/loader:778:27)\n    at Module.require (node:internal/modules/cjs/loader:1005:19)\n    at require (node:internal/modules/cjs/helpers:102:18)\n    at Object.<anonymous> (/home/gurjot/data/cli-test/godspeed-cli/node_modules/@godspeedsystems/core/dist/godspeed.js:184:9)\n    at Module._compile (node:internal/modules/cjs/loader:1103:14)\n    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)\n    at Module.load (node:internal/modules/cjs/loader:981:32)\n    at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n    at Module.require (node:internal/modules/cjs/loader:1005:19)\n    at require (node:internal/modules/cjs/helpers:102:18)\n    at Object.<anonymous> (/home/gurjot/data/cli-test/godspeed-cli/lib/utils/index.js:20:16)\n    at Module._compile (node:internal/modules/cjs/loader:1103:14)\n    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)\n    at Module.load (node:internal/modules/cjs/loader:981:32)\n    at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n    at Module.require (node:internal/modules/cjs/loader:1005:19)\n    at require (node:internal/modules/cjs/helpers:102:18)\n    at Object.<anonymous> (/home/gurjot/data/cli-test/godspeed-cli/lib/commands/create/index.js:15:17)\n    at Module._compile (node:internal/modules/cjs/loader:1103:14)\n    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)\n    at Module.load (node:internal/modules/cjs/loader:981:32)\n    at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n    at Module.require (node:internal/modules/cjs/loader:1005:19)\n    at require (node:internal/modules/cjs/helpers:102:18)\n    at Object.<anonymous> (/home/gurjot/data/cli-test/godspeed-cli/lib/index.js:34:33)\n    at Module._compile (node:internal/modules/cjs/loader:1103:14)\n    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)\n    at Module.load (node:internal/modules/cjs/loader:981:32)\n    at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)\n    at node:internal/main/run_main_module:17:47","code":"MODULE_NOT_FOUND","requireStack":["/home/gurjot/data/cli-test/godspeed-cli/node_modules/@godspeedsystems/core/dist/godspeed.js","/home/gurjot/data/cli-test/godspeed-cli/lib/utils/index.js","/home/gurjot/data/cli-test/godspeed-cli/lib/commands/create/index.js","/home/gurjot/data/cli-test/godspeed-cli/lib/index.js"]}}}

Screenshots or Screencast

image

Possible Solutions or Workarounds

IMO we have two options to solve this issue:

  1. We install @godspeedsystems/tracing in the godspeed-cli. Then all the opentelemetry packages would always get installed with godspeed CLI installation.
  2. We remove @godspeedsystems/core package dependency from godspeed-cli

Godspeed updated CLI Script

Step 1: Install Godspeed CLI

# Install the Godspeed CLI globally
npm install -g @godspeedsystems/cli

This package will install "Godspeed" on your machine.

Step 2: Create a New Godspeed Project

# Create a new Godspeed project
godspeed create <projectName>

Choose one of the following options to proceed, and it will guide you through the prerequisites:

  • Java-based micro-service
  • Node.js-based micro-service
  • Determine if it's a greenfield (brand new) or brownfield (existing) project.

Step 3: Initialize Project
If you choose a Greenfield project:

  • Use Godspeed to create the project.
  • Install necessary plugins, e.g., Express for HTTP.
  • Capture a screenshot of the project creation.
  • Open the project in Visual Studio Code (VSCode).

Step 4: Event Handling

Implement HTTP and Kafka event handling:

HTTP events:

# HTTP Event Handling
'http.post./set-redis':
  fn: set-redis
  body:
    content:
      application/json:
        schema:
          type: object
          properties:
            name:
              type: string
          required: ['name']
  responses:
    200:
      content:
        application/json:
          schema:
            type: object
            properties:
              name:
                type: string

Kafka events:

# Kafka Event Handling
kafka.kafka_topic.kafka_groupId:
  id: kafka__consumer
  fn: kafka_con 
  body:
    description: The body of the query
    content:
      application/json: 
        schema:
          type: string

Step 5: Data Validation
Implement validation for request body, parameters, and response.

Step 6: Workflow Setup

Define your project workflow, including tasks such as:

  • Data source integration with Kafka:
id: hello_world_function
summary: Call an API and transform the
tasks:
  - id: transform_fn_step1
    description: add a message property
    fn: com.gs.switch
    value: <% inputs.body.name %>
    cases:
      'ashutosh':
        - id: case_ashutosh
          fn: com.gs.return
          args: |
            <% return { name: "Hello Ashutosh!" } %>
      'shubham':
        - id: case_shubham
          fn: com.gs.return
          args: |
            <% return { name: "Hello Shubham!" } %>
  • Utilize inbuilt functions as needed.
  • Implement caching mechanisms.

Step 7: JavaScript Integration

- id: step1
  description: upload documents
  fn: com.gs.http
  args:
    datasource: httpbin
    params:
    data: |
      <js% {
        [inputs.body.entity_type + 'id']: inputs.body.entity_id,
        _.omit(inputs.body, ['entity_type', 'entity_id'])}
      %>

Step 8: CRUD API Generation

# Generate CRUD APIs
godspeed generate crud-api

Step 9: Front-end Generation
Generate the front-end components as needed for your project.

# Generate UI components
godspeed generate ui

Step 10: Argo CD Installation
Install Godspeed's Argo CD plugin for continuous deployment.

Step 11: Deployment
Use Godspeed to deploy your project using Argo CD or other deployment tools.

Godspeed New CLI Migration & Release

There are few steps need to be taken to gracefully migrate @mindgrep/godspeed to @ godspeedsystems/godspeed. This documentation is result of discussion with @pankajmaurya @arunsingh and @ashutoshmindgrep.

Step 1: Release a new version on old Godspeed CLI @mindgrep/godspeed with below features.

  • Mechanism to show SOON TO BE DEPRECATED and deadline for deprication, when user runs any godspeed command.

Step 2:

  • #34
  • #35
  • #36
  • #37
  • Internal testing should be done to test @godspeedsystems/godspeed with old projects.
  • Once the new package is stable, We should update docs to use new package @godspeedsystems/godspeed.
  • Add mysql and MSSQL in Godspeed CLI

Old package and repos should be under maintenance until we reach the deprecation deadline.

Once we hit the deadline, We can take measures like deleting Mindgreppers/gs_project_template repo, Whick will force break the old CLI. and a message will be printed with the steps to remote old package and install new one.

[ ] Spec

godspeed CLI: godspeed create -n option is throwing error

`$ godspeed create test_no -n _ _ __ _ ___ __| | ___ _ __ ___ ___ __| | / _ | / _ \ / | / _| | ' \ / _ \ / _ \ / _ |
| (| | | () | | (| | __ \ | |) | | __/ | __/ | (| |
_, | _/ _,| |/ | ./ _| _| _,|
|
/ ||
projectDir: /home/gurjot/cli-test/test_no projectTemplateDir undefined
project created
node:fs:1722
handleErrorFromBinding(ctx);
^

Error: EISDIR: illegal operation on a directory, unlink '/home/gurjot/cli-test/test_no/src/functions/com'
at Object.unlinkSync (node:fs:1722:3)
at /usr/lib/node_modules/@mindgrep/godspeed/lib/index.js:84:126
at Array.map ()
at GSCreate (/usr/lib/node_modules/@mindgrep/godspeed/lib/index.js:84:102)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errno: -21,
syscall: 'unlink',
code: 'EISDIR',
path: '/home/gurjot/cli-test/test_no/src/functions/com'
}
`

Using templates in gs-project

The Problem

Currently this feature is not functional, while creating a project or import a template into existing project.

The Solution

  • There will be a command to import template from github repo or local project

  • Developer can import from github repo with subfolder [optional] or he can import from a local file system

  • Dev can do this while creating a project [add to existing command to create project]
    godspeed create <project_name> --from-template <path_to_github_repo>::<sub_folder_path> [p2]
    godspeed create <project_name> --from-template <path_to_local_fs>
    godspeed create <project_name> --from-template <path_to_github_repo> [p2]

  • Dev can add to an existing project
    godspeed template add <path_to_github_repo>::<sub_folder_path> [p2]
    godspeed template add <path_to_github_repo> [p2]
    godspeed template add <path_to_fs_folder>

How to solve

  • To reuse the code #89
  • You will need to use developer SSH keys to login to github for private projects [p2]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.