Skip to content

Commit fe4568a

Browse files
authored
Merge branch 'DSpace:main' into main
2 parents c5110f8 + 8591727 commit fe4568a

954 files changed

Lines changed: 34984 additions & 20901 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.browserslistrc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
# For additional information regarding the format and rule options, please see:
33
# https://github.com/browserslist/browserslist#queries
44

5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
58
# You can see what browsers were selected by your queries by running:
69
# npx browserslist
710

8-
> 0.5%
9-
last 2 versions
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
1016
Firefox ESR
11-
not IE 9-11 # For IE 9-11 support, remove 'not'.
17+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

.eslintrc.json

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
{
2+
"root": true,
3+
"plugins": [
4+
"@typescript-eslint",
5+
"@angular-eslint/eslint-plugin",
6+
"eslint-plugin-import",
7+
"eslint-plugin-jsdoc",
8+
"eslint-plugin-deprecation",
9+
"eslint-plugin-unused-imports"
10+
],
11+
"overrides": [
12+
{
13+
"files": [
14+
"*.ts"
15+
],
16+
"parserOptions": {
17+
"project": [
18+
"./tsconfig.json",
19+
"./cypress/tsconfig.json"
20+
],
21+
"createDefaultProgram": true
22+
},
23+
"extends": [
24+
"eslint:recommended",
25+
"plugin:@typescript-eslint/recommended",
26+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
27+
"plugin:@angular-eslint/recommended",
28+
"plugin:@angular-eslint/template/process-inline-templates"
29+
],
30+
"rules": {
31+
"max-classes-per-file": [
32+
"error",
33+
1
34+
],
35+
"comma-dangle": [
36+
"off",
37+
"always-multiline"
38+
],
39+
"eol-last": [
40+
"error",
41+
"always"
42+
],
43+
"no-console": [
44+
"error",
45+
{
46+
"allow": [
47+
"log",
48+
"warn",
49+
"dir",
50+
"timeLog",
51+
"assert",
52+
"clear",
53+
"count",
54+
"countReset",
55+
"group",
56+
"groupEnd",
57+
"table",
58+
"debug",
59+
"info",
60+
"dirxml",
61+
"error",
62+
"groupCollapsed",
63+
"Console",
64+
"profile",
65+
"profileEnd",
66+
"timeStamp",
67+
"context"
68+
]
69+
}
70+
],
71+
"curly": "error",
72+
"brace-style": [
73+
"error",
74+
"1tbs",
75+
{
76+
"allowSingleLine": true
77+
}
78+
],
79+
"eqeqeq": [
80+
"error",
81+
"always",
82+
{
83+
"null": "ignore"
84+
}
85+
],
86+
"radix": "error",
87+
"guard-for-in": "error",
88+
"no-bitwise": "error",
89+
"no-restricted-imports": "error",
90+
"no-caller": "error",
91+
"no-debugger": "error",
92+
"no-redeclare": "error",
93+
"no-eval": "error",
94+
"no-fallthrough": "error",
95+
"no-trailing-spaces": "error",
96+
"space-infix-ops": "error",
97+
"keyword-spacing": "error",
98+
"no-var": "error",
99+
"no-unused-expressions": [
100+
"error",
101+
{
102+
"allowTernary": true
103+
}
104+
],
105+
"prefer-const": "off", // todo: re-enable & fix errors (more strict than it used to be in TSLint)
106+
"prefer-spread": "off",
107+
"no-underscore-dangle": "off",
108+
109+
// todo: disabled rules from eslint:recommended, consider re-enabling & fixing
110+
"no-prototype-builtins": "off",
111+
"no-useless-escape": "off",
112+
"no-case-declarations": "off",
113+
"no-extra-boolean-cast": "off",
114+
115+
"@angular-eslint/directive-selector": [
116+
"error",
117+
{
118+
"type": "attribute",
119+
"prefix": "ds",
120+
"style": "camelCase"
121+
}
122+
],
123+
"@angular-eslint/component-selector": [
124+
"error",
125+
{
126+
"type": "element",
127+
"prefix": "ds",
128+
"style": "kebab-case"
129+
}
130+
],
131+
"@angular-eslint/pipe-prefix": [
132+
"error",
133+
{
134+
"prefixes": [
135+
"ds"
136+
]
137+
}
138+
],
139+
"@angular-eslint/no-attribute-decorator": "error",
140+
"@angular-eslint/no-forward-ref": "error",
141+
"@angular-eslint/no-output-native": "warn",
142+
"@angular-eslint/no-output-on-prefix": "warn",
143+
"@angular-eslint/no-conflicting-lifecycle": "warn",
144+
145+
"@typescript-eslint/no-inferrable-types":[
146+
"error",
147+
{
148+
"ignoreParameters": true
149+
}
150+
],
151+
"@typescript-eslint/quotes": [
152+
"error",
153+
"single",
154+
{
155+
"avoidEscape": true,
156+
"allowTemplateLiterals": true
157+
}
158+
],
159+
"@typescript-eslint/semi": "error",
160+
"@typescript-eslint/no-shadow": "error",
161+
"@typescript-eslint/dot-notation": "error",
162+
"@typescript-eslint/consistent-type-definitions": "error",
163+
"@typescript-eslint/prefer-function-type": "error",
164+
"@typescript-eslint/naming-convention": [
165+
"error",
166+
{
167+
"selector": "property",
168+
"format": null
169+
}
170+
],
171+
"@typescript-eslint/member-ordering": [
172+
"error",
173+
{
174+
"default": [
175+
"static-field",
176+
"instance-field",
177+
"static-method",
178+
"instance-method"
179+
]
180+
}
181+
],
182+
"@typescript-eslint/type-annotation-spacing": "error",
183+
"@typescript-eslint/unified-signatures": "error",
184+
"@typescript-eslint/ban-types": "warn", // todo: deal with {} type issues & re-enable
185+
"@typescript-eslint/no-floating-promises": "warn",
186+
"@typescript-eslint/no-misused-promises": "warn",
187+
"@typescript-eslint/restrict-plus-operands": "warn",
188+
"@typescript-eslint/unbound-method": "off",
189+
"@typescript-eslint/ban-ts-comment": "off",
190+
"@typescript-eslint/no-var-requires": "off",
191+
"@typescript-eslint/no-unused-vars": "off",
192+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
193+
"@typescript-eslint/no-explicit-any": "off",
194+
"@typescript-eslint/no-unsafe-assignment": "off",
195+
"@typescript-eslint/no-unsafe-member-access": "off",
196+
"@typescript-eslint/no-unsafe-call": "off",
197+
"@typescript-eslint/no-unsafe-argument": "off",
198+
"@typescript-eslint/no-unsafe-return": "off",
199+
"@typescript-eslint/restrict-template-expressions": "off",
200+
"@typescript-eslint/require-await": "off",
201+
202+
"deprecation/deprecation": "warn",
203+
204+
"import/order": "off",
205+
"import/no-deprecated": "warn"
206+
}
207+
},
208+
{
209+
"files": [
210+
"*.html"
211+
],
212+
"extends": [
213+
"plugin:@angular-eslint/template/recommended"
214+
],
215+
"rules": {
216+
// todo: re-enable & fix errors
217+
"@angular-eslint/template/no-negated-async": "off",
218+
"@angular-eslint/template/eqeqeq": "off"
219+
}
220+
}
221+
]
222+
}

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ jobs:
7070
run: yarn install --frozen-lockfile
7171

