diff --git a/README.md b/README.md index 71054834b985bca1e4a48853154ec2410222acdf..d96976dad98664d8a8bbf92fb7bd6bfca8a93b6c 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,14 @@ This project can be published as an npm package to our npm registry which can then be used in Piveau based projects to import the required parts. +## Module development + +We are developing an npm package named `@piveau/piveau-hub-ui-modules` Component development takes place in the `src/modules` folder and -all importable components should be exported from there. -The rest of the source code is a test app, which is a copy of Data Europa +all components that should be part of our npm package must be +exported from there. + +The rest of the source code (outside `src/modules`) is a test app, which is a copy of Data Europa Piveau-Hub-UI and can be run with `npm run serve`. The basic idea is to take parts from the test app and isolate them in `src/modules`, then import them back into the test app just like you would from the published package: @@ -20,9 +25,18 @@ The workflow is as follows: * Develop your component in `src/modules` * Export the component in `src/modules/index.js` - * Import the component in the test app - * run `npm run build:lib`. This creates a compiled version of the modules folder in `dist`. It also file-copies the result into `node_modules` so the import into the test app works. - * When a new version should be published, increase the version number in `package.json` and run `npm publish` (you have to be logged into our paca npm registry) + * Import the component in the test app from `@piveau/piveau-hub-ui-modules` + * When a new version should be published, increase the version number in `package.json` and run `npm run deploy` (you have to be logged into our paca npm registry) + +In order for imports from `@piveau/piveau-hub-ui-modules` in the test-app to work, that package must be accessible in the node_modules folder. +There are two ways to get achieve this: + + 1. A simple `npm install` takes the dependency from package.json and creates a symlink to the `src/modules` folder in node_modules. + 2. Executing `npm run localdeploy` creates a compiled version of the modules folder in `dist` and copies it into node_modules`. + +The advantage of option 2 is that the package in node_modules is exactly the same as the published version will be. +However development with that option requires repeated `npm run build` to update the package for the test-app. +Option 1 does not require rebuilding so the development experience is simpler and faster. ## Project setup ``` @@ -36,7 +50,18 @@ npm run serve ### Compiling modules ``` -npm run build:lib +npm run build +``` + +or to also add a copy of the compiled modules in node_modules: + +``` +npm run localdeploy +``` + +### Publishing modules +``` +npm run deploy ``` ### Run your unit tests diff --git a/package-lock.json b/package-lock.json index 99e5a175b660b986d9e62804a974fec9641ee88f..b86a512120e8df512bae9b842c3dfd8c81935007 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@piveau/piveau-hub-ui-modules", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@piveau/piveau-hub-ui-modules", - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "@braid/vue-formulate": "^2.5.3", "@citation-js/core": "^0.5.7", @@ -21,7 +21,7 @@ "@fortawesome/free-solid-svg-icons": "^5.3.1", "@fortawesome/vue-fontawesome": "^0.1.1", "@piveau/dcatap-frontend": "^2.5.0", - "@piveau/piveau-hub-ui-modules": "^0.1.0", + "@piveau/piveau-hub-ui-modules": "file:./src/modules", "@piveau/piveau-universal-piwik": "^2.3.0", "@triply/yasgui": "^4.2.25", "@triply/yasqe": "^4.2.23", @@ -3181,15 +3181,8 @@ } }, "node_modules/@piveau/piveau-hub-ui-modules": { - "version": "0.1.0", - "resolved": "https://paca.fokus.fraunhofer.de/repository/npm-hosted/@piveau/piveau-hub-ui-modules/-/piveau-hub-ui-modules-0.1.0.tgz", - "integrity": "sha512-WMGrzhtYfxnQJruFvbwUF2glyc1ZuJoIu9RmFP1wh1tILrlAlAhdHLyQ8ffaC+1DonTu+ydzGbXi6uFSdv8JeA==", - "dependencies": { - "core-js": "^3.8.3", - "vue": "^2.6.14", - "vue-router": "^3.5.1", - "vuex": "^3.6.2" - } + "resolved": "src/modules", + "link": true }, "node_modules/@piveau/piveau-universal-piwik": { "version": "2.3.0", @@ -19152,7 +19145,8 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true - } + }, + "src/modules": {} }, "dependencies": { "@achrinza/node-ipc": { @@ -21357,15 +21351,7 @@ } }, "@piveau/piveau-hub-ui-modules": { - "version": "0.1.0", - "resolved": "https://paca.fokus.fraunhofer.de/repository/npm-hosted/@piveau/piveau-hub-ui-modules/-/piveau-hub-ui-modules-0.1.0.tgz", - "integrity": "sha512-WMGrzhtYfxnQJruFvbwUF2glyc1ZuJoIu9RmFP1wh1tILrlAlAhdHLyQ8ffaC+1DonTu+ydzGbXi6uFSdv8JeA==", - "requires": { - "core-js": "^3.8.3", - "vue": "^2.6.14", - "vue-router": "^3.5.1", - "vuex": "^3.6.2" - } + "version": "file:src/modules" }, "@piveau/piveau-universal-piwik": { "version": "2.3.0", diff --git a/package.json b/package.json index c6e6ee9314e4b8e4084b642d0250509733cf9ac5..bd7089ccff04577a6aec2f6643f01763bad38291 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,15 @@ { "name": "@piveau/piveau-hub-ui-modules", - "version": "0.1.0", + "version": "0.1.1", "files": [ "dist/*" ], "main": "./dist/piveau-hub-ui-modules.umd.min.js", "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "build:lib": "export BUILD_MODE=lib && node ./localuninstall.js && vue-cli-service build --target lib --name piveau-hub-ui-modules src/modules/index.ts && node ./localinstall.js && unset BUILD_MODE", + "build": "export BUILD_MODE=lib && vue-cli-service build --target lib --name piveau-hub-ui-modules src/modules/index.ts && unset BUILD_MODE", + "localdeploy": "node ./localuninstall.js && npm run build && node ./localinstall.js", + "deploy": "npm run build && npm publish", "test:unit": "vue-cli-service test:unit", "test:e2e": "vue-cli-service test:e2e", "lint": "vue-cli-service lint" @@ -28,6 +29,7 @@ "@fortawesome/vue-fontawesome": "^0.1.1", "@piveau/dcatap-frontend": "^2.5.0", "@piveau/piveau-universal-piwik": "^2.3.0", + "@piveau/piveau-hub-ui-modules": "file:./src/modules", "@triply/yasgui": "^4.2.25", "@triply/yasqe": "^4.2.23", "@triply/yasr": "^4.2.25", diff --git a/src/components/Datasets.vue b/src/components/Datasets.vue index 8bfe00fee231d65862cfcee3b15422e0513b8f60..d060771dcc31be214d2d510ef2f0dd16d7aefa36 100644 --- a/src/components/Datasets.vue +++ b/src/components/Datasets.vue @@ -244,9 +244,8 @@ import DatasetFacets from './DatasetFacets'; import DataInfoBox from './DataInfoBox'; import Pagination from './Pagination'; - import { AppLink, SubNavigation } from "@piveau/piveau-hub-ui-modules"; import SelectedFacetsOverview from './SelectedFacetsOverview'; - import { helpers } from '@piveau/piveau-hub-ui-modules'; + import { AppLink, SubNavigation, helpers } from "@piveau/piveau-hub-ui-modules"; const { getTranslationFor, truncate } = helpers; export default { diff --git a/vue.config.js b/vue.config.js index d724eec9b57eeb68a758c8bb6dcb803e7500615b..306ba319a683ee830fbecb40c6815e28afeeedd5 100644 --- a/vue.config.js +++ b/vue.config.js @@ -42,7 +42,7 @@ module.exports = defineConfig({ } ); - // Declare all package.json dependencies as external (i.e. "peer dependencies") when we run build:lib + // Declare all package.json dependencies as external (i.e. "peer dependencies") when we run the build script if (process.env.BUILD_MODE === 'lib') { const dependencyKeys = Object.keys(package.dependencies); const dependenciesObject = dependencyKeys.reduce((acc, curr) => {