1
0
mirror of https://github.com/go-task/task.git synced 2025-03-21 21:27:07 +02:00
task/assets/js/0afd354a.d66f7d0f.js

1 line
12 KiB
JavaScript

"use strict";(self.webpackChunktaskfile_dev=self.webpackChunktaskfile_dev||[]).push([[552],{3905:function(e,n,t){t.d(n,{Zo:function(){return u},kt:function(){return k}});var a=t(7294);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function o(e,n){if(null==e)return{};var t,a,r=function(e,n){if(null==e)return{};var t,a,r={},l=Object.keys(e);for(a=0;a<l.length;a++)t=l[a],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)t=l[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=a.createContext({}),p=function(e){var n=a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},u=function(e){var n=p(e.components);return a.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},d=a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,l=e.originalType,s=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),d=p(t),k=r,m=d["".concat(s,".").concat(k)]||d[k]||c[k]||l;return t?a.createElement(m,i(i({ref:n},u),{},{components:t})):a.createElement(m,i({ref:n},u))}));function k(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var l=t.length,i=new Array(l);i[0]=d;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:r,i[1]=o;for(var p=2;p<l;p++)i[p]=t[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,t)}d.displayName="MDXCreateElement"},2926:function(e,n,t){t.r(n),t.d(n,{assets:function(){return u},contentTitle:function(){return s},default:function(){return k},frontMatter:function(){return o},metadata:function(){return p},toc:function(){return c}});var a=t(7462),r=t(3366),l=(t(7294),t(3905)),i=["components"],o={slug:"/taskfile-versions/",sidebar_position:9},s="Taskfile Versions",p={unversionedId:"taskfile_versions",id:"taskfile_versions",title:"Taskfile Versions",description:"The Taskfile syntax and features changed with time. This document explains what",source:"@site/docs/taskfile_versions.md",sourceDirName:".",slug:"/taskfile-versions/",permalink:"/taskfile-versions/",draft:!1,tags:[],version:"current",sidebarPosition:9,frontMatter:{slug:"/taskfile-versions/",sidebar_position:9},sidebar:"tutorialSidebar",previous:{title:"Releasing",permalink:"/releasing/"},next:{title:"Donate",permalink:"/donate/"}},u={},c=[{value:"What the Taskfile version mean",id:"what-the-taskfile-version-mean",level:2},{value:"Version 1",id:"version-1",level:2},{value:"Version 2.0",id:"version-20",level:2},{value:"Version 2.1",id:"version-21",level:2},{value:"Version 2.2",id:"version-22",level:2},{value:"Version 2.6",id:"version-26",level:2},{value:"Version 3",id:"version-3",level:2}],d={toc:c};function k(e){var n=e.components,t=(0,r.Z)(e,i);return(0,l.kt)("wrapper",(0,a.Z)({},d,t,{components:n,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"taskfile-versions"},"Taskfile Versions"),(0,l.kt)("p",null,"The Taskfile syntax and features changed with time. This document explains what\nchanged on each version and how to upgrade your Taskfile."),(0,l.kt)("h2",{id:"what-the-taskfile-version-mean"},"What the Taskfile version mean"),(0,l.kt)("p",null,"The Taskfile version follows the Task version. E.g. the change to Taskfile\nversion ",(0,l.kt)("inlineCode",{parentName:"p"},"2")," means that Task ",(0,l.kt)("inlineCode",{parentName:"p"},"v2.0.0")," should be release to support it."),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"version:")," key on Taskfile accepts a semver string, so either ",(0,l.kt)("inlineCode",{parentName:"p"},"2"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"2.0")," or\n",(0,l.kt)("inlineCode",{parentName:"p"},"2.0.0")," is accepted. If you choose to use ",(0,l.kt)("inlineCode",{parentName:"p"},"2.0")," Task will not enable future\n",(0,l.kt)("inlineCode",{parentName:"p"},"2.1")," features, but if you choose to use ",(0,l.kt)("inlineCode",{parentName:"p"},"2"),", then any ",(0,l.kt)("inlineCode",{parentName:"p"},"2.x.x")," features will be\navailable, but not ",(0,l.kt)("inlineCode",{parentName:"p"},"3.0.0+"),"."),(0,l.kt)("h2",{id:"version-1"},"Version 1"),(0,l.kt)("blockquote",null,(0,l.kt)("p",{parentName:"blockquote"},"NOTE: Taskfiles in version 1 are not supported on Task >= v3.0.0 anymore.")),(0,l.kt)("p",null,"In the first version of the ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile"),", the ",(0,l.kt)("inlineCode",{parentName:"p"},"version:")," key was not available,\nbecause the tasks was in the root of the YAML document. Like this:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'echo:\n cmds:\n - echo "Hello, World!"\n')),(0,l.kt)("p",null,"The variable priority order was also different:"),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},"Call variables"),(0,l.kt)("li",{parentName:"ol"},"Environment"),(0,l.kt)("li",{parentName:"ol"},"Task variables"),(0,l.kt)("li",{parentName:"ol"},(0,l.kt)("inlineCode",{parentName:"li"},"Taskvars.yml")," variables")),(0,l.kt)("h2",{id:"version-20"},"Version 2.0"),(0,l.kt)("p",null,"At version 2, we introduced the ",(0,l.kt)("inlineCode",{parentName:"p"},"version:")," key, to allow us to evolve Task\nwith new features without breaking existing Taskfiles. The new syntax is as\nfollows:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '2'\n\ntasks:\n echo:\n cmds:\n - echo \"Hello, World!\"\n")),(0,l.kt)("p",null,"Version 2 allows you to write global variables directly in the Taskfile,\nif you don't want to create a ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskvars.yml"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '2'\n\nvars:\n GREETING: Hello, World!\n\ntasks:\n greet:\n cmds:\n - echo \"{{.GREETING}}\"\n")),(0,l.kt)("p",null,"The variable priority order changed to the following:"),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},"Task variables"),(0,l.kt)("li",{parentName:"ol"},"Call variables"),(0,l.kt)("li",{parentName:"ol"},"Taskfile variables"),(0,l.kt)("li",{parentName:"ol"},"Taskvars file variables"),(0,l.kt)("li",{parentName:"ol"},"Environment variables")),(0,l.kt)("p",null,"A new global option was added to configure the number of variables expansions\n(which default to 2):"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'2\'\n\nexpansions: 3\n\nvars:\n FOO: foo\n BAR: bar\n BAZ: baz\n FOOBAR: "{{.FOO}}{{.BAR}}"\n FOOBARBAZ: "{{.FOOBAR}}{{.BAZ}}"\n\ntasks:\n default:\n cmds:\n - echo "{{.FOOBARBAZ}}"\n')),(0,l.kt)("h2",{id:"version-21"},"Version 2.1"),(0,l.kt)("p",null,"Version 2.1 includes a global ",(0,l.kt)("inlineCode",{parentName:"p"},"output")," option, to allow having more control\nover how commands output are printed to the console\n(see ",(0,l.kt)("a",{parentName:"p",href:"/usage/#output-syntax"},"documentation")," for more info):"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '2'\n\noutput: prefixed\n\ntasks:\n server:\n cmds:\n - go run main.go\n prefix: server\n")),(0,l.kt)("p",null,"From this version it's also possible to ignore errors of a command or task\n(check documentation ",(0,l.kt)("a",{parentName:"p",href:"/usage/#ignore-errors"},"here"),"):"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'2\'\n\ntasks:\n example-1:\n cmds:\n - cmd: exit 1\n ignore_error: true\n - echo "This will be print"\n\n example-2:\n cmds:\n - exit 1\n - echo "This will be print"\n ignore_error: true\n')),(0,l.kt)("h2",{id:"version-22"},"Version 2.2"),(0,l.kt)("p",null,"Version 2.2 comes with a global ",(0,l.kt)("inlineCode",{parentName:"p"},"includes")," options to include other\nTaskfiles:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '2'\n\nincludes:\n docs: ./documentation # will look for ./documentation/Taskfile.yml\n docker: ./DockerTasks.yml\n")),(0,l.kt)("h2",{id:"version-26"},"Version 2.6"),(0,l.kt)("p",null,"Version 2.6 comes with ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," stanza in tasks."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '2'\n\ntasks:\n upload_environment:\n preconditions:\n - test -f .env\n cmds:\n - aws s3 cp .env s3://myenvironment\n")),(0,l.kt)("p",null,"Please check the ",(0,l.kt)("a",{parentName:"p",href:"/usage/#including-other-taskfiles"},"documentation")),(0,l.kt)("h2",{id:"version-3"},"Version 3"),(0,l.kt)("p",null,"These are some major changes done on ",(0,l.kt)("inlineCode",{parentName:"p"},"v3"),":"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Task's output will now be colored"),(0,l.kt)("li",{parentName:"ul"},"Added support for ",(0,l.kt)("inlineCode",{parentName:"li"},".env")," like files"),(0,l.kt)("li",{parentName:"ul"},"Added ",(0,l.kt)("inlineCode",{parentName:"li"},"label:")," setting to task so one can override how the task name\nappear in the logs"),(0,l.kt)("li",{parentName:"ul"},"A global ",(0,l.kt)("inlineCode",{parentName:"li"},"method:")," was added to allow setting the default method,\nand Task's default changed to ",(0,l.kt)("inlineCode",{parentName:"li"},"checksum")),(0,l.kt)("li",{parentName:"ul"},"Two magic variables were added when using ",(0,l.kt)("inlineCode",{parentName:"li"},"status:"),": ",(0,l.kt)("inlineCode",{parentName:"li"},"CHECKSUM")," and\n",(0,l.kt)("inlineCode",{parentName:"li"},"TIMESTAMP")," which contains, respectively, the md5 checksum and greatest\nmodification timestamp of the files listed on ",(0,l.kt)("inlineCode",{parentName:"li"},"sources:")),(0,l.kt)("li",{parentName:"ul"},"Also, the ",(0,l.kt)("inlineCode",{parentName:"li"},"TASK")," variable is always available with the current task name"),(0,l.kt)("li",{parentName:"ul"},"CLI variables are always treated as global variables"),(0,l.kt)("li",{parentName:"ul"},"Added ",(0,l.kt)("inlineCode",{parentName:"li"},"dir:")," option to ",(0,l.kt)("inlineCode",{parentName:"li"},"includes")," to allow choosing on which directory an\nincluded Taskfile will run:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"includes:\n docs:\n taskfile: ./docs\n dir: ./docs\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Implemented short task syntax. All below syntaxes are equivalent:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print:\n cmds:\n - echo \"Hello, World!\"\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print:\n - echo \"Hello, World!\"\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print: echo \"Hello, World!\"\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"There was a major refactor on how variables are handled. They're now easier\nto understand. The ",(0,l.kt)("inlineCode",{parentName:"li"},"expansions:")," setting was removed as it became unncessary.\nThis is the order in which Task will process variables, each level can see\nthe variables set by the previous one and override those.",(0,l.kt)("ul",{parentName:"li"},(0,l.kt)("li",{parentName:"ul"},"Environment variables"),(0,l.kt)("li",{parentName:"ul"},"Global + CLI variables"),(0,l.kt)("li",{parentName:"ul"},"Call variables"),(0,l.kt)("li",{parentName:"ul"},"Task variables")))))}k.isMDXComponent=!0}}]);