$ git add . (1)
$ git commit -m "your comments" (2)
In the previous section of this tutorial, you learned how to use Git to clone a Koji project to your development machine and how to install and launch a Node.js server to run your project locally.
In this section, you will learn how to push the changes that you make locally to your project’s origin repository, and how to pull the latest version of your project into the Koji editor, where you can publish it to the world.
Note
|
It is recommended that you test the publishing process before you get deep into development locally. You can make a minor change, push it back to the Koji servers, and check that the change is visible in the published app on Koji. |
By the end of the section, you should feel comfortable:
Making and testing changes locally.
Publishing your changes to the Koji server.
Pushing your changes to the origin repository, and then pulling them into the Koji editor.
Follow the first two sections to set up the Falling Objects game on your development machine.
Let’s make a small change in the Falling Objects game, just for testing purposes.
Open frontend\src\Components\View\LeaderboardMini.js
.
Change <Title>{"Top Players"}</Title>
to <Title>{"Leaderboard"}</Title>
and save the file.
In your browser, go to http://0.0.0.0:8080
, and make sure the leaderboard shows the new title.
To make a local change visible on Koji server, you must use Git to commit
your changes locally and then push
the committed changes to the remote Koji repository.
Pushing the changes automatically publishes the app.
The Git version control system keeps track of every change you make the files in your project.
To see which files have changed, use the command git status
.
Note
|
The .gitignore file at the root of your project lists the files that Git does not track for changes.
You might not see the file if your operating system is configured to hide files whose names begin with a dot.
In particular, this file tells Git to ignore any changes to files in the node_modules folders, which were created when you ran npm install in the frontend and backend folders.
|
When you are ready to test your changes on the Koji server, use Git to commit
your changes locally.
Open a terminal window and go to the root directory of your project (for example, MyKojiApp
).
Run the following Git commands.
$ git add . (1)
$ git commit -m "your comments" (2)
Processes all the documents that you have changed.
Creates an updated version of your project.
Note
|
Be sure to replace For a more complete description of the |
After the commit process is successfully completed, you use Git to upload the committed changes to the repository on the Koji servers.
Open a terminal window and go to the root directory of your project.
Run the following command.
git push origin master
At the username prompt, enter your username on Koji and press Enter.
At the password prompt, enter the access key that you generated in a previous tutorial and press Enter.
Your terminal will look something like this:
$ git push origin master (1)
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (21/21), 84.53 KiB | 0 bytes/s, done.
Total 21 (delta 15), reused 0 (delta 0)
Username for 'https://projects.koji-cdn.com': KojiCoder
Password for 'https://KojiCoder@projects.koji-cdn.com': (2)
To https://projects.koji-cdn.com/a70f8329-e89e-48b0-8d85-7658c1542b9f.git
a88036c..ea6bda1 master -> master
Use Git to upload your new version to the Koji repository
Paste your 32-character access key.
Note
|
Pushing your changes to origin automatically publishes a new version of your app. |
Now that you’ve published your app, you will want to make sure that it works the same on the Koji server as it does locally.
On the Koji home page, click your profile button and select Developer Portal.
Select your app from All Projects.
Click View Published Koji. The published version of your app opens.
Proceed to test all the features of your app.
Tip
|
For tips on testing your app, visit Testing and debugging apps. |
If you want to use the Koji code editor after you make changes locally, you must pull your changes into it and update the Node modules to match your local environment.
The Koji editor uses its own repository, which is different from the origin
repository to which you pushed your changes.
So, if you want to go back to using the Koji editor, you will have to pull
the changes from the origin
repository.
Open your project in the Koji editor.
Open a new terminal tab and run the following command.
git pull origin master
Your terminal will look something like this:
root@ip-172-31-12-226:/usr/src/app# git pull origin master
remote: Counting objects: 13, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 13 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (13/13), done.
From https://projects.koji-cdn.com/d29a69ff-f413-45bb-a364-a6bee40eea91
* branch master -> FETCH_HEAD
0cafbcd..9633a51 master -> origin/master
Updating 0cafbcd..9633a51
Fast-forward
frontend/src/Components/Remix/index.js | 569 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------
frontend/src/Components/View/Leaderboard.js | 456 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------
frontend/src/Components/View/LeaderboardMini.js | 373 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------
3 files changed, 673 insertions(+), 725 deletions(-)
root@ip-172-31-12-226:/usr/src/app#
root@ip-172-31-12-226:/usr/src/app#
The code in the Koji editor should now be identical to the code in your local repository.
In the top right of the Preview pane, click Refresh to make sure you are seeing the latest version.
You should now see the custom title, which corresponds to the local change you made in frontend\src\Components\View\LeaderboardMini.js
.
If you installed new or updated Node modules locally, you must also install these versions on the Koji server.
For example, if you ran npm audit fix
to update all the Node modules to their most recent stable release, the dependencies for the backend
and the frontend
servers might have changed.
The package.json
and package-lock.json
files in the backend
and the frontend
directories should contain the information needed to update your Node modules to the correct versions.
In the Terminal pane, click the frontend
tab.
Press Ctrl+C to cancel the running process.
Run the following command.
npm install
NPM installs the files listed in the package-lock.json
file for the frontend
service.
When the installations are finished, run the following command.
npm start
Your terminal will look something like this:
^C
root@ip-172-31-15-216:/usr/src/app/frontend# npm install
npm WARN meta-project@1.0.0 No repository field.
npm WARN meta-project@1.0.0 No license field.
... (more warnings and comments not shown) ...
audited 12334 packages in 5.192s
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
root@ip-172-31-15-216:/usr/src/app/frontend# npm start
... (more output not shown) ...
ℹ 「wds」: Compiled successfully
In the Terminal pane, click the backend
tab.
Press Ctrl+C to cancel the running process.
Run the following command.
npm install
NPM installs the files listed in the package-lock.json
file for the backend
service.
When the installations are finished, run the following command.
npm run start-dev
Your terminal will look something like this:
^C
root@ip-172-31-15-216:/usr/src/app/backend# npm install
npm WARN koji-project-backend@1.0.0 No description
npm WARN koji-project-backend@1.0.0 No repository field.
... (more warnings and comments not shown) ...
audited 8550 packages in 2.729s
found 0 vulnerabilities
root@ip-172-31-15-216:/usr/src/app/backend# npm run start-dev
... (more output not shown) ...
[koji] backend started
This tutorial has taken you on a round trip from the Koji editor to your local development environment and back again. You have seen changes that you made locally served live from the Koji servers. As you develop your project, you will cycle through many such loops, adding and refining features and testing that everything works just as well from the Koji servers as from the comfort of your own development machine.
In particular, you have seen how to:
Clone a remixable Koji project onto your development machine (part 1).
Install a Node.js server environment and run your project locally (part 2).
Make and test changes locally.
Push your changes to the origin repository, and then pull them into the Koji editor.
Publish your changes to the Koji server.
Test that your app works the same live on a Koji server as it does locally.
You’re now ready to start developing your Koji app in earnest, in the development environment where you feel most comfortable. Let your creativity shine!