Merge pull request #1621 from joaojmendes/react-mgtEvents

This commit is contained in:
Hugo Bernier 2020-12-02 00:03:17 -05:00 committed by GitHub
commit 01d5bce090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 21071 additions and 0 deletions

View File

@ -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

32
samples/react-mgtEvents/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,32 @@
{
"@pnp/generator-spfx": {
"framework": "react",
"pnpFramework": "reactjs.plus",
"pnp-libraries": [
"jquery@3",
"msgraph",
"msgt",
"@pnp/spfx-property-controls",
"spfx-uifabric-themes",
"lodash",
"@pnp/spfx-controls-react",
"ouifr@7",
"rush@3.9"
],
"pnp-ci": "no-devops",
"pnp-vetting": [],
"spfxenv": "spo",
"pnp-testing": []
},
"@microsoft/generator-sharepoint": {
"environment": "spo",
"framework": "react",
"isCreatingSolution": true,
"version": "1.11.0",
"libraryName": "react-mgt-events",
"libraryId": "65598f27-b91c-49f8-a571-379966dde996",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
}
}

View File

@ -0,0 +1,46 @@
# React-mgtEvents
## Summary
This sample shows how to use Microsoft Graph Toolkit in SPFx and custom with Fluent UI Fabric Controls
## ScreenShots
![mgtEvents](./assets/mhtEvents.JPG)
## Used SharePoint Framework Version
![SPFx 1.11.0](https://img.shields.io/badge/spfx-1.11.0-green.svg)
## Applies to
* [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
* [Office 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
## Solution
Solution|Author(s)
--------|---------
react-mgtEvents | João Mendes
## Version history
Version|Date|Comments
-------|----|--------
1.0|November 29, 2020|Initial release
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
---
## Minimal Path to Awesome
If you have not previously granted the required Microsoft Graph permissions, you need to:
- Run `gulp bundle --ship`
- Run `gulp package-solution --ship`
- Install the `.sppkg` file (under `.\sharepoint\solution`) to the SP app catalog
- Approve the API permissions in the new SP admin center
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-mgtEvents" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -0,0 +1,20 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"mgt-events-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/mgtEvents/MgtEventsWebPart.js",
"manifest": "./src/webparts/mgtEvents/MgtEventsWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"MgtEventsWebPartStrings": "lib/webparts/mgtEvents/loc/{locale}.js",
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"
}
}

View File

@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
"deployCdnPath": "temp/deploy"
}

View File

@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-mgt-events",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,35 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-mgt-events-client-side-solution",
"id": "65598f27-b91c-49f8-a571-379966dde996",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": ""
},
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Calendars.Read"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read"
},
{
"resource": "Microsoft Graph",
"scope": "Presence.Read"
}
]
},
"paths": {
"zippedPackage": "solution/react-mgt-events.sppkg"
}
}

View File

@ -0,0 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://localhost:5432/workbench",
"api": {
"port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
}
}

View File

@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}

29
samples/react-mgtEvents/gulpfile.js vendored Normal file
View File

@ -0,0 +1,29 @@
'use strict';
// check if gulp dist was called
if (process.argv.indexOf('dist') !== -1) {
// add ship options to command call
process.argv.push('--ship');
}
const path = require('path');
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const gulpSequence = require('gulp-sequence');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
// Create clean distrubution package
gulp.task('dist', gulpSequence('clean', 'bundle', 'package-solution'));
// Create clean development package
gulp.task('dev', gulpSequence('clean', 'bundle', 'package-solution'));
/**
* Custom Framework Specific gulp tasks
*/
build.initialize(gulp);

