Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Nov 13, 2023
2 parents 6877786 + cccdcc6 commit 5c44ce3
Show file tree
Hide file tree
Showing 28 changed files with 14,731 additions and 480 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ERP_HOST=https://url_erp:8068
ERP_DB=database
ERP_USER=user
ERP_PASSWORD=password
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
42 changes: 42 additions & 0 deletions .github/workflows/create_webclient_alpha_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ALPHA - Create PR on WebClient

on:
release:
types: [published]
workflow_dispatch:

jobs:
create-pr:
if: github.event.release.prerelease == true && contains(github.event.release.tag_name, '-alpha.')
runs-on: ubuntu-latest

steps:
- name: Checkout webclient repository
uses: actions/checkout@v2
with:
repository: 'gisce/webclient'
ref: alpha
token: ${{ secrets.GH_PAT }}

- name: Update library version in package.json
run: |
NEW_VERSION=${{ github.event.release.tag_name }}
NEW_VERSION=${NEW_VERSION#v} # Remove the leading 'v'
sed -i 's|"@gisce/powerp.js": "[^"]*"|"@gisce/powerp.js": "'"$NEW_VERSION"'"|' package.json
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20.5.0'

- name: Install npm dependencies and generate package-lock.json
run: |
npm install
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GH_PAT }}
commit-message: "fix: Update @gisce/powerp.js to ${{ github.event.release.tag_name }}"
title: "Update @gisce/powerp.js to ${{ github.event.release.tag_name }}"
branch: "update-powerpjs-${{ github.event.release.tag_name }}"
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a basic workflow to help you get started with Actions

name: Build and publish

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: ["master", "develop"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/[email protected]
with:
node-version: "16.13.1"
registry-url: "https://registry.npmjs.org"

- name: Installing dependencies
run: npm ci

- name: Build and publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
# - main
# - develop
- alpha
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20.5.0'

- name: Install Dependencies
run: npm ci

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: npx semantic-release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ typings/
# dotenv environment variables file
.env
.idea
.vscode
.DS_Store
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib
coverage
spec
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
74 changes: 59 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
# PowERP.js

Javascript client for PowERP and MessagePack protocol.
A TypeScript implementation for a PowERP client.

## Install

## Example
For the moment you can install this library adding the specific git repository in your `package.json` dependencies, like this:

_package.json_

```json
{
// ...
"dependencies": {
// ...
"powerp.js": "git://github.com/gisce/powerp.js.git#feature/typescript"
}
}
```

## Usage

```javascript
import Client from 'powerp';


const c = new Client('http://localhost:8068', 'test', 'admin', 'admin');
c.login().then(() => {
const model = c.model('res.partner');
model.search([['name', 'ilike', 'asus']]).then((ids) => {
model.read(ids, ['name', 'vat']).then((results) => {
results.map((result) => {
console.log(`Partner ${result.name} vat: ${result.vat}`);
});
});
});
import { Client } from "powerp.js";

// ...

const c = new Client({
host: process.env.ERP_HOST!,
database: process.env.ERP_DB!,
});

const token = await c.loginAndGetToken({
user: process.env.ERP_USER!,
password: process.env.ERP_PASSWORD!,
});
```

## Running tests

First adjust your `.env` file in order to fulfill the proper host, database and auth details. You can get an example copy from `.env.sample`.

Then install the dependencies with:

```shell
$ npm install
```

And therefore you can run the tests using:

```shell
$ npm test
```

## Publishing new versions of the library

If you make any changes in this library and want to use them in your project, you must build it in order to get the updated version:

```shell
$ npm run build
```

This will erase your `dist/` folder and rebuild the library in it. You must push these updated `dist/` files into git.

Then in your project you can simply:

```shell
$ npm update powerp.js
```

## TODO

[ ] Implement pending methods from the old version
[ ] Improve the way to publish this library. NPM public registry?
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
roots: ["<rootDir>/spec"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
collectCoverage: true,
};
108 changes: 0 additions & 108 deletions karma.conf.js

This file was deleted.

Loading

0 comments on commit 5c44ce3

Please sign in to comment.