Skip to content

Commit

Permalink
chore(*): de-support node 8 and 11
Browse files Browse the repository at this point in the history
also ⬆️ @types/chai, @types/lodash, @types/mocha, @types/node, @types/puppeteer, @types/semver, ajv, commander, dependency-cruiser, mocha, mscgenjs, mscgenjs-inpage, nyc, prettier, puppeteer, semver, ts-node, tslint, typescript, upem

also keep puppeteer on 2.1.1 as 3.x does install incorrectly when npm i'd in node 14. Also see puppeteer/puppeteer#5719
  • Loading branch information
sverweij committed Apr 27, 2020
1 parent be9a06d commit 31757a3
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 175 deletions.
7 changes: 4 additions & 3 deletions .codeclimate.yml
Expand Up @@ -4,13 +4,14 @@ checks:
config:
threshold: 30
plugins:
eslint:
enabled: false
tslint:
enabled: true
config: tslint.json
enabled: false
exclude_patterns:
- ".github/"
- "dist/"
- "samples/"
- "test/"
- "utl/"
- "**/node_modules/"
- "**/node_modules/"
8 changes: 8 additions & 0 deletions .gitattributes
@@ -0,0 +1,8 @@
* text eol=lf

*.jpg binary
*.kra binary
*.png binary
*.wav binary
*.mp3 binary
*.ogg binary
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,6 @@ sudo: required
language: node_js

