mirror of
https://github.com/tbluemel/rtf.js.git
synced 2026-11-30 16:47:59 +01:00
To capture types using typewiz run 'npm run typewiz'. Afterwards check the generated types and run the normal build and test
This commit is contained in:
Generated
+41
@@ -786,6 +786,17 @@
|
||||
"mime-types": "2.1.18"
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz",
|
||||
"integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11",
|
||||
"jsonfile": "4.0.0",
|
||||
"universalify": "0.1.1"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
@@ -840,6 +851,12 @@
|
||||
"is-glob": "2.0.1"
|
||||
}
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
},
|
||||
"growl": {
|
||||
"version": "1.10.3",
|
||||
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
|
||||
@@ -1244,6 +1261,15 @@
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
|
||||
"dev": true
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11"
|
||||
}
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
||||
@@ -4835,6 +4861,15 @@
|
||||
"integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==",
|
||||
"dev": true
|
||||
},
|
||||
"typewiz": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/typewiz/-/typewiz-0.6.0.tgz",
|
||||
"integrity": "sha512-FHw0gnLo1z/XBtHOvk+FNtITwBEY//uwVGmcYxZDTx5EEYgVaYZ5vs4pKtI+1CmgyePFTF4M42oXvz2UqxDTUA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"typescript": "2.7.2"
|
||||
}
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "2.8.29",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
|
||||
@@ -4863,6 +4898,12 @@
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
|
||||
"integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=",
|
||||
"dev": true
|
||||
},
|
||||
"urix": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",
|
||||
|
||||
+6
-2
@@ -15,7 +15,8 @@
|
||||
"test": "mocha test/test-rtfjs.js",
|
||||
"coverage": "rimraf .nyc_output && cd dist && nyc instrument . . && cd .. && nyc mocha test/test-rtfjs.js && nyc report --report-dir=.nyc_output --reporter=json",
|
||||
"coverage-html": "rimraf coverage && cd dist && remap-istanbul --input ../.nyc_output/coverage-final.json --output ../coverage --type html && cd ..",
|
||||
"coverage-coveralls": "cd dist && remap-istanbul --input ../.nyc_output/coverage-final.json --type text-lcov | coveralls && cd .."
|
||||
"coverage-coveralls": "cd dist && remap-istanbul --input ../.nyc_output/coverage-final.json --type text-lcov | coveralls && cd ..",
|
||||
"typewiz": "npm run clean && node typewiz-instrument build src/**/*.ts src/**/**/*.ts src/**/**/**/*.ts && npm run bundle && npm run test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,6 +36,8 @@
|
||||
"chai": "^4.1.2",
|
||||
"chai-html": "^1.1.5",
|
||||
"coveralls": "^3.0.0",
|
||||
"fs-extra": "^5.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"jsdom": "^11.6.2",
|
||||
"mocha": "^5.0.1",
|
||||
"nyc": "^11.6.0",
|
||||
@@ -45,7 +48,8 @@
|
||||
"rollup-plugin-node-resolve": "^3.0.3",
|
||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
||||
"tslint": "^5.9.1",
|
||||
"typescript": "2.7.2"
|
||||
"typescript": "2.7.2",
|
||||
"typewiz": "^0.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"codepage": "^1.12.0"
|
||||
|
||||
+9
-1
@@ -4,6 +4,7 @@ var chai = require("chai");
|
||||
var expect = require("chai").expect;
|
||||
var chaiHtml = require('chai-html');
|
||||
chai.use(chaiHtml);
|
||||
var typewiz = require('typewiz');
|
||||
|
||||
var utils = require("./utils");
|
||||
|
||||
@@ -28,6 +29,7 @@ function getTestFiles() {
|
||||
var testFiles = getTestFiles();
|
||||
|
||||
describe("Test files", function() {
|
||||
var $_$twiz;
|
||||
testFiles.forEach(function(testFile) {
|
||||
describe(testFile.name, function() {
|
||||
this.timeout(0);
|
||||
@@ -35,11 +37,12 @@ describe("Test files", function() {
|
||||
var result;
|
||||
|
||||
before(function(done) {
|
||||
utils.runRtfjs(testFile.dir, testFile.source, function (meta, html) {
|
||||
utils.runRtfjs(testFile.dir, testFile.source, function (meta, html, twiz) {
|
||||
result = {
|
||||
html: html,
|
||||
metadata: JSON.parse(meta)
|
||||
};
|
||||
$_$twiz = twiz;
|
||||
done();
|
||||
}, function (error) {
|
||||
var formattedError = new Error(error.message);
|
||||
@@ -61,4 +64,9 @@ describe("Test files", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
after(function() {
|
||||
// Apply captured types
|
||||
typewiz.applyTypes($_$twiz.get());
|
||||
});
|
||||
});
|
||||
|
||||
+4
-2
@@ -1,5 +1,6 @@
|
||||
var jsdom = require("jsdom");
|
||||
var { JSDOM } = jsdom;
|
||||
var $_$twiz = require('typewiz/dist/type-collector-snippet').$_$twiz;
|
||||
|
||||
function stringToBinaryArray(string) {
|
||||
var buffer = new ArrayBuffer(string.length);
|
||||
@@ -92,7 +93,7 @@ exports.runRtfjs = function(path, source, callback, errorCallback) {
|
||||
window.path = path;
|
||||
window.rtfFile = stringToBinaryArray(source);
|
||||
window.done = function(meta, html){
|
||||
callback(JSON.stringify(meta, null, 4), indentHtml(html));
|
||||
callback(JSON.stringify(meta, null, 4), indentHtml(html), $_$twiz);
|
||||
};
|
||||
window.onerror = function (error) {
|
||||
errorCallback(error)
|
||||
@@ -100,6 +101,7 @@ exports.runRtfjs = function(path, source, callback, errorCallback) {
|
||||
// Catch exceptions from jquery.svg.min.js
|
||||
window.alert = function (error) {
|
||||
errorCallback(error)
|
||||
}
|
||||
};
|
||||
window.$_$twiz = $_$twiz;
|
||||
}});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
const typewiz = require('typewiz');
|
||||
const glob = require('glob');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const ts = require('typescript');
|
||||
|
||||
if (process.argv.length < 4) {
|
||||
console.error("You have to provide the files to instrument as an argument.");
|
||||
process.exit(1);
|
||||
throw "Abort";
|
||||
}
|
||||
|
||||
const targetDirectory = process.argv[2];
|
||||
|
||||
fs.mkdir(targetDirectory, function(err) {
|
||||
if (err) {
|
||||
console.error("Could not create directory '" + targetDirectory + "', does the directory already exist?");
|
||||
process.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
process.argv.slice(3).forEach(argument => {
|
||||
glob(argument, {}, function (err, files) {
|
||||
if (!err) {
|
||||
files.forEach(fileName => {
|
||||
const source = fs.readFileSync(fileName, 'utf8');
|
||||
const instrumentedSource = typewiz.instrument(source, fileName);
|
||||
|
||||
let target = fileName.split(path.sep);
|
||||
target.splice(0,1);
|
||||
target.unshift(targetDirectory);
|
||||
target = target.join(path.sep);
|
||||
target = target.replace(/\.ts$/, '.js');
|
||||
fs.ensureFileSync(target);
|
||||
|
||||
const compiled = ts.transpile(instrumentedSource, {
|
||||
module: ts.ModuleKind.ES2015,
|
||||
target: ts.ScriptTarget.ES5
|
||||
});
|
||||
|
||||
fs.writeFileSync(target, compiled);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user