20136
samples/react-mgtEvents/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
{
"name": "react-mgt-events",
"version": "0.0.1",
"private": true,
"main": "lib/index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test",
"preversion": "node ./tools/pre-version.js",
"postversion": "gulp dist"
},
"dependencies": {
"@microsoft/mgt-react": "^2.0.0-preview.6",
"@microsoft/sp-core-library": "1.11.0",
"@microsoft/sp-lodash-subset": "1.11.0",
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
"@microsoft/sp-property-pane": "1.11.0",
"@microsoft/sp-webpart-base": "1.11.0",
"@pnp/spfx-controls-react": "1.19.0",
"@pnp/spfx-property-controls": "1.19.0",
"@types/jquery": "^3.5.0",
"date-fn": "0.0.2",
"date-fns": "^2.16.1",
"jquery": "^3.5.1",
"office-ui-fabric-react": "^7.123.1",
"react": "16.8.5",
"react-dom": "16.8.5"
},
"devDependencies": {
"@microsoft/mgt": "^1.3.5",
"@microsoft/microsoft-graph-types": "^1.12.0",
"@microsoft/rush-stack-compiler-3.9": "^0.4.x",
"@microsoft/sp-build-web": "1.11.0",
"@microsoft/sp-module-interfaces": "1.11.0",
"@microsoft/sp-tslint-rules": "1.11.0",
"@microsoft/sp-webpart-workbench": "1.11.0",
"@types/chai": "3.4.34",
"@types/es6-promise": "0.0.33",
"@types/mocha": "2.2.38",
"@types/react": "^16.9.43",
"@types/react-dom": "16.8.3",
"@types/webpack-env": "1.13.1",
"ajv": "~5.2.2",
"gulp": "~3.9.1",
"gulp-sequence": "1.0.0",
"lodash": "^4.17.15",
"spfx-uifabric-themes": "^0.8.0",
"typescript": "~3.9.x"
}
}

View File

@ -0,0 +1,24 @@
{
"themePrimary": "#6264a7",
"themeLighterAlt": "#f7f7fb",
"themeLighter": "#e1e1f1",
"themeLight": "#c8c9e4",
"themeTertiary": "#989ac9",
"themeSecondary": "#7173b0",
"themeDarkAlt": "#585a95",
"themeDark": "#4a4c7e",
"themeDarker": "#37385d",
"neutralLighterAlt": "#0b0b0b",
"neutralLighter": "#151515",
"neutralLight": "#252525",
"neutralQuaternaryAlt": "#2f2f2f",
"neutralQuaternary": "#373737",
"neutralTertiaryAlt": "#595959",
"neutralTertiary": "#c8c8c8",
"neutralSecondary": "#d0d0d0",
"neutralPrimaryAlt": "#dadada",
"neutralPrimary": "#ffffff",
"neutralDark": "#f4f4f4",
"black": "#f8f8f8",
"white": "#000000"
}

View File

@ -0,0 +1,24 @@
{
"themePrimary": "#6264a7",
"themeLighterAlt": "#f7f7fb",
"themeLighter": "#e1e1f1",
"themeLight": "#c8c9e4",
"themeTertiary": "#989ac9",
"themeSecondary": "#7173b0",
"themeDarkAlt": "#585a95",
"themeDark": "#4a4c7e",
"themeDarker": "#37385d",
"neutralLighterAlt": "#2d2c2c",
"neutralLighter": "#2c2b2b",
"neutralLight": "#2a2929",
"neutralQuaternaryAlt": "#272626",
"neutralQuaternary": "#252525",
"neutralTertiaryAlt": "#242323",
"neutralTertiary": "#c8c8c8",
"neutralSecondary": "#d0d0d0",
"neutralPrimaryAlt": "#dadada",
"neutralPrimary": "#ffffff",
"neutralDark": "#f4f4f4",
"black": "#f8f8f8",
"white": "#2d2c2c"
}

View File

@ -0,0 +1,24 @@
{
"themePrimary": "#6264a7",
"themeLighterAlt": "#f7f7fb",
"themeLighter": "#e1e1f1",
"themeLight": "#c8c9e4",
"themeTertiary": "#989ac9",
"themeSecondary": "#7173b0",
"themeDarkAlt": "#585a95",
"themeDark": "#4a4c7e",
"themeDarker": "#37385d",
"neutralLighterAlt": "#ecebe9",
"neutralLighter": "#e8e7e6",
"neutralLight": "#dedddc",
"neutralQuaternaryAlt": "#cfcecd",
"neutralQuaternary": "#c6c5c4",
"neutralTertiaryAlt": "#bebdbc",
"neutralTertiary": "#b5b4b2",
"neutralSecondary": "#9d9c9a",
"neutralPrimaryAlt": "#868482",
"neutralPrimary": "#252423",
"neutralDark": "#565453",
"black": "#3e3d3b",
"white": "#f3f2f1"
}

