summaryrefslogtreecommitdiff
path: root/node_modules/tailwindcss/scripts
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:54:57 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:57:48 +0100
commitb1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch)
tree49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/tailwindcss/scripts
Docs
Diffstat (limited to 'node_modules/tailwindcss/scripts')
-rw-r--r--node_modules/tailwindcss/scripts/create-plugin-list.js10
-rw-r--r--node_modules/tailwindcss/scripts/generate-types.js105
-rw-r--r--node_modules/tailwindcss/scripts/release-channel.js18
-rw-r--r--node_modules/tailwindcss/scripts/release-notes.js21
-rw-r--r--node_modules/tailwindcss/scripts/swap-engines.js40
-rw-r--r--node_modules/tailwindcss/scripts/type-utils.js27
6 files changed, 221 insertions, 0 deletions
diff --git a/node_modules/tailwindcss/scripts/create-plugin-list.js b/node_modules/tailwindcss/scripts/create-plugin-list.js
new file mode 100644
index 0000000..f38cf50
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/create-plugin-list.js
@@ -0,0 +1,10 @@
+import { corePlugins } from '../src/corePlugins'
+import fs from 'fs'
+import path from 'path'
+
+let corePluginList = Object.keys(corePlugins)
+
+fs.writeFileSync(
+ path.join(process.cwd(), 'src', 'corePluginList.js'),
+ `export default ${JSON.stringify(corePluginList)}`
+)
diff --git a/node_modules/tailwindcss/scripts/generate-types.js b/node_modules/tailwindcss/scripts/generate-types.js
new file mode 100644
index 0000000..d3e0d30
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/generate-types.js
@@ -0,0 +1,105 @@
+import prettier from 'prettier'
+import { corePlugins } from '../src/corePlugins'
+import colors from '../src/public/colors'
+import defaultTheme from '../src/public/default-theme'
+import fs from 'fs'
+import path from 'path'
+import * as types from './type-utils'
+
+fs.writeFileSync(
+ path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
+ `export type CorePluginList = ${Object.keys(corePlugins)
+ .map((p) => `'${p}'`)
+ .join(' | ')}`
+)
+
+let colorsWithoutDeprecatedColors = Object.fromEntries(
+ Object.entries(Object.getOwnPropertyDescriptors(colors))
+ .filter(([_, { value }]) => {
+ return typeof value !== 'undefined'
+ })
+ .map(([name, definition]) => [name, definition.value])
+)
+
+let deprecatedColors = Object.entries(Object.getOwnPropertyDescriptors(colors))
+ .filter(([_, { value }]) => {
+ return typeof value === 'undefined'
+ })
+ .map(([name, definition]) => {
+ let warn = console.warn
+ let messages = []
+ console.warn = (...args) => messages.push(args.pop())
+ definition.get()
+ console.warn = warn
+ let message = messages.join(' ').trim()
+ let newColor = message.match(/renamed to `(.*)`/)[1]
+ return `/** @deprecated ${message} */${name}: DefaultColors['${newColor}'],`
+ })
+ .join('\n')
+
+fs.writeFileSync(
+ path.join(process.cwd(), 'types', 'generated', 'colors.d.ts'),
+ prettier.format(
+ `export interface DefaultColors { ${JSON.stringify(colorsWithoutDeprecatedColors).slice(
+ 1,
+ -1
+ )}\n${deprecatedColors}\n}`,
+ {
+ semi: false,
+ singleQuote: true,
+ printWidth: 100,
+ parser: 'typescript',
+ }
+ )
+)
+
+const defaultThemeTypes = Object.entries(defaultTheme)
+ .map(([name, value]) => {
+ // Special cases for slightly more accurate types
+ if (name === 'keyframes') {
+ return [name, `Record<${types.forKeys(value)}, Record<string, CSSDeclarationList>>`]
+ }
+
+ if (name === 'fontSize') {
+ return [name, `Record<${types.forKeys(value)}, [string, { lineHeight: string }]>`]
+ }
+
+ // General cases
+ if (typeof value === 'string') {
+ return [name, `string`]
+ }
+
+ if (typeof value === 'function') {
+ return [name, null]
+ }
+
+ if (typeof value === 'object') {
+ if (Object.keys(value).length === 0) {
+ return [name, null]
+ }
+
+ return [name, types.forValue(value)]
+ }
+
+ return [name, `unknown`]
+ })
+ .filter(([, type]) => type !== null)
+ .map(([name, type]) => `${name}: ${type}`)
+ .join('\n')
+
+fs.writeFileSync(
+ path.join(process.cwd(), 'types', 'generated', 'default-theme.d.ts'),
+ prettier.format(
+ `
+ import { Config } from '../../types'
+ type CSSDeclarationList = Record<string, string>
+ export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} }
+ `,
+ {
+ semi: false,
+ singleQuote: true,
+ printWidth: 100,
+ parser: 'typescript',
+ }
+ )
+)
diff --git a/node_modules/tailwindcss/scripts/release-channel.js b/node_modules/tailwindcss/scripts/release-channel.js
new file mode 100644
index 0000000..0c827f3
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/release-channel.js
@@ -0,0 +1,18 @@
+// Given a version, figure out what the release channel is so that we can publish to the correct
+// channel on npm.
+//
+// E.g.:
+//
+// 1.2.3 -> latest (default)
+// 0.0.0-insiders.ffaa88 -> insiders
+// 4.1.0-alpha.4 -> alpha
+
+let version =
+ process.argv[2] || process.env.npm_package_version || require('../package.json').version
+
+let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
+if (match) {
+ console.log(match[1])
+} else {
+ console.log('latest')
+}
diff --git a/node_modules/tailwindcss/scripts/release-notes.js b/node_modules/tailwindcss/scripts/release-notes.js
new file mode 100644
index 0000000..bd29e95
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/release-notes.js
@@ -0,0 +1,21 @@
+// Given a version, figure out what the release notes are so that we can use this to pre-fill the
+// relase notes on a GitHub release for the current version.
+
+let path = require('path')
+let fs = require('fs')
+
+let version =
+ process.argv[2] || process.env.npm_package_version || require('../package.json').version
+
+let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8')
+let match = new RegExp(
+ `## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`,
+ 'g'
+).exec(changelog)
+
+if (match) {
+ let [, , notes] = match
+ console.log(notes.trim())
+} else {
+ console.log(`Placeholder release notes for version: v${version}`)
+}
diff --git a/node_modules/tailwindcss/scripts/swap-engines.js b/node_modules/tailwindcss/scripts/swap-engines.js
new file mode 100644
index 0000000..ef8308a
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/swap-engines.js
@@ -0,0 +1,40 @@
+let fs = require('fs')
+let path = require('path')
+
+let engines = {
+ stable: {
+ files: [
+ path.resolve(__dirname, '..', 'package.stable.json'),
+ path.resolve(__dirname, '..', 'package-lock.stable.json'),
+ ],
+ },
+ oxide: {
+ files: [
+ path.resolve(__dirname, '..', 'package.oxide.json'),
+ path.resolve(__dirname, '..', 'package-lock.oxide.json'),
+ ],
+ },
+}
+
+// Find out what the current engine is that we are using:
+let [otherEngine, info] = Object.entries(engines).find(([, info]) =>
+ info.files.every((file) => fs.existsSync(file))
+)
+let currentEngine = otherEngine === 'oxide' ? 'stable' : 'oxide'
+
+console.log(`Current engine: \`${currentEngine}\`, swapping to \`${otherEngine}\``)
+
+// Swap the engines
+for (let file of info.files) {
+ fs.renameSync(
+ file.replace(`.${otherEngine}`, ''),
+ file.replace(`.${otherEngine}`, `.${currentEngine}`)
+ )
+}
+for (let file of engines[otherEngine].files) {
+ fs.renameSync(file, file.replace(`.${otherEngine}`, ''))
+}
+
+console.log(
+ 'Engines have been swapped. Make sure to run `npm install` to update your dependencies.'
+)
diff --git a/node_modules/tailwindcss/scripts/type-utils.js b/node_modules/tailwindcss/scripts/type-utils.js
new file mode 100644
index 0000000..d9d0e61
--- /dev/null
+++ b/node_modules/tailwindcss/scripts/type-utils.js
@@ -0,0 +1,27 @@
+export function union(types) {
+ return [...new Set(types)].join(' | ')
+}
+
+export function unionValues(values) {
+ return union(values.map(forValue))
+}
+
+export function forKeys(value) {
+ return union(Object.keys(value).map((key) => `'${key}'`))
+}
+
+export function forValue(value) {
+ if (Array.isArray(value)) {
+ return `(${unionValues(value)})[]`
+ }
+
+ if (typeof value === 'object') {
+ return `Record<${forKeys(value)}, ${unionValues(Object.values(value))}>`
+ }
+
+ if (typeof value === 'string') {
+ return `string`
+ }
+
+ return `any`
+}