From c8e861907d87b85e349b62890fc1aac3f962acbc Mon Sep 17 00:00:00 2001 From: Bartosz Sekula Date: Tue, 31 Jan 2023 15:35:51 +0100 Subject: [PATCH] [AAE-11496] Publish aca-viewer and aca-preview (#2945) * [AAE-11496] Publish aca-viewer and aca-preview * fix tests --- .github/workflows/test.yml | 18 +++ angular.json | 86 ++++++++++++ package.json | 2 +- .../aca-content/src/lib/aca-content.module.ts | 2 +- .../aca-content/src/lib/aca-content.routes.ts | 57 ++++---- projects/aca-preview/.eslintrc.json | 121 +++++++++++++++++ projects/aca-preview/README.md | 24 ++++ projects/aca-preview/karma.conf.js | 32 +++++ projects/aca-preview/ng-package.json | 7 + projects/aca-preview/package.json | 14 ++ .../lib/components}/preview.component.html | 0 .../lib/components}/preview.component.scss | 0 .../lib/components}/preview.component.spec.ts | 123 ++++++++++++++++-- .../src/lib/components}/preview.component.ts | 5 +- .../src/lib}/preview.module.ts | 17 ++- projects/aca-preview/src/public-api.ts | 6 + projects/aca-preview/src/test.ts | 25 ++++ projects/aca-preview/tsconfig.lib.json | 15 +++ projects/aca-preview/tsconfig.lib.prod.json | 14 ++ projects/aca-preview/tsconfig.spec.json | 17 +++ projects/aca-viewer/.eslintrc.json | 121 +++++++++++++++++ projects/aca-viewer/README.md | 24 ++++ projects/aca-viewer/karma.conf.js | 32 +++++ projects/aca-viewer/ng-package.json | 7 + projects/aca-viewer/package.json | 14 ++ .../components/viewer/viewer.component.html | 0 .../components/viewer/viewer.component.scss | 0 .../lib/components/viewer/viewer.component.ts | 4 +- .../src/lib}/viewer.module.ts | 28 ++-- projects/aca-viewer/src/public-api.ts | 6 + projects/aca-viewer/src/test.ts | 25 ++++ projects/aca-viewer/tsconfig.lib.json | 15 +++ projects/aca-viewer/tsconfig.lib.prod.json | 14 ++ projects/aca-viewer/tsconfig.spec.json | 17 +++ scripts/ci/npm/publish-libs.sh | 2 + tsconfig.adf.json | 2 + tsconfig.json | 10 +- 37 files changed, 832 insertions(+), 74 deletions(-) create mode 100644 projects/aca-preview/.eslintrc.json create mode 100644 projects/aca-preview/README.md create mode 100644 projects/aca-preview/karma.conf.js create mode 100644 projects/aca-preview/ng-package.json create mode 100644 projects/aca-preview/package.json rename projects/{aca-content/src/lib/components/preview => aca-preview/src/lib/components}/preview.component.html (100%) rename projects/{aca-content/src/lib/components/preview => aca-preview/src/lib/components}/preview.component.scss (100%) rename projects/{aca-content/src/lib/components/preview => aca-preview/src/lib/components}/preview.component.spec.ts (86%) rename projects/{aca-content/src/lib/components/preview => aca-preview/src/lib/components}/preview.component.ts (98%) rename projects/{aca-content/src/lib/components/preview => aca-preview/src/lib}/preview.module.ts (80%) create mode 100644 projects/aca-preview/src/public-api.ts create mode 100644 projects/aca-preview/src/test.ts create mode 100644 projects/aca-preview/tsconfig.lib.json create mode 100644 projects/aca-preview/tsconfig.lib.prod.json create mode 100644 projects/aca-preview/tsconfig.spec.json create mode 100644 projects/aca-viewer/.eslintrc.json create mode 100644 projects/aca-viewer/README.md create mode 100644 projects/aca-viewer/karma.conf.js create mode 100644 projects/aca-viewer/ng-package.json create mode 100644 projects/aca-viewer/package.json rename projects/{aca-content => aca-viewer}/src/lib/components/viewer/viewer.component.html (100%) rename projects/{aca-content => aca-viewer}/src/lib/components/viewer/viewer.component.scss (100%) rename projects/{aca-content => aca-viewer}/src/lib/components/viewer/viewer.component.ts (99%) rename projects/{aca-content/src/lib/components/viewer => aca-viewer/src/lib}/viewer.module.ts (73%) create mode 100644 projects/aca-viewer/src/public-api.ts create mode 100644 projects/aca-viewer/src/test.ts create mode 100644 projects/aca-viewer/tsconfig.lib.json create mode 100644 projects/aca-viewer/tsconfig.lib.prod.json create mode 100644 projects/aca-viewer/tsconfig.spec.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dadc4143b..0046f4b8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,3 +130,21 @@ jobs: cache: 'npm' - run: npm ci - run: npm test aca-folder-rules -- --browsers=ChromeHeadless --watch=false $TEST_OPTS + + test-aca-preview: + needs: [lint, build] + name: 'test: aca-preview' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: node + uses: actions/setup-node@v3 + with: + node-version: 14 + cache: 'npm' + - run: npm ci + - run: npm test aca-preview -- --browsers=ChromeHeadless --watch=false $TEST_OPTS diff --git a/angular.json b/angular.json index 18e1be87e..57ebe43dd 100644 --- a/angular.json +++ b/angular.json @@ -645,6 +645,92 @@ } } } + }, + "aca-viewer": { + "projectType": "library", + "root": "projects/aca-viewer", + "sourceRoot": "projects/aca-viewer/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/aca-viewer/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/aca-viewer/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/aca-viewer/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/aca-viewer/src/test.ts", + "tsConfig": "projects/aca-viewer/tsconfig.spec.json", + "karmaConfig": "projects/aca-viewer/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": [ + "projects/aca-viewer/**/*.ts", + "projects/aca-viewer/**/*.html" + ], + "cache": true, + "cacheLocation": ".eslintcache", + "ignorePath": ".eslintignore" + } + } + } + }, + "aca-preview": { + "projectType": "library", + "root": "projects/aca-preview", + "sourceRoot": "projects/aca-preview/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/aca-preview/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/aca-preview/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/aca-preview/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/aca-preview/src/test.ts", + "tsConfig": "projects/aca-preview/tsconfig.spec.json", + "karmaConfig": "projects/aca-preview/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": [ + "projects/aca-preview/**/*.ts", + "projects/aca-preview/**/*.html" + ], + "cache": true, + "cacheLocation": ".eslintcache", + "ignorePath": ".eslintignore" + } + } + } } }, "schematics": { diff --git a/package.json b/package.json index da5284b54..d1ad25596 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "prebuild": "mkdir -p ./app/.tmp && cp ./app/src/app.config.json.tpl ./app/.tmp/app.config.json", "build": "ng build content-ce", "build.release": "npm run build -- --configuration=production,release", - "build-libs": "ng build aca-shared && ng build adf-office-services-ext && ng build aca-settings && ng build aca-about ", + "build-libs": "ng build aca-shared && ng build adf-office-services-ext && ng build aca-settings && ng build aca-about && ng build aca-viewer && ng build aca-preview", "test": "ng test", "test:ci": "ng test adf-office-services-ext && ng test content-ce --code-coverage", "lint": "NODE_OPTIONS=--max_old_space_size=4096 ng lint && npm run spellcheck && npm run e2e.typecheck", diff --git a/projects/aca-content/src/lib/aca-content.module.ts b/projects/aca-content/src/lib/aca-content.module.ts index 6a1a68ccd..5a15302bb 100644 --- a/projects/aca-content/src/lib/aca-content.module.ts +++ b/projects/aca-content/src/lib/aca-content.module.ts @@ -104,7 +104,7 @@ import { CommentsTabComponent } from './components/info-drawer/comments-tab/comm import { LibraryMetadataTabComponent } from './components/info-drawer/library-metadata-tab/library-metadata-tab.component'; import { MetadataTabComponent } from './components/info-drawer/metadata-tab/metadata-tab.component'; import { VersionsTabComponent } from './components/info-drawer/versions-tab/versions-tab.component'; -import { PreviewComponent } from './components/preview/preview.component'; +import { PreviewComponent } from '@alfresco/aca-preview'; import { DocumentDisplayModeComponent } from './components/toolbar/document-display-mode/document-display-mode.component'; import { ToggleEditOfflineComponent } from './components/toolbar/toggle-edit-offline/toggle-edit-offline.component'; import { ToggleFavoriteLibraryComponent } from './components/toolbar/toggle-favorite-library/toggle-favorite-library.component'; diff --git a/projects/aca-content/src/lib/aca-content.routes.ts b/projects/aca-content/src/lib/aca-content.routes.ts index 92140c037..3ad2ae8c7 100644 --- a/projects/aca-content/src/lib/aca-content.routes.ts +++ b/projects/aca-content/src/lib/aca-content.routes.ts @@ -67,7 +67,7 @@ export const CONTENT_ROUTES: ExtensionRoute[] = [ children: [ { path: '', - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -123,7 +123,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -137,7 +137,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'personal-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -150,7 +150,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'personal-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -176,14 +176,14 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'personal-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -191,7 +191,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: ':folderId/preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -205,7 +205,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'personal-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -238,7 +238,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'libraries' } @@ -252,9 +252,12 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'libraries' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } - ] + ], + data: { + navigateSource: 'libraries' + } }, { path: 'view/:nodeId/:versionId', @@ -265,7 +268,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'libraries' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -309,7 +312,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'libraries' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -322,7 +325,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'libraries' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -347,7 +350,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'favorites' } @@ -361,7 +364,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'favorites' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -374,7 +377,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'favorites' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -398,7 +401,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'recent-files' } @@ -412,7 +415,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'recent-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -425,7 +428,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'recent-files' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -447,7 +450,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'shared' } @@ -461,7 +464,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'shared' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -474,7 +477,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'shared' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -499,7 +502,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), + loadChildren: () => import('@alfresco/aca-preview').then((m) => m.PreviewModule), data: { navigateSource: 'search' } @@ -513,7 +516,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'search' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] }, @@ -526,7 +529,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'search' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } @@ -551,7 +554,7 @@ export const CONTENT_LAYOUT_ROUTES: Route = { data: { navigateSource: 'search' }, - loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) + loadChildren: () => import('@alfresco/aca-viewer').then((m) => m.AcaViewerModule) } ] } diff --git a/projects/aca-preview/.eslintrc.json b/projects/aca-preview/.eslintrc.json new file mode 100644 index 000000000..86cf9693a --- /dev/null +++ b/projects/aca-preview/.eslintrc.json @@ -0,0 +1,121 @@ +{ + "extends": "../../.eslintrc.json", + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "projects/aca-preview/tsconfig.lib.json", + "projects/aca-preview/tsconfig.spec.json" + ], + "createDefaultProgram": true + }, + "plugins": [ + "eslint-plugin-rxjs", + "eslint-plugin-unicorn" + ], + "rules": { + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": [ + "lib", + "aca", + "app", + "adf" + ], + "style": "kebab-case" + } + ], + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": [ + "lib", + "aca", + "app", + "adf" + ], + "style": "camelCase" + } + ], + "@angular-eslint/no-host-metadata-property": "off", + "@typescript-eslint/consistent-type-definitions": "error", + "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/explicit-member-accessibility": [ + "off", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/member-delimiter-style": [ + "off", + { + "multiline": { + "delimiter": "none", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": false + } + } + ], + "@typescript-eslint/semi": [ + "off", + null + ], + "@typescript-eslint/type-annotation-spacing": "off", + "arrow-parens": [ + "off", + "always" + ], + "brace-style": [ + "off", + "off" + ], + "eol-last": "off", + "id-blacklist": "off", + "id-match": "off", + "linebreak-style": "off", + "max-len": "off", + "new-parens": "off", + "newline-per-chained-call": "off", + "no-duplicate-imports": "error", + "no-extra-semi": "off", + "no-irregular-whitespace": "off", + "no-return-await": "error", + "no-underscore-dangle": "off", + "quote-props": "off", + "rxjs/no-create": "error", + "rxjs/no-subject-unsubscribe": "error", + "rxjs/no-subject-value": "error", + "rxjs/no-unsafe-takeuntil": "error", + "space-before-function-paren": "off", + "space-in-parens": [ + "off", + "never" + ], + "unicorn/filename-case": "error" + } + }, + { + "files": [ + "*.html" + ], + "rules": { + "@angular-eslint/template/no-autofocus": "error", + "@angular-eslint/template/no-negated-async": "off", + "@angular-eslint/template/no-positive-tabindex": "error", + "@angular-eslint/template/eqeqeq": "error" + } + } + ] +} diff --git a/projects/aca-preview/README.md b/projects/aca-preview/README.md new file mode 100644 index 000000000..40df16377 --- /dev/null +++ b/projects/aca-preview/README.md @@ -0,0 +1,24 @@ +# AcaPreview + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.1.0. + +## Code scaffolding + +Run `ng generate component component-name --project aca-preview` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project aca-preview`. +> Note: Don't forget to add `--project aca-preview` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build aca-preview` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build aca-preview`, go to the dist folder `cd dist/aca-preview` and run `npm publish`. + +## Running unit tests + +Run `ng test aca-preview` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. diff --git a/projects/aca-preview/karma.conf.js b/projects/aca-preview/karma.conf.js new file mode 100644 index 000000000..0e1dfce09 --- /dev/null +++ b/projects/aca-preview/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (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-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/aca-settings'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: true, + restartOnFileChange: true + }); +}; diff --git a/projects/aca-preview/ng-package.json b/projects/aca-preview/ng-package.json new file mode 100644 index 000000000..9ccc65576 --- /dev/null +++ b/projects/aca-preview/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/@alfresco/aca-preview", + "lib": { + "entryFile": "src/public-api.ts" + } +} diff --git a/projects/aca-preview/package.json b/projects/aca-preview/package.json new file mode 100644 index 000000000..8aa61f906 --- /dev/null +++ b/projects/aca-preview/package.json @@ -0,0 +1,14 @@ +{ + "name": "@alfresco/aca-preview", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^14.1.0", + "@angular/core": "^14.1.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/projects/aca-content/src/lib/components/preview/preview.component.html b/projects/aca-preview/src/lib/components/preview.component.html similarity index 100% rename from projects/aca-content/src/lib/components/preview/preview.component.html rename to projects/aca-preview/src/lib/components/preview.component.html diff --git a/projects/aca-content/src/lib/components/preview/preview.component.scss b/projects/aca-preview/src/lib/components/preview.component.scss similarity index 100% rename from projects/aca-content/src/lib/components/preview/preview.component.scss rename to projects/aca-preview/src/lib/components/preview.component.scss diff --git a/projects/aca-content/src/lib/components/preview/preview.component.spec.ts b/projects/aca-preview/src/lib/components/preview.component.spec.ts similarity index 86% rename from projects/aca-content/src/lib/components/preview/preview.component.spec.ts rename to projects/aca-preview/src/lib/components/preview.component.spec.ts index 26cdc75e2..e57db1007 100644 --- a/projects/aca-content/src/lib/components/preview/preview.component.spec.ts +++ b/projects/aca-preview/src/lib/components/preview.component.spec.ts @@ -25,17 +25,78 @@ import { Router, ActivatedRoute } from '@angular/router'; import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; -import { UserPreferencesService, UploadService, NodesApiService } from '@alfresco/adf-core'; -import { ClosePreviewAction } from '@alfresco/aca-shared/store'; +import { + UserPreferencesService, + UploadService, + NodesApiService, + AlfrescoApiService, + AlfrescoApiServiceMock, + AuthenticationService, + DiscoveryApiService, + TranslationMock, + TranslationService, + PipeModule +} from '@alfresco/adf-core'; +import { AppState, ClosePreviewAction } from '@alfresco/aca-shared/store'; import { PreviewComponent } from './preview.component'; -import { of, throwError } from 'rxjs'; +import { BehaviorSubject, Observable, of, throwError } from 'rxjs'; +import { ContentApiService, AppHookService, TranslateServiceMock, DocumentBasePageService } from '@alfresco/aca-shared'; +import { Store, StoreModule } from '@ngrx/store'; +import { Node, NodePaging, FavoritePaging, SharedLinkPaging, PersonEntry, ResultSetPaging, RepositoryInfo, NodeEntry } from '@alfresco/js-api'; +import { PreviewModule } from '../preview.module'; +import { TranslateService } from '@ngx-translate/core'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpClientModule } from '@angular/common/http'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { EffectsModule } from '@ngrx/effects'; -import { NodeEffects } from '../../store/effects/node.effects'; -import { AppTestingModule } from '../../testing/app-testing.module'; -import { ContentApiService, AppHookService } from '@alfresco/aca-shared'; -import { Store } from '@ngrx/store'; -import { Node, NodePaging, FavoritePaging, SharedLinkPaging, PersonEntry, ResultSetPaging } from '@alfresco/js-api'; -import { PreviewModule } from './preview.module'; + +class DocumentBasePageServiceMock extends DocumentBasePageService { + canUpdateNode(_node: NodeEntry): boolean { + return true; + } + canUploadContent(_node: Node): boolean { + return true; + } +} + +export const INITIAL_APP_STATE: AppState = { + appName: 'Alfresco Content Application', + headerColor: '#ffffff', + headerTextColor: '#000000', + logoPath: 'assets/images/alfresco-logo-white.svg', + headerImagePath: 'assets/images/mastHead-bg-shapesPattern.svg', + customCssPath: '', + webFontPath: '', + sharedUrl: '', + user: { + isAdmin: null, + id: null, + firstName: '', + lastName: '' + }, + selection: { + nodes: [], + libraries: [], + isEmpty: true, + count: 0 + }, + navigation: { + currentFolder: null + }, + currentNodeVersion: null, + infoDrawerOpened: false, + infoDrawerPreview: false, + infoDrawerMetadataAspect: '', + showFacetFilter: true, + fileUploadingDialog: true, + documentDisplayMode: 'list', + showLoader: false, + repository: { + status: { + isQuickShareEnabled: true + } + } as any +}; describe('PreviewComponent', () => { let fixture: ComponentFixture; @@ -51,7 +112,49 @@ describe('PreviewComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [EffectsModule.forRoot([NodeEffects]), PreviewModule, AppTestingModule] + imports: [ + PreviewModule, + NoopAnimationsModule, + HttpClientModule, + RouterTestingModule, + StoreModule.forRoot( + { app: (state) => state }, + { + initialState: { + app: INITIAL_APP_STATE + }, + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + } + ), + EffectsModule.forRoot([]), + PipeModule + ], + providers: [ + { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, + { provide: TranslationService, useClass: TranslationMock }, + { provide: TranslateService, useClass: TranslateServiceMock }, + { provide: DocumentBasePageService, useVale: new DocumentBasePageServiceMock() }, + { + provide: DiscoveryApiService, + useValue: { + ecmProductInfo$: new BehaviorSubject(null), + getEcmProductInfo: (): Observable => of(new RepositoryInfo({ version: '10.0.0' })) + } + }, + { + provide: AuthenticationService, + useValue: { + isEcmLoggedIn: (): boolean => true, + getRedirect: (): string | null => null, + setRedirect() {}, + isOauth: (): boolean => false, + isOAuthWithoutSilentLogin: (): boolean => false + } + } + ] }); fixture = TestBed.createComponent(PreviewComponent); diff --git a/projects/aca-content/src/lib/components/preview/preview.component.ts b/projects/aca-preview/src/lib/components/preview.component.ts similarity index 98% rename from projects/aca-content/src/lib/components/preview/preview.component.ts rename to projects/aca-preview/src/lib/components/preview.component.ts index 43059d4c3..88ce95277 100644 --- a/projects/aca-content/src/lib/components/preview/preview.component.ts +++ b/projects/aca-preview/src/lib/components/preview.component.ts @@ -30,8 +30,7 @@ import { debounceTime, map, takeUntil } from 'rxjs/operators'; import { UserPreferencesService, ObjectUtils, UploadService, NodesApiService } from '@alfresco/adf-core'; import { Store } from '@ngrx/store'; import { AppStore, ClosePreviewAction, ViewerActionTypes, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; -import { AppExtensionService, AppHookService, ContentApiService, PageComponent } from '@alfresco/aca-shared'; -import { ContentManagementService } from '../../services/content-management.service'; +import { PageComponent, AppExtensionService, AppHookService, ContentApiService, DocumentBasePageService } from '@alfresco/aca-shared'; import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions'; import { SearchRequest } from '@alfresco/js-api'; import { from } from 'rxjs'; @@ -97,7 +96,7 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy private location: Location, store: Store, extensions: AppExtensionService, - content: ContentManagementService, + content: DocumentBasePageService, private appHookService: AppHookService ) { super(store, extensions, content); diff --git a/projects/aca-content/src/lib/components/preview/preview.module.ts b/projects/aca-preview/src/lib/preview.module.ts similarity index 80% rename from projects/aca-content/src/lib/components/preview/preview.module.ts rename to projects/aca-preview/src/lib/preview.module.ts index 80f879c53..7477ca7a1 100644 --- a/projects/aca-content/src/lib/components/preview/preview.module.ts +++ b/projects/aca-preview/src/lib/preview.module.ts @@ -28,11 +28,9 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { ContentDirectiveModule } from '@alfresco/adf-content-services'; -import { CoreExtensionsModule } from '../../extensions/core.extensions.module'; -import { DirectivesModule } from '../../directives/directives.module'; -import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; -import { PreviewComponent } from './preview.component'; -import { AppToolbarModule } from '../toolbar/toolbar.module'; +import { SharedDirectivesModule, SharedToolbarModule, SharedInfoDrawerModule } from '@alfresco/aca-shared'; +import { ExtensionsModule } from '@alfresco/adf-extensions'; +import { PreviewComponent } from './components/preview.component'; const routes: Routes = [ { @@ -50,11 +48,12 @@ const routes: Routes = [ CommonModule, RouterModule.forChild(routes), CoreModule.forChild(), + ExtensionsModule, ContentDirectiveModule, - DirectivesModule, - AppInfoDrawerModule, - CoreExtensionsModule.forChild(), - AppToolbarModule + SharedDirectivesModule, + ContentDirectiveModule, + SharedInfoDrawerModule, + SharedToolbarModule ], declarations: [PreviewComponent], exports: [PreviewComponent] diff --git a/projects/aca-preview/src/public-api.ts b/projects/aca-preview/src/public-api.ts new file mode 100644 index 000000000..4a96fd7f3 --- /dev/null +++ b/projects/aca-preview/src/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of aca-preview + */ + +export * from './lib/components/preview.component'; +export * from './lib/preview.module'; diff --git a/projects/aca-preview/src/test.ts b/projects/aca-preview/src/test.ts new file mode 100644 index 000000000..59f2f3c78 --- /dev/null +++ b/projects/aca-preview/src/test.ts @@ -0,0 +1,25 @@ +// 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/aca-preview/tsconfig.lib.json b/projects/aca-preview/tsconfig.lib.json new file mode 100644 index 000000000..b77b13c01 --- /dev/null +++ b/projects/aca-preview/tsconfig.lib.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/projects/aca-preview/tsconfig.lib.prod.json b/projects/aca-preview/tsconfig.lib.prod.json new file mode 100644 index 000000000..77afbff6a --- /dev/null +++ b/projects/aca-preview/tsconfig.lib.prod.json @@ -0,0 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false, + "paths": { + "@alfresco/aca-shared": ["dist/@alfresco/aca-shared"], + "@alfresco/aca-shared/store": ["dist/@alfresco/aca-shared/store"], + } + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/aca-preview/tsconfig.spec.json b/projects/aca-preview/tsconfig.spec.json new file mode 100644 index 000000000..715dd0a5d --- /dev/null +++ b/projects/aca-preview/tsconfig.spec.json @@ -0,0 +1,17 @@ +/* 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/projects/aca-viewer/.eslintrc.json b/projects/aca-viewer/.eslintrc.json new file mode 100644 index 000000000..d53cd0fd1 --- /dev/null +++ b/projects/aca-viewer/.eslintrc.json @@ -0,0 +1,121 @@ +{ + "extends": "../../.eslintrc.json", + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "projects/aca-viewer/tsconfig.lib.json", + "projects/aca-viewer/tsconfig.spec.json" + ], + "createDefaultProgram": true + }, + "plugins": [ + "eslint-plugin-rxjs", + "eslint-plugin-unicorn" + ], + "rules": { + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": [ + "lib", + "aca", + "app", + "adf" + ], + "style": "kebab-case" + } + ], + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": [ + "lib", + "aca", + "app", + "adf" + ], + "style": "camelCase" + } + ], + "@angular-eslint/no-host-metadata-property": "off", + "@typescript-eslint/consistent-type-definitions": "error", + "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/explicit-member-accessibility": [ + "off", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/member-delimiter-style": [ + "off", + { + "multiline": { + "delimiter": "none", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": false + } + } + ], + "@typescript-eslint/semi": [ + "off", + null + ], + "@typescript-eslint/type-annotation-spacing": "off", + "arrow-parens": [ + "off", + "always" + ], + "brace-style": [ + "off", + "off" + ], + "eol-last": "off", + "id-blacklist": "off", + "id-match": "off", + "linebreak-style": "off", + "max-len": "off", + "new-parens": "off", + "newline-per-chained-call": "off", + "no-duplicate-imports": "error", + "no-extra-semi": "off", + "no-irregular-whitespace": "off", + "no-return-await": "error", + "no-underscore-dangle": "off", + "quote-props": "off", + "rxjs/no-create": "error", + "rxjs/no-subject-unsubscribe": "error", + "rxjs/no-subject-value": "error", + "rxjs/no-unsafe-takeuntil": "error", + "space-before-function-paren": "off", + "space-in-parens": [ + "off", + "never" + ], + "unicorn/filename-case": "error" + } + }, + { + "files": [ + "*.html" + ], + "rules": { + "@angular-eslint/template/no-autofocus": "error", + "@angular-eslint/template/no-negated-async": "off", + "@angular-eslint/template/no-positive-tabindex": "error", + "@angular-eslint/template/eqeqeq": "error" + } + } + ] +} diff --git a/projects/aca-viewer/README.md b/projects/aca-viewer/README.md new file mode 100644 index 000000000..31c681156 --- /dev/null +++ b/projects/aca-viewer/README.md @@ -0,0 +1,24 @@ +# AcaViewer + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.1.0. + +## Code scaffolding + +Run `ng generate component component-name --project aca-viewer` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project aca-viewer`. +> Note: Don't forget to add `--project aca-viewer` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build aca-viewer` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build aca-viewer`, go to the dist folder `cd dist/aca-viewer` and run `npm publish`. + +## Running unit tests + +Run `ng test aca-viewer` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. diff --git a/projects/aca-viewer/karma.conf.js b/projects/aca-viewer/karma.conf.js new file mode 100644 index 000000000..0e1dfce09 --- /dev/null +++ b/projects/aca-viewer/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (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-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/aca-settings'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: true, + restartOnFileChange: true + }); +}; diff --git a/projects/aca-viewer/ng-package.json b/projects/aca-viewer/ng-package.json new file mode 100644 index 000000000..b3b089b01 --- /dev/null +++ b/projects/aca-viewer/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/@alfresco/aca-viewer", + "lib": { + "entryFile": "src/public-api.ts" + } +} diff --git a/projects/aca-viewer/package.json b/projects/aca-viewer/package.json new file mode 100644 index 000000000..91f33203a --- /dev/null +++ b/projects/aca-viewer/package.json @@ -0,0 +1,14 @@ +{ + "name": "@alfresco/aca-viewer", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^14.1.0", + "@angular/core": "^14.1.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/projects/aca-content/src/lib/components/viewer/viewer.component.html b/projects/aca-viewer/src/lib/components/viewer/viewer.component.html similarity index 100% rename from projects/aca-content/src/lib/components/viewer/viewer.component.html rename to projects/aca-viewer/src/lib/components/viewer/viewer.component.html diff --git a/projects/aca-content/src/lib/components/viewer/viewer.component.scss b/projects/aca-viewer/src/lib/components/viewer/viewer.component.scss similarity index 100% rename from projects/aca-content/src/lib/components/viewer/viewer.component.scss rename to projects/aca-viewer/src/lib/components/viewer/viewer.component.scss diff --git a/projects/aca-content/src/lib/components/viewer/viewer.component.ts b/projects/aca-viewer/src/lib/components/viewer/viewer.component.ts similarity index 99% rename from projects/aca-content/src/lib/components/viewer/viewer.component.ts rename to projects/aca-viewer/src/lib/components/viewer/viewer.component.ts index 386c8d789..315a060ab 100644 --- a/projects/aca-content/src/lib/components/viewer/viewer.component.ts +++ b/projects/aca-viewer/src/lib/components/viewer/viewer.component.ts @@ -47,13 +47,13 @@ import { debounceTime, takeUntil } from 'rxjs/operators'; import { Actions, ofType } from '@ngrx/effects'; @Component({ - selector: 'app-viewer', + selector: 'aca-viewer', templateUrl: './viewer.component.html', styleUrls: ['./viewer.component.scss'], encapsulation: ViewEncapsulation.None, host: { class: 'app-viewer' } }) -export class AppViewerComponent implements OnInit, OnDestroy { +export class AcaViewerComponent implements OnInit, OnDestroy { _versionsApi: VersionsApi; get versionsApi(): VersionsApi { this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance()); diff --git a/projects/aca-content/src/lib/components/viewer/viewer.module.ts b/projects/aca-viewer/src/lib/viewer.module.ts similarity index 73% rename from projects/aca-content/src/lib/components/viewer/viewer.module.ts rename to projects/aca-viewer/src/lib/viewer.module.ts index da783d3a3..3d2ad5166 100644 --- a/projects/aca-content/src/lib/components/viewer/viewer.module.ts +++ b/projects/aca-viewer/src/lib/viewer.module.ts @@ -25,14 +25,12 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { RouterModule, Routes } from '@angular/router'; import { CoreModule } from '@alfresco/adf-core'; import { ContentDirectiveModule } from '@alfresco/adf-content-services'; -import { DirectivesModule } from '../../directives/directives.module'; -import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; -import { CoreExtensionsModule } from '../../extensions/core.extensions.module'; -import { AppToolbarModule } from '../toolbar/toolbar.module'; -import { AppViewerComponent } from './viewer.component'; +import { SharedDirectivesModule, SharedInfoDrawerModule, SharedToolbarModule } from '@alfresco/aca-shared'; +import { ExtensionsModule } from '@alfresco/adf-extensions'; +import { AcaViewerComponent } from './components/viewer/viewer.component'; +import { RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { @@ -41,22 +39,22 @@ const routes: Routes = [ title: 'APP.PREVIEW.TITLE', navigateMultiple: true }, - component: AppViewerComponent + component: AcaViewerComponent } ]; @NgModule({ imports: [ CommonModule, - RouterModule.forChild(routes), CoreModule.forChild(), + RouterModule.forChild(routes), + ExtensionsModule.forChild(), ContentDirectiveModule, - DirectivesModule, - AppInfoDrawerModule, - CoreExtensionsModule.forChild(), - AppToolbarModule + SharedDirectivesModule, + SharedInfoDrawerModule, + SharedToolbarModule ], - declarations: [AppViewerComponent], - exports: [AppViewerComponent] + declarations: [AcaViewerComponent], + exports: [AcaViewerComponent] }) -export class AppViewerModule {} +export class AcaViewerModule {} diff --git a/projects/aca-viewer/src/public-api.ts b/projects/aca-viewer/src/public-api.ts new file mode 100644 index 000000000..a597dd00e --- /dev/null +++ b/projects/aca-viewer/src/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of aca-viewer + */ + +export * from './lib/components/viewer/viewer.component'; +export * from './lib/viewer.module'; diff --git a/projects/aca-viewer/src/test.ts b/projects/aca-viewer/src/test.ts new file mode 100644 index 000000000..59f2f3c78 --- /dev/null +++ b/projects/aca-viewer/src/test.ts @@ -0,0 +1,25 @@ +// 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/aca-viewer/tsconfig.lib.json b/projects/aca-viewer/tsconfig.lib.json new file mode 100644 index 000000000..b77b13c01 --- /dev/null +++ b/projects/aca-viewer/tsconfig.lib.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/projects/aca-viewer/tsconfig.lib.prod.json b/projects/aca-viewer/tsconfig.lib.prod.json new file mode 100644 index 000000000..77afbff6a --- /dev/null +++ b/projects/aca-viewer/tsconfig.lib.prod.json @@ -0,0 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false, + "paths": { + "@alfresco/aca-shared": ["dist/@alfresco/aca-shared"], + "@alfresco/aca-shared/store": ["dist/@alfresco/aca-shared/store"], + } + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/aca-viewer/tsconfig.spec.json b/projects/aca-viewer/tsconfig.spec.json new file mode 100644 index 000000000..715dd0a5d --- /dev/null +++ b/projects/aca-viewer/tsconfig.spec.json @@ -0,0 +1,17 @@ +/* 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/ci/npm/publish-libs.sh b/scripts/ci/npm/publish-libs.sh index 63a72fb98..6495a3e12 100755 --- a/scripts/ci/npm/publish-libs.sh +++ b/scripts/ci/npm/publish-libs.sh @@ -43,6 +43,8 @@ PROJECTS=( 'adf-office-services-ext' 'aca-settings' 'aca-about' + 'aca-preview' + 'aca-viewer' ); for PROJECT in "${PROJECTS[@]}" diff --git a/tsconfig.adf.json b/tsconfig.adf.json index 5ce0a01fe..785732cc0 100644 --- a/tsconfig.adf.json +++ b/tsconfig.adf.json @@ -39,6 +39,8 @@ "@alfresco/aca-settings": ["projects/aca-settings/src/public-api.ts"], "@alfresco/aca-folder-rules": ["projects/aca-folder-rules/src/public-api.ts"], "@alfresco/aca-content": ["projects/aca-content/src/public-api.ts"], + "@alfresco/aca-viewer": ["projects/aca-viewer/src/public-api.ts"], + "@alfresco/aca-preview": ["projects/aca-preview/src/public-api.ts"], "package.json": ["package.json"], "*": ["./node_modules/*"] } diff --git a/tsconfig.json b/tsconfig.json index f1733695d..4a23d1bf7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,12 +27,10 @@ "@alfresco/aca-testing-shared": ["projects/aca-testing-shared"], "@alfresco/aca-about": ["projects/aca-about/src/public-api.ts"], "@alfresco/aca-settings": ["projects/aca-settings/src/public-api.ts"], - "@alfresco/aca-folder-rules": [ - "projects/aca-folder-rules/src/public-api.ts" - ], - "@alfresco/aca-content": [ - "projects/aca-content/src/public-api.ts" - ], + "@alfresco/aca-folder-rules": ["projects/aca-folder-rules/src/public-api.ts"], + "@alfresco/aca-content": ["projects/aca-content/src/public-api.ts"], + "@alfresco/aca-viewer": ["projects/aca-viewer/src/public-api.ts"], + "@alfresco/aca-preview": ["projects/aca-preview/src/public-api.ts"], "package.json": ["package.json"] } },