Update react app settings (#442)
* update code comment * Update to SPFx 1.4.1
This commit is contained in:
parent
e0703d749f
commit
a940cae3bc
|
@ -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.
|
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
|
## 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
|
## Applies to
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ react-app-settings | Velin Georgiev ([@VelinGeorgiev](https://twitter.com/veling
|
||||||
Version|Date|Comments
|
Version|Date|Comments
|
||||||
-------|----|--------
|
-------|----|--------
|
||||||
0.0.1|August 03, 2017 | Initial commit
|
0.0.1|August 03, 2017 | Initial commit
|
||||||
|
0.0.2|March 08, 2018 | Update to SPFx 1.4.1
|
||||||
|
|
||||||
## Disclaimer
|
## 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.**
|
**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.**
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
{
|
{
|
||||||
"entries": [
|
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
{
|
"version": "2.0",
|
||||||
"entry": "./lib/webparts/reactAppSettings/ReactAppSettingsWebPart.js",
|
"bundles": {
|
||||||
"manifest": "./src/webparts/reactAppSettings/ReactAppSettingsWebPart.manifest.json",
|
"react-app-settings-bundle": {
|
||||||
"outputPath": "./dist/react-app-settings.bundle.js"
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/reactAppSettings/ReactAppSettingsWebPart.js",
|
||||||
|
"manifest": "./src/webparts/reactAppSettings/ReactAppSettingsWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
"externals": {},
|
|
||||||
"localizedResources": {
|
"localizedResources": {
|
||||||
"reactAppSettingsStrings": "webparts/reactAppSettings/loc/{locale}.js"
|
"reactAppSettingsStrings": "lib/webparts/reactAppSettings/loc/{locale}.js"
|
||||||
}
|
},
|
||||||
}
|
"externals": {}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
"solution": {
|
"solution": {
|
||||||
"name": "react-app-settings-client-side-solution",
|
"name": "react-app-settings-client-side-solution",
|
||||||
"id": "9573efb7-06d1-4134-aa8d-f6b4803d6096",
|
"id": "9573efb7-06d1-4134-aa8d-f6b4803d6096",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
|
||||||
// Display errors as warnings
|
// Display errors as warnings
|
||||||
"displayAsWarning": true,
|
"displayAsWarning": true,
|
||||||
// The TSLint task may have been configured with several custom lint rules
|
// The TSLint task may have been configured with several custom lint rules
|
||||||
|
@ -29,7 +30,6 @@
|
||||||
"no-switch-case-fall-through": true,
|
"no-switch-case-fall-through": true,
|
||||||
"no-unnecessary-semicolons": true,
|
"no-unnecessary-semicolons": true,
|
||||||
"no-unused-expression": true,
|
"no-unused-expression": true,
|
||||||
"no-unused-imports": true,
|
|
||||||
"no-use-before-declare": true,
|
"no-use-before-declare": true,
|
||||||
"no-with-statement": true,
|
"no-with-statement": true,
|
||||||
"semicolon": true,
|
"semicolon": true,
|
||||||
|
@ -42,4 +42,4 @@
|
||||||
"whitespace": false
|
"whitespace": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,26 +1,26 @@
|
||||||
{
|
{
|
||||||
"name": "react-app-settings",
|
"name": "react-app-settings",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@microsoft/sp-core-library": "~1.1.0",
|
"@microsoft/sp-core-library": "~1.4.1",
|
||||||
"@microsoft/sp-webpart-base": "~1.1.1",
|
"@microsoft/sp-webpart-base": "~1.4.1",
|
||||||
"@types/webpack-env": ">=1.12.1 <1.14.0",
|
"@types/webpack-env": ">=1.12.1 <1.14.0",
|
||||||
"react": "15.4.2",
|
"react": "15.6.2",
|
||||||
"react-dom": "15.4.2",
|
"react-dom": "15.6.2",
|
||||||
"@types/react": "0.14.46",
|
"@types/react": "15.6.6",
|
||||||
"@types/react-dom": "0.14.18",
|
"@types/react-dom": "15.5.6",
|
||||||
"@types/react-addons-shallow-compare": "0.14.17",
|
"@types/react-addons-shallow-compare": "0.14.17",
|
||||||
"@types/react-addons-update": "0.14.14",
|
"@types/react-addons-update": "0.14.14",
|
||||||
"@types/react-addons-test-utils": "0.14.15"
|
"@types/react-addons-test-utils": "0.14.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/sp-build-web": "~1.1.0",
|
"@microsoft/sp-build-web": "~1.4.1",
|
||||||
"@microsoft/sp-module-interfaces": "~1.1.0",
|
"@microsoft/sp-module-interfaces": "~1.4.1",
|
||||||
"@microsoft/sp-webpart-workbench": "~1.1.0",
|
"@microsoft/sp-webpart-workbench": "~1.4.1",
|
||||||
"gulp": "~3.9.1",
|
"gulp": "~3.9.1",
|
||||||
"@types/chai": ">=3.4.34 <3.6.0",
|
"@types/chai": ">=3.4.34 <3.6.0",
|
||||||
"@types/mocha": ">=2.2.33 <2.6.0"
|
"@types/mocha": ">=2.2.33 <2.6.0"
|
||||||
|
|
|
@ -3,7 +3,7 @@ var fs = require('fs'),
|
||||||
build = require('@microsoft/sp-build-web');
|
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) {
|
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.
|
* Pure string operations.
|
||||||
*/
|
*/
|
||||||
var getappSettingsTsKeys = function(appSettingsTsSettingsAsText, appSettingsTsKeysArray) {
|
var getappSettingsTsKeys = function(appSettingsTsSettingsAsText, appSettingsTsKeysArray) {
|
||||||
|
|
||||||
var keyEndPos = appSettingsTsSettingsAsText.indexOf(":");
|
var keyEndPos = appSettingsTsSettingsAsText.indexOf(":");
|
||||||
|
|
||||||
// end the recursion if no more `:`.
|
// end the recursion if no more `:`.
|
||||||
if(keyEndPos === -1) return appSettingsTsKeysArray;
|
if(keyEndPos === -1) return appSettingsTsKeysArray;
|
||||||
|
|
||||||
// substring the appSetting key from the text.
|
// substring the appSetting key from the text.
|
||||||
var key = appSettingsTsSettingsAsText.substring(0, keyEndPos);
|
var key = appSettingsTsSettingsAsText.substring(0, keyEndPos);
|
||||||
|
@ -31,7 +31,7 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
|
||||||
appSettingsTsKeysArray.push(key);
|
appSettingsTsKeysArray.push(key);
|
||||||
|
|
||||||
// exclude the key for the next call.
|
// 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.
|
// call again for the next key.
|
||||||
getappSettingsTsKeys(appSettingsTsSettingsAsText, appSettingsTsKeysArray);
|
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) {
|
fs.readFile('./src/appSettings.json', 'utf8', function (err,data) {
|
||||||
if (err) { return reject(err); }
|
if (err) { return reject(err); }
|
||||||
|
|
||||||
// remove some strings so we can parse to JSON, prue string manipulation.
|
// remove some strings so we can parse to JSON, prue string manipulation.
|
||||||
var jsonAsString = data.replace(/(?:\r\n|\r|\n)/g, "").trim();
|
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.
|
// remove some strings, prue string manipulation.
|
||||||
var text = data.substring(data.indexOf("{") + 1, data.indexOf("}")).replace(/ /g,"").replace(/(?:\r\n|\r|\n)/g, "").trim();
|
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.
|
// fill the appSettingsTsKeys array with the appSettings.d.ts keys.
|
||||||
getappSettingsTsKeys(text, appSettingsTsKeys);
|
getappSettingsTsKeys(text, appSettingsTsKeys);
|
||||||
|
|
||||||
// now we have two arrays with keys to compare.
|
// now we have two arrays with keys to compare.
|
||||||
|
|
||||||
// checks the appSettings.json for missing keys.
|
// checks the appSettings.json for missing keys.
|
||||||
var l = appSettingsTsKeys.length;
|
var l = appSettingsTsKeys.length;
|
||||||
while(l--) {
|
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.`);
|
build.error(`Key \"${appSettingsTsKeys[l]}\" not found in appSettings.json, but exists in appSettings.d.ts. Please fix your appSettings.`);
|
||||||
return reject();
|
return reject();
|
||||||
|
@ -82,7 +82,7 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
|
||||||
l = appSettingsJsKeys.length;
|
l = appSettingsJsKeys.length;
|
||||||
while(l--) {
|
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.`);
|
build.error(`Key \"${appSettingsJsKeys[l]}\" not found in appSettings.d.ts, but exists in appSettings.json. Please fix your appSettings.`);
|
||||||
return reject();
|
return reject();
|
||||||
|
@ -95,4 +95,4 @@ var verifyAppSettings = build.subTask('verify-app-settings', function(gulp, buil
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.default = verifyAppSettings;
|
exports.default = verifyAppSettings;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { IReactAppSettingsWebPartProps } from './IReactAppSettingsWebPartProps';
|
||||||
export default class ReactAppSettingsWebPart extends BaseClientSideWebPart<IReactAppSettingsWebPartProps> {
|
export default class ReactAppSettingsWebPart extends BaseClientSideWebPart<IReactAppSettingsWebPartProps> {
|
||||||
|
|
||||||
public render(): void {
|
public render(): void {
|
||||||
const element: React.ReactElement<IReactAppSettingsProps > = React.createElement(
|
const element: React.ReactElement<IReactAppSettingsProps> = React.createElement(
|
||||||
ReactAppSettings,
|
ReactAppSettings,
|
||||||
{
|
{
|
||||||
description: this.properties.description
|
description: this.properties.description
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { escape } from '@microsoft/sp-lodash-subset';
|
||||||
*/
|
*/
|
||||||
import * as appSettings from 'appSettings';
|
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> {
|
public render(): React.ReactElement<IReactAppSettingsProps> {
|
||||||
return (
|
return (
|
||||||
<div className={styles.reactAppSettings}>
|
<div className={styles.reactAppSettings}>
|
||||||
|
|
|
@ -7,10 +7,19 @@
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"es6-promise",
|
"es6-promise",
|
||||||
"es6-collections",
|
|
||||||
"webpack-env"
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue