proactive-test-pkg
v1.0.0
Published
Test NPM package for Promidea Proactive.
Downloads
10
Maintainers
Readme
proactive-test-pkg
A simple test npm library for Promidea Proactive.
Follow these steps:
- open terminal (command propmpt)
- go to the folder you want to create the package into
- create folder <package-name> e.g. proactive-test-pkg
- go inside <pakage-name> folder - cd proactive-test-pkg
- run
npm init
and set the defaults, name, license, github url, test command etc.; this generates the package.json file
{
"name": "proactive-test-pkg",
"version": "1.0.0",
"description": "Test NPM package for Promidea Proactive.",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"Promidea",
"Proactive",
"Test",
"Package",
"NPM"
],
"author": "Promidea",
"license": "MIT",
"dependencies": {
"expr-eval": "^1.2.1"
}
}
- in VS Code, open folder <package-name>
- create a tsconfig.json file (this one seems OK)
{
"compilerOptions": {
"experimentalDecorators": true,
"lib": ["es5", "dom"],
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "dist",
"removeComments": false,
"typeRoots": [
"node_modules/@types"
]
},
"files": [
"src/index.ts"
],
"exclude": [
"node_modules"
]
}
- create a README.md file
- create a src folder
- edit package.json and include at the end the following entry, required for intellisense
"typings": "dist/index.d.ts"
- create your library (add files to src folder, install packages, run tests etc.)
- in terminal, run tsc to build the library; fix potential errors
- publish using npm (from npm reference)
- from the terminal, login into npm
npm login
username:
password:
- inside the <package-name> folder run npm publish
npm publish
- for later updates, run npm version to increase the version in package.json, then publish
npm version 1.0.1
...
npm publish
- consume library
- create your application, for example using aurelia-skeleton (make sure the application is working, install packages, run tests, etc.)
- in the terminal, navigate to the application folder (cd <app-name>)
- run npm install for the package <package-name>
npm install <package-name> --save
or, if using jspm
jspm install npm:<package-name> -y
- import the class or classes you need from the library
import { Evaluator } from 'proactive-test-package';
- write the code to consume the imported classes - intellisense should be available:
let e: Evaluator = new Evaluator();
e.expression = 'a + b';
e.arguments = { a: 1, b: 2 };
e.eval();
console.log(e.result);
- run app, for example using
au watch
, orgulp watch
ornpm run
or whatever; in our example, the evaluator should calculatea + b
where a = 1 and b = 2 and display 3 in the console.