@thorprovider/storefront 0.11.0 → 0.12.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/README.md CHANGED
@@ -472,12 +472,20 @@ The shell's derived `spec/index.ts` imports the user-owned `shell/props.ts`
472
472
  surface and footer copy are configured without touching derived files. Configure
473
473
  `shell/content.ts` (`logoAccent`/`brandAccent`, `navbarClassName`/`footerClassName`,
474
474
  `brandDescription`, `linkColumns`); defaults are neutral and link only to served routes
475
- (`/`, `/categories`, `/checkout`), never dead `#` links. `newsletter` defaults to `false`
476
- and the scaffold ships no submit callback, so a content-only newsletter renders no form
477
- — never a fake form. `shippingNote` defaults to `''`: while it is empty (and there are
478
- no utility links) the navbar renders no utility strip, so no placeholder note is shown.
479
- The generated footer uses canonical `FooterSection` with `brand-columns` and
480
- native link behavior; numbered footer adapters are no longer part of the Blocks API.
475
+ (`/`, `/categories`, `/checkout`), never dead `#` links. `shippingNote` defaults to `''`:
476
+ while it is empty (and there are no utility links) the navbar renders no utility strip,
477
+ so no placeholder note is shown.
478
+
479
+ The generated footer **is** the `UniversalFooter` design block, rendered in its `commerce`
480
+ preset. Its own copy — newsletter, contact, payments, legal, region — comes from
481
+ `lib/<name>/footer-content.ts`, whose Zod schema is also the response contract of
482
+ `GET /store/footer`: a backend that owns the footer serves that shape and the shell drops
483
+ its defaults. Until then, override individual keys with `footerContent` in
484
+ `shell/content.ts`; the full contract and its wiring live in
485
+ `docs/footer-content-endpoint.md`. The scaffold ships no subscribe callback, so the newsletter form renders
486
+ disabled rather than faking a subscription, and no app-store listing or QR image is
487
+ invented (the app band hides itself while `apps.links` is empty). Navigation stays
488
+ derived from `linkColumns`, so the footer cannot drift from the rest of the chrome.
481
489
 
482
490
  A view's derived `index.tsx` imports the user-owned `content.ts`/`props.ts`/
483
491
  `data.ts`, so a customization changes real spec/loader output and survives `sync`.
