๐ŸŽฎ Unity Study/Unity

[Unity] Github package npm ๋ฐฐํฌ

ibelieveinme 2023. 12. 7. 18:04
728x90

*Github Package ?

 

1. Unity package ๋งŒ๋“ค๊ธฐ

package ๋ฅผ github registry ์— publish ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” registry ๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

package ๋ฅผ registry ์— ์—ฐ๊ฒฐํ•˜๋Š” ๋ฒ•์€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

๋‚˜๋Š” unity ํ”„๋กœ์ ํŠธ ์ด๋ฏ€๋กœ Unity Package Manager ๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” package.json ํŒŒ์ผ์„ ์ด์šฉํ–ˆ๋‹ค.

package.json ํŒŒ์ผ ์•ˆ์— publishConfig ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ package ๋ฅผ registry ๋ฅผ ์—ฐ๊ฒฐํ•˜๋ฉด ๋œ๋‹ค.

"publishConfig": {
  "registry": "https://npm.pkg.github.com"
},

 

[package ๋งŒ๋“ค ๋•Œ ์ฃผ์˜์‚ฌํ•ญ]

1) package ์ด๋ฆ„(name)๊ณผ ๋ฒ”์œ„์—๋Š” ์†Œ๋ฌธ์ž๋งŒ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

2) npm ๋ฒ„์ „์˜ tarball ํฌ๊ธฐ๋Š” 256MB ๋ณด๋‹ค ์ž‘์•„์•ผ ํ•œ๋‹ค.

 

์ƒ์„ธ ๋‚ด์šฉ์€ ํ•˜๋‹จ ๊ฒŒ์‹œ๊ธ€ ์ฐธ๊ณ .

 

[Unity] Custom Unity Package in Git ๋งน๋“ค๊ธฐ

ํšŒ์‚ฌ์—์„œ ํ”„๋กœ์ ํŠธ ๊ฐœ๋ฐœ์‹œ ํ•„์š”ํ•œ ๊ณตํ†ต๋ชจ๋“ˆ์„ ๊ฐ๊ฐ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” Editor ํ™”๋ฉด์„ ํ•˜๋‚˜ ๋งŒ๋“ค๊ณ  ์žˆ๋‹ค. ๋‹คํ–‰ํžˆ Unity ์—์„œ Git ์ €์žฅ์†Œ ์ •๋ณด๋ฅผ package.json ํŒŒ์ผ ์•ˆ์— ๋‹ด์•„์„œ ๊ทธ ํŒŒ์ผ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ •๋ณด๋ฅผ

i-believe-in-me.tistory.com

 

 

2. personal access token(classic) ์ธ์ฆํŒŒ์ผ ๋งŒ๋“ค๊ธฐ

github token(classic) ์„ ๋ฐ›์•„์„œ .npmrc ํŒŒ์ผ์„ ๋งŒ๋“ ๋‹ค.

//npm.pkg.github.com/:_authToken=TOKEN

always-auth ์กฐ๊ฑด ์ถ”๊ฐ€๋„ ๊ฐ€๋Šฅ!

 

 

3. npm Login

$ npm login --scope=@NAMESPACE --auth-type=legacy --registry=https://npm.pkg.github.com

username ๊ณผ password(personal access token(classic)) ์ž…๋ ฅํ•˜๋ฉด ๋กœ๊ทธ์ธ ์„ฑ๊ณต.

 

 

4. package publish

$ npm publish

npm publish ์„ฑ๊ณต.

 

 

6. Github ์˜ Package ํƒญ์—์„œ npm package ํ™•์ธ


 

npm ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ์ž‘์—… - GitHub Docs

ํŒจํ‚ค์ง€๋ฅผ GitHub Packages์— ๊ฒŒ์‹œํ•˜๊ณ  GitHub Packages์— ์ €์žฅ๋œ ํŒจํ‚ค์ง€๋ฅผ npm ํ”„๋กœ์ ํŠธ์˜ ์ข…์†์„ฑ์œผ๋กœ ์‚ฌ์šฉํ•˜๋„๋ก npm์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Free for organiz

docs.github.com

 

Github packages ๋กœ npm ํŒจํ‚ค์ง€ ๋ฐฐํฌ

์—ฌ๋Ÿฌ ํ”„๋กœ์ ํŠธ์—์„œ ๋ฐ˜๋ณต์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ๊ณตํ†ต๋ชจ๋“ˆ์ด ์žˆ๋‹ค๋ฉด Don't repeat your code ์›์น™์— ๋”ฐ๋ผ npm ๋ชจ๋“ˆ๋กœ ๋ฐฐํฌํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์–ด์ง„๋‹ค. npmjs ๋ฅผ ํ†ตํ•ด ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค๊ณ  ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ์ง€๋งŒ npmjs ๋Š” ๋น„๊ณต

min9nim.vercel.app

728x90