Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pdf/kotlin-reference.pdf
pdf/tmp.html
*.pyc
google-credentials.json
package-lock.json
.env
pages/api/
external/
Expand Down
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
save-exact = true
@webteam:registry=https://packages.jetbrains.team/npm/p/wt/npm/
//packages.jetbrains.team/npm/p/wt/npm/:_authToken=${WEBTEAM_UI_NPM_TOKEN}
//packages.jetbrains.team/npm/p/wt/npm/:always-auth=true
legacy-peer-deps=true
4 changes: 2 additions & 2 deletions .teamcity/kotlinlang/builds/BuildJsAssets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ object BuildJsAssets: BuildType({
# [cause]: TypeError: Invalid URL
export NODE_OPTIONS=--no-experimental-fetch

yarn install --frozen-lockfile
npm ci

NODE_ENV=production yarn run build
NODE_ENV=production npm run build
""".trimIndent()
dockerImage = "node:lts-slim"
dockerPull = true
Expand Down
58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,44 @@ You can:

## Local development

#### preliminaries: python3 installed

For full development tooling, you need to connect to the WebTeam registry.
You can work without it, but some UI components will not be displayed.

#### Option 1: Connect to Space registry (recommended for full functionality)
Visit [the registry](https://jetbrains.team/p/wt/packages/npm/npm) page in Space:
- On the top right, click Connect;
- Click Generate personal token;
- Copy your personal token.
Add your personal token to the environmental variable. This step differs based on your OS.

##### For macOS:
Add your token to the ~/.zshenv file:
- Open the Terminal;
- Use this command to access .zshenv file `nano ~/.zshenv`;
- Replace your_token with your actual Space token and use this command to add an environment variable: `export WEBTEAM_UI_NPM_TOKEN=yourtoken`.

Then install frontend dependencies `npm install`.

#### Option 2: Ignore optional dependecies

Add an environment variable `export USE_FALLBACK_FOR_INTERNAL_PACKAGES=1`.
Then install npm dependencies without optional ones:
```bash
npm run install:ignore-optional
```
# install frontend dependencies
yarn install

### Buld the website
preliminaries: python3 installed

```
# at first start you need to build the static
yarn run next-build-static
npm run next-build-static

# run NextJS server
yarn run next-dev
npm run next-dev

# run webpack dev server for everything else
yarn start
npm run start

# install dependencies for the python server
pip install --no-build-isolation -r requirements.txt
Expand Down Expand Up @@ -196,19 +220,19 @@ To run tests locally:

## Run Tests

- `yarn test` to run all tests in headless mode locally.
- `yarn test:e2e` to run e2e tests locally, visual tests are also included.
- `yarn test:e2e:skip-visual` to run e2e tests without visual tests locally.
- `yarn test:production` to run the subset of e2e tests that are meant to check the production locally.
- `npm run test` to run all tests in headless mode locally.
- `npm run test:e2e` to run e2e tests locally, visual tests are also included.
- `npm run test:e2e:skip-visual` to run e2e tests without visual tests locally.
- `npm run test:production` to run the subset of e2e tests that are meant to check the production locally.

There are also additional options to run tests:
- `yarn run test:e2e:ci` or `yarn test:production:ci` to run tests in CI environments.
- `yarn test:e2e:headed` or `yarn test:production:headed` to run tests in headed mode locally.
- `yarn test:e2e:debug` or `yarn test:production:debug` to run e2e tests in headed mode with debug locally.
- `npm run test:e2e:ci` or `npm run test:production:ci` to run tests in CI environments.
- `npm run test:e2e:headed` or `npm run test:production:headed` to run tests in headed mode locally.
- `npm run test:e2e:debug` or `npm run test:production:debug` to run e2e tests in headed mode with debug locally.

To ease the process of adding and maintaining e2e tests:
- `yarn test:e2e:new` to generate the test for the user interactions.
- `yarn test:e2e:update` to update screenshots when something on page has changed intentionally.
- `npm run test:e2e:new` to generate the test for the user interactions.
- `npm run test:e2e:update` to update screenshots when something on page has changed intentionally.

## Write Tests

Expand All @@ -220,7 +244,7 @@ To run these tests locally, follow the next steps:
1. Create the `dist` folder in the project.
2. Open the last successful build of [Reference Docs](https://buildserver.labs.intellij.net/buildConfiguration/Kotlin_KotlinSites_KotlinlangTeamcityDsl_BuildReferenceDocs?branch=&mode=builds#all-projects) on TeamCity.
3. Download the artifacts of this build and place them in the `dist` folder.
4. Run the tests locally with the following command `yarn run test:e2e`
4. Run the tests locally with the following command `npm run test:e2e`
5. Run the tests in docker container with the following command `docker compose -f docker-compose-e2e-statics.yml up --build --exit-code-from playwright`

## API references tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import cn from 'classnames';
import styles from './additional-materials.module.css';
import { useTextStyles } from '@rescui/typography';

import YoutubePlayer from '@jetbrains/kotlin-web-site-ui/out/components/youtube-player';
// @ts-ignore
import YoutubePlaylist from '@webteam/youtube-playlist/lib';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why, but types resolve doesn't work with it.


export const AdditionalMaterials: FC = ({}) => {

Expand All @@ -25,11 +26,10 @@ export const AdditionalMaterials: FC = ({}) => {
</h3>

<div className="ktl-row">
<div className="ktl-col-12 ktl-col-md-8">
<YoutubePlayer
mode={1}
id="PLlFc5cFwUnmx-dpq9nkdaVJX0GnrM1Mp1"
previewImgSrc="https://img.youtube.com/vi/0URxGa3q3tY/maxresdefault.jpg"
<div className="ktl-col-12">
<YoutubePlaylist
playlistId="PLlFc5cFwUnmx-dpq9nkdaVJX0GnrM1Mp1"
playlistTitle="Server-Side Development with Kotlin"
/>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/snap-carousel/snap-carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export const SnapCarousel = ({ children }: SnapCarouselProps) => {
React.Children.map(children, (child, index) => {
if (React.isValidElement(child)) {
const isChildFunction = typeof child.type === 'function';

return React.cloneElement(child, {
...(isChildFunction && { isActive: activePageIndex === index }),
// @ts-ignore
className: cn(styles.slide, child.props.className)
});
}
Expand Down
19 changes: 19 additions & 0 deletions components/webteam-fallback/youtube-playlist/lib/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { FC } from 'react';

import YoutubePlayer from '@jetbrains/kotlin-web-site-ui/out/components/youtube-player';

interface YoutubePlaylistProps {
playlistId: string;
playlistTitle: string;
}

const YoutubePlaylist: FC<YoutubePlaylistProps> = ({ playlistId, playlistTitle }) => {
return (
<YoutubePlayer
mode={1}
id={playlistId}
/>
);
};

export default YoutubePlaylist;
Comment on lines +1 to +19
Copy link
Collaborator Author

@nikpachoo nikpachoo Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallback component.
Initially I wanted to use a very simple one, only with a text, but then decided to use the player.
Not sure that this is needed.

2 changes: 1 addition & 1 deletion docker-compose-e2e-statics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
build:
context: .
dockerfile: ./dockerfiles/playwright/Dockerfile
command: yarn run test:e2e:ci
command: npm run test:e2e:ci
environment:
BASE_URL: "http://nginx-server"
volumes:
Expand Down
26 changes: 26 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const packageJSON = require('./package.json');

const withPlugins = require('next-compose-plugins');
Expand All @@ -13,6 +14,20 @@ let transpiledPackages = [
'@rescui/menu'
];

if (process.env.USE_FALLBACK_FOR_INTERNAL_PACKAGES !== '1') {
transpiledPackages.push(
'@webteam/youtube-playlist',
'@webteam/ui-contexts',
'@webteam/colors',
'@webteam/toggle',
'@webteam/youtube-player',
'@webteam/use-fetch',
'@webteam/use-async-data',
'@webteam/bem-cn-fast',
'@webteam/list'
)
}
Comment on lines +18 to +29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a workaround, it is expected to be here, we do the same with the RescUI components above.


const withTranspile = nextTranspileModules(transpiledPackages);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably keep it for now, but I found out that next-transpile-modules is deprecated see https://github.com/martpie/next-transpile-modules/releases/tag/the-end


const nextConfig = {
Expand Down Expand Up @@ -44,6 +59,17 @@ const nextConfig = {
type: 'asset/source'
});

const useFallbackForInternalPackages = process.env.USE_FALLBACK_FOR_INTERNAL_PACKAGES === '1';

config.resolve.alias = config.resolve.alias || {};

if (useFallbackForInternalPackages) {
config.resolve.alias['@webteam'] = path.resolve(
__dirname,
'components/webteam-fallback'
);
}
Comment on lines +66 to +71
Copy link
Collaborator Author

@nikpachoo nikpachoo Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the place, where all the magic happens.
We just resolve another module in case the env variable is set.


return config;
},
};
Expand Down
Loading