@@ -0,0 +1,203 @@
1
+ // Footer content: the data contract behind the site footer, plus the neutral
2
+ // defaults a fresh storefront ships with.
3
+ //
4
+ // `UniversalFooter` (the footer block) renders `data`, and the shell supplies it.
5
+ // The shape below is the whole contract, so a backend can serve it as-is:
6
+ //
7
+ // GET /store/footer
8
+ // 200 application/json → { ...footerContentSchema }
9
+ //
10
+ // Nothing here performs a request. The generated storefront reads the defaults
11
+ // in this file at build time; replacing them with a `GET /store/footer` read is
12
+ // a one-file change in `shell/props.ts` (see `footerContentEndpoint`), and does
13
+ // not touch the block, the registry, or the shell schema.
14
+ //
15
+ // Defaults are neutral on purpose: no delivery, shipping, or promo promise, no
16
+ // invented social account, no fake app store listing. Phone, address, payment
17
+ // methods and app links are placeholders a merchant must replace.
18
+
19
+ import { z } from 'zod'
20
+ import type { UniversalFooterProps } from '@thorprovider/blocks'
21
+
22
+ export const footerContentSchema = z.object({
23
+ /** Footer navigation, grouped. Derived from `shell/content.ts` link columns by default. */
24
+ nav: z.array(
25
+ z.object({
26
+ title: z.string(),
27
+ links: z.array(z.object({ label: z.string(), href: z.string() })),
28
+ }),
29
+ ),
30
+ /** Accessible label for the navigation region. */
31
+ navLabel: z.string(),
32
+ newsletter: z.object({
33
+ title: z.string(),
34
+ description: z.string(),
35
+ fieldLabel: z.string(),
36
+ placeholder: z.string(),
37
+ buttonLabel: z.string(),
38
+ /** Feedback copy for a successful subscription. */
39
+ success: z.string(),
40
+ /** Feedback copy for a failed subscription. */
41
+ error: z.string(),
42
+ }),
43
+ contact: z.object({
44
+ title: z.string(),
45
+ email: z.string(),
46
+ phone: z.string(),
47
+ address: z.string(),
48
+ hours: z.string(),
49
+ }),
50
+ apps: z.object({
51
+ available: z.boolean(),
52
+ title: z.string(),
53
+ description: z.string(),
54
+ eyebrow: z.string(),
55
+ /** Short glyph shown beside the app invitation. */
56
+ mark: z.string(),
57
+ qr: z.object({ src: z.string(), alt: z.string(), fallback: z.string() }),
58
+ links: z.array(z.object({ label: z.string(), href: z.string(), caption: z.string() })),
59
+ }),
60
+ payments: z.object({ title: z.string(), methods: z.array(z.string()) }),
61
+ legal: z.object({
62
+ company: z.string(),
63
+ title: z.string(),
64
+ copyright: z.string(),
65
+ links: z.array(z.object({ label: z.string(), href: z.string() })),
66
+ }),
67
+ region: z.object({
68
+ label: z.string(),
69
+ languageLabel: z.string(),
70
+ countryLabel: z.string(),
71
+ currencyLabel: z.string(),
72
+ /** Human-readable summary of the active selection (e.g. `Español · Uruguay · UYU`). */
73
+ active: z.string(),
74
+ languages: z.array(z.object({ value: z.string(), label: z.string() })),
75
+ countries: z.array(z.object({ value: z.string(), label: z.string() })),
76
+ currencies: z.array(z.object({ value: z.string(), label: z.string() })),
77
+ }),
78
+ })
79
+
80
+ export type FooterContent = z.infer<typeof footerContentSchema>
81
+
82
+ /** The endpoint a backend implements to own the footer; the shape is the schema above. */
83
+ export const footerContentEndpoint = {
84
+ method: 'GET',
85
+ path: '/store/footer',
86
+ /** Every field is required; partial responses are rejected by the shell schema. */
87
+ response: 'FooterContent',
88
+ } as const
89
+
90
+ /**
91
+ * Default footer content: complete enough to render the commerce footer in a
92
+ * fresh storefront (apps band, newsletter, contact, payments, legal, region).
93
+ * Placeholder values are marked; a merchant replaces them.
94
+ */
95
+ export const footerContentDefaults: FooterContent = {
96
+ // Navigation comes from the shell's link columns; a backend response carries its own.
97
+ nav: [],
98
+ navLabel: 'Navegación del sitio',
99
+ newsletter: {
100
+ title: 'Novedades del catálogo',
101
+ description: 'Productos nuevos y reposiciones, una vez al mes.',
102
+ fieldLabel: 'Correo electrónico',
103
+ placeholder: 'tu@email.com',
104
+ buttonLabel: 'Suscribirme',
105
+ success: 'Listo. Te escribimos cuando haya novedades.',
106
+ error: 'No pudimos suscribirte. Probá de nuevo.',
107
+ },
108
+ contact: {
109
+ title: 'Contacto',
110
+ email: 'hola@example.com',
111
+ phone: '+00 0000 0000',
112
+ address: 'Dirección a definir',
113
+ hours: 'Lunes a viernes, 10:00 a 18:00',
114
+ },
115
+ apps: {
116
+ available: true,
117
+ title: 'Tu catálogo, siempre a mano.',
118
+ description: 'Seguí tus pedidos y mirá las novedades desde el teléfono.',
119
+ eyebrow: 'EN TU TELÉFONO',
120
+ mark: 'S',
121
+ // No QR and no store listing is shipped: a QR image would be a binary asset
122
+ // the scaffold does not own, and invented store URLs would dead-end.
123
+ qr: { src: '', alt: 'Código QR de la aplicación', fallback: '' },
124
+ links: [],
125
+ },
126
+ payments: {
127
+ title: 'Medios de pago',
128
+ methods: ['Tarjeta de crédito', 'Tarjeta de débito', 'Transferencia'],
129
+ },
130
+ legal: {
131
+ company: 'Nombre de la empresa',
132
+ title: 'Legal',
133
+ copyright: 'Todos los derechos reservados.',
134
+ links: [
135
+ { label: 'Términos', href: '/terms' },
136
+ { label: 'Privacidad', href: '/privacy' },
137
+ ],
138
+ },
139
+ region: {
140
+ label: 'Idioma y región',
141
+ languageLabel: 'Idioma',
142
+ countryLabel: 'País',
143
+ currencyLabel: 'Moneda',
144
+ active: 'Español',
145
+ languages: [{ value: 'es', label: 'Español' }],
146
+ countries: [{ value: 'uy', label: 'Uruguay' }],
147
+ currencies: [{ value: 'uyu', label: 'UYU' }],
148
+ },
149
+ }
150
+
151
+ /**
152
+ * Footer navigation from the user-owned shell link columns, so the footer and the
153
+ * rest of the shell never carry two competing link lists. Entries without an
154
+ * `href` are labels, not links, and are dropped.
155
+ */
156
+ export function navFromLinkColumns(
157
+ columns: { title: string; links: { label: string; href?: string }[] }[],
158
+ ): FooterContent['nav'] {
159
+ return columns
160
+ .map((column) => ({
161
+ title: column.title,
162
+ links: column.links
163
+ .filter((link): link is { label: string; href: string } => typeof link.href === 'string')
164
+ .map(({ label, href }) => ({ label, href })),
165
+ }))
166
+ .filter((column) => column.links.length > 0)
167
+ }
168
+
169
+ /** The shell props `UniversalFooter` needs, mirroring `footerPropsSchema`. */
170
+ export interface FooterShellProps {
171
+ brandName: string
172
+ brandAccent?: { text: string; className?: string }
173
+ brandDescription?: string
174
+ linkColumns: { title: string; links: { label: string; href?: string }[] }[]
175
+ className?: string
176
+ footerContent?: FooterContent
177
+ }
178
+
179
+ /**
180
+ * Map the shell seam onto the footer block. The commerce preset is fixed: this
181
+ * is the storefront shell footer, not a chooser. Link columns stay authoritative
182
+ * for navigation so the footer and the rest of the chrome cannot drift apart;
183
+ * `footerContent.nav` is the backend-owned fallback for a shell that ships none.
184
+ */
185
+ export function toUniversalFooterProps(shell: FooterShellProps): UniversalFooterProps {
186
+ const content = shell.footerContent ?? footerContentDefaults
187
+ return {
188
+ data: {
189
+ niche: 'commerce',
190
+ navLabel: content.navLabel,
191
+ brand: { name: shell.brandName, description: shell.brandDescription ?? '' },
192
+ nav: shell.linkColumns.length ? navFromLinkColumns(shell.linkColumns) : content.nav,
193
+ newsletter: content.newsletter,
194
+ contact: content.contact,
195
+ apps: content.apps,
196
+ payments: content.payments,
197
+ legal: content.legal,
198
+ region: content.region,
199
+ },
200
+ brandAccent: shell.brandAccent,
201
+ className: shell.className,
202
+ }
203
+ }
@@ -16,7 +16,7 @@ import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-comme
16
16
  import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
