A set of common codes used in angular and ionic/angular projects.
It exposes:
- NavService: to store data while navigating between two pages
- UIHelperService: helper to manage loaders and toasts
- AuthWordpressService: service to manage authentication with Wordpress
- AuthPlainService: service to manage internal authentication with back-end
It supplies also an interceptor that applies common http headers locale and authorization
- Clone the library workpace ng-node-library in your working dir, NOT inside your main project!; This repo contains angular-core and ionic-core repos
- In the library workspace root folder run
npm i, thennpm run build:ang-libto create the dist folder - In the library /dist/PACKAGE_NAME run
npm link. This will create a symlink to the global node folder - In your main project root folder run
ng add @next-adv/angular-core. This will:- Create an entry in the package.json
- Guide you through the library installation with the wizard
- Copy the library inside your node_modules, which is not what we want (node modules are read-only)
- Delete the library from node_modules folder
- In your main project root folder run
npm link @next-adv/angular-core. This will create a symlink inside the node_modules folder to the global node folder, that points to the library repo /dist folder (p.2) - In your main project angular.json set projects.app.architect.build.options.preserveSymlinks=true
Now the main project will be sym-linked to the library
- In the library root folder run
npm run build-watch:ang-lib. This command will re-build each time you save a modification to the project. - In your main project root folder run
ng serveorionic serve, depending on which framework you are using
When you make some change in the library, the main project will naturally reaload itself!
If your developments to the library are terminated and you want to publish them to NPM registry
- Commit your code and version your software using
npm run version:ang-lib patch|minor|major. This will create a tagged commit in your git repo - Optional: push as usual with tags(
git push && git push --tags) - Run
npm run build-publish:ang-libto generate a new compiled package and publish it to the npm registry
P.S. If you published the wrong package, run npm unpublish <@company/package>
If you don't want to develop the library, just using it inside your project
- Run
ng add @next-adv/angular-coreinside your main project - Follow the installation wizard
This module has an high level of customizability through the setConfig() static method. All settings are configurable through the installation wizard too.
- auth: it contains a map to determine what kind of object the login API expects
- restApi: it contains a map to determine REST-API endpoints
- locale: locale header (it, en etc)
For any further infos please consult the ICoreConfig interface
Since v5.2.0 the node-mock-server is available:
- Run
ng g @next-adv/angular-core:mock-server - Optionally add
--portand--mockPathparmas to it - Run
npm run mock-serverto run it - Open browser to http://localhost:port/ to see the server UI
For documentation please visit npm repo
In order to develop schematics:
- Develop inside the schematics folder
- Version using
npm run version:ang-lib patch|minor|major - Run
npm run build:ang-schemin order to build the schematic inside the dist/angolar-core/ folder - Run
npm run publish:ang-lib - In your main project folder, run
ng add @next-adv/angular-core
If you want to do all of this in only 2 commands:
- Version using
npm run version:ang-lib patch|minor|major - Run
npm run build-publish:ang-pkg
Run ng test to execute the unit tests via Karma.
To get more help on the Angular CLI use ng help or go check out the Angular CLI README.