Skip to content
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

fix: sync libs and docs versions #136

Merged
merged 2 commits into from
Dec 4, 2023
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
run: npm ci
- name: Shape libs-data.json
run: npm run fetch-data
- name: Shape packages-versions.json
run: npm run get-packages-versions
- name: Lint Files
run: npm run lint
- name: Typecheck
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ jobs:
run: npm run build && npm run export
env:
GITHUB_TOKEN: ${{ github.token }}
UIKIT_TARGET_BRANCH: 'main'
DATE_COMPONENTS_TARGET_BRANCH: 'main'
# Deploy
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ yarn-debug.log*
yarn-error.log*

/src/libs-data.json
/src/packages-versions.json

.env
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ npm run start
```bash
# .env file

UIKIT_TARGET_BRANCH="your-branch" # default main, target branch for pulling documentation from uikit

COMPONENTS_TARGET_BRANCH="your-branch" # default main, target branch for pulling documentation from components

DATE_COMPONENTS_TARGET_BRANCH="your-branch" # default main, target branch for pulling documentation from date-components

GITHUB_PROFILE="your profile" # default gravity-ui, target profile for pulling documentation from components
```
5 changes: 0 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
});

if (!options.isServer) {
config.resolve.fallback.fs = false;

Check warning on line 60 in next.config.js

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'config'
}

return config;
Expand All @@ -70,11 +70,6 @@
module.exports = withPlugins(plugins, {
reactStrictMode: true,
output: 'export',
env: {
UIKIT_TARGET_BRANCH: process.env.UIKIT_TARGET_BRANCH,
COMPONENTS_TARGET_BRANCH: process.env.COMPONENTS_TARGET_BRANCH,
DATE_COMPONENTS_TARGET_BRANCH: process.env.DATE_COMPONENTS_TARGET_BRANCH,
},
experimental: {
esmExternals: 'loose',
},
Expand Down
8,757 changes: 1,583 additions & 7,174 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"private": true,
"homepage": "https://gravity-ui.com/",
"dependencies": {
"@doc-tools/transform": "^2.16.0",
"@gravity-ui/components": "^2.1.0",
"@gravity-ui/icons": "^2.3.0",
"@gravity-ui/page-constructor": "^3.9.2",
"@gravity-ui/uikit": "^5.12.1",
"@doc-tools/transform": "^3.11.0",
"@gravity-ui/components": "2.1.0",
"@gravity-ui/icons": "^2.8.1",
"@gravity-ui/page-constructor": "^4.41.0",
"@gravity-ui/uikit": "5.12.1",
"@mdx-js/mdx": "^2.3.0",
"@mdx-js/react": "^2.3.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down Expand Up @@ -63,18 +63,19 @@
},
"overrides": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"@gravity-ui/uikit": "^5.12.1"
"react-dom": "^17.0.2"
},
"scripts": {
"prepare": "husky install",
"start": "next dev",
"build": "next build",
"export": "next export -o build/",
"fetch-data": "node ./scripts/prefetch-data.mjs",
"prestart": "npm run fetch-data",
"prebuild": "npm run fetch-data",
"pretest": "npm run fetch-data",
"get-packages-versions": "node ./scripts/get-packages-versions.mjs",
"prepare-metadata": "npm run fetch-data && npm run get-packages-versions",
"prestart": "npm run prepare-metadata",
"prebuild": "npm run prepare-metadata",
"pretest": "npm run prepare-metadata",
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx .",
"lint:styles": "stylelint '{styles,src}/**/*.scss'",
"lint:prettier": "prettier --check '**/*.md'",
Expand Down
44 changes: 44 additions & 0 deletions scripts/get-packages-versions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

const packagesMap = {
'@gravity-ui/uikit': 'uikit',
'@gravity-ui/components': 'components',
// '@gravity-ui/date-components': 'date-components',
};

const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../package.json');
const packagesVersionsPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'../src/packages-versions.json',
);

const getPackagesVersions = () => {
try {
console.log('GET_PACKAGES_VERSIONS_START');

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const dependencies = packageJson.dependencies;

const result = {};
Object.keys(packagesMap).forEach((packageName) => {
if (dependencies[packageName]) {
result[packagesMap[packageName]] = dependencies[packageName].replace(/[\^~]/g, '');
} else {
console.warn('GET_PACKAGES_VERSIONS_MISSED_PACKAGE', packageName);
}
});

console.log('GET_PACKAGES_VERSIONS_RESULT', result);

fs.writeFileSync(packagesVersionsPath, JSON.stringify(result), 'utf8');

console.log('GET_PACKAGES_VERSIONS_FINISH');
} catch (err) {
console.error(err.message);
process.exit(1);
}
};

getPackagesVersions();
6 changes: 6 additions & 0 deletions src/blocks/CustomHeader/CustomHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
$block: '.#{variables.$ns}custom-header';

#{$block} {
margin-top: 76px;

@media (max-width: map-get(pcVariables.$gridBreakpoints, 'sm') - 1) {
margin-top: 32px;
}

&__title {
@include pcStyles.heading1();
max-width: 800px;
Expand Down
8 changes: 0 additions & 8 deletions src/components/Landing/Landing.scss

This file was deleted.

31 changes: 12 additions & 19 deletions src/components/Landing/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@ import {RoadmapBlock} from '../../blocks/RoadmapBlock/RoadmapBlock';
import {CustomBlock} from '../../blocks/constants';
import {landing} from '../../content/landing';
import {useSectionScroll} from '../../hooks/useSectionScroll';
import {block} from '../../utils';

import './Landing.scss';

const b = block('landing');

export const Landing: React.FC = () => {
useSectionScroll();

return (
<div className={b()}>
<PageConstructor
content={landing}
custom={{
blocks: {
[CustomBlock.CustomHeader]: CustomHeader,
[CustomBlock.CustomExtendedFeatures]: CustomExtendedFeatures,
[CustomBlock.CustomBanner]: CustomBanner,
[CustomBlock.Examples]: Examples,
[CustomBlock.Roadmap]: RoadmapBlock,
},
}}
/>
</div>
<PageConstructor
content={landing}
custom={{
blocks: {
[CustomBlock.CustomHeader]: CustomHeader,
[CustomBlock.CustomExtendedFeatures]: CustomExtendedFeatures,
[CustomBlock.CustomBanner]: CustomBanner,
[CustomBlock.Examples]: Examples,
[CustomBlock.Roadmap]: RoadmapBlock,
},
}}
/>
);
};
2 changes: 0 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ export const GA_ID = 'GTM-KHT6KD7';
export const MENU_ID = 'menu';
export const CONTENT_WRAPPER_ID = 'content';

export const TARGET_BRANCH = 'main';

export const TARGET_PROFILE = 'gravity-ui';
20 changes: 9 additions & 11 deletions src/content/components/utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import {TARGET_BRANCH, TARGET_PROFILE} from '../../constants';
import {TARGET_PROFILE} from '../../constants';
import packagesVersions from '../../packages-versions.json';
import {Repos} from '../../types/common';

const uikitTargetBranch = process.env.UIKIT_TARGET_BRANCH || TARGET_BRANCH;
const componentsTargetBranch = process.env.COMPONENTS_TARGET_BRANCH || TARGET_BRANCH;
const dateComponentsTargetBranch = process.env.DATE_COMPONENTS_TARGET_BRANCH || TARGET_BRANCH;
const githubTargetprofile = process.env.GITHUB_PROFILE || TARGET_PROFILE;
const githubTargetProfile = process.env.GITHUB_PROFILE || TARGET_PROFILE;

const TARGET_REPOS_BRANCHES = {
[Repos.Uikit]: uikitTargetBranch,
[Repos.Components]: componentsTargetBranch,
[Repos.DateComponents]: dateComponentsTargetBranch,
const TARGET_REPOS_VERSIONS = {
[Repos.Uikit]: packagesVersions[Repos.Uikit],
[Repos.Components]: packagesVersions[Repos.Components],
// [Repos.DateComponents]: packagesVersions['@gravity-ui/date-components'],
};

export type GetterProps = {componentName: string; repoName: Repos};
Expand All @@ -23,7 +21,7 @@ export const mappingOptions = (arr: string[]) =>
}));

