There are several ways in which you can contribute to the project:
- Log bugs or file feature suggestions. To do this, simply file the bugs/suggestions in the Issues tab on GitHub for this project.
- Code samples. To suggest edits to existing samples, or to suggest your own, please submit a pull request against the Samples repo: https://github.com/OfficeDev/office-js-snippets.
- Bug-fix/feature contributions. If you have features or bug fixes that you'd like to see incorporated into the playground, just send us your pull request!
- Download & Install Visual Studio Code. https://code.visualstudio.com/. If you don't have a recent version, please update to latest (1.11 at time of writing)
- I would also recommend installing the
TSLintextension, which adds lint warnings straight into the editor.
- I would also recommend installing the
- Download & install Node, version 6.9+. https://nodejs.org/en.
- Download & install Yarn, for use as an alternative for
npm install. Download from https://yarnpkg.com/en/docs/install. The documentation also describes why Yarn is preferable tonpm install. - Install
nodemonfor global use, using
yarn global add nodemon
Note: the installation of Node JS and Yarn add paths to your operating system's PATH variable. Therefore, in some cases you may log off and log in from your System to get Node JS and Yarn work withing Visual Studio Code.
-
Clone the repo
-
Open the root of the repository with VS Code. (File --> Open Folder...)

-
Open the terminal from within VS Code (View --> Integrated Terminal)

-
In the terminal, type in
yarn installand wait for all of the packages to be downloaded (this may take a few minutes). The command prompt will return the control back to you once it's done. -
Run
npm startin the terminal (orctrl+shift+band selectstartin the dropdown). The process may pause for a few seconds, and you may see messages like "compilation complete"; but don't believe it! You'll know that it's finally done when the web browser launches to https://localhost:3000, and when you see the following appear in the terminal:
[BS] Proxying: https://localhost:3100
[BS] Access URLs:
--------------------------------------
Local: https://localhost:3000
External: https://10.82.217.77:3000
--------------------------------------
UI: http://localhost:3001
UI External: http://10.82.217.77:3001
--------------------------------------
- Trust the certificates for both https://localhost:3000 and https://localhost:3100. For purposes of running add-ins on a PC, do this within Internet Explorer. See the gif below for a step-by-step animation:
- Start the runner (server) by pressing
F5within VS Code. If you get an error thatnodemonis not installed, be sure that you've installed it globallyyarn global add nodemon, and that Node is part of your path.
The website is now running. To try it out in an Add-in, see the next section.
Note: To stop debugging, first press the "stop" button on the debugger (shift + F5). You will see an error on the server terminal window (
[nodemon] app crashed - waiting for file changes before starting...); that's ok, just close that terminal instance (trash icon on top-right of terminal). If you want to restart debugging later, just re-press F5 again.
-
Locate the add-in manifest (which you'll find in the
manifestsfolder in the root of the repo). For purposes of running against localhost, usescript-lab-local.xml. -
Sideload the manifest into your office host application. See https://aka.ms/sideload-addins, which includes instructions and a step-by-step video for sideloading on the desktop, as well as links for the other platforms.
The project consists of two separate components: the client (editor) and the server (runner). When run -- both on a dev machine, and in production -- they run on two separate URLs. That way, a running snippet can never get the localStorage data (snippets, auth tokens, etc.) of the actual playground.
At the root level of the repo, the folders of interest (and skipping over the others) are:
client: This is the playground editor UI.config: Configuration related to webpack & deploymentdist: The generated files forclientandserver(it has subfolders for each), which are the compiled and minified html/js/css/etc. (TODO: Add why generate and check in, and which commands generate these files)manifests: Add-in manifests (both localhost and production) for side-loading the Add-in into Office applications.node_modules: The folder with all the node module dependencies that get installed as part ofyarn install.server: A stateless Node backend that receives a POST request with the snippet's HTML, TypeScript, CSS, and Libraries, and creates a web-browser-servable web page out of them. The server makes extensive use of Handlebars.js for templates, which are located in theserver/templatesdirectory.typings: Type definitions for a few of the libraries.
There are also files related to Azure deployment, git ignores, a Travis configuration for continuous-integration, a package.json with the project's metadata, TypeScript configuration files for client and server, a linter configuration, and etc. And of course, the project's README.
- Go to https://github.com/settings/developers, and click "Register new application" if you haven't done it before for your own dev copy of ScriptLab.
- Give it a name like "ScriptLab Local Dev", with a Homepage and Auth callback URL of
https://localhost:3000. - In
config/env.config.js, find theconst config = { ...line, and underlocal: { ..., findclientId: '', and replace withclientId: '<id-from-github>'. - In
server/server.ts, findclient_secret: secrets ? secrets[env] : '',, and replace it withsecrets ? secrets[env] : '<client-secret-from-github>'. - If the site is running, re-start it and do a new
npm start. Incremental compilation is not enough for these changes. Note, too, that you need both the site and the server (F5) running to make auth work. - Once you are done with your testing, be sure to undo both changes!.
- Create a snippet -- both "new" and from a sample
- Import someone else's snippet
- From YAML
- From Gist (incl. old-style)
- From Non-GitHub URL [Currently doesn't work, Issue #146].
- Run snippet, in both in-editor runner (Office 2016 RTM and earlier, or online, or via tweaking the manifest to remove
command=true) and via the "Run" button (run.html), testing that:- Snippet renders correctly
- "Run" from editor or run gallery, in-place refresh, and full refresh all work correctly (render the snippet, don't double-refresh, etc.). The run (either type) doesn't show a "snippet needs reloading" message if the snippet is already fresh.
- Console log renders correctly (and scrolls correctly, if many lines)
- Erroneous code (e.g, syntax error) shows error correctly.
- Running deleted snippet has reasonable behavior.
- [Side-by-side runner]:
- Edit to code causes runner want to refresh.
- Whether starting from error or going to error state and back out, should act correctly.
- Note: when running a script on localhost, you may see two compiler warnings for a critical dependency in the console log. These two warnings always appear in debug mode and are normal.
- Sharing:
- Copying to clipboard works
- Can share as gist
- There are two
package.jsonfiles, one at the global level (for the client), and one inside ofsrc\server. This can lead to differences in behavior betweenlocalhostand the deployed site, so be careful (e.g., if add one dependency in one place that should be shared, add it in both!). Their version numbers should also be bumped in synchrony. - On IE,
console.login the runner won't display anything in FirebugLite if F12 tools are open. It works fine if they're closed.