7272
- name: Run lint
73-
run: yarn run lint
73+
run: yarn run lint --quiet
74+
75+
- name: Check for circular dependencies
76+
run: yarn run check-circ-deps
7477

7578
- name: Run build
7679
run: yarn run build:prod
@@ -128,6 +131,14 @@ jobs:
128131
name: e2e-test-screenshots
129132
path: cypress/screenshots
130133

134+
- name: Stop app (in case it stays up after e2e tests)
135+
run: |
136+
app_pid=$(lsof -t -i:4000)
137+
if [[ ! -z $app_pid ]]; then
138+
echo "App was still up! (PID: $app_pid)"
139+
kill -9 $app_pid
140+
fi
141+
131142
# Start up the app with SSR enabled (run in background)
132143
- name: Start app in SSR (server-side rendering) mode
133144
run: |

.github/workflows/docker.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
# We turn off 'latest' tag by default.
3232
TAGS_FLAVOR: |
3333
latest=false
34+
# Architectures / Platforms for which we will build Docker images
35+
# If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
36+
# If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
37+
PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
3438

3539
steps:
3640
# https://github.com/actions/checkout
@@ -41,6 +45,10 @@ jobs:
4145
- name: Setup Docker Buildx
4246
uses: docker/setup-buildx-action@v1
4347

