Skip to content

Commit

Permalink
Merge branch 'develop' into gh-pages
Browse files Browse the repository at this point in the history
* develop:
  v12.0.3
  chore(package): remove unused test
  chore(package): remove generic test script
  chore(package): removed unused test
  test(tests/test-build): fixup tests/test-build
  fix(tools/builder): dont run when imported as module
  refactor: switch from fs-promise to fs-extra (#1229)
  chore(package): force move hljs
  chore: use hljs from command line (#1228)
  chore(.travis): split into jobs/stages (#1222)
  chore(package): update deps (#1218)
  • Loading branch information
marcoscaceres committed May 19, 2017
2 parents 9e02639 + b3d5bab commit f6f0ee3
Show file tree
Hide file tree
Showing 11 changed files with 848 additions and 234 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Expand Up @@ -19,6 +19,8 @@ before_script:
- unzip out/chrome-linux.zip -d out
- export CHROME_CANARY_BIN=$PWD/out/chrome-linux/chrome
- export CHROME_BIN=$PWD/out/chrome-linux/chrome
- yarn run build


addons:
firefox: "latest"
Expand All @@ -28,10 +30,13 @@ addons:
packages:
- google-chrome-stable

script:
- yarn run pretest
- yarn run build
- yarn run test:headless
- travis_retry karma start --single-run --reporters mocha karma.conf.js

cache: yarn

jobs:
include:
- stage: Pretest
script: yarn run pretest
- stage: Headless tests
script: yarn run test:headless
- stage: Karma
script: travis_retry karma start --single-run --reporters mocha karma.conf.js
2 changes: 1 addition & 1 deletion builds/respec-w3c-common.build.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions builds/respec-w3c-common.js

Large diffs are not rendered by default.

31 changes: 14 additions & 17 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "respec",
"version": "12.0.2",
"version": "12.0.3",
"license": "W3C",
"description": "A technical specification pre-processor.",
"engines": {
Expand All @@ -23,16 +23,16 @@
"clipboard": "^1.6.1",
"domReady": "github:requirejs/domReady",
"glob": "^7.1.1",
"handlebars": "^4.0.7",
"http-server": "^0.9.0",
"handlebars": "^4.0.8",
"http-server": "^0.10.0",
"jasmine-core": "^2.6.1",
"jasmine-reporters": "^2.2.1",
"jquery": "^3.2.1",
"js-beautify": "^1.6.12",
"js-beautify": "^1.6.14",
"jscs": "^3.0.7",
"jshint": "^2.9.4",
"karma": "^1.6.0",
"karma-chrome-launcher": "^2.0.0",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-detect-browsers": "^2.2.5",
"karma-edge-launcher": "^0.4.1",
"karma-firefox-launcher": "^1.0.1",
Expand All @@ -44,7 +44,7 @@
"karma-safari-launcher": "^1.0.0",
"karma-safaritechpreview-launcher": "0.0.5",
"karma-verbose-summary-reporter": "0.0.1",
"mocha": "^3.3.0",
"mocha": "^3.4.1",
"moment": "^2.18.1",
"requirejs": "^2.3.3",
"text": "github:requirejs/text",
Expand All @@ -56,7 +56,7 @@
"babel:build": "babel src -d js --source-maps",
"babel:watch": "babel src -d js --watch --source-maps",
"build": "npm run hb:build && npm run build:highlight && npm run babel:build && npm run copydeps && npm run build:respec-w3c-common",
"build:highlight": "cd node_modules/highlight.js/ && npm install && node ./tools/build.js -n xml javascript css http markdown json abnf && cd ../../",
"build:highlight": "hljs -n --output js/deps/ xml javascript css http markdown json abnf; mv -f js/deps/highlight.pack.js js/deps/highlight.js",
"build:respec-w3c-common": "./tools/builder.js --profile=w3c-common",
"copydeps": "node ./tools/copydeps.js",
"handlebars": "handlebars",
Expand All @@ -70,28 +70,25 @@
"server": "npm start",
"snyk-protect": "snyk protect",
"start": "http-server",
"test": "npm run test:headless && npm run test:karma",
"test:appveyor": "npm run pretest",
"test:build": "mocha ./tests/test-build.js",
"test:headless": "node ./tests/headless.js",
"test:karma": "npm run karma",
"test:travis": "npm run pretest && npm run test:build && karma start --single-run --reporters progress karma.conf.js && npm run test:headless"
"test:karma": "npm run karma"
},
"dependencies": {
"colors": "^1.1.2",
"command-line-args": "^4.0.3",
"command-line-args": "^4.0.4",
"command-line-usage": "^4.0.0",
"epipebomb": "^1.0.0",
"express": "^4.15.2",
"fs-promise": "^2.0.2",
"highlight.js": "github:isagalaev/highlight.js",
"hyperhtml": "^0.10.2",
"fs-extra": "^3.0.1",
"highlight.js": "github:marcoscaceres/highlight.js",
"hyperhtml": "^0.11.0",
"loading-indicator": "^2.0.0",
"marcosc-async": "^4.0.3",
"marked": "^0.3.6",
"nightmare": "^2.10.0",
"prompt": "^1.0.0",
"snyk": "^1.29.0"
"snyk": "^1.30.1"
},
"snyk": true
}
58 changes: 13 additions & 45 deletions tests/test-build.js
Expand Up @@ -3,10 +3,10 @@
"use strict";
const async = require("marcosc-async");
const colors = require("colors");
const fsp = require("fs-promise");
const fsp = require("fs-extra");
const path = require("path");
const expect = require("chai").expect;
const builder = require("../tools/build-w3c-common");
const { Builder } = require("../tools/builder");

colors.setTheme({
data: "grey",
Expand All @@ -27,64 +27,32 @@ function checkIfFileExists(filePath) {
});
}

describe("build-w3c-common.js (tool)", function() {
describe("builder (tool)", function() {
// Generating respec + maps takes time.
this.timeout(60000);

// These files get deleted in after().
let customPath = "";
let customMapPath = "";

const latestMap = path.join(
__dirname,
"../builds/respec-w3c-common.build.js.map"
);
const latest = path.join(__dirname, "../builds/respec-w3c-common.js");
it(
"should have built default respec",
async(function*() {
const latest = path.join(__dirname, "../builds/respec-w3c-common.js");
const latestMap = path.join(
__dirname,
"../builds/respec-w3c-common.build.js.map"
);
yield builder.buildW3C();
yield Builder.build({ name: "w3c-common" });
expect(yield checkIfFileExists(latest)).to.equal(true);
expect(yield checkIfFileExists(latestMap)).to.equal(true);
})
);

it(
"should have built a custom version respec",
async(function*() {
const randomName = "test-" + Math.round(Math.random() * 10000000);
customPath = path.join(
__dirname,
`../builds/respec-w3c-common-${randomName}.js`
);
customMapPath = path.join(
__dirname,
`../builds/respec-w3c-common-${randomName}.build.js.map`
);
yield builder.buildW3C(randomName);
expect(yield checkIfFileExists(customPath)).to.equal(true);
expect(yield checkIfFileExists(customMapPath)).to.equal(true);
})
);

describe("respec-w3c-common.build.js", function() {
it(
"should include the link to the sourcemap",
async(function*() {
var source = yield fsp.readFile(customPath, "utf-8");
var mapFilename = path.basename(customMapPath);
expect(source.includes(mapFilename)).to.equal(true);
var source = yield fsp.readFile(latest, "utf-8");
expect(source.search("respec-w3c-common.build.js.map")).to.not.equal(
-1
);
})
);
});

after(
async(function*() {
yield Promise.all([fsp.remove(customPath), fsp.remove(customMapPath)]);
const msg = ` Deleted test files:
${colors.input(path.basename(customPath))}
${colors.input(path.basename(customMapPath))}`;
console.log(colors.info(msg));
})
);
});
55 changes: 28 additions & 27 deletions tools/builder.js
Expand Up @@ -3,7 +3,7 @@
"use strict";
const async = require("marcosc-async");
const colors = require("colors");
const fsp = require("fs-promise");
const fsp = require("fs-extra");
const loading = require("loading-indicator");
const path = require("path");
const presets = require("loading-indicator/presets");
Expand Down Expand Up @@ -155,29 +155,30 @@ const Builder = {
};

exports.Builder = Builder;

async.task(function* run() {
let parsedArgs;
try {
parsedArgs = commandLineArgs(optionList);
} catch (err) {
console.info(getUsage(usageSections));
console.error(colors.error(err.stack));
return process.exit(127);
}
if (parsedArgs.help) {
console.info(getUsage(usageSections));
return process.exit(0);
}
const { profile: name } = parsedArgs;
if (!name) {
return;
}
try {
yield Builder.build({ name });
} catch (err) {
console.error(colors.error(err.stack));
return process.exit(1);
}
process.exit(0);
});
if (require.main === module) {
async.task(function* run() {
let parsedArgs;
try {
parsedArgs = commandLineArgs(optionList);
} catch (err) {
console.info(getUsage(usageSections));
console.error(colors.error(err.stack));
return process.exit(127);
}
if (parsedArgs.help) {
console.info(getUsage(usageSections));
return process.exit(0);
}
const { profile: name } = parsedArgs;
if (!name) {
return;
}
try {
yield Builder.build({ name });
} catch (err) {
console.error(colors.error(err.stack));
return process.exit(1);
}
process.exit(0);
});
}
6 changes: 1 addition & 5 deletions tools/copydeps.js
Expand Up @@ -2,7 +2,7 @@

"use strict";
const async = require("marcosc-async");
const fsp = require("fs-promise");
const fsp = require("fs-extra");
const path = require("path");

const srcDesMap = new Map([
Expand All @@ -12,10 +12,6 @@ const srcDesMap = new Map([
"./node_modules/handlebars/dist/handlebars.runtime.js",
"./js/deps/handlebars.js",
],
[
"./node_modules/highlight.js/build/highlight.pack.js",
"./js/deps/highlight.js",
],
["./node_modules/highlight.js/src/styles/github.css", "./js/core/css/"],
["./node_modules/hyperhtml/hyperhtml.js", "./js/deps/"],
["./node_modules/jquery/dist/jquery.js", "./js/deps/"],
Expand Down
2 changes: 1 addition & 1 deletion tools/make-test-file-build.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node

"use strict";
const fsp = require("fs-promise");
const fsp = require("fs-extra");
const path = require("path");
const { exec } = require("child_process");
const testsPath = path.resolve(__dirname, "../tests");
Expand Down
2 changes: 1 addition & 1 deletion tools/release.js
Expand Up @@ -6,7 +6,7 @@ const { Builder } = require("./builder");
const cmdPrompt = require("prompt");
const colors = require("colors");
const { exec } = require("child_process");
const fsp = require("fs-promise");
const fsp = require("fs-extra");
const loading = require("loading-indicator");
const path = require("path");
const MAIN_BRANCH = "develop";
Expand Down
20 changes: 2 additions & 18 deletions tools/respecDocWriter.js
Expand Up @@ -10,8 +10,7 @@ const async = require("marcosc-async");
const os = require("os");
const Nightmare = require("nightmare");
const colors = require("colors");
const fsp = require("fs-promise");
const fs = require("fs");
const fsp = require("fs-extra");
const path = require("path");
const parseURL = require("url").parse;
colors.setTheme({
Expand Down Expand Up @@ -43,21 +42,6 @@ const tasks = {
}
});
},
/**
* Makes a temporary directory.
*
* @private
* @param {String} prefix The prefix to use, to distinguish it from other tmp
* directories.
* @return {Promise} Resolves if dir is created; rejects otherwise.
*/
makeTempDir(prefix) {
return new Promise((resolve, reject) => {
fs.mkdtemp(prefix, (err, folder) => {
return err ? reject(err) : resolve(folder);
});
});
},
/**
* Fetches a ReSpec "src" URL, processes via NightmareJS and writes it to an
* "out" path within a given "timeout".
Expand All @@ -76,7 +60,7 @@ const tasks = {
*/
fetchAndWrite(src, out, whenToHalt, timeout) {
return async.task(function*() {
const userData = yield this.makeTempDir(os.tmpdir() + "/respec2html-");
const userData = yield fsp.mkdtemp(os.tmpdir() + "/respec2html-");
const nightmare = new Nightmare({
show: false,
timeout,
Expand Down

0 comments on commit f6f0ee3

Please sign in to comment.