View File

@ -0,0 +1,28 @@
export const currentSiteTheme = window["__themeState__"];
export const outLookCategorieColors: { [key: string]: string } = {
preset0: "Red",
preset1: "Orange",
preset2: "Brown",
preset3: "Yellow",
preset4: "Green",
preset5: "Teal",
preset6: "Olive",
preset7: "Blue",
preset8: "Purple",
preset9: "Cranberry",
preset10: "Steel",
preset11: "DarkSteel",
preset12: "Gray",
preset13: "DarkGray",
preset14: "Black",
preset15: "DarkRed",
preset16: "DarkOrange",
preset17: "DarkBrown",
preset18: "#9B870C",
preset19: "DarkGreen",
preset20: "DarkTeal",
preset21: "DarkOlive",
preset22: "DarkBlue",
preset23: "DarkPurple",
preset24: "DarkCranberry",
};

View File

@ -0,0 +1,17 @@
$default-background: #f3f2f1;
$default-color: #252423;
$default-button-background: #6264a7;
$default-Button-color: #f3f2f1;
// dark theme
$dark-background: #2d2c2c;
$dark-color: #ffffff;
$dark-button-background: #6264a7;
$dark-button-color: #2d2c2c;
// contrast theme
$contrast-background: #000000;
$contrast-color: #ffffff;
$contrast-button-background: #b5c01c;
$contrast-Button-color: #000000;

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -0,0 +1,30 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "03fe68f7-84ef-46a7-8210-d47a1c911d69",
"alias": "MgtEventsWebPart",
"componentType": "WebPart",
"supportsThemeVariants": true,
"supportsFullBleed": true,
// 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,
"supportedHosts": ["SharePointWebPart", "SharePointFullPage","TeamsPersonalApp","TeamsTab"],
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
"group": { "default": "Other" },
"title": { "default": "mgtEvents" },
"description": { "default": "mgtEvents description" },
"officeFabricIconFontName": "Page",
"properties": {
"title": "My Events",
"numberDays": 8
}
}]
}

View File

@ -0,0 +1,151 @@
import * as React from "react";
import * as ReactDom from "react-dom";
import * as strings from "MgtEventsWebPartStrings";
import { loadTheme } from "office-ui-fabric-react/lib/Styling";
import {
Providers,
SharePointProvider
} from "@microsoft/mgt";
import {
IReadonlyTheme,
ThemeChangedEventArgs,
ThemeProvider
} from "@microsoft/sp-component-base";
import { Version } from "@microsoft/sp-core-library";
import {
IPropertyPaneConfiguration,
PropertyPaneSlider,
PropertyPaneTextField
} from "@microsoft/sp-property-pane";
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
import { IMgtEventsProps } from "./components/IMgtEventsProps";
import { MgtEvents } from "./components/MgtEvents";
export interface IMgtEventsWebPartProps {
title: string;
numberDays: number;
}
const teamsDefaultTheme = require("../../common/TeamsDefaultTheme.json");
const teamsDarkTheme = require("../../common/TeamsDarkTheme.json");
const teamsContrastTheme = require("../../common/TeamsContrastTheme.json");
export default class MgtEventsWebPart extends BaseClientSideWebPart<IMgtEventsWebPartProps> {
private _themeProvider: ThemeProvider;
private _themeVariant: IReadonlyTheme | undefined;
protected async onInit(): Promise<void> {
Providers.globalProvider = new SharePointProvider(this.context);
this._themeProvider = this.context.serviceScope.consume(
ThemeProvider.serviceKey
);
// If it exists, get the theme variant
this._themeVariant = this._themeProvider.tryGetTheme();
// Register a handler to be notified if the theme variant changes
this._themeProvider.themeChangedEvent.add(
this,
this._handleThemeChangedEvent
);
if (this.context.sdks.microsoftTeams) {
// in teams ?
const context = this.context.sdks.microsoftTeams!.context;
this._applyTheme(context.theme || "default");
this.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler(
this._applyTheme
);
}
return Promise.resolve();
}
/**
* Update the current theme variant reference and re-render.
*
* @param args The new theme
*/
private _handleThemeChangedEvent(args: ThemeChangedEventArgs): void {
this._themeVariant = args.theme;
this.render();
}
protected get disableReactivePropertyChanges():boolean {
return true;
}
// Apply btheme id in Teams
private _applyTheme = (theme: string): void => {
this.context.domElement.setAttribute("data-theme", theme);
document.body.setAttribute("data-theme", theme);
if (theme == "dark") {
loadTheme({
palette: teamsDarkTheme,
});
}
if (theme == "default") {
loadTheme({
palette: teamsDefaultTheme,
});
}
if (theme == "contrast") {
loadTheme({
palette: teamsContrastTheme,
});
}
}
public render(): void {
const element: React.ReactElement<IMgtEventsProps> = React.createElement(
MgtEvents,
{
title: this.properties.title,
themeVariant: this._themeVariant,
serviceScope: this.context.serviceScope,
numberDays: this.properties.numberDays,
}
);
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('title', {
label: strings.DescriptionFieldLabel
}),
PropertyPaneSlider('numberDays', {
min: 8,
max: 180,
label: 'Number of days to show',
value: this.properties.numberDays | 8 })
]
}
]
}
]
};
}
}

