Skip to content

Commit

Permalink
Make todo sample work standalone again
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fahlander committed Jan 15, 2025
1 parent b415d92 commit 6ddd2d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
30 changes: 14 additions & 16 deletions samples/dexie-cloud-todo-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ If you just want to see the app in action, navigate to the [pre-built published

If you want to build and play with it locally, follow these steps:

1. `npm install --global pnpm@latest-9` (if pnpm not already installed)
2. `npx dexie-cloud create`
3. `pnpm install`
4. `./configure-app.sh`
5. `pnpm start`
1. `npx dexie-cloud create`
2. `npm install`
3. `./configure-app.sh`
4. `npm start`

The steps above will:

1. Install pnpm (if you haven't already)
2. Create a new database in the cloud
3. Install dependencies
4. Import demo-users to your database and create a .env file that connects the ToDo app to your database.
5. Build and start the application in local dev-mode (without a service worker).
1. Create a new database in the cloud
2. Install dependencies
3. Import demo-users to your database and create a .env file that connects the ToDo app to your database.
4. Build and start the application in local dev-mode (without a service worker).

# Activating Service Worker

Service worker is automatically disabled in dev-mode (the default for create-react-app). To enable it, the easiest way is to deploy the app:

1. `pnpm run deploy` (will publish the app to your gh-pages branch of your Dexie.js fork)
1. `npm run deploy` (will publish the app to your gh-pages branch of your Dexie.js fork)
2. `npx dexie-cloud whitelist https://your-github-username.github.io` (replace `your-github-username`)
3. Voila: Go to https://your-github-username.github.io/Dexie.js/dexie-cloud-todo-app/ from your browser. This is a full installable PWA that you can add to your start screen on a mobile phone.

Expand Down Expand Up @@ -61,20 +59,20 @@ This command will create the file .env.local and configure it against the DB URL
You can equally well set the environment variable REACT_APP_DBURL manually to the URL of your
Dexie Cloud database.

### `pnpm start`
### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `pnpm test`
### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `pnpm build`
### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
Expand All @@ -84,11 +82,11 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `pnpm run deploy`
### `npm run deploy`

Deploys the built app to gh-pages branch of this github repository under the folder /dexie-cloud-todo-app/.

### `pnpm run eject`
### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

Expand Down
4 changes: 2 additions & 2 deletions samples/dexie-cloud-todo-app/configure-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ echo "REACT_APP_DBURL=$DB_URL" > .env.local
echo "FAST_REFRESH=false" >> .env.local
echo ""
echo "Application is now configured!"
echo "Use 'yarn install' if you haven't done so already."
echo "Use 'yarn start' to start the app."
echo "Use 'npm install' if you haven't done so already."
echo "Use 'npm start' to start the app."
8 changes: 4 additions & 4 deletions samples/dexie-cloud-todo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"@types/react-dom": "^18.2.4",
"@types/testing-library__jest-dom": "^5.14.6",
"bootstrap": "5.3.0",
"dexie": "workspace:^",
"dexie-cloud-addon": "workspace:^",
"dexie-react-hooks": "workspace:^",
"dexie": "^4.0.11",
"dexie-cloud-addon": "^4.0.11",
"dexie-react-hooks": "^1.1.7",
"postcss-flexbugs-fixes": "^5.0.2",
"react": "^17.0.2",
"react-bootstrap": "^2.7.4",
Expand All @@ -43,7 +43,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"predeploy": "PUBLIC_URL=. REACT_APP_BUILD_TIME=$(date +%s) yarn build",
"predeploy": "PUBLIC_URL=. REACT_APP_BUILD_TIME=$(date +%s) npm run build",
"deploy": "gh-pages -d build -e dexie-cloud-todo-app",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down

0 comments on commit 6ddd2d0

Please sign in to comment.