diff --git a/.github/workflows/release_package.yml b/.github/workflows/release_package.yml new file mode 100644 index 0000000..2c6d878 --- /dev/null +++ b/.github/workflows/release_package.yml @@ -0,0 +1,95 @@ +name: Release package +on: + workflow_dispatch: + inputs: + release-type: + description: 'Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease' + required: true +jobs: + release: + runs-on: ubuntu-latest + steps: + # Checkout project repository + - name: Checkout + uses: actions/checkout@v2.3.4 + + # Setup Node.js environment + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + registry-url: https://registry.npmjs.org/ + node-version: '14' + + # Configure Git + - name: Git configuration + run: | + git config --global user.email "risteristov60@yahoo.com" + git config --global user.name "rristov60" + + # Bump package version + # Use tag latest + - name: Bump release version + if: startsWith(github.event.inputs.release-type, 'pre') != true + run: | + echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV + echo "RELEASE_TAG=latest" >> $GITHUB_ENV + env: + RELEASE_TYPE: ${{ github.event.inputs.release-type }} + + # Bump package pre-release version + # Use tag beta for pre-release versions + - name: Bump pre-release version + if: startsWith(github.event.inputs.release-type, 'pre') + run: | + echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE + echo "RELEASE_TAG=beta" >> $GITHUB_ENV + env: + RELEASE_TYPE: ${{ github.event.inputs.release-type }} + + # Update changelog unreleased section with new version + - name: Update changelog + uses: superfaceai/release-changelog-action@v1 + with: + path-to-changelog: CHANGELOG.md + version: ${{ env.NEW_VERSION }} + operation: release + + # Commit changes + - name: Commit CHANGELOG.md and package.json changes and create tag + run: | + git add "package.json" + git add "CHANGELOG.md" + git commit -m "chore: release ${{ env.NEW_VERSION }}" + git tag ${{ env.NEW_VERSION }} + + # Publish version to public repository + - name: Publish + run: yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} + + # Push repository changes + - name: Push changes to repository + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git push origin && git push --tags + + # Read version changelog + - id: get-changelog + name: Get version changelog + uses: superfaceai/release-changelog-action@v1 + with: + path-to-changelog: CHANGELOG.md + version: ${{ env.NEW_VERSION }} + operation: read + + # Update GitHub release with changelog + - name: Update GitHub release documentation + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.NEW_VERSION }} + body: ${{ steps.get-changelog.outputs.changelog }} + prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9bc4395 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased +Initial release + +### Added +- Changelog diff --git a/README.md b/README.md index 68927a9..878d9a2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# node-red-contrib-puppeteer-new +# @digitalnodecom/node-red-contrib-puppeteer ### Warning & Important! @@ -14,18 +14,22 @@ Chrome browser automation (puppeteer) in node-red. # Credits -## fork from +## Original fork Thank you [oliverlorenz](https://github.com/oliverlorenz)! Pickup update from node-red-contrib-puppeteer +## Forked from + +Thank you [d0uub](https://github.com/d0uub/)! Pickup update from node-red-contrib-puppeteer + ## Screenshorts Node Copy from [node-red-contrib-image-tools (node) - Node-RED (nodered.org)](https://flows.nodered.org/node/node-red-contrib-image-tools) ## Icons -by [fontawesome](https://fontawesome.com/license) +By [fontawesome](https://fontawesome.com/license) ## Palettes -by [coolors.co](https://coolors.co/palette/ef476f-ffd166-06d6a0-118ab2-073b4c) \ No newline at end of file +By [coolors.co](https://coolors.co/palette/ef476f-ffd166-06d6a0-118ab2-073b4c) \ No newline at end of file diff --git a/package.json b/package.json index 6e8bafe..6799d5f 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,24 @@ { - "name": "node-red-contrib-puppeteer-new", + "name": "@digitalnodecom/node-red-contrib-puppeteer", "version": "0.3.7", "description": "NodeRED nodes to control a headless chrome with puppeteer", "main": "index.js", "scripts": {}, - "author": "Roy Chan ", + "author": { + "name": "Riste Ristov", + "email": "ristov@riste.mk", + "url": "https://riste.mk" + }, "license": "MIT", "dependencies": { "puppeteer": "^13.5.1" }, "bugs": { - "url": "https://github.com/d0uub/node-red-contrib-puppeteer-new/issues" + "url": "https://github.com/digitalnodecom/node-red-contrib-puppeteer/issues" }, "repository": { "type": "git", - "url": "https://github.com/d0uub/node-red-contrib-puppeteer-new" + "url": "https://github.com/digitalnodecom/node-red-contrib-puppeteer" }, "keywords": [ "chrome", diff --git a/puppeteer/browser/close.html b/puppeteer/browser/close.html index 51c19ee..667c916 100644 --- a/puppeteer/browser/close.html +++ b/puppeteer/browser/close.html @@ -20,6 +20,15 @@ +
+ + This node closes chromium browser instance provided with puppeteer.browser object + +
- + diff --git a/puppeteer/browser/launch.html b/puppeteer/browser/launch.html index ea3fe4b..1db6852 100644 --- a/puppeteer/browser/launch.html +++ b/puppeteer/browser/launch.html @@ -68,8 +68,8 @@
  • sameParty: boolean | optional,
    Default value: false
  • sourceScheme: string | optional,
    Default value: 'NonSecure'
  • sourcePort: number | optional,
    Default value: 80
  • + - diff --git a/puppeteer/browser/newPage.html b/puppeteer/browser/newPage.html index 64ee589..42f9d3a 100644 --- a/puppeteer/browser/newPage.html +++ b/puppeteer/browser/newPage.html @@ -9,10 +9,11 @@ outputs: 1, icon: "newtab.svg", label: function () { - return this.name || "New Tab"; + return this.name || "New Page"; }, - paletteLabel: "New Tab", + paletteLabel: "New Page", }); + - + diff --git a/puppeteer/page/click.html b/puppeteer/page/click.html index fe955a5..7283fb8 100644 --- a/puppeteer/page/click.html +++ b/puppeteer/page/click.html @@ -66,6 +66,12 @@ +
    + + This node clicks on a specified selector. It fetches an element which matches the provided selector, scrolls it into view if needed and then uses page.mouse to click the element. + If there's no element matching selector, the node throws an error. + +
    diff --git a/puppeteer/page/close.html b/puppeteer/page/close.html index d864887..d799ce9 100644 --- a/puppeteer/page/close.html +++ b/puppeteer/page/close.html @@ -15,11 +15,20 @@ }); - - + + \ No newline at end of file diff --git a/puppeteer/page/content.html b/puppeteer/page/content.html index 0cfd7a0..beb2aea 100644 --- a/puppeteer/page/content.html +++ b/puppeteer/page/content.html @@ -1,6 +1,6 @@ - + diff --git a/puppeteer/page/download.html b/puppeteer/page/download.html index 23ef431..f3cb6cd 100644 --- a/puppeteer/page/download.html +++ b/puppeteer/page/download.html @@ -86,7 +86,7 @@
    - This node downloads a file by clicking on a specified selector. Essetially that can be done with the click node as well, but here you can specify download location and also if this node is followed by rename node with specified download path and filename, it can change the filename directly, but in order to get this to work, in the rename node the old file path needs to be set to msg.old and the new file path needs to be set to msg.new. The output of this node is a msg which contains msg.puppeteer, msg.new & msg.old (only when download path and file path are specified) and msg.error when an error ocurred. + This node downloads a file by clicking on a specified selector. Essetially that can be done with the click node as well, but here you can specify download location and also if this node is followed by rename node(in storage section) with specified download path and filename, it can change the filename directly, but in order to get this to work, in the rename node(in storage section) the old file path needs to be set to msg.old and the new file path needs to be set to msg.new. The output of this node is a msg which contains msg.puppeteer, msg.new & msg.old (only when download path and file path are specified) and msg.error when an error ocurred.
    @@ -103,11 +103,11 @@

    Inputs

    Download pathstring
    Specify custom download path. Leave the field blank for default download path. Defaults to user's default browser download path.
    File namestring
    -
    Specify custom file name. Leave the field blank for default file name. Please note that in order for this to work this node needs to be followed by the rename node. Defaults to default file name.
    +
    Specify custom file name. Leave the field blank for default file name. Please note that in order for this to work this node needs to be followed by the rename node(in storage section). Defaults to default file name.

    Details

    This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error. The main difference between this and click node is that with this node you can specify - download path and file name. But, in order the custom filename to work, this node must have download path and file name specified and be followed by a rename node where + download path and file name. But, in order the custom filename to work, this node must have download path and file name specified and be followed by a rename node(in storage section) where the old file path should be set to msg.old and the new file path should be set to msg.new

    diff --git a/puppeteer/page/focus.html b/puppeteer/page/focus.html index b21bf52..30a1905 100644 --- a/puppeteer/page/focus.html +++ b/puppeteer/page/focus.html @@ -40,6 +40,17 @@ +
    + + This node fetches an element with selector and puts it in focus. + If there's no element matching selector, the node throws an error. + +
    - + diff --git a/puppeteer/page/get.html b/puppeteer/page/get.html index bf007de..0b82371 100644 --- a/puppeteer/page/get.html +++ b/puppeteer/page/get.html @@ -55,6 +55,17 @@ +
    + + This node fetches a specified property value from element with specified selector + If there's no element matching the selector, the node throws an error. + +
    - + diff --git a/puppeteer/page/goto.html b/puppeteer/page/goto.html index d2ad671..e49b6a5 100644 --- a/puppeteer/page/goto.html +++ b/puppeteer/page/goto.html @@ -50,6 +50,18 @@ +
    + + This node visits specified URL. There are three inputs from which the Name and URL are self-explanatory. + The Wait Until input on the other hand has some additional values that need to be further explained, and they are the following: +
      +
    • load - consider navigation to be finished when the load event is fired
    • +
    • domcontentloaded - consider navigation to be finished when the DOMContentLoaded event is fired
    • +
    • networkidle0 - consider navigation to be finished when there are no more than 0 network connections for at least 500 ms
    • +
    • networkidle2 - consider navigation to be finished when there are no more than 2 network connections for at least 500 ms
    • +
    +
    +
    +> +

    Keyboard Press

    +

    Details

    +

    This node presses the keyboard key specified in Key input field.

    + diff --git a/puppeteer/page/keyboard/type.html b/puppeteer/page/keyboard/type.html index ba65f7e..ca3887f 100644 --- a/puppeteer/page/keyboard/type.html +++ b/puppeteer/page/keyboard/type.html @@ -32,7 +32,7 @@ +> +

    Keyboard Type

    +

    Details

    +

    This node types the text specified in the Text input using the puppeteer.page.keyboard.type function.

    + diff --git a/puppeteer/page/querySelector.html b/puppeteer/page/querySelector.html deleted file mode 100644 index 6d4f380..0000000 --- a/puppeteer/page/querySelector.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - diff --git a/puppeteer/page/querySelector.js b/puppeteer/page/querySelector.js deleted file mode 100644 index 9c7c483..0000000 --- a/puppeteer/page/querySelector.js +++ /dev/null @@ -1,72 +0,0 @@ -module.exports = function (RED) { - function PuppeteerDocumentQuerySelector(nodeConfig) { - RED.nodes.createNode(this, nodeConfig); - var node = this; // Referencing the current node - this.selector = nodeConfig.selector; - this.property = nodeConfig.property; - - this.on("input", function (msg, send, done) { - // Parsing the selector - node.selector = - nodeConfig.selectortype == "msg" ? msg[node.selector] : node.selector; - node.selector = - nodeConfig.selectortype == "flow" - ? flowContext.get(node.selector) - : node.selector; - node.selector = - nodeConfig.selectortype == "global" - ? globalContext.get(node.selector) - : node.selector; - const selector = "a"; - const property = "innerText"; - - node.status({ fill: "blue", shape: "dot", text: `Querying` }); - - // Querying the provided selector and property - msg.puppeteer.page - .evaluate( - ({ selector, property }) => { - return document.querySelector(selector)[property]; - }, - { - selector: this.selector, - property: this.property, - } - ) - .then((payload) => { - node.status({ fill: "green", shape: "dot", text: `Queried` }); - msg.payload = payload; - // Sending the msg - send(msg); - }) - .catch((e) => { - // If an error occured - node.error(e); - // Update the status - node.status({ fill: "red", shape: "dot", text: e }); - // And update the message error property - msg.error = e; - send(msg); - }) - .finally(() => { - // Clear status of the node - setTimeout(() => { - done(); - node.status({}); - }, (msg.error) ? 10000 : 3000); - }); - }); - this.on("close", function () { - node.status({}); - }); - oneditprepare: function oneditprepare() { - $("#node-input-name").val(this.name); - $("#node-input-selector").val(this.selector); - $("#node-input-property").val(this.property); - } - } - RED.nodes.registerType( - "puppeteer-page-document-querySelector", - PuppeteerDocumentQuerySelector - ); -}; diff --git a/puppeteer/page/screenshot.html b/puppeteer/page/screenshot.html index bca16a0..0c18dfc 100644 --- a/puppeteer/page/screenshot.html +++ b/puppeteer/page/screenshot.html @@ -37,6 +37,14 @@ +
    + + This node takes a screenshot(captures screen) from the current page. If Capture Full Page flag is set, then the screenshot is from the full scrollable page. It deafults to false. The output from this node is: +
      +
    • msg.payload: Buffer - buffer with captured screenshot
    • +
    +
    +
    - + diff --git a/puppeteer/page/upload.html b/puppeteer/page/upload.html index 419d140..f433204 100644 --- a/puppeteer/page/upload.html +++ b/puppeteer/page/upload.html @@ -52,6 +52,15 @@ +
    + + This node uploads a file(or more accurately specified filePath) specified with Upload File to the element speicified with the selector if it exists. + +
    - + diff --git a/puppeteer/page/waitFor.html b/puppeteer/page/waitFor.html index f2a6637..6eac206 100644 --- a/puppeteer/page/waitFor.html +++ b/puppeteer/page/waitFor.html @@ -40,6 +40,15 @@ +
    + + This node uploads a file(or more accurately specified filePath) specified with Upload File to the element speicified with the selector if it exists. + +
    - +