Browse Source

Monorepo structure, remove Gulp, new build process (#2116)

Paweł Kuna 7 months ago
parent
commit
eaa7f81604
100 changed files with 116 additions and 218 deletions
  1. 4 9
      .browserslistrc
  2. 0 57
      .build/download-images.js
  3. 0 37
      .build/import-icons.js
  4. 0 44
      .build/import-illustrations.js
  5. 0 36
      .build/reformat-mdx.js
  6. 0 26
      .build/unused-files.js
  7. 5 0
      .changeset/short-rocks-battle.md
  8. 1 0
      .gitignore
  9. 7 9
      .vscode/settings.json
  10. 38 0
      build/reformat-mdx.mjs
  11. 15 0
      core/build/postcss.config.mjs
  12. 46 0
      core/build/rollup.config.mjs
  13. 0 0
      core/img/flags/ad.svg
  14. 0 0
      core/img/flags/ae.svg
  15. 0 0
      core/img/flags/af.svg
  16. 0 0
      core/img/flags/afrun.svg
  17. 0 0
      core/img/flags/ag.svg
  18. 0 0
      core/img/flags/ai.svg
  19. 0 0
      core/img/flags/al.svg
  20. 0 0
      core/img/flags/am.svg
  21. 0 0
      core/img/flags/ao.svg
  22. 0 0
      core/img/flags/aq.svg
  23. 0 0
      core/img/flags/ar.svg
  24. 0 0
      core/img/flags/as.svg
  25. 0 0
      core/img/flags/at.svg
  26. 0 0
      core/img/flags/au.svg
  27. 0 0
      core/img/flags/aw.svg
  28. 0 0
      core/img/flags/ax.svg
  29. 0 0
      core/img/flags/az.svg
  30. 0 0
      core/img/flags/ba.svg
  31. 0 0
      core/img/flags/bb.svg
  32. 0 0
      core/img/flags/bd.svg
  33. 0 0
      core/img/flags/be.svg
  34. 0 0
      core/img/flags/bf.svg
  35. 0 0
      core/img/flags/bg.svg
  36. 0 0
      core/img/flags/bh.svg
  37. 0 0
      core/img/flags/bi.svg
  38. 0 0
      core/img/flags/bj.svg
  39. 0 0
      core/img/flags/bl.svg
  40. 0 0
      core/img/flags/bm.svg
  41. 0 0
      core/img/flags/bn.svg
  42. 0 0
      core/img/flags/bo.svg
  43. 0 0
      core/img/flags/bq-bo.svg
  44. 0 0
      core/img/flags/bq-sa.svg
  45. 0 0
      core/img/flags/bq-se.svg
  46. 0 0
      core/img/flags/br.svg
  47. 0 0
      core/img/flags/bs.svg
  48. 0 0
      core/img/flags/bt.svg
  49. 0 0
      core/img/flags/bv.svg
  50. 0 0
      core/img/flags/bw.svg
  51. 0 0
      core/img/flags/by.svg
  52. 0 0
      core/img/flags/bz.svg
  53. 0 0
      core/img/flags/ca.svg
  54. 0 0
      core/img/flags/cc.svg
  55. 0 0
      core/img/flags/cd.svg
  56. 0 0
      core/img/flags/cf.svg
  57. 0 0
      core/img/flags/cg.svg
  58. 0 0
      core/img/flags/ch.svg
  59. 0 0
      core/img/flags/ci.svg
  60. 0 0
      core/img/flags/ck.svg
  61. 0 0
      core/img/flags/cl.svg
  62. 0 0
      core/img/flags/cm.svg
  63. 0 0
      core/img/flags/cn.svg
  64. 0 0
      core/img/flags/co.svg
  65. 0 0
      core/img/flags/cr.svg
  66. 0 0
      core/img/flags/cu.svg
  67. 0 0
      core/img/flags/cv.svg
  68. 0 0
      core/img/flags/cw.svg
  69. 0 0
      core/img/flags/cx.svg
  70. 0 0
      core/img/flags/cy.svg
  71. 0 0
      core/img/flags/cz.svg
  72. 0 0
      core/img/flags/de.svg
  73. 0 0
      core/img/flags/dj.svg
  74. 0 0
      core/img/flags/dk.svg
  75. 0 0
      core/img/flags/dm.svg
  76. 0 0
      core/img/flags/do.svg
  77. 0 0
      core/img/flags/dz.svg
  78. 0 0
      core/img/flags/ec.svg
  79. 0 0
      core/img/flags/ee.svg
  80. 0 0
      core/img/flags/eg.svg
  81. 0 0
      core/img/flags/eh.svg
  82. 0 0
      core/img/flags/er.svg
  83. 0 0
      core/img/flags/es.svg
  84. 0 0
      core/img/flags/et.svg
  85. 0 0
      core/img/flags/eu.svg
  86. 0 0
      core/img/flags/fi.svg
  87. 0 0
      core/img/flags/fj.svg
  88. 0 0
      core/img/flags/fk.svg
  89. 0 0
      core/img/flags/fm.svg
  90. 0 0
      core/img/flags/fo.svg
  91. 0 0
      core/img/flags/fr.svg
  92. 0 0
      core/img/flags/ga.svg
  93. 0 0
      core/img/flags/gb-eng.svg
  94. 0 0
      core/img/flags/gb-nir.svg
  95. 0 0
      core/img/flags/gb-sct.svg
  96. 0 0
      core/img/flags/gb-wls.svg
  97. 0 0
      core/img/flags/gb.svg
  98. 0 0
      core/img/flags/gd.svg
  99. 0 0
      core/img/flags/ge.svg
  100. 0 0
      core/img/flags/gf.svg

+ 4 - 9
.browserslistrc

@@ -1,11 +1,6 @@
 >= 1%
-last 1 major version
+last 2 versions
+Firefox ESR 
 not dead
-Chrome >= 60
-Firefox >= 60
-Edge >= 15.15063
-Explorer 11
-iOS >= 10
-Safari >= 10
-Android >= 6
-not ExplorerMobile <= 11
+safari >= 15.4
+iOS >= 15.4

+ 0 - 57
.build/download-images.js

@@ -1,57 +0,0 @@
-#!/usr/bin/env node
-
-'use strict'
-
-const fs = require('node:fs')
-const path = require('node:path')
-const request = require('request')
-const filePath = path.join(__dirname, '../src/pages/_data/photos.json')
-
-const photos = JSON.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, JSON.stringify(photos))
-}
-
-downloadPhotos();
-

