Skip to content

Commit 3666eee

Browse files
committed
Complet sweep with ESLint, airbnb + prettier config.
1 parent 20d26a6 commit 3666eee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+15683
-11090
lines changed

dev/cssToJS.js

+67-68
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,75 @@
11
// Reads the apglib.css file and outputs a JavaScript function
2+
23
// which will return the CSS as a string.
3-
module.exports = function (inFile, outFile) {
4-
"use strict";
4+
module.exports = function cssToJs(inFile, outFile) {
5+
// function capFirst(str) {
6+
// return str.charAt(0).toUpperCase() + str.slice(1);
7+
// }
58

6-
function capFirst(str) {
7-
return str.charAt(0).toUpperCase() + str.slice(1);
8-
}
9+
function getFileExtension(filename) {
10+
// eslint-disable-next-line no-bitwise
11+
return filename.slice(((filename.lastIndexOf('.') - 1) >>> 0) + 2);
12+
}
913

10-
function getFileExtension(filename) {
11-
return filename.slice(((filename.lastIndexOf(".") - 1) >>> 0) + 2);
14+
const fs = require('fs');
15+
try {
16+
/* validate arguments */
17+
if (!inFile) {
18+
throw new Error('missing input CSS file (name.css)');
1219
}
13-
14-
let fs = require("fs");
15-
try {
16-
/* validate arguments */
17-
if (!inFile) {
18-
throw new Error("missing input CSS file (name.css)");
19-
}
20-
if (getFileExtension(inFile) !== "css") {
21-
throw new Error("input CSS file (" + inFile + ") must have .css extension");
22-
}
23-
if (!outFile) {
24-
throw new Error("missing output JavaScript file (name.js)");
25-
}
26-
if (getFileExtension(outFile) !== "js") {
27-
throw new Error("output JavaScript file (" + outFile + ") must have .js extension");
28-
}
29-
let cssBuf = fs.readFileSync(inFile);
30-
let cssStr = "";
31-
debugger;
32-
for (let i = 0; i < cssBuf.length; i += 1) {
33-
let char = cssBuf[i];
34-
if (char >= 32 && char <= 38) {
35-
cssStr += String.fromCharCode(char);
36-
} else if (char >= 40 && char <= 91) {
37-
cssStr += String.fromCharCode(char);
38-
} else if (char >= 93 && char <= 126) {
39-
cssStr += String.fromCharCode(char);
40-
} else {
41-
switch (char) {
42-
case 9:
43-
cssStr += "\\t";
44-
break;
45-
case 10:
46-
cssStr += "\\n";
47-
break;
48-
case 13:
49-
cssStr += "\\r";
50-
break;
51-
case 39:
52-
cssStr += "\\'";
53-
break;
54-
case 92:
55-
cssStr += "\\\\";
56-
break;
57-
default:
58-
/* ignore invalid string characters */
59-
break;
60-
}
61-
}
20+
if (getFileExtension(inFile) !== 'css') {
21+
throw new Error(`input CSS file (${inFile}) must have .css extension`);
22+
}
23+
if (!outFile) {
24+
throw new Error('missing output JavaScript file (name.js)');
25+
}
26+
if (getFileExtension(outFile) !== 'js') {
27+
throw new Error(`output JavaScript file (${outFile}) must have .js extension`);
28+
}
29+
const cssBuf = fs.readFileSync(inFile);
30+
let cssStr = '';
31+
for (let i = 0; i < cssBuf.length; i += 1) {
32+
const char = cssBuf[i];
33+
if (char >= 32 && char <= 38) {
34+
cssStr += String.fromCharCode(char);
35+
} else if (char >= 40 && char <= 91) {
36+
cssStr += String.fromCharCode(char);
37+
} else if (char >= 93 && char <= 126) {
38+
cssStr += String.fromCharCode(char);
39+
} else {
40+
switch (char) {
41+
case 9:
42+
cssStr += '\\t';
43+
break;
44+
case 10:
45+
cssStr += '\\n';
46+
break;
47+
case 13:
48+
cssStr += '\\r';
49+
break;
50+
case 39:
51+
cssStr += "\\'";
52+
break;
53+
case 92:
54+
cssStr += '\\\\';
55+
break;
56+
default:
57+
/* ignore invalid string characters */
58+
break;
6259
}
63-
64-
let js = "// This module has been developed programmatically in the `apg-lib` build process.\n";
65-
js +=
66-
"// It is used to build web pages programatically on the fly without the need for <script> or <style> tags.\n";
67-
js += "\n";
68-
js += "module.exports = function(){\n";
69-
js += "return '" + cssStr + "';";
70-
js += "\n}\n";
71-
fs.writeFileSync(outFile, js);
72-
} catch (e) {
73-
console.log("cssToJS.js: EXCEPTION: \n");
74-
console.log(e.message);
60+
}
7561
}
62+
63+
let js = '// This module has been developed programmatically in the `apg-lib` build process.\n';
64+
js +=
65+
'// It is used to build web pages programatically on the fly without the need for <script> or <style> tags.\n';
66+
js += '\n';
67+
js += 'module.exports = function emittcss(){\n';
68+
js += `return '${cssStr}';`;
69+
js += '\n}\n';
70+
fs.writeFileSync(outFile, js);
71+
} catch (e) {
72+
console.log('cssToJS.js: EXCEPTION: \n');
73+
console.log(e.message);
74+
}
7675
};

dev/index.js

-2
This file was deleted.

dist/apg-api-bundle.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apg-conv-api-bundle.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apg-exp-bundle.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apg-lib-bundle.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/* *************************************************************************************
22
* copyright: Copyright (c) 2021 Lowell D. Thomas, all rights reserved
33
* license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)
4-
* website: https://sabnf.com/
5-
* ***********************************************************************************/
4+
* ********************************************************************************* */
65
module.exports = {
7-
apg: require("./src/apg/apg.js"),
8-
apgConv: require("./src/apg-conv/apg-conv.js"),
9-
apgConvApi: require("./src/apg-conv-api/node-exports.js"),
10-
apgLib: require("./src/apg-lib/node-exports.js"),
11-
apgApi: require("./src/apg-api/api.js"),
12-
apgExp: require("./src/apg-exp/apg-exp.js"),
6+
apg: require('./src/apg/apg'),
7+
apgConv: require('./src/apg-conv/apg-conv'),
8+
apgConvApi: require('./src/apg-conv-api/node-exports'),
9+
apgLib: require('./src/apg-lib/node-exports'),
10+
apgApi: require('./src/apg-api/api'),
11+
apgExp: require('./src/apg-exp/apg-exp'),
1312
};

0 commit comments

Comments
 (0)