From 77e7a09361e4653cd62d70d7f888e7733eac4bec Mon Sep 17 00:00:00 2001 From: Denis Molodtsov Date: Fri, 11 Mar 2022 16:05:30 -0500 Subject: [PATCH] remote container for react-mobx --- .../.devcontainer/devcontainer.json | 39 +++++++++++++++++++ .../react-mobx/.devcontainer/spfx-startup.sh | 31 +++++++++++++++ samples/react-mobx/README.md | 7 +++- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 samples/react-mobx/.devcontainer/devcontainer.json create mode 100644 samples/react-mobx/.devcontainer/spfx-startup.sh diff --git a/samples/react-mobx/.devcontainer/devcontainer.json b/samples/react-mobx/.devcontainer/devcontainer.json new file mode 100644 index 000000000..ef7afb631 --- /dev/null +++ b/samples/react-mobx/.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 0.4.0", + "image": "docker.io/m365pnp/spfx:0.4.0", + // 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, + 5432 + ], + "portsAttributes": { + "4321": { + "protocol": "https", + "label": "Manifest", + "onAutoForward": "silent", + "requireLocalPort": true + }, + "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-mobx/.devcontainer/spfx-startup.sh b/samples/react-mobx/.devcontainer/spfx-startup.sh new file mode 100644 index 000000000..ca531bdf2 --- /dev/null +++ b/samples/react-mobx/.devcontainer/spfx-startup.sh @@ -0,0 +1,31 @@ +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 + + +cp ~/.gcb-serve-data/gcb-serve.cer ./spfx-dev-cert.cer +cp ~/.gcb-serve-data/gcb-serve.cer ./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-mobx/README.md b/samples/react-mobx/README.md index 3ac83f34a..841ead19a 100644 --- a/samples/react-mobx/README.md +++ b/samples/react-mobx/README.md @@ -34,6 +34,7 @@ Sample web part implementation that uses [Mobx](https://github.com/mobxjs/mobx) ![Compatible with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Compatible-green.svg) ![Local Workbench Compatible](https://img.shields.io/badge/Local%20Workbench-Compatible-green.svg) ![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg) +![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg) ## Applies to @@ -55,13 +56,17 @@ Version|Date|Comments ## Minimal Path to Awesome -```sh +``` + +> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit https://aka.ms/spfx-devcontainer for further instructions.sh $ git clone https://github.com/pnp/sp-dev-fx-webparts $ cd sp-dev-fx-webparts/samples/react-mobx $ npm install $ gulp serve ``` +> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit https://aka.ms/spfx-devcontainer for further instructions. + ## Features * Presentational (dumb) components live in `./components`