1
Fork 0

Allow writing versions to individual styles, reset all styles to 1.0.0

Create bump.js to easily bump versions
This commit is contained in:
Bauke 2018-06-19 16:34:38 +02:00
parent 65b00adb36
commit 2755dc4eaf
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
13 changed files with 3466 additions and 3413 deletions

53
bump.js Normal file
View File

@ -0,0 +1,53 @@
// Bumps a specified style's version
const fs = require('fs')
const path = require('path')
/**
* @function bump
* @param {string} jsonPath - Path to the .json file
* @param {string} incrementType - Which semver type to increment: "major", "minor" or "patch"
*/
function bump(jsonPath, incrementType) {
if (!fs.existsSync(jsonPath))
throw Error(`File ${jsonPath} does not exist.`)
if (path.extname(jsonPath) !== '.json')
throw Error(`File ${jsonPath} does not end in "json".`)
if (typeof incrementType === 'undefined')
throw Error('No valid increment type was included. Valid: "major", "minor" or "patch".')
if (incrementType !== 'major' && incrementType !== 'minor' && incrementType !== 'patch')
throw Error(`Increment type ${incrementType} does not equal "major", "minor" or "patch".`)
const jsonFile = require(jsonPath)
if (typeof jsonFile.options.version === 'undefined')
throw Error(`${jsonFile} does not include a "version" property.`)
const incrementTypes = {
'major': 0,
'minor': 1,
'patch': 2
}
const oldVersion = jsonFile.options.version.split('.')
let bumped = parseInt(oldVersion[incrementTypes[incrementType]]) + 1
let newVersion
switch (incrementType) {
case 'major':
newVersion = `${bumped}.${oldVersion[1]}.${oldVersion[2]}`
break
case 'minor':
newVersion = `${oldVersion[0]}.${bumped}.${oldVersion[2]}`
break
case 'patch':
newVersion = `${oldVersion[0]}.${oldVersion[1]}.${bumped}`
break
}
jsonFile.options.version = newVersion
fs.writeFileSync(jsonPath, JSON.stringify(jsonFile, null, 2))
}
exports.bump = bump

View File

