https://kotlinlang.org logo
#javascript
Title
# javascript
m

Mark Vogel

02/01/2023, 10:20 PM
I'm attempting to create a JavaScript project that depends on libraries written in Kotlin/JS. The code for both is contained within the same project like:
Copy code
| project
| - src/jsMain
  | - kotlin
  | - resources
| - js-client
  | - package.json
The goal is to allow the
js-client
code to use the libraries within the Kotlin/JS project without needing to first publish to an external NPM repository (like with npm-publish etc.) Does anyone know how I would accomplish this? e.g. what I would put into my
package.json
etc. perhaps even how to compile with Gradle Thanks for any help!
b

Big Chungus

02/01/2023, 10:44 PM
Have you tried this setup (works fully locally without publishing) https://github.com/mpetuska/npm-publish/tree/master/sandbox/ts-consumer
m

Mark Vogel

02/01/2023, 10:47 PM
I didn't see that no. I will check it out thanks!
@Big Chungus this is accomplished by using
npm-publish
to create the local?
b

Big Chungus

02/01/2023, 11:06 PM
Correct. It utilises npm-publish to pack (but not publish) kjs lib as npm lib. Then it installs it to ts project from generated tarball.
m

Mark Vogel

02/01/2023, 11:09 PM
I see. That sounds like exactly what I need. I cloned the project and am looking it over. Do you have any understanding of how this kind of thing is working? I've never seen plain text files with a path used before in projects.
b

Big Chungus

02/01/2023, 11:14 PM
Ah, that's just the way github web ui displays unix symbolic links 😀 confusing, I know. It basically allows me to avoid duplicating those sample sources
But that's not relevant at all to what you need.
m

Mark Vogel

02/01/2023, 11:18 PM
Ahh yeah Git doesn't like tracking empty directories I see haha
@Big Chungus can the npm-publish plugin be used in a non-Kotlin project? In other words, a Gradle project with pure JS using the node-gradle-node plugin
Lol never mind I sort of figured it out and then also saw the sample provided in the repo
b

Big Chungus

02/08/2023, 7:25 PM
I should probably make another sample that integrates with node gradle plugin too
m

Mark Vogel

02/08/2023, 7:37 PM
Any insight on how to use a Github personal access token to authenticate? I'm getting permission denied along with it not finding my repository
Copy code
npmPublish {
    packages {
        named("js") {
            files.from("dist")
            packageJsonTemplateFile.set(file("package.json"))
            packageJson {
                version.set(project.version as String)
                repository {
                    type.set("git")
                    url.set("<https://github.com/Org/example-common.git>")
                }
            }
        }
    }
    registries {
        github { // Not found - PUT <https://npm.pkg.github.com/components>
            authToken.set(findProperty(tokenKey) as? String)
        }
        register("github") { // Permission denied
            uri.set(uri("<https://npm.pkg.github.com/Org>"))
            authToken.set(findProperty(tokenKey) as? String)
        }
    }
}
The PAT is supposed to use a username also which I'm assuming is the problem, but I'm not sure how to resolve it
@Big Chungus no problem if you don't have anything further, but just pinging in case you possibly know an answer to this. Thanks for your help
b

Big Chungus

02/08/2023, 9:34 PM
Have a look at gh publishing sample and read readme and comments in the buildfile for ghp specific gotchas (there be plenty)
m

Mark Vogel

02/08/2023, 9:43 PM
Thanks! Appreciate the reply. I will go through that more thoroughly
b

Big Chungus

02/09/2023, 5:01 PM
Hi, just want to check if you've managed to solve your issue with ghp or are you still stuck?
m

Mark Vogel

02/09/2023, 5:04 PM
I was finally able to solve it. Turns out the personal access token was working fine without a username, but the package name + organization combination was finicky. It has to be the exact organization name and a simple name for the project.
b

Big Chungus

02/09/2023, 5:44 PM
Yep, that's why ghp aren't that popular 😀
14 Views