tisdag 29 oktober 2019

Kotline React GH-pages app Stage 1-2

This is my record of learning to use Kotlin in combination of React on github pages. I used React with typescript before at work. I did some Kotlin for android dabeling. I use gh-pages for most my hosting. I also want my source code to be private, so we need two github repositories. One for the source code and one for the gh-page.

I created two repositories on : https://github.com/new
The private project for my source code organiser, git-url: git@github.com:paven/organiser.git
gh page project organiser_beta: git@github.com:paven/organiser_beta.git

This first step required me to create a react kotlin app and hook it up to github:
yarn global add create-react-kotlin-app
create-react-kotlin-app organiser
yarn add gh-pages
cd organiser
git init
git remote add github git@github.com:paven/organiser.git
git commit -a -m "create-react-kotlin-app"
git push -f github master 
You can read about the create-react-kotlin-app here:  create-react-kotlin-app
And the git commands: git/docs

By now I had my source project created and up on github, but the gh-page was not up and running, for this I needed to do some editing to the configuration. The guide i looked at "How to deploy your react application to github pages" was pretty strait forward, but it defaults to sending to the origin repo and I wanted to send to a second github repo so i hade to figure some things out from npm/gh-pages.

So i modified my package.json (int the organiser repo) with the this:
{
   ...
   "predeploy": "yarn run build",
   "deploy": "gh-pages -d build --repo 'git@github.com:paven/organiser_beta.git'"
   ...
}

yarn deploy
Resulting in some joy from me, I figured this was a twitter moment
Though the page was mysteriously white it was a smale win. After investigating the webcode I realised that code tried to load from organiser instead of organiser_beta. I needed to change the first value in package-json
{
   {
      "name": "organiser_beta",
   ...
}
and after yarn deploy  this it was a second twitter moment.
Tada!
More react: https://medium.com/@ralf.stuckert/getting-started-with-kotlin-react-c5f3b079a8bf