Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change Jekyll to Eleventy #1837

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d6a6f00
new build process, separate packages
codecalm Jan 21, 2024
74ba9b6
update banners
codecalm Jan 21, 2024
ad5cdc9
change build scripts
codecalm Jan 22, 2024
3c843d3
banner, generate sri
codecalm Jan 22, 2024
36008d1
generate sri
codecalm Jan 22, 2024
82216ad
banner update
codecalm Jan 31, 2024
f2587ae
banner update
codecalm Jan 31, 2024
54ea139
new foders structure
codecalm Jan 31, 2024
3564ffb
dist remove, build improvements
codecalm Feb 27, 2024
c46a8fe
dist remove, build improvements
codecalm Feb 27, 2024
5219b86
browsersync init
codecalm Feb 27, 2024
8627d32
eleventy init
codecalm Feb 29, 2024
5065078
build fix
codecalm Feb 29, 2024
4c1b9e8
rename preview to pages
codecalm Feb 29, 2024
69fb270
rename preview to pages
codecalm Feb 29, 2024
e107d34
Merge branch 'dev-build-eleventy' of https://github.com/tabler/tabler…
codecalm Feb 29, 2024
51da6d1
Merge branch 'dev-build-eleventy' of https://github.com/tabler/tabler…
codecalm Feb 29, 2024
87d785c
Merge branch 'dev-build-eleventy' of https://github.com/tabler/tabler…
codecalm Feb 29, 2024
3632b6d
env variables
codecalm Feb 29, 2024
5efdcad
layout fixes
codecalm Feb 29, 2024
d0a15c1
partials fix
codecalm Feb 29, 2024
6bcb7e3
includes fixes
codecalm Feb 29, 2024
b593404
icons, time now
codecalm Feb 29, 2024
70e4346
build fixes
codecalm Feb 29, 2024
2633097
build fixes
codecalm Feb 29, 2024
6d6a158
build fix
codecalm Feb 29, 2024
9d93029
icons include
codecalm Apr 29, 2024
2cd0da4
add missing filters
codecalm Apr 29, 2024
5e196a2
homepagge activity
codecalm Apr 29, 2024
eb3c122
css and js libs include
codecalm Apr 29, 2024
7f37111
libs fix
codecalm Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
20 changes: 20 additions & 0 deletions .build/banner.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const pkgJson = path.join(__dirname, '../package.json')
const pkg = JSON.parse(await fs.readFile(pkgJson, 'utf8'))

const year = new Date().getFullYear()

function getBanner(pluginFilename) {
return `/*!
* Tabler${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage})
* Copyright 2018-${year} ${pkg.author}
* Licensed under MIT (https://github.com/tabler/tabler/blob/main/LICENSE)
*/`
}

export default getBanner
16 changes: 16 additions & 0 deletions .build/browsersync.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import bs from 'browser-sync';

bs.init({
server: {
baseDir: "_site",
routes: {
"/dist": "./dist",
}
},
files: [
'./dist/*'
],
ui: {
port: 3000
}
})
106 changes: 106 additions & 0 deletions .build/change-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env node

'use strict'

import { execFile } from 'node:child_process'
import fs from 'node:fs/promises'
import process from 'node:process'

const VERBOSE = process.argv.includes('--verbose')
const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run')

const FILES = [
'README.md',
'test.md',
'preview/_config.yml',
'core/scss/_banner.scss',
'core/js/base.js'
]

function regExpQuote(string) {
return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&')
}

function regExpQuoteReplacement(string) {
return string.replace(/\$/g, '$$')
}

async function replaceRecursively(file, oldVersion, newVersion) {
const originalString = await fs.readFile(file, 'utf8')
const newString = originalString
.replace(
new RegExp(regExpQuote(oldVersion), 'g'),
regExpQuoteReplacement(newVersion)
)
// Also replace the version used by the rubygem,
// which is using periods (`.`) instead of hyphens (`-`)
.replace(
new RegExp(regExpQuote(oldVersion.replace(/-/g, '.')), 'g'),
regExpQuoteReplacement(newVersion.replace(/-/g, '.'))
)

// No need to move any further if the strings are identical
if (originalString === newString) {
return
}

if (VERBOSE) {
console.log(`Found ${oldVersion} in ${file}`)
}

if (DRY_RUN) {
return
}

await fs.writeFile(file, newString, 'utf8')
}

function showUsage(args) {
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
console.error('Got arguments:', args)
process.exit(1)
}

function bumpPnpmVersion(newVersion) {
if (DRY_RUN) {
return
}

if (process.env.npm_package_version !== newVersion) {
execFile('pnpm', ['version', '-r', newVersion, '--no-git-tag'], { shell: true }, error => {
if (error) {
console.error(error)
process.exit(1)
}
})
}
}

async function main(args) {
let [oldVersion, newVersion] = args

if (!oldVersion || !newVersion) {
showUsage(args)
}

[oldVersion, newVersion] = [oldVersion, newVersion].map(arg => {
return arg.startsWith('v') ? arg.slice(1) : arg
})

if (oldVersion === newVersion) {
showUsage(args)
}

bumpPnpmVersion(newVersion)

try {
await Promise.all(
FILES.map(file => replaceRecursively(file, oldVersion, newVersion))
)
} catch (error) {
console.error(error)
process.exit(1)
}
}

main(process.argv.slice(2))
27 changes: 27 additions & 0 deletions .build/changelog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node

'use strict'