node_js:
- "8"
- "10"
- "12"
- stable
Expand Down
12 changes: 6 additions & 6 deletions dist/actions/index.js
Expand Up @@ -12,7 +12,7 @@ function isGraphicsOutput(pOutputType) {
function getAST(pInput, pOptions) {
return mscgenjs_1.translateMsc(pInput, {
inputType: pOptions.inputType,
outputType: "ast"
outputType: "ast",
});
}
function removeAutoWidth(pAST, pOutputType) {
Expand All @@ -25,18 +25,18 @@ function removeAutoWidth(pAST, pOutputType) {
exports.removeAutoWidth = removeAutoWidth;
function render(pOptions) {
return getStream(fileNameToStream_1.getInStream(pOptions.inputFrom))
.then(pInput => getAST(pInput, pOptions))
.then(pAST => render_1.renderWithChromeHeadless(removeAutoWidth(pAST, pOptions.outputType), pOptions));
.then((pInput) => getAST(pInput, pOptions))
.then((pAST) => render_1.renderWithChromeHeadless(removeAutoWidth(pAST, pOptions.outputType), pOptions));
}
function transpile(pOptions) {
return getStream(fileNameToStream_1.getInStream(pOptions.inputFrom)).then(pInput => mscgenjs_1.translateMsc(pInput, pOptions));
return getStream(fileNameToStream_1.getInStream(pOptions.inputFrom)).then((pInput) => mscgenjs_1.translateMsc(pInput, pOptions));
}
function transform(pOptions) {
if (isGraphicsOutput(pOptions.outputType)) {
return render(pOptions).then(pResult => fileNameToStream_1.getOutStream(pOptions.outputTo).write(pResult));
return render(pOptions).then((pResult) => fileNameToStream_1.getOutStream(pOptions.outputTo).write(pResult));
}
else {
return transpile(pOptions).then(pResult => fileNameToStream_1.getOutStream(pOptions.outputTo).write(pResult, "utf8"));
return transpile(pOptions).then((pResult) => fileNameToStream_1.getOutStream(pOptions.outputTo).write(pResult, "utf8"));
}
}
exports.transform = transform;
Expand Down
10 changes: 5 additions & 5 deletions dist/actions/render.js
Expand Up @@ -23,7 +23,7 @@ function cookEvalFunction(pAST, pOptions) {
}
function getPuppeteerLaunchOptions(pPuppeteerLaunchOptions) {
return Object.assign({
headless: true
headless: true,
}, pPuppeteerLaunchOptions || {});
}
function renderSVG(page) {
Expand All @@ -50,12 +50,12 @@ function renderBitmap(page, pOptions) {
deviceScaleFactor: 2,
height: 1,
isMobile: false,
width: 1
width: 1,
});
return yield page.screenshot({
fullPage: true,
omitBackground: false,
type: pOptions.outputType
type: pOptions.outputType,
});
});
}
Expand All @@ -66,11 +66,11 @@ function renderWithChromeHeadless(pAST, pOptions) {
browser = yield puppeteer.launch(getPuppeteerLaunchOptions(pOptions.puppeteerOptions));
const page = yield browser.newPage();
yield page.goto(`file:///${__dirname}/template.html`, {
waitUntil: "networkidle2"
waitUntil: "networkidle2",
});
yield page.evaluate(cookEvalFunction(JSON.stringify(pAST), pOptions));
yield page.addScriptTag({
path: require.resolve("mscgenjs-inpage")
path: require.resolve("mscgenjs-inpage"),
});
yield page.waitFor("mscgen#replaceme[data-renderedby='mscgen_js']");
if (pOptions.outputType === "svg") {
Expand Down
4 changes: 2 additions & 2 deletions dist/cli/index.js
Expand Up @@ -25,13 +25,13 @@ try {
program
/* tslint:disable-next-line */
.version(require("../../package.json").version)
.option("-T --output-type <type>", validations.validOutputTypeRE, validations.validOutputType)
.option("-T --output-type <type>", validations.validOutputTypeRE, (pOutputType) => validations.validOutputType(pOutputType))
.option("-I --input-type <type>", validations.validInputTypeRE, validations.validInputType)
.option("-i --input-from <file>", "File to read from. use - for stdin.")
.option("-o --output-to <file>", "File to write to. use - for stdout.")
.option("-p --parser-output", "Print parsed msc output")
.option("-s --css <string>", "Additional styles to use. Experimental")
.option("-n --named-style <style>", validations.validNamedStyleRE, validations.validNamedStyle)
.option("-n --named-style <style>", validations.validNamedStyleRE, (pNamedStyle) => validations.validNamedStyle(pNamedStyle))
.option("-m --mirror-entities", `Repeat the entities on the chart's
bottom`)
.option("-v --vertical-alignment <align>", `Vertical alignment of labels on regular
Expand Down
4 changes: 2 additions & 2 deletions dist/cli/normalizations.js
Expand Up @@ -9,7 +9,7 @@ const INPUT_EXTENSIONS = Object.freeze({
mscin: "mscgen",
msgenny: "msgenny",
seq: "mscgen",
xu: "xu"
xu: "xu",
});
const OUTPUT_EXTENSIONS = Object.freeze({
ast: "json",
Expand All @@ -25,7 +25,7 @@ const OUTPUT_EXTENSIONS = Object.freeze({
png: "png",
seq: "mscgen",
svg: "svg",
xu: "xu"
xu: "xu",
});
/**
* Given a filename in pString, returns what language is probably
Expand Down
12 changes: 6 additions & 6 deletions dist/cli/validations.js
Expand Up @@ -6,7 +6,7 @@ const mscgenjs = require("mscgenjs");
/* tslint:disable-next-line */
const puppeteerOptionsSchema = require("./puppeteer-options.schema.json");
const VALID_GRAPHICS_TYPES = Object.freeze(["svg", "png", "jpeg"]);
const VALID_OUTPUT_TYPES = VALID_GRAPHICS_TYPES.concat(mscgenjs.getAllowedValues().outputType.map(pValue => pValue.name));
const VALID_OUTPUT_TYPES = VALID_GRAPHICS_TYPES.concat(mscgenjs.getAllowedValues().outputType.map((pValue) => pValue.name));
const ajv = new Ajv();
function isStdout(pFilename) {
return "-" === pFilename;
Expand All @@ -32,7 +32,7 @@ function isValidValue(pAttribute, pCandidateValue) {
return mscgenjs.getAllowedValues()[pAttribute].some((pValue) => pValue.name === pCandidateValue);
}
function validOutputType(pType) {
if (VALID_OUTPUT_TYPES.some(pName => pName === pType)) {
if (VALID_OUTPUT_TYPES.some((pName) => pName === pType)) {
return pType;
}
throw Error(`\n error: '${pType}' is not a valid output type. mscgen_js can emit:` +
Expand Down Expand Up @@ -112,14 +112,14 @@ exports.validPuppeteerOptions = validPuppeteerOptions;
exports.validOutputTypeRE = VALID_OUTPUT_TYPES.join("|");
exports.validInputTypeRE = mscgenjs
.getAllowedValues()
.inputType.map(pValue => pValue.name)
.inputType.map((pValue) => pValue.name)
.join("|");
exports.validNamedStyleRE = mscgenjs
.getAllowedValues()
.namedStyle.filter(pValue => pValue.experimental === false && pValue.deprecated === false)
.map(pValue => pValue.name)
.namedStyle.filter((pValue) => pValue.experimental === false && pValue.deprecated === false)
.map((pValue) => pValue.name)
.join("|");
exports.validVerticalAlignmentRE = mscgenjs
.getAllowedValues()
.regularArcTextVerticalAlignment.map(pValue => pValue.name)
.regularArcTextVerticalAlignment.map((pValue) => pValue.name)
.join("|");
58 changes: 29 additions & 29 deletions package.json
Expand Up @@ -11,7 +11,7 @@
],
"license": "GPL-3.0",
"engines": {
"node": ">=8.0"
"node": "^10||^12||>=13"
},
"bugs": {
"url": "https://github.com/mscgenjs/mscgenjs-cli/issues"
Expand Down Expand Up @@ -42,36 +42,44 @@
"msgenny"
],
"dependencies": {
"ajv": "6.10.2",
"commander": "4.0.1",
"ajv": "6.12.2",
"commander": "5.1.0",
"get-stream": "5.1.0",
"lodash": "4.17.15",
"mscgenjs": "4.0.4",
"mscgenjs-inpage": "2.0.13",
"puppeteer": "2.0.0",
"semver": "6.3.0"
"mscgenjs": "5.0.0",
"mscgenjs-inpage": "3.0.0",
"puppeteer": "2.1.1",
"semver": "7.3.2"
},
"devDependencies": {
"@types/chai": "4.2.7",
"@types/chai": "4.2.11",
"@types/chai-as-promised": "7.1.2",
"@types/lodash": "4.14.149",
"@types/mocha": "5.2.7",
"@types/node": "13.1.2",
"@types/puppeteer": "2.0.0",
"@types/semver": "6.2.0",
"@types/lodash": "4.14.150",
"@types/mocha": "7.0.2",
"@types/node": "13.13.4",
"@types/puppeteer": "2.0.1",
"@types/semver": "7.1.0",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"dependency-cruiser": "6.1.0",
"mocha": "6.2.2",
"dependency-cruiser": "9.0.0",
"mocha": "7.1.2",
"npm-run-all": "4.1.5",
"nyc": "15.0.0",
"prettier": "1.19.1",
"nyc": "15.0.1",
"prettier": "2.0.5",
"shx": "0.3.2",
"ts-node": "8.5.4",
"tslint": "5.20.1",
"ts-node": "8.9.1",
"tslint": "6.1.2",
"tslint-config-prettier": "1.18.0",
"typescript": "3.7.4",
"upem": "3.1.2"
"typescript": "3.8.3",
"upem": "4.0.0"
},
"upem": {
"donotup": [
{
"package": "puppeteer",
"because": "puppeteer 3.0.1 doesn't install correctly on node 14: https://github.com/puppeteer/puppeteer/issues/5719"
}
]
},
"scripts": {
"build": "npm-run-all build:clean build:compile build:copy",
Expand Down Expand Up @@ -108,14 +116,6 @@
"version": "run-s build depcruise:graph scm:stage",
"watch": "tsc --project src/tsconfig.json --watch"
},
"upem": {
"donotup": [
{
"package": "semver",
"because": "doesn't support node 8 anymore, while current mscgenjs still does"
}
]
},
"nyc": {
"statements": 95,
"branches": 90,
Expand Down
12 changes: 6 additions & 6 deletions src/actions/index.ts
Expand Up @@ -13,7 +13,7 @@ function isGraphicsOutput(pOutputType: OutputType) {
function getAST(pInput: string, pOptions: INormalizedOptions): string {
return translateMsc(pInput, {
inputType: pOptions.inputType,
outputType: "ast"
outputType: "ast",
});
}

Expand All @@ -29,8 +29,8 @@ export function removeAutoWidth(pAST: any, pOutputType: OutputType) {

function render(pOptions: INormalizedOptions): Promise<any> {
return getStream(getInStream(pOptions.inputFrom))
.then(pInput => getAST(pInput, pOptions))
.then(pAST =>
.then((pInput) => getAST(pInput, pOptions))
.then((pAST) =>
renderWithChromeHeadless(
removeAutoWidth(pAST, pOptions.outputType),
pOptions
Expand All @@ -39,18 +39,18 @@ function render(pOptions: INormalizedOptions): Promise<any> {
}

function transpile(pOptions: INormalizedOptions): Promise<string> {
return getStream(getInStream(pOptions.inputFrom)).then(pInput =>
return getStream(getInStream(pOptions.inputFrom)).then((pInput) =>
translateMsc(pInput, pOptions as ITranslateOptions)
);
}

export function transform(pOptions: INormalizedOptions): Promise<boolean> {
if (isGraphicsOutput(pOptions.outputType)) {
return render(pOptions).then(pResult =>
return render(pOptions).then((pResult) =>
getOutStream(pOptions.outputTo).write(pResult)
);
} else {
return transpile(pOptions).then(pResult =>
return transpile(pOptions).then((pResult) =>
getOutStream(pOptions.outputTo).write(pResult, "utf8")
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/actions/render.ts
Expand Up @@ -18,7 +18,7 @@ function cookEvalFunction(pAST: string, pOptions: INormalizedOptions): string {
function getPuppeteerLaunchOptions(pPuppeteerLaunchOptions: IPuppeteerOptions) {
return Object.assign(
{
headless: true
headless: true,
},
pPuppeteerLaunchOptions || {}
);
Expand Down Expand Up @@ -49,12 +49,12 @@ async function renderBitmap(
deviceScaleFactor: 2,
height: 1,
isMobile: false,
width: 1
width: 1,
});
return await page.screenshot({
fullPage: true,
omitBackground: false,
type: pOptions.outputType as any
type: pOptions.outputType as any,
});
}

Expand All @@ -72,13 +72,13 @@ export async function renderWithChromeHeadless(
const page = await browser.newPage();

await page.goto(`file:///${__dirname}/template.html`, {
waitUntil: "networkidle2"
waitUntil: "networkidle2",
});

await page.evaluate(cookEvalFunction(JSON.stringify(pAST), pOptions));

await page.addScriptTag({
path: require.resolve("mscgenjs-inpage")
path: require.resolve("mscgenjs-inpage"),
});

await page.waitFor("mscgen#replaceme[data-renderedby='mscgen_js']");
Expand Down
7 changes: 5 additions & 2 deletions src/cli/index.ts
Expand Up @@ -7,6 +7,7 @@ import formatError = require("../actions/formatError");
import showLicense = require("../actions/showLicense");
import * as normalizations from "./normalizations";
import * as validations from "./validations";
import { OutputType, NamedStyleType } from "../types";

// tslint:disable-next-line:no-var-requires
const $package = require("../../package.json");
Expand Down Expand Up @@ -36,7 +37,8 @@ try {
.option(
"-T --output-type <type>",
validations.validOutputTypeRE,
validations.validOutputType
(pOutputType) =>
validations.validOutputType(pOutputType as OutputType) as string
)
.option(
"-I --input-type <type>",
Expand All @@ -50,7 +52,8 @@ try {
.option(
"-n --named-style <style>",
validations.validNamedStyleRE,
validations.validNamedStyle
(pNamedStyle) =>
validations.validNamedStyle(pNamedStyle as NamedStyleType) as string
)
.option(
"-m --mirror-entities",
Expand Down
4 changes: 2 additions & 2 deletions src/cli/normalizations.ts
Expand Up @@ -12,7 +12,7 @@ const INPUT_EXTENSIONS = Object.freeze({
mscin: "mscgen",
msgenny: "msgenny",
seq: "mscgen",
xu: "xu"
xu: "xu",
});
const OUTPUT_EXTENSIONS = Object.freeze({
ast: "json",
Expand All @@ -28,7 +28,7 @@ const OUTPUT_EXTENSIONS = Object.freeze({
png: "png",
seq: "mscgen",
svg: "svg",
xu: "xu"
xu: "xu",
});

/**
Expand Down

0 comments on commit 31757a3

Please sign in to comment.