Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
Upd deps (#22)
Browse files Browse the repository at this point in the history
* Fix version tests, closes #20

* update xo to 0.23

* update ava to 1.0 🎉

* update css-analyzer to 2.0.0-0
  • Loading branch information
bartveneman authored Dec 23, 2018
1 parent 7730724 commit e005285
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 285 deletions.
17 changes: 0 additions & 17 deletions .prettierrc.js

This file was deleted.

3 changes: 1 addition & 2 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
'use strict'

/* eslint-disable unicorn/no-process-exit */
const {readFile} = require('fs')
const {promisify} = require('util')
const {resolve: resolvePath} = require('path')
Expand Down Expand Up @@ -51,7 +50,7 @@ const cli = meow(
}
)

// Read the filepath from the CLI
// Read the file path from the CLI
const [filePath] = cli.input

// Show the help if there is no file argument
Expand Down
6 changes: 2 additions & 4 deletions lib/flatten-stats.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const flatten = require('flat')

module.exports = stats => {
return Object.entries(flatten(stats, {safe: true}))
return Object.entries(stats)
.map(([key, stat]) => {
if (key.includes('unique')) {
return {
key,
stat: stat.map(item => item.value || item.selector)
stat: stat.map(item => item.value)
}
}

Expand Down
585 changes: 331 additions & 254 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"projectwallace"
],
"dependencies": {
"@projectwallace/css-analyzer": "^1.5.1",
"@projectwallace/css-analyzer": "^2.0.0-0",
"flat": "^4.1.0",
"get-stdin": "^6.0.0",
"is-array": "^1.0.1",
Expand All @@ -35,15 +35,32 @@
"unique-random-array": "^1.0.1"
},
"devDependencies": {
"ava": "^1.0.0-rc.2",
"ava": "^1.0.1",
"execa": "^1.0.0",
"prettier": "^1.14.3",
"semver": "^5.6.0",
"xo": "^0.23.0"
},
"scripts": {
"test": "xo && ava"
},
"xo": {
"semicolon": false
"semicolon": false,
"prettier": true
},
"prettier": {
"useTabs": true,
"semi": false,
"singleQuote": true,
"bracketSpacing": false,
"proseWrap": "always",
"overrides": [
{
"files": "*.json",
"options": {
"useTabs": false
}
}
]
}
}
99 changes: 98 additions & 1 deletion test/fixture.jsonc
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
{
"stylesheets.size": 25
"atrules.charsets.total": 0,
"atrules.charsets.totalUnique": 0,
"atrules.charsets.unique": [],
"atrules.documents.total": 0,
"atrules.documents.totalUnique": 0,
"atrules.documents.unique": [],
"atrules.fontfaces.total": 0,
"atrules.fontfaces.totalUnique": 0,
"atrules.fontfaces.unique": [],
"atrules.imports.total": 0,
"atrules.imports.totalUnique": 0,
"atrules.imports.unique": [],
"atrules.keyframes.total": 0,
"atrules.keyframes.totalUnique": 0,
"atrules.keyframes.unique": [],
"atrules.mediaqueries.total": 0,
"atrules.mediaqueries.totalUnique": 0,
"atrules.mediaqueries.unique": [],
"atrules.mediaqueries.browserhacks.total": 0,
"atrules.mediaqueries.browserhacks.unique": [],
"atrules.mediaqueries.browserhacks.totalUnique": 0,
"atrules.namespaces.total": 0,
"atrules.namespaces.totalUnique": 0,
"atrules.namespaces.unique": [],
"atrules.pages.total": 0,
"atrules.pages.totalUnique": 0,
"atrules.pages.unique": [],
"atrules.supports.total": 0,
"atrules.supports.totalUnique": 0,
"atrules.supports.unique": [],
"atrules.supports.browserhacks.total": 0,
"atrules.supports.browserhacks.unique": [],
"atrules.supports.browserhacks.totalUnique": 0,
"declarations.importants.share": 0,
"declarations.importants.total": 0,
"declarations.total": 1,
"declarations.totalUnique": 1,
"properties.prefixed.share": 0,
"properties.prefixed.total": 0,
"properties.prefixed.totalUnique": 0,
"properties.prefixed.unique": [],
"properties.browserhacks.total": 0,
"properties.browserhacks.unique": [],
"properties.browserhacks.totalUnique": 0,
"properties.total": 1,
"properties.totalUnique": 1,
"properties.unique": ["color"],
"rules.total": 1,
"rules.empty.total": 0,
"selectors.accessibility.total": 0,
"selectors.accessibility.totalUnique": 0,
"selectors.accessibility.unique": [],
"selectors.id.total": 0,
"selectors.id.totalUnique": 0,
"selectors.id.unique": [],
"selectors.identifiers.average": 1,
// "selectors.identifiers.top": [{"count": 1, "value": "body"}],
"selectors.identifiers.max.count": 1,
// "selectors.identifiers.max.value": "foo",
"selectors.js.total": 0,
"selectors.js.totalUnique": 0,
"selectors.js.unique": [],
// "selectors.specificity.top": [
// {"value": "foo", "specificity": {"a": 0, "b": 0, "c": 0, "d": 1}}
// ],
"selectors.total": 1,
"selectors.totalUnique": 1,
"selectors.universal.total": 0,
"selectors.universal.totalUnique": 0,
"selectors.universal.unique": [],
"selectors.browserhacks.total": 0,
"selectors.browserhacks.unique": [],
"selectors.browserhacks.totalUnique": 0,
"stylesheets.cohesion.average": 1,
"stylesheets.simplicity": 1,
"stylesheets.size": 25,
"stylesheets.browserhacks.total": 0,
"stylesheets.browserhacks.totalUnique": 0,
"values.browserhacks.total": 0,
"values.browserhacks.unique": [],
"values.browserhacks.totalUnique": 0,
"values.colors.total": 1,
"values.colors.totalUnique": 1,
"values.colors.unique": ["blue"],
"values.colors.duplicates.total": 0,
"values.colors.duplicates.totalUnique": 0,
"values.colors.duplicates.unique": [],
"values.fontfamilies.total": 0,
"values.fontfamilies.totalUnique": 0,
"values.fontfamilies.unique": [],
"values.fontsizes.total": 0,
"values.fontsizes.totalUnique": 0,
"values.fontsizes.unique": [],
"values.prefixed.share": 0,
"values.prefixed.total": 0,
"values.prefixed.totalUnique": 0,
"values.prefixed.unique": [],
"values.total": 1
}
9 changes: 5 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const test = require('ava')
const execa = require('execa')
const semver = require('semver')

test('it shows the version when passing -v', async t => {
test('it shows a valid version when passing -v', async t => {
const {stdout} = await execa('./cli.js', ['-v'])
t.is(stdout, '1.0.0')
t.is(stdout, semver.valid(stdout))
})

test('it shows the version when passing --version', async t => {
test('it shows a valid version when passing --version', async t => {
const {stdout} = await execa('./cli.js', ['--version'])
t.is(stdout, '1.0.0')
t.is(stdout, semver.valid(stdout))
})

test('it passes when given a valid config and css file', async t => {
Expand Down

0 comments on commit e005285

Please sign in to comment.