Update react app settings (#442)

* update code comment

* Update to SPFx 1.4.1
This commit is contained in:
Joel Rodrigues 2018-03-09 00:34:33 +00:00 committed by Vesa Juvonen
parent e0703d749f
commit a940cae3bc
10 changed files with 17764 additions and 36 deletions

View File

@ -20,7 +20,7 @@ I have added appSettingsGulp.js with one gulp task in it. The task starts just b
Since the gulp task I created contains checks based on string operations, it is required that the appSettings.json and appSettings.d.ts are in format as provided and just key-pairs are added to the json file and respective just new properties are added to the IAppSettings interface in the appSettings.d.ts.
## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/drop-GA-green.svg)
![drop](https://img.shields.io/badge/drop-1.4.1-green.svg)
## Applies to
@ -43,6 +43,7 @@ react-app-settings | Velin Georgiev ([@VelinGeorgiev](https://twitter.com/veling
Version|Date|Comments
-------|----|--------
0.0.1|August 03, 2017 | Initial commit
0.0.2|March 08, 2018 | Update to SPFx 1.4.1
## 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.**

View File

@ -1,13 +1,18 @@
{
"entries": [
{
"entry": "./lib/webparts/reactAppSettings/ReactAppSettingsWebPart.js",
"manifest": "./src/webparts/reactAppSettings/ReactAppSettingsWebPart.manifest.json",
"outputPath": "./dist/react-app-settings.bundle.js"
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"react-app-settings-bundle": {
"components": [
{
"entrypoint": "./lib/webparts/reactAppSettings/ReactAppSettingsWebPart.js",
"manifest": "./src/webparts/reactAppSettings/ReactAppSettingsWebPart.manifest.json"
}
]
}
],
"externals": {},
},
"localizedResources": {
"reactAppSettingsStrings": "webparts/reactAppSettings/loc/{locale}.js"
}
}
"reactAppSettingsStrings": "lib/webparts/reactAppSettings/loc/{locale}.js"
},
"externals": {}
}

View File

@ -1,4 +1,5 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-app-settings-client-side-solution",
"id": "9573efb7-06d1-4134-aa8d-f6b4803d6096",

View File

@ -1,4 +1,5 @@
{
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
// Display errors as warnings
"displayAsWarning": true,
// The TSLint task may have been configured with several custom lint rules
@ -29,7 +30,6 @@
"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,
@ -42,4 +42,4 @@
"whitespace": false
}
}
}
}

