@barefootjs/cli 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/core/quick-start.mdx +5 -0
- package/dist/index.js +178 -23
- package/package.json +4 -4
|
@@ -18,6 +18,11 @@ Scaffold a BarefootJS app, run it locally, and tour the generated project. About
|
|
|
18
18
|
|
|
19
19
|
Press Enter at the prompts to accept the defaults (Hono on Cloudflare Workers, UnoCSS).
|
|
20
20
|
|
|
21
|
+
The CSS prompt has two options:
|
|
22
|
+
|
|
23
|
+
- **UnoCSS** (default) — wires up UnoCSS and pulls a starter `<Button>` from the BarefootJS UI registry. The rest of this guide follows this path.
|
|
24
|
+
- **None (bring your own CSS)** — no UnoCSS, no UI components, no stylesheets. You get just the JSX→template+signals compiler output and a dependency-free starter `Counter` built from native `<button>` elements. Pick this when you want to wire up your own styling. Pass `--css none` to select it non-interactively.
|
|
25
|
+
|
|
21
26
|
## 2. Install and run
|
|
22
27
|
|
|
23
28
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __bfCreateRequire } from 'node:module';
|
|
3
|
+
const require = __bfCreateRequire(import.meta.url);
|
|
2
4
|
var __create = Object.create;
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
4
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20100,8 +20102,8 @@ function buildStaticBudget(source, filePath, componentName, options2 = {}) {
|
|
|
20100
20102
|
0
|
|
20101
20103
|
);
|
|
20102
20104
|
const fanOut = graph.signals.map((s) => {
|
|
20103
|
-
const
|
|
20104
|
-
return { signal: s.name, subscribers, hot:
|
|
20105
|
+
const { direct, total } = subscriberCounts(graph, s.name);
|
|
20106
|
+
return { signal: s.name, subscribers: total, direct, hot: direct >= threshold, loc: s.loc };
|
|
20105
20107
|
}).sort((a, b) => b.subscribers - a.subscribers);
|
|
20106
20108
|
const { depth, chain } = longestMemoChain(graph);
|
|
20107
20109
|
const hasReactiveState = graph.signals.length > 0 || graph.memos.length > 0;
|
|
@@ -20129,18 +20131,25 @@ function isEventHandlerConsumer(consumer) {
|
|
|
20129
20131
|
const i = consumer.indexOf(":");
|
|
20130
20132
|
return i > 0 && isEventHandlerEntry(consumer.slice(0, i), consumer.slice(i + 1));
|
|
20131
20133
|
}
|
|
20132
|
-
function
|
|
20134
|
+
function subscriberCounts(graph, name2) {
|
|
20133
20135
|
const path25 = traceUpdatePath(graph, name2);
|
|
20134
|
-
if (!path25) return 0;
|
|
20136
|
+
if (!path25) return { direct: 0, total: 0 };
|
|
20135
20137
|
const seen = /* @__PURE__ */ new Set();
|
|
20136
|
-
const
|
|
20138
|
+
const directSeen = /* @__PURE__ */ new Set();
|
|
20139
|
+
const walk = (entries2, depth) => {
|
|
20137
20140
|
for (const e of entries2) {
|
|
20138
|
-
if (!isEventHandlerEntry(e.kind, e.name))
|
|
20139
|
-
|
|
20141
|
+
if (!isEventHandlerEntry(e.kind, e.name)) {
|
|
20142
|
+
seen.add(`${e.kind}:${e.name}`);
|
|
20143
|
+
if (depth === 0) directSeen.add(`${e.kind}:${e.name}`);
|
|
20144
|
+
}
|
|
20145
|
+
walk(e.children, depth + 1);
|
|
20140
20146
|
}
|
|
20141
20147
|
};
|
|
20142
|
-
walk(path25.dependents);
|
|
20143
|
-
return seen.size;
|
|
20148
|
+
walk(path25.dependents, 0);
|
|
20149
|
+
return { direct: directSeen.size, total: seen.size };
|
|
20150
|
+
}
|
|
20151
|
+
function transitiveSubscriberCount(graph, name2) {
|
|
20152
|
+
return subscriberCounts(graph, name2).total;
|
|
20144
20153
|
}
|
|
20145
20154
|
function longestMemoChain(graph) {
|
|
20146
20155
|
const memoChainFrom = (entry) => {
|
|
@@ -20177,7 +20186,9 @@ function formatStaticBudget(b) {
|
|
|
20177
20186
|
if (shown.length > 0) {
|
|
20178
20187
|
lines.push(" fan-out (top):");
|
|
20179
20188
|
for (const f of shown) {
|
|
20180
|
-
|
|
20189
|
+
const indirect = f.subscribers - f.direct;
|
|
20190
|
+
const detail2 = indirect > 0 ? ` (${f.direct} direct \xB7 ${indirect} via memo)` : "";
|
|
20191
|
+
lines.push(` ${f.signal.padEnd(12)} \u2192 ${f.subscribers} subscribers${detail2}${f.hot ? " \u26A0 high" : ""}`);
|
|
20181
20192
|
}
|
|
20182
20193
|
}
|
|
20183
20194
|
if (b.crossComponentOnly) {
|
|
@@ -20191,8 +20202,8 @@ function formatStaticBudget(b) {
|
|
|
20191
20202
|
return lines.join("\n");
|
|
20192
20203
|
}
|
|
20193
20204
|
function diffStaticBudget(base, head) {
|
|
20194
|
-
const baseFan = new Map(base.fanOut.map((f) => [f.signal, f.
|
|
20195
|
-
const headFan = new Map(head.fanOut.map((f) => [f.signal, f.
|
|
20205
|
+
const baseFan = new Map(base.fanOut.map((f) => [f.signal, f.direct]));
|
|
20206
|
+
const headFan = new Map(head.fanOut.map((f) => [f.signal, f.direct]));
|
|
20196
20207
|
const signals = /* @__PURE__ */ new Set([...baseFan.keys(), ...headFan.keys()]);
|
|
20197
20208
|
const fanOut = [];
|
|
20198
20209
|
for (const sig of signals) {
|
|
@@ -20230,7 +20241,7 @@ function formatBudgetDiff(d) {
|
|
|
20230
20241
|
lines.push(` memo chain ${d.memoChainDepth > 0 ? "deepened" : "shortened"} by ${Math.abs(d.memoChainDepth)}`);
|
|
20231
20242
|
}
|
|
20232
20243
|
for (const f of d.fanOut) {
|
|
20233
|
-
lines.push(` signal \`${f.signal}\` fan-out ${f.before}\u2192${f.after}`);
|
|
20244
|
+
lines.push(` signal \`${f.signal}\` direct fan-out ${f.before}\u2192${f.after}`);
|
|
20234
20245
|
}
|
|
20235
20246
|
if (lines.length === 1) lines.push(" no structural reactivity change");
|
|
20236
20247
|
else lines.push(d.regressed ? " \u26A0 reactivity regressed" : " \u2713 no regression");
|
|
@@ -24826,10 +24837,12 @@ function buildGitignore(sections) {
|
|
|
24826
24837
|
lines.push(...SHARED_GITIGNORE_LINES);
|
|
24827
24838
|
return lines.join("\n") + "\n";
|
|
24828
24839
|
}
|
|
24829
|
-
var SHARED_COUNTER_TSX, SHARED_COUNTER_TEST_TSX, TOKENS_CSS, STYLES_CSS, UNO_CSS_PLACEHOLDER, COMPONENTS_MANIFEST_SEED, UNOCSS_DEV_DEPENDENCIES, SHARED_GITIGNORE_LINES;
|
|
24840
|
+
var CSS_LINKS_BEGIN, CSS_LINKS_END, SHARED_COUNTER_TSX, SHARED_COUNTER_TEST_TSX, SHARED_COUNTER_BARE_TSX, SHARED_COUNTER_BARE_TEST_TSX, TOKENS_CSS, STYLES_CSS, UNO_CSS_PLACEHOLDER, COMPONENTS_MANIFEST_SEED, UNOCSS_DEV_DEPENDENCIES, SHARED_GITIGNORE_LINES;
|
|
24830
24841
|
var init_shared2 = __esm({
|
|
24831
24842
|
"src/lib/adapters/shared.ts"() {
|
|
24832
24843
|
"use strict";
|
|
24844
|
+
CSS_LINKS_BEGIN = "@@BF_CSS_LINKS_BEGIN@@";
|
|
24845
|
+
CSS_LINKS_END = "@@BF_CSS_LINKS_END@@";
|
|
24833
24846
|
SHARED_COUNTER_TSX = `'use client'
|
|
24834
24847
|
|
|
24835
24848
|
import { createSignal, createMemo } from '@barefootjs/client'
|
|
@@ -24899,6 +24912,71 @@ describe('Counter', () => {
|
|
|
24899
24912
|
expect(structure).toContain('div')
|
|
24900
24913
|
})
|
|
24901
24914
|
})
|
|
24915
|
+
`;
|
|
24916
|
+
SHARED_COUNTER_BARE_TSX = `'use client'
|
|
24917
|
+
|
|
24918
|
+
import { createSignal, createMemo } from '@barefootjs/client'
|
|
24919
|
+
|
|
24920
|
+
interface CounterProps {
|
|
24921
|
+
initial?: number
|
|
24922
|
+
}
|
|
24923
|
+
|
|
24924
|
+
export function Counter(props: CounterProps) {
|
|
24925
|
+
const [count, setCount] = createSignal(props.initial ?? 0)
|
|
24926
|
+
const doubled = createMemo(() => count() * 2)
|
|
24927
|
+
|
|
24928
|
+
return (
|
|
24929
|
+
<div className="counter">
|
|
24930
|
+
<p className="counter-value">count: {count()}</p>
|
|
24931
|
+
<p className="counter-doubled">doubled: {doubled()}</p>
|
|
24932
|
+
<div className="counter-buttons">
|
|
24933
|
+
<button type="button" onClick={() => setCount(n => n + 1)}>+1</button>
|
|
24934
|
+
<button type="button" onClick={() => setCount(n => n - 1)}>-1</button>
|
|
24935
|
+
<button type="button" onClick={() => setCount(0)}>Reset</button>
|
|
24936
|
+
</div>
|
|
24937
|
+
</div>
|
|
24938
|
+
)
|
|
24939
|
+
}
|
|
24940
|
+
`;
|
|
24941
|
+
SHARED_COUNTER_BARE_TEST_TSX = `import { describe, test, expect } from '{{__TEST_RUNNER_IMPORT__}}'
|
|
24942
|
+
import { readFileSync } from 'fs'
|
|
24943
|
+
import { resolve } from 'path'
|
|
24944
|
+
import { renderToTest } from '@barefootjs/test'
|
|
24945
|
+
|
|
24946
|
+
const CounterSource = readFileSync(resolve(__dirname, 'Counter.tsx'), 'utf-8')
|
|
24947
|
+
|
|
24948
|
+
describe('Counter', () => {
|
|
24949
|
+
const result = renderToTest(CounterSource, 'Counter.tsx')
|
|
24950
|
+
|
|
24951
|
+
test('has no compiler errors', () => {
|
|
24952
|
+
expect(result.errors).toEqual([])
|
|
24953
|
+
})
|
|
24954
|
+
|
|
24955
|
+
test('componentName is Counter', () => {
|
|
24956
|
+
expect(result.componentName).toBe('Counter')
|
|
24957
|
+
})
|
|
24958
|
+
|
|
24959
|
+
test('has expected signals', () => {
|
|
24960
|
+
expect(result.signals).toContain('count')
|
|
24961
|
+
})
|
|
24962
|
+
|
|
24963
|
+
test('renders as <div>', () => {
|
|
24964
|
+
expect(result.root.tag).toBe('div')
|
|
24965
|
+
})
|
|
24966
|
+
|
|
24967
|
+
test('has event handlers', () => {
|
|
24968
|
+
const all = result.findAll({})
|
|
24969
|
+
expect(
|
|
24970
|
+
all.some(n => n.events.includes('click') || n.props['onClick'] != null),
|
|
24971
|
+
).toBe(true)
|
|
24972
|
+
})
|
|
24973
|
+
|
|
24974
|
+
test('toStructure() shows expected tree', () => {
|
|
24975
|
+
const structure = result.toStructure()
|
|
24976
|
+
expect(structure.length).toBeGreaterThan(0)
|
|
24977
|
+
expect(structure).toContain('div')
|
|
24978
|
+
})
|
|
24979
|
+
})
|
|
24902
24980
|
`;
|
|
24903
24981
|
TOKENS_CSS = `:root {
|
|
24904
24982
|
/* \u2500\u2500 Typography \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
@@ -25381,6 +25459,7 @@ func defaultLayout(ctx *bf.RenderContext) string {
|
|
|
25381
25459
|
<meta charset="utf-8" />
|
|
25382
25460
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
25383
25461
|
<title>%s</title>
|
|
25462
|
+
${CSS_LINKS_BEGIN}
|
|
25384
25463
|
<!-- Link all three sheets so the browser fetches them in parallel \u2014
|
|
25385
25464
|
chaining via styles.css @import would defer tokens/uno to a
|
|
25386
25465
|
second round-trip and flash unstyled DOM. tokens first so its
|
|
@@ -25388,6 +25467,7 @@ func defaultLayout(ctx *bf.RenderContext) string {
|
|
|
25388
25467
|
<link rel="stylesheet" href="/static/tokens.css" />
|
|
25389
25468
|
<link rel="stylesheet" href="/static/styles.css" />
|
|
25390
25469
|
<link rel="stylesheet" href="/static/uno.css" />
|
|
25470
|
+
${CSS_LINKS_END}
|
|
25391
25471
|
</head>
|
|
25392
25472
|
<body>
|
|
25393
25473
|
<main>%s</main>
|
|
@@ -25771,6 +25851,7 @@ server.listen(port, () => {
|
|
|
25771
25851
|
<script type="importmap">
|
|
25772
25852
|
{ "imports": { "@barefootjs/client/runtime": "/static/components/barefoot.js" } }
|
|
25773
25853
|
</script>
|
|
25854
|
+
${CSS_LINKS_BEGIN}
|
|
25774
25855
|
<!-- Link all three sheets so the browser fetches them in parallel \u2014
|
|
25775
25856
|
chaining via styles.css @import would defer tokens/uno to a
|
|
25776
25857
|
second round-trip and flash unstyled DOM. tokens first so its
|
|
@@ -25778,6 +25859,7 @@ server.listen(port, () => {
|
|
|
25778
25859
|
<link rel="stylesheet" href="/static/tokens.css">
|
|
25779
25860
|
<link rel="stylesheet" href="/static/styles.css">
|
|
25780
25861
|
<link rel="stylesheet" href="/static/uno.css">
|
|
25862
|
+
${CSS_LINKS_END}
|
|
25781
25863
|
</head>
|
|
25782
25864
|
<body>
|
|
25783
25865
|
<main>
|
|
@@ -25970,6 +26052,7 @@ func defaultLayout(ctx *bf.RenderContext) string {
|
|
|
25970
26052
|
<meta charset="utf-8" />
|
|
25971
26053
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
25972
26054
|
<title>%s</title>
|
|
26055
|
+
${CSS_LINKS_BEGIN}
|
|
25973
26056
|
<!-- Link all three sheets so the browser fetches them in parallel \u2014
|
|
25974
26057
|
chaining via styles.css @import would defer tokens/uno to a
|
|
25975
26058
|
second round-trip and flash unstyled DOM. tokens first so its
|
|
@@ -25977,6 +26060,7 @@ func defaultLayout(ctx *bf.RenderContext) string {
|
|
|
25977
26060
|
<link rel="stylesheet" href="/static/tokens.css" />
|
|
25978
26061
|
<link rel="stylesheet" href="/static/styles.css" />
|
|
25979
26062
|
<link rel="stylesheet" href="/static/uno.css" />
|
|
26063
|
+
${CSS_LINKS_END}
|
|
25980
26064
|
</head>
|
|
25981
26065
|
<body>
|
|
25982
26066
|
<main>%s</main>
|
|
@@ -26533,6 +26617,7 @@ export const renderer = jsxRenderer(({ children, title }) => (
|
|
|
26533
26617
|
<meta charset="UTF-8" />
|
|
26534
26618
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
26535
26619
|
<title>{title ?? 'BarefootJS app'}</title>
|
|
26620
|
+
${CSS_LINKS_BEGIN}
|
|
26536
26621
|
{/* Link all three sheets so the browser fetches them in
|
|
26537
26622
|
parallel \u2014 chaining via styles.css @import would defer
|
|
26538
26623
|
tokens/uno to a second round-trip and flash unstyled DOM.
|
|
@@ -26541,6 +26626,7 @@ export const renderer = jsxRenderer(({ children, title }) => (
|
|
|
26541
26626
|
<link rel="stylesheet" href="/tokens.css" />
|
|
26542
26627
|
<link rel="stylesheet" href="/styles.css" />
|
|
26543
26628
|
<link rel="stylesheet" href="/uno.css" />
|
|
26629
|
+
${CSS_LINKS_END}
|
|
26544
26630
|
<BfImportMap base={componentsBase} />
|
|
26545
26631
|
</head>
|
|
26546
26632
|
<body>
|
|
@@ -26826,6 +26912,7 @@ export function createRenderer({ componentsBase }: CreateRendererOptions) {
|
|
|
26826
26912
|
<meta charset="UTF-8" />
|
|
26827
26913
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
26828
26914
|
<title>{title ?? 'BarefootJS app'}</title>
|
|
26915
|
+
${CSS_LINKS_BEGIN}
|
|
26829
26916
|
{/* Link all three sheets so the browser fetches them in
|
|
26830
26917
|
parallel \u2014 chaining via styles.css @import would defer
|
|
26831
26918
|
tokens/uno to a second round-trip and flash unstyled
|
|
@@ -26834,6 +26921,7 @@ export function createRenderer({ componentsBase }: CreateRendererOptions) {
|
|
|
26834
26921
|
<link rel="stylesheet" href="/static/tokens.css" />
|
|
26835
26922
|
<link rel="stylesheet" href="/static/styles.css" />
|
|
26836
26923
|
<link rel="stylesheet" href="/static/uno.css" />
|
|
26924
|
+
${CSS_LINKS_END}
|
|
26837
26925
|
<BfImportMap base={componentsBase} />
|
|
26838
26926
|
</head>
|
|
26839
26927
|
<body>
|
|
@@ -27047,6 +27135,7 @@ __DATA__
|
|
|
27047
27135
|
<meta charset="utf-8">
|
|
27048
27136
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
27049
27137
|
<title>BarefootJS app</title>
|
|
27138
|
+
${CSS_LINKS_BEGIN}
|
|
27050
27139
|
<!-- Link all three sheets so the browser fetches them in parallel \u2014
|
|
27051
27140
|
chaining via styles.css @import would defer tokens/uno to a
|
|
27052
27141
|
second round-trip and flash unstyled DOM. tokens first so its
|
|
@@ -27054,6 +27143,7 @@ __DATA__
|
|
|
27054
27143
|
<link rel="stylesheet" href="/static/tokens.css">
|
|
27055
27144
|
<link rel="stylesheet" href="/static/styles.css">
|
|
27056
27145
|
<link rel="stylesheet" href="/static/uno.css">
|
|
27146
|
+
${CSS_LINKS_END}
|
|
27057
27147
|
</head>
|
|
27058
27148
|
<body>
|
|
27059
27149
|
<main><%== content %></main>
|
|
@@ -27440,11 +27530,13 @@ sub layout (%a) {
|
|
|
27440
27530
|
<meta charset="utf-8">
|
|
27441
27531
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
27442
27532
|
<title>BarefootJS app</title>
|
|
27533
|
+
${CSS_LINKS_BEGIN}
|
|
27443
27534
|
<!-- Link all three sheets so the browser fetches them in parallel.
|
|
27444
27535
|
tokens first so its CSS variables exist before any rule uses them. -->
|
|
27445
27536
|
<link rel="stylesheet" href="/static/tokens.css">
|
|
27446
27537
|
<link rel="stylesheet" href="/static/styles.css">
|
|
27447
27538
|
<link rel="stylesheet" href="/static/uno.css">
|
|
27539
|
+
${CSS_LINKS_END}
|
|
27448
27540
|
</head>
|
|
27449
27541
|
<body>
|
|
27450
27542
|
<main>$a{body}</main>
|
|
@@ -27684,7 +27776,8 @@ var init_templates = __esm({
|
|
|
27684
27776
|
init_nethttp();
|
|
27685
27777
|
init_xslate();
|
|
27686
27778
|
CSS_LIBRARIES = {
|
|
27687
|
-
unocss: { label: "UnoCSS" }
|
|
27779
|
+
unocss: { label: "UnoCSS", usesUnoUi: true },
|
|
27780
|
+
none: { label: "None (bring your own CSS)", usesUnoUi: false }
|
|
27688
27781
|
};
|
|
27689
27782
|
DEFAULT_CSS_LIBRARY = "unocss";
|
|
27690
27783
|
ADAPTERS = {
|
|
@@ -27845,6 +27938,48 @@ var init_spinner = __esm({
|
|
|
27845
27938
|
}
|
|
27846
27939
|
});
|
|
27847
27940
|
|
|
27941
|
+
// src/lib/css.ts
|
|
27942
|
+
function processCssHead(content2, usesUno) {
|
|
27943
|
+
if (!content2.includes(CSS_LINKS_BEGIN)) return content2;
|
|
27944
|
+
const out = [];
|
|
27945
|
+
let inRegion = false;
|
|
27946
|
+
for (const line of content2.split("\n")) {
|
|
27947
|
+
const trimmed = line.trim();
|
|
27948
|
+
if (trimmed === CSS_LINKS_BEGIN) {
|
|
27949
|
+
inRegion = true;
|
|
27950
|
+
continue;
|
|
27951
|
+
}
|
|
27952
|
+
if (trimmed === CSS_LINKS_END) {
|
|
27953
|
+
inRegion = false;
|
|
27954
|
+
continue;
|
|
27955
|
+
}
|
|
27956
|
+
if (inRegion && !usesUno) continue;
|
|
27957
|
+
out.push(line);
|
|
27958
|
+
}
|
|
27959
|
+
return out.join("\n");
|
|
27960
|
+
}
|
|
27961
|
+
function stripUnocssFromScript(cmd) {
|
|
27962
|
+
let out = cmd;
|
|
27963
|
+
out = out.split(' "unocss --watch"').join("");
|
|
27964
|
+
out = out.replace("-n build,uno,server -c blue,magenta,green", "-n build,server -c blue,green");
|
|
27965
|
+
out = out.replace("-n build,uno -c blue,magenta", "-n build -c blue");
|
|
27966
|
+
out = out.split(" && unocss && ").join(" && ");
|
|
27967
|
+
out = out.replace(/ && unocss$/, "");
|
|
27968
|
+
return out;
|
|
27969
|
+
}
|
|
27970
|
+
function stripUnoGitignore(content2) {
|
|
27971
|
+
return content2.replace(
|
|
27972
|
+
"# UnoCSS output (regenerated by `unocss --watch` / `unocss`)\npublic/uno.css\n\n",
|
|
27973
|
+
""
|
|
27974
|
+
);
|
|
27975
|
+
}
|
|
27976
|
+
var init_css = __esm({
|
|
27977
|
+
"src/lib/css.ts"() {
|
|
27978
|
+
"use strict";
|
|
27979
|
+
init_shared2();
|
|
27980
|
+
}
|
|
27981
|
+
});
|
|
27982
|
+
|
|
27848
27983
|
// src/commands/init.ts
|
|
27849
27984
|
var init_exports = {};
|
|
27850
27985
|
__export(init_exports, {
|
|
@@ -27887,7 +28022,8 @@ async function run4(args2, ctx2) {
|
|
|
27887
28022
|
const adapter = ADAPTERS[adapterId];
|
|
27888
28023
|
const cssId = await resolveCssLibrary(flags.css);
|
|
27889
28024
|
const cssLibrary = CSS_LIBRARIES[cssId];
|
|
27890
|
-
const
|
|
28025
|
+
const usesUno = cssLibrary.usesUnoUi !== false;
|
|
28026
|
+
const bundledComponents = usesUno ? adapter.bundledRegistryComponents ?? ["button"] : [];
|
|
27891
28027
|
if (bundledComponents.length > 0) {
|
|
27892
28028
|
const registryHost = new URL(DEFAULT_REGISTRY_URL2).host;
|
|
27893
28029
|
const probeSpinner = startSpinner({
|
|
@@ -27918,7 +28054,7 @@ async function run4(args2, ctx2) {
|
|
|
27918
28054
|
text: `Creating ${adapter.label.split(" ")[0]} + ${cssLibrary.label} project...`
|
|
27919
28055
|
});
|
|
27920
28056
|
try {
|
|
27921
|
-
await scaffoldApp(projectDir, adapter, flags, ctx2);
|
|
28057
|
+
await scaffoldApp(projectDir, adapter, flags, usesUno, ctx2);
|
|
27922
28058
|
} catch (err) {
|
|
27923
28059
|
buildSpinner.fail("Failed to create project files");
|
|
27924
28060
|
throw err;
|
|
@@ -27981,7 +28117,7 @@ async function probeRegistry(url2) {
|
|
|
27981
28117
|
throw new Error(`HTTP ${res.status}`);
|
|
27982
28118
|
}
|
|
27983
28119
|
}
|
|
27984
|
-
async function scaffoldApp(projectDir, adapter, flags, _ctx) {
|
|
28120
|
+
async function scaffoldApp(projectDir, adapter, flags, usesUno, _ctx) {
|
|
27985
28121
|
const paths = {
|
|
27986
28122
|
components: "components/ui",
|
|
27987
28123
|
tokens: "tokens",
|
|
@@ -27993,11 +28129,20 @@ async function scaffoldApp(projectDir, adapter, flags, _ctx) {
|
|
|
27993
28129
|
const pm = detectPackageManager(projectDir);
|
|
27994
28130
|
const runner = testRunnerFor(pm);
|
|
27995
28131
|
const pmTypesEntry = runner.typesEntry;
|
|
28132
|
+
const UNO_ONLY_FILES = /* @__PURE__ */ new Set(["uno.config.ts", "uno.css", "tokens.css", "styles.css"]);
|
|
27996
28133
|
for (const [relPath, contents] of Object.entries(adapter.files)) {
|
|
28134
|
+
if (!usesUno && UNO_ONLY_FILES.has(path10.basename(relPath))) continue;
|
|
27997
28135
|
const target2 = path10.join(projectDir, relPath);
|
|
27998
28136
|
if (existsSync8(target2)) continue;
|
|
27999
28137
|
mkdirSync3(path10.dirname(target2), { recursive: true });
|
|
28000
|
-
|
|
28138
|
+
let source = contents;
|
|
28139
|
+
if (!usesUno && relPath === "components/Counter.tsx") source = SHARED_COUNTER_BARE_TSX;
|
|
28140
|
+
if (!usesUno && relPath === "components/Counter.test.tsx") source = SHARED_COUNTER_BARE_TEST_TSX;
|
|
28141
|
+
let resolved = source.replace(/\{\{__PROJECT_NAME__\}\}/g, pkgName).replace(/\{\{__PM_TYPES_ENTRY__\}\}/g, pmTypesEntry).replace(/\{\{__TEST_RUNNER_IMPORT__\}\}/g, runner.importSource);
|
|
28142
|
+
resolved = processCssHead(resolved, usesUno);
|
|
28143
|
+
if (!usesUno && path10.basename(relPath) === ".gitignore") {
|
|
28144
|
+
resolved = stripUnoGitignore(resolved);
|
|
28145
|
+
}
|
|
28001
28146
|
writeFileSync3(target2, resolved);
|
|
28002
28147
|
created++;
|
|
28003
28148
|
}
|
|
@@ -28011,16 +28156,24 @@ async function scaffoldApp(projectDir, adapter, flags, _ctx) {
|
|
|
28011
28156
|
const pkgJsonPath = path10.join(projectDir, "package.json");
|
|
28012
28157
|
const resolvedAdapterScripts = {};
|
|
28013
28158
|
for (const [k, v] of Object.entries(adapter.scripts)) {
|
|
28014
|
-
|
|
28159
|
+
const rendered = typeof v === "function" ? v(pm) : v;
|
|
28160
|
+
resolvedAdapterScripts[k] = usesUno ? rendered : stripUnocssFromScript(rendered);
|
|
28015
28161
|
}
|
|
28016
28162
|
const pmDevDeps = runner.devDeps;
|
|
28163
|
+
const adapterDevDeps = { ...adapter.devDependencies };
|
|
28164
|
+
if (!usesUno) {
|
|
28165
|
+
for (const key of Object.keys(UNOCSS_DEV_DEPENDENCIES)) delete adapterDevDeps[key];
|
|
28166
|
+
}
|
|
28017
28167
|
const pkgJson = {
|
|
28018
28168
|
name: pkgName,
|
|
28019
28169
|
private: true,
|
|
28020
28170
|
type: "module",
|
|
28021
28171
|
scripts: {
|
|
28022
28172
|
...resolvedAdapterScripts,
|
|
28023
|
-
|
|
28173
|
+
// The cross-adapter rebuild watcher. Under `--css none` there's no
|
|
28174
|
+
// `unocss --watch` pane to run alongside `bf build --watch`, so it
|
|
28175
|
+
// collapses to a bare build watch (no `concurrently` wrapper).
|
|
28176
|
+
watch: usesUno ? 'concurrently -k -n build,uno -c blue,magenta "bf build --watch" "unocss --watch"' : "bf build --watch",
|
|
28024
28177
|
// `test` is wired to the runner that matches the user's package
|
|
28025
28178
|
// manager — `bun test` for bun, `vitest run` for npm / pnpm /
|
|
28026
28179
|
// yarn. The matching `bf gen component` / `bf gen test` output
|
|
@@ -28030,13 +28183,13 @@ async function scaffoldApp(projectDir, adapter, flags, _ctx) {
|
|
|
28030
28183
|
test: runner.scriptValue
|
|
28031
28184
|
},
|
|
28032
28185
|
dependencies: { ...adapter.dependencies },
|
|
28033
|
-
devDependencies: { ...
|
|
28186
|
+
devDependencies: { ...adapterDevDeps, ...pmDevDeps }
|
|
28034
28187
|
};
|
|
28035
28188
|
if (!existsSync8(pkgJsonPath)) {
|
|
28036
28189
|
writeFileSync3(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
|
|
28037
28190
|
created++;
|
|
28038
28191
|
}
|
|
28039
|
-
const bundledComponents = adapter.bundledRegistryComponents ?? ["button"];
|
|
28192
|
+
const bundledComponents = usesUno ? adapter.bundledRegistryComponents ?? ["button"] : [];
|
|
28040
28193
|
if (bundledComponents.length > 0) {
|
|
28041
28194
|
await addFromRegistry(
|
|
28042
28195
|
bundledComponents,
|
|
@@ -28087,6 +28240,8 @@ var init_init = __esm({
|
|
|
28087
28240
|
init_pm();
|
|
28088
28241
|
init_select();
|
|
28089
28242
|
init_spinner();
|
|
28243
|
+
init_css();
|
|
28244
|
+
init_shared2();
|
|
28090
28245
|
INIT_GATE_ENV = "BAREFOOT_INIT_VIA_CREATE";
|
|
28091
28246
|
DEFAULT_REGISTRY_URL2 = "https://ui.barefootjs.dev/r/";
|
|
28092
28247
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "CLI for agent-driven UI component discovery and scaffolding",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"esbuild": "^0.25.0",
|
|
31
31
|
"typescript": "^5.0.0",
|
|
32
|
-
"@barefootjs/client": "0.
|
|
33
|
-
"@barefootjs/shared": "0.
|
|
32
|
+
"@barefootjs/client": "0.13.0",
|
|
33
|
+
"@barefootjs/shared": "0.13.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@barefootjs/jsx": "0.
|
|
36
|
+
"@barefootjs/jsx": "0.13.0",
|
|
37
37
|
"@types/node": "^22.0.0",
|
|
38
38
|
"@happy-dom/global-registrator": "^20.0.11",
|
|
39
39
|
"happy-dom": "^20.0.11"
|