From 31fc45dc7d0da1ea3c1b45433a5d4e51010e6917 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Mon, 21 Apr 2025 16:53:02 +0200 Subject: [PATCH 1/3] docs: add since badge wip wip wip --- website/docs/experiments/env_precedence.mdx | 4 ++- website/docs/getting_started.mdx | 14 ++++++-- website/docs/reference/cli.mdx | 6 ++-- website/docs/taskfile_versions.mdx | 4 +++ website/docs/usage.mdx | 10 ++++-- website/package.json | 3 +- website/src/components/AvailableSince.tsx | 36 +++++++++++++++++++++ website/src/css/custom.css | 4 +++ website/yarn.lock | 5 +++ 9 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 website/src/components/AvailableSince.tsx diff --git a/website/docs/experiments/env_precedence.mdx b/website/docs/experiments/env_precedence.mdx index 535a676e1c..aeefda228e 100644 --- a/website/docs/experiments/env_precedence.mdx +++ b/website/docs/experiments/env_precedence.mdx @@ -2,8 +2,10 @@ slug: '/experiments/env-precedence' --- -# Env Precedence (#1038) +import AvailableSinceBadge from '../../src/components/AvailableSince'; +# Env Precedence (#1038) + :::caution All experimental features are subject to breaking changes and/or removal _at any diff --git a/website/docs/getting_started.mdx b/website/docs/getting_started.mdx index e79108d26d..5ddb981d5a 100644 --- a/website/docs/getting_started.mdx +++ b/website/docs/getting_started.mdx @@ -3,6 +3,8 @@ slug: /getting-started/ sidebar_position: 3 --- +import AvailableSinceBadge from '../src/components/AvailableSince'; + # Getting Started The following guide will help introduce you to the basics of Task. We'll cover @@ -18,8 +20,13 @@ Once Task is installed, you can create your first Taskfile by running: task --init ``` -This will create a file called `Taskfile.yml` in the current directory. If you -want to create the file in another directory, you can pass an absolute or +This will create a file called `Taskfile.yml` in the current directory. + +--- + + + +If you want to create the file in another directory, you can pass an absolute or relative path to the directory into the command: ```shell @@ -33,6 +40,9 @@ the file: task --init Custom.yml ``` +--- + + This will create a Taskfile that looks something like this: ```yaml diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx index e5094a9a42..99f9823bdf 100644 --- a/website/docs/reference/cli.mdx +++ b/website/docs/reference/cli.mdx @@ -21,7 +21,7 @@ If `--` is given, all remaining arguments will be assigned to a special ## Flags | Short | Flag | Type | Default | Description | -| ----- | --------------------------- | -------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|-------|-----------------------------|----------|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `-c` | `--color` | `bool` | `true` | Colored output. Enabled by default. Set flag to `false` or use `NO_COLOR=1` to disable. | | `-C` | `--concurrency` | `int` | `0` | Limit number tasks to run concurrently. Zero means unlimited. | | `-d` | `--dir` | `string` | Working directory | Sets the directory in which Task will execute and look for a Taskfile. | @@ -45,10 +45,10 @@ If `--` is given, all remaining arguments will be assigned to a special | `-y` | `--yes` | `bool` | `false` | Assume "yes" as answer to all prompts. | | | `--status` | `bool` | `false` | Exits with non-zero exit code if any of the given tasks is not up-to-date. | | | `--summary` | `bool` | `false` | Show summary about a task. | -| `-t` | `--taskfile` | `string` | | Taskfile path to run.
Check the list of default filenames [here](../usage/#supported-file-names). | +| `-t` | `--taskfile` | `string` | | Taskfile path to run.
Check the list of default filenames [here](../usage/#supported-file-names). | | `-v` | `--verbose` | `bool` | `false` | Enables verbose mode. | | | `--version` | `bool` | `false` | Show Task version. | -| `-w` | `--watch` | `bool` | `false` | Enables watch of the given task. +| `-w` | `--watch` | `bool` | `false` | Enables watch of the given task. | ## Exit Codes diff --git a/website/docs/taskfile_versions.mdx b/website/docs/taskfile_versions.mdx index 23c8ac02dc..9295d10517 100644 --- a/website/docs/taskfile_versions.mdx +++ b/website/docs/taskfile_versions.mdx @@ -3,6 +3,8 @@ slug: /taskfile-versions/ sidebar_position: 6 --- +import AvailableSinceBadge from '../src/components/AvailableSince'; + # Taskfile Versions The Taskfile schema slowly changes as new features are added and old ones are @@ -56,6 +58,8 @@ Instead, we should start the file like this: version: '3.17' ``` + + Now when someone tries to run the Taskfile with an older version of Task, they will receive an error prompting them to upgrade their version of Task to `v3.17.0` or greater. diff --git a/website/docs/usage.mdx b/website/docs/usage.mdx index e672cf822d..e490a29f19 100644 --- a/website/docs/usage.mdx +++ b/website/docs/usage.mdx @@ -3,6 +3,7 @@ slug: /usage/ sidebar_position: 4 --- +import AvailableSinceBadge from '../src/components/AvailableSince'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; @@ -311,6 +312,8 @@ includes: ### Flatten includes + + You can flatten the included Taskfile tasks into the main Taskfile by using the `flatten` option. It means that the included Taskfile tasks will be available without the namespace. @@ -1100,7 +1103,7 @@ variable types are supported: - `int` - `float` - `array` -- `map` +- `map` :::note @@ -1373,6 +1376,7 @@ tasks: ``` ### Looping over a matrix + If you need to loop over all permutations of multiple lists, you can use the `matrix` property. This should be familiar to anyone who has used a matrix in a @@ -1447,7 +1451,7 @@ tasks: - + ```yaml version: '3' @@ -1495,7 +1499,7 @@ tasks: - + ```yaml version: '3' diff --git a/website/package.json b/website/package.json index c15c3fc30b..da2a9bcf00 100644 --- a/website/package.json +++ b/website/package.json @@ -27,7 +27,8 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "remark-gfm": "^4.0.0", - "remark-github": "^12.0.0" + "remark-github": "^12.0.0", + "react-icons" : "^5.5.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "^3.5.2", diff --git a/website/src/components/AvailableSince.tsx b/website/src/components/AvailableSince.tsx new file mode 100644 index 0000000000..3dcc87dbc4 --- /dev/null +++ b/website/src/components/AvailableSince.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { FaCalendarCheck } from 'react-icons/fa'; +import { useColorMode } from '@docusaurus/theme-common'; + +type Props = { + version: string; +}; + +export default function AvailableSince({ version }: Props) { + const { colorMode } = useColorMode(); + + const isDark = colorMode === 'dark'; + + const style = { + display: 'inline-flex', + alignItems: 'center', + border: `1px solid var(--ifm-color-primary)`, + color: isDark ? '#fffdf9' : 'var(--ifm-color-primary)', + padding: '0.2em 0.6em', + borderRadius: '999px', + fontSize: '0.8em', + fontWeight: 500, + backgroundColor: isDark ? 'var(--ifm-color-primary)' : '#f0fdfa', + marginBottom: 'calc(var(--ifm-heading-vertical-rhythm-bottom) * var(--ifm-leading))', + }; + + + return ( + + + Since {version} + + ); +} + + diff --git a/website/src/css/custom.css b/website/src/css/custom.css index 293a837913..5a1942c8d9 100644 --- a/website/src/css/custom.css +++ b/website/src/css/custom.css @@ -121,3 +121,7 @@ .icon-bluesky::before { mask-image: url('/img/icon-bluesky.svg'); } + +h3:has(+ .available-since-badge) { + margin-bottom: 0.5rem; +} diff --git a/website/yarn.lock b/website/yarn.lock index 540e89ed37..da5abe204d 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -7441,6 +7441,11 @@ react-fast-compare@^3.2.0: react-fast-compare "^3.2.0" shallowequal "^1.1.0" +react-icons@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-5.5.0.tgz#8aa25d3543ff84231685d3331164c00299cdfaf2" + integrity sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw== + react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" From 9d67d2688d7419b973a12958a38ca9a533295d34 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Tue, 22 Apr 2025 14:09:32 +0200 Subject: [PATCH 2/3] apply prettier --- .editorconfig | 2 +- website/src/components/AvailableSince.tsx | 46 +++++++++++------------ 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index 34e2c9cf3a..97693c7310 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,6 @@ charset = utf-8 trim_trailing_whitespace = true indent_style = tab -[*.{md,mdx,yml,yaml,json,toml,htm,html,js,ts,css,svg,sh,bash,fish}] +[*.{md,mdx,yml,yaml,json,toml,htm,html,js,ts,css,svg,sh,bash,fish,tsx}] indent_style = space indent_size = 2 diff --git a/website/src/components/AvailableSince.tsx b/website/src/components/AvailableSince.tsx index 3dcc87dbc4..da2d3bdb27 100644 --- a/website/src/components/AvailableSince.tsx +++ b/website/src/components/AvailableSince.tsx @@ -3,34 +3,32 @@ import { FaCalendarCheck } from 'react-icons/fa'; import { useColorMode } from '@docusaurus/theme-common'; type Props = { - version: string; + version: string; }; export default function AvailableSince({ version }: Props) { - const { colorMode } = useColorMode(); - - const isDark = colorMode === 'dark'; - - const style = { - display: 'inline-flex', - alignItems: 'center', - border: `1px solid var(--ifm-color-primary)`, - color: isDark ? '#fffdf9' : 'var(--ifm-color-primary)', - padding: '0.2em 0.6em', - borderRadius: '999px', - fontSize: '0.8em', - fontWeight: 500, - backgroundColor: isDark ? 'var(--ifm-color-primary)' : '#f0fdfa', - marginBottom: 'calc(var(--ifm-heading-vertical-rhythm-bottom) * var(--ifm-leading))', - }; - - - return ( - + const { colorMode } = useColorMode(); + + const isDark = colorMode === 'dark'; + + const style = { + display: 'inline-flex', + alignItems: 'center', + border: `1px solid var(--ifm-color-primary)`, + color: isDark ? '#fffdf9' : 'var(--ifm-color-primary)', + padding: '0.2em 0.6em', + borderRadius: '999px', + fontSize: '0.8em', + fontWeight: 500, + backgroundColor: isDark ? 'var(--ifm-color-primary)' : '#f0fdfa', + marginBottom: + 'calc(var(--ifm-heading-vertical-rhythm-bottom) * var(--ifm-leading))' + }; + + return ( + Since {version} - ); + ); } - - From 0983882ff3f0c7742adc13ce388a120859b022e5 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Tue, 22 Apr 2025 14:25:32 +0200 Subject: [PATCH 3/3] use custom alias --- website/docs/experiments/env_precedence.mdx | 2 +- website/docs/getting_started.mdx | 2 +- website/docs/taskfile_versions.mdx | 2 +- website/docs/usage.mdx | 2 +- website/docusaurus.config.ts | 32 +++++++++---------- website/plugins/webpack-alias-plugin/index.js | 16 ++++++++++ website/tsconfig.json | 5 ++- .../experiments/env_precedence.mdx | 4 ++- .../version-latest/getting_started.mdx | 14 ++++++-- .../version-latest/reference/cli.mdx | 6 ++-- .../version-latest/taskfile_versions.mdx | 4 +++ .../versioned_docs/version-latest/usage.mdx | 10 ++++-- 12 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 website/plugins/webpack-alias-plugin/index.js diff --git a/website/docs/experiments/env_precedence.mdx b/website/docs/experiments/env_precedence.mdx index aeefda228e..99caef5b70 100644 --- a/website/docs/experiments/env_precedence.mdx +++ b/website/docs/experiments/env_precedence.mdx @@ -2,7 +2,7 @@ slug: '/experiments/env-precedence' --- -import AvailableSinceBadge from '../../src/components/AvailableSince'; +import AvailableSinceBadge from '~/components/AvailableSince'; # Env Precedence (#1038) diff --git a/website/docs/getting_started.mdx b/website/docs/getting_started.mdx index 5ddb981d5a..b96d42001d 100644 --- a/website/docs/getting_started.mdx +++ b/website/docs/getting_started.mdx @@ -3,7 +3,7 @@ slug: /getting-started/ sidebar_position: 3 --- -import AvailableSinceBadge from '../src/components/AvailableSince'; +import AvailableSinceBadge from '~/components/AvailableSince'; # Getting Started diff --git a/website/docs/taskfile_versions.mdx b/website/docs/taskfile_versions.mdx index 9295d10517..f972d50de1 100644 --- a/website/docs/taskfile_versions.mdx +++ b/website/docs/taskfile_versions.mdx @@ -3,7 +3,7 @@ slug: /taskfile-versions/ sidebar_position: 6 --- -import AvailableSinceBadge from '../src/components/AvailableSince'; +import AvailableSinceBadge from '~/components/AvailableSince'; # Taskfile Versions diff --git a/website/docs/usage.mdx b/website/docs/usage.mdx index e490a29f19..e975d4604d 100644 --- a/website/docs/usage.mdx +++ b/website/docs/usage.mdx @@ -3,7 +3,7 @@ slug: /usage/ sidebar_position: 4 --- -import AvailableSinceBadge from '../src/components/AvailableSince'; +import AvailableSinceBadge from '~/components/AvailableSince'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index b89535a193..d9948242e1 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -1,4 +1,4 @@ -import type {Config} from '@docusaurus/types'; +import type { Config } from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; import { EnumChangefreq } from 'sitemap'; @@ -40,6 +40,7 @@ const config: Config = { } } }, + plugins: [require.resolve('./plugins/webpack-alias-plugin')], presets: [ [ @@ -67,10 +68,7 @@ const config: Config = { blogSidebarCount: 'ALL' }, theme: { - customCss: [ - './src/css/custom.css', - './src/css/carbon.css', - ] + customCss: ['./src/css/custom.css', './src/css/carbon.css'] }, gtag: { trackingID: 'G-4RT25NXQ7N', @@ -81,7 +79,7 @@ const config: Config = { priority: 0.5, ignorePatterns: ['/tags/**'] } - } satisfies Preset.Options, + } satisfies Preset.Options ] ], @@ -92,7 +90,7 @@ const config: Config = { } ], - themeConfig:{ + themeConfig: { metadata: [ { name: 'og:image', @@ -125,38 +123,38 @@ const config: Config = { { type: 'docsVersionDropdown', position: 'right', - dropdownActiveClassDisabled: true, + dropdownActiveClassDisabled: true }, { href: GITHUB_URL, title: 'GitHub', position: 'right', - className: "header-icon-link icon-github", + className: 'header-icon-link icon-github' }, { href: DISCORD_URL, title: 'Discord', position: 'right', - className: "header-icon-link icon-discord", + className: 'header-icon-link icon-discord' }, { href: TWITTER_URL, title: 'X (Twitter)', position: 'right', - className: "header-icon-link icon-twitter", + className: 'header-icon-link icon-twitter' }, { href: BLUESKY_URL, title: 'Bluesky', position: 'right', - className: "header-icon-link icon-bluesky", + className: 'header-icon-link icon-bluesky' }, { href: MASTODON_URL, title: 'Mastodon', rel: 'me', position: 'right', - className: "header-icon-link icon-mastodon", + className: 'header-icon-link icon-mastodon' } ] }, @@ -232,9 +230,9 @@ const config: Config = { theme: lightCodeTheme, darkTheme: darkCodeTheme, additionalLanguages: [ - "bash", // aka. shell - "json", - "powershell" + 'bash', // aka. shell + 'json', + 'powershell' ] }, // NOTE(@andreynering): Don't worry, these keys are meant to be public =) @@ -243,7 +241,7 @@ const config: Config = { apiKey: '34b64ae4fc8d9da43d9a13d9710aaddc', indexName: 'taskfile' } - } satisfies Preset.ThemeConfig, + } satisfies Preset.ThemeConfig }; export default config; diff --git a/website/plugins/webpack-alias-plugin/index.js b/website/plugins/webpack-alias-plugin/index.js new file mode 100644 index 0000000000..56d9b50f9e --- /dev/null +++ b/website/plugins/webpack-alias-plugin/index.js @@ -0,0 +1,16 @@ +const path = require('path'); + +module.exports = function webpackAliasPlugin(context, options) { + return { + name: 'webpack-alias-plugin', + configureWebpack(config, isServer, utils) { + return { + resolve: { + alias: { + '~': path.resolve(__dirname, '../../src'), + }, + }, + }; + }, + }; +}; diff --git a/website/tsconfig.json b/website/tsconfig.json index d250afaedd..0deb711e1e 100644 --- a/website/tsconfig.json +++ b/website/tsconfig.json @@ -1,6 +1,9 @@ { "extends": "@docusaurus/tsconfig", "compilerOptions": { - "baseUrl": "." + "baseUrl": ".", + "paths": { + "~/*": ["src/*"] + } } } diff --git a/website/versioned_docs/version-latest/experiments/env_precedence.mdx b/website/versioned_docs/version-latest/experiments/env_precedence.mdx index 535a676e1c..99caef5b70 100644 --- a/website/versioned_docs/version-latest/experiments/env_precedence.mdx +++ b/website/versioned_docs/version-latest/experiments/env_precedence.mdx @@ -2,8 +2,10 @@ slug: '/experiments/env-precedence' --- -# Env Precedence (#1038) +import AvailableSinceBadge from '~/components/AvailableSince'; +# Env Precedence (#1038) + :::caution All experimental features are subject to breaking changes and/or removal _at any diff --git a/website/versioned_docs/version-latest/getting_started.mdx b/website/versioned_docs/version-latest/getting_started.mdx index e79108d26d..b96d42001d 100644 --- a/website/versioned_docs/version-latest/getting_started.mdx +++ b/website/versioned_docs/version-latest/getting_started.mdx @@ -3,6 +3,8 @@ slug: /getting-started/ sidebar_position: 3 --- +import AvailableSinceBadge from '~/components/AvailableSince'; + # Getting Started The following guide will help introduce you to the basics of Task. We'll cover @@ -18,8 +20,13 @@ Once Task is installed, you can create your first Taskfile by running: task --init ``` -This will create a file called `Taskfile.yml` in the current directory. If you -want to create the file in another directory, you can pass an absolute or +This will create a file called `Taskfile.yml` in the current directory. + +--- + + + +If you want to create the file in another directory, you can pass an absolute or relative path to the directory into the command: ```shell @@ -33,6 +40,9 @@ the file: task --init Custom.yml ``` +--- + + This will create a Taskfile that looks something like this: ```yaml diff --git a/website/versioned_docs/version-latest/reference/cli.mdx b/website/versioned_docs/version-latest/reference/cli.mdx index e5094a9a42..99f9823bdf 100644 --- a/website/versioned_docs/version-latest/reference/cli.mdx +++ b/website/versioned_docs/version-latest/reference/cli.mdx @@ -21,7 +21,7 @@ If `--` is given, all remaining arguments will be assigned to a special ## Flags | Short | Flag | Type | Default | Description | -| ----- | --------------------------- | -------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|-------|-----------------------------|----------|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `-c` | `--color` | `bool` | `true` | Colored output. Enabled by default. Set flag to `false` or use `NO_COLOR=1` to disable. | | `-C` | `--concurrency` | `int` | `0` | Limit number tasks to run concurrently. Zero means unlimited. | | `-d` | `--dir` | `string` | Working directory | Sets the directory in which Task will execute and look for a Taskfile. | @@ -45,10 +45,10 @@ If `--` is given, all remaining arguments will be assigned to a special | `-y` | `--yes` | `bool` | `false` | Assume "yes" as answer to all prompts. | | | `--status` | `bool` | `false` | Exits with non-zero exit code if any of the given tasks is not up-to-date. | | | `--summary` | `bool` | `false` | Show summary about a task. | -| `-t` | `--taskfile` | `string` | | Taskfile path to run.
Check the list of default filenames [here](../usage/#supported-file-names). | +| `-t` | `--taskfile` | `string` | | Taskfile path to run.
Check the list of default filenames [here](../usage/#supported-file-names). | | `-v` | `--verbose` | `bool` | `false` | Enables verbose mode. | | | `--version` | `bool` | `false` | Show Task version. | -| `-w` | `--watch` | `bool` | `false` | Enables watch of the given task. +| `-w` | `--watch` | `bool` | `false` | Enables watch of the given task. | ## Exit Codes diff --git a/website/versioned_docs/version-latest/taskfile_versions.mdx b/website/versioned_docs/version-latest/taskfile_versions.mdx index 23c8ac02dc..f972d50de1 100644 --- a/website/versioned_docs/version-latest/taskfile_versions.mdx +++ b/website/versioned_docs/version-latest/taskfile_versions.mdx @@ -3,6 +3,8 @@ slug: /taskfile-versions/ sidebar_position: 6 --- +import AvailableSinceBadge from '~/components/AvailableSince'; + # Taskfile Versions The Taskfile schema slowly changes as new features are added and old ones are @@ -56,6 +58,8 @@ Instead, we should start the file like this: version: '3.17' ``` + + Now when someone tries to run the Taskfile with an older version of Task, they will receive an error prompting them to upgrade their version of Task to `v3.17.0` or greater. diff --git a/website/versioned_docs/version-latest/usage.mdx b/website/versioned_docs/version-latest/usage.mdx index e672cf822d..e975d4604d 100644 --- a/website/versioned_docs/version-latest/usage.mdx +++ b/website/versioned_docs/version-latest/usage.mdx @@ -3,6 +3,7 @@ slug: /usage/ sidebar_position: 4 --- +import AvailableSinceBadge from '~/components/AvailableSince'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; @@ -311,6 +312,8 @@ includes: ### Flatten includes + + You can flatten the included Taskfile tasks into the main Taskfile by using the `flatten` option. It means that the included Taskfile tasks will be available without the namespace. @@ -1100,7 +1103,7 @@ variable types are supported: - `int` - `float` - `array` -- `map` +- `map` :::note @@ -1373,6 +1376,7 @@ tasks: ``` ### Looping over a matrix + If you need to loop over all permutations of multiple lists, you can use the `matrix` property. This should be familiar to anyone who has used a matrix in a @@ -1447,7 +1451,7 @@ tasks:
- + ```yaml version: '3' @@ -1495,7 +1499,7 @@ tasks: - + ```yaml version: '3'