+ 0 - 37
.build/import-icons.js

@@ -1,37 +0,0 @@
-#!/usr/bin/env node
-
-'use strict'
-
-const fs = require('fs'),
-	path = require('path');
-
-const iconsTags = require('../node_modules/@tabler/icons/icons.json'),
-	iconsPkg = require('../node_modules/@tabler/icons/package.json');
-
-const prepareSvgFile = (svg) => {
-	return svg.replace(/\n/g, '').replace(/>\s+</g, '><').replace(/\s+/g, ' ')
-}
-
-let svgList = {}
-for (let iconName in iconsTags) {
-	let iconData = iconsTags[iconName]
-	svgList[iconName] = {
-		name: iconName,
-		svg: {
-			outline: iconData.styles.outline ? prepareSvgFile(fs.readFileSync(path.join(__dirname, `../node_modules/@tabler/icons/icons/outline/${iconName}.svg`), 'utf8')) : null,
-			filled: iconData.styles.filled ? prepareSvgFile(fs.readFileSync(path.join(__dirname, `../node_modules/@tabler/icons/icons/filled/${iconName}.svg`), 'utf8')) : null,
-		}
-	}
-}
-
-fs.writeFileSync(
-	path.join(__dirname, `../src/pages/_data/icons-info.json`),
-	JSON.stringify({
-		version: iconsPkg.version,
-		count: Object.values(svgList).reduce((acc, icon) => {
-			return acc + (icon.svg.outline ? 1 : 0) + (icon.svg.filled ? 1 : 0)
-		}, 0)
-	})
-)
-
-fs.writeFileSync(path.join(__dirname, `../src/pages/_data/icons.json`), JSON.stringify(svgList))

