erp-dev-tools
v18.10.9
Published
Auxiliary tools used in the development of Bematech ERP products.
Downloads
40
Readme
Bematech ERP Development Tools
Auxiliary tools used in the development of Bematech ERP products.
Install
Prerequisites
- Node.js 8.0 or greater.
Installation
Install erp-dev-tools using npm (or yarn):
npm install erp-dev-tools
Configuration
Builder API requires a configuration about the target database that will run the tests and receive the build artifacts. The configuration can be informed by environment variables or by a .env config file placed at repository root.
The build API and scripts will search custom jaz archives automatically at directory build/jaz and they will use directory .engine as Engine work directory. It´s recommended to ignore this directory in .gitignore to avoid to commit Engine large temporary files like logs and database local caches.
Configure defining the environment variables:
- SERVER_URL: engine server URL. Example: http://my_database.bematech.com.
- SERVER_DB_NAME: database name. Example: MY_DATABASE.
- SERVER_USR: user name used to upload artifacts and run tests.
- SERVER_PSW: user password used to upload artifacts and run tests.
- BUILDER_API_KEY: API_KEY configured at /configuration/HTTP APIs/System Builder.
- JAZ_API_KEY: API_KEY configured at /configuration/HTTP APIs/Jaz.
Or use a .env file:
SERVER_URL=http://my_database.bematech.com
SERVER_DB_NAME=MY_DATABASE
SERVER_USR=username
SERVER_PSW=password
BUILDER_API_KEY=my-builder-api-key
JAZ_API_KEY=my-jaz-api-key
Components
Engine Wrapper
EngineWrapper API can be used to start and stop an Engine programmatically.
Usage:
const EngineWrapper = require('erp-dev-tools').EngineWrapper;
const url = require('url');
const request = require('request-promise-native');
const engine = new EngineWrapper('installPath', 'http://myserver.com', 'DBNAME');
engine.install().then(() => {
return engine.start();
}).then(() => {
return request.get(url.resolve(engine.url, '/api/service-status/v1/status'));
}).then(body => {
console.log(body);
return engine.stop();
}).catch(err => {
console.error(err);
});
Builder
Builder API can be used to execute tests on Engine and upload the build artifacts to the Virtual File System.
Usage:
const Builder = require('../lib/Builder');
new Builder().uploadArtifacts([
{
key: fileKey,
path: './build/jaz/my-product.jaz'
}
]])
.then(() => process.exit(0))
.catch(() => process.exit(1));
Build and utilities scripts
uploadToVfs
Upload one or more build artifacts to Engine Virtual File System.
Usage:
uploadToVfs PATH_1 FILE_KEY_1 PATH_2 FILE_KEY_2 ... PATH_N FILE_KEY_N
runTests
Run server testes on Engine and save the results to a file using the JUnit tests XML report file format. If the report path was not informed it will use "build/server-tests.xml".
Usage:
runTests.js TESTS_PATHS [OUT_REPORT_PATH]
publishToNpm
Publish the informed path as a public npm module only if the package version changed.
Usage:
publishToNpm
installSelf
Create a self-referencing symbolic link in node_modules allowing require itself using the package name instead of relative paths.
Is recommended to use installSelf as a postinstall script of package.json.
Usage:
installSelf
installJazDependencies
Read the array property jazDependencies of package.json and download the informed JAZ packages of the server informed by the environment variable SERVER_URL using the JAZ_API_KEY. The downloaded JAZ packages are extracted in node_modules.
Is recommended to use installJazDependencies as a postinstall script of package.json.
Usage:
installJazDependencies
packJaz
Build a JAZ file using a config file informed as argument. Config example:
{
"dest": "build/jaz/my-package.jaz",
"files": [
"package.json", "lib/**", "routes/**", "controllers/**", "keys/**", "tests/**",
"publicModules.js", "scripts/**", "startups/**"
],
"ignore": [
"lib/localConfig.js"
],
"uglify": {
"options": {
"compress": {
"booleans": false,
"typeofs": false,
"keep_infinity": true
}
},
"files": [
"lib/**"
]
},
"e2c": [
{
"metadata": {
"license": {
"product": -1898148465
}
},
"files": [
"lib/testing/e2c/**"
]
}
]
}
Use uglify options to obfuscate the files of the JAZ Package. The e2c options allow to encrypt files using the Engine E2C file format. Both features are experimental and not were officially released by Bematech as supported product features.
Usage:
packJaz jaz.config.json
Dictionaries
In directory erp-dev-tools/dictionaries can be found single word per line dictionaries used to spell check Bematech ERP codes using tools like Code Spellchecker.