View File

@ -0,0 +1,9 @@
import { IReadonlyTheme } from "@microsoft/sp-component-base";
import { ServiceScope } from "@microsoft/sp-core-library";
export interface IMgtEventsProps {
title:string;
themeVariant: IReadonlyTheme;
serviceScope: ServiceScope;
numberDays: number;
}

View File

@ -0,0 +1,127 @@
import React from "react";
import {
format,
parseISO
} from "date-fns";
import jquery from "jquery";
import {
DocumentCard,
DocumentCardDetails,
format as formatString,
IDocumentCardStyles,
mergeStyles,
mergeStyleSets,
Stack,
Text
} from "office-ui-fabric-react";
import { MgtTemplateProps } from "@microsoft/mgt-react";
import { Event as IEvent } from "@microsoft/microsoft-graph-types";
import { currentSiteTheme } from "../../../common/constants";
import { MgtPersons } from "./MgtPersons";
const tileStyle: IDocumentCardStyles = {
root: {
minHeight: 280,
boxShadow: "0 5px 15px rgba(50, 50, 90, .1)",
},
};
export const Event = (props: MgtTemplateProps) => {
const event:IEvent = props.dataContext.event;
const componentClasses = mergeStyleSets({
eventDay: mergeStyles({
position: "relative",
left: -5,
paddingLeft: 20,
verticalAlign: "center",
borderLeftWidth: 4,
borderLeftColor: currentSiteTheme.theme.themePrimary,
borderLeftStyle: "solid",
}),
});
React.useEffect(() => {
(async () => {
// get ShadowRoot top container of events to apply css grid
const _agendaWebComponentShadowRoot = jquery("mgt-agenda").get()[0]
.shadowRoot;
if (_agendaWebComponentShadowRoot) {
jquery(_agendaWebComponentShadowRoot)
.find(".agenda-list")
.css("display", "grid")
.css(
"grid-template-columns",
"repeat(auto-fill, minmax(min(100%, 220px), 1fr))"
)
.css("grid-gap", "1rem");
}
})();
}, [props]);
// Render component
return (
<>
<DocumentCard styles={tileStyle} data-interception="false" onClickTarget="_blank" onClickHref={event.webLink}>
<Stack
horizontal
horizontalAlign="start"
verticalAlign="center"
tokens={{ childrenGap: 10 }}
styles={{ root: { marginTop: 20 } }}
>
<div className={componentClasses.eventDay}>
<Text variant={"xxLargePlus"}>
{format(parseISO(event.start.dateTime), "dd")}
</Text>
</div>
<Stack>
<Text
styles={{ root: { fontWeight: 600 } }}
variant="mediumPlus"
block
nowrap
>
{format(parseISO(event.start.dateTime), "EEEE")}
</Text>
<Text variant="small">
{format(parseISO(event.start.dateTime), "MMMM,yyyy")}
</Text>
</Stack>
</Stack>
<DocumentCardDetails
styles={{ root: { height: 100 } }}
></DocumentCardDetails>
<Stack styles={{ root: { position: "relative", padding: 20 } }}>
<Text
styles={{ root: { fontWeight: 600 } }}
variant="mediumPlus"
block
nowrap
title={event.subject}
>
{event.subject}
</Text>
<Text variant="small">
{formatString(
"Start at {0}",
format(parseISO(event.start.dateTime), "p")
)}
</Text>
</Stack>
<Stack
tokens={{ childrenGap: 5 }}
horizontal
horizontalAlign="start"
wrap
styles={{ root: { paddingLeft: 20, paddingRight: 20 } }}
>
<MgtPersons attendees={event.attendees} />
</Stack>
</DocumentCard>
</>
);
};

