Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Remove unused scripts (#39595)

Chris Chinchilla46b4a707220a
diff --git a/apps/docs/scripts/codemod/mdx-meta.mjs b/apps/docs/scripts/codemod/mdx-meta.mjs
deleted file mode 100644
index 84f9fe15adf..00000000000
--- a/apps/docs/scripts/codemod/mdx-meta.mjs
+++ /dev/null
@@ -1,116 +0,0 @@
-// @ts-check
-
-/**
- * Copies MDX files from the `pages` directory to the `content` directory,
- * replacing frontmatter in `meta` with YAML frontmatter.
- *
- * Also deletes import and export statements.
- */
-
-let SUB_DIR = 'self-hosting'
-
-import { parse } from 'acorn'
-import { fromMarkdown } from 'mdast-util-from-markdown'
-import { mdxFromMarkdown } from 'mdast-util-mdx'
-import { mdxjs } from 'micromark-extension-mdxjs'
-import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'
-import { dirname, extname, join } from 'node:path'
-import { fileURLToPath } from 'node:url'
-
-const __dirname = dirname(fileURLToPath(import.meta.url))
-const ROOT_DIR = join(__dirname, '../..')
-let PAGES_DIR = join(ROOT_DIR, 'pages/guides')
-let CONTENT_DIR = join(ROOT_DIR, 'content/guides')
-
-if (SUB_DIR) {
- PAGES_DIR = join(PAGES_DIR, SUB_DIR)
- CONTENT_DIR = join(CONTENT_DIR, SUB_DIR)
-}
-
-function convertToYaml(properties) {
- let result = '---\n'
-
- for (const property of properties) {
- const key = property.key.name
- const value = property.value.value
- result += `${key}: "${value}"\n`
- }
-
- result += '---\n\n'
- return result
-}
-
-async function main() {
- try {
- const origDirContents = await readdir(PAGES_DIR, { recursive: true })
- const origMdxFiles = origDirContents.filter((filename) => extname(filename) === '.mdx')
-
- await Promise.all(
- origMdxFiles.map(async (filename) => {
- const content = await readFile(join(PAGES_DIR, filename), 'utf-8')
-
- const mdxTree = fromMarkdown(content, {
- extensions: [mdxjs()],
- mdastExtensions: [mdxFromMarkdown()],
- })
-
- const meta = mdxTree.children.find(
- (node) => node.type === 'mdxjsEsm' && node.value.trim().startsWith('export const meta')
- )
-
- let yamlString = ''
- if (meta) {
- // @ts-ignore
- const parsedMeta = parse(meta.value, { ecmaVersion: 2020, sourceType: 'module' })
- yamlString = convertToYaml(
- // @ts-ignore
- parsedMeta.body[0].declaration.declarations[0].init.properties
- )
- }
-
- const importStatements = mdxTree.children.filter(
- (node) => node.type === 'mdxjsEsm' && node.value.trim().match(/^import \w+ from/)
- )
-
- const exportStatements = mdxTree.children.filter(
- (node) =>
- node.type === 'mdxjsEsm' &&
- (node.value.trim().match(/^export const (?!meta)/) ||
- node.value.trim().startsWith('export default'))
- )
-
- const positions = [meta, ...importStatements, ...exportStatements]
- // @ts-ignore
- .map(({ position }) => [position.start.line, position.end.line])
- // splicing them out in reverse order means we don't have to worry about line numbers shifting
- .sort((a, b) => b[0] - a[0])
-
- let index = 0
- while (index < positions.length - 1) {
- const overlapsNext = positions[index][0] <= positions[index + 1][1]
- if (overlapsNext) {
- positions[index][0] = positions[index + 1][0]
- positions.splice(index + 1, 1)
- } else {
- index++
- }
- }
-
- const lines = content.split('\n')
- for (const position of positions) {
- lines.splice(position[0] - 1, position[1] - position[0] + 1)
- }
- const splicedLines = lines.join('\n')
- const splicedWithFrontmatter = yamlString + splicedLines
-
- const destinationPath = join(CONTENT_DIR, filename)
- await mkdir(dirname(destinationPath), { recursive: true })
- writeFile(destinationPath, splicedWithFrontmatter)
- })
- )
- } catch (err) {
- console.error(err)
- }
-}
-
-main()
diff --git a/apps/docs/scripts/orphans/detect-orphan-mdx.ts b/apps/docs/scripts/orphans/detect-orphan-mdx.ts
deleted file mode 100644
index 89554cd7aa6..00000000000
--- a/apps/docs/scripts/orphans/detect-orphan-mdx.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { readdir } from 'node:fs/promises'
-import { extname, join } from 'node:path'
-import {
- GLOBAL_MENU_ITEMS,
- ai,
- api,
- auth,
- cli,
- database,
- functions,
- gettingstarted,
- graphql,
- platform,
- realtime,
- resources,
- self_hosting,
- storage,
-} from '../../components/Navigation/NavigationMenu/NavigationMenu.constants.js'
-
-const DOCS_ROOT_DIR = join(__dirname, '..', '..')
-const DEFAULT_DOCS_CONTENT_DIR = join(DOCS_ROOT_DIR, 'content')
-
-// eslint-disable-next-line turbo/no-undeclared-env-vars
-const DOCS_CONTENT_DIR = process.env.DOCS_CONTENT_DIR || DEFAULT_DOCS_CONTENT_DIR
-
-const IGNORE_LIST = [
- /**
- * This is linked from the Edge Functions examples page though not from the
- * main nav.
- */
- 'guides/functions/examples/github-actions',
- /**
- * Auth helpers are deprecated and hidden but still available for legacy
- * users if they need it.
- */
- 'guides/auth/auth-helpers',
- 'guides/auth/auth-helpers/nextjs-pages',
- 'guides/auth/auth-helpers/nextjs',
- 'guides/auth/auth-helpers/remix',
- 'guides/auth/auth-helpers/sveltekit',
-]
-
-type RefItem = {
- href?: string
- url?: string
- items?: RefItem[]
-}
-
-const recGetUrl = (items: readonly RefItem[], acc: string[] = []) =>
- items.reduce((acc, item) => {
- const url = item.href || item.url
- if (url) acc.push(url)
- if (item.items) acc.push(...recGetUrl(item.items, acc))
- return acc
- }, acc)
-
-const main = async () => {
- try {
- const savedFiles = (await readdir(DOCS_CONTENT_DIR, { recursive: true }))
- .filter((file) => extname(file) === '.mdx')
- .map((file) => file.replace(/\.mdx$/, ''))
-
- const flattenedGlobalMenuItems = GLOBAL_MENU_ITEMS.flat() as RefItem[]
- const pagesToPublish = [
- flattenedGlobalMenuItems,
- gettingstarted.items,
- cli.items,
- auth.items,
- database.items,
- api.items,
- graphql.items,
- functions.items,
- realtime.items,
- storage.items,
- ai.items,
- platform.items,
- resources.items,
- self_hosting.items,
- ]
- .flatMap((items) => recGetUrl(items))
- // Remove initial slash
- .map((path) => path.substring(1))
-
- const extraPages = savedFiles.filter(
- (file) => !pagesToPublish.includes(file) && !IGNORE_LIST.includes(file)
- )
- console.log(extraPages)
- } catch (err) {
- console.error(err)
- process.exit(1)
- }
-}
-
-main()