#lets make a thread

1 messages · Page 1 of 1 (latest)

summer osprey
#

its not a help forum thing so this is probably best

real spindle
#

aight

summer osprey
#

so first off… you are comfortable with github workflows yeah?

real spindle
#

i would not say comfortable per-say. I have used them in the past for CI but i usually copy and pasted. never looked too deep into them but im sure i could figure it out

summer osprey
#

make an example org so you can wrap your head around it first

#

make 3 repos

#

ui, db, and core

real spindle
#

wait what is core?

summer osprey
#

the “shared code”

real spindle
#

my use case is i have

backend
nextjs

ui/database stuff

summer osprey
#

name em whatever you want. backend = db, nextjs = ui, and ui/database = core in my example

real spindle
#

right alright

#

give me a minute

#

can i rename a org later

#

lmao

summer osprey
#

yes haha

#

just dont name it fiddledicks or something you will regret haha

#

you only need a github workflow initially in the shared code repo

#

because the ui is being built by vercel, and db i assume is being ran directly

real spindle
#

I named them

frontend - nextjs app
backend - my custom backend

core - the shared code

#

will rename later on but

#

will do for now

summer osprey
#

in the core repo make a .github/workflows/build.yml

real spindle
#

alright let me download the repo

#

btw

#

all of these repos

#

should all be under a single folder right

#

to make things easy

#

basically monorepo without the mono

summer osprey
#

nono

#

what ide do you use

real spindle
#

vs code

summer osprey
#

if vscode then maybe

#

in jb webstorm you can “attach” separate folders

#

i personally keep repos organized by org in my drive anyway tho

#

so it would work out the same way i guess

real spindle
#

alright

summer osprey
#
name: Core CI
on:
  workflow_dispatch:
  push:
    paths:
      - "src/**"
      - "package*.json"
      - "tsconfig.json"
      - ".github/workflows/build.yml"
  pull_request:
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x, 20.x]
    steps:
      - uses: actions/checkout@v3

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://npm.pkg.github.com
          scope: '@yourorgname'

      - name: Install dependencies
        run: npm ci
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Build package
        run: npm run build --if-present

      - name: Publish package
        run: npm publish
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#

something like that

#

may need a tweak or 2 thats from one of my repos

#

change scope to your org name obviously

#

and you can remove matrix if you are just building for node 20

#

i was just being boujie

real spindle
#

well

#

this is for core right?

#

if thats the case there is no building involved

summer osprey
#

correct

summer osprey
#

you should…

real spindle
#

erm

summer osprey
#

it reduces package size

#

minifies etc

real spindle
#

i mean i can always do that later right?

summer osprey
#

yes

real spindle
#

feel like i should get this flow down first

summer osprey
#

sure then remove the build step

#

in github settings, go into the core repo and enable access to actions

real spindle
#

should already be enabled

#

and this package name will be the name in package.json?

summer osprey
summer osprey
#

so @orgname/packagename

#

thats the scope you have access to

#

good practice anyway… but yeah

real spindle
#

aight

summer osprey
#

then… just… push

#

the workflow should trigger

#

should build it

#

should be available

real spindle
summer osprey
#

you do need to npm login 1 time on your pc if the packages are private

#

its missing an env:

#

(im on my phone so copy paste hard)

real spindle
#

figured

summer osprey
#

you can technically set that env on all steps and not have to set it per step but if you are building you dont want it to pollute things like .env for nextjs etc

real spindle
#

oh i dont have a package .lock

#

lmao

#

do i have to use npm or can i use pnpm

summer osprey
#

i dont use pnpm but i assume theres a ci type command for pnpm

#

ci just means clean install

#

like dont keep rogue bullshit

real spindle
#

uh

#

pnpm not found

summer osprey
#

oh yeah i bet its a different setup

#

lemme check for an action

real spindle
#

i think i found one

summer osprey
#

i have no idea what those args are as i dont use pnpm

#

so thats a you thing

real spindle
#

right so yeah

#

im getting the npm auth error

#

on github

summer osprey
#

where

real spindle
#

on the github action

summer osprey
#

is the repo private?

