Skip to content

Commit

Permalink
Update npm publish
Browse files Browse the repository at this point in the history
  • Loading branch information
splainez committed Mar 18, 2023
1 parent 7da4061 commit 08bf4fb
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 224 deletions.
27 changes: 0 additions & 27 deletions .devcontainer/devcontainer.json

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run prepublishOnly

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
76 changes: 0 additions & 76 deletions CODE_OF_CONDUCT.md

This file was deleted.

88 changes: 41 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

# n8n-nodes-starter

This repo contains example nodes to help you get started building your own custom integrations for [n8n](n8n.io). It includes the node linter and other dependencies.

To make your custom node available to the community, you must create it as an npm package, and [submit it to the npm registry](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry).

## Prerequisites

You need the following installed on your development machine:

* [git](https://git-scm.com/downloads)
* Node.js and npm. Minimum version Node 16. You can find instructions on how to install both using nvm (Node Version Manager) for Linux, Mac, and WSL [here](https://github.com/nvm-sh/nvm). For Windows users, refer to Microsoft's guide to [Install NodeJS on Windows](https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows).
* Install n8n with:
```
npm install n8n -g
```
* Recommended: follow n8n's guide to [set up your development environment](https://docs.n8n.io/integrations/creating-nodes/build/node-development-environment/).


## Using this starter

These are the basic steps for working with the starter. For detailed guidance on creating and publishing nodes, refer to the [documentation](https://docs.n8n.io/integrations/creating-nodes/).

1. [Generate a new repository](https://github.com/n8n-io/n8n-nodes-starter/generate) from this template repository.
2. Clone your new repo:
```
git clone https://github.com/<your organization>/<your-repo-name>.git
```
3. Run `npm i` to install dependencies.
4. Open the project in your editor.
5. Browse the examples in `/nodes` and `/credentials`. Modify the examples, or replace them with your own nodes.
6. Update the `package.json` to match your details.
7. Run `npm run lint` to check for errors or `npm run lintfix` to automatically fix errors when possible.
8. Test your node locally. Refer to [Run your node locally](https://docs.n8n.io/integrations/creating-nodes/test/run-node-locally/) for guidance.
9. Replace this README with documentation for your node. Use the [README_TEMPLATE](README_TEMPLATE.md) to get started.
10. Update the LICENSE file to use your details.
11. [Publish](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) your package to npm.
## More information
Refer to our [documentation on creating nodes](https://docs.n8n.io/integrations/creating-nodes/) for detailed information on building your own nodes.
## License
[MIT](https://github.com/n8n-io/n8n-nodes-starter/blob/master/LICENSE.md)
# n8n-nodes-phonenumber-parser

[![version](https://img.shields.io/npm/v/@splainez/n8n-nodes-phonenumber-parser.svg)](https://www.npmjs.org/package/@splainez/n8n-nodes-phonenumber-parser)

## Description

The `PhoneNumberParser` node is a useful tool for working with phone numbers in your n8n workflows. This node uses the `libphonenumber-js` library to format phone numbers into human-readable formats and extract useful information from them, such as the country code, area code, and phone number itself.


Alternatively, you can clone the repository from Github and build the package yourself.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

## Usage

To use the `PhoneNumberParser` node in your n8n workflows, simply drag and drop the node from the node palette onto your workflow canvas. Then, connect the output of any preceding nodes to the input of the `PhoneNumberParser` node.

The `PhoneNumberParser` node has a single input parameter, the phone number to be formatted. This should be a string containing only digits. Once the node receives the phone number, it will automatically format it into a human-readable format and extract useful information from it, such as the country code, area code, and phone number itself. The formatted phone number will be output as a JSON object containing these different fields.

This node parses a phone number using the libphonenumber-js library and returns its information in JSON format. The following information is included in the output:

* `country`: The country code of the phone number.
* `countryCallingCode`: The country calling code of the phone number.
* `nationalNumber`: The national (significant) number of the phone number.
* `formatNational`: The phone number formatted in the national format.
* `formatInternational`: The phone number formatted in the international format.
* `formatE164`: The phone number formatted in the E.164 format.
* `formatRFC3966`: The phone number formatted in the RFC3966 format.
* `possible`: Whether the phone number is possible (i.e., it is a valid phone number but not necessarily assigned to a specific user or location).
* `valid`: Whether the phone number is valid (i.e., it is a valid phone number and is assigned to a specific user or location).
* `nonGeographic`: Whether the phone number is non-geographic (i.e., it is not assigned to a specific geographic location).
* `type`: The type of the phone number (e.g., FIXED_LINE_OR_MOBILE, MOBILE, FIXED_LINE, TOLL_FREE, etc.).


## License

This project is licensed under the MIT License. See the `LICENSE` file for more details.

This project uses the `libphonenumber-js` library, which is licensed under the MIT License. See the `libphonenumber-js/LICENSE` file for more details.
48 changes: 0 additions & 48 deletions README_TEMPLATE.md

This file was deleted.

13 changes: 0 additions & 13 deletions nodes/PhoneNumberParser/PhoneNumberParser.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ export class PhoneNumberParser implements INodeType {
newItem.json.countryCallingCode = phoneNumber?.countryCallingCode ?? '';
newItem.json.nationalNumber = phoneNumber?.nationalNumber ?? '';

// NATIONAL — Example: "(213) 373-4253"
// INTERNATIONAL — Example: "+1 213 373 4253"
// E.164 — Example: "+12133734253"
// RFC3966 (the phone number URI) — Example: "tel:+12133734253;ext=123"
newItem.json.formatNational = phoneNumber?.format('NATIONAL') ?? '';
newItem.json.formatInternational = phoneNumber?.format('INTERNATIONAL') ?? '';
newItem.json.formatE164 = phoneNumber?.format('E.164') ?? '';
Expand All @@ -116,15 +112,6 @@ export class PhoneNumberParser implements INodeType {

newItem.json.type = phoneNumber?.getType() ?? '';

// PhoneNumber class instance has the following properties:

// number: string — The phone number in E.164 format. Example: "+12133734253".
// countryCallingCode: string — The country calling code. Example: "1".
// nationalNumber: string — The national (significant) number. Example: "2133734253".
// country: string? — The country code. Example: "US". Will be undefined when no country could be derived from the phone number. For example, when several countries have the same countryCallingCode and the nationalNumber doesn't look like it belongs to any of them. Or when a number belongs to a non-geographic numbering plan.
// ext: string? — The phone number extension, if any. Example: "1234".
// carrierCode: string? — The "carrier code", if any. Example: "15". "Carrier codes" are only used in Colombia and Brazil and only when dialing within those countries from a mobile phone to a fixed line number.

returnData.push(newItem);
}

Expand Down
21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splainez/n8n-nodes-phonenumber-parser",
"version": "0.1.0",
"version": "1.0.0",
"description": "Parse a phone number and return its information",
"keywords": [
"n8n-community-node-package",
Expand All @@ -13,8 +13,7 @@
"license": "MIT",
"homepage": "https://github.com/splainez/n8n-nodes-phonenumber-parser",
"author": {
"name": "Sergio Parra",
"email": "[email protected]"
"name": "splainez"
},
"repository": {
"type": "git",
Expand All @@ -24,23 +23,19 @@
"scripts": {
"build": "tsc && gulp build:icons",
"dev": "tsc --watch",
"format": "prettier nodes credentials --write",
"lint": "eslint nodes credentials package.json",
"lintfix": "eslint nodes credentials package.json --fix",
"prepublishOnly": "npm run build && npm run lint -c .eslintrc.prepublish.js nodes credentials package.json"
"format": "prettier nodes --write",
"lint": "eslint nodes package.json",
"lintfix": "eslint nodes package.json --fix",
"prepublishOnly": "npm run build && npm run lint -c .eslintrc.prepublish.js nodes package.json"
},
"files": [
"dist"
],
"n8n": {
"n8nNodesApiVersion": 1,
"credentials": [
"dist/credentials/ExampleCredentialsApi.credentials.js",
"dist/credentials/HttpBinApi.credentials.js"
],
"credentials": [],
"nodes": [
"dist/nodes/ExampleNode/ExampleNode.node.js",
"dist/nodes/HttpBin/HttpBin.node.js"
"dist/nodes/PhoneNumberParser/PhoneNumberParser.node.js"
]
},
"devDependencies": {
Expand Down

0 comments on commit 08bf4fb

Please sign in to comment.