PageSourceSearch

https://oclif.io/assets/js/56cc2276.50228925.js

js oclif.io collected 2026-10-02 05:28:46 UTC 6,031 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[2623],{1462(e,n,i){i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>r,default:()=>p,frontMatter:()=>t,metadata:()=>s,toc:()=>a});var o=i(4848),c=i(8453);const t={title:"Introducing `oclif init` command"},r=void 0,s={permalink:"/blog/2024/04/10/oclif-init",source:"@site/blog/2024-04-10-oclif-init.md",title:"Introducing `oclif init` command",description:"Thanks to the contribution of @joshcanhelp we released a new command for the oclif CLI called oclif init in version 4.8.0",date:"2024-04-10T00:00:00.000Z",tags:[],readingTime:1.795,hasTruncateMarker:!1,authors:[],frontMatter:{title:"Introducing `oclif init` command"},unlisted:!1,nextItem:{title:"oclif Spring 2024 Update",permalink:"/blog/2024/03/29/spring-update"}},l={authorsImageUrls:[]},a=[];function d(e){const n={a:"a",code:"code",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,c.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:["Thanks to the contribution of ",(0,o.jsx)(n.a,{href:"https://github.com/joshcanhelp",children:"@joshcanhelp"})," we released a new command for the ",(0,o.jsx)(n.code,{children:"oclif"})," CLI called ",(0,o.jsx)(n.code,{children:"oclif init"})," in version ",(0,o.jsx)(n.a,{href:"https://github.com/oclif/oclif/releases/tag/4.8.0",children:"4.8.0"})]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"oclif init"})," command allows you to initialize oclif in an existing project directory by adding the bare minimum requirements: a few pieces of configuration, bin scripts, and a couple of dependencies (",(0,o.jsx)(n.code,{children:"@oclif/core"})," and ",(0,o.jsx)(n.code,{children:"ts-node"}),"). This is slightly different from ",(0,o.jsx)(n.code,{children:"oclif generate"}),", which will create an entirely new oclif project based on our ",(0,o.jsx)(n.a,{href:"/docs/templates",children:"templates"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"oclif init"})," will add the following:"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["bin scripts: ",(0,o.jsx)(n.code,{children:"bin/run.js"}),", ",(0,o.jsx)(n.code,{children:"bin/run.cmd"}),", ",(0,o.jsx)(n.code,{children:"bin/dev.js"}),", and ",(0,o.jsx)(n.code,{children:"bin/dev.cmd"})]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"oclif"})," section to package.json with ",(0,o.jsx)(n.code,{children:"bin"}),", ",(0,o.jsx)(n.code,{children:"dirname"}),", ",(0,o.jsx)(n.code,{children:"commands"}),", and ",(0,o.jsx)(n.code,{children:"topicSeparator"})," set (See ",(0,o.jsx)(n.a,{href:"/docs/configuring_your_cli",children:"Configuring Your CLI"})," for more)"]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"@oclif/core"})," to ",(0,o.jsx)(n.code,{children:"dependencies"})," in your package.json (if it's not already there)"]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"ts-node"})," to ",(0,o.jsx)(n.code,{children:"devDependencies"})," in your package.json (if it's not already there)"]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["Once you've initialized oclif, you can use the ",(0,o.jsx)(n.a,{href:"/docs/templates#bin-scripts",children:"bin scripts"})," to execute your CLI. You can also use the other ",(0,o.jsx)(n.code,{children:"oclif"})," commands like ",(0,o.jsx)(n.code,{children:"oclif generate command"})," and ",(0,o.jsx)(n.code,{children:"oclif generate hook"})," to start adding new functionality."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{alt:"oclif init demo",src:i(866).A+"",width:"910",height:"472"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:'\u276f oclif init --help\nInitialize a new oclif CLI\n\nUSAGE\n  $ oclif init [--bin <value>] [--module-type ESM|CommonJS] [--package-manager npm|yarn|pnpm] [--topic-separator\n    colons|spaces] [-d <value>] [-y]\n\nFLAGS\n  -d, --output-dir=<value>        Directory to initialize the CLI in.\n  -y, --yes                       Use defaults for all prompts. Individual flags will override defaults.\n      --bin=<value>               Supply answer for prompt: Command bin name the CLI will export\n      --module-type=<option>      Supply answer for prompt: Select a module type\n                                  <options: ESM|CommonJS>\n      --package-manager=<option>  Supply answer for prompt: Select a package manager\n                                  <options: npm|yarn|pnpm>\n      --topic-separator=<option>  Supply answer for prompt: Select a topic separator\n                                  <options: colons|spaces>\n\nDESCRIPTION\n  Initialize a new oclif CLI\n\n  This will add the necessary oclif bin files, add oclif config to package.json, and install @oclif/core and ts-node.\n\nEXAMPLES\n  Initialize a new CLI in the current directory\n\n    $ oclif init\n\n  Initialize a new CLI in a different directory\n\n    $ oclif init --output-dir "/path/to/existing/project"\n\n  Supply answers for specific prompts\n\n    $ oclif init --topic-separator colons --bin mycli\n'})}),"\n",(0,o.jsxs)(n.p,{children:["Hope you enjoy the new command! If you come across any issues or have any new ideas for this command, head over to the ",(0,o.jsx)(n.a,{href:"https://github.com/oclif/oclif",children:"oclif/oclif"})," repo and open a new issue."]}),"\n",(0,o.jsx)(n.p,{children:"All our best,"}),"\n",(0,o.jsx)(n.p,{children:"The oclif team"})]})}function p(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},866(e,n,i){i.d(n,{A:()=>o});const o=i.p+"assets/images/oclif-init-demo-54fb354decdef35abf2863a02087255a.gif"},8453(e,n,i){i.d(n,{R:()=>r,x:()=>s});var o=i(6540);const c={},t=o.createContext(c);function r(e){const n=o.useContext(t);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:r(e.components),o.createElement(t.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.