File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import crypto from "node:crypto" ;
2+ import fs from "node:fs/promises" ;
3+ import registerGitHubApp from "./lib/register-github-app/index.js" ;
4+
5+ // register app and retrieve credentials
6+ const appCredentials = await registerGitHubApp ( {
7+ // name of your app
8+ name : "jargons.dev-app-for-" ,
9+ url : "https://github.com/babblebey/jargons.dev/CONTRIBUTING.md" ,
10+ default_permissions : {
11+ issues : "write" ,
12+ }
13+ } ) ;
14+
15+ // convert private key to pkcs8 format (recommended for better cross plattform support)
16+ const privateKeyPKCS8 = String (
17+ crypto . createPrivateKey ( appCredentials . pem ) . export ( {
18+ type : "pkcs8" ,
19+ format : "pem" ,
20+ } ) ,
21+ ) ;
22+ const singleLinePrivateKey = privateKeyPKCS8 . trim ( ) . replace ( / \n / g, "\\n" ) ;
23+
24+ // write credentials into `.env` file
25+ const envFileTemp = await fs . readFile ( ".env.example" , "utf-8" ) ;
26+ const newEnvFileContent = envFileTemp
27+ . replace ( / ^ G I T H U B _ A P P _ I D = .* $ / m, `GITHUB_APP_ID=${ appCredentials . id } ` )
28+ . replace ( / ^ G I T H U B _ A P P _ P R I V A T E _ K E Y = .* $ / m, `GITHUB_APP_PRIVATE_KEY="${ singleLinePrivateKey } "` )
29+ await fs . writeFile ( ".env" , newEnvFileContent ) ;
Original file line number Diff line number Diff line change 88 "start" : " astro dev" ,
99 "build" : " astro build" ,
1010 "preview" : " astro preview" ,
11- "astro" : " astro"
11+ "astro" : " astro" ,
12+ "setup" : " node dev/setup.js"
1213 },
1314 "keywords" : [],
1415 "author" : " " ,
You can’t perform that action at this time.
0 commit comments