From 77e3d76fcf1cf27648f34b8897c15bb1ec936efe Mon Sep 17 00:00:00 2001 From: Hugo Bernier Date: Wed, 8 Feb 2023 23:44:25 -0500 Subject: [PATCH] Added sample.json and container --- .../.devcontainer/devcontainer.json | 39 +++++++++++ .../.devcontainer/spfx-startup.sh | 33 +++++++++ samples/react-chat-gpt/README.md | 28 ++------ samples/react-chat-gpt/assets/sample.json | 69 +++++++++++++++++++ 4 files changed, 145 insertions(+), 24 deletions(-) create mode 100644 samples/react-chat-gpt/.devcontainer/devcontainer.json create mode 100644 samples/react-chat-gpt/.devcontainer/spfx-startup.sh create mode 100644 samples/react-chat-gpt/assets/sample.json diff --git a/samples/react-chat-gpt/.devcontainer/devcontainer.json b/samples/react-chat-gpt/.devcontainer/devcontainer.json new file mode 100644 index 000000000..d0df53099 --- /dev/null +++ b/samples/react-chat-gpt/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer +{ + "name": "SPFx 1.16.1", + "image": "docker.io/m365pnp/spfx:1.16.1", + // Set *default* container specific settings.json values on container create. + "settings": {}, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint" + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 4321, + 35729 + ], + "portsAttributes": { + "4321": { + "protocol": "https", + "label": "Manifest", + "onAutoForward": "silent", + "requireLocalPort": true + }, + // Not needed for SPFx>= 1.12.1 + // "5432": { + // "protocol": "https", + // "label": "Workbench", + // "onAutoForward": "silent" + // }, + "35729": { + "protocol": "https", + "label": "LiveReload", + "onAutoForward": "silent", + "requireLocalPort": true + } + }, + "postCreateCommand": "bash .devcontainer/spfx-startup.sh", + "remoteUser": "node" +} \ No newline at end of file diff --git a/samples/react-chat-gpt/.devcontainer/spfx-startup.sh b/samples/react-chat-gpt/.devcontainer/spfx-startup.sh new file mode 100644 index 000000000..456d6aea8 --- /dev/null +++ b/samples/react-chat-gpt/.devcontainer/spfx-startup.sh @@ -0,0 +1,33 @@ +echo +echo -e "\e[1;94mInstalling Node dependencies\e[0m" +npm install + +## commands to create dev certificate and copy it to the root folder of the project +echo +echo -e "\e[1;94mGenerating dev certificate\e[0m" +gulp trust-dev-cert + +# Convert the generated PEM certificate to a CER certificate +openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer + +# Copy the PEM ecrtificate for non-Windows hosts +cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem + +## add *.cer to .gitignore to prevent certificates from being saved in repo +if ! grep -Fxq '*.cer' ./.gitignore + then + echo "# .CER Certificates" >> .gitignore + echo "*.cer" >> .gitignore +fi + +## add *.pem to .gitignore to prevent certificates from being saved in repo +if ! grep -Fxq '*.pem' ./.gitignore + then + echo "# .PEM Certificates" >> .gitignore + echo "*.pem" >> .gitignore +fi + +echo +echo -e "\e[1;92mReady!\e[0m" + +echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********" \ No newline at end of file diff --git a/samples/react-chat-gpt/README.md b/samples/react-chat-gpt/README.md index 2f99bf35a..bf6f9b179 100644 --- a/samples/react-chat-gpt/README.md +++ b/samples/react-chat-gpt/README.md @@ -2,7 +2,7 @@ ## Summary -This webpart uses Chat GPT in an SPFx webpart. You can ask questions from the web part and you will see the answers, most recent answers first. +This webpart uses Chat GPT in an SPFx web part. You can ask questions from the web part and you will see the answers, most recent answers first. ![Example animated screen](assets/chatgpt.gif) @@ -52,18 +52,6 @@ You must then enter this api key in the web part properties ## Minimal path to awesome - * Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-chat-gpt) then unzip it) * From your command line, change your current directory to the directory containing this sample (`react-chat-gpt`, located under `samples`) @@ -73,14 +61,6 @@ As tempting as it may be, don't just use images to describe the steps. Let's be > This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit for further instructions. -## Features - -Description of the web part with possible additional details than in short summary. -This Web Part illustrates the following concepts on top of the SharePoint Framework: - -* topic 1 -* topic 2 -* topic 3 ## Help @@ -92,11 +72,11 @@ You can try looking at [issues related to this sample](https://github.com/pnp/sp You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-chat-gpt) and see what the community is saying. -If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-chat-gpt&template=bug-report.yml&sample=react-chat-gpt&authors=@YOURGITHUBUSERNAME&title=react-chat-gpt%20-%20). +If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-chat-gpt&template=bug-report.yml&sample=react-chat-gpt&authors=@nicodecleyre&title=react-chat-gpt%20-%20). -For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-chat-gpt&template=question.yml&sample=react-chat-gpt&authors=@YOURGITHUBUSERNAME&title=react-chat-gpt%20-%20). +For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-chat-gpt&template=question.yml&sample=react-chat-gpt&authors=@nicodecleyre&title=react-chat-gpt%20-%20). -Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-chat-gpt&template=suggestion.yml&sample=react-chat-gpt&authors=@YOURGITHUBUSERNAME&title=react-chat-gpt%20-%20). +Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-chat-gpt&template=suggestion.yml&sample=react-chat-gpt&authors=@nicodecleyre&title=react-chat-gpt%20-%20). ## Disclaimer diff --git a/samples/react-chat-gpt/assets/sample.json b/samples/react-chat-gpt/assets/sample.json new file mode 100644 index 000000000..8c8e0d443 --- /dev/null +++ b/samples/react-chat-gpt/assets/sample.json @@ -0,0 +1,69 @@ +[ + { + "name": "pnp-sp-dev-spfx-web-parts-react-chat-gpt", + "source": "pnp", + "title": "Chat GPT inside SPFx", + "shortDescription": "This webpart uses Chat GPT in an SPFx web part. You can ask questions from the web part and you will see the answers, most recent answers first.", + "url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-chat-gpt", + "downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-chat-gpt", + "longDescription": [ + "This webpart uses Chat GPT in an SPFx web part. You can ask questions from the web part and you will see the answers, most recent answers first." + ], + "creationDateTime": "2023-02-04", + "updateDateTime": "2023-02-04", + "products": [ + "SharePoint" + ], + "metadata": [ + { + "key": "CLIENT-SIDE-DEV", + "value": "React" + }, + { + "key": "SPFX-VERSION", + "value": "1.16.1" + } + ], + "thumbnails": [ + { + "type": "image", + "order": 100, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-chat-gpt/assets/example2.png", + "alt": "Web Part Preview" + }, + { + "type": "image", + "order": 101, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-chat-gpt/assets/example.png", + "alt": "Web Part Preview" + }, + { + "type": "image", + "order": 102, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-chat-gpt/assets/example3.png", + "alt": "Web Part Preview" + }, + { + "type": "image", + "order": 103, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-chat-gpt/assets/chatgpt.gif", + "alt": "Web Part Preview" + } + + ], + "authors": [ + { + "gitHubAccount": "nicodecleyre", + "pictureUrl": "https://github.com/nicodecleyre.png", + "name": "Nico De Cleyre" + } + ], + "references": [ + { + "name": "Build your first SharePoint client-side web part", + "description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.", + "url": "https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part" + } + ] + } +]