You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: This repo is equipped to run with VSCode on Linux (specifically, WSL Ubuntu).
9
+
10
+
# Repo Setup
11
+
12
+
First, create a new file in the root of this project named `.env` and add the following contents:
13
+
14
+
```
15
+
# Server config
16
+
API_LOGGING=true # Enable or disable logging
17
+
API_BASE_PATH=https://cad.onshape.com # Use a different base path
18
+
API_VERSION=10 # Use a different version of the API
19
+
20
+
# API Keys
21
+
API_ACCESS_KEY=<Your API Access Key>
22
+
API_SECRET_KEY=<Your API Secret Key>
23
+
24
+
# OAuth
25
+
OAUTH_CLIENT_ID=<Your OAuth client id>
26
+
OAUTH_CLIENT_SECRET=<Your OAuth client secret>
27
+
SESSION_SECRET=literallyAnythingWillDo
28
+
29
+
NODE_ENV=development
30
+
FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
31
+
```
32
+
8
33
# Onshape API
9
34
10
35
A generic library for connecting with and using the Onshape API.
@@ -16,23 +41,12 @@ They are explained in more detail below.
16
41
17
42
Besides the environment variables required for each API variant, you can also set the variables:
18
43
19
-
```
20
-
API_LOGGING=true # Enable logging
21
-
API_BASE_PATH=https://cad.onshape.com # Use a different base path
22
-
API_VERSION=6 # Use a different version of the API
23
-
```
24
-
25
44
## Key API
26
45
27
46
This allows you to use the Onshape API with API keys.
28
47
29
48
1. Get an API key from the [Onshape developer portal](https://dev-portal.onshape.com/keys).
30
-
1. Add your access key and secret key to `.env`:
31
-
32
-
```
33
-
API_ACCESS_KEY=<Your access key>
34
-
API_SECRET_KEY=<Your secret key>
35
-
```
49
+
1. Add your access key and secret key to `.env`.
36
50
37
51
You can then call `make_key_api()` to get an `Api` instance you can pass to endpoints or invoke directly.
38
52
@@ -62,42 +76,119 @@ Install `pipx`:
62
76
```
63
77
sudo apt install pipx
64
78
pipx ensurepath
79
+
```
80
+
81
+
The use `pipx` to install poetry and install the project:
82
+
83
+
```
65
84
pipx install poetry
85
+
poetry install
86
+
```
87
+
88
+
## Scripts
89
+
90
+
Several scripts for pulling code from Onshape and pushing new versions of Robot FeatureScripts are included in `scripts`. Scripts can be invoked as follows:
91
+
92
+
```
93
+
./scripts/onshape.sh
66
94
```
67
95
96
+
The following scripts are available:
97
+
98
+
- deploy - Deploys the Robot manager app to google cloud.
99
+
- onshape - Can be used to push and pull code from Onshape via the API.
100
+
- robot - Can be used to release new versions of Robot FeatureScripts.
101
+
68
102
# Robot Manager
69
103
70
104
The Robot manager app lives in the `frontend` and `backend` folders. The app uses Python and flask as the backend and API and Vite and React for the frontend. The app is deployed using Google Cloud App Engine, with Google Cloud Firestore as the database.
71
105
72
-
## Robot Manager Setup
106
+
## Onshape App Setup
107
+
108
+
To test Onshape app changes, you will need to create an OAuth application in the [Onshape Developer Portal](https://cad.onshape.com/appstore/dev-portal/oauthApps). Fill out the following information:
You'll need to create a store entry in Onshape and generate secure certificates for the python dev server so Onshape will connect with it in your dev environment.
130
+
### Flask Credentials Setup
75
131
76
-
Use the `Launch servers` task to launch the dev servers necessary to view the app. You should set up Onshape to connect to:
132
+
Onshape requires all apps, even temporary test apps, to use https. This creates a headache for local development.
133
+
In order to solve this issue, you'll need to generate a certificate and add it to a folder named `credentials` in the root of this project:
77
134
78
135
```
79
-
https://localhost:3000/app
136
+
/credentials/cert.pem
137
+
/credentials/key.pem
138
+
```
139
+
140
+
This can be done automatically by running the script `make_credentials.sh`:
141
+
142
+
```
143
+
./scripts/make_credentials.sh
144
+
```
145
+
146
+
You'll then need to add a security exception to your browser to avoid getting blocked by a security exception.
147
+
On Firefox, the procedure is:
148
+
149
+
1. Start the development servers using the `Launch servers` VSCode task.
150
+
2. Open Firefox and go to `Settings > Certificates > View Certificates... > Servers > Add Exception...`
151
+
3. Enter `https://localhost:3000` as the Location and click `Get Certificate`.
152
+
4. Check `Permanently store this exception` and then click `Confirm Security Exception`.
153
+
154
+
## Frontend Setup
155
+
156
+
Install Node.js, then use npm to install the dependencies in `frontend`:
157
+
158
+
```
159
+
cd frontend
160
+
npm install
80
161
```
81
162
82
163
## Google Cloud Dev Setup
83
164
84
165
To emulate the google cloud database locally, you'll need to install the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install#deb).
85
166
167
+
You should also install the firestore emulator and a Java JRE:
To enable python to connect to the emulator, add the variable `FIRESTORE_EMULATOR_HOST` to `.env` with the value `127.0.0.1:8080`.
93
-
94
179
<!-- Then restart the distro. This prevents google cloud from using the google cloud version located outside of WSL. -->
95
180
96
181
Note: this project uses Google Cloud Firestore as it's database. This is not to be confused with Google Firebase's Firestore, as Firebase is a separate project from Google Cloud.
97
182
98
-
## Deploying in Google Cloud
183
+
## Development Servers
184
+
185
+
Run the `Launch servers` VSCode task to launch the dev servers necessary to view and test the app.
186
+
If everything is setup properly, you should see all three servers start successfully.
187
+
You should also be able to launch Robot Manager from the right panel of any Onshape Part Studio or Assembly and see the Robot manager UI appear.
188
+
189
+
# Deploying in Google Cloud
99
190
100
-
The app can be deployed using the google cloud CLI - `gcloud app deploy`.
191
+
The app can be deployed by running the script `./scripts/deploy.sh`.
0 commit comments