This project was generated with Angular CLI version 16.0.2. This package is a library of common Angular tools intended for use in the BCParks Digital Services branch.
To contribute to this library, fork the main repository and push contributrions to your fork. Create PRs to merge with the main repository from your fork.
To create a new release of the library on npm, create a Github release. Ensure the version tag is valid semver, ie v1.2.3.
The Publish to NPM Github Action will automatically publish the library to @digitalspace/ngds-toolkit: https://www.npmjs.com/package/@digitalspace/ngds-toolkit
To develop for this library locally, it helps to run a separate project that uses the library as a dependency to test how the library is consumed. You cannot run library components on their own.
- Clone the library and a dependent project to your workspace.
- Navigate to your library root folder and run
yarn buildat least once. This will generate the/distfolder. - Navigate to
/dist/ngds-toolkit/now that the/distfolder has been created. - Run
yarn linkto generate a symlink to@digitalspace/ngds-toolkit - Navigate back to the root folder of the library project and run
yarn build --watch. This will build the library to the dist folder with every change. - Navigate to the dependent project root folder and run
yarn link @digitalspace/ngds-toolkit. This will link the local version of the library to yournode_modules. - Run
yarn add @digitalspace/ngds-toolkitto install the local library. - Ensure
preserveSymlinks: truehas been added toangular.jsonof the dependent project.
"architect": {
...
"build": {
...
"options": {
...
"preserveSymlinks": true,
- Run
yarn startfrom the dependent project's root folder. If done correctly, any local changes to the library will be reflected in the project, though a page refresh is necessary for them to take effect. Theauto-reloadfeature of Angular does not work the same as it does for changes to the dependent project - probably because no files within the project actually change when the library is updated.
You can force the auto-reload behaviour by adding the paths object to the tsconfig.json file in the dependent project. Note: this change is unaffected by symlinks and will break the dependent project if it is committed and used outside the local environment.
in tsconfig.json:
{
"compilerOptions": {
...
"paths": {
"@digitalspace/ngds-toolkit": [
"<relative-path-to-library>"
],
"@angular/*": [
"./node_modules/@angular/*"
]
...
},
}
}
where <relative-path-to-library> might look like this: "../ngds-toolkit/dist/ngds-toolkit".
To switch from local library to npm package, follow these steps:
- Break the symlink in your dependent project by running
yarn unlink @digitalspace/ngds-toolkit. - Uninstall your local version of the library by running
yarn remove @digitalspace/ngds-toolkit. - Install from npm by running
yarn add @digitalspace/ngds-toolkit
Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.
Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory.
Run ng test to execute the unit tests via Karma.
Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.