Skip to content

Commit

Permalink
build: refactor build script
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Dec 29, 2023
1 parent ae6165d commit 0a04287
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 30 deletions.
126 changes: 110 additions & 16 deletions .stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
#───────────────────────────────────────────────────────────────────────────────
# DOCS https://stylelint.io/user-guide/rules
#───────────────────────────────────────────────────────────────────────────────
extends:
- stylelint-config-standard
- stylelint-config-recess-order
plugins:
- stylelint-order
reportInvalidScopeDisables: true
reportNeedlessDisables: true
#───────────────────────────────────────────────────────────────────────────────
Expand All @@ -16,19 +11,118 @@ reportNeedlessDisables: true
defaultSeverity: warning
#───────────────────────────────────────────────────────────────────────────────
rules:
annotation-no-unknown: true
at-rule-no-unknown: true
block-no-empty: true
color-no-invalid-hex: true
comment-no-empty: true
custom-property-no-missing-var-function: true
declaration-block-no-duplicate-custom-properties: true
declaration-block-no-duplicate-properties:
- true
- ignore:
- consecutive-duplicates-with-different-syntaxes
declaration-block-no-shorthand-property-overrides: true
font-family-no-duplicate-names: true
font-family-no-missing-generic-family-keyword: true
function-calc-no-unspaced-operator: true
function-linear-gradient-no-nonstandard-direction: true
function-no-unknown: true
keyframe-block-no-duplicate-selectors: true
keyframe-declaration-no-important: true
media-feature-name-no-unknown: true
media-query-no-invalid: true
named-grid-areas-no-invalid: true
no-descending-specificity: true
no-duplicate-at-import-rules: true
no-duplicate-selectors: true
no-empty-source: true
no-invalid-double-slash-comments: true
no-invalid-position-at-import-rule: true
no-irregular-whitespace: true
property-no-unknown: true
selector-anb-no-unmatchable: true
selector-pseudo-class-no-unknown: true
selector-pseudo-element-no-unknown: true
selector-type-no-unknown:
- true
- ignore:
- custom-elements
string-no-newline: true
unit-no-unknown: true
alpha-value-notation:
- percentage
- exceptProperties:
- opacity
- fill-opacity
- flood-opacity
- stop-opacity
- stroke-opacity
at-rule-empty-line-before:
- always
- except:
- blockless-after-same-name-blockless
- first-nested
ignore:
- after-comment
at-rule-no-vendor-prefix: true
color-function-notation: [modern, {ignore: [with-var-inside]}]
color-hex-length: short
comment-empty-line-before: null # does not work well with comment decorators
comment-whitespace-inside: always
custom-property-empty-line-before: never
custom-media-pattern:
- ^([a-z][a-z0-9]*)(-[a-z0-9]+)*$
- {}
custom-property-pattern:
- ^([a-z][a-z0-9]*)(-[a-z0-9]+)*$
- {}
declaration-block-no-redundant-longhand-properties: true
declaration-block-single-line-max-declarations: 1
declaration-empty-line-before: never
font-family-name-quotes: always-where-recommended
function-name-case: lower
function-url-quotes: always
hue-degree-notation: number # compatible with ccc.nvim output
import-notation: url
keyframe-selector-notation: percentage-unless-within-keyword-only-block
keyframes-name-pattern:
- ^([a-z][a-z0-9]*)(-[a-z0-9]+)*$
- {}
length-zero-no-unit:
- true
- ignore:
- custom-properties
lightness-notation: null # PENDING support from stylelint-lsp
media-feature-name-no-vendor-prefix: true
media-feature-range-notation: context
number-max-precision: 4
property-no-vendor-prefix: true
rule-empty-line-before:
- always-multi-line
- except:
- first-nested
ignore:
- after-comment
selector-attribute-quotes: always
selector-class-pattern: null # when doing themes, you mostly do not decide on class names
selector-id-pattern:
- ^([a-z][a-z0-9]*)(-[a-z0-9]+)*$
- {}
selector-no-vendor-prefix: true
selector-not-notation: complex
selector-pseudo-element-colon-notation: double
selector-type-case: lower
shorthand-property-no-redundant-values: true
value-keyword-case: lower
value-no-vendor-prefix:
- true
- ignoreValues:
- box
- inline-box
color-named: never
color-no-hex: true
color-function-notation: [modern, { ignore: [with-var-inside] }]
hue-degree-notation: number # compatible with ccc.nvim output
comment-empty-line-before: null # does not work well with comment decorators
declaration-no-important: true
font-weight-notation: numeric
selector-class-pattern: null # when doing themes, you mostly do not decide on class names
no-unknown-custom-properties: [true, { severity: error }] # equivalent to "no undeclared variables" in other linters
declaration-empty-line-before: never
custom-property-empty-line-before: never
no-unknown-custom-properties: [true, {severity: error}] # equivalent to "no undeclared variables" in other linters
max-nesting-depth: 3

