Repository navigation
Move shared scaffolding concerns into feature-aware eject #347
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bea9014
Move shared scaffold integrations into eject presets
bcomnes 03640a2
Remove padded blank line from scaffold metadata test
bcomnes 8e252e1
Use explicit CSS presets instead of a Tailwind shorthand
bcomnes d6ca734
Generate eject dependency data instead of publishing its manifest
bcomnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Eject dependencies | ||
|
|
||
| This private npm workspace holds the dependency ranges for DOMStack's optional ejected integrations: React, Preact, their types, and the Tailwind esbuild plugin. | ||
| Dependabot maintains these ranges through the root npm workspace configuration. | ||
|
|
||
| `npm run build:defaults` extracts the declared ranges into `lib/defaults/eject-deps.json`, rather than inspecting installed packages. | ||
| The generated JSON is checked in so a fresh checkout works without a build, and the test, build, and release flows regenerate it from this workspace. | ||
| Run `npm run build:defaults` after changing the ranges; do not edit the generated JSON directly. | ||
|
|
||
| `lib/cli/eject-features.js` reads the generated JSON so eject and `create-domstack-app` use the same metadata. | ||
| Only that data file ships in the DOMStack tarball; this workspace's `package.json` is not included, and the workspace is not published separately. | ||
|
|
||
| Dependencies used by the bundled defaults, including `fragtml`, `mine.css`, and `highlight.js`, remain sourced from DOMStack's root `package.json`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "@domstack/eject-dependencies", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "Dependency ranges for DOMStack's ejected integrations; not a runtime package.", | ||
| "dependencies": { | ||
| "preact": "^10.29.6", | ||
| "react": "^19.1.1", | ||
| "react-dom": "^19.1.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.1.10", | ||
| "@types/react-dom": "^19.1.7", | ||
| "esbuild-plugin-tailwindcss": "2.2.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** Shared, unstyled DOMStack ASCII header for CLI output. */ | ||
| export const domstackBanner = ` +##. | ||
| .:. ### | ||
| ####. :+ ### | ||
| :#####. .:+. .: :. :: :+. +##. :+. .+: ###.:. | ||
| :#####+ :#####+ :##+########: .+#####.#####. +####. .+#### ######: | ||
| .##: ###.###:###.+###+######## +##:###..###. :#####+ #####+ ###:###: | ||
| .##: ###.##+ :##. ### +##..### ### .#+ ### #:.##+ ###.. ###.##: | ||
| .##: ###.##+ :##. ### +##. ### +######: ### #::##+ ### #####+ | ||
| .##: ###.##+ :##. ### +##..### .###:##+ ### #####+ ### ######. | ||
| :### ###.###.:##. ### +##..### +#: ##+ ### .+##:##+ ###+. ###.##+ | ||
| .######+ ####### .### ###: ###:.######: ###+.#######:+####+.### #### | ||
| :##+. :##+. +#+ .##. :##. :##+. :##: .##++#+ :###. +#: .##:` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /** | ||
| * @typedef {'js' | 'ts'} Language | ||
| * @typedef {'none' | 'preact' | 'react'} Framework | ||
| * @typedef {'mine' | 'tailwind' | 'none'} Css | ||
| * @typedef {{ language?: Language, framework?: Framework, css?: Css, module?: boolean }} EjectFeaturesOptions | ||
| */ | ||
|
|
||
| import { readFileSync } from 'node:fs' | ||
|
|
||
| const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')) | ||
| const mineStyle = readFileSync(new URL('../defaults/default.style.css', import.meta.url), 'utf8') | ||
|
|
||
| // Generated at build time from the Dependabot-maintained eject-deps workspace. | ||
| const versions = JSON.parse(readFileSync(new URL('../defaults/eject-deps.json', import.meta.url), 'utf8')) | ||
|
|
||
| /** | ||
| * Generate source-relative integration files without writing or installing anything. | ||
| * `module` defaults to true; false selects .mjs/.mts settings for non-ESM packages. | ||
| * @param {EjectFeaturesOptions} [options] | ||
| */ | ||
| export function ejectFeatures ({ language = 'js', framework = 'none', css = 'mine', module = true } = {}) { | ||
| if (!['js', 'ts'].includes(language)) throw new Error('--language must be ts or js') | ||
| if (!['none', 'preact', 'react'].includes(framework)) throw new Error('--framework must be none, preact or react') | ||
| if (!['mine', 'tailwind', 'none'].includes(css)) throw new Error('--css must be mine, tailwind or none') | ||
|
|
||
| /** @type {Record<string, string>} */ | ||
| const files = { | ||
| 'globals/global.css': css === 'mine' | ||
| ? mineStyle | ||
| : css === 'tailwind' ? '@import "tailwindcss" source("../");\n' : '/* No global styles. */\n', | ||
| } | ||
| /** @type {Record<string, string>} */ | ||
| const dependencies = { fragtml: pkg.dependencies.fragtml } | ||
| /** @type {Record<string, string>} */ | ||
| const devDependencies = {} | ||
|
|
||
| if (css === 'mine') { | ||
| dependencies['mine.css'] = pkg.dependencies['mine.css'] | ||
| dependencies['highlight.js'] = pkg.dependencies['highlight.js'] | ||
| } | ||
| if (framework === 'preact') dependencies['preact'] = versions.preact | ||
| if (framework === 'react') { | ||
| dependencies['react'] = versions.react | ||
| dependencies['react-dom'] = versions['react-dom'] | ||
| if (language === 'ts') { | ||
| devDependencies['@types/react'] = versions['@types/react'] | ||
| devDependencies['@types/react-dom'] = versions['@types/react-dom'] | ||
| } | ||
| } | ||
| if (css === 'tailwind') devDependencies['esbuild-plugin-tailwindcss'] = versions['esbuild-plugin-tailwindcss'] | ||
|
|
||
| if (framework !== 'none' || css === 'tailwind') { | ||
| const extension = module ? language : language === 'ts' ? 'mts' : 'mjs' | ||
| const typeImport = language === 'ts' | ||
| ? "import type { BuildOptions } from '@domstack/static/types.js'\n" | ||
| : "/** @import { BuildOptions } from '@domstack/static/types.js' */\n" | ||
| const pluginImport = css === 'tailwind' ? "import tailwindPlugin from 'esbuild-plugin-tailwindcss'\n" : '' | ||
| const annotation = language === 'js' ? '/** @param {BuildOptions} settings */\n' : '' | ||
| const parameter = language === 'ts' ? 'settings: BuildOptions' : 'settings' | ||
| const returnType = language === 'ts' ? ': BuildOptions' : '' | ||
| const jsxSettings = framework === 'none' | ||
| ? '' | ||
| : ` settings.jsx = 'automatic' | ||
| settings.jsxImportSource = '${framework}' | ||
| ` | ||
| const pluginSettings = css === 'tailwind' ? ' settings.plugins = [...(settings.plugins ?? []), tailwindPlugin()]\n' : '' | ||
| files[`globals/esbuild.settings.${extension}`] = `${typeImport}${pluginImport} | ||
| ${annotation}export default function esbuildSettingsOverride (${parameter})${returnType} { | ||
| ${jsxSettings}${pluginSettings} return settings | ||
| } | ||
| ` | ||
| } | ||
|
|
||
| return { files, dependencies, devDependencies } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.