Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace with new tn-models-fp #204

Merged
merged 39 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
483d038
replace with new tn-models-fp
paribaker Jul 16, 2023
70fc1e6
updated to remove comments
paribaker Jul 16, 2023
ea88024
updated axios
paribaker Jul 16, 2023
8622f56
fix missing deps
paribaker Jul 16, 2023
93c7a1e
remvoed users
paribaker Jul 16, 2023
d363f64
checking implicit exports
paribaker Jul 16, 2023
90f1703
updated user api
paribaker Jul 16, 2023
16845aa
import axios instance
paribaker Jul 16, 2023
9c73166
updated user resgistration
paribaker Jul 16, 2023
ca47ae0
updated fn
paribaker Jul 16, 2023
1d8c8eb
make base shape readonly
paribaker Jul 16, 2023
1223953
updated baseModelShape
paribaker Jul 16, 2023
d521408
updated typo
paribaker Jul 16, 2023
666a654
updated to include token as opt
paribaker Jul 16, 2023
401d469
fix readonly import
paribaker Jul 16, 2023
c443347
change to confirm password
paribaker Jul 16, 2023
5afc5eb
updated reset flow
paribaker Jul 16, 2023
5f50bd5
Merge branch 'main' into feature/vue-to-models-fp
paribaker Jul 17, 2023
30a5c6d
small fixes
paribaker Aug 3, 2023
d7234d3
updated code with new libs
paribaker Aug 10, 2023
33f44c6
merge main
paribaker Aug 10, 2023
c42d41c
remove lock file
paribaker Aug 10, 2023
3bb0c6c
updated package.json
paribaker Aug 10, 2023
d7b64fe
Merge branch 'main' into feature/vue-to-models-fp
paribaker Aug 10, 2023
9f4cc27
Merge branch 'main' into feature/vue-to-models-fp
paribaker Aug 11, 2023
1274573
remove read only
paribaker Aug 11, 2023
0084f37
upadted readonly
paribaker Aug 11, 2023
935effc
changed to tailwind 3.2.2 for async error
paribaker Aug 11, 2023
bc631b2
trying tailwind 3.2.2
paribaker Aug 12, 2023
aa3dd24
pin tailwind version
paribaker Aug 12, 2023
26a7eee
resolve comments
paribaker Aug 18, 2023
778a22b
updated with merge conflicts
paribaker Aug 18, 2023
6bf9082
added api to axios and removed from libs
paribaker Aug 18, 2023
676c68a
fix for sign up, temp use react for test
paribaker Aug 20, 2023
4d5d804
trigger react
paribaker Aug 20, 2023
bb7adb5
fix skip lock issue
paribaker Aug 20, 2023
9320df5
updated to force react
paribaker Aug 20, 2023
64d9ca5
updated to remove react force
paribaker Aug 20, 2023
65d7348
form fix for react sign up
paribaker Aug 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Pytest, McCabe, and Coverage
run: |
cd my_project
pipenv install --dev --deploy --skip-lock
pipenv install --dev --deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we make this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting....looks like they deprecated this flag.
pypa/pipenv#5805

Sounds like this should be replaced with pipenv run pip install
Not sure if it has the --dev and --deploy flag for regular pip though.

The reason why this was here was to test the app with the latest versions of a library (instead of the pinned versions in the lock file). This would encourage devs to version bump more often because you know it works with the latest.
And if some new thing breaks the build, we can investigate it sooner instead of waiting to hit that error when we are trying to version bump.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeaaa....pip install couldn't possibly have the --dev flag. Lets merge this as-is and open a github issue to figure out a way to bring this back using pipenv

mkdir -p client/dist/static
pipenv run python server/manage.py collectstatic
pipenv run pytest --mccabe --cov=my_project -vv server/my_project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ alternatively if you want to use expo run command

