# WI-240089-Application and Program Development on the R Platform (v3.0) (NOTES)
<!-- the images for this file are in the draw.io file titled, rstudio-app-dev-WI-240089.drawio -->
## Procedure
The overall process flow of R Shiny application (App) or R program development is captured in the process flowcharts in appendix A & B of this document. The detailed description of each process step is described in the sections below.
### 1. Initial Account Setup
#### 1.1. Log in to https://git.bmrn.com/. If you don’t have access to URL, please contact your R App Manager for approval.
> **NOTE:** consider adding, "Use BioMarin login information to get access to GitLab. Your profile settings should look something like this:"

#### 1.2. Log in to the RStudio Connect by navigating to the login URL in the table in Appendix C for the appropriate environment using a compatible web browser. If you do not have a compatible web browser, use a web browser within the Citrix SAS System Desktop to access the RStudio Server IDE.
> Chrome was used in this example, but Edge will also work.
#### 1.3. Log in to the RStudio Server IDE by navigating to the login URL in the table in Appendix C for the appropriate environment using a compatible web browser. If you do not have a compatible web browser, use a web browser within the Citrix SAS System Desktop to access the RStudio Server IDE.
> **NOTE:** consider adding,
- RStudio Workbench Development Server
- https://aceshiny-dev.bmrn.com/rstudio/
- RStudio Workbench UAT Server
- https://aceshiny-uat.bmrn.com/rstudio/
- RStudio Workbench Production Server
- https://aceshiny.bmrn.com/rstudio/
> **NOTE:** consider adding, "When signing into a new session, you will be prompted to log in with your username and password:"

#### 1.4. Start a new session, if prompted.
> **NOTE:** consider adding,

#### 1.5. The first logging into the development (DEV) instances, steps 1.6 to 1.22 should be completed.
> **NOTE:** consider adding,

## 1.?? Configuring Git
The first-time logging into QA or PROD, steps 1.6 to 1.22 should be completed. Proceed to section 3 on all subsequent.
#### 1.6. Configure your local git settings by running in the RStudio Server IDE Terminal:
```bash=
git config --global user.name "<Developer Name>"
git config --global user.email "<Developer BioMarin Email Address>"
git config --global log.abbrevcommit yes
git config --global log.date rfc2822
```
example command:
```bash=
git config --global user.name "Martin Frigaard"
git config --global user.email "ma904058@bmrn.com"
git config --global log.abbrevcommit yes
git config --global log.date rfc2822
```
> **NOTE:** consider adding, "Check the global settings by running `git config --list`"
```bash=
[ma904058@bmnsa04a ~]$ git config --list
user.name=Martin Frigaard
user.email=ma904058@bmrn.com
push.default=matching
credential.helper=cache
```
#### 1.7. Create an SSH Key by running: `ssh-keygen` using all the default values.
```bash=
ssh-keygen
```
> **NOTE:** consider adding, "1.7.1 Accept the proposal to save the key in the default location (press Enter)""
```
Enter file in which to save the key (/path/to/.ssh/<id_rsa.pub>):
```
> **NOTE:** consider adding, "1.7.2 Leave the passphrase empty (it's optional)"
```
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
```
> **NOTE:** consider adding, "When the keygen is created, you'll see something *like* the following:"
```
Your identification has been saved in /path/to/.ssh/<id_rsa.pub>.
Your public key has been saved in /path/to/.ssh/<id_rsa.pub>.
The key fingerprint is:
SHA256:XUEaY/elhcQJz3M9jx/SdC0zh10lCA7uNpqgkm5G/R0 <user-name></user-name>
The key's randomart image is:
+--[ED25519 256]--+
| . =o==oo*|
| . + =.=+B+|
| . o . @oB|
| . . . oO+|
| . . S . ..o.|
| o o . E . ...|
|+ . . + . .|
|.+ . . |
|o. |
+----[SHA256]-----+
```
#### 1.8. Print the contents of the public SSH key by running the following command in the RStudio server IDE terminal:
> **NOTE:** consider adding, "Below is an example `id_rsa.pub` (note the email at the end!)"
```bash=
cat $HOME/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq+kVWcZVVbiLl5DUkxI0h9+m6qBfu+
rTgMH2eYWUn3KYrwNeWaCbeHLUkC2Ixy3y8HwsaE3fljfGaWH0YcK4dEV4nKoT4hVQX
+4jQyuxprXcmH/JFECgaqSh7rH6tp3Samg5TlxRRdSeB0JQOQf+y/Ifz0TE06/YP1cR
6S8SvLuze0PIIcWnizMHy3FwzvDAxA30THZ+OJ74j4ZPQjIFHSXNM+UDUOTa6H0E/7
Ab2Ab+RjPODfofUK3rYm3x62s+KNERLNDBf <username@bmnsa04a.bmrn.com>
```
#### 1.9. Copy the contents to the clipboard by selecting the output, right clicking, and selecting "Copy".
> **NOTE:** consider adding, CTRL + C will not work in the Terminial!
#### 1.10. Navigate to https://git.bmrn.com/profile/keys in a new web browser tab.
> **NOTE:** consider adding,

#### 1.11. Paste the clipboard contents into the "Key" field by right-clicking in it, and selection "Paste". Ensure the title is unique within the list on the page, if not assign a unique name.
> **NOTE:** consider adding, CTRL + P will not work in the Terminial!
> **NOTE:** consider adding,

#### 1.12. Press "add key" to add the public key to your GitLab account.
> **NOTE:** consider adding,

#### 1.13. Return to the RStudio Server IDE.
#### 1.14. Open the tools menu and navigate to the Global Settings dialog.
> **NOTE:** consider adding,

#### 1.15. Select "Publishing" and verify that an entry is present for the URL of the current environment. If so, proceed to section 3, otherwise continue.
> **NOTE:** consider adding,

##### 1.16. Click the connect button and enter the URL of the current environment, proceed with the login to RStudio Connect as prompted. If user already have "publisher" permission, proceed to step 1.20, otherwise continue.
> **NOTE:** the "*URL of the current environment*" means the base URL you used to log in (i.e. `aceshiny-dev.bmrn.com` or `aceshiny-uat.bmrn.com/`)

#### 1.17. If user needs the permission to publish, please contact RStudio Connect Software Administrator by email.
#### 1.18. Once RStudio connect software administrator received the request.
- ##### 1.18.1. Verify the user permission if user is allowed to be a publisher
- ##### 1.18.2. RStudio connect software administrator login to RStudio Connect, go to "people". Select the user and click edit
- ##### 1.18.3. Change the user role to "Publisher" and click save (Enter the administrator password if system asked)
- ##### 1.18.4. Inform user that permission is granted
#### 1.19. User received the permission granted email, back to RStudio IDE and follow the step 1.20 to 1.22.
#### 1.20. Press the “Connect” button when prompted and close the window upon success.
#### 1.21. Press the “Connect Account” button in the Verifying Account dialog box to complete the connection between RStudio Server IDE and RStudio Connect.
#### 1.22. Press OK to exit the Global Settings dialog box.
***