1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["2806"],{3416(e,t,n){n.r(t),n.d(t,{metadata:()=>s,default:()=>p,frontMatter:()=>i,contentTitle:()=>c,toc:()=>l,assets:()=>a});var s=JSON.parse('{"id":"quick-starts/custom/index","title":"Custom Project Installation","description":"This quick start will help you install a pre-created custom project.","source":"@site/../docs/quick-starts/custom/index.md","sourceDirName":"quick-starts/custom","slug":"/quick-starts/custom/","permalink":"/docs/quick-starts/custom/","draft":false,"unlisted":false,"editUrl":"https://github.com/projen/projen/tree/main/docusaurus/../docs/quick-starts/custom/index.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{"sidebar_position":5},"sidebar":"docsSidebar","previous":{"title":"Create a Spring Boot Application","permalink":"/docs/quick-starts/java/spring-boot/"},"next":{"title":"Constructs","permalink":"/docs/concepts/components"}}'),r=n(4848),o=n(8453);let i={sidebar_position:5},c="Custom Project Installation",a={},l=[{value:"Project Type",id:"project-type",level:2},{value:"Package",id:"package",level:2},{value:"Example",id:"example",level:2}];function d(e){let t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"custom-project-installation",children:"Custom Project Installation"})}),"\n",(0,r.jsxs)(t.p,{children:["This quick start will help you install a pre-created ",(0,r.jsx)(t.a,{href:"/docs/custom/custom-projects",children:"custom project"}),".\nIt's not always clear what project type to pass in if the project's README does not explicitly\ntell you."]}),"\n",(0,r.jsx)(t.p,{children:"The basic format to install a custom project is as follows:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-shell",children:"pnpm dlx projen new $PROJECT_TYPE --from $PACKAGE\n"})}),"\n",(0,r.jsx)(t.h2,{id:"project-type",children:"Project Type"}),"\n",(0,r.jsxs)(t.p,{children:["The ",(0,r.jsx)(t.code,{children:"$PROJECT_TYPE"})," is the type of project you want to create. Using projen's default projects\nas examples, if you want to create a TypeScript project, you would pass in ",(0,r.jsx)(t.code,{children:"typescript"}),". If\nyou want to create a Python project, you would pass in ",(0,r.jsx)(t.code,{children:"python"}),"."]}),"\n",(0,r.jsxs)(t.p,{children:["The name of the project is typically the name of the exported class, minus the suffix ",(0,r.jsx)(t.code,{children:"Project"}),".\nFor example, if the project's README says to install a ",(0,r.jsx)(t.code,{children:"CustomProject"})," project, you would pass\nin ",(0,r.jsx)(t.code,{children:"custom"})," as the ",(0,r.jsx)(t.code,{children:"$PROJECT_TYPE"}),". Projen's CLI is generally very good about identifying\nmis-typed ",(0,r.jsx)(t.code,{children:"$PROJECT_TYPE"}),"s, so if you get it wrong, it will tell you."]}),"\n",(0,r.jsx)(t.h2,{id:"package",children:"Package"}),"\n",(0,r.jsxs)(t.p,{children:["The ",(0,r.jsx)(t.code,{children:"$PACKAGE"})," is the name of the package that contains the project you want to install. This\nparameter supports anything that your installer supports. Examples can be found\n",(0,r.jsx)(t.a,{href:"https://docs.npmjs.com/cli/v10/commands/npm-install?v=true",children:"in the npmjs docs"}),". ",(0,r.jsx)(t.code,{children:"yarn"}),", ",(0,r.jsx)(t.code,{children:"pnpm"}),",\nand other package managers generally maintain backwards compatibility with ",(0,r.jsx)(t.code,{children:"npm"}),", so you can\nuse the same syntax."]}),"\n",(0,r.jsx)(t.h2,{id:"example",children:"Example"}),"\n",(0,r.jsxs)(t.p,{children:["Let's look at a specific example. There is a\n",(0,r.jsx)(t.a,{href:"https://github.com/cdktn-io/cdktn-provider-project",children:"custom project for creating CDKTN providers"}),".\nTo install it, we would use the following command:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-shell",children:"pnpm dlx projen new cdktn_provider --from @cdktn/provider-project\n"})}),"\n",(0,r.jsxs)(t.p,{children:["We would infer that it's ",(0,r.jsx)(t.code,{children:"cdktnprovider"}
1)," because the name of the exported class in ",(0,r.jsx)(t.code,{children:"src/main.ts"}),"\nis ",(0,r.jsx)(t.code,{children:"CdkTnProviderProject"}),". However, when we try installing that, we get an error:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-shell",children:'\u{1F47E} Project type "cdktnprovider" not found in "@cdktn/provider-project". Found:\n\n cdktn_provider\n\nPlease specify a valid project type.\nExample: pnpm dlx projen new --from @cdktn/provider-project cdktn_provider\n'})}),"\n",(0,r.jsx)(t.p,{children:"In this case the error message is very helpful. It tells us the project type and we can easily\nadjust. When we execute the correct command, we get the following output:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-shell",children:'\u276F pnpm dlx projen new cdktn_provider --from @cdktn/provider-project\nblank@ /Users/admin/cdktn-provider-project\n\u2514\u2500\u2500 [email protected]\n\n\u{1F47E} installing external module @cdktn/provider-project...\n\nup to date, audited 89 packages in 399ms\n\n9 packages are looking for funding\n run `npm fund` for details\n\nfound 0 vulnerabilities\n\n\u{1F47E}
1 Cannot create "@cdktn/provider-project.CdktnProviderProject". Missing required options:\n --cdktn-version [string]\n --constructs-version [string]\n --terraform-provider [string]\n'})}),"\n",(0,r.jsx)(t.p,{children:"Here the error message is helpful again. There are required options that must be passed in via\nthe command line. It tells us the options and the syntax to pass them. We can now install the\nproject with the following command:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-shell",children:"pnpm dlx projen new cdktn_provider --from @cdktn/provider-project \\\n--cdktn-version 0.24.0 \\\n--constructs-version 10.7.0 \\\n--terraform-provider [email protected]\n"})}),"\n",(0,r.jsx)(t.p,{children:"This command will execute successfully."}),"\n",(0,r.jsxs)(t.p,{children:["Why did we have to pass in those options? This project is designed to be built from a\n",(0,r.jsx)(t.code,{children:".projenrc"})," file first, with those required variables set. When we use the ",(0,r.jsx)(t.code,{children:"--from"})," flag to\ninitialize the project, those required variables must be passed in via the command line instead\nof the ",(0,r.jsx)(t.code,{children:".projenrc"})," file."]})]})}function p(e={}){let{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},8453(e,t,n){n.d(t,{R:()=>i,x:()=>c});var s=n(6540);let r={},o=s.createContext(r);function i(e){let t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(o.Provider,{value:t},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.