Skip to content

Commit

Permalink
Chore: upgrade Alpine.js version, fix version detection issues + prep…
Browse files Browse the repository at this point in the history
… 0.1.0 (#125)

* chore: upgrade Alpine.js version

* fix: orange + cool-gray (Tailwind 2)

* 0.1.0

* fix semver version detection
  • Loading branch information
HugoDF authored Dec 15, 2020
1 parent 8ad12a0 commit 4ca1579
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alpinejs-devtools",
"version": "0.0.10",
"version": "0.1.0",
"private": true,
"description": "DevTools extension for debugging Alpine.js applications.",
"homepage": "https://github.com/alpine-collective/alpinejs-devtools",
Expand All @@ -23,7 +23,7 @@
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.4",
"@tailwindcss/forms": "^0.2.1",
"alpinejs": "^2.7.3",
"alpinejs": "^2.8.0",
"cypress": "^6.1.0",
"cypress-iframe": "^1.0.1",
"edge.js": "^1.1.4",
Expand Down
3 changes: 2 additions & 1 deletion packages/shell-chrome/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export function fetchWithTimeout(resource, options) {
* @returns {boolean}
*/
export function isRequiredVersion(required, actual) {
if (required === actual) return true
const requiredArray = required.split('.').map((v) => parseInt(v, 10))
const currentArray = actual.split('.').map((v) => parseInt(v, 10))
for (let i = 0; i < requiredArray.length; i++) {
if (!currentArray[i] || currentArray[i] < requiredArray[i]) {
if (currentArray[i] < requiredArray[i]) {
return false
}
if (currentArray[i] > requiredArray[i]) {
Expand Down
4 changes: 4 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const colors = require('tailwindcss/colors')

module.exports = {
purge: {
content: ['./packages/**/*.{html,edge}', './packages/shell-chrome/src/devtools/devtools.js'],
Expand All @@ -17,6 +19,8 @@ module.exports = {
},
extend: {
colors: {
orange: colors.orange,
'cool-gray': colors.coolGray,
alpine: {
100: '#7C87A2',
200: '#616D89',
Expand Down
21 changes: 20 additions & 1 deletion tests/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createComponentId, getComponentName } from '../packages/shell-chrome/src/utils'
import { isRequiredVersion, getComponentName } from '../packages/shell-chrome/src/utils'

test('getComponentName > can handle multiple scenarios to determine component name', async () => {
window.myFn = () => {}
Expand All @@ -24,3 +24,22 @@ test('getComponentName > can handle multiple scenarios to determine component na
element.removeAttribute('role')
expect(getComponentName(element)).toBe('div')
})

describe('isRequiredVersion', () => {
test('works for major', () => {
expect(isRequiredVersion('1.11.0', '2.1.1')).toBe(true)
expect(isRequiredVersion('2.11.0', '0.1.1')).toBe(false)
})
test('works for minor', () => {
expect(isRequiredVersion('1.1.1', '1.11.0')).toBe(true)
expect(isRequiredVersion('1.11.0', '1.1.1')).toBe(false)
})
test('works for patch', () => {
expect(isRequiredVersion('0.11.0', '0.11.1')).toBe(true)
expect(isRequiredVersion('0.1.1', '0.1.0')).toBe(false)
})
test('works for equal', () => {
expect(isRequiredVersion('2.8.0', '2.8.0')).toBe(true)
expect(isRequiredVersion('1.1.0', '1.1.0')).toBe(true)
})
})

0 comments on commit 4ca1579

Please sign in to comment.