From 1eaa884e0fc1eafd474c5b8af2a5503e3b88c132 Mon Sep 17 00:00:00 2001 From: Misite Bao Date: Thu, 16 Mar 2023 12:24:56 +0800 Subject: [PATCH] docs(zh-Hans): add Simplified Chinese translation This commit is for testing only and will be forced to be overwritten. --- docs/i18n/zh-Hans/code.json | 198 +-- .../authors.yml | 5 + .../current/api_reference.md | 266 ++++ .../current/changelog.md | 438 ++++++ .../current/community.md | 50 + .../current/contributing.md | 69 + .../current/donate.md | 39 + .../current/faq.md | 40 + .../current/installation.md | 231 +++ .../current/intro.md | 48 + .../current/releasing.md | 35 + .../current/styleguide.md | 209 +++ .../current/taskfile_versions.md | 204 +++ .../current/usage.md | 1357 +++++++++++++++++ .../docusaurus-theme-classic/navbar.json | 2 +- 15 files changed, 3091 insertions(+), 100 deletions(-) create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/api_reference.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/changelog.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/contributing.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/donate.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/faq.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/installation.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/intro.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/releasing.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/styleguide.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/taskfile_versions.md create mode 100644 docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage.md diff --git a/docs/i18n/zh-Hans/code.json b/docs/i18n/zh-Hans/code.json index be706914ac..6b7d5530c2 100644 --- a/docs/i18n/zh-Hans/code.json +++ b/docs/i18n/zh-Hans/code.json @@ -1,396 +1,396 @@ { "theme.ErrorPageContent.title": { - "message": "This page crashed.", + "message": "页面已崩溃。", "description": "The title of the fallback page when the page crashed" }, "theme.ErrorPageContent.tryAgain": { - "message": "Try again", + "message": "重试", "description": "The label of the button to try again when the page crashed" }, "theme.NotFound.title": { - "message": "Page Not Found", + "message": "找不到页面", "description": "The title of the 404 page" }, "theme.NotFound.p1": { - "message": "We could not find what you were looking for.", + "message": "我们找不到您要找的页面。", "description": "The first paragraph of the 404 page" }, "theme.NotFound.p2": { - "message": "Please contact the owner of the site that linked you to the original URL and let them know their link is broken.", + "message": "请联系原始链接来源网站的所有者,并告知他们链接已损坏。", "description": "The 2nd paragraph of the 404 page" }, "theme.admonition.note": { - "message": "note", + "message": "备注", "description": "The default label used for the Note admonition (:::note)" }, "theme.admonition.tip": { - "message": "tip", + "message": "提示", "description": "The default label used for the Tip admonition (:::tip)" }, "theme.admonition.danger": { - "message": "danger", + "message": "危险", "description": "The default label used for the Danger admonition (:::danger)" }, "theme.admonition.info": { - "message": "info", + "message": "信息", "description": "The default label used for the Info admonition (:::info)" }, "theme.admonition.caution": { - "message": "caution", + "message": "警告", "description": "The default label used for the Caution admonition (:::caution)" }, "theme.BackToTopButton.buttonAriaLabel": { - "message": "Scroll back to top", + "message": "回到顶部", "description": "The ARIA label for the back to top button" }, "theme.blog.archive.title": { - "message": "Archive", + "message": "历史博文", "description": "The page & hero title of the blog archive page" }, "theme.blog.archive.description": { - "message": "Archive", + "message": "历史博文", "description": "The page & hero description of the blog archive page" }, "theme.blog.paginator.navAriaLabel": { - "message": "Blog list page navigation", + "message": "博文列表分页导航", "description": "The ARIA label for the blog pagination" }, "theme.blog.paginator.newerEntries": { - "message": "Newer Entries", + "message": "较新的博文", "description": "The label used to navigate to the newer blog posts page (previous page)" }, "theme.blog.paginator.olderEntries": { - "message": "Older Entries", + "message": "较旧的博文", "description": "The label used to navigate to the older blog posts page (next page)" }, "theme.blog.post.paginator.navAriaLabel": { - "message": "Blog post page navigation", + "message": "博文分页导航", "description": "The ARIA label for the blog posts pagination" }, "theme.blog.post.paginator.newerPost": { - "message": "Newer Post", + "message": "较新一篇", "description": "The blog post button label to navigate to the newer/previous post" }, "theme.blog.post.paginator.olderPost": { - "message": "Older Post", + "message": "较旧一篇", "description": "The blog post button label to navigate to the older/next post" }, "theme.blog.post.plurals": { - "message": "One post|{count} posts", + "message": "{count} 篇博文", "description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" }, "theme.blog.tagTitle": { - "message": "{nPosts} tagged with \"{tagName}\"", + "message": "{nPosts} 含有标签「{tagName}」", "description": "The title of the page for a blog tag" }, "theme.tags.tagsPageLink": { - "message": "View All Tags", + "message": "查看所有标签", "description": "The label of the link targeting the tag list page" }, "theme.colorToggle.ariaLabel": { - "message": "Switch between dark and light mode (currently {mode})", + "message": "切换浅色/暗黑模式(当前为{mode})", "description": "The ARIA label for the navbar color mode toggle" }, "theme.colorToggle.ariaLabel.mode.dark": { - "message": "dark mode", + "message": "暗黑模式", "description": "The name for the dark color mode" }, "theme.colorToggle.ariaLabel.mode.light": { - "message": "light mode", + "message": "浅色模式", "description": "The name for the light color mode" }, "theme.docs.breadcrumbs.home": { - "message": "Home page", + "message": "主页面", "description": "The ARIA label for the home page in the breadcrumbs" }, "theme.docs.breadcrumbs.navAriaLabel": { - "message": "Breadcrumbs", + "message": "页面路径", "description": "The ARIA label for the breadcrumbs" }, "theme.docs.DocCard.categoryDescription": { - "message": "{count} items", + "message": "{count} 个项目", "description": "The default description for a category card in the generated index about how many items this category includes" }, "theme.docs.paginator.navAriaLabel": { - "message": "Docs pages navigation", + "message": "文档分页导航", "description": "The ARIA label for the docs pagination" }, "theme.docs.paginator.previous": { - "message": "Previous", + "message": "上一页", "description": "The label used to navigate to the previous doc" }, "theme.docs.paginator.next": { - "message": "Next", + "message": "下一页", "description": "The label used to navigate to the next doc" }, "theme.docs.tagDocListPageTitle.nDocsTagged": { - "message": "One doc tagged|{count} docs tagged", + "message": "{count} 篇文档带有标签", "description": "Pluralized label for \"{count} docs tagged\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" }, "theme.docs.tagDocListPageTitle": { - "message": "{nDocsTagged} with \"{tagName}\"", + "message": "{nDocsTagged}「{tagName}」", "description": "The title of the page for a docs tag" }, "theme.docs.versionBadge.label": { - "message": "Version: {versionLabel}" + "message": "版本:{versionLabel}" }, "theme.docs.versions.unreleasedVersionLabel": { - "message": "This is unreleased documentation for {siteTitle} {versionLabel} version.", + "message": "此为 {siteTitle} {versionLabel} 版尚未发行的文档。", "description": "The label used to tell the user that he's browsing an unreleased doc version" }, "theme.docs.versions.unmaintainedVersionLabel": { - "message": "This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.", + "message": "此为 {siteTitle} {versionLabel} 版的文档,现已不再积极维护。", "description": "The label used to tell the user that he's browsing an unmaintained doc version" }, "theme.docs.versions.latestVersionSuggestionLabel": { - "message": "For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).", + "message": "最新的文档请参阅 {latestVersionLink} ({versionLabel})。", "description": "The label used to tell the user to check the latest version" }, "theme.docs.versions.latestVersionLinkLabel": { - "message": "latest version", + "message": "最新版本", "description": "The label used for the latest version suggestion link label" }, "theme.common.editThisPage": { - "message": "Edit this page", + "message": "编辑此页", "description": "The link label to edit the current page" }, "theme.common.headingLinkTitle": { - "message": "Direct link to heading", + "message": "标题的直接链接", "description": "Title for link to heading" }, "theme.lastUpdated.atDate": { - "message": " on {date}", + "message": "于 {date} ", "description": "The words used to describe on which date a page has been last updated" }, "theme.lastUpdated.byUser": { - "message": " by {user}", + "message": "由 {user} ", "description": "The words used to describe by who the page has been last updated" }, "theme.lastUpdated.lastUpdatedAtBy": { - "message": "Last updated{atDate}{byUser}", + "message": "最后{byUser}{atDate}更新", "description": "The sentence used to display when a page has been last updated, and by who" }, "theme.navbar.mobileVersionsDropdown.label": { - "message": "Versions", + "message": "选择版本", "description": "The label for the navbar versions dropdown on mobile view" }, "theme.tags.tagsListLabel": { - "message": "Tags:", + "message": "标签:", "description": "The label alongside a tag list" }, "theme.AnnouncementBar.closeButtonAriaLabel": { - "message": "Close", + "message": "关闭", "description": "The ARIA label for close button of announcement bar" }, "theme.blog.sidebar.navAriaLabel": { - "message": "Blog recent posts navigation", + "message": "最近博文导航", "description": "The ARIA label for recent posts in the blog sidebar" }, "theme.CodeBlock.copied": { - "message": "Copied", + "message": "复制成功", "description": "The copied button label on code blocks" }, "theme.CodeBlock.copyButtonAriaLabel": { - "message": "Copy code to clipboard", + "message": "复制代码到剪贴板", "description": "The ARIA label for copy code blocks button" }, "theme.CodeBlock.copy": { - "message": "Copy", + "message": "复制", "description": "The copy button label on code blocks" }, "theme.CodeBlock.wordWrapToggle": { - "message": "Toggle word wrap", + "message": "切换自动换行", "description": "The title attribute for toggle word wrapping button of code block lines" }, "theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": { - "message": "Toggle the collapsible sidebar category '{label}'", + "message": "打开/收起侧边栏菜单「{label}」", "description": "The ARIA label to toggle the collapsible sidebar category" }, "theme.navbar.mobileLanguageDropdown.label": { - "message": "Languages", + "message": "选择语言", "description": "The label for the mobile language switcher dropdown" }, "theme.TOCCollapsible.toggleButtonLabel": { - "message": "On this page", + "message": "本页总览", "description": "The label used by the button on the collapsible TOC component" }, "theme.blog.post.readMore": { - "message": "Read More", + "message": "阅读更多", "description": "The label used in blog post item excerpts to link to full blog posts" }, "theme.blog.post.readMoreLabel": { - "message": "Read more about {title}", + "message": "阅读 {title} 的全文", "description": "The ARIA label for the link to full blog posts from excerpts" }, "theme.blog.post.readingTime.plurals": { - "message": "One min read|{readingTime} min read", + "message": "阅读需 {readingTime} 分钟", "description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" }, "theme.docs.sidebar.collapseButtonTitle": { - "message": "Collapse sidebar", + "message": "收起侧边栏", "description": "The title attribute for collapse button of doc sidebar" }, "theme.docs.sidebar.collapseButtonAriaLabel": { - "message": "Collapse sidebar", + "message": "收起侧边栏", "description": "The title attribute for collapse button of doc sidebar" }, "theme.docs.sidebar.closeSidebarButtonAriaLabel": { - "message": "Close navigation bar", + "message": "关闭导航栏", "description": "The ARIA label for close button of mobile sidebar" }, "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": { - "message": "← Back to main menu", + "message": "← 回到主菜单", "description": "The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)" }, "theme.docs.sidebar.toggleSidebarButtonAriaLabel": { - "message": "Toggle navigation bar", + "message": "切换导航栏", "description": "The ARIA label for hamburger menu button of mobile navigation" }, "theme.docs.sidebar.expandButtonTitle": { - "message": "Expand sidebar", + "message": "展开侧边栏", "description": "The ARIA label and title attribute for expand button of doc sidebar" }, "theme.docs.sidebar.expandButtonAriaLabel": { - "message": "Expand sidebar", + "message": "展开侧边栏", "description": "The ARIA label and title attribute for expand button of doc sidebar" }, "theme.SearchBar.seeAll": { - "message": "See all {count} results" + "message": "查看全部 {count} 个结果" }, "theme.SearchPage.documentsFound.plurals": { - "message": "One document found|{count} documents found", + "message": "找到 {count} 份文件", "description": "Pluralized label for \"{count} documents found\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" }, "theme.SearchPage.existingResultsTitle": { - "message": "Search results for \"{query}\"", + "message": "「{query}」的搜索结果", "description": "The search page title for non-empty query" }, "theme.SearchPage.emptyResultsTitle": { - "message": "Search the documentation", + "message": "在文档中搜索", "description": "The search page title for empty query" }, "theme.SearchPage.inputPlaceholder": { - "message": "Type your search here", + "message": "在此输入搜索字词", "description": "The placeholder for search page input" }, "theme.SearchPage.inputLabel": { - "message": "Search", + "message": "搜索", "description": "The ARIA label for search page input" }, "theme.SearchPage.algoliaLabel": { - "message": "Search by Algolia", + "message": "通过 Algolia 搜索", "description": "The ARIA label for Algolia mention" }, "theme.SearchPage.noResultsText": { - "message": "No results were found", + "message": "未找到任何结果", "description": "The paragraph for empty search result" }, "theme.SearchPage.fetchingNewResults": { - "message": "Fetching new results...", + "message": "正在获取新的搜索结果...", "description": "The paragraph for fetching new search results" }, "theme.SearchBar.label": { - "message": "Search", + "message": "搜索", "description": "The ARIA label and placeholder for search button" }, "theme.SearchModal.searchBox.resetButtonTitle": { - "message": "Clear the query", + "message": "清除查询", "description": "The label and ARIA label for search box reset button" }, "theme.SearchModal.searchBox.cancelButtonText": { - "message": "Cancel", + "message": "取消", "description": "The label and ARIA label for search box cancel button" }, "theme.SearchModal.startScreen.recentSearchesTitle": { - "message": "Recent", + "message": "最近搜索", "description": "The title for recent searches" }, "theme.SearchModal.startScreen.noRecentSearchesText": { - "message": "No recent searches", + "message": "没有最近搜索", "description": "The text when no recent searches" }, "theme.SearchModal.startScreen.saveRecentSearchButtonTitle": { - "message": "Save this search", + "message": "保存这个搜索", "description": "The label for save recent search button" }, "theme.SearchModal.startScreen.removeRecentSearchButtonTitle": { - "message": "Remove this search from history", + "message": "从历史记录中删除这个搜索", "description": "The label for remove recent search button" }, "theme.SearchModal.startScreen.favoriteSearchesTitle": { - "message": "Favorite", + "message": "收藏", "description": "The title for favorite searches" }, "theme.SearchModal.startScreen.removeFavoriteSearchButtonTitle": { - "message": "Remove this search from favorites", + "message": "从收藏列表中删除这个搜索", "description": "The label for remove favorite search button" }, "theme.SearchModal.errorScreen.titleText": { - "message": "Unable to fetch results", + "message": "无法获取结果", "description": "The title for error screen of search modal" }, "theme.SearchModal.errorScreen.helpText": { - "message": "You might want to check your network connection.", + "message": "你可能需要检查网络连接。", "description": "The help text for error screen of search modal" }, "theme.SearchModal.footer.selectText": { - "message": "to select", + "message": "选中", "description": "The explanatory text of the action for the enter key" }, "theme.SearchModal.footer.selectKeyAriaLabel": { - "message": "Enter key", + "message": "Enter 键", "description": "The ARIA label for the Enter key button that makes the selection" }, "theme.SearchModal.footer.navigateText": { - "message": "to navigate", + "message": "导航", "description": "The explanatory text of the action for the Arrow up and Arrow down key" }, "theme.SearchModal.footer.navigateUpKeyAriaLabel": { - "message": "Arrow up", + "message": "向上键", "description": "The ARIA label for the Arrow up key button that makes the navigation" }, "theme.SearchModal.footer.navigateDownKeyAriaLabel": { - "message": "Arrow down", + "message": "向下键", "description": "The ARIA label for the Arrow down key button that makes the navigation" }, "theme.SearchModal.footer.closeText": { - "message": "to close", + "message": "关闭", "description": "The explanatory text of the action for Escape key" }, "theme.SearchModal.footer.closeKeyAriaLabel": { - "message": "Escape key", + "message": "Esc 键", "description": "The ARIA label for the Escape key button that close the modal" }, "theme.SearchModal.footer.searchByText": { - "message": "Search by", + "message": "搜索提供", "description": "The text explain that the search is making by Algolia" }, "theme.SearchModal.noResultsScreen.noResultsText": { - "message": "No results for", + "message": "没有结果:", "description": "The text explains that there are no results for the following search" }, "theme.SearchModal.noResultsScreen.suggestedQueryText": { - "message": "Try searching for", + "message": "试试搜索", "description": "The text for the suggested query when no results are found for the following search" }, "theme.SearchModal.noResultsScreen.reportMissingResultsText": { - "message": "Believe this query should return results?", + "message": "认为这个查询应该有结果?", "description": "The text for the question where the user thinks there are missing results" }, "theme.SearchModal.noResultsScreen.reportMissingResultsLinkText": { - "message": "Let us know.", + "message": "请告知我们。", "description": "The text for the link to report missing results" }, "theme.SearchModal.placeholder": { - "message": "Search docs", + "message": "搜索文档", "description": "The placeholder of the input of the DocSearch pop-up modal" }, "theme.common.skipToMainContent": { - "message": "Skip to main content", + "message": "跳到主要内容", "description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation" }, "theme.tags.tagsPageTitle": { - "message": "Tags", + "message": "标签", "description": "The title of the tag list page" } } diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml b/docs/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml new file mode 100644 index 0000000000..8a230a3e0a --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml @@ -0,0 +1,5 @@ +andreynering: + name: Andrey Nering + title: Task 项目维护者 + url: https://github.com/andreynering + image_url: https://github.com/andreynering.png diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/api_reference.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/api_reference.md new file mode 100644 index 0000000000..428ca38426 --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/api_reference.md @@ -0,0 +1,266 @@ +--- +slug: /api/ +sidebar_position: 4 +--- + +# API 参考 + +## 命令行 + +该命令的语法如下: + +```bash +task [--flags] [tasks...] [-- CLI_ARGS...] +``` + +:::tip + + +如果 `--` 给出,所有剩余参数将被分配给一个特殊的 `CLI_ARGS` 变量 + +::: + + +| 缩写 | 标志 | 类型 | 默认 | 描述 | +| ---- | --------------------------- | -------- | -------------------------------- | --------------------------------------------------------------------------------------------------- | +| `-c` | `--color` | `bool` | `true` | 彩色输出。 默认开启。 设置为 `false` 或使用 `NO_COLOR=1` 禁用。 | +| `-C` | `--concurrency` | `int` | `0` | 限制并发运行的任务数。 零意味着无限。 | +| `-d` | `--dir` | `string` | 工作目录 | 设置执行目录。 | +| `-n` | `--dry` | `bool` | `false` | 按运行顺序编译和打印任务,而不执行它们。 | +| `-x` | `--exit-code` | `bool` | `false` | 传递任务命令的退出代码。 | +| `-f` | `--force` | `bool` | `false` | 即使任务是最新的也强制执行。 | +| `-g` | `--global` | `bool` | `false` | 从 `$HOME/Taskfile.{yml,yaml}` 运行全局任务文件。 | +| `-h` | `--help` | `bool` | `false` | 显示任务使用情况。 | +| `-i` | `--init` | `bool` | `false` | 在当前文件夹中创建一个新的 Taskfile.yaml。 | +| `-I` | `--interval` | `string` | `5s` | 使用 `--watch` 设置不同的观察间隔,默认为 5 秒。 这个字符串应该是一个有效的 [Go Duration](https://pkg.go.dev/time#ParseDuration)。 | +| `-l` | `--list` | `bool` | `false` | 列出当前文件的全部任务及对应描述。 | +| `-a` | `--list-all` | `bool` | `false` | 列出无论有没有描述的所有任务。 | +| `-o` | `--output` | `string` | 在 Taskfile 中设置默认值或 `intervealed` | 设置输出样式:[`interleaved`/`group`/`prefixed`]。 | +| | `--output-group-begin` | `string` | | 在任务组输出前打印的消息模板。 | +| | `--output-group-end` | `string` | | 在任务组输出后打印的消息模板。 | +| | `--output-group-error-only` | `bool` | `false` | 在退出码为 0 时忽略命令输出。 | +| `-p` | `--parallel` | `bool` | `false` | 并行执行命令行上提供的任务。 | +| `-s` | `--silent` | `bool` | `false` | 禁用回显。 | +| | `--status` | `bool` | `false` | 如果任何给定任务不是最新的,则以非 0 退出码退出。 | +| | `--summary` | `bool` | `false` | 显示有关任务的摘要。 | +| `-t` | `--taskfile` | `string` | `Taskfile.yml` 或 `Taskfile.yaml` | | +| `-v` | `--verbose` | `bool` | `false` | 启用详细模式。 | +| | `--version` | `bool` | `false` | 显示 Task 版本。 | +| `-w` | `--watch` | `bool` | `false` | 启用给定任务的观察器。 | + +## 特殊变量 + +模板系统上有一些可用的特殊变量: + +| 变量 | 描述 | +| ------------------ | --------------------------------------------------------------------- | +| `CLI_ARGS` | 当通过 CLI 调用 Task 时,传递包含在 `--` 之后的所有额外参数。 | +| `TASK` | 当前任务的名称。 | +| `ROOT_DIR` | 根 Taskfile 的绝对路径。 | +| `TASKFILE_DIR` | 包含 Taskfile 的绝对路径 | +| `USER_WORKING_DIR` | 调用 `task` 的目录的绝对路径。 | +| `CHECKSUM` | 在 `sources` 中列出的文件的 checksum。 仅在 `status` 参数中可用,并且如果方法设置为 `checksum`。 | +| `TIMESTAMP` | `sources` 中列出的文件的最大时间戳的日期对象。 仅在 `status` 参数中可用,并且如果方法设置为 `timestamp`。 | +| `TASK_VERSION` | Task 的当前版本。 | + +## 环境变量 + +可以覆盖某些环境变量以调整 Task 行为。 + +| 环境变量 | 默认 | 描述 | +| -------------------- | ------- | ------------------------------------------------------------ | +| `TASK_TEMP_DIR` | `.task` | 临时目录的位置。 可以相对于项目比如 `tmp/task` 或绝对如 `/tmp/.task` 或 `~/.task`。 | +| `TASK_COLOR_RESET` | `0` | 用于白色的颜色。 | +| `TASK_COLOR_BLUE` | `34` | 用于蓝色的颜色。 | +| `TASK_COLOR_GREEN` | `32` | 用于绿色的颜色。 | +| `TASK_COLOR_CYAN` | `36` | 用于青色的颜色。 | +| `TASK_COLOR_YELLOW` | `33` | 用于黄色的颜色。 | +| `TASK_COLOR_MAGENTA` | `35` | 用于洋红色的颜色。 | +| `TASK_COLOR_RED` | `31` | 用于红色的颜色。 | +| `FORCE_COLOR` | | 强制使用颜色输出。 | + +## 规则 + +### Taskfile + +| 属性 | 类型 | 默认 | 描述 | +| ---------- | ---------------------------------- | ------------- | ------------------------------------------------------------------------------------------------- | +| `version` | `string` | | Taskfile 的版本。 当前版本是 `3`。 | +| `output` | `string` | `interleaved` | 输出模式。 可用选项: `interleaved`、`group` 和 `prefixed` | +| `method` | `string` | `checksum` | Taskfile 中的默认方法。 可以在任务基础上覆盖。 可用选项:`checksum`、`timestamp` 和 `none`。 | +| `includes` | [`map[string]Include`](#include) | | 要包含的其他 Taskfile。 | +| `vars` | [`map[string]Variable`](#variable) | | 一组全局变量。 | +| `env` | [`map[string]Variable`](#variable) | | 一组全局环境变量。 | +| `tasks` | [`map[string]Task`](#task) | | 一组任务定义。 | +| `silent` | `bool` | `false` | 此任务文件的默认“silent”选项。 如果为 `false`,则可以在任务的基础上用 `true` 覆盖。 | +| `dotenv` | `[]string` | | 要解析的 `.env` 文件路径列表。 | +| `run` | `string` | `always` | Taskfile 中默认的 'run' 选项。 可用选项: `always`、`once` 和 `when_changed`。 | +| `interval` | `string` | `5s` | 设置 `--watch` 模式下的观察时间,默认 5 秒。 这个字符串应该是一个有效的 [Go Duration](https://pkg.go.dev/time#ParseDuration)。 | +| `set` | `[]string` | | 为 [内置 `set`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) 指定选项。 | +| `shopt` | `[]string` | | 为 [内置 `shopt`](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) 指定选项。 | + +### Include + +| 属性 | 类型 | 默认 | 描述 | +| ---------- | --------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------ | +| `taskfile` | `string` | | 要包含的 Taskfile 或目录的路径。 如果是目录,Task 将在该目录中查找名为 `Taskfile.yml` 或 `Taskfile.yaml` 的文件。 如果是相对路径,则相对于包含 Taskfile 的目录进行解析。 | +| `dir` | `string` | Taskfile 文件父目录 | 运行时包含的任务的工作目录。 | +| `optional` | `bool` | `false` | 设置为 `true` 时, 文件不存在也不会报错 | +| `internal` | `bool` | `false` | 停止在命令行上调用包含的任务文件中的任何任务。 当与 `--list` 一起使用时,这些命令也将从输出中省略。 | +| `aliases` | `[]string` | | 包含的 Taskfile 的命名空间的替代名称。 | +| `vars` | `map[string]Variable` | | 一组应用于包含的 Taskfile 的变量。 | + +:::info + + +像下面这样只赋值一个字符串,和把这个值设置到 `taskfile` 属性是一样的。 + +```yaml +includes: + foo: ./path +``` + +::: + + +### Task + +| 属性 | 类型 | 默认 | 描述 | +| --------------- | ---------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| `cmds` | [`[]Command`](#command) | | 要执行的 shell 命令列表。 | +| `deps` | [`[]Dependency`](#dependency) | | 此任务的依赖项列表。 此处定义的任务将在此任务之前并行运行。 | +| `label` | `string` | | 运行任务时覆盖输出中的任务名称。 支持变量。 | +| `desc` | `string` | | Task 的简短描述。 这在调用 `task --list` 时显示。 | +| `summary` | `string` | | 任务的较长描述。 这在调用 `task --summary [task]` 时显示。 | +| `aliases` | `[]string` | | 可以调用任务的别名列表。 | +| `sources` | `[]string` | | 运行此任务之前要检查的源列表。 与 `checksum` 和 `timestamp` 相关。 可以是文件路径或星号。 | +| `generates` | `[]string` | | 此任务要生成的文件列表。 与 `timestamp` 方法相关。 可以是文件路径或星号。 | +| `status` | `[]string` | | 用于检查此 task 是否应运行的命令列表。 否则跳过该任务。 这个方法会覆盖 `method`、`sources` 和 `generates`。 | +| `preconditions` | [`[]Precondition`](#precondition) | | 用于检查此任务是否应运行的命令列表。 如果不满足条件,任务将出错。 | +| `dir` | `string` | | 此 task 应运行的目录。 默认为当前工作目录。 | +| `vars` | [`map[string]Variable`](#variable) | | 可在 task 中使用的一组变量。 | +| `env` | [`map[string]Variable`](#variable) | | 一组可用于 shell 命令的环境变量。 | +| `dotenv` | `[]string` | | 要解析的 `.env` 文件路径列表。 | +| `silent` | `bool` | `false` | 从输出中隐藏任务名称和命令。 命令的输出仍将重定向到 `STDOUT` 和 `STDERR`。 当与 `--list` 标志结合使用时,任务描述将被隐藏。 | +| `interactive` | `bool` | `false` | 告诉任务该命令是交互式的。 | +| `internal` | `bool` | `false` | 停止在命令行上调用任务。 当与 `--list` 一起使用时,它也会从输出中省略。 | +| `method` | `string` | `checksum` | 定义用于检查任务是最新的方法。 `timestamp` 将比较源的时间戳并生成文件。 `checksum` 将检查 checksum(您可能想忽略 .gitignore 文件中的 .task 文件夹)。 `none` 跳过任何验证并始终运行任务。 | +| `prefix` | `string` | | 定义一个字符串作为并行运行 task 输出的前缀。 仅在输出模式是 `prefixed` 时使用。 | +| `ignore_error` | `bool` | `false` | 如果执行命令时发生错误,则继续执行。 | +| `run` | `string` | Taskfile 中全局声明的值或 `always` | 指定如果多次调用该任务是否应再次运行。 可用选项:`always`、`once` 和 `when_changed`。 | +| `platforms` | `[]string` | 所有平台 | 指定应在哪些平台上运行任务。 允许使用 [有效的 GOOS 和 GOARCH 值](https://github.com/golang/go/blob/master/src/go/build/syslist.go)。 否则将跳过任务。 | +| `set` | `[]string` | | 为 [内置 `set`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) 指定选项。 | +| `shopt` | `[]string` | | 为 [内置 `shopt`](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) 指定选项。 | + +:::info + + +这些替代语法可用。 他们会将给定值设置为 `cmds`,其他所有内容都将设置为其默认值: + +```yaml +tasks: + foo: echo "foo" + + foobar: + - echo "foo" + - echo "bar" + + baz: + cmd: echo "baz" +``` + +::: + + +### Dependency + +| 属性 | 类型 | 默认 | 描述 | +| ------ | ---------------------------------- | -- | --------------- | +| `task` | `string` | | 要作为依赖项执行的任务。 | +| `vars` | [`map[string]Variable`](#variable) | | 要传递给此任务的可选附加变量。 | + +:::tip + + +如果你不想设置额外的变量,将依赖关系声明为一个字符串列表就足够了(它们将被分配给 `task`)。 + +```yaml +tasks: + foo: + deps: [foo, bar] +``` + +::: + + +### Command + +| 属性 | 类型 | 默认 | 描述 | +| -------------- | ---------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- | +| `cmd` | `string` | | 要执行的 shell 命令 | +| `silent` | `bool` | `false` | 跳过此命令的一些输出。 请注意,命令的 STDOUT 和 STDERR 仍将被重定向。 | +| `task` | `string` | | 执行另一个 task,而不执行命令。 不能与 `cmd` 同时设置。 | +| `vars` | [`map[string]Variable`](#variable) | | 要传递给引用任务的可选附加变量。 仅在设置 `task` 而不是 `cmd` 时相关。 | +| `ignore_error` | `bool` | `false` | 执行命令的时候忽略错误,继续执行 | +| `defer` | `string` | | `cmd` 的替代方法,但安排命令在此任务结束时执行,而不是立即执行。 不能与 `cmd` 一同使用。 | +| `platforms` | `[]string` | 所有平台 | 指定应在哪些平台上运行该命令。 允许使用 [有效的 GOOS 和 GOARCH 值](https://github.com/golang/go/blob/master/src/go/build/syslist.go)。 否则将跳过命令。 | +| `set` | `[]string` | | 为 [内置 `set`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) 指定选项。 | +| `shopt` | `[]string` | | 为 [内置 `shopt`](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) 指定选项。 | + +:::info + + +如果以字符串形式给出,该值将分配给 `cmd`: + +```yaml +tasks: + foo: + cmds: + - echo "foo" + - echo "bar" +``` + +::: + + +### Variable + +| 属性 | 类型 | 默认 | 描述 | +| -------- | -------- | -- | ---------------------------------- | +| *itself* | `string` | | 将设置为变量的静态值。 | +| `sh` | `string` | | 一个 shell 命令。 输出 (`STDOUT`) 将分配给变量。 | + +:::info + + +静态和动态变量有不同的语法,如下所示: + +```yaml +vars: + STATIC: static + DYNAMIC: + sh: echo "dynamic" +``` + +::: + + +### Precondition + +| 属性 | 类型 | 默认 | 描述 | +| ----- | -------- | -- | ----------------------------------- | +| `sh` | `string` | | 要执行的命令。 如果返回非零退出码,任务将在不执行其命令的情况下出错。 | +| `msg` | `string` | | 如果不满足先决条件,则打印可选消息。 | + +:::tip + + +如果你不想设置不同的消息,你可以像这样声明一个前提条件,值将被分配给 `sh`: + +```yaml +tasks: + foo: + precondition: test -f Taskfile.yml +``` + +::: diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/changelog.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/changelog.md new file mode 100644 index 0000000000..8d24f94e42 --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/changelog.md @@ -0,0 +1,438 @@ +--- +slug: /changelog/ +sidebar_position: 7 +--- + +# 更新日志 + +## v3.22.0 - 2023-03-10 + +- Add a brand new `--global` (`-g`) flag that will run a Taskfile from your `$HOME` directory. This is useful to have automation that you can run from anywhere in your system! ([Documentation](https://taskfile.dev/usage/#running-a-global-taskfile), [#1029](https://github.com/go-task/task/pull/1029) by @andreynering). +- Add ability to set `error_only: true` on the `group` output mode. This will instruct Task to only print a command output if it returned with a non-zero exit code ([#664](https://github.com/go-task/task/issues/664), [#1022](https://github.com/go-task/task/pull/1022) by @jaedle). +- Fixed bug where `.task/checksum` file was sometimes not being created when task also declares a `status:` ([#840](https://github.com/go-task/task/issues/840), [#1035](https://github.com/go-task/task/pull/1035) by @harelwa, [#1037](https://github.com/go-task/task/pull/1037) by @pd93). +- Refactored and decoupled fingerprinting from the main Task executor ([#1039](https://github.com/go-task/task/issues/1039) by @pd93). +- Fixed deadlock issue when using `run: once` ([#715](https://github.com/go-task/task/issues/715), [#1025](https://github.com/go-task/task/pull/1025) by @theunrepentantgeek). + +## v3.21.0 - 2023-02-22 + +- Added new `TASK_VERSION` special variable ([#990](https://github.com/go-task/task/issues/990), [#1014](https://github.com/go-task/task/pull/1014) by @ja1code). +- Fixed a bug where tasks were sometimes incorrectly marked as internal ([#1007](https://github.com/go-task/task/pull/1007) by @pd93). +- Update to Go 1.20 (bump minimum version to 1.19) ([#1010](https://github.com/go-task/task/pull/1010) by @pd93) +- Added environment variable `FORCE_COLOR` support to force color output. Usefull for environments without TTY ([#1003](https://github.com/go-task/task/pull/1003) by @automation-stack) + +## v3.20.0 - 2023-01-14 + +- Improve behavior and performance of status checking when using the `timestamp` mode ([#976](https://github.com/go-task/task/issues/976), [#977](https://github.com/go-task/task/pull/977) by @aminya). +- Performance optimizations were made for large Taskfiles ([#982](https://github.com/go-task/task/pull/982) by @pd93). +- Add ability to configure options for the [`set`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) and [`shopt`](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) builtins ([#908](https://github.com/go-task/task/issues/908), [#929](https://github.com/go-task/task/pull/929) by @pd93, [Documentation](http://taskfile.dev/usage/#set-and-shopt)). +- Add new `platforms:` attribute to `task` and `cmd`, so it's now possible to choose in which platforms that given task or command will be run on. Possible values are operating system (GOOS), architecture (GOARCH) or a combination of the two. Example: `platforms: [linux]`, `platforms: [amd64]` or `platforms: [linux/amd64]`. Other platforms will be skipped ([#978](https://github.com/go-task/task/issues/978), [#980](https://github.com/go-task/task/pull/980) by @leaanthony). + +## v3.19.1 - 2022-12-31 + +- Small bug fix: closing `Taskfile.yml` once we're done reading it ([#963](https://github.com/go-task/task/issues/963), [#964](https://github.com/go-task/task/pull/964) by @HeCorr). +- Fixes a bug in v2 that caused a panic when using a `Taskfile_{{OS}}.yml` file ([#961](https://github.com/go-task/task/issues/961), [#971](https://github.com/go-task/task/pull/971) by @pd93). +- Fixed a bug where watch intervals set in the Taskfile were not being respected ([#969](https://github.com/go-task/task/pull/969), [#970](https://github.com/go-task/task/pull/970) by @pd93) +- Add `--json` flag (alias `-j`) with the intent to improve support for code editors and add room to other possible integrations. This is basic for now, but we plan to add more info in the near future ([#936](https://github.com/go-task/task/pull/936) by @davidalpert, [#764](https://github.com/go-task/task/issues/764)). + +## v3.19.0 - 2022-12-05 + +- Installation via npm now supports [pnpm](https://pnpm.io/) as well ([go-task/go-npm#2](https://github.com/go-task/go-npm/issues/2), [go-task/go-npm#3](https://github.com/go-task/go-npm/pull/3)). +- It's now possible to run Taskfiles from subdirectories! A new `USER_WORKING_DIR` special variable was added to add even more flexibility for monorepos ([#289](https://github.com/go-task/task/issues/289), [#920](https://github.com/go-task/task/pull/920)). +- Add task-level `dotenv` support ([#389](https://github.com/go-task/task/issues/389), [#904](https://github.com/go-task/task/pull/904)). +- It's now possible to use global level variables on `includes` ([#942](https://github.com/go-task/task/issues/942), [#943](https://github.com/go-task/task/pull/943)). +- The website got a brand new [translation to Chinese](https://task-zh.readthedocs.io/zh_CN/latest/) by [@DeronW](https://github.com/DeronW). Thanks! + +## v3.18.0 - 2022-11-12 + +- Show aliases on `task --list --silent` (`task --ls`). This means that aliases will be completed by the completion scripts ([#919](https://github.com/go-task/task/pull/919)). +- Tasks in the root Taskfile will now be displayed first in `--list`/`--list-all` output ([#806](https://github.com/go-task/task/pull/806), [#890](https://github.com/go-task/task/pull/890)). +- It's now possible to call a `default` task in an included Taskfile by using just the namespace. For example: `docs:default` is now automatically aliased to `docs` ([#661](https://github.com/go-task/task/issues/661), [#815](https://github.com/go-task/task/pull/815)). + +## v3.17.0 - 2022-10-14 + +- Add a "Did you mean ...?" suggestion when a task does not exits another one with a similar name is found ([#867](https://github.com/go-task/task/issues/867), [#880](https://github.com/go-task/task/pull/880)). +- Now YAML parse errors will print which Taskfile failed to parse ([#885](https://github.com/go-task/task/issues/885), [#887](https://github.com/go-task/task/pull/887)). +- Add ability to set `aliases` for tasks and namespaces ([#268](https://github.com/go-task/task/pull/268), [#340](https://github.com/go-task/task/pull/340), [#879](https://github.com/go-task/task/pull/879)). +- Improvements to Fish shell completion ([#897](https://github.com/go-task/task/pull/897)). +- Added ability to set a different watch interval by setting `interval: '500ms'` or using the `--interval=500ms` flag ([#813](https://github.com/go-task/task/issues/813), [#865](https://github.com/go-task/task/pull/865)). +- Add colored output to `--list`, `--list-all` and `--summary` flags ([#845](https://github.com/go-task/task/pull/845), [#874](https://github.com/go-task/task/pull/874)). +- Fix unexpected behavior where `label:` was being shown instead of the task name on `--list` ([#603](https://github.com/go-task/task/issues/603), [#877](https://github.com/go-task/task/pull/877)). + +## v3.16.0 - 2022-09-29 + +- Add `npm` as new installation method: `npm i -g @go-task/cli` ([#870](https://github.com/go-task/task/issues/870), [#871](https://github.com/go-task/task/pull/871), [npm package](https://www.npmjs.com/package/@go-task/cli)). +- Add support to marking tasks and includes as internal, which will hide them from `--list` and `--list-all` ([#818](https://github.com/go-task/task/pull/818)). + +## v3.15.2 - 2022-09-08 + +- Fix error when using variable in `env:` introduced in the previous release ([#858](https://github.com/go-task/task/issues/858), [#866](https://github.com/go-task/task/pull/866)). +- Fix handling of `CLI_ARGS` (`--`) in Bash completion ([#863](https://github.com/go-task/task/pull/863)). +- On zsh completion, add ability to replace `--list-all` with `--list` as already possible on the Bash completion ([#861](https://github.com/go-task/task/pull/861)). + +## v3.15.0 - 2022-09-03 + +- Add new special variables `ROOT_DIR` and `TASKFILE_DIR`. This was a highly requested feature ([#215](https://github.com/go-task/task/issues/215), [#857](https://github.com/go-task/task/pull/857), [Documentation](https://taskfile.dev/api/#special-variables)). +- Follow symlinks on `sources` ([#826](https://github.com/go-task/task/issues/826), [#831](https://github.com/go-task/task/pull/831)). +- Improvements and fixes to Bash completion ([#835](https://github.com/go-task/task/pull/835), [#844](https://github.com/go-task/task/pull/844)). + +## v3.14.1 - 2022-08-03 + +- Always resolve relative include paths relative to the including Taskfile ([#822](https://github.com/go-task/task/issues/822), [#823](https://github.com/go-task/task/pull/823)). +- Fix ZSH and PowerShell completions to consider all tasks instead of just the public ones (those with descriptions) ([#803](https://github.com/go-task/task/pull/803)). + +## v3.14.0 - 2022-07-08 + +- Add ability to override the `.task` directory location with the `TASK_TEMP_DIR` environment variable. +- Allow to override Task colors using environment variables: `TASK_COLOR_RESET`, `TASK_COLOR_BLUE`, `TASK_COLOR_GREEN`, `TASK_COLOR_CYAN`, `TASK_COLOR_YELLOW`, `TASK_COLOR_MAGENTA` and `TASK_COLOR_RED` ([#568](https://github.com/go-task/task/pull/568), [#792](https://github.com/go-task/task/pull/792)). +- Fixed bug when using the `output: group` mode where STDOUT and STDERR were being print in separated blocks instead of in the right order ([#779](https://github.com/go-task/task/issues/779)). +- Starting on this release, ARM architecture binaries are been released to Snap as well ([#795](https://github.com/go-task/task/issues/795)). +- i386 binaries won't be available anymore on Snap because Ubuntu removed the support for this architecture. +- Upgrade mvdan.cc/sh, which fixes a bug with associative arrays ([#785](https://github.com/go-task/task/issues/785), [mvdan/sh#884](https://github.com/mvdan/sh/issues/884), [mvdan/sh#893](https://github.com/mvdan/sh/pull/893)). + +## v3.13.0 - 2022-06-13 + +- Added `-n` as an alias to `--dry` ([#776](https://github.com/go-task/task/issues/776), [#777](https://github.com/go-task/task/pull/777)). +- Fix behavior of interrupt (SIGINT, SIGTERM) signals. Task will now give time for the processes running to do cleanup work ([#458](https://github.com/go-task/task/issues/458), [#479](https://github.com/go-task/task/pull/479), [#728](https://github.com/go-task/task/issues/728), [#769](https://github.com/go-task/task/pull/769)). +- Add new `--exit-code` (`-x`) flag that will pass-through the exit form the command being ran ([#755](https://github.com/go-task/task/pull/755)). + +## v3.12.1 - 2022-05-10 + +- Fixed bug where, on Windows, variables were ending with `\r` because we were only removing the final `\n` but not `\r\n` ([#717](https://github.com/go-task/task/issues/717)). + +## v3.12.0 - 2022-03-31 + +- The `--list` and `--list-all` flags can now be combined with the `--silent` flag to print the task names only, without their description ([#691](https://github.com/go-task/task/pull/691)). +- Added support for multi-level inclusion of Taskfiles. This means that included Taskfiles can also include other Taskfiles. Before this was limited to one level ([#390](https://github.com/go-task/task/issues/390), [#623](https://github.com/go-task/task/discussions/623), [#656](https://github.com/go-task/task/pull/656)). +- Add ability to specify vars when including a Taskfile. [Check out the documentation](https://taskfile.dev/#/usage?id=vars-of-included-taskfiles) for more information. ([#677](https://github.com/go-task/task/pull/677)). + +## v3.11.0 - 2022-02-19 + +- Task now supports printing begin and end messages when using the `group` output mode, useful for grouping tasks in CI systems. [Check out the documentation](http://taskfile.dev/#/usage?id=output-syntax) for more information ([#647](https://github.com/go-task/task/issues/647), [#651](https://github.com/go-task/task/pull/651)). +- Add `Taskfile.dist.yml` and `Taskfile.dist.yaml` to the supported file name list. [Check out the documentation](https://taskfile.dev/#/usage?id=supported-file-names) for more information ([#498](https://github.com/go-task/task/issues/498), [#666](https://github.com/go-task/task/pull/666)). + +## v3.10.0 - 2022-01-04 + +- A new `--list-all` (alias `-a`) flag is now available. It's similar to the exiting `--list` (`-l`) but prints all tasks, even those without a description ([#383](https://github.com/go-task/task/issues/383), [#401](https://github.com/go-task/task/pull/401)). +- It's now possible to schedule cleanup commands to run once a task finishes with the `defer:` keyword ([Documentation](https://taskfile.dev/#/usage?id=doing-task-cleanup-with-defer), [#475](https://github.com/go-task/task/issues/475), [#626](https://github.com/go-task/task/pull/626)). +- Remove long deprecated and undocumented `$` variable prefix and `^` command prefix ([#642](https://github.com/go-task/task/issues/642), [#644](https://github.com/go-task/task/issues/644), [#645](https://github.com/go-task/task/pull/645)). +- Add support for `.yaml` extension (as an alternative to `.yml`). This was requested multiple times throughout the years. Enjoy! ([#183](https://github.com/go-task/task/issues/183), [#184](https://github.com/go-task/task/pull/184), [#369](https://github.com/go-task/task/issues/369), [#584](https://github.com/go-task/task/issues/584), [#621](https://github.com/go-task/task/pull/621)). +- Fixed error when computing a variable when the task directory do not exist yet ([#481](https://github.com/go-task/task/issues/481), [#579](https://github.com/go-task/task/pull/579)). + +## v3.9.2 - 2021-12-02 + +- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains a fix a for a important regression on Windows ([#619](https://github.com/go-task/task/issues/619), [mvdan/sh#768](https://github.com/mvdan/sh/issues/768), [mvdan/sh#769](https://github.com/mvdan/sh/pull/769)). + +## v3.9.1 - 2021-11-28 + +- Add logging in verbose mode for when a task starts and finishes ([#533](https://github.com/go-task/task/issues/533), [#588](https://github.com/go-task/task/pull/588)). +- Fix an issue with preconditions and context errors ([#597](https://github.com/go-task/task/issues/597), [#598](https://github.com/go-task/task/pull/598)). +- Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many ([#613](https://github.com/go-task/task/pull/613)). +- Fix nil pointer when `cmd:` was left empty ([#612](https://github.com/go-task/task/issues/612), [#614](https://github.com/go-task/task/pull/614)). +- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two relevant fixes: + - Fix quote of empty strings in `shellQuote` ([#609](https://github.com/go-task/task/issues/609), [mvdan/sh#763](https://github.com/mvdan/sh/issues/763)). + - Fix issue of wrong environment variable being picked when there's another very similar one ([#586](https://github.com/go-task/task/issues/586), [mvdan/sh#745](https://github.com/mvdan/sh/pull/745)). +- Install shell completions automatically when installing via Homebrew ([#264](https://github.com/go-task/task/issues/264), [#592](https://github.com/go-task/task/pull/592), [go-task/homebrew-tap#2](https://github.com/go-task/homebrew-tap/pull/2)). + +## v3.9.0 - 2021-10-02 + +- A new `shellQuote` function was added to the template system (`{{shellQuote "a string"}}`) to ensure a string is safe for use in shell ([mvdan/sh#727](https://github.com/mvdan/sh/pull/727), [mvdan/sh#737](https://github.com/mvdan/sh/pull/737), [Documentation](https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/syntax#Quote)) +- In this version [mvdan.cc/sh](https://github.com/mvdan/sh) was upgraded with some small fixes and features + - The `read -p` flag is now supported ([#314](https://github.com/go-task/task/issues/314), [mvdan/sh#551](https://github.com/mvdan/sh/issues/551), [mvdan/sh#772](https://github.com/mvdan/sh/pull/722)) + - The `pwd -P` and `pwd -L` flags are now supported ([#553](https://github.com/go-task/task/issues/553), [mvdan/sh#724](https://github.com/mvdan/sh/issues/724), [mvdan/sh#728](https://github.com/mvdan/sh/pull/728)) + - The `$GID` environment variable is now correctly being set ([#561](https://github.com/go-task/task/issues/561), [mvdan/sh#723](https://github.com/mvdan/sh/pull/723)) + +## v3.8.0 - 2021-09-26 + +- Add `interactive: true` setting to improve support for interactive CLI apps ([#217](https://github.com/go-task/task/issues/217), [#563](https://github.com/go-task/task/pull/563)). +- Fix some `nil` errors ([#534](https://github.com/go-task/task/issues/534), [#573](https://github.com/go-task/task/pull/573)). +- Add ability to declare an included Taskfile as optional ([#519](https://github.com/go-task/task/issues/519), [#552](https://github.com/go-task/task/pull/552)). +- Add support for including Taskfiles in the home directory by using `~` ([#539](https://github.com/go-task/task/issues/539), [#557](https://github.com/go-task/task/pull/557)). + +## v3.7.3 - 2021-09-04 + +- Add official support to Apple M1 ([#564](https://github.com/go-task/task/pull/564), [#567](https://github.com/go-task/task/pull/567)). +- Our [official Homebrew tap](https://github.com/go-task/homebrew-tap) will support more platforms, including Apple M1 + +## v3.7.0 - 2021-07-31 + +- Add `run:` setting to control if tasks should run multiple times or not. Available options are `always` (the default), `when_changed` (if a variable modified the task) and `once` (run only once no matter what). This is a long time requested feature. Enjoy! ([#53](https://github.com/go-task/task/issues/53), [#359](https://github.com/go-task/task/pull/359)). + +## v3.6.0 - 2021-07-10 + +- Allow using both `sources:` and `status:` in the same task ([#411](https://github.com/go-task/task/issues/411), [#427](https://github.com/go-task/task/issues/427), [#477](https://github.com/go-task/task/pull/477)). +- Small optimization and bug fix: don't compute variables if not needed for `dotenv:` ([#517](https://github.com/go-task/task/issues/517)). + +## v3.5.0 - 2021-07-04 + +- Add support for interpolation in `dotenv:` ([#433](https://github.com/go-task/task/discussions/433), [#434](https://github.com/go-task/task/issues/434), [#453](https://github.com/go-task/task/pull/453)). + +## v3.4.3 - 2021-05-30 + +- Add support for the `NO_COLOR` environment variable. ([#459](https://github.com/go-task/task/issues/459), [fatih/color#137](https://github.com/fatih/color/pull/137)). +- Fix bug where sources were not considering the right directory in `--watch` mode ([#484](https://github.com/go-task/task/issues/484), [#485](https://github.com/go-task/task/pull/485)). + +## v3.4.2 - 2021-04-23 + +- On watch, report which file failed to read ([#472](https://github.com/go-task/task/pull/472)). +- Do not try to catch SIGKILL signal, which are not actually possible ([#476](https://github.com/go-task/task/pull/476)). +- Improve version reporting when building Task from source using Go Modules ([#462](https://github.com/go-task/task/pull/462), [#473](https://github.com/go-task/task/pull/473)). + +## v3.4.1 - 2021-04-17 + +- Improve error reporting when parsing YAML: in some situations where you would just see an generic error, you'll now see the actual error with more detail: the YAML line the failed to parse, for example ([#467](https://github.com/go-task/task/issues/467)). +- A JSON Schema was published [here](https://json.schemastore.org/taskfile.json) and is automatically being used by some editors like Visual Studio Code ([#135](https://github.com/go-task/task/issues/135)). +- Print task name before the command in the log output ([#398](https://github.com/go-task/task/pull/398)). + +## v3.3.0 - 2021-03-20 + +- Add support for delegating CLI arguments to commands with `--` and a special `CLI_ARGS` variable ([#327](https://github.com/go-task/task/issues/327)). +- Add a `--concurrency` (alias `-C`) flag, to limit the number of tasks that run concurrently. This is useful for heavy workloads. ([#345](https://github.com/go-task/task/pull/345)). + +## v3.2.2 - 2021-01-12 + +- Improve performance of `--list` and `--summary` by skipping running shell variables for these flags ([#332](https://github.com/go-task/task/issues/332)). +- Fixed a bug where an environment in a Taskfile was not always overridable by the system environment ([#425](https://github.com/go-task/task/issues/425)). +- Fixed environment from .env files not being available as variables ([#379](https://github.com/go-task/task/issues/379)). +- The install script is now working for ARM platforms ([#428](https://github.com/go-task/task/pull/428)). + +## v3.2.1 - 2021-01-09 + +- Fixed some bugs and regressions regarding dynamic variables and directories ([#426](https://github.com/go-task/task/issues/426)). +- The [slim-sprig](https://github.com/go-task/slim-sprig) package was updated with the upstream [sprig](https://github.com/Masterminds/sprig). + +## v3.2.0 - 2021-01-07 + +- Fix the `.task` directory being created in the task directory instead of the Taskfile directory ([#247](https://github.com/go-task/task/issues/247)). +- Fix a bug where dynamic variables (those declared with `sh:`) were not running in the task directory when the task has a custom dir or it was in an included Taskfile ([#384](https://github.com/go-task/task/issues/384)). +- The watch feature (via the `--watch` flag) got a few different bug fixes and should be more stable now ([#423](https://github.com/go-task/task/pull/423), [#365](https://github.com/go-task/task/issues/365)). + +## v3.1.0 - 2021-01-03 + +- Fix a bug when the checksum up-to-date resolution is used by a task with a custom `label:` attribute ([#412](https://github.com/go-task/task/issues/412)). +- Starting from this release, we're releasing official ARMv6 and ARM64 binaries for Linux ([#375](https://github.com/go-task/task/issues/375), [#418](https://github.com/go-task/task/issues/418)). +- Task now respects the order of declaration of included Taskfiles when evaluating variables declaring by them ([#393](https://github.com/go-task/task/issues/393)). +- `set -e` is now automatically set on every command. This was done to fix an issue where multiline string commands wouldn't really fail unless the sentence was in the last line ([#403](https://github.com/go-task/task/issues/403)). + +## v3.0.1 - 2020-12-26 + +- Allow use as a library by moving the required packages out of the `internal` directory ([#358](https://github.com/go-task/task/pull/358)). +- Do not error if a specified dotenv file does not exist ([#378](https://github.com/go-task/task/issues/378), [#385](https://github.com/go-task/task/pull/385)). +- Fix panic when you have empty tasks in your Taskfile ([#338](https://github.com/go-task/task/issues/338), [#362](https://github.com/go-task/task/pull/362)). + +## v3.0.0 - 2020-08-16 + +- On `v3`, all CLI variables will be considered global variables ([#336](https://github.com/go-task/task/issues/336), [#341](https://github.com/go-task/task/pull/341)) +- Add support to `.env` like files ([#324](https://github.com/go-task/task/issues/324), [#356](https://github.com/go-task/task/pull/356)). +- Add `label:` to task so you can override the task name in the logs ([#321](https://github.com/go-task/task/issues/321]), [#337](https://github.com/go-task/task/pull/337)). +- Refactor how variables work on version 3 ([#311](https://github.com/go-task/task/pull/311)). +- Disallow `expansions` on v3 since it has no effect. +- `Taskvars.yml` is not automatically included anymore. +- `Taskfile_{{OS}}.yml` is not automatically included anymore. +- Allow interpolation on `includes`, so you can manually include a Taskfile based on operation system, for example. +- Expose `.TASK` variable in templates with the task name ([#252](https://github.com/go-task/task/issues/252)). +- Implement short task syntax ([#194](https://github.com/go-task/task/issues/194), [#240](https://github.com/go-task/task/pull/240)). +- Added option to make included Taskfile run commands on its own directory ([#260](https://github.com/go-task/task/issues/260), [#144](https://github.com/go-task/task/issues/144)) +- Taskfiles in version 1 are not supported anymore ([#237](https://github.com/go-task/task/pull/237)). +- Added global `method:` option. With this option, you can set a default method to all tasks in a Taskfile ([#246](https://github.com/go-task/task/issues/246)). +- Changed default method from `timestamp` to `checksum` ([#246](https://github.com/go-task/task/issues/246)). +- New magic variables are now available when using `status:`: `.TIMESTAMP` which contains the greatest modification date from the files listed in `sources:`, and `.CHECKSUM`, which contains a checksum of all files listed in `status:`. This is useful for manual checking when using external, or even remote, artifacts when using `status:` ([#216](https://github.com/go-task/task/pull/216)). +- We're now using [slim-sprig](https://github.com/go-task/slim-sprig) instead of [sprig](https://github.com/Masterminds/sprig), which allowed a file size reduction of about 22% ([#219](https://github.com/go-task/task/pull/219)). +- We now use some colors on Task output to better distinguish message types - commands are green, errors are red, etc ([#207](https://github.com/go-task/task/pull/207)). + +## v2.8.1 - 2020-05-20 + +- Fix error code for the `--help` flag ([#300](https://github.com/go-task/task/issues/300), [#330](https://github.com/go-task/task/pull/330)). +- Print version to stdout instead of stderr ([#299](https://github.com/go-task/task/issues/299), [#329](https://github.com/go-task/task/pull/329)). +- Supress `context` errors when using the `--watch` flag ([#313](https://github.com/go-task/task/issues/313), [#317](https://github.com/go-task/task/pull/317)). +- Support templating on description ([#276](https://github.com/go-task/task/issues/276), [#283](https://github.com/go-task/task/pull/283)). + +## v2.8.0 - 2019-12-07 + +- Add `--parallel` flag (alias `-p`) to run tasks given by the command line in parallel ([#266](https://github.com/go-task/task/pull/266)). +- Fixed bug where calling the `task` CLI only informing global vars would not execute the `default` task. +- Add hability to silent all tasks by adding `silent: true` a the root of the Taskfile. + +## v2.7.1 - 2019-11-10 + +- Fix error being raised when `exit 0` was called ([#251](https://github.com/go-task/task/issues/251)). + +## v2.7.0 - 2019-09-22 + +- Fixed panic bug when assigning a global variable ([#229](https://github.com/go-task/task/issues/229), [#243](https://github.com/go-task/task/issues/234)). +- A task with `method: checksum` will now re-run if generated files are deleted ([#228](https://github.com/go-task/task/pull/228), [#238](https://github.com/go-task/task/issues/238)). + +## v2.6.0 - 2019-07-21 + +- Fixed some bugs regarding minor version checks on `version:`. +- Add `preconditions:` to task ([#205](https://github.com/go-task/task/pull/205)). +- Create directory informed on `dir:` if it doesn't exist ([#209](https://github.com/go-task/task/issues/209), [#211](https://github.com/go-task/task/pull/211)). +- We now have a `--taskfile` flag (alias `-t`), which can be used to run another Taskfile (other than the default `Taskfile.yml`) ([#221](https://github.com/go-task/task/pull/221)). +- It's now possible to install Task using Homebrew on Linux ([go-task/homebrew-tap#1](https://github.com/go-task/homebrew-tap/pull/1)). + +## v2.5.2 - 2019-05-11 + +- Reverted YAML upgrade due issues with CRLF on Windows ([#201](https://github.com/go-task/task/issues/201), [go-yaml/yaml#450](https://github.com/go-yaml/yaml/issues/450)). +- Allow setting global variables through the CLI ([#192](https://github.com/go-task/task/issues/192)). + +## 2.5.1 - 2019-04-27 + +- Fixed some issues with interactive command line tools, where sometimes the output were not being shown, and similar issues ([#114](https://github.com/go-task/task/issues/114), [#190](https://github.com/go-task/task/issues/190), [#200](https://github.com/go-task/task/pull/200)). +- Upgraded [go-yaml/yaml](https://github.com/go-yaml/yaml) from v2 to v3. + +## v2.5.0 - 2019-03-16 + +- We moved from the taskfile.org domain to the new fancy taskfile.dev domain. While stuff is being redirected, we strongly recommend to everyone that use [this install script](https://taskfile.dev/#/installation?id=install-script) to use the new taskfile.dev domain on scripts from now on. +- Fixed to the ZSH completion ([#182](https://github.com/go-task/task/pull/182)). +- Add [`--summary` flag along with `summary:` task attribute](https://taskfile.org/#/usage?id=display-summary-of-task) ([#180](https://github.com/go-task/task/pull/180)). + +## v2.4.0 - 2019-02-21 + +- Allow calling a task of the root Taskfile from an included Taskfile by prefixing it with `:` ([#161](https://github.com/go-task/task/issues/161), [#172](https://github.com/go-task/task/issues/172)), +- Add flag to override the `output` option ([#173](https://github.com/go-task/task/pull/173)); +- Fix bug where Task was persisting the new checksum on the disk when the Dry Mode is enabled ([#166](https://github.com/go-task/task/issues/166)); +- Fix file timestamp issue when the file name has spaces ([#176](https://github.com/go-task/task/issues/176)); +- Mitigating path expanding issues on Windows ([#170](https://github.com/go-task/task/pull/170)). + +## v2.3.0 - 2019-01-02 + +- On Windows, Task can now be installed using [Scoop](https://scoop.sh/) ([#152](https://github.com/go-task/task/pull/152)); +- Fixed issue with file/directory globing ([#153](https://github.com/go-task/task/issues/153)); +- Added ability to globally set environment variables ( [#138](https://github.com/go-task/task/pull/138), [#159](https://github.com/go-task/task/pull/159) ). + +## v2.2.1 - 2018-12-09 + +- This repository now uses Go Modules (#143). We'll still keep the `vendor` directory in sync for some time, though; +- Fixing a bug when the Taskfile has no tasks but includes another Taskfile (#150); +- Fix a bug when calling another task or a dependency in an included Taskfile (#151). + +## v2.2.0 - 2018-10-25 + +- Added support for [including other Taskfiles](https://taskfile.org/#/usage?id=including-other-taskfiles) (#98) + - This should be considered experimental. For now, only including local files is supported, but support for including remote Taskfiles is being discussed. If you have any feedback, please comment on #98. +- Task now have a dedicated documentation site: https://taskfile.org + - Thanks to [Docsify](https://docsify.js.org/) for making this pretty easy. To check the source code, just take a look at the [docs](https://github.com/go-task/task/tree/master/docs) directory of this repository. Contributions to the documentation is really appreciated. + +## v2.1.1 - 2018-09-17 + +- Fix suggestion to use `task --init` not being shown anymore (when a `Taskfile.yml` is not found) +- Fix error when using checksum method and no file exists for a source glob (#131) +- Fix signal handling when the `--watch` flag is given (#132) + +## v2.1.0 - 2018-08-19 + +- Add a `ignore_error` option to task and command (#123) +- Add a dry run mode (`--dry` flag) (#126) + +## v2.0.3 - 2018-06-24 + +- Expand environment variables on "dir", "sources" and "generates" (#116) +- Fix YAML merging syntax (#112) +- Add ZSH completion (#111) +- Implement new `output` option. Please check out the [documentation](https://github.com/go-task/task#output-syntax) + +## v2.0.2 - 2018-05-01 + +- Fix merging of YAML anchors (#112) + +## v2.0.1 - 2018-03-11 + +- Fixes panic on `task --list` + +## v2.0.0 - 2018-03-08 + +Version 2.0.0 is here, with a new Taskfile format. + +Please, make sure to read the [Taskfile versions](https://github.com/go-task/task/blob/master/TASKFILE_VERSIONS.md) document, since it describes in depth what changed for this version. + +* New Taskfile version 2 (https://github.com/go-task/task/issues/77) +* Possibility to have global variables in the `Taskfile.yml` instead of `Taskvars.yml` (https://github.com/go-task/task/issues/66) +* Small improvements and fixes + +## v1.4.4 - 2017-11-19 + +- Handle SIGINT and SIGTERM (#75); +- List: print message with there's no task with description; +- Expand home dir ("~" symbol) on paths (#74); +- Add Snap as an installation method; +- Move examples to its own repo; +- Watch: also walk on tasks called on on "cmds", and not only on "deps"; +- Print logs to stderr instead of stdout (#68); +- Remove deprecated `set` keyword; +- Add checksum based status check, alternative to timestamp based. + +## v1.4.3 - 2017-09-07 + +- Allow assigning variables to tasks at run time via CLI (#33) +- Added suport for multiline variables from sh (#64) +- Fixes env: remove square braces and evaluate shell (#62) +- Watch: change watch library and few fixes and improvements +- When use watching, cancel and restart long running process on file change (#59 and #60) + +## v1.4.2 - 2017-07-30 + +- Flag to set directory of execution +- Always echo command if is verbose mode +- Add silent mode to disable echoing of commands +- Fixes and improvements of variables (#56) + +## v1.4.1 - 2017-07-15 + +- Allow use of YAML for dynamic variables instead of $ prefix + - `VAR: {sh: echo Hello}` instead of `VAR: $echo Hello` +- Add `--list` (or `-l`) flag to print existing tasks +- OS specific Taskvars file (e.g. `Taskvars_windows.yml`, `Taskvars_linux.yml`, etc) +- Consider task up-to-date on equal timestamps (#49) +- Allow absolute path in generates section (#48) +- Bugfix: allow templating when calling deps (#42) +- Fix panic for invalid task in cyclic dep detection +- Better error output for dynamic variables in Taskvars.yml (#41) +- Allow template evaluation in parameters + +## v1.4.0 - 2017-07-06 + +- Cache dynamic variables +- Add verbose mode (`-v` flag) +- Support to task parameters (overriding vars) (#31) (#32) +- Print command, also when "set:" is specified (#35) +- Improve task command help text (#35) + +## v1.3.1 - 2017-06-14 + +- Fix glob not working on commands (#28) +- Add ExeExt template function +- Add `--init` flag to create a new Taskfile +- Add status option to prevent task from running (#27) +- Allow interpolation on `generates` and `sources` attributes (#26) + +## v1.3.0 - 2017-04-24 + +- Migrate from os/exec.Cmd to a native Go sh/bash interpreter + - This is a potentially breaking change if you use Windows. + - Now, `cmd` is not used anymore on Windows. Always use Bash-like syntax for your commands, even on Windows. +- Add "ToSlash" and "FromSlash" to template functions +- Use functions defined on github.com/Masterminds/sprig +- Do not redirect stdin while running variables commands +- Using `context` and `errgroup` packages (this will make other tasks to be cancelled, if one returned an error) + +## v1.2.0 - 2017-04-02 + +- More tests and Travis integration +- Watch a task (experimental) +- Possibility to call another task +- Fix "=" not being reconized in variables/environment variables +- Tasks can now have a description, and help will print them (#10) +- Task dependencies now run concurrently +- Support for a default task (#16) + +## v1.1.0 - 2017-03-08 + +- Support for YAML, TOML and JSON (#1) +- Support running command in another directory (#4) +- `--force` or `-f` flag to force execution of task even when it's up-to-date +- Detection of cyclic dependencies (#5) +- Support for variables (#6, #9, #14) +- Operation System specific commands and variables (#13) + +## v1.0.0 - 2017-02-28 + +- Add LICENSE file diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community.md new file mode 100644 index 0000000000..2ed3b7f6e5 --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community.md @@ -0,0 +1,50 @@ +--- +slug: /community/ +sidebar_position: 8 +--- + +# 社区 + +一些改善 Task 生态的工作是由社区完成,包括安装方法或代码编辑器集成。 我(指作者)非常感谢所有帮助提升整体体验的人们。 + +## 翻译 + +[@DeronW](https://github.com/DeronW) 在 [此存储库](https://github.com/DeronW/task) 中维护网站的 [中文翻译](https://task-zh.readthedocs.io/zh_CN/latest/)。 + +## 编辑器集成 + +### JSON Schema + +Schema 的初步工作是由 [@KROSF](https://github.com/KROSF) 在此 [Gist](https://gist.github.com/KROSF/c5435acf590acd632f71bb720f685895) 上完成的。 这个 Schema 目前在 https://taskfile.dev/schema.json 上可用,并在 https://json.schemastore.org/taskfile.json 上添加了链接,因此它可以自动在许多代码编辑器使用,例如 VSCode。 可以通过编辑 [此文件](https://github.com/go-task/task/blob/master/docs/static/schema.json) 来完成贡献。 + +### Visual Studio Code 扩展 + +另外,在开发 Visual Studio Code 扩展过程中, 还有一些工作由 [@paulvarache](https://github.com/paulvarache) 完成, 代码在 [这里](https://github.com/paulvarache/vscode-taskfile) 并发布到了 [这里](https://marketplace.visualstudio.com/items?itemName=paulvarache.vscode-taskfile)。 + +### Sublime Text 4 包 + +通过 Sublime Text 的命令面板有一个简便的安装运行方法。 这个包是由 [@biozz](https://github.com/biozz) 开发的, 源代码在 [这里](https://github.com/biozz/sublime-taskfile) 并且发布到了包管理 [这里](https://packagecontrol.io/packages/Taskfile)。 + +### IntelliJ 插件 + +JetBrains IntelliJ 插件由 [@lechuckroh](https://github.com/lechuckroh) 完成, 代码在 [这里](https://github.com/lechuckroh/task-intellij-plugin) 并且发布到了 [这里](https://plugins.jetbrains.com/plugin/17058-taskfile)。 + +## 其他集成 + +- [mk](https://github.com/pycontribs/mk) 命令行工具可以原生识别任务文件。 + +## 安装方法 + +有些安装方式是通过第三方维护的: + +- [GitHub Actions](https://github.com/arduino/setup-task) 由 [@arduino](https://github.com/arduino) 维护 +- [AUR](https://aur.archlinux.org/packages/go-task-bin) 由 [@carlsmedstad](https://github.com/carlsmedstad) 维护 +- [Scoop](https://github.com/lukesampson/scoop-extras/blob/master/bucket/task.json) +- [Fedora](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/) +- [NixOS](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/go-task/default.nix) + +## 更多 + +同时,感谢所有 [代码贡献者](https://github.com/go-task/task/graphs/contributors), [资金赞助](https://opencollective.com/task),以及 [提交问题](https://github.com/go-task/task/issues?q=is%3Aissue) 和 [解答问题](https://github.com/go-task/task/discussions) 的人。 + +如果你发现文档有哪些遗漏信息,欢迎提交 pull request。 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/contributing.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/contributing.md new file mode 100644 index 0000000000..142075f8fc --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/contributing.md @@ -0,0 +1,69 @@ +--- +slug: /contributing/ +sidebar_position: 9 +--- + +# 贡献 + +非常欢迎对 Task 的贡献,但我们要求您在提交 PR 之前阅读本文档。 + +## 开始之前 + +- **检查已有工作** - 是否已经存在 PR? 是否存在 Issue 正在讨论您要进行的功能/更改? 请确保你的工作中确实考虑了这些相关的讨论内容。 +- **向后兼容** - 你的变更是否破坏了已经存在的 Taskfile? 向后兼容的变更会更容易被合并进去。 您是否可以采取一种方法来保持这种兼容性? 如果没有,请考虑先提出一个 Issue,以便在您投入时间进行 PR 之前讨论 API 的更改。 + +## 1. 设置 + +- **Go** - Task 使用 [Go](https://go.dev) 编写。 我们始终支持最新的两个主要 Go 版本,因此请确保您的版本足够新。 +- **Node.js** - [Node.js](https://nodejs.org/en/) 用于托管 Task 的文档服务器,如果您想在本地运行此服务器,则需要它。 +- **Yarn** - [Yarn](https://yarnpkg.com/) 是 Task 使用的 Node.js 包管理器。 + +## 2. 进行变更 + +- **代码风格** - 尽量保持现有的代码风格,并确保代码采用 `gofmt`。 我们在我们的 CI 中使用 `golangci-lint` 来强制执行一致的风格和最佳实践。 Taskfile 中有一个 `lint` 命令可以在本地运行。 +- **文档** - 确保添加/更新了相关文档。 请参阅下面的 [更新文档](#更新文档) 部分。 +- **测试** - 确保添加/更新了相关测试,并且在提交 PR 前已通过所有测试。 请参阅下面的 [编写测试](#编写测试) 部分。 + +### 运行您的变更 + +要运行带有工作变更的任务,您可以使用 `go run ./cmd/task`。 要针对 `testdata` 中的测试任务文件运行任务的开发构建,您可以使用 `go +run ./cmd/task --dir ./testdata/ `。 + +### 更新文档 + +Task 用 [Docusaurus](https://docusaurus.io) 托管文档服务。 这可以通过使用 `task docs`(需要 `nodejs` 和 `yarn`)在本地设置和运行。 所有内容均使用 Markdown 编写,位于 `docs/docs` 目录中。 所有 Markdown 文档都应有 80 个字符的换行限制。 + +进行变更时,请考虑是否有必要更改 [使用指南](./usage.md)。 本文档包含有关如何使用任务功能的说明和示例。 如果您要添加新功能,请尝试找到合适的位置来添加新部分。 如果您要更新现有功能,请确保文档和所有示例都是最新的。 确保任何示例都遵循 [Taskfile 风格指南](./styleguide.md)。 + +如果您添加了新字段、命令或标志,请确保将其添加到 [API 参考](./api_reference.md) 中。 还需要将新字段添加到 [JSON Schema](https://github.com/go-task/task/blob/master/docs/static/schema.json) 中。 API 参考和 schema 中的字段描述应该匹配。 + +### 编写测试 + +Task 的大部分测试都保存在项目根目录的 `task_test.go` 文件中并且这是您最有可能想要添加新测试的地方。 这些测试中的大多数在目录中还有一个 `testdata` 子目录,其中存储了运行测试所需的 Taskfiles/数据。 + +进行更改时,请考虑是否需要添加新的测试。 这些测试应确保您添加的功能在未来持续工作。 如果您更改了任务的行为,现有测试可能也需要更新。 + +## 3. 提交代码 + +编写有意义的提交信息,避免一个 PR 上有太多提交。 大多数PR应该有一个提交(尽管对于较大的PR来说,把它分成几个提交可能是合理的)。 Git squash和rebase是你的好朋友! + +## 4. 提交 PR + +- **描述变更** - 确保您提供对更改的全面描述。 +- **Issue/PR 链接** - 链接到之前相关的 Issue 或 PR。 请描述当前工作与之前的不同之处。 +- **示例** - 添加您认为有助于展示变更效果的示例。 +- **PR 草案** - 如果变更还未完成,但您想讨论它们,请将 PR 作为草稿打开并添加评论以开始讨论。 使用评论而不是 PR 描述允许稍后更新描述,同时保留讨论。 + +## 常见问题 + +> 我想贡献,我从哪里开始? + +查看 [未解决 Issue](https://github.com/go-task/task/issues) 的列表。 我们有一个 [good first issue](https://github.com/go-task/task/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) 标签,用于更简单的 Issue,非常适合首次贡献。 + +欢迎各种贡献,无论是拼写错误修复还是很小的新功能。 您还可以通过对 Issue 进行投票/评论、帮助回答问题或帮助 [其他社区项目](./community.md) 来做出贡献。 + +> 我被困住了,我在哪里可以获得帮助? + +如果您有任何疑问,请随时在我们的 [Discord 服务器](https://discord.gg/6TY36E39UK) 上的 `#help` 论坛频道中提问,或在 GitHub 上打开 [讨论](https://github.com/go-task/task/discussions)。 + +--- diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/donate.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/donate.md new file mode 100644 index 0000000000..700abb6a8f --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/donate.md @@ -0,0 +1,39 @@ +--- +slug: /donate/ +sidebar_position: 12 +--- + +# 赞助 + +如果您觉得这个项目有用,您可以考虑使用下面列出的渠道之一进行捐赠。 + +这只是一种表达“感谢”的方式,它不会给你任何好处,比如在 Issue 上的更高优先级或类似的东西。 + +每月捐赠至少 50 美元的公司将在网站主页和 GitHub 存储库 README 中被标为“金牌赞助商”。 请与 [@andreynering](https://github.com/andreynering) 联系,说明你希望显示的标志。 不过,可疑的企业(赌博、赌场等)将不被允许。 + +## GitHub Sponsors + +捐赠给维护者的首选方式是通过 GitHub Sponsors。 只需使用以下链接就可以进行捐赠: + +- [@andreynering](https://github.com/sponsors/andreynering) +- [@pd93](https://github.com/sponsors/pd93) + +## Open Collective + +如果你喜欢 [Open Collective](https://opencollective.com/task),你可以通过这些链接进行捐赠: + +- [每月 2 美元](https://opencollective.com/task/contribute/backer-4034/checkout) +- [每月 5 美元](https://opencollective.com/task/contribute/supporter-8404/checkout) +- [每月 20 美元](https://opencollective.com/task/contribute/sponsor-4035/checkout) +- [每月 50 美元](https://opencollective.com/task/contribute/sponsor-28775/checkout) +- [自定义金额 - 支持一次性捐赠选项](https://opencollective.com/task/donate) + +## PayPal + +你也可以通过 PayPal 向 [@andreynering](https://github.com/andreynering) 捐款。 + +- [任何金额 - 一次性捐款](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GSVDU63RKG45A¤cy_code=USD&source=url) + +## PIX (仅巴西) + +如果你是巴西人,你也可以通过 PIX [使用这个QR码](/img/pix.png) 向 [@andreynering](https://github.com/andreynering) 捐款。 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/faq.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/faq.md new file mode 100644 index 0000000000..f547c96aac --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/faq.md @@ -0,0 +1,40 @@ +--- +slug: /faq/ +sidebar_position: 5 +--- + +# 常见问题 + +此页面包含有关 Task 的常见问题列表。 + +- [为什么我的 task 不会更新我的 shell 环境?](#为什么我的-task-不会更新我的-shell-环境) +- [内置的 'x' 命令在 Windows 上不起作用](#内置的-x-命令在-windows-上不起作用) + +## 为什么我的 task 不会更新我的 shell 环境? + +这是 shell 工作方式的限制。 任务作为当前 shell 的子进程运行,因此它不能更改启动它的 shell 的环境。 其他任务运行器和构建工具也有此限制。 + +解决此问题的一种常见方法是创建一个 task,该任务将生成可由您的 shell 解析的输出。 例如,要在 shell 上设置环境变量,您可以编写如下任务: + +```yaml +my-shell-env: + cmds: + - echo "export FOO=foo" + - echo "export BAR=bar" +``` + +现在运行 `eval $(task my-shell-env)` 变量 `$FOO` 和 `$BAR` 将在您的 shell 中可用。 + +## 内置的 'x' 命令在 Windows 上不起作用 + +Windows 上的默认 shell(`cmd` 和 `powershell`)没有像 `rm` 和 `cp` 这样的内置命令。 这意味着这些命令将不起作用。 如果你想让你的 Taskfile 完全跨平台,你需要使用以下方法之一来解决这个限制: + +- 使用 `{{OS}}` 函数运行特定于操作系统的脚本。 +- 使用 `{{if eq OS "windows"}}powershell {{end}}` 之类的东西来检测 windows 并直接在 Powershell 中运行命令。 +- 在 Windows 上使用支持这些命令的 shell 作为内置命令,例如 [Git Bash](https://gitforwindows.org/) 或 [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)。 + +我们希望对 Task 的这一部分进行改进,下面的 Issue 会跟踪这项工作。 非常欢迎建设性的意见和贡献! + +- [#197](https://github.com/go-task/task/issues/197) +- [mvdan/sh#93](https://github.com/mvdan/sh/issues/93) +- [mvdan/sh#97](https://github.com/mvdan/sh/issues/97) diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/installation.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/installation.md new file mode 100644 index 0000000000..1df256228c --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/installation.md @@ -0,0 +1,231 @@ +--- +slug: /installation/ +sidebar_position: 2 +--- + +# 安装 + +Task 提供以下多种安装方式。 查看以下可用方法。 + +## 包管理工具 + +### Homebrew + +如果您使用的是 macOS 或 Linux 并安装了 [Homebrew](https://brew.sh/),获取 Task 就像运行一样简单: + +```bash +brew install go-task/tap/go-task +``` + +上面的公式是 [我们自己维护](https://github.com/go-task/homebrew-tap/blob/master/Formula/go-task.rb) 的。 + +最近,[官方 Homebrew 存储库](https://formulae.brew.sh/formula/go-task) 中也提供了 Task,因此如果您愿意,也可以使用该选项: + +```bash +brew install go-task +``` + +### Snap + +Task 在 [Snapcraft](https://snapcraft.io/task) 中可用,但请记住,您的 Linux 发行版应该符合 Snaps 的基本约束才能正确安装: + +```bash +sudo snap install task --classic +``` + +### Chocolatey + +如果 Windows 上安装了 [Chocolatey](https://chocolatey.org/),再安装 Task 只要这样: + +```bash +choco install go-task +``` + +这种安装方式是社区维护的。 + +### Scoop + +如果 Windows 上安装了 [Scoop](https://scoop.sh/),再安装 Task 只要这样: + +```cmd +scoop install task +``` + +这种安装方式是社区维护的。 新版 Task 发布后,需要过一段时间才能通过 Scoop 安装。 + +### AUR + +如果你使用的是 Arch Linux,你可以使用你最喜欢的包管理器(例如 `yay`、`pacaur` 或 `yaourt`)从 [AUR](https://aur.archlinux.org/packages/go-task-bin) 安装 Task: + +```cmd +yay -S go-task-bin +``` + +或者,有一个从源代码安装的 [软件包](https://aur.archlinux.org/packages/go-task),而不是从 [发布页面](https://github.com/go-task/task/releases) 下载二进制文件: + +```cmd +yay -S go-task +``` + +这种安装方式是社区维护的。 + +### Fedora + +如果您使用的是 Fedora Linux,则可以使用 `dnf` 从 [官方 Fedora 存储库](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/) 安装 Task: + +```cmd +sudo dnf install go-task +``` + +这种安装方式是社区维护的。 新版 Task 发布后,需要一段时间才能通过 [Fedora](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/) 安装。 + +### Nix + +如果您使用的是 NixOS 或安装了 Nix,则可以从 [nixpkgs](https://github.com/NixOS/nixpkgs) 安装 Task: + +```cmd +nix-env -iA nixpkgs.go-task +``` + +这种安装方式是社区维护的。 新版本的 Task 发布后,可能需要一些时间才能在 [nixpkgs](https://github.com/NixOS/nixpkgs) 中可用。 + +### npm + +您也可以通过使用 Node 和 npm 安装 [此包](https://www.npmjs.com/package/@go-task/cli) 来安装 Task。 + +```bash +npm install -g @go-task/cli +``` + +## 获取二进制文件 + +### 二进制文件 + +您可以从 [GitHub 上的发布页面](https://github.com/go-task/task/releases) 下载二进制文件并添加到您的 `$PATH` 中。 + +还支持 DEB 和 RPM 包。 + +`task_checksums.txt` 文件包含每个文件的 SHA-256 校验和。 + +### 安装脚本 + +我们还有一个 [安装脚本](https://github.com/go-task/task/blob/master/install-task.sh),它在 CI 等场景中非常有用。 非常感谢 [GoDownloader](https://github.com/goreleaser/godownloader) 使这个脚本的生成变得容易。 + +默认情况下,它安装在相对于工作目录的 `./bin` 目录中: + +```bash +sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d +``` + +可以使用 `-b` 参数覆盖安装目录。 通过 `-b` 参数可以自定义安装目录,在 Linux 中当前用户安装一般会选择 `~/.local/bin` 或 `~/bin`, 全局用户安装会选择 `/usr/local/bin`: + +```bash +sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin +``` + +:::caution + + +在 macOS 和 Windows 上,`~/.local/bin` 和 `~/bin` 默认情况下不会添加到 `$PATH`。 + +::: + + +### GitHub Actions + +如果你想在 GitHub Actions 中安装 Task,你可以尝试使用 Arduino 团队的 [这个 action](https://github.com/arduino/setup-task): + +```yaml +- name: Install Task + uses: arduino/setup-task@v1 +``` + +这种安装方式是社区维护的。 + +## 从源码构建 + +### Go Modules + +确保您已正确安装和设置受支持的 [Go](https://golang.org/) 版本。 您可以在 [go.mod](https://github.com/go-task/task/blob/master/go.mod#L3) 文件中找到最低要求的 Go 版本。 + +然后,您可以通过运行以下命令全局安装最新版本: + +```bash +go install github.com/go-task/task/v3/cmd/task@latest +``` + +或者你可以安装到另一个目录: + +```bash +env GOBIN=/bin go install github.com/go-task/task/v3/cmd/task@latest +``` + +:::tip + + +对于 CI 环境,我们建议改用 [安装脚本](#get-the-binary),它更快更稳定,因为它只会下载最新发布的二进制文件。 + +::: + + +## 自动完成 + +下载与您的 shell 对应的自动完成文件。 + +[所有自动完成都在任务存储库中可用](https://github.com/go-task/task/tree/master/completion)。 + +### Bash + +首先,确认你通过包管理安装了 bash-completion。 + +使完成文件可执行: + +``` +chmod +x path/to/task.bash +``` + +然后在 `~/.bash_profile` 文件中添加: + +```shell +source path/to/task.bash +``` + +### ZSH + +把 `_task` 文件放到你的 `$FPATH` 中: + +```shell +mv path/to/_task /usr/local/share/zsh/site-functions/_task +``` + +在 `~/.zshrc` 文件中添加: + +```shell +autoload -U compinit +compinit -i +``` + +建议使用 ZSH 5.7 或更高版本。 + +### Fish + +移动 `task.fish` 完成脚本: + +```shell +mv path/to/task.fish ~/.config/fish/completions/task.fish +``` + +### PowerShell + +使用以下命令打开您的配置文件脚本: + +``` +mkdir -Path (Split-Path -Parent $profile) -ErrorAction SilentlyContinue +notepad $profile +``` + +添加这行并保存文件: + +```shell +Invoke-Expression -Command path/to/task.ps1 +``` diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/intro.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/intro.md new file mode 100644 index 0000000000..6dff60ad2d --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/intro.md @@ -0,0 +1,48 @@ +--- +slug: / +sidebar_position: 1 +title: 主页 +--- + +# Task + +
+ +
+ +Task 是一个任务运行器/构建工具,旨在比 [GNU Make](https://www.gnu.org/software/make/) 等更简单易用。 + +由于它是用 [Go](https://go.dev/) 编写的,Task 只是一个二进制文件,没有其他依赖项,这意味着您不需要为了使用构建工具而搞乱任何复杂的安装设置。 + +[安装](installation.md) 后,您只需在名为 `Taskfile.yml` 的文件中使用简单的 [YAML](http://yaml.org/) 规则描述您的构建任务: + +```yaml title="Taskfile.yml" +version: '3' + +tasks: + hello: + cmds: + - echo 'Hello World from Task!' + silent: true +``` + +然后通过从您的终端运行 `task hello` 来调用它。 + +上面的示例只是一个开始,您可以查看 [使用指南](/usage) 以检查完整的模式文档和任务功能。 + +## 特性 + +- [易于安装](installation.md):只需要下载一个二进制文件,添加到 `$PATH` 即可! 或者,您也可以根据需要使用 [Homebrew](https://brew.sh/)、[Snapcraft](https://snapcraft.io/) 或 [Scoop](https://scoop.sh/) 进行安装。 +- 可以在 CI 中使用:只要添加 [这个命令](installation.md#安装脚本) 到 CI 安装脚本中,然后就可以把 Task 当做 CI 的一个功能来使用了。 +- 真正的跨平台:虽然大多数构建工具只能在 Linux 或 macOS 上运行良好,但由于 [这个用于 Go 的 shell 解释器](https://github.com/mvdan/sh),Task 也支持 Windows。 +- 非常适合代码生成:如果给定的一组文件自上次运行以来没有更改(基于其时间戳或内容),您可以轻松地阻止任务运行。 + +## 金牌赞助商 + +
+ +| [Appwrite][appwrite] | +| - | +| [![Appwrite](/img/appwrite.svg)][appwrite] | + +
diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/releasing.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/releasing.md new file mode 100644 index 0000000000..479320c547 --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/releasing.md @@ -0,0 +1,35 @@ +--- +slug: /releasing/ +sidebar_position: 10 +--- + +# 发布 + +Task 的发布流程是在 [GoReleaser](https://goreleaser.com/) 的帮助下完成的。 本地调用 Taskfile 的 `test-release` 任务可以测试发布流程。 + +[GitHub Actions](https://github.com/go-task/task/actions) 会在新 tag 推送到 master 分支的时候,自动发布产出物(原生的可执行文件、DEB 和 RPM 包)。 + +从 v3.15.0 开始,原始可执行文件也可以通过检查特定的标签并调用 `goreleaser build`,使用上述 GitHub Actions 中定义的 Go 版本,在本地进行复制和验证。 + +# Homebrew + +Goreleaser 会自动向 [Homebrew tap](https://github.com/go-task/homebrew-tap) 仓库中的 [Formula/go-task.rb](https://github.com/go-task/homebrew-tap/blob/master/Formula/go-task.rb) 文件推送一个新的提交,以发布新的版本。 + +# npm + +要发布到 npm ,请更新 [`package.json`](https://github.com/go-task/task/blob/master/package.json#L3) 文件中的版本,然后运行 `task npm:publish` 来推送它。 + +# Snapcraft + +[snap package](https://github.com/go-task/snap) 发布新版本需要手动执行下面步骤: + +* 更新 [snapcraft.yaml](https://github.com/go-task/snap/blob/master/snap/snapcraft.yaml#L2) 文件中的版本。 +* 把新的 `amd64`, `armhf` 和 `arm64` 移动到 [Snapcraft dashboard](https://snapcraft.io/task/releases) 的稳定通道。 + +# Scoop + +Scoop 是一个 Windows 系统的命令行包管理工具。 Scoop 的包清单由社区维护。 Scoop 的维护人通常会在 [这个文件](https://github.com/lukesampson/scoop-extras/blob/master/bucket/task.json) 里维护版本。 如果发现 Task 版本是旧的,请提交一个 Issue 通知我们。 + +# Nix + +Nix 安装由社区维护。 Nix 包的维护人员通常会在 [这个文件](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/tools/go-task/default.nix) 里维护版本。 如果发现 Task 版本是旧的,请提交一个 Issue 通知我们。 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/styleguide.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/styleguide.md new file mode 100644 index 0000000000..85519ec16e --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/styleguide.md @@ -0,0 +1,209 @@ +--- +slug: /styleguide/ +sidebar_position: 6 +--- + +# 风格指南 + +这是对 `Taskfile.yml` 文件的官方风格指南。 本指南包含一些基本说明,可让您的任务文件保持简洁易用。 + +这包含一般准则,但不一定需要严格遵守。 如果你需要或想要,请随时提出不同意见,并在某些时候以不同方式进行。 此外,请随时打开 Issue 或 PR,对本指南进行改进。 + +## 使用 `Taskfile.yml` 而不是 `taskfile.yml` + +```yaml +# bad +taskfile.yml + + +# good +Taskfile.yml +``` + +这对于 Linux 用户尤其重要。 Windows 和 macOS 的文件系统不区分大小写,因此 `taskfile.yml` 最终会正常工作,即使它不受官方支持。 不过,在 Linux 上,只有 `Taskfile.yml` 可以工作。 + +## 使用正确的关键字顺序 + +- `version:` +- `includes:` +- 可选配置命令,比如 `output:`、`silent:`、`method:` 和 `run:` +- `vars:` +- `env:`、`dotenv:` +- `tasks:` + +## 使用2 个空格缩进 + +这是 YAML 文件最常见的约定,Task 同样也遵循它。 + +```yaml +# bad +tasks: + foo: + cmds: + - echo 'foo' + + +# good +tasks: + foo: + cmds: + - echo 'foo' +``` + +## 用空行分隔主要部分 + +```yaml +# bad +version: '3' +includes: + docker: ./docker/Taskfile.yml +output: prefixed +vars: + FOO: bar +env: + BAR: baz +tasks: + # ... + + +# good +version: '3' + +includes: + docker: ./docker/Taskfile.yml + +output: prefixed + +vars: + FOO: bar + +env: + BAR: baz + +tasks: + # ... +``` + +## 用空行分隔 task + +```yaml +# bad +version: '3' + +tasks: + foo: + cmds: + - echo 'foo' + bar: + cmds: + - echo 'bar' + baz: + cmds: + - echo 'baz' + + +# good +version: '3' + +tasks: + foo: + cmds: + - echo 'foo' + + bar: + cmds: + - echo 'bar' + + baz: + cmds: + - echo 'baz' +``` + +## 使用大写变量名称 + +```yaml +# bad +version: '3' + +vars: + binary_name: myapp + +tasks: + build: + cmds: + - go build -o {{.binary_name}} . + + +# good +version: '3' + +vars: + BINARY_NAME: myapp + +tasks: + build: + cmds: + - go build -o {{.BINARY_NAME}} . +``` + +## 模板中不要用空格包住变量 + +```yaml +# bad +version: '3' + +tasks: + greet: + cmds: + - echo '{{ .MESSAGE }}' + + +# good +version: '3' + +tasks: + greet: + cmds: + - echo '{{.MESSAGE}}' +``` + +这个约定也被大多数人用于 Go 模板。 + +## 用破折号分隔任务名称单词 + +```yaml +# bad +version: '3' + +tasks: + do_something_fancy: + cmds: + - echo 'Do something' + + +# good +version: '3' + +tasks: + do-something-fancy: + cmds: + - echo 'Do something' +``` + +## 使用冒号作为任务命名空间 + +```yaml +# good +version: '3' + +tasks: + docker:build: + cmds: + - docker ... + + docker:run: + cmds: + - docker-compose ... +``` + +这在使用包含的任务文件时也会自动完成。 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/taskfile_versions.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/taskfile_versions.md new file mode 100644 index 0000000000..c8f2c05b16 --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/taskfile_versions.md @@ -0,0 +1,204 @@ +--- +slug: /taskfile-versions/ +sidebar_position: 11 +--- + +# Taskfile 版本 + +Taskfile 语法和功能随着时间的推移而改变。 本文档解释了每个版本的变化以及如何升级您的任务文件。 + +## Taskfile 版本的含义 + +Taskfile 版本遵循 Task 版本。 例如, taskfile version `2` 意味着应该切换为 Task `v2.0.0` 以支持它。 + +Taskfile 文件的 `version:` 关键字接受语义化字符串, 所以 `2`, `2.0` 或 `2.0.0` 都可以。 如果使用版本号 `2.0`,那么 Task 就不会使用 `2.1` 的功能, 但如果使用版本号 `2`, 那么任意 `2.x.x` 版本中的功能都是可用的, 但 `3.0.0+` 的功能不可用。 + +## 版本 1 + +> 注意:Task v3.0.0 以后就不再支持 Taskfiles 的 1 版本了。 + +最初的 `Taskfile` 并不支持 `version:` 关键字,因为 YAML 文档中的根属性都是 task。 就像这样: + +```yaml +echo: + cmds: + - echo "Hello, World!" +``` + +变量的优先级也不同: + +1. 调用变量 +2. 环境变量 +3. Task 变量 +4. `Taskvars.yml` 定义变量 + +## 版本 2.0 + +到了 2.0 版本,我们引入了 `version:` 字段, 在不破坏已存在的 Taskfiles 的前提下,在 Task 中引入新功能。 新语法如下: + +```yaml +version: '2' + +tasks: + echo: + cmds: + - echo "Hello, World!" +``` + +如果您不想创建 `Taskvars.yml`,版本 2 允许您直接在任务文件中写入全局变量: + +```yaml +version: '2' + +vars: + GREETING: Hello, World! + +tasks: + greet: + cmds: + - echo "{{.GREETING}}" +``` + +变量的优先级调整为: + +1. Task 变量 +2. 调用变量 +3. Taskfile 定义变量 +4. Taskvars 文件定义变量 +5. 环境变量 + +添加了一个新的全局配置项来配置变量扩展的数量(默认为 2): + +```yaml +version: '2' + +expansions: 3 + +vars: + FOO: foo + BAR: bar + BAZ: baz + FOOBAR: "{{.FOO}}{{.BAR}}" + FOOBARBAZ: "{{.FOOBAR}}{{.BAZ}}" + +tasks: + default: + cmds: + - echo "{{.FOOBARBAZ}}" +``` + +## 版本 2.1 + +2.1 版包括一个全局 `output` 选项,以允许更好地控制如何将命令输出打印到控制台(有关更多信息,请参阅 [文档](usage.md#输出语法)): + +```yaml +version: '2' + +output: prefixed + +tasks: + server: + cmds: + - go run main.go + prefix: server +``` + +从这个版本开始,也可以忽略命令或 task 的错误(在 [此处](usage.md#忽略错误) 查看文档): + +```yaml +version: '2' + +tasks: + example-1: + cmds: + - cmd: exit 1 + ignore_error: true + - echo "This will be print" + + example-2: + cmds: + - exit 1 + - echo "This will be print" + ignore_error: true +``` + +## 版本 2.2 + +2.2 版带有全局 `includes` 选项来包含其他 Taskfiles: + +```yaml +version: '2' + +includes: + docs: ./documentation # will look for ./documentation/Taskfile.yml + docker: ./DockerTasks.yml +``` + +## 版本 2.6 + +2.6 版本增加任务的先决条件字段 `preconditions`。 + +```yaml +version: '2' + +tasks: + upload_environment: + preconditions: + - test -f .env + cmds: + - aws s3 cp .env s3://myenvironment +``` + +请检查 [文档](usage.md#包含其他-taskfile) + +## 版本 3 + +以下是 `v3` 所做的一些主要变更: + +- Task 的日志使用彩色输出 +- 支持类 `.env` 文件 +- 添加 `label:` 设置后可以覆盖任务名称在日志中的显示方式 +- 添加了全局 `method:` 允许设置默认方法,Task 的默认值更改为 `checksum` +- 使用 `status:`: `CHECKSUM` 和 `TIMESTAMP` 时新增了两个魔术变量,分别包含 `sources:` 列出的文件的 md5 checksum 和最大修改时间戳 +- 另外,`TASK` 变量总是可以使用当前的任务名称 +- CLI 变量始终被视为全局变量 +- 向 `includes` 添加了 `dir:` 选项,以允许选择包含的任务文件将在哪个目录上运行: + +```yaml +includes: + docs: + taskfile: ./docs + dir: ./docs +``` + +- 实现短任务语法。 以下所有语法都是等效的: + +```yaml +version: '3' + +tasks: + print: + cmds: + - echo "Hello, World!" +``` + +```yaml +version: '3' + +tasks: + print: + - echo "Hello, World!" +``` + +```yaml +version: '3' + +tasks: + print: echo "Hello, World!" +``` + +- 对变量的处理方式进行了重大重构。 现在它们更容易理解了。 `expansions:` 设置被删除了,因为它变得不必要。 这是 Task 处理变量的顺序,每一层都可以看到前一层设置的变量并覆盖这些变量。 + - 环境变量 + - 全局或 CLI 变量 + - 调用变量 + - Task 内的变量 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage.md new file mode 100644 index 0000000000..443d816c6c --- /dev/null +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage.md @@ -0,0 +1,1357 @@ +--- +slug: /usage/ +sidebar_position: 3 +--- + +# 使用指南 + +## 快速入门 + +Create a file called `Taskfile.yml` in the root of your project. The `cmds` attribute should contain the commands of a task. The example below allows compiling a Go app and uses [esbuild](https://esbuild.github.io/) to concat and minify multiple CSS files into a single one. + +```yaml +version: '3' + +tasks: + build: + cmds: + - go build -v -i main.go + + assets: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css +``` + +Running the tasks is as simple as running: + +```bash +task assets build +``` + +Task uses [mvdan.cc/sh](https://mvdan.cc/sh/), a native Go sh interpreter. So you can write sh/bash commands, and it will work even on Windows, where `sh` or `bash` are usually not available. Just remember any executable called must be available by the OS or in PATH. + +If you omit a task name, "default" will be assumed. + +## 支持的文件名称 + +Task will look for the following file names, in order of priority: + +- Taskfile.yml +- Taskfile.yaml +- Taskfile.dist.yml +- Taskfile.dist.yaml + +The intention of having the `.dist` variants is to allow projects to have one committed version (`.dist`) while still allowing individual users to override the Taskfile by adding an additional `Taskfile.yml` (which would be on `.gitignore`). + +### 从子目录运行 Taskfile + +If a Taskfile cannot be found in the current working directory, it will walk up the file tree until it finds one (similar to how `git` works). When running Task from a subdirectory like this, it will behave as if you ran it from the directory containing the Taskfile. + +You can use this functionality along with the special `{{.USER_WORKING_DIR}}` variable to create some very useful reusable tasks. For example, if you have a monorepo with directories for each microservice, you can `cd` into a microservice directory and run a task command to bring it up without having to create multiple tasks or Taskfiles with identical content. For example: + +```yaml +version: '3' + +tasks: + up: + dir: '{{.USER_WORKING_DIR}}' + preconditions: + - test -f docker-compose.yml + cmds: + - docker-compose up -d +``` + +In this example, we can run `cd ` and `task up` and as long as the `` directory contains a `docker-compose.yml`, the Docker composition will be brought up. + +### 运行全局 Taskfile + +If you call Task with the `--global` (alias `-g`) flag, it will look for your home directory instead of your working directory. In short, Task will look for a Taskfile on either `$HOME/Taskfile.yml` or `$HOME/Taskfile.yaml` paths. + +This is useful to have automation that you can run from anywhere in your system! + +:::info + + +When running your global Taskfile with `-g`, tasks will run on `$HOME` by default, and not on your working directory! + +As mentioned in the previous section, the `{{.USER_WORKING_DIR}}` special variable can be very handy here to run stuff on the directory you're calling `task -g` from. + +```yaml +version: '3' + +tasks: + from-home: + cmds: + - pwd + + from-working-directory: + dir: '{{.USER_WORKING_DIR}}' + cmds: + - pwd +``` + +::: + + +## 环境变量 + +### Task + +You can use `env` to set custom environment variables for a specific task: + +```yaml +version: '3' + +tasks: + greet: + cmds: + - echo $GREETING + env: + GREETING: Hey, there! +``` + +Additionally, you can set global environment variables that will be available to all tasks: + +```yaml +version: '3' + +env: + GREETING: Hey, there! + +tasks: + greet: + cmds: + - echo $GREETING +``` + +:::info + + +`env` supports expansion and retrieving output from a shell command just like variables, as you can see in the [Variables](#variables) section. + +::: + + +### .env 文件 + +You can also ask Task to include `.env` like files by using the `dotenv:` setting: + +```bash title=".env" +KEYNAME=VALUE +``` + +```bash title="testing/.env" +ENDPOINT=testing.com +``` + +```yaml title="Taskfile.yml" +version: '3' + +env: + ENV: testing + +dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env'] + +tasks: + greet: + cmds: + - echo "Using $KEYNAME and endpoint $ENDPOINT" +``` + +Dotenv files can also be specified at the task level: + +```yaml +version: '3' + +env: + ENV: testing + +tasks: + greet: + dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env'] + cmds: + - echo "Using $KEYNAME and endpoint $ENDPOINT" +``` + +Environment variables specified explicitly at the task-level will override variables defined in dotfiles: + +```yaml +version: '3' + +env: + ENV: testing + +tasks: + greet: + dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env'] + env: + KEYNAME: DIFFERENT_VALUE + cmds: + - echo "Using $KEYNAME and endpoint $ENDPOINT" +``` + +:::info + + +Please note that you are not currently able to use the `dotenv` key inside included Taskfiles. + +::: + + +## 包含其他 Taskfile + +If you want to share tasks between different projects (Taskfiles), you can use the importing mechanism to include other Taskfiles using the `includes` keyword: + +```yaml +version: '3' + +includes: + docs: ./documentation # will look for ./documentation/Taskfile.yml + docker: ./DockerTasks.yml +``` + +The tasks described in the given Taskfiles will be available with the informed namespace. So, you'd call `task docs:serve` to run the `serve` task from `documentation/Taskfile.yml` or `task docker:build` to run the `build` task from the `DockerTasks.yml` file. + +Relative paths are resolved relative to the directory containing the including Taskfile. + +### 操作系统特定 Taskfile + +With `version: '2'`, task automatically includes any `Taskfile_{{OS}}.yml` if it exists (for example: `Taskfile_windows.yml`, `Taskfile_linux.yml` or `Taskfile_darwin.yml`). Since this behavior was a bit too implicit, it was removed on version 3, but you still can have a similar behavior by explicitly importing these files: + +```yaml +version: '3' + +includes: + build: ./Taskfile_{{OS}}.yml +``` + +### 包含 Taskfile 的目录 + +By default, included Taskfile's tasks are run in the current directory, even if the Taskfile is in another directory, but you can force its tasks to run in another directory by using this alternative syntax: + +```yaml +version: '3' + +includes: + docs: + taskfile: ./docs/Taskfile.yml + dir: ./docs +``` + +:::info + + +The included Taskfiles must be using the same schema version as the main Taskfile uses. + +::: + + +### Optional includes + +Includes marked as optional will allow Task to continue execution as normal if the included file is missing. + +```yaml +version: '3' + +includes: + tests: + taskfile: ./tests/Taskfile.yml + optional: true + +tasks: + greet: + cmds: + - echo "This command can still be successfully executed if ./tests/Taskfile.yml does not exist" +``` + +### Internal includes + +Includes marked as internal will set all the tasks of the included file to be internal as well (see the [Internal tasks](#internal-tasks) section below). This is useful when including utility tasks that are not intended to be used directly by the user. + +```yaml +version: '3' + +includes: + tests: + taskfile: ./taskfiles/Utils.yml + internal: true +``` + +### 包含的 Taskfile 的变量 + +You can also specify variables when including a Taskfile. This may be useful for having reusable Taskfile that can be tweaked or even included more than once: + +```yaml +version: '3' + +includes: + backend: + taskfile: ./taskfiles/Docker.yml + vars: + DOCKER_IMAGE: backend_image + + frontend: + taskfile: ./taskfiles/Docker.yml + vars: + DOCKER_IMAGE: frontend_image +``` + +### 命名空间别名。 + +When including a Taskfile, you can give the namespace a list of `aliases`. This works in the same way as [task aliases](#task-aliases) and can be used together to create shorter and easier-to-type commands. + +```yaml +version: '3' + +includes: + generate: + taskfile: ./taskfiles/Generate.yml + aliases: [gen] +``` + +:::info + + +Vars declared in the included Taskfile have preference over the variables in the including Taskfile! If you want a variable in an included Taskfile to be overridable, use the [default function](https://go-task.github.io/slim-sprig/defaults.html): `MY_VAR: '{{.MY_VAR | default "my-default-value"}}'`. + +::: + + +## 内部 task + +Internal tasks are tasks that cannot be called directly by the user. They will not appear in the output when running `task --list|--list-all`. Other tasks may call internal tasks in the usual way. This is useful for creating reusable, function-like tasks that have no useful purpose on the command line. + +```yaml +version: '3' + +tasks: + build-image-1: + cmds: + - task: build-image + vars: + DOCKER_IMAGE: image-1 + + build-image: + internal: true + cmds: + - docker build -t {{.DOCKER_IMAGE}} . +``` + +## Task 目录 + +By default, tasks will be executed in the directory where the Taskfile is located. But you can easily make the task run in another folder, informing `dir`: + +```yaml +version: '3' + +tasks: + serve: + dir: public/www + cmds: + # run http server + - caddy +``` + +If the directory does not exist, `task` creates it. + +## Task 依赖 + +> Dependencies run in parallel, so dependencies of a task should not depend one another. If you want to force tasks to run serially, take a look at the [Calling Another Task](#calling-another-task) section below. + +You may have tasks that depend on others. Just pointing them on `deps` will make them run automatically before running the parent task: + +```yaml +version: '3' + +tasks: + build: + deps: [assets] + cmds: + - go build -v -i main.go + + assets: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css +``` + +In the above example, `assets` will always run right before `build` if you run `task build`. + +A task can have only dependencies and no commands to group tasks together: + +```yaml +version: '3' + +tasks: + assets: + deps: [js, css] + + js: + cmds: + - esbuild --bundle --minify js/index.js > public/bundle.js + + css: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css +``` + +If there is more than one dependency, they always run in parallel for better performance. + +:::tip + + +You can also make the tasks given by the command line run in parallel by using the `--parallel` flag (alias `-p`). Example: `task --parallel js css`. + +::: + + +If you want to pass information to dependencies, you can do that the same manner as you would to [call another task](#calling-another-task): + +```yaml +version: '3' + +tasks: + default: + deps: + - task: echo_sth + vars: {TEXT: "before 1"} + - task: echo_sth + vars: {TEXT: "before 2"} + cmds: + - echo "after" + + echo_sth: + cmds: + - echo {{.TEXT}} +``` + +## 平台特定的 task 和 命令 + +If you want to restrict the running of tasks to explicit platforms, this can be achieved using the `platforms:` key. Tasks can be restricted to a specific OS, architecture or a combination of both. On a mismatch, the task or command will be skipped, and no error will be thrown. + +The values allowed as OS or Arch are valid `GOOS` and `GOARCH` values, as defined by the Go language [here](https://github.com/golang/go/blob/master/src/go/build/syslist.go). + +The `build-windows` task below will run only on Windows, and on any architecture: + +```yaml +version: '3' + +tasks: + build-windows: + platforms: [windows] + cmds: + - echo 'Running command on Windows' +``` + +This can be restricted to a specific architecture as follows: + +```yaml +version: '3' + +tasks: + build-windows-amd64: + platforms: [windows/amd64] + cmds: + - echo 'Running command on Windows (amd64)' +``` + +It is also possible to restrict the task to specific architectures: + +```yaml +version: '3' + +tasks: + build-amd64: + platforms: [amd64] + cmds: + - echo 'Running command on amd64' +``` + +Multiple platforms can be specified as follows: + +```yaml +version: '3' + +tasks: + build: + platforms: [windows/amd64, darwin] + cmds: + - echo 'Running command on Windows (amd64) and macOS' +``` + +Individual commands can also be restricted to specific platforms: + +```yaml +version: '3' + +tasks: + build: + cmds: + - cmd: echo 'Running command on Windows (amd64) and macOS' + platforms: [windows/amd64, darwin] + - cmd: echo 'Running on all platforms' +``` + +## 调用另一个任务 + +When a task has many dependencies, they are executed concurrently. This will often result in a faster build pipeline. However, in some situations, you may need to call other tasks serially. In this case, use the following syntax: + +```yaml +version: '3' + +tasks: + main-task: + cmds: + - task: task-to-be-called + - task: another-task + - echo "Both done" + + task-to-be-called: + cmds: + - echo "Task to be called" + + another-task: + cmds: + - echo "Another task" +``` + +Overriding variables in the called task is as simple as informing `vars` attribute: + +```yaml +version: '3' + +tasks: + greet: + vars: + RECIPIENT: '{{default "World" .RECIPIENT}}' + cmds: + - echo "Hello, {{.RECIPIENT}}!" + + greet-pessimistically: + cmds: + - task: greet + vars: {RECIPIENT: "Cruel World"} +``` + +The above syntax is also supported in `deps`. + +:::tip + + +NOTE: If you want to call a task declared in the root Taskfile from within an [included Taskfile](#including-other-taskfiles), add a leading `:` like this: `task: :task-name`. + +::: + + +## Prevent unnecessary work + +### By fingerprinting locally generated files and their sources + +If a task generates something, you can inform Task the source and generated files, so Task will prevent running them if not necessary. + +```yaml +version: '3' + +tasks: + build: + deps: [js, css] + cmds: + - go build -v -i main.go + + js: + cmds: + - esbuild --bundle --minify js/index.js > public/bundle.js + sources: + - src/js/**/*.js + generates: + - public/bundle.js + + css: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css + sources: + - src/css/**/*.css + generates: + - public/bundle.css +``` + +`sources` and `generates` can be files or file patterns. When given, Task will compare the checksum of the source files to determine if it's necessary to run the task. If not, it will just print a message like `Task "js" is up to date`. + +If you prefer this check to be made by the modification timestamp of the files, instead of its checksum (content), just set the `method` property to `timestamp`. + +```yaml +version: '3' + +tasks: + build: + cmds: + - go build . + sources: + - ./*.go + generates: + - app{{exeExt}} + method: timestamp +``` + +In situations where you need more flexibility the `status` keyword can be used. You can even combine the two. See the documentation for [status](#using-programmatic-checks-to-indicate-a-task-is-up-to-date) for an example. + +:::info + + +By default, task stores checksums on a local `.task` directory in the project's directory. Most of the time, you'll want to have this directory on `.gitignore` (or equivalent) so it isn't committed. (If you have a task for code generation that is committed it may make sense to commit the checksum of that task as well, though). + +If you want these files to be stored in another directory, you can set a `TASK_TEMP_DIR` environment variable in your machine. It can contain a relative path like `tmp/task` that will be interpreted as relative to the project directory, or an absolute or home path like `/tmp/.task` or `~/.task` (subdirectories will be created for each project). + +```bash +export TASK_TEMP_DIR='~/.task' +``` + +::: + + +:::info + + +Each task has only one checksum stored for its `sources`. If you want to distinguish a task by any of its input variables, you can add those variables as part of the task's label, and it will be considered a different task. + +This is useful if you want to run a task once for each distinct set of inputs until the sources actually change. For example, if the sources depend on the value of a variable, or you if you want the task to rerun if some arguments change even if the source has not. + +::: + + +:::tip + + +The method `none` skips any validation and always run the task. + +::: + + +:::info + + +For the `checksum` (default) or `timestamp` method to work, it is only necessary to inform the source files. When the `timestamp` method is used, the last time of the running the task is considered as a generate. + +::: + + +### Using programmatic checks to indicate a task is up to date. + +Alternatively, you can inform a sequence of tests as `status`. If no error is returned (exit status 0), the task is considered up-to-date: + +```yaml +version: '3' + +tasks: + generate-files: + cmds: + - mkdir directory + - touch directory/file1.txt + - touch directory/file2.txt + # test existence of files + status: + - test -d directory + - test -f directory/file1.txt + - test -f directory/file2.txt +``` + +Normally, you would use `sources` in combination with `generates` - but for tasks that generate remote artifacts (Docker images, deploys, CD releases) the checksum source and timestamps require either access to the artifact or for an out-of-band refresh of the `.checksum` fingerprint file. + +Two special variables `{{.CHECKSUM}}` and `{{.TIMESTAMP}}` are available for interpolation within `status` commands, depending on the method assigned to fingerprint the sources. Only `source` globs are fingerprinted. + +Note that the `{{.TIMESTAMP}}` variable is a "live" Go `time.Time` struct, and can be formatted using any of the methods that `time.Time` responds to. + +See [the Go Time documentation](https://golang.org/pkg/time/) for more information. + +You can use `--force` or `-f` if you want to force a task to run even when up-to-date. + +Also, `task --status [tasks]...` will exit with a non-zero exit code if any of the tasks are not up-to-date. + +`status` can be combined with the [fingerprinting](#by-fingerprinting-locally-generated-files-and-their-sources) to have a task run if either the the source/generated artifacts changes, or the programmatic check fails: + +```yaml +version: '3' + +tasks: + build:prod: + desc: Build for production usage. + cmds: + - composer install + # Run this task if source files changes. + sources: + - composer.json + - composer.lock + generates: + - ./vendor/composer/installed.json + - ./vendor/autoload.php + # But also run the task if the last build was not a production build. + status: + - grep -q '"dev": false' ./vendor/composer/installed.json +``` + +### Using programmatic checks to cancel the execution of a task and its dependencies + +In addition to `status` checks, `preconditions` checks are the logical inverse of `status` checks. That is, if you need a certain set of conditions to be _true_ you can use the `preconditions` stanza. `preconditions` are similar to `status` lines, except they support `sh` expansion, and they SHOULD all return 0. + +```yaml +version: '3' + +tasks: + generate-files: + cmds: + - mkdir directory + - touch directory/file1.txt + - touch directory/file2.txt + # test existence of files + preconditions: + - test -f .env + - sh: "[ 1 = 0 ]" + msg: "One doesn't equal Zero, Halting" +``` + +Preconditions can set specific failure messages that can tell a user what steps to take using the `msg` field. + +If a task has a dependency on a sub-task with a precondition, and that precondition is not met - the calling task will fail. Note that a task executed with a failing precondition will not run unless `--force` is given. + +Unlike `status`, which will skip a task if it is up to date and continue executing tasks that depend on it, a `precondition` will fail a task, along with any other tasks that depend on it. + +```yaml +version: '3' + +tasks: + task-will-fail: + preconditions: + - sh: "exit 1" + + task-will-also-fail: + deps: + - task-will-fail + + task-will-still-fail: + cmds: + - task: task-will-fail + - echo "I will not run" +``` + +### Limiting when tasks run + +If a task executed by multiple `cmds` or multiple `deps` you can control when it is executed using `run`. `run` can also be set at the root of the Taskfile to change the behavior of all the tasks unless explicitly overridden. + +Supported values for `run`: + + * `always` (default) always attempt to invoke the task regardless of the number of previous executions + * `once` only invoke this task once regardless of the number of references + * `when_changed` only invokes the task once for each unique set of variables passed into the task + +```yaml +version: '3' + +tasks: + default: + cmds: + - task: generate-file + vars: { CONTENT: '1' } + - task: generate-file + vars: { CONTENT: '2' } + - task: generate-file + vars: { CONTENT: '2' } + + generate-file: + run: when_changed + deps: + - install-deps + cmds: + - echo {{.CONTENT}} + + install-deps: + run: once + cmds: + - sleep 5 # long operation like installing packages +``` + +## 变量 + +When doing interpolation of variables, Task will look for the below. They are listed below in order of importance (i.e. most important first): + +- Variables declared in the task definition +- Variables given while calling a task from another (See [Calling another task](#calling-another-task) above) +- Variables of the [included Taskfile](#including-other-taskfiles) (when the task is included) +- Variables of the [inclusion of the Taskfile](#vars-of-included-taskfiles) (when the task is included) +- Global variables (those declared in the `vars:` option in the Taskfile) +- Environment variables + +Example of sending parameters with environment variables: + +```bash +$ TASK_VARIABLE=a-value task do-something +``` + +:::tip + + +A special variable `.TASK` is always available containing the task name. + +::: + + +Since some shells do not support the above syntax to set environment variables (Windows) tasks also accept a similar style when not at the beginning of the command. + +```bash +$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!" +``` + +Example of locally declared vars: + +```yaml +version: '3' + +tasks: + print-var: + cmds: + - echo "{{.VAR}}" + vars: + VAR: Hello! +``` + +Example of global vars in a `Taskfile.yml`: + +```yaml +version: '3' + +vars: + GREETING: Hello from Taskfile! + +tasks: + greet: + cmds: + - echo "{{.GREETING}}" +``` + +### 动态变量 + +The below syntax (`sh:` prop in a variable) is considered a dynamic variable. The value will be treated as a command and the output assigned. If there are one or more trailing newlines, the last newline will be trimmed. + +```yaml +version: '3' + +tasks: + build: + cmds: + - go build -ldflags="-X main.Version={{.GIT_COMMIT}}" main.go + vars: + GIT_COMMIT: + sh: git log -n 1 --format=%h +``` + +This works for all types of variables. + +## 将 CLI 参数转发到 cmds + +If `--` is given in the CLI, all following parameters are added to a special `.CLI_ARGS` variable. This is useful to forward arguments to another command. + +The below example will run `yarn install`. + +```bash +$ task yarn -- install +``` + +```yaml +version: '3' + +tasks: + yarn: + cmds: + - yarn {{.CLI_ARGS}} +``` + +## Doing task cleanup with `defer` + +With the `defer` keyword, it's possible to schedule cleanup to be run once the task finishes. The difference with just putting it as the last command is that this command will run even when the task fails. + +In the example below, `rm -rf tmpdir/` will run even if the third command fails: + +```yaml +version: '3' + +tasks: + default: + cmds: + - mkdir -p tmpdir/ + - defer: rm -rf tmpdir/ + - echo 'Do work on tmpdir/' +``` + +If you want to move the cleanup command into another task, that is possible as well: + +```yaml +version: '3' + +tasks: + default: + cmds: + - mkdir -p tmpdir/ + - defer: { task: cleanup } + - echo 'Do work on tmpdir/' + + cleanup: rm -rf tmpdir/ +``` + +:::info + + +Due to the nature of how the [Go's own `defer` work](https://go.dev/tour/flowcontrol/13), the deferred commands are executed in the reverse order if you schedule multiple of them. + +::: + + +## Go 的模板引擎 + +Task parse commands as [Go's template engine](https://golang.org/pkg/text/template/) before executing them. Variables are accessible through dot syntax (`.VARNAME`). + +All functions by the Go's [slim-sprig lib](https://go-task.github.io/slim-sprig/) are available. The following example gets the current date in a given format: + +```yaml +version: '3' + +tasks: + print-date: + cmds: + - echo {{now | date "2006-01-02"}} +``` + +Task also adds the following functions: + +- `OS`: Returns the operating system. Possible values are "windows", "linux", "darwin" (macOS) and "freebsd". +- `ARCH`: return the architecture Task was compiled to: "386", "amd64", "arm" or "s390x". +- `splitLines`: Splits Unix (\n) and Windows (\r\n) styled newlines. +- `catLines`: Replaces Unix (\n) and Windows (\r\n) styled newlines with a space. +- `toSlash`: Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. +- `fromSlash`: Opposite of `toSlash`. Does nothing on Unix, but on Windows converts a string from `/` path format to `\`. +- `exeExt`: Returns the right executable extension for the current OS (`".exe"` for Windows, `""` for others). +- `shellQuote`: Quotes a string to make it safe for use in shell scripts. Task uses [this Go function](https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/syntax#Quote) for this. The Bash dialect is assumed. + +Example: + +```yaml +version: '3' + +tasks: + print-os: + cmds: + - echo '{{OS}} {{ARCH}}' + - echo '{{if eq OS "windows"}}windows-command{{else}}unix-command{{end}}' + # This will be path/to/file on Unix but path\to\file on Windows + - echo '{{fromSlash "path/to/file"}}' + enumerated-file: + vars: + CONTENT: | + foo + bar + cmds: + - | + cat << EOF > output.txt + {{range $i, $line := .CONTENT | splitLines -}} + {{printf "%3d" $i}}: {{$line}} + {{end}}EOF +``` + +## 帮助 + +Running `task --list` (or `task -l`) lists all tasks with a description. The following Taskfile: + +```yaml +version: '3' + +tasks: + build: + desc: Build the go binary. + cmds: + - go build -v -i main.go + + test: + desc: Run all the go tests. + cmds: + - go test -race ./... + + js: + cmds: + - esbuild --bundle --minify js/index.js > public/bundle.js + + css: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css +``` + +would print the following output: + +```bash +* build: Build the go binary. +* test: Run all the go tests. +``` + +If you want to see all tasks, there's a `--list-all` (alias `-a`) flag as well. + +## 显示任务摘要 + +Running `task --summary task-name` will show a summary of a task. The following Taskfile: + +```yaml +version: '3' + +tasks: + release: + deps: [build] + summary: | + Release your project to github + + It will build your project before starting the release. + Please make sure that you have set GITHUB_TOKEN before starting. + cmds: + - your-release-tool + + build: + cmds: + - your-build-tool +``` + +with running `task --summary release` would print the following output: + +``` +task: release + +Release your project to github + +It will build your project before starting the release. +Please make sure that you have set GITHUB_TOKEN before starting. + +dependencies: + - build + +commands: + - your-release-tool +``` +If a summary is missing, the description will be printed. If the task does not have a summary or a description, a warning is printed. + +Please note: *showing the summary will not execute the command*. + +## Task 别名 + +Aliases are alternative names for tasks. They can be used to make it easier and quicker to run tasks with long or hard-to-type names. You can use them on the command line, when [calling sub-tasks](#calling-another-task) in your Taskfile and when [including tasks](#including-other-taskfiles) with aliases from another Taskfile. They can also be used together with [namespace aliases](#namespace-aliases). + +```yaml +version: '3' + +tasks: + generate: + aliases: [gen] + cmds: + - task: gen-mocks + + generate-mocks: + aliases: [gen-mocks] + cmds: + - echo "generating..." +``` + +## 重写 Task 名称 + +Sometimes you may want to override the task name printed on the summary, up-to-date messages to STDOUT, etc. In this case, you can just set `label:`, which can also be interpolated with variables: + +```yaml +version: '3' + +tasks: + default: + - task: print + vars: + MESSAGE: hello + - task: print + vars: + MESSAGE: world + + print: + label: 'print-{{.MESSAGE}}' + cmds: + - echo "{{.MESSAGE}}" +``` + +## 静默模式 + +Silent mode disables the echoing of commands before Task runs it. For the following Taskfile: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - echo "Print something" +``` + +Normally this will be printed: + +```sh +echo "Print something" +Print something +``` + +With silent mode on, the below will be printed instead: + +```sh +Print something +``` + +There are four ways to enable silent mode: + +* At command level: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - cmd: echo "Print something" + silent: true +``` + +* At task level: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - echo "Print something" + silent: true +``` + +* Globally at Taskfile level: + +```yaml +version: '3' + +silent: true + +tasks: + echo: + cmds: + - echo "Print something" +``` + +* Or globally with `--silent` or `-s` flag + +If you want to suppress STDOUT instead, just redirect a command to `/dev/null`: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - echo "This will print nothing" > /dev/null +``` + +## Dry run mode + +Dry run mode (`--dry`) compiles and steps through each task, printing the commands that would be run without executing them. This is useful for debugging your Taskfiles. + +## 忽略错误 + +You have the option to ignore errors during command execution. Given the following Taskfile: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - exit 1 + - echo "Hello World" +``` + +Task will abort the execution after running `exit 1` because the status code `1` stands for `EXIT_FAILURE`. However, it is possible to continue with execution using `ignore_error`: + +```yaml +version: '3' + +tasks: + echo: + cmds: + - cmd: exit 1 + ignore_error: true + - echo "Hello World" +``` + +`ignore_error` can also be set for a task, which means errors will be suppressed for all commands. Nevertheless, keep in mind that this option will not propagate to other tasks called either by `deps` or `cmds`! + +## 输出语法 + +By default, Task just redirects the STDOUT and STDERR of the running commands to the shell in real-time. This is good for having live feedback for logging printed by commands, but the output can become messy if you have multiple commands running simultaneously and printing lots of stuff. + +To make this more customizable, there are currently three different output options you can choose: + +- `interleaved` (default) +- `group` +- `prefixed` + +To choose another one, just set it to root in the Taskfile: + +```yaml +version: '3' + +output: 'group' + +tasks: + # ... +``` + +The `group` output will print the entire output of a command once after it finishes, so you will not have live feedback for commands that take a long time to run. + +When using the `group` output, you can optionally provide a templated message to print at the start and end of the group. This can be useful for instructing CI systems to group all of the output for a given task, such as with [GitHub Actions' `::group::` command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines) or [Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?expand=1&view=azure-devops&tabs=bash#formatting-commands). + +```yaml +version: '3' + +output: + group: + begin: '::group::{{.TASK}}' + end: '::endgroup::' + +tasks: + default: + cmds: + - echo 'Hello, World!' + silent: true +``` + +```bash +$ task default +::group::default +Hello, World! +::endgroup:: +``` + +When using the `group` output, you may swallow the output of the executed command on standard output and standard error if it does not fail (zero exit code). + +```yaml +version: '3' + +silent: true + +output: + group: + error_only: true + +tasks: + passes: echo 'output-of-passes' + errors: echo 'output-of-errors' && exit 1 +``` + +```bash +$ task passes +$ task errors +output-of-errors +task: Failed to run task "errors": exit status 1 +``` + +The `prefix` output will prefix every line printed by a command with `[task-name]` as the prefix, but you can customize the prefix for a command with the `prefix:` attribute: + + ```yaml +version: '3' + +output: prefixed + +tasks: + default: + deps: + - task: print + vars: {TEXT: foo} + - task: print + vars: {TEXT: bar} + - task: print + vars: {TEXT: baz} + + print: + cmds: + - echo "{{.TEXT}}" + prefix: "print-{{.TEXT}}" + silent: true +``` + +```bash +$ task default +[print-foo] foo +[print-bar] bar +[print-baz] baz +``` + +:::tip + + +The `output` option can also be specified by the `--output` or `-o` flags. + +::: + + +## 交互式 CLI 应用 + +When running interactive CLI applications inside Task they can sometimes behave weirdly, especially when the [output mode](#output-syntax) is set to something other than `interleaved` (the default), or when interactive apps are run in parallel with other tasks. + +The `interactive: true` tells Task this is an interactive application and Task will try to optimize for it: + +```yaml +version: '3' + +tasks: + default: + cmds: + - vim my-file.txt + interactive: true +``` + +If you still have problems running an interactive app through Task, please open an issue about it. + +## 短 Task 语法 + +Starting on Task v3, you can now write tasks with a shorter syntax if they have the default settings (e.g. no custom `env:`, `vars:`, `desc:`, `silent:` , etc): + +```yaml +version: '3' + +tasks: + build: go build -v -o ./app{{exeExt}} . + + run: + - task: build + - ./app{{exeExt}} -h localhost -p 8080 +``` + +## `set` 和 `shopt` + +It's possible to specify options to the [`set`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) and [`shopt`](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) builtins. This can be added at global, task or command level. + +```yaml +version: '3' + +set: [pipefail] +shopt: [globstar] + +tasks: + # `globstar` required for double star globs to work + default: echo **/*.go +``` + +:::info + + +Keep in mind that not all options are available in the [shell interpreter library](https://github.com/mvdan/sh) that Task uses. + +::: + + +## 观察任务 + +With the flags `--watch` or `-w` task will watch for file changes and run the task again. This requires the `sources` attribute to be given, so task knows which files to watch. + +The default watch interval is 5 seconds, but it's possible to change it by either setting `interval: '500ms'` in the root of the Taskfile passing it as an argument like `--interval=500ms`. diff --git a/docs/i18n/zh-Hans/docusaurus-theme-classic/navbar.json b/docs/i18n/zh-Hans/docusaurus-theme-classic/navbar.json index 389f4de381..6898733aad 100644 --- a/docs/i18n/zh-Hans/docusaurus-theme-classic/navbar.json +++ b/docs/i18n/zh-Hans/docusaurus-theme-classic/navbar.json @@ -12,7 +12,7 @@ "description": "Navbar item with label Usage" }, "item.label.API": { - "message": "API", + "message": "接口", "description": "Navbar item with label API" }, "item.label.Donate": {