1. Download and install ngrok
2. Set up ngrok auth token (request an account from William Huster)
3. run ngrok `~/.ngrok http 8000 --subdomain <yourname>-thinknimble` PLEASE NOTICE THE DASH APPENDED NAME `--subdomain <yourname>-thinknimble` DO NOT USE `--subdomain thinknimble`
3. run ngrok `~/.ngrok http 8000 --subdomain <a domain>`
4. add your new subomain to the `.env` IN MOBILE DIR as BACKEND_DEV_SERVER
5. append your new subdomain to the `.env` in ROOT DIR to ALLOW_HOSTS e.g `ALLOW_HOSTS=[localhost:8080,<yourname>-thinknimble.ngrok.io]`
5. append your new subdomain to the `.env` in ROOT DIR to ALLOW_HOSTS e.g `ALLOW_HOSTS=[localhost:8080,<your domain>.ngrok.io]`



Expand Down Expand Up @@ -229,3 +229,24 @@ _expo-teststore-build-ios.yml_
Run this workflow to deploy an emergency code related bugfix

expo-emergency-prod-update.yml


#### Important note about custom native modules and expo eject

We can easily use our own native or non supported RN pacakges by checking if we are running an expo build or not, these will only work in expo builds not expo go.
When building for local testing/development we use the alternative builds in our eas.json
Recently Expo has changed the `expo eject` command for `expo pre-build` this will create the iOS and Android folders and allow you to run your project in xcode or android studio as well you will need to activate your .env file since some vars are supplied from there.

You can accomplish this with `npm run prebuild:local` this will ensure that your `.env` file is sourced!

Expo will automatically change your package.json and add/remove/change the following

- `"main"` entry will be removed
- `"start"`: `"expo start --dev-client"` will change to this <----

therefore when running prebuild ensure not to commit these changes!





47 changes: 23 additions & 24 deletions {{cookiecutter.project_slug}}/clients/mobile/react-native/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"SENTRY_DSN": "<REPLACE_WITH_LOCAL_SENTRY_DSN>"
}
},
"development-review": {
"development_review": {
"developmentClient": true,
"distribution": "internal",
"channel": "review",
Expand All @@ -42,31 +42,30 @@
"ios": {
"simulator": true
}
},
"staging": {
"distribution": "internal",
"channel": "staging",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_STAGING_BACKEND_SERVER_URL>",
"BUILD_ENV": "staging",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_STAGING_ROLLBAR_TOKEN>",
"SENTRY_PROJECT_NAME": "<REPLACE_WITH_STAGING_SENTRY_PROJECT_NAME>",
"SENTRY_DSN": "<REPLACE_WITH_STAGING_SENTRY_DSN>"
}
},
"production": {
"channel": "production",
"autoIncrement": true,
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_PROD_BACKEND_SERVER_URL>",
"BUILD_ENV": "production",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_PROD_ROLLBAR_TOKEN>",
"SENTRY_PROJECT_NAME": "<REPLACE_WITH_PROD_SENTRY_PROJECT_NAME>",
"SENTRY_DSN": "<REPLACE_WITH_PROD_SENTRY_DSN>"
}
}
},
"staging": {
"distribution": "internal",
"channel": "staging",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_STAGING_BACKEND_SERVER_URL>",
"BUILD_ENV": "staging",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_STAGING_ROLLBAR_TOKEN>",
"SENTRY_PROJECT_NAME": "<REPLACE_WITH_STAGING_SENTRY_PROJECT_NAME>",
"SENTRY_DSN": "<REPLACE_WITH_STAGING_SENTRY_DSN>"
}
},
"production": {
"channel": "production",
"autoIncrement": true,
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_PROD_BACKEND_SERVER_URL>",
"BUILD_ENV": "production",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_PROD_ROLLBAR_TOKEN>",
"SENTRY_PROJECT_NAME": "<REPLACE_WITH_PROD_SENTRY_PROJECT_NAME>",
"SENTRY_DSN": "<REPLACE_WITH_PROD_SENTRY_DSN>"
}
}
},
"submit": {
"production": {
"ios": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "yarn run start:nc --clear",
"start:nc": "source .env npx expo start",
"start:prod": "source .env npx expo start --no-dev --minify",
"start:android": "source .env npx expo start --android",
"start:ios": "source .env npx expo start --ios",
"start:web": "source .env npx expo start --web",
"start:nc": "source .env && npx expo start",
"start:prod": "source .env && npx expo start --no-dev --minify",
"start:android": "source .env && npx expo start --android",
"start:ios": "source .env && npx expo start --ios",
"start:web": "source .env && npx expo start --web",
"prebuild": "npx expo prebuild",
"run:android": "source .env npx expo run:android --clear",
"prebuild:local" : "source .env && SENTRY_PROJECT_NAME=${SENTRY_PROJECT_NAME} SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} expo prebuild",
"run:android": "source .env && npx expo run:android --clear",
"run:android:release": "npx expo run:android --variant release",
"run:ios": "source .env npx expo run:ios --clear",
"run:ios": "source .env && npx expo run:ios --clear",
"run:ios:release": "npx expo run:ios --configuration Release",
"pub:web": "npx expo export:web && cd web-build && vercel --prod && cd ..",
"format": "prettier --check ./src",
Expand All @@ -35,7 +36,7 @@
"@tanstack/react-query": "^4.24.4",
"@thinknimble/tn-forms": "^3.1.3",
"@thinknimble/tn-forms-react": "^1.0.3",
"@thinknimble/tn-models-fp": "2.5.3",
"@thinknimble/tn-models-fp": "^2.13.0",
"axios": "^1.3.2",
"date-fns": "^2.29.3",
"expo": "^48.0.9",
Expand Down Expand Up @@ -90,7 +91,7 @@
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"tailwindcss": "^3.2.6",
"tailwindcss": "3.3.2",
"typescript": "^4.9.4"
},
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAuth } from '../stores/auth'