17
17
  import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
18
18
  import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
19
- import { FooterSection, Navbar, StorefrontNavbar } from '@thorprovider/blocks'
19
+ import { Navbar, StorefrontNavbar, UniversalFooter } from '@thorprovider/blocks'
20
20
  import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
21
21
  import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
22
22
  import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
@@ -28,6 +28,7 @@ import type { CartLineState, CartTotalsState } from './state'
28
28
  import { useStorefrontHandlers } from './handlers'
29
29
  import { cartViewAvailable, checkoutAvailable, mountedFeatureNames } from './composition'
30
30
  import { accountStoreUser } from './account-user.core'
31
+ import { toUniversalFooterProps } from './footer-content'
31
32
  import type { AccountIdentity, AccountResolution } from './account-session.core'
32
33
  import {
33
34
  bannerPropsSchema,
@@ -306,29 +307,12 @@ const baseComponents = {
306
307
  },
307
308
  Footer: ({ props }: { props: Record<string, unknown> }) => {
308
309
  const parsed = footerPropsSchema.parse(props)
309
- return (
310
- <FooterSection
311
- presentation="brand-columns"
312
- brandName={parsed.brandName}
313
- brandAccent={parsed.brandAccent}
314
- brandDescription={parsed.brandDescription}
315
- linkColumns={parsed.linkColumns}
316
- className={parsed.className}
317
- linkBehavior="native"
318
- // The scaffold ships no newsletter submit callback. The seam's
319
- // `newsletter` is content only, so the block swallows it and renders no
320
- // form. Wiring a real host callback (which would enable the form) is an
321
- // external integration, out of scope for the scaffold.
322
- newsletter={
323
- parsed.newsletter
324
- ? {
325
- placeholder: parsed.newsletter.placeholder,
326
- buttonLabel: parsed.newsletter.buttonLabel ?? 'Suscribirme',
327
- }
328
- : undefined
329
- }
330
- />
331
- )
310
+ // The storefront shell footer is the design block itself. Brand name,
311
+ // description, accent, surface classes and the content contract all arrive
312
+ // through the shell seam, so the merchant surface stays `shell/content.ts`.
313
+ // No `onSubscribe` is bound: the scaffold ships no newsletter endpoint, and
314
+ // the block disables the form rather than faking a subscription.
315
+ return <UniversalFooter {...toUniversalFooterProps(parsed)} />
332
316
  },
333
317
  }
334
318
 
@@ -6,6 +6,8 @@
6
6
 
7
7
  import { z } from 'zod'
8
8
 
9
+ import { footerContentSchema } from './footer-content'
10
+
9
11
  export const ctaSchema = z.object({
10
12
  label: z.string(),
11
13
  href: z.string().optional(),
@@ -170,9 +172,9 @@ export const footerPropsSchema = z.object({
170
172
  brandDescription: z.string().optional(),
171
173
  linkColumns: z.array(footerLinkColumnSchema),
172
174
  className: z.string().optional(),
173
- newsletter: z
174
- .object({ placeholder: z.string().optional(), buttonLabel: z.string().optional() })
175
- .optional(),
175
+ // The footer's own content contract, shared with `GET /store/footer`. Optional
176
+ // so an older scaffold that predates it keeps rendering from the defaults.
177
+ footerContent: footerContentSchema.optional(),
176
178
  })
177
179
 
178
180
  // Navigability chrome contracts, mirrored from @thorprovider/blocks so the
@@ -10,10 +10,11 @@
10
10
  // `/about`, `/terms`, `/privacy`). Brand colors and copy belong
11
11
  // in your own content, never in the package.
12
12
  //
13
- // The scaffold ships no newsletter submit callback, so the footer newsletter is
14
- // omitted by default. A content-only `newsletter` is swallowed by the block
15
- // (no form renders); wiring a real host callback to enable it is an external
16
- // integration, out of scope for the scaffold.
13
+ // The footer's own copy (newsletter, contact, payments, legal, region) lives in
14
+ // the footer content contract, not here: `GET /store/footer` is what a backend
15
+ // implements, and `../footer-content.ts` documents its shape and defaults.
16
+
17
+ import type { FooterContent } from '../footer-content'
17
18
 
18
19
  export interface ShellAccent {
19
20
  /** Trailing segment of the site-name wordmark to render with the accent. */
@@ -33,11 +34,6 @@ export interface ShellLinkColumn {
33
34
  links: ShellLink[]
34
35
  }
35
36
 
36
- export interface ShellNewsletter {
37
- placeholder?: string
38
- buttonLabel: string
39
- }
40
-
41
37
  /**
42
38
  * Optional trailing accent for the navbar wordmark, e.g. the "Cuba" in
43
39
  * "ElectroCuba". Leave `undefined` to render the wordmark in one colour. The
@@ -97,11 +93,16 @@ export const linkColumns: ShellLinkColumn[] = [
97
93
  ]
98
94
 
99
95
  /**
100
- * Footer newsletter content. The scaffold has no working submit handler, so it
101
- * is omitted by default (`false`). Setting it without a host-provided callback
102
- * renders no form — never a fake one.
96
+ * Footer copy overrides, merged over the package defaults in
97
+ * `../footer-content.ts` (newsletter, contact, apps, payments, legal, region).
98
+ * Same shape as the `GET /store/footer` response, so a backend that owns the
99
+ * footer replaces this seam instead of filling it in. Leave a key out to keep
100
+ * the default; set `undefined` for no overrides.
101
+ *
102
+ * Placeholders shipped by default (contact phone/address, company name, payment
103
+ * methods) are not customer-ready — a merchant must replace them.
103
104
  */
104
- export const newsletter: false | ShellNewsletter = false
105
+ export const footerContent: Partial<FooterContent> | undefined = undefined
105
106
 
106
107
  // Primary destinations for the mobile bottom navigation. Only routes the
107
108
  // storefront actually serves; the icons come from the shared category icon set.
@@ -8,12 +8,13 @@ import {
8
8
  brandAccent,
9
9
  brandDescription,
10
10
  footerClassName,
11
+ footerContent,
11
12
  linkColumns,
12
13
  logoAccent,
13
14
  navbarClassName,
14
- newsletter,
15
15
  shippingNote,
16
16
  } from './content'
17
+ import { footerContentDefaults } from '../footer-content'
17
18
 
18
19
  export const navbarShellProps = {
19
20
  logoAccent,
@@ -34,5 +35,9 @@ export const footerShellProps = {
34
35
  brandDescription,
35
36
  linkColumns,
36
37
  className: footerClassName,
37
- ...(newsletter ? { newsletter } : {}),
38
+ // The footer's own content contract. Neutral defaults ship with the scaffold;
39
+ // a backend that owns the footer replaces this with a `GET /store/footer`
40
+ // read (shape: `footerContentSchema` in ../footer-content.ts). Merchant
41
+ // overrides in `content.ts` win over the package defaults.
42
+ footerContent: { ...footerContentDefaults, ...footerContent },
38
43
  }
package/bin/storefront.js CHANGED
@@ -52,6 +52,10 @@ import {
52
52
  writeManifest,
53
53
  } from '../scripts/manifest.mjs'
54
54
  import { reconcile } from '../scripts/reconcile.mjs'
55
+ import {
56
+ cleanupScaffoldTemp,
57
+ scaffoldTempEnv,
58
+ } from '../scripts/scaffold-env.mjs'
55
59
  import { preflightManifest } from '../scripts/preflight.mjs'
56
60
  import { scaffoldComposition } from '../scripts/starter.mjs'
57
61
  import {
@@ -791,8 +795,13 @@ async function remainingNonSuiteSkills(opencodeDir) {
791
795
  // Run Yarn under the pinned Corepack version (`yarn@x.y.z`), so the scaffold
792
796
  // and every install use the canonical package manager deterministically rather
793
797
  // than whatever "known good release" Corepack would otherwise pick.
794
- function runYarn(yarnSpec, cmdArgs, cwd) {
795
- const res = spawnSync('corepack', [yarnSpec, ...cmdArgs], { cwd, stdio: 'inherit', shell: false })
798
+ function runYarn(yarnSpec, cmdArgs, cwd, env) {
799
+ const res = spawnSync('corepack', [yarnSpec, ...cmdArgs], {
800
+ cwd,
801
+ stdio: 'inherit',
802
+ shell: false,
803
+ env: env ? { ...process.env, ...env } : process.env,
804
+ })
796
805
  return res.status ?? 1
797
806
  }
798
807
 
@@ -1068,6 +1077,13 @@ async function create(args) {
1068
1077
  }
1069
1078
  if (!(await verifyConsistency())) return 1
1070
1079
 
1080
+ // 1b. Keep Yarn's staging on the target's device. `yarn dlx` installs into
1081
+ // `os.tmpdir()`; when that is a different filesystem than the global
1082
+ // cache, Yarn downgrades `nmMode` to `hardlinks-local` (YN0074) and copies
1083
+ // files it would otherwise hardlink. The directory is removed on exit.
1084
+ const tmpEnv = scaffoldTempEnv(target)
1085
+ if (tmpEnv.TMPDIR) process.once('exit', () => cleanupScaffoldTemp(tmpEnv))
1086
+
1071
1087
  // 2. Next.js base
1072
1088
  const hasPackageJson = existsSync(join(target, 'package.json'))
1073
1089
  if (!hasPackageJson) {
@@ -1083,7 +1099,7 @@ async function create(args) {
1083
1099
  // written in step 3, so network hardening applies to every install. The
1084
1100
  // pinned package manager is forced for the bootstrap too (Corepack), so the
1085
1101
  // whole scaffold runs under the canonical Yarn, not a floating release.
1086
- const status = runYarn(plan.packageManager, ['dlx', `create-next-app@${plan.scaffolder.createNextApp}`, '.', '--ts', '--tailwind', '--app', '--import-alias', '@/*', '--no-turbopack', '--use-yarn', '--skip-install'], target)
1102
+ const status = runYarn(plan.packageManager, ['dlx', `create-next-app@${plan.scaffolder.createNextApp}`, '.', '--ts', '--tailwind', '--app', '--import-alias', '@/*', '--no-turbopack', '--use-yarn', '--skip-install'], target, tmpEnv)
1087
1103
  if (hadOpenCode) {
1088
1104
  await cp(stash, opencodeDir, { recursive: true })
1089
1105
  await rm(stash, { recursive: true, force: true })
@@ -1111,26 +1127,45 @@ async function create(args) {
1111
1127
  )
1112
1128
  await rm(join(target, '.pnp.cjs'), { force: true })
1113
1129
 
1114
- // 3b. Pin the package manager (Corepack reads `packageManager`) and the local
1115
- // candidate. Yarn `resolutions` map each local @thorprovider/* package to
1116
- // its packed tarball while the declared dependency ranges stay honest
1117
- // semver. Written before any install so the whole tree resolves to the
1118
- // local candidate (no publish, no workspace import) under the pinned Yarn.
1130
+ // 3a. Own Yarn project root. When the target sits inside another Yarn project
1131
+ // (e.g. `projects/consumers/*` in the Thor Commerce monorepo), Yarn walks
1132
+ // up and rejects the first install — `shadcn init` aborts with "the nearest
1133
+ // package directory … doesn't seem to be part of the project". An empty
1134
+ // lockfile claims this directory as its own project; the first install
1135
+ // replaces it with a real one. Harmless for a standalone target, and an
1136
+ // existing lockfile is left untouched so resumed scaffolds keep theirs.
1137
+ const lockPath = join(target, 'yarn.lock')
1138
+ if (!existsSync(lockPath)) await writeFile(lockPath, '', 'utf8')
1139
+
1140
+ // 3b. Pin the package manager (Corepack reads `packageManager`), declare the
1141
+ // curated dependencies, and resolve the local candidate. Yarn `resolutions`
1142
+ // map each local @thorprovider/* package to its packed tarball while the
1143
+ // declared dependency ranges stay honest semver. Everything is written
1144
+ // before the first install so one install covers the curated set and the
1145
+ // set `shadcn init` adds — step 5 then only reconciles the tree.
1119
1146
  {
1120
1147
  const pkgPath = join(target, 'package.json')
1121
1148
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
1122
1149
  pkg.packageManager = plan.packageManager
1123
- if (Object.keys(plan.resolutions).length > 0) {
1124
- pkg.resolutions = { ...(pkg.resolutions ?? {}), ...plan.resolutions }
1125
- }
1150
+ pkg.dependencies = { ...(pkg.dependencies ?? {}), ...plan.dependencies }
1151
+ // `shadcn init` installs the CLI at whatever `latest` resolves to; pin it
1152
+ // through `resolutions` so its own install already lands on the candidate
1153
+ // version and step 4b's exact pin changes nothing in the tree.
1154
+ pkg.resolutions = { shadcn: plan.scaffolder.shadcn, ...plan.resolutions }
1155
+ if (Object.keys(pkg.resolutions).length === 0) delete pkg.resolutions
1126
1156
  await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
1127
1157
  }
1128
1158
 
1129
- // 4. shadcn base
1159
+ // 4. shadcn base. `shadcn init` declares the packages it needs and installs
1160
+ // them in one pass — and because the curated dependencies are already in
1161
+ // package.json, that single install covers both sets. Installing again
1162
+ // afterwards would link the same tree a second time for a handful of new
1163
+ // packages.
1130
1164
  const shadcnStatus = runYarn(
1131
1165
  plan.packageManager,
1132
1166
  ['dlx', `shadcn@${plan.scaffolder.shadcn}`, 'init', '--template', 'next', '--base', 'base', '--preset', preset, '--no-monorepo', '--no-rtl', '--yes'],
1133
1167
  target,
1168
+ tmpEnv,
1134
1169
  )
1135
1170
  if (shadcnStatus !== 0) {
1136
1171
  console.error('shadcn init failed.')
@@ -1149,13 +1184,13 @@ async function create(args) {
1149
1184
  await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
1150
1185
  }
1151
1186
 
1152
- // 5. Dependencies — every declared dep at its exact compatible version,
1153
- // including the exact candidate CLI.
1154
- const installDeps = Object.entries(plan.dependencies).map(([dep, version]) => `${dep}@${version}`)
1155
- const addStatus = runYarn(plan.packageManager, ['add', ...installDeps], target)
1156
- if (addStatus !== 0) {
1157
- console.error('yarn add failed.')
1158
- return addStatus
1187
+ // 5. Reconcile — the curated dependencies were declared in 3b and installed by
1188
+ // step 4, and 4b may have tightened the shadcn pin, so this pass normally
1189
+ // links nothing and only records the corrected lockfile entry.
1190
+ const reconcileStatus = runYarn(plan.packageManager, ['install'], target, tmpEnv)
1191
+ if (reconcileStatus !== 0) {
1192
+ console.error('yarn install failed.')
1193
+ return reconcileStatus
1159
1194
  }
1160
1195
 
1161
1196
  // 6. Template copy + placeholder substitution, then reconcile to the manifest.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thorprovider/storefront",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Deterministic storefront scaffolder and installable OpenCode skill suite for Thor Commerce (Next.js, @thorprovider/blocks, @thorprovider/adapters, Medusa)",
5
5
  "type": "module",
6
6
  "bin": "bin/storefront.js",
@@ -47,7 +47,7 @@ export const CANDIDATE_TOOLSET = Object.freeze({
47
47
  '@json-render/next': '0.21.0',
48
48
  }),
49
49
  local: Object.freeze({
50
- '@thorprovider/blocks': '4.3.2',
50
+ '@thorprovider/blocks': '4.4.0',
51
51
  '@thorprovider/adapters': '5.6.0',
52
52
  '@thorprovider/runtime': '0.8.0',
53
53
  '@thorprovider/types': '7.7.0',
@@ -58,6 +58,9 @@ const RULES = [
58
58
  'app/lib/*/account-session.core.ts',
59
59
  'app/lib/*/account-private.core.ts',
60
60
  'app/lib/*/account-user.core.ts',
61
+ // The footer content contract and its neutral defaults are package-owned;
62
+ // a merchant overrides copy through the user-owned shell content seam.
63
+ 'app/lib/*/footer-content.ts',
61
64
  'app/lib/*/account-lifecycle.client.tsx',
62
65
  'app/lib/*/account-boundary.client.tsx',
63
66
  'app/lib/*/account-mutation.client.ts',
@@ -0,0 +1,48 @@
1
+ // Child-process environment for `storefront create`.
2
+ //
3
+ // `yarn dlx` stages its temporary install under `os.tmpdir()`. When that lives
4
+ // on a different device than Yarn's global cache, Yarn downgrades `nmMode` to
5
+ // `hardlinks-local` (warning YN0074) and copies every file it would otherwise
6
+ // hardlink, which turns a cheap scaffold into a burst of disk writes. Pointing
7
+ // `TMPDIR` at a directory beside the target keeps staging and cache on one
8
+ // device, so `hardlinks-global` holds for every install the scaffold runs.
9
+
10
+ import { mkdtempSync, rmSync, statSync } from 'node:fs'
11
+ import { tmpdir } from 'node:os'
12
+ import { dirname, join } from 'node:path'
13
+
14
+ /**
15
+ * Env overrides that keep Yarn staging on the target's device.
16
+ * Returns `{}` when the default temp directory already shares the device, or
17
+ * when the target cannot be inspected.
18
+ */
19
+ export function scaffoldTempEnv(target) {
20
+ if (process.platform === 'win32') return {}
21
+ let targetDevice
22
+ try {
23
+ targetDevice = statSync(target).dev
24
+ } catch {
25
+ return {}
26
+ }
27
+ try {
28
+ if (statSync(tmpdir()).dev === targetDevice) return {}
29
+ } catch {
30
+ return {}
31
+ }
32
+ try {
33
+ return { TMPDIR: mkdtempSync(join(dirname(target), '.storefront-tmp-')) }
34
+ } catch {
35
+ // A read-only parent is not a reason to fail the scaffold.
36
+ return {}
37
+ }
38
+ }
39
+
40
+ /** Remove a directory created by `scaffoldTempEnv`, ignoring failures. */
41
+ export function cleanupScaffoldTemp(env) {
42
+ if (!env?.TMPDIR) return
43
+ try {
44
+ rmSync(env.TMPDIR, { recursive: true, force: true })
45
+ } catch {
46
+ // Best effort: a leftover empty temp directory is not a scaffold failure.
47
+ }
48
+ }