Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit f1d3583
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Sat Jun 8 00:45:59 2024 +0800

    build(devcontainer): add omz plugins & verify extension signature

    VSCode fixed signature validation hangs in v1.90

commit cf853f1
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Fri Jun 7 19:27:54 2024 +0800

    chore: upgrade `husky` v9 settings

commit 7ca9c59
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Wed Jun 5 23:51:10 2024 +0800

    build(deps-dev): remove package `rollup-plugin-license` (cotes2020#1796)

    The `rollup-plugin-license` has been using too many deprecated dependencies, so it is necessary to remove it.

    As an alternative, this changes uses Rollup `output.banner` to insert copyright information. Since `terser` runs after `output`, it is not possible to insert the Front Matter defining permlink for `sw.js` through the same way (Jekyll Front Matter is YAML rather than JS, which would cause errors with terser).

    Therefore, _Jekyll Collection_ is now used to add permlink to `sw.js`, with the collection named `app`, and the directory placed in `_app`. This directory is not tracked by git, but it will be included when building the gem.

commit 250880c
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Tue Jun 4 19:28:02 2024 +0800

    docs: change ordering of badges

commit 88b844c
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Tue Jun 4 19:26:17 2024 +0800

    build(deps): improve dependency grouping

commit 3b46629
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Tue Jun 4 01:36:27 2024 +0800

    build(deps-dev): bump the npm group across 1 directory with 8 updates

    Updates the requirements on [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core), [@babel/plugin-transform-class-properties](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-class-properties), [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env), [conventional-changelog-conventionalcommits](https://github.com/conventional-changelog/conventional-changelog/tree/HEAD/packages/conventional-changelog-conventionalcommits), [rollup](https://github.com/rollup/rollup), [rollup-plugin-license](https://github.com/mjeanroy/rollup-plugin-license), [semantic-release](https://github.com/semantic-release/semantic-release) and [stylelint](https://github.com/stylelint/stylelint) to permit the latest version.

    Updates `@babel/core` to 7.24.6
    - [Release notes](https://github.com/babel/babel/releases)
    - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/babel/babel/commits/v7.24.6/packages/babel-core)

    Updates `@babel/plugin-transform-class-properties` to 7.24.6
    - [Release notes](https://github.com/babel/babel/releases)
    - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/babel/babel/commits/v7.24.6/packages/babel-plugin-transform-class-properties)

    Updates `@babel/preset-env` to 7.24.6
    - [Release notes](https://github.com/babel/babel/releases)
    - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/babel/babel/commits/v7.24.6/packages/babel-preset-env)

    Updates `conventional-changelog-conventionalcommits` from 7.0.2 to 8.0.0
    - [Release notes](https://github.com/conventional-changelog/conventional-changelog/releases)
    - [Changelog](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-conventionalcommits/CHANGELOG.md)
    - [Commits](https://github.com/conventional-changelog/conventional-changelog/commits/conventional-changelog-conventionalcommits-v8.0.0/packages/conventional-changelog-conventionalcommits)

    Updates `rollup` to 4.18.0
    - [Release notes](https://github.com/rollup/rollup/releases)
    - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
    - [Commits](rollup/rollup@v4.17.2...v4.18.0)

    Updates `rollup-plugin-license` to 3.4.0
    - [Changelog](https://github.com/mjeanroy/rollup-plugin-license/blob/master/CHANGELOG.md)
    - [Commits](mjeanroy/rollup-plugin-license@v3.3.1...v3.4.0)

    Updates `semantic-release` from 23.1.1 to 24.0.0
    - [Release notes](https://github.com/semantic-release/semantic-release/releases)
    - [Commits](semantic-release/semantic-release@v23.1.1...v24.0.0)

    Updates `stylelint` to 16.6.1
    - [Release notes](https://github.com/stylelint/stylelint/releases)
    - [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
    - [Commits](stylelint/stylelint@16.5.0...16.6.1)

commit 1e3d4a6
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Mon Jun 3 21:12:54 2024 +0800

    feat(dev): support vscode dev-container (cotes2020#1781)

commit 1c5fa08
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Sat Jun 1 04:11:01 2024 +0800

    refactor: restore shell script extensions

    Without an extension, the shell script configuration in `.gitattribute` will not work.

commit 64ae7a3
Author: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date:   Thu May 30 03:33:35 2024 +0800

    docs: correct markdown syntax of tutorial (cotes2020#1787)
  • Loading branch information
lotusk08 committed Jun 8, 2024
1 parent 5de46c1 commit f63a18b
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 77 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Jekyll",
"image": "mcr.microsoft.com/devcontainers/jekyll:2-bullseye",
"onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"postCreateCommand": "bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh"
},
"extensions": [
// Liquid tags auto-complete
"killalau.vscode-liquid-snippets",
// Liquid syntax highlighting and formatting
"Shopify.theme-check-vscode",
// Shell
"timonwong.shellcheck",
"mkhl.shfmt",
// Common formatter
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"yzhang.markdown-all-in-one",
// Git
"mhutchie.git-graph"
]
}
}
}
18 changes: 18 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

if [ -f package.json ]; then
bash -i -c "nvm install --lts && nvm install-latest-npm"
npm i
npm run build
fi

# Install dependencies for shfmt extension
curl -sS https://webi.sh/shfmt | sh &>/dev/null

# Add OMZ plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
sed -i -E "s/^(plugins=\()(git)(\))/\1\2 zsh-syntax-highlighting zsh-autosuggestions\3/" ~/.zshrc

# Avoid git log use less
echo -e "\nunset LESS" >>~/.zshrc
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
run: npm i && npm run build

- name: Test Site
run: bash tools/test
run: bash tools/test.sh
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Gemfile.lock
.jekyll-cache
.jekyll-metadata
_site
_app

# RubyGems
*.gem
Expand All @@ -17,7 +18,7 @@ package-lock.json

# IDE configurations
.idea
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
!.nova
Expand Down
5 changes: 1 addition & 4 deletions .husky/commit-msg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
npx --no -- commitlint --edit $1
7 changes: 3 additions & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ collections:
tabs:
output: true
sort_by: order
app:
output: true
permalink: /:name

defaults:
- scope:
Expand All @@ -194,10 +197,6 @@ defaults:
values:
layout: page
permalink: /:title/
- scope:
path: assets/js/dist
values:
swcache: true

sass:
style: compressed
Expand Down
2 changes: 0 additions & 2 deletions _drafts/2019-08-08-write-a-new-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,6 @@ If you want to display the **Liquid** snippet, surround the liquid code with `{%

Or adding `render_with_liquid: false` (Requires Jekyll 4.0 or higher) to the post's YAML block.

```
## Mathematics

We use [**MathJax**][mathjax] to generate mathematics. For website performance reasons, the mathematical feature won't be loaded by default. But it can be enabled by:
Expand Down
7 changes: 3 additions & 4 deletions _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

<!-- layout specified -->

{% assign js_dist = '/assets/js/dist/' %}

{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
{% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %}

Expand Down Expand Up @@ -62,7 +60,8 @@
{% assign js = 'commons' %}
{% endcase %}

{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}

<script src="{{ script | relative_url }}"></script>

{% if page.math %}
Expand Down Expand Up @@ -93,7 +92,7 @@
{% if jekyll.environment == 'production' %}
<!-- PWA -->
{% if site.pwa.enabled %}
<script defer src="{{ 'app.min.js' | prepend: js_dist | relative_url }}"></script>
<script defer src="{{ 'app.min.js' | relative_url }}"></script>
{% endif %}

<!-- Web Analytics -->
Expand Down
1 change: 0 additions & 1 deletion _javascript/_copyright

This file was deleted.

3 changes: 0 additions & 3 deletions _javascript/pwa/_frontmatter

This file was deleted.

2 changes: 1 addition & 1 deletion jekyll-theme-chirpy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0").select { |f|
f.match(%r!^((_(includes|layouts|sass|(data\/(locales|origin)))|assets)\/|README|LICENSE)!i)
f.match(%r!^((_(includes|layouts|sass|app|(data\/(locales|origin)))|assets)\/|README|LICENSE)!i)
}

spec.metadata = {
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"author": "Cotes Chung",
"license": "MIT",
"since": 2019,
"bugs": {
"url": "https://github.com/cotes2020/jekyll-theme-chirpy/issues"
},
Expand All @@ -19,17 +20,18 @@
"watch:js": "rollup -c --bundleConfigAsCjs -w",
"lint:scss": "stylelint _sass/**/*.scss",
"lint:fix:scss": "npm run lint:scss -- --fix",
"test": "npm run lint:scss"
"test": "npm run lint:scss",
"prepare": "husky"
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.3",
"lqip-modern": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/plugin-transform-class-properties": "^7.24.1",
"@babel/preset-env": "^7.24.5",
"@babel/core": "^7.24.6",
"@babel/plugin-transform-class-properties": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@rollup/plugin-babel": "^6.0.4",
Expand All @@ -43,10 +45,9 @@
"conventional-changelog-conventionalcommits": "^8.0.0",
"husky": "^9.0.11",
"purgecss": "^6.0.0",
"rollup": "^4.17.2",
"rollup-plugin-license": "^3.3.1",
"semantic-release": "^23.1.1",
"stylelint": "^16.5.0",
"rollup": "^4.18.0",
"semantic-release": "^24.0.0",
"stylelint": "^16.6.1",
"stylelint-config-standard-scss": "^13.1.0"
},
"prettier": {
Expand Down Expand Up @@ -157,8 +158,8 @@
[
"@semantic-release/exec",
{
"prepareCmd": "bash tools/release --prepare",
"publishCmd": "bash tools/release"
"prepareCmd": "bash tools/release.sh --prepare",
"publishCmd": "bash tools/release.sh"
}
],
[
Expand Down
50 changes: 23 additions & 27 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
import babel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import license from 'rollup-plugin-license';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import fs from 'fs';
import path from 'path';
import yaml from '@rollup/plugin-yaml';
import fs from 'fs';
import pkg from './package.json';

const SRC_DEFAULT = '_javascript';
const DIST_DEFAULT = 'assets/js/dist';

const SRC_PWA = `${SRC_DEFAULT}/pwa`;
const DIST_PWA = '_app';

const banner = `/*!
* ${pkg.name} v${pkg.version} | © ${pkg.since} ${pkg.author} | ${pkg.license} Licensed | ${pkg.homepage}
*/`;

const isProd = process.env.BUILD === 'production';

if (fs.existsSync(DIST_DEFAULT)) {
fs.rm(DIST_DEFAULT, { recursive: true, force: true }, (err) => {
if (err) {
throw err;
}
});
function cleanup(...directories) {
for (const dir of directories) {
fs.rm(dir, { recursive: true, force: true }, (err) => {
if (err) {
console.error(`Failed to remove directory ${dir}: ${err}`);
}
});
}
}

function build(filename, opts = {}) {
const src = opts.src || SRC_DEFAULT;
const dist = opts.dist || DIST_DEFAULT;
const bannerUrl =
opts.bannerUrl || path.join(__dirname, SRC_DEFAULT, '_copyright');
const commentStyle = opts.commentStyle || 'ignored';

return {
input: [`${src}/${filename}.js`],
input: `${src}/${filename}.js`,
output: {
file: `${dist}/${filename}.min.js`,
format: 'iife',
name: 'Chirpy',
banner,
sourcemap: !isProd
},
watch: {
Expand All @@ -46,29 +51,20 @@ function build(filename, opts = {}) {
}),
nodeResolve(),
yaml(),
isProd && commentStyle === 'none' && terser(),
license({
banner: {
commentStyle,
content: { file: bannerUrl }
}
}),
isProd && commentStyle !== 'none' && terser()
isProd && terser()
]
};
}

cleanup(DIST_DEFAULT, DIST_PWA);

export default [
build('commons'),
build('home'),
build('categories'),
build('page'),
build('post'),
build('misc'),
build('app', { src: SRC_PWA }),
build('sw', {
src: SRC_PWA,
bannerUrl: path.join(__dirname, SRC_PWA, '_frontmatter'),
commentStyle: 'none'
})
build('app', { src: SRC_PWA, dist: DIST_PWA }),
build('sw', { src: SRC_PWA, dist: DIST_PWA })
];
2 changes: 1 addition & 1 deletion tools/init → tools/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ init_files() {
npm i && npm run build

# track the CSS/JS output
_sedi "/.*\/dist$/d" .gitignore
_sedi "/.*\/dist$/d;/^_app$/d" .gitignore
}

commit() {
Expand Down
20 changes: 3 additions & 17 deletions tools/release → tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CONFIG="_config.yml"

CSS_DIST="_sass/dist"
JS_DIST="assets/js/dist"
PWA_DIST="_app"

FILES=(
"$GEM_SPEC"
Expand All @@ -37,7 +38,7 @@ help() {
echo " 2. Merge the release branch into the default branch"
echo
echo "Usage:"
echo " bash ./tools/release [options]"
echo " bash $0 [options]"
echo
echo "Options:"
echo " --prepare Preparation for release"
Expand Down Expand Up @@ -111,35 +112,20 @@ prepare() {

## Build a Gem package
build_gem() {
if $opt_pkg; then
BACKUP_PATH="$(mktemp -d)"
mkdir -p "$BACKUP_PATH"/css "$BACKUP_PATH"/js
[[ -d $CSS_DIST ]] && cp "$CSS_DIST"/* "$BACKUP_PATH"/css
[[ -d $JS_DIST ]] && cp "$JS_DIST"/* "$BACKUP_PATH"/js
fi

# Remove unnecessary theme settings
sed -i -E "s/(^timezone:).*/\1/;s/(^cdn:).*/\1/;s/(^avatar:).*/\1/" $CONFIG
rm -f ./*.gem

npm run build
# add CSS/JS distribution files to gem package
git add "$CSS_DIST" "$JS_DIST" -f
git add "$CSS_DIST" "$JS_DIST" "$PWA_DIST" -f

echo -e "\n> gem build $GEM_SPEC\n"
gem build "$GEM_SPEC"

echo -e "\n> Resume file changes ...\n"
git reset
git checkout .

if $opt_pkg; then
# restore the dist files for future development
mkdir -p "$CSS_DIST" "$JS_DIST"
cp "$BACKUP_PATH"/css/* "$CSS_DIST"
cp "$BACKUP_PATH"/js/* "$JS_DIST"
rm -rf "$BACKUP_PATH"
fi
}

# Push the gem to RubyGems.org (using $GEM_HOST_API_KEY)
Expand Down
4 changes: 4 additions & 0 deletions tools/run → tools/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ if $prod; then
command="JEKYLL_ENV=production $command"
fi

if [ -e /proc/1/cgroup ] && grep -q docker /proc/1/cgroup; then
command="$command --force_polling"
fi

echo -e "\n> $command\n"
eval "$command"
2 changes: 1 addition & 1 deletion tools/test → tools/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ help() {
echo
echo "Usage:"
echo
echo " bash ./tools/test [options]"
echo " bash $0 [options]"
echo
echo "Options:"
echo ' -c, --config "<config_a[,config_b[...]]>" Specify config file(s)'
Expand Down

0 comments on commit f63a18b

Please sign in to comment.