View File

@ -0,0 +1,24 @@
import * as React from "react";
import { Text } from "office-ui-fabric-react";
import { Agenda } from "@microsoft/mgt-react";
import { IMgtEventsProps } from "./IMgtEventsProps";
import { Event } from "./MgtEvent";
//
export const MgtEvents: React.FunctionComponent<IMgtEventsProps> = (
props: React.PropsWithChildren<IMgtEventsProps>
) => {
return (
<>
<Text variant="xLarge">{props.title}</Text>
<div style={{ marginTop: 30 }}>
<Agenda days={props.numberDays} >
<Event template="event" />
</Agenda>
</div>
</>
);
};

View File

@ -0,0 +1,26 @@
import * as React from "react";
import { Person } from "@microsoft/mgt-react";
import { Attendee } from "@microsoft/microsoft-graph-types";
export interface IMgtPersonsProps {
attendees: Attendee[];
}
export const MgtPersons: React.FunctionComponent<IMgtPersonsProps> = (
props: React.PropsWithChildren<IMgtPersonsProps>
) => {
const { attendees } = props;
return (
<>
{attendees.map((attendee, i) => {
return (
<Person
userId={attendee.emailAddress.address}
showPresence={true}
></Person>
);
})}
</>
);
};

View File

@ -0,0 +1,7 @@
define([], function() {
return {
"PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field"
}
});

View File

@ -0,0 +1,10 @@
declare interface IMgtEventsWebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
DescriptionFieldLabel: string;
}
declare module 'MgtEventsWebPartStrings' {
const strings: IMgtEventsWebPartStrings;
export = strings;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

View File

@ -0,0 +1,64 @@
/**
* This script updates the package-solution version analogue to the
* the package.json file.
*/
if (process.env.npm_package_version === undefined) {
throw 'Package version cannot be evaluated';
}
// define path to package-solution file
const solution = './config/package-solution.json',
teams = './teams/manifest.json';
// require filesystem instance
const fs = require('fs');
// get next automated package version from process variable
const nextPkgVersion = process.env.npm_package_version;
// make sure next build version match
const nextVersion = nextPkgVersion.indexOf('-') === -1 ?
nextPkgVersion : nextPkgVersion.split('-')[0];
// Update version in SPFx package-solution if exists
if (fs.existsSync(solution)) {
// read package-solution file
const solutionFileContent = fs.readFileSync(solution, 'UTF-8');
// parse file as json
const solutionContents = JSON.parse(solutionFileContent);
// set property of version to next version
solutionContents.solution.version = nextVersion + '.0';
// save file
fs.writeFileSync(
solution,
// convert file back to proper json
JSON.stringify(solutionContents, null, 2),
'UTF-8');
}
// Update version in teams manifest if exists
if (fs.existsSync(teams)) {
// read package-solution file
const teamsManifestContent = fs.readFileSync(teams, 'UTF-8');
// parse file as json
const teamsContent = JSON.parse(teamsManifestContent);
// set property of version to next version
teamsContent.version = nextVersion;
// save file
fs.writeFileSync(
teams,
// convert file back to proper json
JSON.stringify(teamsContent, null, 2),
'UTF-8');
}

View File

@ -0,0 +1,41 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules",
"lib"
]
}

View File

@ -0,0 +1,30 @@
{
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
"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-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-use-before-declare": false,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"variable-name": false,
"whitespace": false
}
}