Skip to content

Commit

Permalink
Initial Template Generation
Browse files Browse the repository at this point in the history
  • Loading branch information
thechriskent committed Aug 29, 2017
1 parent 2a939de commit d4fb682
Show file tree
Hide file tree
Showing 20 changed files with 342 additions and 0 deletions.
25 changes: 25 additions & 0 deletions samples/js-command-clone/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# change these settings to your own preference
indent_style = space
indent_size = 2

# we recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{package,bower}.json]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions samples/js-command-clone/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
32 changes: 32 additions & 0 deletions samples/js-command-clone/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
solution
temp
*.sppkg

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
14 changes: 14 additions & 0 deletions samples/js-command-clone/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Folders
.vscode
coverage
node_modules
sharepoint
src
temp

# Files
*.csproj
.git*
.yo-rc.json
gulpfile.js
tsconfig.json
8 changes: 8 additions & 0 deletions samples/js-command-clone/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@microsoft/generator-sharepoint": {
"version": "1.1.3",
"libraryName": "js-command-clone",
"libraryId": "f1506103-545d-4ec5-abdc-b9cce96df092",
"environment": "spo"
}
}
26 changes: 26 additions & 0 deletions samples/js-command-clone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## js-command-clone

This is where you include your WebPart documentation.

### Building the code

```bash
git clone the repo
npm i
npm i -g gulp
gulp
```

This package produces the following:

* lib/* - intermediate-stage commonjs build artifacts
* dist/* - the bundled script, along with other resources
* deploy/* - all resources which should be uploaded to a CDN.

### Build options

gulp clean - TODO
gulp test - TODO
gulp serve - TODO
gulp bundle - TODO
gulp package-solution - TODO
13 changes: 13 additions & 0 deletions samples/js-command-clone/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"entries": [
{
"entry": "./lib/extensions/spfxClone/SpfxCloneCommandSet.js",
"manifest": "./src/extensions/spfxClone/SpfxCloneCommandSet.manifest.json",
"outputPath": "./dist/spfx-clone.bundle.js"
}
],
"externals": {},
"localizedResources": {
"spfxCloneStrings": "extensions/spfxClone/loc/{locale}.js"
}
}
3 changes: 3 additions & 0 deletions samples/js-command-clone/config/copy-assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployCdnPath": "temp/deploy"
}
6 changes: 6 additions & 0 deletions samples/js-command-clone/config/deploy-azure-storage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "js-command-clone",
"accessKey": "<!-- ACCESS KEY -->"
}
11 changes: 11 additions & 0 deletions samples/js-command-clone/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"solution": {
"name": "js-command-clone-client-side-solution",
"id": "f1506103-545d-4ec5-abdc-b9cce96df092",
"version": "1.0.0.0",
"skipFeatureDeployment": true
},
"paths": {
"zippedPackage": "solution/js-command-clone.sppkg"
}
}
9 changes: 9 additions & 0 deletions samples/js-command-clone/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"port": 4321,
"initialPage": "https://localhost:5432/workbench",
"https": true,
"api": {
"port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
}
}
45 changes: 45 additions & 0 deletions samples/js-command-clone/config/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Display errors as warnings
"displayAsWarning": true,
// The TSLint task may have been configured with several custom lint rules
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
// project). If true, this flag will deactivate any of these rules.
"removeExistingRules": true,
// When true, the TSLint task is configured with some default TSLint "rules.":
"useDefaultConfigAsBase": false,
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
// which are active, other than the list of rules below.
"lintConfig": {
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-case": true,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-unused-imports": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"valid-typeof": true,
"variable-name": false,
"whitespace": false
}
}
}
3 changes: 3 additions & 0 deletions samples/js-command-clone/config/write-manifests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cdnBasePath": "<!-- PATH TO CDN -->"
}
6 changes: 6 additions & 0 deletions samples/js-command-clone/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');

build.initialize(gulp);
28 changes: 28 additions & 0 deletions samples/js-command-clone/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "js-command-clone",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"@microsoft/sp-core-library": "~1.1.0",
"@microsoft/sp-webpart-base": "~1.1.1",
"@types/webpack-env": ">=1.12.1 <1.14.0",
"@microsoft/sp-listview-extensibility": "0.1.1",
"@microsoft/sp-application-base": "1.1.1"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.1.0",
"@microsoft/sp-module-interfaces": "~1.1.1",
"@microsoft/sp-webpart-workbench": "~1.1.0",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",

"id": "d2b98569-65e0-4e75-b7b9-5e3964cd8e5f",
"alias": "SpfxCloneCommandSet",
"componentType": "Extension",
"extensionType": "ListViewCommandSet",

// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,

// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,

"commands": {
"spfxClone": {
"title": "Clone",
"iconImageUrl": "icons/request.png"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { override } from '@microsoft/decorators';
import { Log } from '@microsoft/sp-core-library';
import {
BaseListViewCommandSet,
IListViewCommandSetRefreshEventParameters,
IListViewCommandSetExecuteEventParameters
} from '@microsoft/sp-listview-extensibility';

import * as strings from 'spfxCloneStrings';

/**
* If your command set uses the ClientSideComponentProperties JSON input,
* it will be deserialized into the BaseExtension.properties object.
* You can define an interface to describe it.
*/
export interface ISpfxCloneCommandSetProperties {
// This is an example; replace with your own property
disabledCommandIds: string[];
}

const LOG_SOURCE: string = 'SpfxCloneCommandSet';

export default class SpfxCloneCommandSet
extends BaseListViewCommandSet<ISpfxCloneCommandSetProperties> {

@override
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, 'Initialized SpfxCloneCommandSet');
return Promise.resolve<void>();
}

@override
public onRefreshCommand(event: IListViewCommandSetRefreshEventParameters): void {
event.visible = true; // assume true by default

if (this.properties.disabledCommandIds) {
if (this.properties.disabledCommandIds.indexOf(event.commandId) >= 0) {
Log.info(LOG_SOURCE, 'Hiding command ' + event.commandId);
event.visible = false;
}
}
}

@override
public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
switch (event.commandId) {
case 'COMMAND_1':
alert(`Clicked ${strings.Command1}`);
break;
case 'COMMAND_2':
alert(`Clicked ${strings.Command2}`);
break;
default:
throw new Error('Unknown command');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define([], function() {
return {
"Command1": "Command 1",
"Command2": "Command 2"
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare interface ISpfxCloneStrings {
Command1: string;
Command2: string;
}

declare module 'spfxCloneStrings' {
const strings: ISpfxCloneStrings;
export = strings;
}
16 changes: 16 additions & 0 deletions samples/js-command-clone/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"types": [
"es6-promise",
"es6-collections",
"webpack-env"
]
}
}

0 comments on commit d4fb682

Please sign in to comment.