diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml index ea60b8e1..6b326a1f 100644 --- a/.github/workflows/ci_release.yml +++ b/.github/workflows/ci_release.yml @@ -11,6 +11,7 @@ on: options: - -- all -- - core + - date-picker - layout - list-loader - message-box @@ -37,13 +38,16 @@ env: jobs: ci_release: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 secrets: - GH_USER_NAME: 'dsi-hug-bot' - GH_USER_EMAIL: 'dsi-hug-bot@users.noreply.github.com' + GIT_USER_NAME: 'dsi-hug-bot' + GIT_USER_EMAIL: 'dsi-hug-bot@users.noreply.github.com' GH_TOKEN: ${{ secrets.DSI_HUG_BOT_GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.DSI_HUG_NPM_TOKEN }} with: working-directory: ${{ (inputs.package == '-- all --') && '.' || format('projects/{0}', inputs.package) }} dry-run: ${{ inputs.dry-run }} + lint: true + test: true + build: true release: true diff --git a/.github/workflows/ci_test_core.yml b/.github/workflows/ci_test_core.yml index 7f90aa67..be3348dc 100644 --- a/.github/workflows/ci_test_core.yml +++ b/.github/workflows/ci_test_core.yml @@ -17,11 +17,13 @@ concurrency: jobs: ci_test_core: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/core runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true # # Not needed here because it will be triggered by `ci_test_sidenav` diff --git a/.github/workflows/ci_test_date-picker.yml b/.github/workflows/ci_test_date-picker.yml new file mode 100644 index 00000000..0825a152 --- /dev/null +++ b/.github/workflows/ci_test_date-picker.yml @@ -0,0 +1,27 @@ +name: Test date-picker + +on: + workflow_dispatch: + workflow_call: + push: + branches: + - '**' + tags-ignore: + - '**' + paths: + - '.github/workflows/ci_test_date-picker.yml' + - 'projects/date-picker/**' + +concurrency: + group: ci-test-date-picker-group-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci_test_date-picker: + uses: dsi-hug/actions/.github/workflows/action.yml@v2 + with: + working-directory: projects/date-picker + runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' + node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_layout.yml b/.github/workflows/ci_test_layout.yml index 88a44b42..08980452 100644 --- a/.github/workflows/ci_test_layout.yml +++ b/.github/workflows/ci_test_layout.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_layout: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/layout runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_list-loader.yml b/.github/workflows/ci_test_list-loader.yml index d32c8df4..338bd9ba 100644 --- a/.github/workflows/ci_test_list-loader.yml +++ b/.github/workflows/ci_test_list-loader.yml @@ -17,8 +17,10 @@ concurrency: jobs: ci_test_list-loader: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/list-loader runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_message-box-dialog.yml b/.github/workflows/ci_test_message-box-dialog.yml index abc5ac67..e1a60f28 100644 --- a/.github/workflows/ci_test_message-box-dialog.yml +++ b/.github/workflows/ci_test_message-box-dialog.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_message-box-dialog: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/message-box-dialog runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_message-box.yml b/.github/workflows/ci_test_message-box.yml index c9e556cd..7df7b564 100644 --- a/.github/workflows/ci_test_message-box.yml +++ b/.github/workflows/ci_test_message-box.yml @@ -17,11 +17,13 @@ concurrency: jobs: ci_test_message-box: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/message-box runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_status: needs: ci_test_message-box diff --git a/.github/workflows/ci_test_numeric-stepper.yml b/.github/workflows/ci_test_numeric-stepper.yml index 91ec8bd0..4c9de620 100644 --- a/.github/workflows/ci_test_numeric-stepper.yml +++ b/.github/workflows/ci_test_numeric-stepper.yml @@ -18,11 +18,13 @@ concurrency: jobs: ci_test_numeric-stepper: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/numeric-stepper runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_time-picker: needs: ci_test_numeric-stepper diff --git a/.github/workflows/ci_test_overlay.yml b/.github/workflows/ci_test_overlay.yml index d57bba09..078ecd9f 100644 --- a/.github/workflows/ci_test_overlay.yml +++ b/.github/workflows/ci_test_overlay.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_overlay: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/overlay runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_search-container.yml b/.github/workflows/ci_test_search-container.yml index 78097607..7292ae17 100644 --- a/.github/workflows/ci_test_search-container.yml +++ b/.github/workflows/ci_test_search-container.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_search-container: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/search-container runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_sidenav.yml b/.github/workflows/ci_test_sidenav.yml index b95bb2ac..e4080936 100644 --- a/.github/workflows/ci_test_sidenav.yml +++ b/.github/workflows/ci_test_sidenav.yml @@ -18,11 +18,13 @@ concurrency: jobs: ci_test_sidenav: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/sidenav runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_layout: needs: ci_test_sidenav diff --git a/.github/workflows/ci_test_snackbar.yml b/.github/workflows/ci_test_snackbar.yml index da64ccdf..428e576a 100644 --- a/.github/workflows/ci_test_snackbar.yml +++ b/.github/workflows/ci_test_snackbar.yml @@ -18,11 +18,13 @@ concurrency: jobs: ci_test_snackbar: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/snackbar runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_status: needs: ci_test_snackbar diff --git a/.github/workflows/ci_test_splitter.yml b/.github/workflows/ci_test_splitter.yml index b4022808..d09c7258 100644 --- a/.github/workflows/ci_test_splitter.yml +++ b/.github/workflows/ci_test_splitter.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_splitter: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/splitter runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_status.yml b/.github/workflows/ci_test_status.yml index 463b1dbd..db4a342c 100644 --- a/.github/workflows/ci_test_status.yml +++ b/.github/workflows/ci_test_status.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_status: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/status runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_time-picker.yml b/.github/workflows/ci_test_time-picker.yml index 25c75a9d..ae0069de 100644 --- a/.github/workflows/ci_test_time-picker.yml +++ b/.github/workflows/ci_test_time-picker.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_time-picker: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/time-picker runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/.github/workflows/ci_test_tooltip.yml b/.github/workflows/ci_test_tooltip.yml index 475e4e7a..4ce8fe57 100644 --- a/.github/workflows/ci_test_tooltip.yml +++ b/.github/workflows/ci_test_tooltip.yml @@ -18,11 +18,13 @@ concurrency: jobs: ci_test_tooltip: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/tooltip runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_user-tooltip: needs: ci_test_tooltip diff --git a/.github/workflows/ci_test_user-card.yml b/.github/workflows/ci_test_user-card.yml index 51f3147d..53e34acc 100644 --- a/.github/workflows/ci_test_user-card.yml +++ b/.github/workflows/ci_test_user-card.yml @@ -18,11 +18,13 @@ concurrency: jobs: ci_test_user-card: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/user-card runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true ci_test_user-tooltip: needs: ci_test_user-card diff --git a/.github/workflows/ci_test_user-tooltip.yml b/.github/workflows/ci_test_user-tooltip.yml index 4be67a40..21c18e87 100644 --- a/.github/workflows/ci_test_user-tooltip.yml +++ b/.github/workflows/ci_test_user-tooltip.yml @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_user-tooltip: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/user-tooltip runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/DEVELOPER.md b/DEVELOPER.md index 4e251527..158bfb82 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -19,17 +19,16 @@ npm install ## Creating a new package -Create a new package using the built-in schematic tool: +1. Create a new package using the built-in schematic tool: -```sh -run run new-package -``` + ```sh + npm run new-package + ``` -If this new package has any other internal packages as peer dependencies: +2. Reorder alphabetically what was generated in `README.md` and `.github/workflows/ci_release.yml`. -- make sure that this new package is also tested during the tests of the other packages - -_(have a look at [ci_test_core.yml](https://github.com/DSI-HUG/ngx-components/blob/main/.github/workflows/ci_test_core.yml#L27-L29) for examples)_ +3. If this new package has any other internal packages as peer dependencies: + - Make sure that this new package is also tested during the tests of the other packages
_(have a look at [ci_test_core.yml](https://github.com/DSI-HUG/ngx-components/blob/main/.github/workflows/ci_test_core.yml#L27-L29) for examples)_ ## Linting/verifying source code @@ -42,7 +41,7 @@ npm run lint You can also verify it per package: ```sh -npm run lint -w=projects/ +npm run lint -w projects/ ``` ## Unit testing a package @@ -50,7 +49,7 @@ npm run lint -w=projects/ Unit testing a package can be executed with the following command: ```sh -npm run test -w=projects/ +npm run test -w projects/ ``` ## Building a package @@ -58,7 +57,7 @@ npm run test -w=projects/ Building a package can be executed with the following command: ```sh -npm run build -w=projects/ +npm run build -w projects/ ``` ## Publishing a package to NPM repository @@ -67,26 +66,26 @@ This project comes with automatic continuous delivery (CD) using _GitHub Actions To publish a package: -1. Trigger a new: [Workflow release](https://github.com/dsi-hug/ngx-components/actions/workflows/ci_release.yml) +1. Trigger a new [workflow release](https://github.com/dsi-hug/ngx-components/actions/workflows/ci_release.yml) 2. Watch the results in: [Actions](https://github.com/dsi-hug/ngx-components/actions) ### ⚠️ First release > A previous tag needs to be found to compute the next semver version. -So when you publish a package for the first time, you will have to do the following: +When you publish a package for the first time, you will have to do the following: 1. Commit and push the package, using this commit message: -```sh -feat(): first commit -``` + ```sh + feat(): first commit + ``` -2. Add a tag to the commit prior the one you just created, and push it: +2. Add a tag to the commit prior to the one you just created, and push it: -```sh -@hug/ngx-@1.0.0 -``` + ```sh + @hug/ngx-@1.0.0 + ``` 3. Trigger a new release diff --git a/README.md b/README.md index 9d4ef99f..44510c44 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ | [@hug/ngx-tooltip](/projects/tooltip) | [![npm version][npm-logo-tooltip]][npm-tooltip] | [![npm downloads][npm-dl-logo-tooltip]][npm-dl-tooltip] | [![build status][tests-logo-tooltip]][tests-tooltip] | | [@hug/ngx-user-card](/projects/user-card) | [![npm version][npm-logo-user-card]][npm-user-card] | [![npm downloads][npm-dl-logo-user-card]][npm-dl-user-card] | [![build status][tests-logo-user-card]][tests-user-card] | | [@hug/ngx-user-tooltip](/projects/user-tooltip) | [![npm version][npm-logo-user-tooltip]][npm-user-tooltip] | [![npm downloads][npm-dl-logo-user-tooltip]][npm-dl-user-tooltip] | [![build status][tests-logo-user-tooltip]][tests-user-tooltip] | +| [@hug/ngx-date-picker](/projects/date-picker) | [![npm version][npm-logo-date-picker]][npm-date-picker] | [![npm downloads][npm-dl-logo-date-picker]][npm-dl-date-picker] | [![build status][tests-logo-date-picker]][tests-date-picker] | @@ -79,6 +80,12 @@ Copyright (C) 2024 [HUG - Hôpitaux Universitaires Genève][dsi-hug] [npm-dl-logo-core]: https://img.shields.io/npm/dw/@hug/ngx-core.svg?color=7986CB&logo=npm&label=npm [tests-core]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_core.yml [tests-logo-core]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_core.yml/badge.svg +[npm-date-picker]: https://www.npmjs.com/package/@hug/ngx-date-picker +[npm-logo-date-picker]: https://img.shields.io/npm/v/@hug/ngx-date-picker.svg?color=blue&logo=npm +[npm-dl-date-picker]: https://npmcharts.com/compare/@hug/ngx-date-picker?minimal=true +[npm-dl-logo-date-picker]: https://img.shields.io/npm/dw/@hug/ngx-date-picker.svg?color=7986CB&logo=npm&label=npm +[tests-date-picker]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_date-picker.yml +[tests-logo-date-picker]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_date-picker.yml/badge.svg [npm-layout]: https://www.npmjs.com/package/@hug/ngx-layout [npm-logo-layout]: https://img.shields.io/npm/v/@hug/ngx-layout.svg?color=blue&logo=npm [npm-dl-layout]: https://npmcharts.com/compare/@hug/ngx-layout?minimal=true diff --git a/angular.json b/angular.json index 795073d9..adaa140d 100644 --- a/angular.json +++ b/angular.json @@ -588,6 +588,37 @@ } } } + }, + "date-picker": { + "projectType": "library", + "root": "projects/date-picker", + "sourceRoot": "projects/date-picker/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/date-picker/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/date-picker/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/date-picker/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/date-picker/src/test.ts", + "tsConfig": "projects/date-picker/tsconfig.spec.json", + "karmaConfig": "projects/date-picker/karma.conf.js" + } + } + } } }, "cli": { diff --git a/package-lock.json b/package-lock.json index c9a4fbdd..6b412855 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "hasInstallScript": true, "workspaces": [ "projects/core", + "projects/date-picker", "projects/layout", "projects/list-loader", "projects/message-box", @@ -3880,6 +3881,10 @@ "resolved": "projects/core", "link": true }, + "node_modules/@hug/ngx-date-picker": { + "resolved": "projects/date-picker", + "link": true + }, "node_modules/@hug/ngx-layout": { "resolved": "projects/layout", "link": true @@ -18933,6 +18938,17 @@ "rxjs": ">= 7.0.0" } }, + "projects/date-picker": { + "version": "1.0.0", + "license": "GPL-3.0-only", + "dependencies": { + "tslib": "^2.6.3" + }, + "peerDependencies": { + "@angular/common": ">= 14", + "@angular/core": ">= 14" + } + }, "projects/layout": { "name": "@hug/ngx-layout", "version": "1.1.3", diff --git a/package.json b/package.json index 0fa6c507..25acf722 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "workspaces": [ "projects/core", + "projects/date-picker", "projects/layout", "projects/list-loader", "projects/message-box", diff --git a/projects/date-picker/README.md b/projects/date-picker/README.md new file mode 100644 index 00000000..11a45730 --- /dev/null +++ b/projects/date-picker/README.md @@ -0,0 +1,5 @@ +# @hug/date-picker + +The sources for this package are in the main [DSI-HUG/ngx-components](https://github.com/dsi-hug/ngx-components) repo. Please file issues and pull requests against that repo. + +License: GPL-3.0-only diff --git a/projects/date-picker/karma.conf.js b/projects/date-picker/karma.conf.js new file mode 100644 index 00000000..d849de20 --- /dev/null +++ b/projects/date-picker/karma.conf.js @@ -0,0 +1,45 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = config => { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/date-picker'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + failOnEmptyTestSuite: false, + restartOnFileChange: true + }); +}; diff --git a/projects/date-picker/ng-package.json b/projects/date-picker/ng-package.json new file mode 100644 index 00000000..0274ba03 --- /dev/null +++ b/projects/date-picker/ng-package.json @@ -0,0 +1,8 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/date-picker", + "assets": ["CHANGELOG.md"], + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/projects/date-picker/package.json b/projects/date-picker/package.json new file mode 100644 index 00000000..560e31eb --- /dev/null +++ b/projects/date-picker/package.json @@ -0,0 +1,42 @@ +{ + "name": "@hug/ngx-date-picker", + "version": "1.0.0", + "description": "HUG Angular - date-picker component", + "homepage": "https://github.com/dsi-hug/ngx-components", + "license": "GPL-3.0-only", + "author": "HUG - Hôpitaux Universitaires Genève", + "contributors": [ + "badisi (https://github.com/badisi)", + "vapkse (https://github.com/vapkse)" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/dsi-hug/ngx-components.git" + }, + "keywords": [ + "angular", + "material", + "material design", + "components" + ], + "sideEffects": false, + "scripts": { + "lint": "eslint . --fix", + "test": "ng test date-picker", + "test:ci": "ng test date-picker --watch=false --browsers=ChromeHeadless", + "build:ng": "ng build date-picker -c=production", + "build": "nx build:ng @hug/ngx-date-picker --verbose", + "release": "nx release -p=@hug/ngx-date-picker --yes --verbose", + "release:dry-run": "nx release -p=@hug/ngx-date-picker --verbose --dry-run" + }, + "peerDependencies": { + "@angular/common": ">= 14", + "@angular/core": ">= 14" + }, + "dependencies": { + "tslib": "^2.6.3" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/projects/date-picker/src/index.ts b/projects/date-picker/src/index.ts new file mode 100644 index 00000000..e69de29b diff --git a/projects/date-picker/src/test.ts b/projects/date-picker/src/test.ts new file mode 100644 index 00000000..390c9374 --- /dev/null +++ b/projects/date-picker/src/test.ts @@ -0,0 +1,28 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js'; +import 'zone.js/testing'; + +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context: (path: string, deep?: boolean, filter?: RegExp) => { + (id: string): T; + keys: () => string[]; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); + +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().forEach(context); diff --git a/projects/date-picker/tsconfig.lib.json b/projects/date-picker/tsconfig.lib.json new file mode 100644 index 00000000..d2090cb2 --- /dev/null +++ b/projects/date-picker/tsconfig.lib.json @@ -0,0 +1,12 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": ["src/test.ts", "**/*.spec.ts"] +} diff --git a/projects/date-picker/tsconfig.lib.prod.json b/projects/date-picker/tsconfig.lib.prod.json new file mode 100644 index 00000000..560c2391 --- /dev/null +++ b/projects/date-picker/tsconfig.lib.prod.json @@ -0,0 +1,10 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/date-picker/tsconfig.spec.json b/projects/date-picker/tsconfig.spec.json new file mode 100644 index 00000000..4ed8f505 --- /dev/null +++ b/projects/date-picker/tsconfig.spec.json @@ -0,0 +1,10 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": ["jasmine"] + }, + "files": ["src/test.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/scripts/new-package/files/workspace/.github/workflows/ci_test__ciName__.yml.template b/scripts/new-package/files/workspace/.github/workflows/ci_test__ciName__.yml.template index 2551c6fc..0ff76840 100644 --- a/scripts/new-package/files/workspace/.github/workflows/ci_test__ciName__.yml.template +++ b/scripts/new-package/files/workspace/.github/workflows/ci_test__ciName__.yml.template @@ -18,8 +18,10 @@ concurrency: jobs: ci_test_<%= libName %>: - uses: dsi-hug/action/.github/workflows/action.yml@v1 + uses: dsi-hug/actions/.github/workflows/action.yml@v2 with: working-directory: projects/<%= libName %> runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + lint: true + test: true diff --git a/scripts/new-package/index.js b/scripts/new-package/index.js index 6a0f0b2a..c5955df1 100644 --- a/scripts/new-package/index.js +++ b/scripts/new-package/index.js @@ -1,6 +1,24 @@ const { schematic, spawn, replaceInFile, workspace, modifyJsonFile, library, createOrUpdateFile } = require('@hug/ngx-schematics-utilities'); const { noop } = require('@angular-devkit/schematics'); +const scheduledTasks = {}; +const runAtEnd = cb => + (tree, context) => { + const name = `__task_${Object.keys(scheduledTasks).length}__`; + + // Register the task + if (!scheduledTasks[name]) { + context.engine._host.registerTaskExecutor({ + name, create: async () => new Promise(resolve => resolve(() => Promise.resolve(cb(tree, context)))) + }); + } else { + throw new Error(`Task with name '${name}' already registered.`); + } + + // Schedule the task + scheduledTasks[name] = context.addTask({ toConfiguration: () => ({ name }) }, Object.values(scheduledTasks)); + }; + exports.default = options => schematic('new-package', [ spawn('ng', ['g', 'library', options.libName]), @@ -32,7 +50,8 @@ exports.default = options => paths[`@hug/ngx-${options.libName.toLowerCase()}`] = [ `projects/${options.libName.toLowerCase()}/src` ]; - return modifyJsonFile('tsconfig.json', ['compilerOptions', 'paths'], paths); + const sortedPaths = Object.fromEntries(Object.entries(paths).sort()); + return modifyJsonFile('tsconfig.json', ['compilerOptions', 'paths'], sortedPaths); }) // modify tsconfig.base.json @@ -41,7 +60,8 @@ exports.default = options => paths[`@hug/ngx-${options.libName.toLowerCase()}`] = [ `dist/${options.libName.toLowerCase()}` ]; - return modifyJsonFile('tsconfig.base.json', ['compilerOptions', 'paths'], paths); + const sortedPaths = Object.fromEntries(Object.entries(paths).sort()); + return modifyJsonFile('tsconfig.base.json', ['compilerOptions', 'paths'], sortedPaths); }) // modify package.json @@ -50,6 +70,7 @@ exports.default = options => const value = `projects/${options.libName.toLowerCase()}`; if (!workspaces.includes(value)) { workspaces.push(value); + workspaces.sort(); return modifyJsonFile('package.json', ['workspaces'], workspaces); } return noop(); @@ -97,5 +118,9 @@ exports.default = options => // delete `lib` folder .deleteFiles(['__SRC__/lib'], true) - .toRule() + .toRule(), + + // Update `package-lock.json` + runAtEnd(spawn('npm', ['install'])) + ], options); diff --git a/tsconfig.base.json b/tsconfig.base.json index f0ab1c37..fdfb0c0a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -20,6 +20,7 @@ "lib": ["es2020", "dom"], "paths": { "@hug/ngx-core": ["dist/core"], + "@hug/ngx-date-picker": ["dist/date-picker"], "@hug/ngx-layout": ["dist/layout"], "@hug/ngx-list-loader": ["dist/list-loader"], "@hug/ngx-message-box": ["dist/message-box"], diff --git a/tsconfig.json b/tsconfig.json index 5236e570..e2947328 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "paths": { "@hug/ngx-core": ["projects/core/src"], + "@hug/ngx-date-picker": ["projects/date-picker/src"], "@hug/ngx-layout": ["projects/layout/src"], "@hug/ngx-list-loader": ["projects/list-loader/src"], "@hug/ngx-message-box": ["projects/message-box/src"],