diff --git a/samples/js-gitHubBadge/.editorconfig b/samples/js-gitHubBadge/.editorconfig new file mode 100644 index 000000000..8ffcdc4ec --- /dev/null +++ b/samples/js-gitHubBadge/.editorconfig @@ -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 \ No newline at end of file diff --git a/samples/js-gitHubBadge/.gitignore b/samples/js-gitHubBadge/.gitignore new file mode 100644 index 000000000..c1d101dae --- /dev/null +++ b/samples/js-gitHubBadge/.gitignore @@ -0,0 +1,36 @@ +# 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 + +# Added +package-lock.json +yarn.lock \ No newline at end of file diff --git a/samples/js-gitHubBadge/.yo-rc.json b/samples/js-gitHubBadge/.yo-rc.json new file mode 100644 index 000000000..1e4efdf66 --- /dev/null +++ b/samples/js-gitHubBadge/.yo-rc.json @@ -0,0 +1,21 @@ +{ + "@pnp/generator-spfx": { + "framework": "none", + "pnpFramework": "none.plus", + "pnp-libraries": [], + "pnp-ci": [], + "pnp-vetting": [], + "spfxenv": "spo" + }, + "@microsoft/generator-sharepoint": { + "environment": "spo", + "framework": "none", + "isCreatingSolution": true, + "version": "1.8.0", + "libraryName": "git-hub-badge-web-part", + "libraryId": "d40be93e-575e-419a-a56a-05067c51bfae", + "packageManager": "npm", + "isDomainIsolated": false, + "componentType": "webpart" + } +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/README.md b/samples/js-gitHubBadge/README.md new file mode 100644 index 000000000..04f176686 --- /dev/null +++ b/samples/js-gitHubBadge/README.md @@ -0,0 +1,53 @@ +# GitHub Badge + +## Summary +Displays information from GitHub for a specified user. +![drop](./assets/1.png) + +## Used SharePoint Framework Version +![drop](https://img.shields.io/badge/version-GA-green.svg) + +## Applies to + +* [SharePoint Framework](https:/dev.office.com/sharepoint) +* [Office 365 tenant](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment) + + +## Prerequisites + +None + +## Solution + +Solution|Author(s) +--------|--------- +js-GitHubBadge | Eric Skaggs [@skaggej](https://www.twitter.com/skaggej) + +## Version history + +Version|Date|Comments +-------|----|-------- +1.0 | April 18, 2019 | 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 + +- Clone this repository +- in the command line run: + - `npm install` + - `gulp serve` + +> Include any additional steps as needed. + +## Features +It's not the prettiest thing in the world, but the goal here was to create a web part that demonstrates something a bit beyond the standard "Hello, World!" web part in which we change some HTML. This sample shows how to pull in data from somewhere without authentication and without over-complicating things. + +Future samples will refactor this into something more professional that follows recommended coding patterns and practices and leverage modern frameworks. + +Ultimately, this sample along with its yet-to-be-created future samples could be a useful teaching tool to developers new to SPFx as well as developers who aren't well-versed in SPFx coding patterns or the various frameworks available. + + \ No newline at end of file diff --git a/samples/js-gitHubBadge/assets/1.png b/samples/js-gitHubBadge/assets/1.png new file mode 100644 index 000000000..17346c861 Binary files /dev/null and b/samples/js-gitHubBadge/assets/1.png differ diff --git a/samples/js-gitHubBadge/config/config.json b/samples/js-gitHubBadge/config/config.json new file mode 100644 index 000000000..6bcd7c89b --- /dev/null +++ b/samples/js-gitHubBadge/config/config.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json", + "version": "2.0", + "bundles": { + "git-hub-badge-web-part": { + "components": [ + { + "entrypoint": "./lib/webparts/gitHubBadge/GitHubBadgeWebPart.js", + "manifest": "./src/webparts/gitHubBadge/GitHubBadgeWebPart.manifest.json" + } + ] + } + }, + "externals": {}, + "localizedResources": { + "GitHubBadgeWebPartStrings": "lib/webparts/gitHubBadge/loc/{locale}.js" + } +} diff --git a/samples/js-gitHubBadge/config/copy-assets.json b/samples/js-gitHubBadge/config/copy-assets.json new file mode 100644 index 000000000..3771fd04a --- /dev/null +++ b/samples/js-gitHubBadge/config/copy-assets.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json", + "deployCdnPath": "temp/deploy" +} diff --git a/samples/js-gitHubBadge/config/deploy-azure-storage.json b/samples/js-gitHubBadge/config/deploy-azure-storage.json new file mode 100644 index 000000000..502b86a51 --- /dev/null +++ b/samples/js-gitHubBadge/config/deploy-azure-storage.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", + "workingDir": "./temp/deploy/", + "account": "", + "container": "git-hub-badge-web-part", + "accessKey": "" +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/config/jest.config.json b/samples/js-gitHubBadge/config/jest.config.json new file mode 100644 index 000000000..a48ae739c --- /dev/null +++ b/samples/js-gitHubBadge/config/jest.config.json @@ -0,0 +1,4 @@ +{ + "preset": "@voitanos/jest-preset-spfx", + "rootDir": "../src" +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/config/package-solution.json b/samples/js-gitHubBadge/config/package-solution.json new file mode 100644 index 000000000..9d24d7526 --- /dev/null +++ b/samples/js-gitHubBadge/config/package-solution.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json", + "solution": { + "name": "git-hub-badge-web-part-client-side-solution", + "id": "d40be93e-575e-419a-a56a-05067c51bfae", + "version": "1.0.0.0", + "includeClientSideAssets": true, + "skipFeatureDeployment": true, + "isDomainIsolated": false + }, + "paths": { + "zippedPackage": "solution/git-hub-badge-web-part.sppkg" + } +} diff --git a/samples/js-gitHubBadge/config/serve.json b/samples/js-gitHubBadge/config/serve.json new file mode 100644 index 000000000..e6f10c421 --- /dev/null +++ b/samples/js-gitHubBadge/config/serve.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json", + "port": 4321, + "hostname": "0.0.0.0", + "https": true, + "initialPage": "https://localhost:5432/workbench", + "api": { + "port": 5432, + "entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/" + } +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/config/write-manifests.json b/samples/js-gitHubBadge/config/write-manifests.json new file mode 100644 index 000000000..77892b4ff --- /dev/null +++ b/samples/js-gitHubBadge/config/write-manifests.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json", + "cdnBasePath": "", + "debugBasePath": "https://localhost:4321/" +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/gulpfile.js b/samples/js-gitHubBadge/gulpfile.js new file mode 100644 index 000000000..1633ea380 --- /dev/null +++ b/samples/js-gitHubBadge/gulpfile.js @@ -0,0 +1,34 @@ +'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); + +/** + * Continuous Integration + */ + diff --git a/samples/js-gitHubBadge/package.json b/samples/js-gitHubBadge/package.json new file mode 100644 index 000000000..a11b2d5e9 --- /dev/null +++ b/samples/js-gitHubBadge/package.json @@ -0,0 +1,40 @@ +{ + "name": "git-hub-badge-web-part", + "version": "0.0.1", + "private": true, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "build": "gulp bundle", + "clean": "gulp clean", + "preversion": "node ./tools/pre-version.js", + "postversion": "gulp dist", + "test": "./node_modules/.bin/jest --config ./config/jest.config.json", + "test:watch": "./node_modules/.bin/jest --config ./config/jest.config.json --watchAll" + }, + "dependencies": { + "@microsoft/sp-core-library": "1.8.0", + "@microsoft/sp-lodash-subset": "1.8.0", + "@microsoft/sp-office-ui-fabric-core": "1.8.0", + "@microsoft/sp-property-pane": "1.8.0", + "@microsoft/sp-webpart-base": "1.8.0", + "@types/es6-promise": "0.0.33", + "@types/webpack-env": "1.13.1" + }, + "devDependencies": { + "@microsoft/rush-stack-compiler-2.7": "0.4.0", + "@microsoft/sp-build-web": "1.8.0", + "@microsoft/sp-module-interfaces": "1.8.0", + "@microsoft/sp-tslint-rules": "1.8.0", + "@microsoft/sp-webpart-workbench": "1.8.0", + "@types/chai": "3.4.34", + "@types/mocha": "2.2.38", + "@voitanos/jest-preset-spfx": "^1.1.0", + "ajv": "~5.2.2", + "gulp": "~3.9.1", + "gulp-sequence": "1.0.0", + "jest": "^23.6.0", + "karma-junit-reporter": "^1.2.0" + } +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/src/index.ts b/samples/js-gitHubBadge/src/index.ts new file mode 100644 index 000000000..fb81db1e2 --- /dev/null +++ b/samples/js-gitHubBadge/src/index.ts @@ -0,0 +1 @@ +// A file is required to be in the root of the /src directory by the TypeScript compiler diff --git a/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.manifest.json b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.manifest.json new file mode 100644 index 000000000..7fdd5b4c5 --- /dev/null +++ b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.manifest.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", + "id": "130674a1-0182-4b57-8ce9-88e1516abbcf", + "alias": "GitHubBadgeWebPart", + "componentType": "WebPart", + + // 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"], + + "preconfiguredEntries": [{ + "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other + "group": { "default": "Other" }, + "title": { "default": "GitHub Badge" }, + "description": { "default": "Displays information from GitHub for a specified user." }, + "officeFabricIconFontName": "Page", + "properties": { + "description": "GitHub Badge", + "gitHubUserName": "skaggej" + } + }] +} diff --git a/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.module.scss b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.module.scss new file mode 100644 index 000000000..ab90327f8 --- /dev/null +++ b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.module.scss @@ -0,0 +1,74 @@ +@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss'; + +.gitHubBadge { + .container { + max-width: 700px; + margin: 0px auto; + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1); + } + + .row { + @include ms-Grid-row; + @include ms-fontColor-white; + background-color: $ms-color-themeDark; + padding: 20px; + } + + .column { + @include ms-Grid-col; + @include ms-lg10; + @include ms-xl8; + @include ms-xlPush2; + @include ms-lgPush1; + } + + .title { + @include ms-font-xl; + @include ms-fontColor-white; + } + + .subTitle { + @include ms-font-l; + @include ms-fontColor-white; + } + + .description { + @include ms-font-l; + @include ms-fontColor-white; + } + + .button { + // Our button + text-decoration: none; + height: 32px; + + // Primary Button + min-width: 80px; + background-color: $ms-color-themePrimary; + border-color: $ms-color-themePrimary; + color: $ms-color-white; + + // Basic Button + outline: transparent; + position: relative; + font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif; + -webkit-font-smoothing: antialiased; + font-size: $ms-font-size-m; + font-weight: $ms-font-weight-regular; + border-width: 0; + text-align: center; + cursor: pointer; + display: inline-block; + padding: 0 16px; + + .label { + font-weight: $ms-font-weight-semibold; + font-size: $ms-font-size-m; + height: 32px; + line-height: 32px; + margin: 0 4px; + vertical-align: top; + display: inline-block; + } + } +} \ No newline at end of file diff --git a/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.ts b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.ts new file mode 100644 index 000000000..5776e6d10 --- /dev/null +++ b/samples/js-gitHubBadge/src/webparts/gitHubBadge/GitHubBadgeWebPart.ts @@ -0,0 +1,216 @@ +import { Version } from '@microsoft/sp-core-library'; +import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; +import { + IPropertyPaneConfiguration, + PropertyPaneTextField +} from '@microsoft/sp-property-pane'; +import { HttpClient, SPHttpClient, HttpClientConfiguration, HttpClientResponse, ODataVersion, IHttpClientConfiguration, IHttpClientOptions, ISPHttpClientOptions } from '@microsoft/sp-http'; +import { escape } from '@microsoft/sp-lodash-subset'; + +import styles from './GitHubBadgeWebPart.module.scss'; +import * as strings from 'GitHubBadgeWebPartStrings'; + +export interface IGitHubBadgeWebPartProps { + description: string; + gitHubUserName: string; +} + +export interface IGitHubBadgeUserProfileProps { + login: string; + id: string; + node_id: string; + avatar_url: string; + gravatar_id: string; + url: string; + html_url: string; + followers_url: string; + following_url: string; + gists_url: string; + starred_url: string; + subscriptions_url: string; + organizations_url: string; + repos_url: string; + events_url: string; + received_events_url: string; + type: string; + site_admin: string; + name: string; + company: string; + blog: string; + location: string; + email: string; + hireable: string; + bio: string; + public_repos: string; + public_gists: string; + followers: string; + following: string; + created_at: string; + updated_at: string; +} + +export default class GitHubBadgeWebPart extends BaseClientSideWebPart { + + protected getGitHubData(): void { + let gitHubUrl: string = "https://api.github.com/users/"+this.properties.gitHubUserName; + let responseText: string = ""; + let notfound: HTMLElement = document.getElementById("notfound"); + let gitHubUserProfilePic: HTMLElement = document.getElementById("gitHubUserProfilePic"); + let login: HTMLElement = document.getElementById("login"); + let id: HTMLElement = document.getElementById("id"); + let node_id: HTMLElement = document.getElementById("node_id"); + let avatar_url: HTMLElement = document.getElementById("avatar_url"); + let gravatar_id: HTMLElement = document.getElementById("gravatar_id"); + let url: HTMLElement = document.getElementById("url"); + let html_url: HTMLElement = document.getElementById("html_url"); + let followers_url: HTMLElement = document.getElementById("followers_url"); + let following_url: HTMLElement = document.getElementById("following_url"); + let gists_url: HTMLElement = document.getElementById("gists_url"); + let starred_url: HTMLElement = document.getElementById("starred_url"); + let subscriptions_url: HTMLElement = document.getElementById("subscriptions_url"); + let organizations_url: HTMLElement = document.getElementById("organizations_url"); + let repos_url: HTMLElement = document.getElementById("repos_url"); + let events_url: HTMLElement = document.getElementById("events_url"); + let received_events_url: HTMLElement = document.getElementById("received_events_url"); + let type: HTMLElement = document.getElementById("type"); + let site_admin: HTMLElement = document.getElementById("site_admin"); + let name: HTMLElement = document.getElementById("name"); + let company: HTMLElement = document.getElementById("company"); + let blog: HTMLElement = document.getElementById("blog"); + let location: HTMLElement = document.getElementById("location"); + let email: HTMLElement = document.getElementById("email"); + let hireable: HTMLElement = document.getElementById("hireable"); + let bio: HTMLElement = document.getElementById("bio"); + let public_repos: HTMLElement = document.getElementById("public_repos"); + let public_gists: HTMLElement = document.getElementById("public_gists"); + let followers: HTMLElement = document.getElementById("followers"); + let following: HTMLElement = document.getElementById("following"); + let created_at: HTMLElement = document.getElementById("created_at"); + let updated_at: HTMLElement = document.getElementById("updated_at"); + let responseJSONparsed: IGitHubBadgeUserProfileProps; + this.context.httpClient.get(gitHubUrl, HttpClient.configurations.v1).then((response: HttpClientResponse) => { + response.json().then((responseJSON: JSON) => { + responseText = JSON.stringify(responseJSON); + responseJSONparsed = JSON.parse(responseText); + gitHubUserProfilePic.innerHTML= `GitHub User Profile Picture`; + login.innerText = responseJSONparsed.login; + id.innerText = responseJSONparsed.id; + node_id.innerText = responseJSONparsed.node_id; + avatar_url.innerText = responseJSONparsed.avatar_url; + gravatar_id.innerText = responseJSONparsed.gravatar_id; + url.innerText = responseJSONparsed.url; + html_url.innerText = responseJSONparsed.html_url; + followers_url.innerText = responseJSONparsed.followers_url; + following_url.innerText = responseJSONparsed.following_url; + gists_url.innerText = responseJSONparsed.gists_url; + starred_url.innerText = responseJSONparsed.starred_url; + subscriptions_url.innerText = responseJSONparsed.subscriptions_url; + organizations_url.innerText = responseJSONparsed.organizations_url; + repos_url.innerText = responseJSONparsed.repos_url; + events_url.innerText = responseJSONparsed.events_url; + received_events_url.innerText = responseJSONparsed.received_events_url; + type.innerText = responseJSONparsed.type; + site_admin.innerText = responseJSONparsed.site_admin; + name.innerText = responseJSONparsed.name; + company.innerText = responseJSONparsed.company; + blog.innerText = responseJSONparsed.blog; + location.innerText = responseJSONparsed.location; + email.innerText = responseJSONparsed.email; + hireable.innerText = responseJSONparsed.hireable; + bio.innerText = responseJSONparsed.bio; + public_repos.innerText = responseJSONparsed.public_repos; + public_gists.innerText = responseJSONparsed.public_gists; + followers.innerText = responseJSONparsed.followers; + following.innerText = responseJSONparsed.following; + created_at.innerText = responseJSONparsed.created_at; + updated_at.innerText = responseJSONparsed.updated_at; + }) + .catch ((response: any) => { + let errMsg: string = `WARNING - error when calling URL ${gitHubUrl}. Error = ${response.message}`; + notfound.style.color = "red"; + console.log(errMsg); + notfound.innerText = errMsg; + }); + }); + } + + public render(): void { + this.domElement.innerHTML = ` +
+
+
+
+
+
${this.properties.gitHubUserName}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`; + this.getGitHubData(); + } + + protected get dataVersion(): Version { + return Version.parse('1.0'); + } + + protected get disableReactivePropertyChanges(): boolean { + return true; + } + + protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { + return { + pages: [ + { + header: { + description: strings.PropertyPaneDescription + }, + groups: [ + { + groupName: strings.BasicGroupName, + groupFields: [ + PropertyPaneTextField('description', { + label: strings.DescriptionFieldLabel + }), + PropertyPaneTextField('gitHubUserName', { + label: strings.GitHubUserNameFieldLabel + }) + ] + } + ] + } + ] + }; + } +} diff --git a/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/en-us.js b/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/en-us.js new file mode 100644 index 000000000..e4461466e --- /dev/null +++ b/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/en-us.js @@ -0,0 +1,8 @@ +define([], function() { + return { + "PropertyPaneDescription": "Description", + "BasicGroupName": "Group Name", + "DescriptionFieldLabel": "Description Field", + "GitHubUserNameFieldLabel": "GitHub User Name" + } +}); \ No newline at end of file diff --git a/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/mystrings.d.ts b/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/mystrings.d.ts new file mode 100644 index 000000000..265815385 --- /dev/null +++ b/samples/js-gitHubBadge/src/webparts/gitHubBadge/loc/mystrings.d.ts @@ -0,0 +1,11 @@ +declare interface IGitHubBadgeWebPartStrings { + PropertyPaneDescription: string; + BasicGroupName: string; + DescriptionFieldLabel: string; + GitHubUserNameFieldLabel: string; +} + +declare module 'GitHubBadgeWebPartStrings' { + const strings: IGitHubBadgeWebPartStrings; + export = strings; +} diff --git a/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_color.png b/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_color.png new file mode 100644 index 000000000..a8d279707 Binary files /dev/null and b/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_color.png differ diff --git a/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_outline.png b/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_outline.png new file mode 100644 index 000000000..6df4a038d Binary files /dev/null and b/samples/js-gitHubBadge/teams/130674a1-0182-4b57-8ce9-88e1516abbcf_outline.png differ diff --git a/samples/js-gitHubBadge/tools/pre-version.js b/samples/js-gitHubBadge/tools/pre-version.js new file mode 100644 index 000000000..be51a4beb --- /dev/null +++ b/samples/js-gitHubBadge/tools/pre-version.js @@ -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 instanc +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'); + +} diff --git a/samples/js-gitHubBadge/tsconfig.json b/samples/js-gitHubBadge/tsconfig.json new file mode 100644 index 000000000..e0d751e33 --- /dev/null +++ b/samples/js-gitHubBadge/tsconfig.json @@ -0,0 +1,38 @@ +{ + "extends": "./node_modules/@microsoft/rush-stack-compiler-2.7/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" + ] + }, + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "node_modules", + "lib" + ] +} diff --git a/samples/js-gitHubBadge/tslint.json b/samples/js-gitHubBadge/tslint.json new file mode 100644 index 000000000..23fa2aa43 --- /dev/null +++ b/samples/js-gitHubBadge/tslint.json @@ -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": true, + "no-with-statement": true, + "semicolon": true, + "trailing-comma": false, + "typedef": false, + "typedef-whitespace": false, + "use-named-parameter": true, + "variable-name": false, + "whitespace": false + } +} \ No newline at end of file