@ -1,9 +1,9 @@
/* ==UserStyle==
@name Tildes Compact
@namespace tildes.net
@version 3.0.1
@version 1.0.0
@author Bauke
@description Compact theme for Tildes.net
@description Removes some elements and changes some sizes to make the Tildes.net layout a little more compact.
@homepageURL https://gitlab.com/Bauke/styles
@supportURL https://gitlab.com/Bauke/styles/issues
@license MIT

View File

@ -1,7 +1,7 @@
/* ==UserStyle==
@name Tildes Dracula
@namespace tildes.net
@version 3.0.1
@version 1.0.0
@author Bauke
@description Dracula theme for Tildes.net
@homepageURL https://gitlab.com/Bauke/styles

View File

@ -1,7 +1,7 @@
/* ==UserStyle==
@name Tildes Monokai
@namespace tildes.net
@version 3.0.1
@version 1.0.0
@author Bauke
@description Monokai theme for Tildes.net
@homepageURL https://gitlab.com/Bauke/styles

View File

@ -2,6 +2,7 @@
// Require dependencies
// const fs = require('fs')
const { bump } = require('./bump.js')
const klawSync = require('klaw-sync')
const path = require('path')
const userCss = require('usercss-creator')
@ -13,13 +14,38 @@ const cssDirectory = path.join(__dirname, 'css')
// Walk recursively through styles directory
let files = klawSync(stylesDirectory, {nodir: true})
// Filter out any files that aren't .js files
files = files.filter(file => path.extname(file.path) === '.js')
// Filter out any files that aren't .json files
files = files.filter(file => path.extname(file.path) === '.json')
// Iterate through all .js files
let style
let incrementType
for (const arg of process.argv) {
if (arg.includes('--bump')) {
style = arg.substring('--bump='.length, arg.length)
}
switch (arg) {
case 'major':
incrementType = 'major'
break
case 'minor':
incrementType = 'minor'
break
case 'patch':
incrementType = 'patch'
break
}
}
// Iterate through all .json files
for (const file of files) {
// Requiring the .js files as the descriptor of the style
// Requiring the .json file as the descriptor of the style
const descriptor = require(file.path)
// Test if the style we want to bump is the one currently generating
if (style === descriptor.folder) {
// Bump the style's .json with the increment type
bump(file.path, incrementType)
}
// Creating the css path and generating the .user.css file with the options
const cssPath = path.join(cssDirectory, descriptor.folder, descriptor.entry)
userCss.create(cssPath, descriptor.options)

View File

@ -1,15 +1,16 @@
{
"name": "bauke-styles",
"repository": "https://gitlab.com/Bauke/styles",
"version": "3.0.1",
"version": "1.0.0",
"author": {
"name": "Bauke",
"email": "me@bauke.xyz"
},
"license": "MIT",
"scripts": {
"release signature example: yarn release --bump=tildes-monokai minor": "echo \"no.\"",
"release": "yarn lint && yarn build:prod && yarn generate",
"watch": "node-sass -w sass -o temp",
"release": "yarn lint && yarn build:prod && yarn version && yarn generate",
"generate": "node generate.js",
"build:dev": "node-sass sass -o temp --output-style compact",
"build:prod": "node-sass sass -o css -q --output-style compact",

View File

@ -1,23 +0,0 @@
const pjson = require('../../package.json')
// Descriptor for Tildes Compact
const entry = 'tildes-compact.css'
const folder = 'tildes-compact'
const options = {
name: 'Tildes Compact',
namespace: 'tildes.net',
version: pjson.version,
author: 'Bauke',
description: 'Compact theme for Tildes.net',
homepageURL: 'https://gitlab.com/Bauke/styles',
supportURL: 'https://gitlab.com/Bauke/styles/issues',
license: 'MIT'
}
module.exports = {
entry: entry,
folder: folder,
options: options
}

View File

@ -0,0 +1,14 @@
{
"entry": "tildes-compact.css",
"folder": "tildes-compact",
"options": {
"name": "Tildes Compact",
"namespace": "tildes.net",
"version": "1.0.0",
"author": "Bauke",
"description": "Removes some elements and changes some sizes to make the Tildes.net layout a little more compact.",
"homepageURL": "https://gitlab.com/Bauke/styles",
"supportURL": "https://gitlab.com/Bauke/styles/issues",
"license": "MIT"
}
}

View File

@ -1,23 +0,0 @@
const pjson = require('../../package.json')
// Descriptor for Tildes Dracula
const entry = 'tildes-dracula.css'
const folder = 'tildes-dracula'
const options = {
name: 'Tildes Dracula',
namespace: 'tildes.net',
version: pjson.version,
author: 'Bauke',
description: 'Dracula theme for Tildes.net',
homepageURL: 'https://gitlab.com/Bauke/styles',
supportURL: 'https://gitlab.com/Bauke/styles/issues',
license: 'MIT'
}
module.exports = {
entry: entry,
folder: folder,
options: options
}

View File

@ -0,0 +1,14 @@
{
"entry": "tildes-dracula.css",
"folder": "tildes-dracula",
"options": {
"name": "Tildes Dracula",
"namespace": "tildes.net",
"version": "1.0.0",
"author": "Bauke",
"description": "Dracula theme for Tildes.net",
"homepageURL": "https://gitlab.com/Bauke/styles",
"supportURL": "https://gitlab.com/Bauke/styles/issues",
"license": "MIT"
}
}

View File

@ -1,23 +0,0 @@
const pjson = require('../../package.json')
// Descriptor for Tildes Monokai
const entry = 'tildes-monokai.css'
const folder = 'tildes-monokai'
const options = {
name: 'Tildes Monokai',
namespace: 'tildes.net',
version: pjson.version,
author: 'Bauke',
description: 'Monokai theme for Tildes.net',
homepageURL: 'https://gitlab.com/Bauke/styles',
supportURL: 'https://gitlab.com/Bauke/styles/issues',
license: 'MIT'
}
module.exports = {
entry: entry,
folder: folder,
options: options
}

View File

@ -0,0 +1,14 @@
{
"entry": "tildes-monokai.css",
"folder": "tildes-monokai",
"options": {
"name": "Tildes Monokai",
"namespace": "tildes.net",
"version": "1.0.0",
"author": "Bauke",
"description": "Monokai theme for Tildes.net",
"homepageURL": "https://gitlab.com/Bauke/styles",
"supportURL": "https://gitlab.com/Bauke/styles/issues",
"license": "MIT"
}
}

56
yarn.lock Executable file → Normal file
View File

@ -28,8 +28,8 @@ acorn@^3.0.4:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
acorn@^5.5.0:
version "5.6.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.6.2.tgz#b1da1d7be2ac1b4a327fb9eab851702c5045b4e7"
version "5.7.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8"
ajv-keywords@^2.1.0:
version "2.1.1"
@ -184,11 +184,11 @@ atob@^2.1.1:
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.1.tgz#ae2d5a729477f289d60dd7f96a6314a22dd6c22a"
autoprefixer@^8.0.0:
version "8.6.2"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-8.6.2.tgz#51d42ff13243820a582a53ecca20dedaeb7f2efd"
version "8.6.3"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-8.6.3.tgz#1d38a129e6a4582a565b6570d16f2d7d3de9cbf9"
dependencies:
browserslist "^3.2.8"
caniuse-lite "^1.0.30000851"
caniuse-lite "^1.0.30000856"
normalize-range "^0.1.2"
num2fraction "^1.2.2"
postcss "^6.0.22"
@ -348,9 +348,9 @@ camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000851:
version "1.0.30000855"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000855.tgz#d5a26a9093b932d6266bf4ed9294b41b84945d14"
caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000856:
version "1.0.30000856"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000856.tgz#ecc16978135a6f219b138991eb62009d25ee8daa"
caseless@~0.11.0:
version "0.11.0"
@ -681,8 +681,8 @@ entities@^1.1.1, entities@~1.1.1:
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
error-ex@^1.2.0, error-ex@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
version "1.3.2"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
dependencies:
is-arrayish "^0.2.1"
@ -2241,21 +2241,21 @@ posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
postcss-html@^0.23.6:
version "0.23.7"
resolved "https://registry.yarnpkg.com/postcss-html/-/postcss-html-0.23.7.tgz#47146c15e21b9c00746c40115dcff8270c439f32"
postcss-html@^0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/postcss-html/-/postcss-html-0.28.0.tgz#3dd0f5b5d7f886b8181bf844396d43a7898162cb"
dependencies:
htmlparser2 "^3.9.2"
postcss-less@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-1.1.5.tgz#a6f0ce180cf3797eeee1d4adc0e9e6d6db665609"
postcss-less@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-2.0.0.tgz#5d190b8e057ca446d60fe2e2587ad791c9029fb8"
dependencies:
postcss "^5.2.16"
postcss-markdown@^0.23.6:
version "0.23.7"
resolved "https://registry.yarnpkg.com/postcss-markdown/-/postcss-markdown-0.23.7.tgz#7e3a398794295c425e51e4f0abdee6d13ad3d134"
postcss-markdown@^0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/postcss-markdown/-/postcss-markdown-0.28.0.tgz#99d1c4e74967af9e9c98acb2e2b66df4b3c6ed86"
dependencies:
remark "^9.0.0"
unist-util-find-all-after "^1.0.2"
@ -2304,9 +2304,9 @@ postcss-selector-parser@^3.1.0:
indexes-of "^1.0.1"
uniq "^1.0.1"
postcss-syntax@^0.9.0:
version "0.9.1"
resolved "https://registry.yarnpkg.com/postcss-syntax/-/postcss-syntax-0.9.1.tgz#5dbd90af1631ab8805b8f594bef2c2e8002d3758"
postcss-syntax@^0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/postcss-syntax/-/postcss-syntax-0.28.0.tgz#e17572a7dcf5388f0c9b68232d2dad48fa7f0b12"
postcss-value-parser@^3.2.3, postcss-value-parser@^3.3.0:
version "3.3.0"
@ -2923,8 +2923,8 @@ stylelint-config-recommended@^2.1.0:
resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-2.1.0.tgz#f526d5c771c6811186d9eaedbed02195fee30858"
stylelint@^9.2.1:
version "9.2.1"
resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-9.2.1.tgz#fe63c169f6cd3bc81e77f0e3c6443df3267ec211"
version "9.3.0"
resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-9.3.0.tgz#fe176e4e421ac10eac1a6b6d9f28e908eb58c5db"
dependencies:
autoprefixer "^8.0.0"
balanced-match "^1.0.0"
@ -2949,9 +2949,9 @@ stylelint@^9.2.1:
normalize-selector "^0.2.0"
pify "^3.0.0"
postcss "^6.0.16"
postcss-html "^0.23.6"
postcss-less "^1.1.5"
postcss-markdown "^0.23.6"
postcss-html "^0.28.0"
postcss-less "^2.0.0"
postcss-markdown "^0.28.0"
postcss-media-query-parser "^0.2.3"
postcss-reporter "^5.0.0"
postcss-resolve-nested-selector "^0.1.1"
@ -2959,7 +2959,7 @@ stylelint@^9.2.1:
postcss-sass "^0.3.0"
postcss-scss "^1.0.2"
postcss-selector-parser "^3.1.0"
postcss-syntax "^0.9.0"
postcss-syntax "^0.28.0"
postcss-value-parser "^3.3.0"
resolve-from "^4.0.0"
signal-exit "^3.0.2"