real spindle
#

yep

summer osprey
#

like can you invite me?

#

so i can visualize

real spindle
#

i mean obviously github

#

does not know anything about npm

#

i never connected it

summer osprey
#

you shouldnt

real spindle
#

how would github know then

summer osprey
#
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://npm.pkg.github.com
          scope: '@yourorgname'
real spindle
#

hm

summer osprey
#

ohhhhhhh show me your package.json

real spindle
#

{
"name": "@rblx-internal/core",
"version": "0.0.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "MIT",
"scripts": {
"generate": "drizzle-kit generate:mysql --config=configs/drizzle.config.ts",
"introspect": "drizzle-kit introspect:mysql --config=configs/drizzle.config.ts",
"push": "drizzle-kit push:mysql --config=configs/drizzle.config.ts",
"drop": "drizzle-kit drop --config=configs/drizzle.config.ts"
},
"dependencies": {
"@lucia-auth/adapter-mysql": "^2.1.0",
"@lucia-auth/oauth": "^3.3.1",
"@planetscale/database": "^1.11.0",
"@sinclair/typebox": "^0.31.20",
"drizzle-orm": "^0.28.6",
"lucia": "^2.7.1",
"typescript": "latest"
}
}

summer osprey
#

yeah thats whats missing. sec

real spindle
#

also should scope be the name of the package or just the org name

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

add that

summer osprey
real spindle
#

haha

#

i was lazy ;p

#

figured did not need it for that package

#

seems like it does not exist

summer osprey
#

i do not recall if you need to push it once on your own. i thought you didnt.

#

do you have a github PAT

#

if not, generate one

#

you need one for local

real spindle
#

PAT?

summer osprey
#

personal access token

real spindle
#

i mean i use a token in my .ssh

#

if thats what your refering to

summer osprey
#

generate a "classic" token.

#

nono

#

generate new tokoen -> generate new token (classic)

real spindle
#

what is this for

summer osprey
#

to log into github npm

#

from your machine

real spindle
#

question

#

all the stuff we are doing rn

summer osprey
#

daily double

real spindle
#

does this make it insanely difficult to bring someone else onto the project

summer osprey
#

and most users ive ever worked with already have a pat

#

npm login remembers your creds on your pc

#

so you only have to do it once

real spindle
#

what scopes should i give it

#

just write packages?

summer osprey
#

i have 2

#

1 "master" pat with all scopes

#

and 1 with restricted scopes

#

until you learn the scope system, just make your master pat

real spindle
#

but isnt this pat just for the first push

summer osprey
#

no

#

what if you dont need to work on both simultaniously

#

you can just npm i

#

and install from remote

#

it will use that pat

real spindle
#

so any user who wants to work on my codebase needs to have a PAT

summer osprey
#

any user who wants to work on just db or ui

#

these are standard flows. npm authentication is not a new concept.

#

authentication in general is not a new concept hah

real spindle
#

i know but

#

i never used PAT before

#

we usually just use .ssh tokens

summer osprey
#

ssh === git clone

real spindle
#

so should i just give all perms for this

summer osprey
#

yeah for the sake of the example

#

lilke with your naming haha

real spindle
#

okay i have my pat

#

you going to pat me

summer osprey
#

in your readme you can have a bulletpoint under "local dev" with

  • Authenticate with the myorgname package registry
    --- 2 steps here
real spindle
#

where do i provide this pat

summer osprey
#

open up terminal powershell or whatever vs-code terminal is using

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

you will get a username and password prompt

#

username is github username not email

#

password is the pat

real spindle
#

when it says the email IS public

#

does that mean everyone can see it

#

lol

summer osprey
#

nono

#

thats default npmjs text

#

isnt relevant for github

real spindle
#

so i dont need to provide anything?

summer osprey
#

i mean....

#

give it your github email

real spindle
#

k well im logged in

summer osprey
#

so it associeates your username in the little info boxes

#

ok now npm publish

real spindle
summer osprey
#

owner not found

#

ive literally never seen that before

real spindle
#

oh

#

im stupid

summer osprey
#

?

#

your org name isnt rblx-internal is it