const appConfig = Config as any
export const axiosInstance = axios.create({
baseURL: appConfig?.backendServerUrl,
baseURL: `${appConfig?.backendServerUrl}/api`,
})

axiosInstance.interceptors.request.use(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const login = createCustomServiceCall(
outputShape: userShape,
},
async ({ client, input, utils }) => {
const res = await client.post('api/login/', utils.toApi(input))
const res = await client.post('/login/', utils.toApi(input))
return utils.fromApi(res.data)
},
)
Expand All @@ -19,25 +19,26 @@ const requestPasswordResetCode = createCustomServiceCall(
inputShape: forgotPasswordShape,
},
async ({ client, input, utils }) => {
await client.get(`api/password/reset/code/${input.email}/`)
await client.get(`/password/reset/code/${input.email}/`)
},
)

const resetPassword = createCustomServiceCall(
{
inputShape: { email: z.string().email(), code: z.string(), password: z.string() },
outputShape: userShape,
},
async ({ client, input, utils }) => {
const { email, ...rest } = utils.toApi(input)
const res = await client.post(`api/password/reset/code/confirm/${input.email}/`, rest)
const res = await client.post(`/password/reset/code/confirm/${input.email}/`, rest)
return utils.fromApi(res.data)
},
)

export const userApi = createApi(
{
client: axiosInstance,
baseUri: '/api/users/',
baseUri: '/users/',
models: {
create: userCreateShape,
entity: userShape,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
*
*/

import { GetInferredFromRaw } from '@thinknimble/tn-models-fp'
import { z } from 'zod'
import { GetInferredFromRaw, readonly } from '@thinknimble/tn-models-fp'
import { baseModelShape } from '../base-model'


export const userShape = {
...baseModelShape,
email: z.string().email(),
firstName: z.string(),
lastName: z.string(),
token: z.string().nullable(),
token: readonly(z.string().nullable()),
}
export type UserShape = GetInferredFromRaw<typeof userShape>

export const userCreateShape = {
...userShape,
email: userShape.email,
firstName: userShape.firstName,
lastName:userShape.lastName,
password: z.string(),
confirmPassword: z.string(),
}

export const forgotPasswordShape = {
Expand Down
Loading
Loading