17712
samples/react-app-settings/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,26 @@
{
"name": "react-app-settings",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"@microsoft/sp-core-library": "~1.1.0",
"@microsoft/sp-webpart-base": "~1.1.1",
"@microsoft/sp-core-library": "~1.4.1",
"@microsoft/sp-webpart-base": "~1.4.1",
"@types/webpack-env": ">=1.12.1 <1.14.0",
"react": "15.4.2",
"react-dom": "15.4.2",
"@types/react": "0.14.46",
"@types/react-dom": "0.14.18",
"react": "15.6.2",
"react-dom": "15.6.2",
"@types/react": "15.6.6",
"@types/react-dom": "15.5.6",
"@types/react-addons-shallow-compare": "0.14.17",
"@types/react-addons-update": "0.14.14",
"@types/react-addons-test-utils": "0.14.15"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.1.0",
"@microsoft/sp-module-interfaces": "~1.1.0",
"@microsoft/sp-webpart-workbench": "~1.1.0",
"@microsoft/sp-build-web": "~1.4.1",
"@microsoft/sp-module-interfaces": "~1.4.1",
"@microsoft/sp-webpart-workbench": "~1.4.1",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"

View File

@ -3,7 +3,7 @@ var fs = require('fs'),
build = require('@microsoft/sp-build-web');
/**
* Verifies if the appSettings.json and appSettings.d.ts are have the same appSetting keys.
* Verifies if the appSettings.json and appSettings.d.ts have the same appSetting keys.
*/
var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buildConfig, done) {
@ -18,11 +18,11 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
* Pure string operations.
*/
var getappSettingsTsKeys = function(appSettingsTsSettingsAsText, appSettingsTsKeysArray) {
var keyEndPos = appSettingsTsSettingsAsText.indexOf(":");
// end the recursion if no more `:`.
if(keyEndPos === -1) return appSettingsTsKeysArray;
if(keyEndPos === -1) return appSettingsTsKeysArray;
// substring the appSetting key from the text.
var key = appSettingsTsSettingsAsText.substring(0, keyEndPos);
@ -31,7 +31,7 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
appSettingsTsKeysArray.push(key);
// exclude the key for the next call.
appSettingsTsSettingsAsText = appSettingsTsSettingsAsText.substring(appSettingsTsSettingsAsText.indexOf(";") + 1);
appSettingsTsSettingsAsText = appSettingsTsSettingsAsText.substring(appSettingsTsSettingsAsText.indexOf(";") + 1);
// call again for the next key.
getappSettingsTsKeys(appSettingsTsSettingsAsText, appSettingsTsKeysArray);
@ -45,7 +45,7 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
*/
fs.readFile('./src/appSettings.json', 'utf8', function (err,data) {
if (err) { return reject(err); }
// remove some strings so we can parse to JSON, prue string manipulation.
var jsonAsString = data.replace(/(?:\r\n|\r|\n)/g, "").trim();
@ -61,17 +61,17 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
// remove some strings, prue string manipulation.
var text = data.substring(data.indexOf("{") + 1, data.indexOf("}")).replace(/ /g,"").replace(/(?:\r\n|\r|\n)/g, "").trim();
// fill the appSettingsTsKeys array with the appSettings.d.ts keys.
getappSettingsTsKeys(text, appSettingsTsKeys);
// now we have two arrays with keys to compare.
// checks the appSettings.json for missing keys.
var l = appSettingsTsKeys.length;
while(l--) {
if(appSettingsJsKeys.indexOf(appSettingsTsKeys[l]) === -1)
if(appSettingsJsKeys.indexOf(appSettingsTsKeys[l]) === -1)
{
build.error(`Key \"${appSettingsTsKeys[l]}\" not found in appSettings.json, but exists in appSettings.d.ts. Please fix your appSettings.`);
return reject();
@ -82,7 +82,7 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
l = appSettingsJsKeys.length;
while(l--) {
if(appSettingsTsKeys.indexOf(appSettingsJsKeys[l]) === -1)
if(appSettingsTsKeys.indexOf(appSettingsJsKeys[l]) === -1)
{
build.error(`Key \"${appSettingsJsKeys[l]}\" not found in appSettings.d.ts, but exists in appSettings.json. Please fix your appSettings.`);
return reject();
@ -95,4 +95,4 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
});
});
exports.default = verifyAppSettings;
exports.default = verifyAppSettings;

View File

@ -15,7 +15,7 @@ import { IReactAppSettingsWebPartProps } from './IReactAppSettingsWebPartProps';
export default class ReactAppSettingsWebPart extends BaseClientSideWebPart<IReactAppSettingsWebPartProps> {
public render(): void {
const element: React.ReactElement<IReactAppSettingsProps > = React.createElement(
const element: React.ReactElement<IReactAppSettingsProps> = React.createElement(
ReactAppSettings,
{
description: this.properties.description

View File

@ -8,7 +8,7 @@ import { escape } from '@microsoft/sp-lodash-subset';
*/
import * as appSettings from 'appSettings';
export default class ReactAppSettings extends React.Component<IReactAppSettingsProps, void> {
export default class ReactAppSettings extends React.Component<IReactAppSettingsProps, {}> {
public render(): React.ReactElement<IReactAppSettingsProps> {
return (
<div className={styles.reactAppSettings}>

View File

@ -7,10 +7,19 @@
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"es6-collections",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
]
}
}