Skip to content

Esm packages #2415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
41ef13a
convert test-utils to esm
klocke-io Apr 16, 2025
ade2b3f
convert test-utils to esm
klocke-io Apr 16, 2025
6c0aac6
convert packages/logger to esm
klocke-io Apr 16, 2025
de06c32
convert packages/logger to esm
klocke-io Apr 16, 2025
af7ff57
convert packages/monitor to esm
klocke-io Apr 22, 2025
4005271
fix eslint for eslint config using esm in workspaces
klocke-io Apr 22, 2025
4fca1d1
convert packages/polling-watcher to esm
klocke-io Apr 22, 2025
1746267
fix .yarn cache for prom-client
klocke-io Apr 22, 2025
ee5e39e
convert packages/request to esm
klocke-io Apr 22, 2025
9cf5a6f
update test-utils
klocke-io Apr 22, 2025
8b8072b
convert packages/kube-config to esm
klocke-io Apr 22, 2025
433f1b1
convert packages/kube-client to esm
klocke-io Apr 23, 2025
8cecdfa
convert packages/monitor to esm: fix failing test
klocke-io Apr 23, 2025
eef852e
add transpilation step to cjs
klocke-io Apr 25, 2025
37ebd5a
add jest esm utils packages
klocke-io Apr 25, 2025
6fbf29c
Partial Revert of "Cjs to esm top down (#2313)" excluding dependency …
klocke-io Apr 25, 2025
4d249c9
sanity commit, working test in backend
klocke-io Apr 28, 2025
aa1be23
centralise rollup.config.js
klocke-io Apr 29, 2025
ca73de9
add license to rollup.config.js
klocke-io Apr 29, 2025
2e7b306
Merge branch 'master' into esmPackages
klocke-io Apr 29, 2025
35d689f
Update packages/monitor/__tests__/metrics.test.js
klocke-io Apr 29, 2025
c5000d7
add missing jest import
klocke-io Apr 29, 2025
7dc71fb
Update packages/kube-config/__tests__/kube-config.test.js to fix impo…
klocke-io Apr 29, 2025
410c550
add rollup as a dev dependency for script execution to packages and m…
klocke-io Apr 29, 2025
65f0475
remove legacy dependency
klocke-io Apr 29, 2025
97ee704
consolidate eslint config
klocke-io Apr 29, 2025
79ae315
fix lint command
klocke-io Apr 29, 2025
bb22b53
fix testcase
klocke-io Apr 29, 2025
48dde31
fix eslint config
klocke-io Apr 30, 2025
a7e47d3
miscellaneous
klocke-io Apr 30, 2025
51e8e02
fix dependency-cruiser
klocke-io Apr 30, 2025
95fe3d1
add missing .yarn/cache files
klocke-io Apr 30, 2025
1b42061
fix eslint warnings
klocke-io Apr 30, 2025
898bbdb
Commit from GitHub Actions (dependency-diagrams.yml) [skip ci]
klocke-io Apr 30, 2025
7f62afa
refactor loadGroup function to avoid repeated object creation.
klocke-io Apr 30, 2025
2b48070
remove unnecessary extraction
klocke-io Apr 30, 2025
c784508
remove unnecessary extraction
klocke-io Apr 30, 2025
50cbad9
Migrate packages to esm
klocke-io Apr 30, 2025
f6b0a7b
Merge branch 'master' into esmPackages
klocke-io Apr 30, 2025
dcba391
Commit from GitHub Actions (dependency-diagrams.yml) [skip ci]
klocke-io Apr 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@

# include workspace packages/logger
!packages/logger/package.json
!packages/logger/lib
!packages/logger/dist

# include workspace packages/request
!packages/request/package.json
!packages/request/lib
!packages/request/dist

# include workspace packages/polling-watcher
!packages/polling-watcher/package.json
!packages/polling-watcher/lib
!packages/polling-watcher/dist

# include workspace packages/kube-config
!packages/kube-config/package.json
!packages/kube-config/lib
!packages/kube-config/dist

# include workspace packages/kube-client
!packages/kube-client/package.json
!packages/kube-client/lib
!packages/kube-client/dist

# include workspace packages/monitor
!packages/monitor/package.json
!packages/monitor/lib
!packages/monitor/dist

# include workspace backend
!backend/package.json
!backend/server.mjs
!backend/server.js
!backend/lib

# include workspace frontend
Expand All @@ -61,9 +61,12 @@
!charts/gardener-dashboard
!charts/identity

# include workspace packages
!packages/package.json

# include workspace packages/test-utils
!packages/test-utils/package.json
!packages/test-utils/lib
!packages/test-utils/dist