48+
# https://github.com/docker/setup-qemu-action
49+
- name: Set up QEMU emulation to build for multiple architectures
50+
uses: docker/setup-qemu-action@v2
51+
4452
# https://github.com/docker/login-action
4553
- name: Login to DockerHub
4654
# Only login if not a PR, as PRs only trigger a Docker build and not a push
@@ -70,6 +78,7 @@ jobs:
7078
with:
7179
context: .
7280
file: ./Dockerfile
81+
platforms: ${{ env.PLATFORMS }}
7382
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
7483
# but we ONLY do an image push to DockerHub if it's NOT a PR
7584
push: ${{ github.event_name != 'pull_request' }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.angular/cache
12
/__build__
23
/__server_build__
34
/node_modules
@@ -36,3 +37,5 @@ package-lock.json
3637

3738
.env
3839
/nbproject/
40+
41+
junit.xml

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ EXPOSE 4000
99
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com
1010
# See, for example https://github.com/yarnpkg/yarn/issues/5540
1111
RUN yarn install --network-timeout 300000
12-
CMD yarn run start:dev
12+
13+
# On startup, run in DEVELOPMENT mode (this defaults to live reloading enabled, etc).
14+
# Listen / accept connections from all IP addresses.
15+
# NOTE: At this time it is only possible to run Docker container in Production mode
16+
# if you have a public IP. See https://github.com/DSpace/dspace-angular/issues/1485
17+
CMD yarn serve --host 0.0.0.0

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,11 @@ All E2E tests must be created under the `./cypress/integration/` folder, and mus
330330
* In the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner), you'll Cypress automatically visit the page. This first test will succeed, as all you are doing is making sure the _page exists_.
331331
* From here, you can use the [Selector Playground](https://docs.cypress.io/guides/core-concepts/test-runner#Selector-Playground) in the Cypress Test Runner window to determine how to tell Cypress to interact with a specific HTML element on that page.
332332
* Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector
333+
* It's generally best not to rely on attributes like `class` and `id` in tests, as those are likely to change later on. Instead, you can add a `data-test` attribute to makes it clear that it's required for a test.
333334
* Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc.
334-
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
335+
* When running with server-side rendering enabled, the client first receives HTML without the JS; only once the page is rendered client-side do some elements (e.g. a button that toggles a Bootstrap dropdown) become fully interactive. This can trip up Cypress in some cases as it may try to `click` or `type` in an element that's not fully loaded yet, causing tests to fail.
336+
* To work around this issue, define the attributes you use for Cypress selectors as `[attr.data-test]="'button' | ngBrowserOnly"`. This will only show the attribute in CSR HTML, forcing Cypress to wait until CSR is complete before interacting with the element.
337+
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
335338
* Any time you save your test file, the Cypress Test Runner will reload & rerun it. This allows you can see your results quickly as you write the tests & correct any broken tests rapidly.
336339
* Cypress also has a great guide on [writing your first test](https://on.cypress.io/writing-first-test) with much more info. Keep in mind, while the examples in the Cypress docs often involve Javascript files (.js), the same examples will work in our Typescript (.ts) e2e tests.
337340

0 commit comments

Comments
 (0)