mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["7390"],{46597:function(e,t,n){n.r(t),n.d(t,{frontMatter:()=>l,default:()=>m,contentTitle:()=>d,assets:()=>c,toc:()=>u,metadata:()=>r});var r=JSON.parse('{"id":"migration/v2/migration-automated","title":"Automated migration","description":"The migration CLI automatically migrates your v1 website to a v2 website.","source":"@site/docs/migration/v2/migration-automated.mdx","sourceDirName":"migration/v2","slug":"/migration/v2/automated","permalink":"/docs/migration/v2/automated","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/migration/v2/migration-automated.mdx","tags":[],"version":"current","lastUpdatedBy":"dependabot[bot]","lastUpdatedAt":1744702265000,"frontMatter":{"slug":"/migration/v2/automated"},"sidebar":"docs","previous":{"title":"Overview","permalink":"/docs/migration/v2"},"next":{"title":"Manual migration","permalink":"/docs/migration/v2/manual"}}'),a=n(85893),i=n(80980),s=n(15398),o=n(58636);let l={slug:"/migration/v2/automated"},d="Automated migration",c={},u=[{value:"Options",id:"options",level:4}];function h(e){let t={admonition:"admonition",code:"code",h1:"h1",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.header,{children:(0,a.jsx)(t.h1,{id:"automated-migration",children:"Automated migration"})}),"\n",(0,a.jsx)(t.p,{children:"The migration CLI automatically migrates your v1 website to a v2 website."}),"\n",(0,a.jsx)(t.admonition,{type:"info",children:(0,a.jsx)(t.p,{children:"Manual work is still required after using the migration CLI, as we can't automate a full migration"})}),"\n",(0,a.jsx)(t.p,{children:"The migration CLI migrates:"}),"\n",(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsxs)(t.li,{children:["Site configurations (from ",(0,a.jsx)(t.code,{children:"siteConfig.js"})," to ",(0,a.jsx)(t.code,{children:"docusaurus.config.js"}),")"]}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"package.json"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"sidebars.json"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"/docs"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"/blog"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"/static"})}),"\n",(0,a.jsxs)(t.li,{children:[(0,a.jsx)(t.code,{children:"versioned_sidebar.json"})," and ",(0,a.jsx)(t.code,{children:"/versioned_docs"})," if your site uses versioning"]}),"\n"]}),"\n",(0,a.jsx)(t.p,{children:"To use the migration CLI, follow these steps:"}),"\n",(0,a.jsxs)(t.ol,{children:["\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsxs)(t.p,{children:["Before using the migration CLI, ensure that ",(0,a.jsx)(t.code,{children:"/docs"}),", ",(0,a.jsx)(t.code,{children:"/blog"}),", ",(0,a.jsx)(t.code,{children:"/static"}),", ",(0,a.jsx)(t.code,{children:"sidebars.json"}),", ",(0,a.jsx)(t.code,{children:"siteConfig.js"}),", ",(0,a.jsx)(t.code,{children:"package.json"})," follow the expected structure."]}),"\n"]}),"\n",(0,a.jsxs)(t.li,{children:["\n",(0,a.jsx)(t.p,{children:"To migrate your v1 website, run the migration CLI with the appropriate filesystem paths:"}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"# migration command format\nnpx @docusaurus/migrate migrate <v1 website directory> <desired v2 website directory>\n\n# example\nnpx @docusaurus/migrate migrate ./v1-website ./v2-website\n"})}),"\n",(0,a.jsxs)(t.ol,{start:"3",children:["\n",(0,a.jsx)(t.li,{children:"To view your new website locally, go into your v2 website's directory and start your development server."}),"\n"]}),"\n",(0,a.jsxs)(s.Z,{groupId:"npm2yarn",children:[(0,a.jsx)(o.Z,{value:"npm",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"cd ./v2-website\nnpm install\nnpm start\n"})})}),(0,a.jsx)(o.Z,{value:"yarn",label:"Yarn",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"cd ./v2-website\nyarn install\nyarn start\n"})})}),(0,a.jsx)(o.Z,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"cd ./v2-website\npnpm install\npnpm start\n"})})}),(0,a.jsx)(o.Z,{value:"bun",label:"Bun",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"cd ./v2-website\nbun install\nbun start\n"})})})]}),"\n",(0,a.jsx)(t.admonition,{type:"danger",children:(0,a.jsx)(t.p,{children:"The migration CLI updates existing files. Be sure to have committed them first!"})}),"\n",(0,a.jsx)(t.h4,{id:"options",children:"Options"}),"\n",(0,a.jsx)(t.p,{children:"You can add option flags to the migration CLI to automatically migrate Markdown content and pages to v2. It is likely that you will still need to make some manual changes to achieve your desired result."}),"\n",(0,a.jsxs)(t.table,{children:[(0,a.jsx)(t.thead,{children:(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.th,{children:"Name"}),(0,a.jsx)(t.th,{children:"Description"})]})}),(0,a.jsxs)(t.tbody,{children:[(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.td,{children:(0,a.jsx)(t.code,{children:"--mdx"})}),(0,a.jsx)(t.td,{children:"Add this flag to convert Markdown to MDX automatically"})]}),(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.td,{children:(0,a.jsx)(t.code,{children:"--page"})}),(0,a.jsx)(t.td,{children:"Add this flag to migrate pages automatically"})]})]})]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"# example using options\nnpx @docusaurus/migrate migrate --mdx --page ./v1-website ./v2-website\n"})}),"\n",(0,a.jsxs)(t.admonition,{type:"danger",children:[(0,a.jsx)(t.p,{children:"The migration of pages and MDX is still a work in progress."}),(0,a.jsxs)(t.p,{children:["We recommend you to try to run the pages without these options, commit, and then try to run the migration again with the ",(0,a.jsx)(t.code,{children:"--page"})," and ",(0,a.jsx)(t.code,{children:"--mdx"})," options."]}),(0,a.jsx)(t.p,{children:"This way, you'd be able to easily inspect and fix the diff."})]})]})}function m(e={}){let{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(h,{...e})}):h(e)}},58636:function(e,t,n){n.d(t,{Z:()=>i});var r=n(85893);n(67294);var a=n(90496);function i(e){let{children:t,hidden:n,className:i}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,a.Z)("tabItem_pnkT",i),hidden:n,children:t})}},15398:function(e,t,n){n.d(t,{Z:()=>f});var r=n(85893),a=n(67294),i=n(90496),s=n(54947),o=n(3620),l=n(844),d=n(97486),c=n(32263),u=n(16971);function h(e){return a.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,a.isValidElement)(e)&&function(e){let{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(e))return e;throw Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function m(e){let{value:t,tabValues:n}=e;return n.some(e=>e.value===t)}var p=n(71607);function x(e){let{className:t,block:n,selectedValue:a,selectValue:o,tabValues:l}=e,d=[],{blockElementScrollPositionUntilNextRender:c}=(0,s.o5)(),u=e=>{let t=e.currentTarget,n=l[d.indexOf(t)].value;n!==a&&(c(t),o(n))},h=e=>{let t=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{let n=d.indexOf(e.currentTarget)+1;t=d[n]??d[0];break}case"ArrowLeft":{let n=d.indexOf(e.currentTarget)-1;t=d[n]??d[d.length-1]}}t?.focus()};return(0,r.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,i.Z)("tabs",{"tabs--block":n},t),children:l.map(e=>{let{value:t,label:n,attributes:s}=e;return(0,r.jsx)("li",{role:"tab",tabIndex:a===t?0:-1,"aria-selected":a===t,ref:e=>{d.push(e)},onKeyDown:h,onClick:u,...s,className:(0,i.Z)("tabs__item","tabItem_AQgk",s?.className,{"tabs__item--active":a===t}),children:n??t},t)})})}function g(e){let{lazy:t,children:n,selectedValue:s}=e,o=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){let e=o.find(e=>e.props.value===s);return e?(0,a.cloneElement)(e,{className:(0,i.Z)("margin-top--md",e.props.className)}):null}return(0,r.jsx)("div",{className:"margin-top--md",children:o.map((e,t)=>(0,a.cloneElement)(e,{key:t,hidden:e.props.value!==s}))})}function j(e){let t=function(e){let{defaultValue:t,queryString:n=!1,groupId:r}=e,i=function(e){let{values:t,children:n}=e;return(0,a.useMemo)(()=>{let e=t??h(n).map(e=>{let{props:{value:t,label:n,attributes:r,default:a}}=e;return{value:t,label:n,attributes:r,default:a}}),r=(0,c.lx)(e,(e,t)=>e.value===t.value);if(r.length>0)throw Error(`Docusaurus error: Duplicate values "${r.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[t,n])}(e),[s,p]=(0,a.useState)(()=>(function(e){let{defaultValue:t,tabValues:n}=e;if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(t){if(!m({value:t,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${t}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return t}let r=n.find(e=>e.default)??n[0];if(!r)throw Error("Unexpected error: 0 tabValues");return r.value})({defaultValue:t,tabValues:i})),[x,g]=function(e){let{queryString:t=!1,groupId:n}=e,r=(0,o.k6)(),i=function(e){let{queryString:t=!1,groupId:n}=e;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!n)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:t,groupId:n});return[(0,d._X)(i),(0,a.useCallback)(e=>{if(!i)return;let t=new URLSearchParams(r.location.search);t.set(i,e),r.replace({...r.location,search:t.toString()})},[i,r])]}({queryString:n,groupId:r}),[j,f]=function(e){let{groupId:t}=e,n=t?`docusaurus.tab.${t}`:null,[r,i]=(0,u.Nk)(n);return[r,(0,a.useCallback)(e=>{n&&i.set(e)},[n,i])]}({groupId:r}),b=(()=>{let e=x??j;return m({value:e,tabValues:i})?e:null})();return(0,l.Z)(()=>{b&&p(b)},[b]),{selectedValue:s,selectValue:(0,a.useCallback)(e=>{if(!m({value:e,tabValues:i}))throw Error(`Can't select invalid tab value=${e}`);p(e),g(e),f(e)},[g,f,i]),tabValues:i}}(e);return(0,r.jsxs)("div",{className:(0,i.Z)("tabs-container","tabList_Qoir"),children:[(0,r.jsx)(x,{...t,...e}),(0,r.jsx)(g,{...t,...e})]})}function f(e){let t=(0,p.Z)();return(0,r.jsx)(j,{...e,children:h(e.children)},String(t))}},80980:function(e,t,n){n.d(t,{Z:()=>o,a:()=>s});var r=n(67294);let a={},i=r.createContext(a);function s(e){let t=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),r.createElement(i.Provider,{value:t},e.children)}}}]); |