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:
parent
65b00adb36
commit
2755dc4eaf
|
@ -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
|
|
@ -1,9 +1,9 @@
|
||||||
/* ==UserStyle==
|
/* ==UserStyle==
|
||||||
@name Tildes Compact
|
@name Tildes Compact
|
||||||
@namespace tildes.net
|
@namespace tildes.net
|
||||||
@version 3.0.1
|
@version 1.0.0
|
||||||
@author Bauke
|
@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
|
@homepageURL https://gitlab.com/Bauke/styles
|
||||||
@supportURL https://gitlab.com/Bauke/styles/issues
|
@supportURL https://gitlab.com/Bauke/styles/issues
|
||||||
@license MIT
|
@license MIT
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ==UserStyle==
|
/* ==UserStyle==
|
||||||
@name Tildes Dracula
|
@name Tildes Dracula
|
||||||
@namespace tildes.net
|
@namespace tildes.net
|
||||||
@version 3.0.1
|
@version 1.0.0
|
||||||
@author Bauke
|
@author Bauke
|
||||||
@description Dracula theme for Tildes.net
|
@description Dracula theme for Tildes.net
|
||||||
@homepageURL https://gitlab.com/Bauke/styles
|
@homepageURL https://gitlab.com/Bauke/styles
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ==UserStyle==
|
/* ==UserStyle==
|
||||||
@name Tildes Monokai
|
@name Tildes Monokai
|
||||||
@namespace tildes.net
|
@namespace tildes.net
|
||||||
@version 3.0.1
|
@version 1.0.0
|
||||||
@author Bauke
|
@author Bauke
|
||||||
@description Monokai theme for Tildes.net
|
@description Monokai theme for Tildes.net
|
||||||
@homepageURL https://gitlab.com/Bauke/styles
|
@homepageURL https://gitlab.com/Bauke/styles
|
||||||
|
|
34
generate.js
34
generate.js
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
// Require dependencies
|
// Require dependencies
|
||||||
// const fs = require('fs')
|
// const fs = require('fs')
|
||||||
|
const { bump } = require('./bump.js')
|
||||||
const klawSync = require('klaw-sync')
|
const klawSync = require('klaw-sync')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const userCss = require('usercss-creator')
|
const userCss = require('usercss-creator')
|
||||||
|
@ -13,13 +14,38 @@ const cssDirectory = path.join(__dirname, 'css')
|
||||||
// Walk recursively through styles directory
|
// Walk recursively through styles directory
|
||||||
let files = klawSync(stylesDirectory, {nodir: true})
|
let files = klawSync(stylesDirectory, {nodir: true})
|
||||||
|
|
||||||
// Filter out any files that aren't .js files
|
// Filter out any files that aren't .json files
|
||||||
files = files.filter(file => path.extname(file.path) === '.js')
|
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) {
|
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)
|
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
|
// Creating the css path and generating the .user.css file with the options
|
||||||
const cssPath = path.join(cssDirectory, descriptor.folder, descriptor.entry)
|
const cssPath = path.join(cssDirectory, descriptor.folder, descriptor.entry)
|
||||||
userCss.create(cssPath, descriptor.options)
|
userCss.create(cssPath, descriptor.options)
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "bauke-styles",
|
"name": "bauke-styles",
|
||||||
"repository": "https://gitlab.com/Bauke/styles",
|
"repository": "https://gitlab.com/Bauke/styles",
|
||||||
"version": "3.0.1",
|
"version": "1.0.0",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Bauke",
|
"name": "Bauke",
|
||||||
"email": "me@bauke.xyz"
|
"email": "me@bauke.xyz"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"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",
|
"watch": "node-sass -w sass -o temp",
|
||||||
"release": "yarn lint && yarn build:prod && yarn version && yarn generate",
|
|
||||||
"generate": "node generate.js",
|
"generate": "node generate.js",
|
||||||
"build:dev": "node-sass sass -o temp --output-style compact",
|
"build:dev": "node-sass sass -o temp --output-style compact",
|
||||||
"build:prod": "node-sass sass -o css -q --output-style compact",
|
"build:prod": "node-sass sass -o css -q --output-style compact",
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue