# generator-sppp

![NPM](https://camo.githubusercontent.com/93c66ef7dd702108c6b9f030b8d854d328f496bf/68747470733a2f2f6e6f6465692e636f2f6e706d2f67656e657261746f722d737070702e706e673f6d696e693d7472756526646f776e6c6f6164733d7472756526646f776e6c6f616452616e6b3d747275652673746172733d74727565)

[![npm version](https://camo.githubusercontent.com/61df278db6d0cc63a6232581a7c2659888505c08/68747470733a2f2f62616467652e667572792e696f2f6a732f67656e657261746f722d737070702e737667)](https://badge.fury.io/js/generator-sppp) [![Downloads](https://camo.githubusercontent.com/ff5363bcc561bc340b66e166b2da5361599dbc81/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f67656e657261746f722d737070702e737667)](https://www.npmjs.com/package/generator-sppp) [![Build Status](https://camo.githubusercontent.com/7d200c3eaefe3a5e6eaa5c2f1052f08c8e82e340/68747470733a2f2f6465762e617a7572652e636f6d2f6b6f6c7479616b6f762f53504e6f64652f5f617069732f6275696c642f7374617475732f67656e657261746f722d737070703f6272616e63684e616d653d6d6173746572)](https://camo.githubusercontent.com/7d200c3eaefe3a5e6eaa5c2f1052f08c8e82e340/68747470733a2f2f6465762e617a7572652e636f6d2f6b6f6c7479616b6f762f53504e6f64652f5f617069732f6275696c642f7374617475732f67656e657261746f722d737070703f6272616e63684e616d653d6d6173746572) [![FOSSA Status](https://camo.githubusercontent.com/96b1ad6563cbb8e39806dda563a7f2d01e1a977d/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532466b6f6c7479616b6f7625324667656e657261746f722d737070702e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkoltyakov%2Fgenerator-sppp?ref=badge_shield) [![Gitter chat](https://camo.githubusercontent.com/20d7543bc8280bf8134b686c46c7b7e2c0a467fd/68747470733a2f2f6261646765732e6769747465722e696d2f67697474657248512f6769747465722e706e67)](https://gitter.im/sharepoint-node/Lobby)

Yeoman generator for SharePoint - lets you quickly set up a project with sensible defaults for pulling and pushing files between SharePoint asset library and local projects sources.

Generated project allows immediately start developing SharePoint client-side solutions in Visual Studio Code or any other editor with instant publishing changes to SharePoint web site and downloading specific assets from SP Document library folder to local project assets which can be enforced with Git Diff algorithm for tracking changes.

SPPP generated projects suite perfectly for SPA development scenarious having local serve workbench with SharePoint API proxy server intergated from OOTB. Starting a local server your app refreshes instantly on changes using hot reload and incremental build at the same time the app is fully powered with real data from the API without any extra configuration.

React, PnPjs, Office UI Fabric, TypeScript, SCSS, Linting rules, polyfills, Webpack bundling, Live server, SharePoint interactive connection, [pipeline tasks](https://github.com/koltyakov/sp-build-tasks), all of these just work from the start. The batteries are included, but maybe you need congifuration changes? No problem, just override or provide yours, or extend a task, this is a part of the design.

Don't need React or Office UI Fabric? Don't worry, these guys are installed as a presets only when you decided to.

### Development scenarious

* Webparts developement
  * classic CEWPs
  * SPA applications
* Branding
  * masterpages
  * page layouts development
* Custom actions (ScriptLink User Custom Action)
* Custom scripts and portal libraries
* Custom styles
* Direct edit assets with Git backup (like in SPD days, or [SPGo](https://marketplace.visualstudio.com/items?itemName=SiteGo.spgo) but using CLI)

### Supported SharePoint versions

* SharePoint Online
* SharePoint On-Prem (2019/2016/2013)
* SharePoint 2010 (limited support)

### How to use

#### Using NPX (without Yeoman and generator global installation)

Create and navigane to project folder then run:

```
npx -p yo -p generator-sppp -c 'yo sppp'
```

NPM v6 is required.

#### Global install (classic approach)

**Install**

To use Yeoman, one need to has Node.js and NPM installed on the computer. Basic installation process description can be found in [this blog post](https://www.linkedin.com/pulse/preparing-development-machine-client-side-sharepoint-mac-koltyakov?trk=pulse_spock-articles).

Alter Node.js and NPM are staffed, install `Gulp`, `Yeoman` and `generator-sppp` globally in your Node.js environment.

```
npm install -g gulp-cli yo generator-sppp
```

`gulp-cli` global installation can be omitted while using NPM tasks.

**Generate**

Make a new directory or clone a blank Git project of your own and navigate to the created folder.

Inside project directory execulte:

```
yo sppp
```

Then follow the the Yeoman wizard instructions:

![Generator in action](https://github.com/koltyakov/generator-sppp/raw/master/assets/sppp01.gif)

**Package managers switch**

With `--package-manager` (or `--pm`), a package manager can be selected. Possible managers are: `pnpm`, `yarm` and `npm`. `npm` is used by default and also as a fallback option.

Use `yarn`:

```
yo sppp --pm yarn
```

Use `pnpm`:

```
yo sppp --pm pnpm
```

#### Define connection with SharePoint

```
npm run connect
```

![Connect with SharePoint](https://github.com/koltyakov/generator-sppp/raw/master/assets/sppp02.gif)

#### Dev Server & API Proxy

```
npm run start
```

![Dev Server](https://github.com/koltyakov/generator-sppp/raw/master/assets/sppp03.gif)

#### Sync with SharePoint

Now you can run gulp [sppull](https://www.npmjs.com/package/sppull) task:

```
gulp pull
```

![SPPull in action](https://camo.githubusercontent.com/602bf9aa186657c35c31479f9069e876ebd3d680/687474703a2f2f6b6f6c7479616b6f762e72752f696d616765732f67656e657261746f722d737070702d64656d6f2d322e676966)

It will deliver all files from assets folder from SharePoint to local directory.

Run npm watch task before starting editing files:

```
npm run watch
```

On files change they are uploaded and published to SharePoint with use of [gulp-spsave](https://www.npmjs.com/package/gulp-spsave).

For publishing files from `./dist` folder the `publish` task can be used:

```
npm run publish
```

#### Additional Gulp tasks

Available tasks list:

```
gulp --tasks
```

**Watch changes of the assets with live reload**

```
gulp live
```

Check [sp-live-reload project page](https://github.com/koltyakov/sp-live-reload) more information.

### Tasks detail information

Please check a reference in [this wiki page](https://github.com/koltyakov/sp-build-tasks/wiki/Tasks).

### Build configuration details

SPPP is powered with `sp-build-tasks`, build configs can be found in a [wiki section](https://github.com/koltyakov/sp-build-tasks/wiki/Build-options) of the project.

![app.json settings](https://raw.githubusercontent.com/koltyakov/sp-build-tasks/master/docs/schema.gif)

### SharePoint communication layer

* [sppull](https://github.com/koltyakov/sppull) library is used for downloading files from SharePoint
* [gulp-spsave](https://github.com/s-KaiNet/gulp-spsave) library is used for saving files to SharePoint
* [sp-request](https://github.com/s-KaiNet/sp-request) and [node-sp-auth](https://github.com/s-KaiNet/node-sp-auth) are in charge for low level communication with SharePoint
* [sp-live-reload](https://github.com/koltyakov/sp-live-reload) library is used for instantaneous page reload
* [node-so-auth-config](https://github.com/koltyakov/node-so-auth-config) authentication config wizard
* [sp-build-tasks](https://github.com/koltyakov/sp-build-tasks) build tasks tool-belt

Communication layer settings are stored in `./config/private.json`, parameters settings description can be found [here](https://github.com/s-KaiNet/node-sp-auth/wiki).

### Configuring CI/CD

Checkout [this end-to-end sample](https://github.com/koltyakov/sppp-cicd-sample).

### License

[![FOSSA Status](https://camo.githubusercontent.com/bdf5d379f290731b53b4763dee17406667303c0c/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532466b6f6c7479616b6f7625324667656e657261746f722d737070702e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkoltyakov%2Fgenerator-sppp?ref=badge_large)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://node.spflow.com/packages/generator-sppp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
