exp-frontendlib v0.0.4
ExpFrontendlib
this lib holds the shared Components for the ExPlanner Frontend and the global styles.
import the global CSS
to import the global css in another angular app: go to 'angular.json' and edit "styles":
Configure GitLab Package Registry
Create GitLab Access Token
The access token will be needed to pull packages from our registry. To generate a Token with !api access! see AccessTokenhttps://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token save the token in keypass or so, you only see it once.
Configure npm
Setup URL for Instance Level
npm config set @artemgmbh:registry https://gitlab.com/api/v4/packages/npm/
npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_token>"
Set URL for your scoped packages.
For example package with name '@artemgmbh' will use this URL for download
npm config set @artemgmbh:registry https://gitlab.com/api/v4/projects/32890180/packages/npm/
Add the token for the scoped packages URL. Replace <your_project_id>
with the project where your package is located.
npm config set -- '//gitlab.com/api/v4/projects/32890180/packages/npm/:_authToken' "<your_token>"
build and deploy the library
Build the patched library in order to create the final dist folder
ng build <library-name>
go to your newly builded dist/libraryName folder in the terminal and excecute:
npm publish
since earlier we connected our Gitlab accesstoken to our project, we are able to publish it directly to gitlab (npm is also possible)
ExP-ApiClient
The ApiClient works a bit different than a normal Angular Library following are the steps for Generating, Building and Publishing.
Generate ApiClient
Following are the steps to generate a new version of the api client
- Get the latest api-file as yaml or json & save it as
explanner_api-docs.json
- Run the generator command either with openapi cli or .jar -
increase version parameter!
- CLI:
openapi-generator generate -g typescript-angular -i explanner_api-docs.json -o <AbsolutePathOnMaschine>/exp-frontendlib/projects/exp-apiclient
- .JAR:
java -jar openapi-generator-cli-4.3.1.jar generate -g typescript-angular -i explanner_api-docs.json -o ./projects/exp-apiclient
Necessary changes after generation
in the package.json
change following properties:
- in "publishConfig": "registry" => "@artemgmbh:registry":
- remove "license": "Unlicense" & "keywords": ... & "author": "OpenAPI-Generator Contributors",
- fix possible compile errors
Build ApiClient
npm run build:exp-apiclient
Publish ApiClient
Reminder Increase Version in package.json
! If the version is not increased npm publish will fail, because the version already exists.
Run following command in the terminal:
npm publish projects/exp-apiclient/dist
ApiClient Usage
For more information on how to use the ApiClient in Angular apps see the ReadMe in ApiClient.
Testing a Library localy
In order to test a library locally we need to create an npm link. follow the steps below to localy link the library to your project:
- Build the liblary which will be linked with the
--watch
option so the build automatically gets updated each time something changes
ng build <lib-name> --watch
- In the project which uses the library remove the lib from node-modules folder. for example:
node_modules/@artemgmbh/exp-apiclient
- Make sure the
preserveSymlinks
flag is set totrue
in theangular.json
file. - Now create the symlink to the library. In your project run following command:
npm link ../<path to dist/library/>
When the changes to library are completed. Build
and Publish
the new version of the library.
After testing the library we need to remove the symlink (The link is only for testing purpose)
- Remove the locally linked library from node-modules
- Unlink the library with
npm unlink ../<path to dist/library/>
- Update the Version of the library in
package.json
- Run
npm install
2 years ago