#

XD

real spindle
#

it is not

summer osprey
#

hahahah

real spindle
#

okay published

summer osprey
#

i bet you didnt even need to do that

#

i bet if you fixed and pushed it would have worked

real spindle
#

well i tried publishing

summer osprey
#

thats what the workflow was crying about

real spindle
#

and it still did the same error on the github workflow

#

but it did work via npm publish

summer osprey
#

oh

#

ok good

real spindle
#

should i test just to see if it publishes now via the workflow

summer osprey
#

yes. remember to increment your version

real spindle
#

alright

#

i still get the error

#

in the github workflow

summer osprey
#

oh you need to enable in the package

#

go to your org

#

click packages

#

click the package you pushed

#

there is a "manage actions access"

#

add the repo and give it role write

#

github is srs about security

real spindle
#

as they should

#

huh

summer osprey
#

dunno thats a pnpm thing

real spindle
#

still did not work

#

i think it canceled

summer osprey
#

that errored before publish

real spindle
#

in the .18 node

#

but in the .20

#

it got the same perm error

summer osprey
#

ohhhh thats because actions are "fail fast"

#

if 1 in the matrix fails, the rest are inturrupted

real spindle
#

yeah

#

so its still the same perm error

#

ima actually stop bulding on both

#

and just on .20

summer osprey
#

remove the 18.x

#

from matrix strategy

real spindle
summer osprey
#

ah easy fix

#

associate the package with your repo

real spindle
#

i thought we did that

summer osprey
#

OR change perms to "Admin" for the action

#

nono

#

you see this in your package?

real spindle
#

but i did that?

summer osprey
#

can you screenshot your whole package settings

real spindle
summer osprey
#

no i said to give the perms in settings

real spindle
#

???

#

is that not what this is?

summer osprey
#

that is what i said for the first thing

#

go out of settings

real spindle
#

i dont understand why i need to link twice lmao

summer osprey
#

one is permissions

#

one is scope

real spindle
#

i still dont understand lmao

summer osprey
#

you can give the role Admin

#

and not do the second part

#

but its best practice to link

#

just go to the main page of the package

real spindle
#

with connecting it

#

it still did not work

summer osprey
#

same error?!?

real spindle
real spindle
summer osprey
#

show me your actions settings

#

the first thing you said should be default

real spindle
summer osprey
#

whats your inherited access settings in your package

real spindle
#

where do i see that

summer osprey
#

the next section

real spindle
summer osprey
#

there it is

#

check that

real spindle
#

man this is giving me a doozie

#

ngl this is so much more complicated than a turborepo 💀

summer osprey
#

this is devops

#

this is removing bullshit from your codebase so your codebase is just your codebase

#

its not "hard" or "complicated' its just security settings you arent used to

real spindle
#

🙃

summer osprey
#

for the sake

#

change perms from write to admin

#

and push another change

real spindle
#

same error

summer osprey
#

before runs-on: ubuntu

#

add permissions: write-all

#

ive literally neer seen that before, but without visibility into your org its not worth tracing

real spindle
#

ill try it

#

and it finally worked

#

so its possible all the shit we just did

#

was pointless

#

and just needed that

summer osprey
#

1000%

#

on-the-fly troubleshooting "be like dat bruv"

#

XD

real spindle
#

yeah but because we did like

#

100 things

#

i dont even remember

#

what i would have to do if i ever wanted to do this again

#

lmao

summer osprey
#

so test it again

#

core 2

real spindle
#

core 2?

summer osprey
#

push it as is

#

like another repo

#

and change packagename to core2

#

and make no changes

#

and see if it works

#

if it doesnt, tweak one thing

real spindle
#

whats this testing for?

summer osprey
#

to see the "minimum steps required"

real spindle
#

oh

#

well i would have to create a new repo

#

and set up all the settings again

summer osprey
#

dont gotta make an extra pat

real spindle
#

i know

#

but this hassle was mostly the security settings

#

i would have to do the package settings + the repo settings

summer osprey
#

You are making me want to write a readme

real spindle
#

lmao

#

anyways lets move onto the other step lmao

