Compare commits

...
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] e32dbe5c5d Version Packages (#2071)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-22 15:23:42 +02:00
Ken de36269582 ✨ Oppdaterte shadow-tokens (#2041) 2023-06-22 15:12:42 +02:00
Julian Nymark 6cb6c52770 Changelog generator script (#2046) 2023-06-22 15:10:03 +02:00
Ken a877d24ed0 🐛 Fikset corder-bleed på komponentside-header 2023-06-21 17:10:43 +02:00
github-actions[bot]andgithub-actions[bot] a1b6332fa1 Version Packages (#2070)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-21 13:48:45 +02:00
Ken 99c08b8e4a Fikset bug i Popover/Helptext der popover gikk helt ut i kantene (#2069) 2023-06-21 13:44:59 +02:00
Ken d39ed906c6 🐛 Fikset ExpansionCard bug ved nesting (#2067) 2023-06-21 13:40:48 +02:00
35 changed files with 1585 additions and 134 deletions

No files matched your search

+4
View File
@@ -28,6 +28,10 @@ jobs:
node-version: 16.13.0
cache: yarn
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Restore cache
uses: actions/cache@v3
with:
+4
View File
@@ -1,5 +1,9 @@
# @navikt/aksel-icons
## 4.4.0
## 4.3.0
## 4.2.0
## 4.1.7
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-icons",
"version": "4.2.0",
"version": "4.4.0",
"author": "Aksel | NAV",
"homepage": "https://aksel.nav.no/ikoner",
"repository": {
+4
View File
@@ -1,5 +1,9 @@
# @navikt/aksel-stylelint
## 4.4.0
## 4.3.0
## 4.2.0
### Minor Changes
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel-stylelint",
"version": "4.2.0",
"version": "4.4.0",
"author": "Aksel | NAV",
"homepage": "https://aksel.nav.no/grunnleggende/kode/stylelint",
"repository": {
@@ -35,8 +35,8 @@
"dev": "yarn watch:lint"
},
"devDependencies": {
"@navikt/ds-css": "^4.2.0",
"@navikt/ds-tokens": "^4.2.0",
"@navikt/ds-css": "^4.4.0",
"@navikt/ds-tokens": "^4.4.0",
"@types/jest": "^29.0.0",
"concurrently": "7.2.1",
"copyfiles": "2.4.1",
+14
View File
@@ -1,5 +1,19 @@
# @navikt/aksel
## 4.4.0
### Patch Changes
- Updated dependencies [[`de3626958`](https://github.com/navikt/aksel/commit/de3626958266d1271840fa341c36500ab66b573d)]:
- @navikt/ds-css@4.4.0
## 4.3.0
### Patch Changes
- Updated dependencies [[`99c08b8e4`](https://github.com/navikt/aksel/commit/99c08b8e4ab33acd20a21719986452652ffe3c57), [`d39ed906c`](https://github.com/navikt/aksel/commit/d39ed906c61149ac823ebab2e8974a105e592163)]:
- @navikt/ds-css@4.3.0
## 4.2.0
### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/aksel",
"version": "4.2.0",
"version": "4.4.0",
"description": "Aksel command line interface. Handles css-imports, codemods and more",
"author": "Aksel | NAV designsystem team",
"license": "MIT",
@@ -29,7 +29,7 @@
},
"homepage": "https://aksel.nav.no/grunnleggende/kode/kommandolinje",
"dependencies": {
"@navikt/ds-css": "4.2.0",
"@navikt/ds-css": "4.4.0",
"axios": "1.3.6",
"chalk": "4.1.0",
"clipboardy": "^2.3.0",
+16
View File
@@ -1,5 +1,21 @@
# @navikt/ds-css
## 4.4.0
### Minor Changes
- [#2041](https://github.com/navikt/aksel/pull/2041) [`de3626958`](https://github.com/navikt/aksel/commit/de3626958266d1271840fa341c36500ab66b573d) Thanks [@KenAJoh](https://github.com/KenAJoh)! - Shadow-tokens er oppdatert til mer tydeligere varianter
## 4.3.0
### Minor Changes
- [#2069](https://github.com/navikt/aksel/pull/2069) [`99c08b8e4`](https://github.com/navikt/aksel/commit/99c08b8e4ab33acd20a21719986452652ffe3c57) Thanks [@KenAJoh](https://github.com/KenAJoh)! - Popover og Helptext har nå luft mot siden av skjerm på mindre flater
### Patch Changes
- [#2067](https://github.com/navikt/aksel/pull/2067) [`d39ed906c`](https://github.com/navikt/aksel/commit/d39ed906c61149ac823ebab2e8974a105e592163) Thanks [@KenAJoh](https://github.com/KenAJoh)! - :bug: Nested ExpansionCard fikk styling fra parent
## 4.2.0
### Minor Changes
+4
View File
@@ -278,3 +278,7 @@
visibility: hidden;
pointer-events: none;
}
.navds-date__popover:where(.navds-popover) {
border: none;
}
+6 -3
View File
@@ -77,7 +77,7 @@
margin-top: var(--a-spacing-1);
}
.navds-expansioncard--small :where(.navds-expansioncard__title--small) {
.navds-expansioncard--small > :where(.navds-expansioncard__header) :where(.navds-expansioncard__title--small) {
margin-top: var(--a-spacing-05);
}
@@ -115,7 +115,7 @@
transition: transform 150ms ease-in-out;
}
.navds-expansioncard--open :where(.navds-expansioncard__header-chevron) {
.navds-expansioncard--open > :where(.navds-expansioncard__header) :where(.navds-expansioncard__header-chevron) {
transform: translateY(0) rotate(180deg);
}
@@ -135,7 +135,10 @@
}
}
.navds-expansioncard--open :where(.navds-expansioncard__header-button):hover :where(.navds-expansioncard__header-chevron) {
.navds-expansioncard--open
> :where(.navds-expansioncard__header)
> :where(.navds-expansioncard__header-button):hover
:where(.navds-expansioncard__header-chevron) {
transform: translateY(-1px) rotate(180deg);
}
+1 -1
View File
@@ -33,7 +33,7 @@
.navds-help-text__popover.navds-popover {
background-color: var(--ac-help-text-popover-bg, var(--a-surface-info-subtle));
max-width: min(65ch, 90vw);
max-width: min(65ch, calc(100vw - 1.5rem));
--ac-popover-border: var(--a-border-info);
}
+1 -1
View File
@@ -13,7 +13,7 @@
}
.navds-link-panel:hover {
box-shadow: var(--a-shadow-medium);
box-shadow: var(--a-shadow-small);
border-color: var(--ac-link-panel-hover-border, var(--a-border-action));
}
+1
View File
@@ -9,6 +9,7 @@
position: relative;
overflow: auto;
max-height: 100%;
box-shadow: var(--a-shadow-xlarge);
}
.navds-modal__content {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-css",
"version": "4.2.0",
"version": "4.4.0",
"description": "CSS for NAV Designsystem",
"author": "Aksel | NAV designsystem team",
"keywords": [
@@ -27,7 +27,7 @@
"css:get-version": "node config/get-version.js"
},
"devDependencies": {
"@navikt/ds-tokens": "^4.2.0",
"@navikt/ds-tokens": "^4.4.0",
"cssnano": "6.0.0",
"fast-glob": "3.2.11",
"lodash": "4.17.21",
+1
View File
@@ -5,6 +5,7 @@
border: 1px solid;
border-color: var(--ac-popover-border, var(--a-border-default));
border-radius: var(--a-border-radius-medium);
max-width: calc(100vw - var(--a-spacing-6));
}
.navds-popover__content {
+22
View File
@@ -1,5 +1,27 @@
# @navikt/ds-react
## 4.4.0
### Minor Changes
- [#2041](https://github.com/navikt/aksel/pull/2041) [`de3626958`](https://github.com/navikt/aksel/commit/de3626958266d1271840fa341c36500ab66b573d) Thanks [@KenAJoh](https://github.com/KenAJoh)! - Shadow-tokens er oppdatert til mer tydeligere varianter
### Patch Changes
- Updated dependencies []:
- @navikt/aksel-icons@4.4.0
## 4.3.0
### Minor Changes
- [#2069](https://github.com/navikt/aksel/pull/2069) [`99c08b8e4`](https://github.com/navikt/aksel/commit/99c08b8e4ab33acd20a21719986452652ffe3c57) Thanks [@KenAJoh](https://github.com/KenAJoh)! - Popover og Helptext har nå luft mot siden av skjerm på mindre flater
### Patch Changes
- Updated dependencies []:
- @navikt/aksel-icons@4.3.0
## 4.2.0
### Minor Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-react",
"version": "4.2.0",
"version": "4.4.0",
"description": "Aksel react-components for NAV designsystem",
"author": "Aksel | NAV designsystem team",
"license": "MIT",
@@ -38,7 +38,7 @@
},
"dependencies": {
"@floating-ui/react": "0.24.1",
"@navikt/aksel-icons": "^4.2.0",
"@navikt/aksel-icons": "^4.4.0",
"@radix-ui/react-tabs": "1.0.0",
"@radix-ui/react-toggle-group": "1.0.0",
"clsx": "^1.2.1",
@@ -257,6 +257,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
role="dialog"
ref={ref}
strategy={strategy}
className="navds-date__popover"
bubbleEscape={bubbleEscape}
>
<DayPicker
@@ -208,7 +208,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
role="dialog"
ref={ref}
id={ariaId}
className="navds-date"
className="navds-date navds-date__popover"
strategy={strategy}
bubbleEscape={bubbleEscape}
>
+4 -4
View File
@@ -1,8 +1,8 @@
import {
arrow as flArrow,
autoUpdate,
flip,
arrow as flArrow,
offset as flOffset,
flip,
shift,
useClick,
useDismiss,
@@ -11,8 +11,8 @@ import {
} from "@floating-ui/react";
import cl from "clsx";
import React, {
forwardRef,
HTMLAttributes,
forwardRef,
useCallback,
useMemo,
useRef,
@@ -141,8 +141,8 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
onOpenChange: onClose,
middleware: [
flOffset(offset ?? (arrow ? 16 : 4)),
shift(),
flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
shift({ padding: 12 }),
flArrow({ element: arrowRef, padding: 8 }),
],
});
+4
View File
@@ -1,5 +1,9 @@
# @navikt/ds-tailwind
## 4.4.0
## 4.3.0
## 4.2.0
## 4.1.7
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tailwind",
"version": "4.2.0",
"version": "4.4.0",
"description": "Tailwind config based on @navikt/ds-tokens",
"author": "Aksel | NAV designsystem team",
"keywords": [
@@ -22,7 +22,7 @@
"directory": "@navikt/core/tailwind"
},
"devDependencies": {
"@navikt/ds-tokens": "^4.2.0",
"@navikt/ds-tokens": "^4.4.0",
"@types/jest": "^29.0.0",
"color": "4.2.3",
"jest": "^29.0.0",
+8
View File
@@ -1,5 +1,13 @@
# @navikt/ds-tokens
## 4.4.0
### Minor Changes
- [#2041](https://github.com/navikt/aksel/pull/2041) [`de3626958`](https://github.com/navikt/aksel/commit/de3626958266d1271840fa341c36500ab66b573d) Thanks [@KenAJoh](https://github.com/KenAJoh)! - Shadow-tokens er oppdatert til mer tydeligere varianter
## 4.3.0
## 4.2.0
## 4.1.7
+8 -5
View File
@@ -474,22 +474,25 @@
{ "name": "--a-border-radius-full", "value": "9999px" }
],
"shadow": [
{ "name": "--a-shadow-xsmall", "value": "0 1px 2px 0 rgba(0, 0, 0, 0.12)" },
{
"name": "--a-shadow-xsmall",
"value": "0px 1px 3px 0px rgba(0, 0, 0, 0.15), 0px 0px 1px 0px rgba(0, 0, 0, 0.20)"
},
{
"name": "--a-shadow-small",
"value": "0 1px 2px -1px rgba(0, 0, 0, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1)"
"value": "0px 3px 8px 0px rgba(0, 0, 0, 0.10), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.18)"
},
{
"name": "--a-shadow-medium",
"value": "0 2px 4px -2px rgba(0, 0, 0, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.1)"
"value": "0px 5px 12px 0px rgba(0, 0, 0, 0.13), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.15)"
},
{
"name": "--a-shadow-large",
"value": "0 4px 6px -4px rgba(0, 0, 0, 0.1), 0 10px 15px -3px rgba(0, 0, 0, 0.1)"
"value": "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 16px 0px rgba(0, 0, 0, 0.12), 0px 0px 1px 0px rgba(0, 0, 0, 0.12)"
},
{
"name": "--a-shadow-xlarge",
"value": "0 8px 10px -6px rgba(0, 0, 0, 0.1), 0 25px 50px -5px rgba(0, 0, 0, 0.1)"
"value": "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 24px 0px rgba(0, 0, 0, 0.18), 0px 0px 1px 0px rgba(0, 0, 0, 0.08)"
},
{ "name": "--a-shadow-focus", "value": "0 0 0 3px rgba(0, 52, 125, 1)" },
{
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@navikt/ds-tokens",
"version": "4.2.0",
"version": "4.4.0",
"description": "Design-tokens for NAV designsystem",
"author": "Aksel | NAV designsystem team",
"keywords": [
+5 -5
View File
@@ -2,19 +2,19 @@
"a": {
"shadow": {
"xsmall": {
"value": "0 1px 2px 0 rgba(0, 0, 0, 0.12)"
"value": "0px 1px 3px 0px rgba(0, 0, 0, 0.15), 0px 0px 1px 0px rgba(0, 0, 0, 0.20)"
},
"small": {
"value": "0 1px 2px -1px rgba(0, 0, 0, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1)"
"value": "0px 3px 8px 0px rgba(0, 0, 0, 0.10), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.18)"
},
"medium": {
"value": "0 2px 4px -2px rgba(0, 0, 0, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.1)"
"value": "0px 5px 12px 0px rgba(0, 0, 0, 0.13), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.15)"
},
"large": {
"value": "0 4px 6px -4px rgba(0, 0, 0, 0.1), 0 10px 15px -3px rgba(0, 0, 0, 0.1)"
"value": "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 16px 0px rgba(0, 0, 0, 0.12), 0px 0px 1px 0px rgba(0, 0, 0, 0.12)"
},
"xlarge": {
"value": "0 8px 10px -6px rgba(0, 0, 0, 0.1), 0 25px 50px -5px rgba(0, 0, 0, 0.1)"
"value": "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 24px 0px rgba(0, 0, 0, 0.18), 0px 0px 1px 0px rgba(0, 0, 0, 0.08)"
},
"focus": {
"inverted": {
@@ -10,9 +10,8 @@ const Shadow = ({ token }) => (
<div className="shadow" style={{ boxShadow: token }} />
<style>{`
.shadow {
width: 4rem;
height: 4rem;
background: #f7f7f7;
width: 12rem;
height: 6rem;
border-radius: 16px;
}
`}</style>
@@ -23,7 +22,7 @@ export const XSmall = () => <Shadow token="var(--a-shadow-xsmall)" />;
export const Small = () => <Shadow token="var(--a-shadow-small)" />;
export const Medium = () => <Shadow token="var(--a-shadow-medium)" />;
export const Large = () => <Shadow token="var(--a-shadow-large)" />;
export const XxLarge = () => <Shadow token="var(--a-shadow-xlarge)" />;
export const XLarge = () => <Shadow token="var(--a-shadow-xlarge)" />;
export const Focus = () => <Shadow token="var(--a-shadow-focus)" />;
export const FocusInverted = () => (
<Shadow token="var(--a-shadow-focus-inverted)" />
+1108
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -15,11 +15,11 @@
"website"
],
"dependencies": {
"@navikt/aksel-icons": "^4.2.0",
"@navikt/ds-css": "^4.2.0",
"@navikt/ds-react": "^4.2.0",
"@navikt/ds-tailwind": "^4.2.0",
"@navikt/ds-tokens": "^4.2.0"
"@navikt/aksel-icons": "^4.4.0",
"@navikt/ds-css": "^4.4.0",
"@navikt/ds-react": "^4.4.0",
"@navikt/ds-tailwind": "^4.4.0",
"@navikt/ds-tokens": "^4.4.0"
},
"devDependencies": {
"prettier-plugin-tailwindcss": "^0.2.3"
@@ -81,83 +81,81 @@ export const WithSidebar = ({
<main
tabIndex={-1}
id="hovedinnhold"
className="min-h-screen-header md:max-w-screen-sidebar relative w-full px-4 focus:outline-none sm:pl-6 sm:pr-6 md:pl-0"
className="min-h-screen-header md:max-w-screen-sidebar relative z-0 w-full px-4 focus:outline-none sm:pl-6 sm:pr-6 md:pl-0"
>
<div className="from-deepblue-700 rounded-xl bg-gradient-to-br via-blue-500 to-violet-700">
<div
className={cl(
"relative mb-10 min-h-[12.5rem] overflow-hidden rounded-xl pl-6 pr-4 md:pl-10 lg:pr-10",
{
"bg-surface-subtle flex items-center justify-between":
variant === "page",
"bg-deepblue-700/80 grid py-[4.25rem] pb-6":
variant !== "page",
}
<div
className={cl(
"relative mb-10 min-h-[12.5rem] overflow-hidden rounded-xl pl-6 pr-4 md:pl-10 lg:pr-10",
{
"bg-surface-subtle flex items-center justify-between":
variant === "page",
"bg-deepblue-700/80 grid py-[4.25rem] pb-6":
variant !== "page",
"before:from-deepblue-700 before:absolute before:inset-0 before:-z-10 before:rounded-xl before:bg-gradient-to-br before:via-blue-500 before:to-violet-700":
variant !== "page",
}
)}
>
<div className="z-[1]">
{variant === "page" && pageProps?.kategori && (
<Detail as="div" className="mb-2">
<NextLink
href={`/${pageType.type.toLowerCase()}`}
passHref
legacyBehavior
>
<Link className="text-text-default">
{capitalize(pageType.type)}
</Link>
</NextLink>{" "}
/ {capitalize(pageProps.kategori)}
</Detail>
)}
>
<div className="z-[1]">
{variant === "page" && pageProps?.kategori && (
<Detail as="div" className="mb-2">
<NextLink
href={`/${pageType.type.toLowerCase()}`}
passHref
legacyBehavior
>
<Link className="text-text-default">
{capitalize(pageType.type)}
</Link>
</NextLink>{" "}
/ {capitalize(pageProps.kategori)}
</Detail>
)}
<Heading
level="1"
size="xlarge"
className={cl({
"text-deepblue-800": variant === "page",
"text-text-on-action w-fit": variant !== "page",
})}
>
{pageType.title}
</Heading>
<div
className={cl({
"w-fit": variant !== "page",
})}
>
{intro}
</div>
<Heading
level="1"
size="xlarge"
className={cl({
"text-deepblue-800": variant === "page",
"text-text-on-action w-fit": variant !== "page",
})}
>
{pageType.title}
</Heading>
<div
className={cl({
"w-fit": variant !== "page",
})}
>
{intro}
</div>
{variant === "page" && pageProps.status?.bilde && (
<div
className={cl(
"relative hidden aspect-square h-[12.5rem] lg:block xl:mr-40",
{
"hue-rotate-[65deg]":
pageProps?.status?.tag === "beta",
}
)}
>
<Image
src={urlFor(pageProps.status?.bilde)
.auto("format")
.url()}
decoding="async"
layout="fill"
objectFit="contain"
aria-hidden
priority
/>
</div>
)}
{variant === "landingPage" && (
<div className="pointer-events-none absolute right-0 top-0 hidden sm:block">
<HeaderCube className="text-deepblue-300 z-[-1] max-h-full" />
</div>
)}
</div>
{variant === "page" && pageProps.status?.bilde && (
<div
className={cl(
"relative hidden aspect-square h-[12.5rem] lg:block xl:mr-40",
{
"hue-rotate-[65deg]": pageProps?.status?.tag === "beta",
}
)}
>
<Image
src={urlFor(pageProps.status?.bilde).auto("format").url()}
decoding="async"
layout="fill"
objectFit="contain"
aria-hidden
priority
/>
</div>
)}
{variant === "landingPage" && (
<div className="pointer-events-none absolute right-0 top-0 hidden sm:block">
<HeaderCube className="text-deepblue-300 z-[-1] max-h-full" />
</div>
)}
</div>
<div className={cl("sm:px-6 md:px-10", { flex: withToc })}>
{withToc && (
<TableOfContentsv2 changedState={pageProps["content"]} />
+2 -2
View File
@@ -10,8 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@navikt/ds-css": "4.2.0",
"@navikt/ds-react": "4.2.0",
"@navikt/ds-css": "4.4.0",
"@navikt/ds-react": "4.4.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
+2 -1
View File
@@ -11,13 +11,14 @@
"storybook:aksel": "concurrently \"yarn watch:tw\" \"cross-env STORYBOOK_STORIES=all storybook dev -p 6006\"",
"dev": "yarn workspace aksel.nav.no dev",
"docgen": "yarn workspaces foreach -p run docgen",
"changelog": "deno run --allow-read --allow-write --no-config scripts/deno/createMainChangelog.ts",
"chromatic": "npx chromatic --project-token x3xqdfgkujg --build-script-name build:storybook",
"build:storybook": "storybook build",
"test": "yarn workspaces foreach -p run test",
"lint": "yarn eslint . && yarn stylelint @navikt/**/*.css",
"lint:css": "yarn stylelint @navikt/**/*.css",
"changeset": "changeset",
"version": "changeset version",
"version": "changeset version && yarn changelog",
"release": "yarn boot && yarn docgen && changeset publish"
},
"workspaces": [
+233
View File
@@ -0,0 +1,233 @@
import { readFileSync, writeFileSync } from "node:fs";
import {
List,
ListItem,
Root,
Text,
Link,
Paragraph,
PhrasingContent,
} from "npm:@types/mdast";
import { Node } from "npm:@types/unist";
import { heading, root, text } from "npm:mdast-builder";
import remarkParse from "npm:remark-parse";
import remarkStringify from "npm:remark-stringify";
import { unified } from "npm:unified";
import { EXIT, SKIP, CONTINUE, visit } from "npm:unist-util-visit";
import { visitParents } from "npm:unist-util-visit-parents";
import { getChangelogs } from "./utils.ts";
/**
* Small diagram of the process:
original
markdown files
|
V
custom JSON
representation
of changelog
|
V
final markdown
*/
type PackageName = string;
type Version = string;
type VersionEntry = Record<PackageName, Node[]>;
type Changelog = Record<Version, VersionEntry>;
const upsertEntry = (
changelog: Changelog,
{
lastSeenPackage,
lastSeenVersion,
}: {
lastSeenPackage: string;
lastSeenVersion: string;
},
value: Node
) => {
changelog[lastSeenVersion] ??= {};
const raw_ast_nodes = changelog[lastSeenVersion][lastSeenPackage];
changelog[lastSeenVersion][lastSeenPackage] = raw_ast_nodes
? [...raw_ast_nodes, value]
: [value];
const updatedVersion = changelog[lastSeenVersion] || [];
changelog[lastSeenVersion] = updatedVersion;
};
const PROrCommitHashLink = (node: Root): Link | null => {
let infoLink: Link | null = null;
visit(node, (someChildNode) => {
if (someChildNode.type === "link") {
infoLink = structuredClone(someChildNode);
return EXIT;
}
});
return infoLink;
};
const processNode = (node: Root) => {
const infoLink = PROrCommitHashLink(node) || text("");
visitParents(node, (childNode, ancestors) => {
if (childNode.type === "text" && childNode.value.startsWith("! -")) {
const parent = ancestors.findLast(
(ancestor) => ancestor.type === "paragraph"
) as Paragraph;
visit(parent, (node, index, parent) => {
if (
node.type === "link" ||
(node.type === "text" && node.value === " Thanks ")
) {
if (parent && index !== null) {
parent.children.splice(index, 1);
return [CONTINUE, index];
}
}
if (node.type === "text" && node.value.startsWith("! -")) {
node.value = node.value.replace(/! (- )+/, "");
return;
}
});
parent.children.push(text(" ") as PhrasingContent);
parent.children.push(infoLink as PhrasingContent);
}
});
};
const parseMarkdownFiles = async (filePaths: string[]): Promise<Changelog> => {
const changelog: Changelog = {};
for (const filePath of filePaths) {
const fileContent = readFileSync(filePath, { encoding: "utf-8" });
const fileAST = await unified().use(remarkParse).parse(fileContent);
///////////////////
// filtering passes
///////////////////
// filter out all the 'Updated dependencies' nodes (at their relevant parent)
visitParents(fileAST, "paragraph", (node, ancestors) => {
if (
node.children[0].type === "text" &&
node.children[0].value.startsWith("Updated dependencies")
) {
const listIndex = ancestors.findLastIndex(
(ancestor) => ancestor.type === "list"
);
const parent = ancestors[listIndex] as List;
// we traversed up from child match to parent
// so we need to traverse down from parent to child
// again to find index of child within parent... yeah 😂
const indexWithinList = parent.children.findIndex((child: ListItem) => {
return child.children.some((grandchild) => {
let found = false;
visit(grandchild, (node) => {
if (
node.type === "text" &&
node.value.startsWith("Updated dependencies")
) {
found = true;
return EXIT;
}
});
return found;
});
});
if (parent && indexWithinList !== -1) {
parent.children.splice(indexWithinList, 1);
return [SKIP, indexWithinList];
}
}
});
// filter all empty list nodes
visit(fileAST, (node, index, parent) => {
if (node.type === "list" && node.children.length === 0) {
if (parent && index !== null) {
parent.children.splice(index, 1);
return [SKIP, index];
}
}
});
///////////////////
// upsert into custom JS object
///////////////////
let lastSeenPackage = "";
let lastSeenVersion = "";
visit(fileAST, (node) => {
if (node.type === "root") {
return;
}
if (node.type === "heading" && node.depth === 1) {
const childNode = node.children[0] as Text | undefined;
if (childNode && childNode.type === "text") {
const packageName = childNode.value;
if (packageName.startsWith("@navikt/")) {
lastSeenPackage = packageName;
}
}
} else if (node.type === "heading" && node.depth === 2) {
const childNode = node.children[0] as Text | undefined;
if (childNode && childNode.type === "text") {
const version = childNode.value;
if (version.match(/^\d+\.\d+\.\d+$/)) {
lastSeenVersion = version;
}
}
} else if (node.type === "heading" && node.depth === 3) {
const childNode = node.children[0] as Text | undefined;
if (childNode && childNode.type === "text") {
// ignore semver heading ('Major', 'Minor', 'Patch')
}
} else {
upsertEntry(
changelog,
{ lastSeenPackage, lastSeenVersion },
structuredClone(node)
);
}
return SKIP;
});
}
return changelog;
};
const createMainChangelog = async (changelog: Changelog): Promise<string> => {
const headings = [];
Object.entries(changelog).forEach(([version, versionEntry]) => {
headings.push(heading(2, [text(version)]));
for (const [packageName, changes] of Object.entries(versionEntry)) {
headings.push(heading(3, [text(packageName)]));
for (const change of changes) {
processNode(change as Root);
headings.push(change);
}
}
});
headings.unshift(heading(1, [text("Changelog")]));
const changelog_node_tree = root(headings) as Root;
const processed = await unified()
.use(remarkStringify, { bullet: "-" })
.stringify(changelog_node_tree);
return processed;
};
const changelogFiles = getChangelogs("./@navikt");
console.log("processing the following markdown files:", changelogFiles);
const changelogJSON = await parseMarkdownFiles(changelogFiles);
const changelog = await createMainChangelog(changelogJSON);
writeFileSync("CHANGELOG.md", changelog);
console.log("wrote to CHANGELOG.md");
+23
View File
@@ -0,0 +1,23 @@
import { readdirSync, statSync } from "node:fs";
export const getChangelogs = (path: string) => {
const changelogs: string[] = [];
const walkFiles = (dirPath: string) => {
const files = readdirSync(dirPath);
files.forEach((file) => {
const filePath = `${dirPath}/${file}`;
if (
statSync(filePath).isDirectory() &&
!file.startsWith("node_modules")
) {
walkFiles(filePath);
} else {
if (file.match(/^CHANGELOG\.md$/)) {
changelogs.push(filePath);
}
}
});
};
walkFiles(path);
return changelogs;
};
+18 -18
View File
@@ -3798,7 +3798,7 @@ __metadata:
languageName: node
linkType: hard
"@navikt/aksel-icons@^4.1.7, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
"@navikt/aksel-icons@^4.3.0, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
version: 0.0.0-use.local
resolution: "@navikt/aksel-icons@workspace:@navikt/aksel-icons"
dependencies:
@@ -3825,8 +3825,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel-stylelint@workspace:@navikt/aksel-stylelint"
dependencies:
"@navikt/ds-css": ^4.1.7
"@navikt/ds-tokens": ^4.1.7
"@navikt/ds-css": ^4.3.0
"@navikt/ds-tokens": ^4.3.0
"@types/jest": ^29.0.0
concurrently: 7.2.1
copyfiles: 2.4.1
@@ -3843,7 +3843,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel@workspace:@navikt/aksel"
dependencies:
"@navikt/ds-css": 4.1.7
"@navikt/ds-css": 4.3.0
"@types/inquirer": ^9.0.3
"@types/jest": ^29.0.0
axios: 1.3.6
@@ -3867,11 +3867,11 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-css@*, @navikt/ds-css@4.1.7, @navikt/ds-css@^4.1.7, @navikt/ds-css@workspace:@navikt/core/css":
"@navikt/ds-css@*, @navikt/ds-css@4.3.0, @navikt/ds-css@^4.3.0, @navikt/ds-css@workspace:@navikt/core/css":
version: 0.0.0-use.local
resolution: "@navikt/ds-css@workspace:@navikt/core/css"
dependencies:
"@navikt/ds-tokens": ^4.1.7
"@navikt/ds-tokens": ^4.3.0
cssnano: 6.0.0
fast-glob: 3.2.11
lodash: 4.17.21
@@ -3884,12 +3884,12 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-react@*, @navikt/ds-react@4.1.7, @navikt/ds-react@^4.1.7, @navikt/ds-react@workspace:@navikt/core/react":
"@navikt/ds-react@*, @navikt/ds-react@4.3.0, @navikt/ds-react@^4.3.0, @navikt/ds-react@workspace:@navikt/core/react":
version: 0.0.0-use.local
resolution: "@navikt/ds-react@workspace:@navikt/core/react"
dependencies:
"@floating-ui/react": 0.24.1
"@navikt/aksel-icons": ^4.1.7
"@navikt/aksel-icons": ^4.3.0
"@radix-ui/react-tabs": 1.0.0
"@radix-ui/react-toggle-group": 1.0.0
"@testing-library/dom": 8.13.0
@@ -3925,11 +3925,11 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-tailwind@^4.1.7, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
"@navikt/ds-tailwind@^4.3.0, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
version: 0.0.0-use.local
resolution: "@navikt/ds-tailwind@workspace:@navikt/core/tailwind"
dependencies:
"@navikt/ds-tokens": ^4.1.7
"@navikt/ds-tokens": ^4.3.0
"@types/jest": ^29.0.0
color: 4.2.3
jest: ^29.0.0
@@ -3940,7 +3940,7 @@ __metadata:
languageName: unknown
linkType: soft
"@navikt/ds-tokens@^4.1.7, @navikt/ds-tokens@workspace:@navikt/core/tokens":
"@navikt/ds-tokens@^4.3.0, @navikt/ds-tokens@workspace:@navikt/core/tokens":
version: 0.0.0-use.local
resolution: "@navikt/ds-tokens@workspace:@navikt/core/tokens"
dependencies:
@@ -7962,11 +7962,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "aksel.nav.no@workspace:aksel.nav.no"
dependencies:
"@navikt/aksel-icons": ^4.1.7
"@navikt/ds-css": ^4.1.7
"@navikt/ds-react": ^4.1.7
"@navikt/ds-tailwind": ^4.1.7
"@navikt/ds-tokens": ^4.1.7
"@navikt/aksel-icons": ^4.3.0
"@navikt/ds-css": ^4.3.0
"@navikt/ds-react": ^4.3.0
"@navikt/ds-tailwind": ^4.3.0
"@navikt/ds-tokens": ^4.3.0
prettier-plugin-tailwindcss: ^0.2.3
languageName: unknown
linkType: soft
@@ -22311,8 +22311,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "shadow-dom@workspace:examples/shadow-dom"
dependencies:
"@navikt/ds-css": 4.1.7
"@navikt/ds-react": 4.1.7
"@navikt/ds-css": 4.3.0
"@navikt/ds-react": 4.3.0
"@types/react": ^18.0.0
"@types/react-dom": ^18.0.0
"@vitejs/plugin-react": ^2.1.0