Skip to content

Commit

Permalink
Merge branch 'master' into tech/demoteToDevDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Nov 15, 2021
2 parents fdcd077 + 541e374 commit dae6853
Show file tree
Hide file tree
Showing 18 changed files with 1,716 additions and 640 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["standard", "prettier", "prettier/standard"],
"extends": ["standard", "prettier"],
"plugins": ["import", "mocha"],
"env": {
"mocha": true
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Tests
'on':
push:
pull_request:

jobs:
test:
runs-on: ubuntu-18.04
name: Node ${{ matrix.node }}
strategy:
matrix:
node:
- '12'
- '14'
- '16'
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: sudo add-apt-repository -y ppa:inkscape.dev/stable && sudo apt-get update && sudo apt-get install -y inkscape graphicsmagick && inkscape --version
- run: npm install
- run: npm test

test-targets:
runs-on: ubuntu-18.04
name: ${{ matrix.targets.name }}
strategy:
matrix:
targets:
- name: 'Lint'
target: 'lint'
- name: 'Coverage'
target: 'coverage'

steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '14'
- run: sudo add-apt-repository -y ppa:inkscape.dev/stable && sudo apt-get update && sudo apt-get install -y inkscape graphicsmagick && inkscape --version
- run: npm install
- run: npm run ${{ matrix.targets.target }}
- name: Upload coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.targets.target == 'coverage' }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules/
/testdata/
/coverage/
/.nyc_output/

# Generated
/CHANGELOG.md
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"request": "launch",
"name": "Test suite",
"program": "${workspaceFolder}/node_modules/.bin/_mocha",
"args": ["--timeout", "0"],
"skipFiles": [
"<node_internals>/**" // Prevent stepping through async_hooks.js et al.
]
Expand Down
386 changes: 384 additions & 2 deletions CHANGELOG.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM node:14

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -11,7 +11,8 @@ ENV PATH=$NPM_CONFIG_PREFIX/bin:$PATH
USER node

RUN npm --loglevel=warn install -g \
assetgraph-builder \
svgo
assetgraph-builder \
svgo \
&& npm cache clean --force

ENTRYPOINT ["buildProduction"]
6 changes: 3 additions & 3 deletions bin/addIntegrityToForeignRelations
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const optimist = require('optimist')
const yargs = require('yargs')
.usage('$0 --root <inputRootDirectory> -o <dir> [options] <htmlFile(s)>')
.wrap(72)
.options('h', {
Expand Down Expand Up @@ -29,10 +29,10 @@ const optimist = require('optimist')
demand: false,
});

const commandLineOptions = optimist.argv;
const commandLineOptions = yargs.argv;

if (commandLineOptions.h) {
optimist.showHelp();
yargs.showHelp();
process.exit(0);
}