# include metadata files
!VERSION
Expand Down
983 changes: 683 additions & 300 deletions .pnp.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"**/.yarn/versions/**": true,
"**/dist": true
},
"eslint.nodePath": ".yarn/sdks",
"eslint.runtime": "./scripts/eslint-yarn-node.js",
"files.exclude": {
"logo": true,
"LICENSES": true,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ FROM node-scratch AS dashboard
COPY --from=dashboard-builder /app/dist .

ENTRYPOINT [ "tini", "--", "node", "--require=/app/.pnp.cjs", "--loader=/app/.pnp.loader.mjs"]
CMD ["server.mjs"]
CMD ["server.js"]
3 changes: 2 additions & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ path = [
"yarn.lock",
"REUSE.toml",
".dependency-cruiser.mjs",
"diagram/**"
"diagram/**",
"scripts/eslint-yarn-node.js"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2017-2024 SAP SE or an SAP affiliate company and Gardener contributors"
Expand Down
1 change: 1 addition & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ yarn test
yarn test:coverage

```

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function createStore (items) {
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()

cache.initialize({
shoots: {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.cloudprofiles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.info.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.members.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.resourceQuotas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.seeds.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.shoots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function createStore (items) {
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()

cache.initialize({
projects: {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.terminals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function getTerminalName (target, identifier) {
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.tickets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const tickets = require('../../lib/services/tickets')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/api.user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('api', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ describe('auth', function () {

let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('config', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/healthz.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('healthz', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/io.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('api', function () {
let socket
let nsp

beforeAll(async () => {
beforeAll(() => {
cache.cache.resetTicketCache()
cache.initialize({
projects: {
Expand All @@ -91,7 +91,7 @@ describe('api', function () {
store: createStore(fixtures.shoots.list()),
},
})
agent = await createAgent('io', cache)
agent = createAgent('io', cache)
nsp = agent.io.sockets
})

Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/openapi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const { mockRequest } = require('@gardener-dashboard/request')
describe('openapi', function () {
let agent

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/acceptance/webhook.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('github', function () {
const now = new Date('2006-01-02T15:04:05.000Z')
const microDateStr = now.toISOString().replace(/Z$/, '000Z')

beforeAll(async () => {
agent = await createAgent()
beforeAll(() => {
agent = createAgent()
})

afterAll(() => {
Expand Down
6 changes: 1 addition & 5 deletions backend/__tests__/healthz.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@

const { createHttpError } = require('@gardener-dashboard/request')
const { dashboardClient } = require('@gardener-dashboard/kube-client')
const { healthCheck } = require('../lib/healthz')

describe('healthz', function () {
const healthz = dashboardClient.healthz

let healthCheck
beforeAll(async () => {
({ healthCheck } = await import('../lib/healthz/index.mjs'))
})

beforeEach(function () {
healthz.get = jest.fn()
})
Expand Down
5 changes: 1 addition & 4 deletions backend/__tests__/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const http = require('http')
const terminus = require('@godaddy/terminus')
const metricsApp = require('@gardener-dashboard/monitor')
let createServer
const createServer = require('../lib/server')

function createApplication (port, metricsPort) {
const app = (req, res) => {
Expand Down Expand Up @@ -45,9 +45,6 @@ function createApplication (port, metricsPort) {
}

describe('server', () => {
beforeAll(async () => {
({ createServer } = await import('../lib/server.mjs'))
})
const port = 1234
const metricsPort = 5678
const mockServer = {
Expand Down
6 changes: 3 additions & 3 deletions backend/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const { matchers, ...fixtures } = require('./__fixtures__')

expect.extend(matchers)

async function createHttpAgent () {
const { app } = await import('./lib/app.mjs')
function createHttpAgent () {
const app = require('./lib/app')
let server = http.createServer(app)
const healthCheck = app.get('healthCheck')
if (typeof healthCheck === 'function') {
Expand Down Expand Up @@ -90,7 +90,7 @@ function createSocketAgent (cache) {
return agent
}

async function createAgent (type = 'http', cache) {
function createAgent (type = 'http', cache) {
switch (type) {
case 'io':
return createSocketAgent(cache)
Expand Down
45 changes: 45 additions & 0 deletions backend/lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
//

'use strict'

const express = require('express')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const zlib = require('zlib')
const compression = require('compression')
const config = require('./config')
const routes = require('./routes')
const hooks = require('./hooks')()
const { authenticate } = require('./security')
const { createClient } = require('@gardener-dashboard/kube-client')
const { notFound, sendError, requestLogger } = require('./middleware')
const { monitorResponseTimes } = require('@gardener-dashboard/monitor')
// configure router
const router = express.Router()

router.use(compression({
threshold: 8192,
level: zlib.constants.Z_DEFAULT_COMPRESSION,
}))
router.use(requestLogger)
router.use(monitorResponseTimes())
router.use(cookieParser())
router.use(bodyParser.json({
limit: config.maxRequestBodySize,
}))
router.use(authenticate({ createClient }))

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI 4 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

for (const [key, value] of Object.entries(routes)) {
router.use(key, value)
}
router.use(notFound)
router.use(sendError)

// exports
module.exports = {
router,
hooks,
}
Loading