const content = YAML.parse(fs.readFileSync(path.join(__dirname, '../preview/pages/_data/changelog.yml', 'utf8'))).reverse()

let readme = `# Changelog

All notable changes to this project will be documented in this file.\n`

content.forEach((change) => {
readme += `\n\n## \`${change.version}\` - ${change.date}\n\n`

if (change.description) {
readme += `**${change.description}**\n\n`
}

change.changes.forEach((line) => {
readme += `- ${line}\n`
})

console.log(change.version);
})

console.log(readme);

// fs.writeFileSync('CHANGELOG.md', readme)
17 changes: 17 additions & 0 deletions .build/convert-yml-to-json.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { globSync } from 'glob';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { readFileSync, writeFileSync, unlinkSync } from 'fs';
import YAML from 'yaml';

const __dirname = dirname(fileURLToPath(import.meta.url))

const files = globSync(join(__dirname, `../pages/_data/*.yml`))
console.log(files);

files.forEach((file) => {
const content = YAML.parse(readFileSync(file, 'utf8'))

writeFileSync(file.replace('.yml', '.json'), JSON.stringify(content, null, 2))
unlinkSync(file)
})
61 changes: 61 additions & 0 deletions .build/download-images.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env node

'use strict'

import YAML from 'yaml'
import fs from 'node:fs'
import path from 'node:path'
import request from 'request'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const filePath = path.join(__dirname, '../preview/pages/_data/photos.yml')
const photos = YAML.parse(fs.readFileSync(filePath, 'utf8'))

const urlTitle = (str) => {
str = str
.toLowerCase()
.replaceAll('&', 'and')
.replace(/[^[a-z0-9-]/g, '-')
.replace(/-+/g, '-')

return str
}

const download = function(uri, filename, callback, error) {
request.head(uri, function(err, res, body) {
request(uri).pipe(fs.createWriteStream(filename))
.on('close', callback)
.on('error', error)
})
}

async function downloadPhotos() {
for (const key in photos) {
const photo = photos[key]

let filename, i = 1;

do {
filename = `${urlTitle(photo['title'])}${i > 1 ? `-${i}` : ''}.jpg`
i++
} while (fs.existsSync(path.join(__dirname, `../src/static/photos/${filename}`)))

await new Promise((resolve, reject) => {
download(photo['path'], path.join(__dirname, `../src/static/photos/${filename}`), function(){
resolve()
}, function() {
reject()
});
})

photos[key]['file'] = filename
photos[key]['horizontal'] = photo['width'] > photo['height']
}

fs.writeFileSync(filePath, YAML.stringify(photos))
}

downloadPhotos();

66 changes: 66 additions & 0 deletions .build/generate-sri.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env node

'use strict'

import crypto from 'crypto'
import { readFileSync, writeFileSync } from 'fs'
import path from 'path'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const configFile = path.join(__dirname, '../pages/_data/site.json')

console.log(configFile)

const files = [
{
file: 'dist/css/tabler.min.css',
configPropertyName: 'css_hash'
},
{
file: 'dist/css/tabler.rtl.min.css',
configPropertyName: 'css_rtl_hash'
},
{
file: 'dist/css/tabler-flags.min.css',
configPropertyName: 'css_flags_hash'
},
{
file: 'dist/css/tabler-payments.min.css',
configPropertyName: 'css_payments_hash'
},
{
file: 'dist/css/tabler-social.min.css',
configPropertyName: 'css_social_hash'
},
{
file: 'dist/css/tabler-vendors.min.css',
configPropertyName: 'css_vendors_hash'
},
{
file: 'dist/js/tabler.min.js',
configPropertyName: 'js_hash'
},
{
file: 'dist/js/tabler.bundle.min.js',
configPropertyName: 'js_bundle_hash'
}
]

files.forEach((file) => {
const data = readFileSync(path.join(__dirname, '..', file.file), 'utf8')

const algo = 'sha384'
const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
const integrity = `${algo}-${hash}`

let config = readFileSync(configFile, 'utf8')

const regex = new RegExp(`"${file.configPropertyName}"\\:\\s+("|')(\\S+)(\\1)`, 'gm')
config = config.replace(regex, function() {
return `"${file.configPropertyName}": ${arguments[1]}${integrity}${arguments[3]}`
})

writeFileSync(configFile, config, 'utf8')
})
50 changes: 50 additions & 0 deletions .build/import-icons.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env node

'use strict'

import { fileURLToPath } from 'node:url'
import { readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'

import iconsTags from '../node_modules/@tabler/icons/tags.json' assert { type: "json" }
import iconsPkg from '../node_modules/@tabler/icons/package.json' assert { type: "json" }

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const prepareSvgFile = (svg) => {
return svg.replace(/\n/g, '').replace(/>\s+</g, '><')
}

let svgList = {}
for (let iconName in iconsTags) {
let iconData = iconsTags[iconName]
svgList[iconName] = {
name: iconName,
version: iconData.version,
category: iconData.category,
tags: iconData.tags,
unicode: iconData.unicode,
svg: prepareSvgFile(
readFileSync(
path.join(
__dirname,
`../node_modules/@tabler/icons/icons/${iconName}.svg`
)
)
.toString())

}
}

writeFileSync(
path.join(__dirname, `../preview/pages/_data/icons-info.json`),
JSON.stringify({
version: iconsPkg.version,
count: Object.keys(svgList).length,
})
)

writeFileSync(
path.join(__dirname, `../preview/pages/_data/icons.json`),
JSON.stringify(svgList)
)