+ 0 - 44
.build/import-illustrations.js

@@ -1,44 +0,0 @@
-#!/usr/bin/env node
-
-'use strict'
-
-const fs = require('fs'),
-	path = require('path'),
-	glob = require('glob');
-
-const illustrations = glob
-	.sync(path.join(__dirname, `../src/static/illustrations/light/*.png`))
-	.map((file) => {
-		return path.basename(file, '.png')
-	})
-
-fs.writeFileSync(
-	path.join(__dirname, `../src/pages/_data/illustrations.json`),
-	JSON.stringify(illustrations)
-)
-
-
-// let i = {}
-// const dirs = ['light', 'dark', 'autodark']
-// const ilustrations = ['not-found', 'computer-fix', 'boy-with-key', 'boy-girl']
-
-// for(const dir of dirs) {
-// 	i[dir] = {}
-
-// 	for(const ilustration of ilustrations) {
-// 		let svg = fs.readFileSync(path.join(__dirname, `../src/pages/_free-illustrations/${dir}/${ilustration}.svg`), 'utf8')
-
-// 		svg = svg
-// 			.replace(/\n+/g, ' ')
-// 			.replace(/>\s+</g, '><')
-// 			.replace(/\s+/g, ' ')
-// 			.replace(/^[\n\s-]+/, '')
-
-// 		i[dir][ilustration] = svg
-// 	}
-// }
-
-// fs.writeFileSync(
-// 	path.join(__dirname, `../src/pages/_data/free-illustrations.json`),
-// 	JSON.stringify(i)
-// )

+ 0 - 36
.build/reformat-mdx.js

@@ -1,36 +0,0 @@
-#!/usr/bin/env node
-
-'use strict'
-
-const fs = require('fs'),
-	path = require('path'),
-	glob = require('glob'),
-	beautifyHtml = require('js-beautify').html;
-
-const docs = glob
-	.sync(path.join(__dirname, `../docs/**/*.mdx`))
-
-docs.forEach((file, i) => {
-	const oldContent = fs.readFileSync(file, 'utf8')
-
-	// get codeblocks from markdown
-	const content = oldContent.replace(/(```([a-z0-9]+).*?\n)(.*?)(```)/gs, (m, m1, m2, m3, m4) => {
-		if (m2 === 'html') {
-			let m3m = beautifyHtml(m3, {
-				"indent_size": 2,
-				"indent_char": " ",
-			}).trim();
-
-			// remove empty lines
-			m3m = m3m.replace(/^\s*[\r\n]/gm, '');
-
-			return m1 + m3m + "\n" + m4;
-		}
-		return m
-	})
-
-	if (content !== oldContent) {
-		fs.writeFileSync(file, content, 'utf8')
-		console.log(`Reformatted ${file}`)
-	}
-})

+ 0 - 26
.build/unused-files.js