Expand Down
8 changes: 4 additions & 4 deletions bin/buildProduction
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint indent:0 */
const chalk = require('chalk');
const parseExpression = require('assetgraph/lib/parseExpression');
const optimist = require('optimist')
const yargs = require('yargs')
.usage('$0 --root <inputRootDirectory> -o <dir> [options] <htmlFile(s)>')
.wrap(72)
.options('h', {
Expand Down Expand Up @@ -245,14 +245,14 @@ for (const javaScriptSerializationOptionName of javaScriptSerializationOptionNam
const type =
javaScriptSerializationOptionName === 'indent_level' ? 'number' : 'boolean';
// Also accept the option without underscores, or with the underscores replaced with dashes:
optimist.options(javaScriptSerializationOptionName.replace(/_/g, ''), {
yargs.options(javaScriptSerializationOptionName.replace(/_/g, ''), {
type,
description:
'UglifyJS serialization option, see http://lisperator.net/uglifyjs/codegen',
});
}

const commandLineOptions = optimist.argv;
const commandLineOptions = yargs.argv;

const javaScriptSerializationOptions = {
compact: commandLineOptions.compact,
Expand Down Expand Up @@ -302,7 +302,7 @@ if (Array.isArray(browsers)) {
}

if (commandLineOptions.h) {
optimist.showHelp();
yargs.showHelp();
process.exit(0);
}

Expand Down
74 changes: 37 additions & 37 deletions bin/findUnusedSelectors
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const AssetGraph = require('../lib/AssetGraph');
const _ = require('lodash');
const urlTools = require('urltools');
const commandLineOptions = require('optimist')
const commandLineOptions = require('yargs')
.usage('$0 [--root <inputRootDirectory>] <htmlFile>...')
.demand(1).argv;

Expand Down Expand Up @@ -56,21 +56,20 @@ new AssetGraph({ root: commandLineOptions.root })
function isSelectorUsed(selector) {
var giveUp = false;
// Preprocess pseudo-classes
selector = selector.replace(/:([a-z-]+)(\()?/g, function (
$0,
pseudoClassName,
leadingParen
) {
if (leadingParen) {
// Give up on :not(...) etc., anything that takes parameters
giveUp = true;
return $0;
} else if (ignorePseudoClasses.indexOf(pseudoClassName) !== -1) {
return '';
} else {
return $0;
selector = selector.replace(
/:([a-z-]+)(\()?/g,
function ($0, pseudoClassName, leadingParen) {
if (leadingParen) {
// Give up on :not(...) etc., anything that takes parameters
giveUp = true;
return $0;
} else if (ignorePseudoClasses.indexOf(pseudoClassName) !== -1) {
return '';
} else {
return $0;
}
}
});
);
if (giveUp) {
return true;
}
Expand All @@ -85,31 +84,32 @@ new AssetGraph({ root: commandLineOptions.root })
});
}
assetGraph.findAssets({ type: 'Css' }).forEach(function (cssAsset) {
cssAsset.constructor.eachRuleInParseTree(cssAsset.parseTree, function (
cssRule
) {
if (cssRule.type === 'rule') {
// STYLE_RULE
var selectors = cssRule.selectors;
var unusedSelectors = cssRule.selectors.filter(function (selector) {
return !isSelectorUsed(selector);
});
if (unusedSelectors.length > 0) {
if (unusedSelectors.length === selectors.length) {
console.warn('Unused rule: ' + cssRule.toString());
} else {
console.warn(
'Unused selector' +
(unusedSelectors.length === 1 ? '' : 's') +
' "' +
unusedSelectors.join('", "') +
'" in rule: ' +
cssRule.toString()
);
cssAsset.constructor.eachRuleInParseTree(
cssAsset.parseTree,
function (cssRule) {
if (cssRule.type === 'rule') {
// STYLE_RULE
var selectors = cssRule.selectors;
var unusedSelectors = cssRule.selectors.filter(function (selector) {
return !isSelectorUsed(selector);
});
if (unusedSelectors.length > 0) {
if (unusedSelectors.length === selectors.length) {
console.warn('Unused rule: ' + cssRule.toString());
} else {
console.warn(
'Unused selector' +
(unusedSelectors.length === 1 ? '' : 's') +
' "' +
unusedSelectors.join('", "') +
'" in rule: ' +
cssRule.toString()
);
}
}
}
}
});
);
});
})
.run();
2 changes: 1 addition & 1 deletion bin/optimizeImage
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const AssetGraph = require('../lib/AssetGraph');
const urlTools = require('urltools');
const commandLineOptions = require('optimist')
const commandLineOptions = require('yargs')
.usage('$0 image1 image2...')
.demand(1).argv;

Expand Down
2 changes: 1 addition & 1 deletion lib/AssetGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const pathModule = require('path');
const AssetGraph = (module.exports = require('assetgraph'));

// Get the spriteBackgroundImages transform from assetgraph-sprite if available:
var spriteBackgroundImages;
let spriteBackgroundImages;
try {
spriteBackgroundImages = require('assetgraph-sprite');
} catch (e) {
Expand Down

0 comments on commit dae6853

Please sign in to comment.