export const getReadmeUrl: RepoInfoGetterFunc = ({componentName, repoName}) =>
`https://raw.githubusercontent.com/${githubTargetprofile}/${repoName}/${TARGET_REPOS_BRANCHES[repoName]}/src/components/${componentName}/README.md`;
`https://raw.githubusercontent.com/${githubTargetProfile}/${repoName}/v${TARGET_REPOS_VERSIONS[repoName]}/src/components/${componentName}/README.md`;

export const getGithubUrl: RepoInfoGetterFunc = ({componentName, repoName}) =>
`https://github.com/${githubTargetprofile}/${repoName}/tree/main/src/components/${componentName}`;
`https://github.com/${githubTargetProfile}/${repoName}/tree/main/src/components/${componentName}`;
17 changes: 12 additions & 5 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ body,
height: 100%;
}

body.g-root {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

body.g-root,
.g-root {
&_theme_dark {
--g-color-base-background: #160d1b;
background-color: var(--g-color-base-background);
}
}

.g-root {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

&:not(.sandbox) {
--g-font-family-sans: 'Inter', 'Helvetica Neue', 'Arial', 'Helvetica', sans-serif;
Expand Down Expand Up @@ -133,4 +136,8 @@ body.g-root {
}
}
}

.pc-page-constructor {
background-color: transparent;
}
}
2 changes: 1 addition & 1 deletion src/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum Repos {
Uikit = 'uikit',
Components = 'components',
DateComponents = 'date-components',
// DateComponents = 'date-components',
}
Loading