summer osprey
#

because this is so native to me XD

summer osprey
#

locally, cd into the root directory of your core folder

real spindle
#

wym i already have been

summer osprey
#

oh. welp

#

then type pnpm link

real spindle
summer osprey
#

fuckin pnpm

real spindle
#

lmao

summer osprey
#

pnpm link --global

#

wait

#

pnpm link --global <pkg>

real spindle
summer osprey
#

pnpm link --global @rblx-headless/core

real spindle
#

you want <pkg> to be @rblx-headless/core ?

summer osprey
#

thats some pnpm shit man

real spindle
#

lmao

summer osprey
#

i dont know why people like that thing

real spindle
#

oh

#

maybe this is because

#

i dont have it 'installed'

#

im trying to replace something that has not even been installed yet?

#

idk

summer osprey
#

maybe. do what the example above says to do

#

pnpm install THEN pnpm link --blobal

real spindle
#

i tried

#

lmao

#

same error

summer osprey
#

nono

#

you need to CHANGE DIRECTORY

#

to the db folder

#

or the ui folder

#

before you do the --global <pkg>

#

the second command is saying "use this previously linked pkg"

real spindle
#

i thought i need to A.

Create the global link for the core package,

THEN go to the backend package and link it

summer osprey
#

right

real spindle
#

but im just getting errors at the first step

summer osprey
#

global link is just
pnpm link --global

#

you did that

#

oh pnpm registries error

real spindle
#

no ive been getting errors

#

ive been posting them

summer osprey
#

again. that is literally not a thing with npm

real spindle
#

you know what

summer osprey
#

guess ill google

real spindle
#

ima try the non global one

#

ima try this

summer osprey
#

i see you

#

i see you

#

XD

real spindle
#

🙂

summer osprey
#

stupid. fuckin. pnpm.

#

anyways

#

ok. so all changes should be live now

#

any changes instantly propogate in local dev

real spindle
#

so wait

#

dont i need to add this to my backend package.json though

#

its linked but its not in the package.json

summer osprey
#

yeah it should be in package.json for prod builds

#

and you need to remember to authenticate in prod builds

#

by passing the "scoped" pat as an env var to vercel

#

on db side you can save an env var in .bashrc or whatever

#

export NPM_TOKEN=myscopedreadonlypat

#

adding this in your db / ui repos makes it automatic:

real spindle
#

so

summer osprey
#
@rblx-headless:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
real spindle
#

when i run pnpm i

summer osprey
#

as .npmrc

real spindle
#

in the backend directory

#

and its pulling the content from npm thingy

#

is that because its using the PAT

#

it has access to read it

summer osprey
#

with pnpm i dont know. with npm it doesnt try to update that 1 line because its linked

real spindle
#

right but when i did pnpm install it will still install it

summer osprey
#

just pnpm things

#

its literally an open issue

#

but noooo yall loooooove pnpm

#

-,-

real spindle
#

?

#

whats is

summer osprey
#

when calling pnpm install it ignores linked

#

and overrides install

real spindle
#

oh

#

so its not using my local package?

summer osprey
#

according to the output you should know apparently

#

if it has a <-- for that file its linked

#

but thats using a global link

#

not a dir link

real spindle
#

ugh

#

im getting stupid errors

#

in my code now

#

oh

#

i wonder if this is because

#

hold on

#

so i can confirm

#

i ran the local backend server

#

when i made a change to the local core

#

and it outputted the change

summer osprey
#

😉

real spindle
#

i also love

#

there is no command

#

to see the links currently in use

summer osprey
summer osprey
#

you add a .npmrc file

#

or if pnpm has some stupid renamed one

real spindle
#

this should go in the backend repo right

summer osprey
#

the ones that need to ingest the core package

real spindle
#

and the // is suppose to be there right

#

thats not a comment

summer osprey
#

correct thats supposed to be there

real spindle
#

can i change version back to 0

#

or does it always need to be greater than the previous

#

what actually happens if I push the same version package?

#

nothing?

summer osprey
#

in npmjs it errors

#

i dont know if it errors in github

#

but...

#

you should always be incrementing

