From 3d5ec19de66f91ec0ab6609ae3dffa95538d681c Mon Sep 17 00:00:00 2001 From: dtookey Date: Thu, 5 Nov 2020 11:23:12 -0500 Subject: [PATCH 01/10] scss is validated and will fail on compile if incorrect. typescript is validated and will fail on compile if there's a problem with the linter --- gulpfile.js | 18 ++++++++++++++---- package-lock.json | 12 ++++++------ package.json | 2 +- tests/default-test.ts | 11 ++++++----- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5ac527f..1af3aad 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,19 +11,26 @@ function clean(cb) { cb(); } +function validateConfigSources(){ + +} + function conf() { return src(['src/assets/**/*', '!src/assets/**/*.scss'], {base: 'src/assets'}) .pipe(dest('build/assets/')); } -function style(){ +function style() { return src('node_modules/bootstrap/dist/css/bootstrap.css') .pipe(dest('build/assets/pages/styles/')); } -function scss(){ - return src('src/assets/pages/styles/*.scss', ) +function scss() { + return src('src/assets/pages/styles/*.scss',) .pipe(sass.sync().on('error', sass.logError)) + .on('error', () => { + process.exit(1) + }) .pipe(dest('build/assets/pages/styles/')); } @@ -39,7 +46,10 @@ function pkg() { function typescript() { return tsSource.src() - .pipe(tsSource()).js + .pipe(tsSource()).on('error', () => { + process.exit(1) + }) + .js .pipe(dest('build/util/')); } diff --git a/package-lock.json b/package-lock.json index 19539b4..a72d8ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4582,9 +4582,9 @@ } }, "mocha": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.2.0.tgz", - "integrity": "sha512-lEWEMq2LMfNJMKeuEwb5UELi+OgFDollXaytR5ggQcHpzG3NP/R7rvixAvF+9/lLsTWhWG+4yD2M70GsM06nxw==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.2.1.tgz", + "integrity": "sha512-cuLBVfyFfFqbNR0uUKbDGXKGk+UDFe6aR4os78XIrMQpZl/nv7JYHcvP5MFIAb374b2zFXsdgEGwmzMtP0Xg8w==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -7844,9 +7844,9 @@ }, "dependencies": { "camelcase": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.1.0.tgz", - "integrity": "sha512-WCMml9ivU60+8rEJgELlFp1gxFcEGxwYleE3bziHEDeqsqAWGHdimB7beBFGjLzVNgPGyDsfgXLQEYMpmIFnVQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", "dev": true }, "decamelize": { diff --git a/package.json b/package.json index ae0e750..ce310bc 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "gulp-typescript": "^6.0.0-alpha.1", "gulp-exec": "^5.0.0", "del": "^6.0.0", - "chai": "^4.2.0", "electron-mocha": "^9.3.1", + "chai": "^4.2.0", "nyc": "^15.1.0", "ts-node": "^9.0.0", "check-for-leaks": "^1.2.1" diff --git a/tests/default-test.ts b/tests/default-test.ts index e56fbff..df60da6 100644 --- a/tests/default-test.ts +++ b/tests/default-test.ts @@ -1,8 +1,9 @@ const assert = require('assert'); describe('default', ()=>{ - it('default-test', ()=>{ - let res = 5+2; - assert.strictEqual(res, 7); - }) -}) \ No newline at end of file + it('snippit', snippit) +}) + +function snippit(){ + console.log("okay") +} \ No newline at end of file From 9ab3cf19ae9c9380c9ebb3b083ae1c28a271ca7a Mon Sep 17 00:00:00 2001 From: dtookey Date: Thu, 5 Nov 2020 11:31:57 -0500 Subject: [PATCH 02/10] tweaked whitespace in resources-landing-page.html and resources-landing-page.json --- src/assets/pages/resources-landing-page.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/assets/pages/resources-landing-page.html b/src/assets/pages/resources-landing-page.html index baa94cb..8151b05 100644 --- a/src/assets/pages/resources-landing-page.html +++ b/src/assets/pages/resources-landing-page.html @@ -56,8 +56,6 @@
- -
From bede5ae17872a1bef0d67fb92b347c19e25e9112 Mon Sep 17 00:00:00 2001 From: dtookey Date: Thu, 5 Nov 2020 15:58:38 -0500 Subject: [PATCH 03/10] implemented small validation pipeline that will iterate through content sources --- gulpfile.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1af3aad..b559e0a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,8 @@ const del = require('del'); const ts = require('gulp-typescript'); const exec = require('child_process').exec; const sass = require('gulp-sass'); +const fs = require('fs'); +const path = require('path'); sass.compiler = require('node-sass'); let tsSource = ts.createProject('tsconfig.json') @@ -11,8 +13,34 @@ function clean(cb) { cb(); } -function validateConfigSources(){ - +function validateConfigSources(cb) { + let confBase = "src/assets/conf/"; + let configsToCheck = ["resources-landing-page.json"]; + for (let i = 0, l = configsToCheck.length; i < l; i++) { + let currConfig = configsToCheck[i]; + let configContent = fs.readFileSync(path.join(confBase, currConfig)); + let conf = JSON.parse(configContent.toString()); + let keys = Object.keys(conf); + for (let j = 0, m = keys.length; j < m; j++) { + let key = keys[i]; + let content = conf[key]; + let rules = resourceLandingPageRules[key]; + let ruleKeys = Object.keys(rules); + for (let k = 0, n = ruleKeys.length; k < n; k++) { + let rule = ruleKeys[k]; + let ruleValidator = rules[rule]; + for (let x = 0, y = content.length; x < y; x++) { + let renderObj = content[x]; + let ruleSubject = renderObj[rule]; + let validResults = ruleValidator(ruleSubject, currConfig, rule); + if (null !== validResults) { + cb(validResults); + } + } + } + } + } + cb(); } function conf() { @@ -63,8 +91,23 @@ function dependencies(cb) { }); } + +let stringLengthRule = function (str, fileName, rulename) { + let maxLen = 125; + if (str.length > maxLen) { + return Error(`Content too long in ${fileName}->${rulename}! Expected ${maxLen} characters, got ${str.length} "${str}"`) + } +} + +let resourceLandingPageRules = { + "grid-container": { + "description": stringLengthRule + } +} + + exports.clean = clean; -exports.default = series(conf, style, scss, root, pkg, typescript, dependencies); +exports.default = series(validateConfigSources, conf, style, scss, root, pkg, typescript, dependencies); -exports.runFast = series(conf, style, scss, root, pkg) \ No newline at end of file +exports.runFast = series(validateConfigSources, conf, style, scss, root, pkg) \ No newline at end of file From fb2a9a65b865d8b671d57283a0469466b6ba1dc4 Mon Sep 17 00:00:00 2001 From: dtookey Date: Thu, 5 Nov 2020 16:02:16 -0500 Subject: [PATCH 04/10] removed red background from footer in resources-landing-page.html. Sometimes it would show when changing themes. --- src/assets/pages/resources-landing-page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/pages/resources-landing-page.html b/src/assets/pages/resources-landing-page.html index d899780..5933d6b 100644 --- a/src/assets/pages/resources-landing-page.html +++ b/src/assets/pages/resources-landing-page.html @@ -64,7 +64,7 @@