@@ -1,26 +0,0 @@
-const glob = require('glob');
-const fs = require('fs')
-const path = require('path')
-
-const srcDir = path.join(__dirname, '../src')
-
-let foundFiles = []
-glob.sync(`${srcDir}/pages/**/*.{html,md}`).forEach((file) => {
-	let fileContent = fs.readFileSync(file)
-
-	fileContent.toString().replace(/\{% include(_cached)? "([a-z0-9\/_-]+\.html)"/g, (f, c, filename) => {
-		filename = `${srcDir}/pages/_includes/${filename}`
-
-		if (!foundFiles.includes(filename)) {
-			foundFiles.push(filename)
-		}
-	})
-})
-
-let includeFiles = glob.sync(`${srcDir}/pages/_includes/**/*.html`)
-
-includeFiles.forEach((file) => {
-	if (!foundFiles.includes(file)) {
-		console.log('file', file)
-	}
-})

+ 5 - 0
.changeset/short-rocks-battle.md

@@ -0,0 +1,5 @@
+---
+"@tabler/core": patch
+---
+
+Refactored the project into a monorepo, removed Gulp, and introduced a new, more efficient build process.

+ 1 - 0
.gitignore

@@ -28,6 +28,7 @@ node_modules/
 .yarn
 .next
 .vercel
+.turbo
 package-lock.json
 
 demo/

+ 7 - 9
.vscode/settings.json

@@ -1,14 +1,12 @@
 {
    "files.exclude": {
-      "**/.git": false,
-      "**/.svn": false,
-      "**/.hg": false,
-      "**/CVS": false,
-      "**/.DS_Store": false,
-      "**/Thumbs.db": false,
-      "**/.idea/": false,
-      "dist": false,
-      "demo": false
+      "**/.git": true,
+      "**/.svn": true,
+      "**/.hg": true,
+      "**/CVS": true,
+      "**/.DS_Store": true,
+      "**/Thumbs.db": true,
+      "**/.idea/": true
    },
    "explorerExclude.backup": {}
 }

+ 38 - 0
build/reformat-mdx.mjs

@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+
+'use strict'
+
+import { readFileSync, writeFileSync } from 'node:fs';
+import { join, dirname } from 'node:path';
+import { fileURLToPath } from 'node:url'
+import { sync } from 'glob';
+import beautify from 'js-beautify';
+
+const __dirname = dirname(fileURLToPath(import.meta.url))
+
+const docs = sync(join(__dirname, '..', 'docs', '**', '*.mdx'))
+
+docs.forEach((file, i) => {
+	const oldContent = readFileSync(file, 'utf8')
+
+	// get codeblocks from markdown
+	const content = oldContent.replace(/(```([a-z0-9]+).*?\n)(.*?)(```)/gs, (m, m1, m2, m3, m4) => {
+		if (m2 === 'html') {
+			// m3 = beautify.default.html(m3, {
+			// 	"indent_size": 2,
+			// 	"indent_char": " ",
+			// }).trim();
+
+			// remove empty lines
+			m3 = m3.replace(/^\s*[\r\n]/gm, '');
+
+			return m1 + m3 + "\n" + m4;
+		}
+		return m
+	})
+
+	if (content !== oldContent) {
+		writeFileSync(file, content, 'utf8')
+		console.log(`Reformatted ${file}`)
+	}
+})

+ 15 - 0
core/build/postcss.config.mjs

@@ -0,0 +1,15 @@
+export default context => {
+	return {
+		map: {
+			inline: false,
+			annotation: true,
+			sourcesContent: true
+		},
+		plugins: {
+			autoprefixer: {
+				cascade: false
+			},
+			rtlcss: context.env === 'RTL'
+		}
+	}
+}

+ 46 - 0
core/build/rollup.config.mjs

@@ -0,0 +1,46 @@
+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 '@repo/banner'
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
+
+const ESM = process.env.ESM === 'true'
+
+let destinationFile = `tabler${ESM ? '.esm' : ''}`
+const external = []
+const plugins = [
+	babel({
+		exclude: 'node_modules/**',
+		babelHelpers: 'bundled'
+	})
+]
+
+plugins.push(
+	replace({
+		'process.env.NODE_ENV': '"production"',
+		preventAssignment: true
+	}),
+	nodeResolve()
+)
+
+const rollupConfig = {
+	input: path.resolve(__dirname, `../js/tabler.${ESM ? 'esm' : 'umd'}.js`),
+	output: {
+		banner: banner(),
+		file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`),
+		format: ESM ? 'esm' : 'umd',
+		generatedCode: 'es2015'
+	},
+	external,
+	plugins
+}
+
+if (!ESM) {
+	rollupConfig.output.name = 'tabler'
+}
+
+export default rollupConfig

+ 0 - 0
src/img/flags/ad.svg → core/img/flags/ad.svg


+ 0 - 0
src/img/flags/ae.svg → core/img/flags/ae.svg


+ 0 - 0
src/img/flags/af.svg → core/img/flags/af.svg


+ 0 - 0
src/img/flags/afrun.svg → core/img/flags/afrun.svg


+ 0 - 0
src/img/flags/ag.svg → core/img/flags/ag.svg


+ 0 - 0
src/img/flags/ai.svg → core/img/flags/ai.svg


+ 0 - 0
src/img/flags/al.svg → core/img/flags/al.svg


+ 0 - 0
src/img/flags/am.svg → core/img/flags/am.svg


+ 0 - 0
src/img/flags/ao.svg → core/img/flags/ao.svg


+ 0 - 0
src/img/flags/aq.svg → core/img/flags/aq.svg


+ 0 - 0
src/img/flags/ar.svg → core/img/flags/ar.svg


+ 0 - 0
src/img/flags/as.svg → core/img/flags/as.svg


+ 0 - 0
src/img/flags/at.svg → core/img/flags/at.svg


+ 0 - 0
src/img/flags/au.svg → core/img/flags/au.svg


+ 0 - 0
src/img/flags/aw.svg → core/img/flags/aw.svg


+ 0 - 0
src/img/flags/ax.svg → core/img/flags/ax.svg


+ 0 - 0
src/img/flags/az.svg → core/img/flags/az.svg


+ 0 - 0
src/img/flags/ba.svg → core/img/flags/ba.svg


+ 0 - 0
src/img/flags/bb.svg → core/img/flags/bb.svg


+ 0 - 0
src/img/flags/bd.svg → core/img/flags/bd.svg


+ 0 - 0
src/img/flags/be.svg → core/img/flags/be.svg


+ 0 - 0
src/img/flags/bf.svg → core/img/flags/bf.svg


+ 0 - 0
src/img/flags/bg.svg → core/img/flags/bg.svg


+ 0 - 0
src/img/flags/bh.svg → core/img/flags/bh.svg


+ 0 - 0
src/img/flags/bi.svg → core/img/flags/bi.svg


+ 0 - 0
src/img/flags/bj.svg → core/img/flags/bj.svg


+ 0 - 0
src/img/flags/bl.svg → core/img/flags/bl.svg


+ 0 - 0
src/img/flags/bm.svg → core/img/flags/bm.svg


+ 0 - 0
src/img/flags/bn.svg → core/img/flags/bn.svg


+ 0 - 0
src/img/flags/bo.svg → core/img/flags/bo.svg


+ 0 - 0
src/img/flags/bq-bo.svg → core/img/flags/bq-bo.svg


+ 0 - 0
src/img/flags/bq-sa.svg → core/img/flags/bq-sa.svg


+ 0 - 0
src/img/flags/bq-se.svg → core/img/flags/bq-se.svg


+ 0 - 0
src/img/flags/br.svg → core/img/flags/br.svg


+ 0 - 0
src/img/flags/bs.svg → core/img/flags/bs.svg


+ 0 - 0
src/img/flags/bt.svg → core/img/flags/bt.svg


+ 0 - 0
src/img/flags/bv.svg → core/img/flags/bv.svg


+ 0 - 0
src/img/flags/bw.svg → core/img/flags/bw.svg


+ 0 - 0
src/img/flags/by.svg → core/img/flags/by.svg


+ 0 - 0
src/img/flags/bz.svg → core/img/flags/bz.svg


+ 0 - 0
src/img/flags/ca.svg → core/img/flags/ca.svg


+ 0 - 0
src/img/flags/cc.svg → core/img/flags/cc.svg


+ 0 - 0
src/img/flags/cd.svg → core/img/flags/cd.svg


+ 0 - 0
src/img/flags/cf.svg → core/img/flags/cf.svg


+ 0 - 0
src/img/flags/cg.svg → core/img/flags/cg.svg


+ 0 - 0
src/img/flags/ch.svg → core/img/flags/ch.svg


+ 0 - 0
src/img/flags/ci.svg → core/img/flags/ci.svg


+ 0 - 0
src/img/flags/ck.svg → core/img/flags/ck.svg


+ 0 - 0
src/img/flags/cl.svg → core/img/flags/cl.svg


+ 0 - 0
src/img/flags/cm.svg → core/img/flags/cm.svg


+ 0 - 0
src/img/flags/cn.svg → core/img/flags/cn.svg


+ 0 - 0
src/img/flags/co.svg → core/img/flags/co.svg


+ 0 - 0
src/img/flags/cr.svg → core/img/flags/cr.svg


+ 0 - 0
src/img/flags/cu.svg → core/img/flags/cu.svg


+ 0 - 0
src/img/flags/cv.svg → core/img/flags/cv.svg


+ 0 - 0
src/img/flags/cw.svg → core/img/flags/cw.svg


+ 0 - 0
src/img/flags/cx.svg → core/img/flags/cx.svg


+ 0 - 0
src/img/flags/cy.svg → core/img/flags/cy.svg


+ 0 - 0
src/img/flags/cz.svg → core/img/flags/cz.svg


+ 0 - 0
src/img/flags/de.svg → core/img/flags/de.svg


+ 0 - 0
src/img/flags/dj.svg → core/img/flags/dj.svg


+ 0 - 0
src/img/flags/dk.svg → core/img/flags/dk.svg


+ 0 - 0
src/img/flags/dm.svg → core/img/flags/dm.svg


+ 0 - 0
src/img/flags/do.svg → core/img/flags/do.svg


+ 0 - 0
src/img/flags/dz.svg → core/img/flags/dz.svg


+ 0 - 0
src/img/flags/ec.svg → core/img/flags/ec.svg


+ 0 - 0
src/img/flags/ee.svg → core/img/flags/ee.svg


+ 0 - 0
src/img/flags/eg.svg → core/img/flags/eg.svg


+ 0 - 0
src/img/flags/eh.svg → core/img/flags/eh.svg


+ 0 - 0
src/img/flags/er.svg → core/img/flags/er.svg


+ 0 - 0
src/img/flags/es.svg → core/img/flags/es.svg


+ 0 - 0
src/img/flags/et.svg → core/img/flags/et.svg


+ 0 - 0
src/img/flags/eu.svg → core/img/flags/eu.svg


+ 0 - 0
src/img/flags/fi.svg → core/img/flags/fi.svg


+ 0 - 0
src/img/flags/fj.svg → core/img/flags/fj.svg


+ 0 - 0
src/img/flags/fk.svg → core/img/flags/fk.svg


+ 0 - 0
src/img/flags/fm.svg → core/img/flags/fm.svg


+ 0 - 0
src/img/flags/fo.svg → core/img/flags/fo.svg


+ 0 - 0
src/img/flags/fr.svg → core/img/flags/fr.svg


+ 0 - 0
src/img/flags/ga.svg → core/img/flags/ga.svg


+ 0 - 0
src/img/flags/gb-eng.svg → core/img/flags/gb-eng.svg


+ 0 - 0
src/img/flags/gb-nir.svg → core/img/flags/gb-nir.svg


+ 0 - 0
src/img/flags/gb-sct.svg → core/img/flags/gb-sct.svg


+ 0 - 0
src/img/flags/gb-wls.svg → core/img/flags/gb-wls.svg


+ 0 - 0
src/img/flags/gb.svg → core/img/flags/gb.svg


+ 0 - 0
src/img/flags/gd.svg → core/img/flags/gd.svg


+ 0 - 0
src/img/flags/ge.svg → core/img/flags/ge.svg


+ 0 - 0
src/img/flags/gf.svg → core/img/flags/gf.svg


Some files were not shown because too many files changed in this diff