order/order:
- custom-properties
- declarations
27 changes: 13 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# - Check the yaml from the Style Settings for errors. If there are any, the
# build is aborted, the errors are passed (e.g. for a notification) and the
# Style Settings tab is opened.
# - bumps version number in css file
# - updates download counts in badges of the .md files
# - updates the stylelint-file
# - bumps version number in css file and manifest
# - updates download counts in badges of the README files
# - copies the stylelint-config for documentation
# - git add, commit, pull, and push to the remote repo

#───────────────────────────────────────────────────────────────────────────────
Expand All @@ -31,33 +31,32 @@ if [[ $? == 1 ]]; then
fi
rm temp.yml

# Copy for styleint config for documentation purposes
cp "$HOME/.config/+ linter-configs/stylelint/compiled.yml" ./.stylelintrc.yml

#───────────────────────────────────────────────────────────────────────────────

# Bump version number
versionLine=$(grep -Ewn "^Version" "$CSS_PATH" | cut -d: -f1 | head -n1)
currentVersion=$(sed -n "${versionLine}p" "$CSS_PATH" | cut -d. -f2)
# BUMP VERSION NUMBER
versionLine=$(grep -n --max-count=1 "^Version" "theme.css")
currentVersion=$(echo "$versionLine" | cut -d" " -f2)
nextVersion=$((currentVersion + 1))

versionLineNum=$(echo "$versionLine" | cut -d: -f1)
manifest="$(dirname "$CSS_PATH")/manifest.json"
sed -E -i '' "${versionLine}s/(.*\.)[[:digit:]]+/\1$nextVersion/" "$CSS_PATH"
sed -E -i '' "${versionLineNum}s/(.*\.)[[:digit:]]+/\1$nextVersion/" "$CSS_PATH"
sed -E -i '' "s/(\"version\": \".*\.).*/\1$nextVersion\",/" "$manifest"

#───────────────────────────────────────────────────────────────────────────────

# Copy for documentation purposes
cp "$HOME/.config/+ linter-configs/stylelint/compiled.yml" ./.stylelintrc.yml

# Update Theme Download numbers in README.md
dl=$(curl -s "https://releases.obsidian.md/stats/theme" | grep -oe '"Shimmering Focus","download":[[:digit:]]*' | cut -d: -f2)
sed -E -i '' "s/badge.*-[[:digit:]]+-/badge\/downloads-$dl-/" ./README.md

#───────────────────────────────────────────────────────────────────────────────

# git add, commit, pull, and push
# GIT ADD, COMMIT, PULL, AND PUSH
# needs piping stderr to stdin, since git push reports an error even on success
git add --all && git commit -m "publish (automated)"
git pull && git push 2>&1

#───────────────────────────────────────────────────────────────────────────────
#───────────────────────────────────────────────────────────────────────────────
# INFO specific to my setup

Expand Down

0 comments on commit 0a04287

Please sign in to comment.