p:: Web Apps
Fork and Clone Habitica
{
git clone [email protected] :adithya321/habitica.git
cd habitica
git remote add upstream https://github.com/HabitRPG/habitica.git
git remote -v
}
Cloning into 'habitica'...
remote: Enumerating objects: 308198, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 308198 (delta 0), reused 0 (delta 0), pack-reused 308197
Receiving objects: 100% (308198/308198), 1.50 GiB | 7.20 MiB/s, done.
Resolving deltas: 100% (223406/223406), done.
Updating files: 100% (4840/4840), done.
origin [email protected] :adithya321/habitica.git (fetch)
origin [email protected] :adithya321/habitica.git (push)
upstream https://github.com/HabitRPG/habitica.git (fetch)
upstream https://github.com/HabitRPG/habitica.git (push)
Initial Habitica Configuration
Create your own copy of the config.json configuration file by copying (not renaming) the example file:
cp config.json.example config.json
If desired, edit config.json
:
One possible reason for editing config.json is to change the port that Habitica’s Express server uses. By default, it uses port 3000 and there’s no reason to change that unless you know that you are running other software on your machine that uses the same port. If you are, find the BASE_URL
and PORT
lines in config.json
and change the port to a suitable number. Use the same number for both.
Install Habitica-Specific Requirements
volta pin node@14
success: pinned [email protected] (with [email protected] ) in package.json
npm i
...
added 1886 packages from 1519 contributors and audited 1917 packages in 107.554s
99 packages are looking for funding
run `npm fund` for details
found 53 vulnerabilities (8 low, 30 moderate, 14 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
Start the Habitica Web Server
Start Habitica’s own MongoDB instance
npm run mongo:dev
...
Restarting replica set...
Started replica set on "mongodb://localhost:27017?replicaSet=rs"
In a second command prompt or terminal window, start the Habitica web server with:
npm start
2022-01-15T10:53:56.681Z - info Express server listening on port 3210
2022-01-15T10:53:56.815Z - info Connected with Mongoose.
In a third command prompt or terminal window, build the website client with npm run client:dev
. This will rebuild itself automatically as you save changes to client files and will inform you of any errors.
npm run client:dev
...
App running at:
- Local: http://localhost:8080/
- Network: http://192.168.29.107:8080/
Note that the development build is not optimized.
To create a production build, run npm run build.
Open a browser to http://localhost:8080 to test the application.
To add a one-month gift Subscription to a user
brew install mongosh
mongosh
Current Mongosh Log ID: 61e2acd421989f67367ddc9f
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 4.2.8
Using Mongosh: 1.1.8
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
------
The server generated these startup warnings when booting:
2022-01-15T16:22:30.814+0530:
2022-01-15T16:22:30.814+0530: ** WARNING: Access control is not enabled for the database.
2022-01-15T16:22:30.814+0530: ** Read and write access to data and configuration is unrestricted.
2022-01-15T16:22:30.814+0530:
------
rs [direct: primary] test>
use habitica-dev
switched to db habitica-dev
rs [direct: primary] habitica-dev>
db.users.find()
[
{
_id: '5fc14a1a-39ae-4b40-935a-72f90b9110a2',
auth: {
local: {
username: 'adithya321',
lowerCaseUsername: 'adithya321',
...
db.users.update({_id: '5fc14a1a-39ae-4b40-935a-72f90b9110a2'}, {$set: {
'purchased.plan': {
'owner': "5fc14a1a-39ae-4b40-935a-72f90b9110a2",
"dateCreated" : new Date("2021-01-15T00:00:00.000Z"),
"dateUpdated" : new Date("2021-01-15T00:00:00.000Z"),
"dateTerminated" : null, // or you can add a date using the same format as above if needed for your testing
"gemsBought" : 0,
"extraMonths" : 0,
"quantity" : 1,
"mysteryItems" : [ ],
"consecutive" : {
"count" : 1, "offset":0, "gemCapExtra":0, "trinkets":0,
},
"customerId" : "Gift",
},
}})
DeprecationWarning: Collection.update() is deprecated. Use updateOne, updateMany, or bulkWrite.
{
acknowledged: true,
insertedId: null,
matchedCount: 1,
modifiedCount: 1,
upsertedCount: 0
}