Compare commits
5 Commits
refactor/s
...
36008d1b6d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36008d1b6d | ||
|
|
3c843d3d6a | ||
|
|
ad5cdc920b | ||
|
|
74ba9b640c | ||
|
|
d6a6f003a5 |
20
.build/banner.mjs
Normal file
@@ -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 2011-${year} ${pkg.author}
|
||||
* Licensed under MIT (https://github.com/tabler/tabler/blob/main/LICENSE)
|
||||
*/`
|
||||
}
|
||||
|
||||
export default getBanner
|
||||
106
.build/change-version.mjs
Normal file
@@ -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
.build/changelog.mjs
Normal file
@@ -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)
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
'use strict'
|
||||
|
||||
const YAML = require('yaml')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const request = require('request')
|
||||
const filePath = path.join(__dirname, '../src/pages/_data/photos.yml')
|
||||
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) => {
|
||||
@@ -51,7 +54,7 @@ async function downloadPhotos() {
|
||||
photos[key]['horizontal'] = photo['width'] > photo['height']
|
||||
}
|
||||
|
||||
fs.writeFileSync(filePath, YAML.stringify(photos))
|
||||
fs.writeFileSync(filePath, YAML.stringify(photos))
|
||||
}
|
||||
|
||||
downloadPhotos();
|
||||
66
.build/generate-sri.mjs
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict'
|
||||
|
||||
import crypto from 'crypto'
|
||||
import { readFileSync, write, 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, '../preview/_config.yml')
|
||||
|
||||
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, '../core', file.file), 'utf8')
|
||||
|
||||
const algo = 'sha384'
|
||||
const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
|
||||
const integrity = `${algo}-${hash}`
|
||||
|
||||
console.log(`${file.configPropertyName}: ${integrity}`)
|
||||
|
||||
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
.build/import-icons.mjs
Normal file
@@ -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)
|
||||
)
|
||||
4
.gitignore
vendored
@@ -30,4 +30,6 @@ node_modules/
|
||||
.yarn
|
||||
.next
|
||||
.vercel
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
|
||||
.turbo
|
||||
@@ -1,3 +0,0 @@
|
||||
version: 1
|
||||
snapshot:
|
||||
widths: [1440]
|
||||
17
core/.build/postcss.config.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
const mapConfig = {
|
||||
inline: false,
|
||||
annotation: true,
|
||||
sourcesContent: true
|
||||
}
|
||||
|
||||
export default context => {
|
||||
return {
|
||||
map: mapConfig,
|
||||
plugins: {
|
||||
autoprefixer: {
|
||||
cascade: false
|
||||
},
|
||||
rtlcss: context.env === 'RTL'
|
||||
}
|
||||
}
|
||||
}
|
||||
59
core/.build/rollup.config.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { babel } from '@rollup/plugin-babel'
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import banner from '../../.build/banner.mjs'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const BUNDLE = process.env.BUNDLE === 'true'
|
||||
const ESM = process.env.ESM === 'true'
|
||||
|
||||
let destinationFile = `tabler${ESM ? '.esm' : ''}`
|
||||
const external = ['@popperjs/core', 'bootstrap']
|
||||
const plugins = [
|
||||
babel({
|
||||
exclude: 'node_modules/**',
|
||||
babelHelpers: 'bundled'
|
||||
})
|
||||
]
|
||||
const globals = {
|
||||
'@popperjs/core': 'Popper',
|
||||
'bootstrap': 'Bootstrap',
|
||||
}
|
||||
|
||||
if (BUNDLE) {
|
||||
destinationFile += '.bundle'
|
||||
external.pop()
|
||||
external.pop()
|
||||
delete globals['@popperjs/core']
|
||||
delete globals['bootstrap']
|
||||
plugins.push(
|
||||
replace({
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
preventAssignment: true
|
||||
}),
|
||||
nodeResolve()
|
||||
)
|
||||
}
|
||||
|
||||
const rollupConfig = {
|
||||
input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`),
|
||||
output: {
|
||||
banner: banner(),
|
||||
file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`),
|
||||
format: ESM ? 'esm' : 'umd',
|
||||
globals,
|
||||
generatedCode: 'es2015'
|
||||
},
|
||||
external,
|
||||
plugins
|
||||
}
|
||||
|
||||
if (!ESM) {
|
||||
rollupConfig.output.name = 'tabler'
|
||||
}
|
||||
|
||||
export default rollupConfig
|
||||
1
core/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
dist
|
||||
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 877 B After Width: | Height: | Size: 877 B |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 584 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 572 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 970 B After Width: | Height: | Size: 970 B |
|
Before Width: | Height: | Size: 842 B After Width: | Height: | Size: 842 B |
|
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 711 B |
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 577 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 634 B |
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 757 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 849 B After Width: | Height: | Size: 849 B |
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 437 B After Width: | Height: | Size: 437 B |
|
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 532 B |
|
Before Width: | Height: | Size: 950 B After Width: | Height: | Size: 950 B |
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 565 B After Width: | Height: | Size: 565 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 817 B After Width: | Height: | Size: 817 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 666 B After Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 584 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 573 B After Width: | Height: | Size: 573 B |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 609 B After Width: | Height: | Size: 609 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 572 B |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 979 B After Width: | Height: | Size: 979 B |
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 634 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 417 B |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 801 B After Width: | Height: | Size: 801 B |