toolsplus / nx-forge

Atlassian Forge plugin for Nx
https://toolsplus.github.io/nx-forge/
MIT License
17 stars 4 forks source link

nx serve does not start tunnel #132

Closed antonversal closed 1 week ago

antonversal commented 2 weeks ago

Hello, Thanks for the project.

It seems that nx serve only serves the forge app, not the custom app, and it does not start tunneling. Deploying and installing work just fine. Any change to the custom UI app does not start rebuilding, but changes to the forge app do.

nx serve simple-project

> nx run simple-project:serve

> webpack-cli serve --node-env=development

<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://192.168.178.20:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/Users/ant/projects/simple-project/apps/simple-project/public' directory
chunk (runtime: index) index.js (index) 5.58 KiB (javascript) 22.6 KiB (runtime) [entry] [rendered]
chunk (runtime: main) main.js (main) 5.58 KiB (javascript) 22.6 KiB (runtime) [entry] [rendered]
webpack compiled successfully (bf81ddf32d5f7636)

manifest.yml:

modules:
  jira:projectPage:
    - key: project-page
      title: Project page Custom UI
      layout: basic
      resource: project-page
      resolver:
        function: resolver
  function:
    - key: resolver
      handler: index.handler
resources:
  - key: project-page
    path: simple-project-ui
    tunnel:
      port: 4200
permissions:
  content:
    styles:
      - unsafe-inline
app:
  id: ari:cloud:ecosystem::app/1111111-1111-111
  runtime:
   name: nodejs18.x
tbinna commented 1 week ago

Hey @antonversal, thanks for the report. The way I thought about implementing this was through the tunnel exectutor. The idea is that the tunnel executor starts the serve target on the Forge app and all dependent Custom UI projects.

Having said that, the tunnel executor is quite experimental at this stage. There were some challenges around terminating all processes in one go and I didn't find the time to implement this properly.

Alternatively, you may be able to define your own nx:run-commands executor on the Forge app project/s to start the serve processes and projects you need.

I am closing this in favor of https://github.com/toolsplus/nx-forge/issues/36, but let me know if you have any further questions.

antonversal commented 19 hours ago

Hey @tbinna , Thanks. I'll leave the configuration here if someone needs it: apps/forge-app/project.json

"targets": {
    "tunnel": {
      "command": "cd {projectRoot} && forge tunnel"
    },
    "start": {
      "executor": "nx:run-commands",
      "options": {
        "commands": [
          {
            "command": "nx serve forge-app",
            "prefix": "[FORGE]"
          },
          {
            "command": "nx serve custom-ui",
            "prefix": "[UI]"
          },
          {
            "command": "nx tunnel forge-app",
            "prefix": "[TUNNEL]"
          }
        ],
        "parallel": true
      }
    }
  }