#

you can increment in PRERELEASE

#

e.g. 0.0.1-RC13234234234

real spindle
#

alright

#

im going to attempt to get the backend repo

summer osprey
real spindle
#

scotch?

summer osprey
#

then we can click a link and have it jump between squares going back and forth

real spindle
#

im more of a wine type of guy

real spindle
#

so

#

i assume best practice

#

would be to create a PAT specfically for reading only

#

for production

summer osprey
#

yes 100%

real spindle
#

i lowkey feel like

#

there must be a better way than doing PATs

#

because PATs is basically my personal account giving permission

summer osprey
#

oh there is

real spindle
#

which realistically this should not be an account token

#

this should only be specific to the org

summer osprey
#

the right way is to create a deploy key

real spindle
#

yeah thats what i remembered

summer osprey
#

and have github workflow push the built code to the prod server

real spindle
#

wait

#

fuck

#

i dont think i could even use a deploy key

#

arent deploy keys used in dedicated servers

summer osprey
#

you mean a runner?

#

it wont work for vercel

#

if thats what you are asking.

real spindle
#

bruh

#

i dont understand that though

#

why do i have to create a PAT for my own personal acount

#

when in reality this is not a thing for my account its a thing for my org

summer osprey
#

thats the point of the new access tokens

#

fine grained access tokens

#

which are repositry scoped and action scoped

#

but because they are still beta they dont work on github packages yet

real spindle
#

bruh

summer osprey
#

bruh

real spindle
#

idk what to even give this PAT

#

i assume read packages and uh

#

ur telling me

#

i cant create a PAT for a private repo

#

that only has read access

summer osprey
real spindle
#

im looking into bun

#

for proper workspaces

#

sorry registry setup

summer osprey
#

jesus not that too

#

pnpm

#

bun

real spindle
#

LMAO

summer osprey
#

damn hipsters

real spindle
#

im forced to use both

#

well

#

not anymore since this is not a monorepo

#

the backend only uses bun

summer osprey
real spindle
#

there is registry with token

summer osprey
#

that should literally be the only scope you need

real spindle
#

is the PAT considered a token or a password for username one

summer osprey
real spindle
summer osprey
#

why does it need repo for the npm package

#

it only needs repo for its own package

#

which is ssh key

real spindle
#

oh yeah

#

im retarded

summer osprey
#

we all are at some point in the day

real spindle
#

trying to deploy this

#

lets see

#

things never work first try

#

ah yes

#

we love to see it

summer osprey
real spindle
summer osprey
#

you need bunfig.toml apparently

real spindle
#

yeah they dont support it they have their own

#

file

#

yeah i have it

#

i used both of these

#

and got unauthorized on both

#

unless im supposed to add the package too the name

#

actually

#

i can just test locally

#

first

#

yeah hmm

summer osprey
#

do you have your env var set up?

#

or are you trying to log in via no password haha

#

also i would remove line 2

#

those are conflicting

real spindle
#

even if i put the PAT

#

in the file itself

#

for password

#

i still get the same thing

real spindle
summer osprey
#

tried it both ways?

real spindle
#

im just showing you i tried both of those lines

#

oh

#

wait

#

the token way worked

summer osprey
#

there ya go

real spindle
#

however

#

i dont think it will work

summer osprey
#

no build env vars...?

real spindle
#

i do add it in the env variables

summer osprey
#

jesus christ

#

5 seconds to load docs

#

wtf is going on

real spindle
#

lmao

#

bun is fairly new

summer osprey
#

looks like it needs to be ${SECRETS.NPM_TOKEN} ?

real spindle
#

idk

#

if thats the case

#

this is a toml file afterall

summer osprey
#

thats just what their docs say

#

i dunno

real spindle
#

figures its also just getting stuck at the install

#

not moving past it now

#

ugh

#

i wish there was a way to log out what the env is in that toml

real spindle
#

finally got it working on hop lmao

#

@summer osprey so what do u use to compile to esm

real spindle
#

im assuming now

#

that i compile the code in a /dist folder

#

that after i build the package i need to like

#

only publish the /dist folder and package.json?