Skip to content

Commit

Permalink
feat: add debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
naimo84 committed Jun 19, 2023
1 parent 350cdda commit 7610691
Show file tree
Hide file tree
Showing 8 changed files with 13,477 additions and 21 deletions.
18 changes: 17 additions & 1 deletion docs/.vuepress/config.js
Expand Up @@ -46,7 +46,23 @@ module.exports = {
'/': {
label: 'English',
selectText: 'Languages',
lastUpdated: 'Last Updated',
lastUpdated: 'Last Updated',
nav: [
{
text: 'Guide',
link: '/guide/'
},
],
sidebar: {
'/guide/': [
'/guide/',
{
title: 'Debug',
path: '/guide/debug',
collapsable: false
},
]
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
@@ -1,6 +1,8 @@
---
home: true
heroImage: /favicon.png
actionText: Get Started →
actionLink: /guide/
footer: MIT Licensed | Copyright © 2019-present Benjamin Neumann
---
# Getting Started
Expand Down
7 changes: 7 additions & 0 deletions docs/guide/README.md
@@ -0,0 +1,7 @@
---
sidebarDepth: 0
---

# Overview

- [Debug](./debug.md)
Binary file added docs/guide/attach.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions docs/guide/debug.md
@@ -0,0 +1,102 @@
# Debug node-red-contrib-ical-events

<ol>
<li>First of all, we have to install Node-RED locally as a global package

```sh
npm i -g node-red
```
</li>

<li>run node-red once and shutdown it after a few seconds, in order to generate a .node-red folder in your $HOME folder</li>

```sh
node-red
```
<li>
create a launch.json under ~/.node-red/.vscode
<a id="launch"/>

![launch_json](./launch.json.jpeg)

```json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to node-red",
"port": 9229,
"trace": true,
"sourceMaps": true,
"outFiles": ["/Users/benjamin/.node-red/node_modules/node-red-contrib-ical-events/dist/**/*.js"]
}
]
}
```
</li>
<li>
Now clone node-red-contrib-ical-events and install the dependencies.

```sh
cd $HOME
git clone https://github.com/naimo84/node-red-contrib-ical-events
npm i
```
</li>
<li>
Connect node-red-contrib-ical-events via npm install to the $HOME/.node-red folder

```sh
cd $HOME/.node-red
npm install $HOME/node-red-contrib-ical-events
```

The package.json under $HOME/.node-red should now look like the following:

```json
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"private": true,
"dependencies": {
"node-red-contrib-ical-events": "file:../node-red-contrib-ical-events"
}
}
```
</li>
<li>
Now it's really important to open the correct folder as you can see under topic

[create launch.json](#launch).

I'm doing this wrong after so many years of Node-RED module coding ;)
The correct folder to get a breakpoint into the module is:

```sh
$HOME/.node-red/node_modules/node-red-contrib-ical-events
```
</li>
<li>
Run the dev task, which opens a <a href="https://nodejs.org/en/docs/guides/debugging-getting-started">remote debugging<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> port 9229

```sh
cd $HOME/.node-red/node_modules/node-red-contrib-ical-events
npm run dev
```
</li>
<li>
Attach to node-red under VS Code's "Run and Debug"

![attach](./attach.png)

</li>

<li>
Now open <a href="http://localhost:1880" target="_blank" rel="noopener noreferrer">http://localhost:1880<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and add a node, trigger it and happy debugging ;)

</li>
</ol>

Binary file added docs/guide/launch.json.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7610691

Please sign in to comment.