distribution and site management

This commit is contained in:
Clément GOUIN
2019-07-10 15:07:32 +02:00
parent 682e84914c
commit 2701ee39e5
14 changed files with 7287 additions and 30 deletions
+1
View File
@@ -1,2 +1,3 @@
/node_modules
/build
/dist
+23 -1
View File
@@ -17,7 +17,8 @@ node build.sh
## Usage
How to use (theorically)
### With node
```javascript
const diag = require('fa-diagrams');
@@ -54,4 +55,25 @@ Will produce the following diagram :
![sample](sample.png)
### On web page
```html
<head>
...
<script src="fa-diagrams-data.min.js"></script>
<script src="fa-diagrams.min.js"></script>
...
</head>
<body>
...
<script>
...
const svg = faDiagrams.compute(data); // string containing xml data
...
</script>
...
</body>
</html>
```
+3 -4
View File
@@ -97,11 +97,10 @@ svn.commands.checkout(FA_SVG_FOLDER_URL, svgDir, (err) => {
console.log(`\t\t${type}: ${Object.keys(svgs[type]).length} SVGs`);
});
const argIndex = process.argv.indexOf('--output');
const output = (argIndex === -1 || !process.argv[argIndex + 1]) ? path.join(buildDir, 'svg_list.json') : process.argv[argIndex + 1];
fs.writeFileSync(output, JSON.stringify(svgs), {encoding: 'utf8'});
const output = path.join(__dirname, 'svg_list.json');
fs.writeFileSync(output, JSON.stringify(svgs, null, 4), {encoding: 'utf8'});
console.log(`\tSVG list saved at "${output}"`);
});
});
Executable
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# temporary file
npm run prepublishOnly
cp dist/*.min.js site
+6162
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){
let list = {};
try {
list = require('../svg_list.json');
}catch(err){
console.error('fa-diagrams: SVG list could not be loaded', err);
}
const self = {
list: list
};
module.exports = self; // Node
global.faDiagrams = self; // Browserify
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../svg_list.json":undefined}]},{},[1]);
+1
View File
@@ -0,0 +1 @@
!function(){return function e(n,r,o){function t(f,u){if(!r[f]){if(!n[f]){var l="function"==typeof require&&require;if(!u&&l)return l(f,!0);if(i)return i(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[f]={exports:{}};n[f][0].call(a.exports,function(e){return t(n[f][1][e]||e)},a,a.exports,e,n,r,o)}return r[f].exports}for(var i="function"==typeof require&&require,f=0;f<o.length;f++)t(o[f]);return t}}()({1:[function(e,n,r){(function(r){let o={};try{o=e("../svg_list.json")}catch(e){console.error("fa-diagrams: SVG list could not be loaded",e)}const t={list:o};n.exports=t,r.faDiagrams=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../svg_list.json":void 0}]},{},[1]);
+1043 -2
View File
File diff suppressed because it is too large Load Diff
+7 -2
View File
@@ -5,11 +5,12 @@
"main": "src/index.js",
"files": [
"/src",
"/dist",
"/svg_list.json"
],
"scripts": {
"test": "jest --silent",
"prepublishOnly": "node build.js --output svg_list.json"
"prepublishOnly": "browserify --require ./svg_list.json:../svg_list.json -o dist/fa-diagrams-data.js && browserify --exclude ../svg_list.json src/index.js -o dist/fa-diagrams.js && uglifyjs -m -c -o dist/fa-diagrams.min.js -- dist/fa-diagrams.js && uglifyjs -m -c -o dist/fa-diagrams-data.min.js -- dist/fa-diagrams-data.js"
},
"repository": {
"type": "git",
@@ -26,7 +27,9 @@
"url": "https://github.com/Klemek/fa-diagrams/issues"
},
"homepage": "https://github.com/Klemek/fa-diagrams#readme",
"dependencies": {},
"dependencies": {
},
"jest": {
"collectCoverageFrom": [
"src/**/*.js",
@@ -34,6 +37,8 @@
]
},
"devDependencies": {
"uglify-es": "^3.3.9",
"browserify": "^16.3.0",
"coveralls": "^3.0.4",
"jest": "^24.8.0",
"jshint": "^2.10.2",
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
!function(){return function e(n,r,o){function t(f,u){if(!r[f]){if(!n[f]){var l="function"==typeof require&&require;if(!u&&l)return l(f,!0);if(i)return i(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[f]={exports:{}};n[f][0].call(a.exports,function(e){return t(n[f][1][e]||e)},a,a.exports,e,n,r,o)}return r[f].exports}for(var i="function"==typeof require&&require,f=0;f<o.length;f++)t(o[f]);return t}}()({1:[function(e,n,r){(function(r){let o={};try{o=e("../svg_list.json")}catch(e){console.error("fa-diagrams: SVG list could not be loaded",e)}const t={list:o};n.exports=t,r.faDiagrams=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../svg_list.json":void 0}]},{},[1]);
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>fa-diagrams example</title>
<script src="fa-diagrams-data.min.js"></script>
<script src="fa-diagrams.min.js"></script>
</head>
<body>
<h1 id="title">WIP</h1>
</body>
</html>
+5 -17
View File
@@ -1,25 +1,13 @@
const path = require('path');
const loadList = () => {
const paths = [
path.join(__dirname, '..', 'build', 'svg_list.json'),
path.join(__dirname, '..', 'svg_list.json'),
];
for (let p = 0; p < paths.length; p++) {
let list = {};
try {
return require(paths[p]);
list = require('../svg_list.json');
}catch(err){
//ignored
console.error('fa-diagrams: SVG list could not be loaded', err);
}
}
console.error('fa-diagrams: SVG list was not found at the following paths:\n\t* ' + paths.join('\n\t* '));
return {};
};
const list = loadList();
const self = {
list: list
};
module.exports = self;
module.exports = self; // Node
global['faDiagrams'] = self; // Browserify