Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Move default project template backend to server (#14624)

Damian Legawiecc4381f702285
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index 410ff80076..5a4dcce075 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -4,7 +4,7 @@ import * as p from '@clack/prompts'
import type { Command } from 'commander'
import { execa } from 'execa'
import pc from 'picocolors'
-import { detectProject, hasMonorepoSpreePath, isEjectedProject } from '../context.js'
+import { detectProject, findApiDir, hasMonorepoSpreePath, isEjectedProject } from '../context.js'
import { appServices, dockerCompose } from '../docker.js'
export function registerBuildCommand(program: Command): void {
@@ -50,7 +50,7 @@ async function buildDevImage(flags: { resetBundle?: boolean; yes?: boolean }): P
// Always build against the active docker-compose.yml — the same file
// `spree dev` runs. After `spree eject` that contains a `build:` section
- // pointing at ./backend; before eject, it's a prebuilt-image stack and
+ // pointing at the API directory; before eject, it's a prebuilt-image stack and
// there's nothing to rebuild.
if (!isEjectedProject(ctx.projectDir)) {
console.error(
@@ -119,12 +119,12 @@ async function buildDevImage(flags: { resetBundle?: boolean; yes?: boolean }): P
/**
* What `spree build --production` will run, computed without touching Docker
* — exported for tests. The starter Dockerfile normalizes its own build
- * context (backend/Gemfile marks the project layout; apps/dashboard marks a
+ * context (server/Gemfile marks the project layout; apps/dashboard marks a
* customized dashboard), so the plan is a plain `docker build` from the
- * project root — the ejected backend and your dashboard ship in one image
+ * project root — the ejected Rails app and your dashboard ship in one image
* with zero flags, exactly what Render/Railway run from the repo. A
- * Dockerfile predating the normalization builds from backend/ as before,
- * with a warning when a dashboard would be silently left out.
+ * Dockerfile predating the normalization builds from the API directory as
+ * before, with a warning when a dashboard would be silently left out.
*/
export function planProductionBuild(
projectDir: string,
@@ -132,12 +132,14 @@ export function planProductionBuild(
): {
args: string[]
imageTag: string
+ apiDir: string
dashboard: 'custom' | 'stock-or-none' | 'unsupported-dockerfile'
} {
- const backendDir = path.join(projectDir, 'backend')
- const dockerfile = path.join(backendDir, 'Dockerfile')
+ const apiDir = findApiDir(projectDir)
+ const apiPath = path.join(projectDir, apiDir)
+ const dockerfile = path.join(apiPath, 'Dockerfile')
if (!fs.existsSync(dockerfile)) {
- throw new Error('No backend/Dockerfile found. Is this a create-spree-app project?')
+ throw new Error(`No ${apiDir}/Dockerfile found. Is this a create-spree-app project?`)
}
const imageTag =
@@ -151,11 +153,12 @@ export function planProductionBuild(
// The layout-normalizing Dockerfile leaves a distinctive marker; without
// it, root context would break the build (the old file expects the Rails
- // app at the context root), so fall back to the old backend/ context.
+ // app at the context root), so fall back to the old API-directory context.
if (!fs.readFileSync(dockerfile, 'utf-8').includes('.spree-custom-dashboard')) {
return {
- args: ['build', backendDir, '-f', dockerfile, '-t', imageTag],
+ args: ['build', apiPath, '-f', dockerfile, '-t', imageTag],
imageTag,
+ apiDir,
dashboard: hasDashboard ? 'unsupported-dockerfile' : 'stock-or-none',
}
}
@@ -164,6 +167,7 @@ export function planProductionBuild(
return {
args: ['build', projectDir, '-f', dockerfile, '-t', imageTag],
imageTag,
+ apiDir,
dashboard: hasDashboard ? 'custom' : 'stock-or-none',
}
}
@@ -179,13 +183,18 @@ export function ensureRootDockerignore(projectDir: string): void {
fs.writeFileSync(target, ROOT_DOCKERIGNORE)
}
-export const ROOT_DOCKERIGNORE = `# Build context for backend/Dockerfile (repo root): keep it to sources.
+export const ROOT_DOCKERIGNORE = `# Build context for server/Dockerfile (repo root): keep it to sources.
**/node_modules
**/.git
.spree
apps/storefront
apps/dashboard/dist
apps/dashboard/.tanstack
+server/log
+server/tmp
+server/storage
+server/.env*
+# Legacy layout (projects scaffolded before the server/ rename)
backend/log
backend/tmp
backend/storage
@@ -210,7 +219,7 @@ async function buildProductionImage(projectDir: string, tag?: string): Promise<v
p.log.info(`Including your dashboard from ${pc.bold('apps/dashboard/')} (built in-image).`)
} else if (plan.dashboard === 'unsupported-dockerfile') {
p.log.warn(
- `${pc.bold('apps/dashboard/')} exists, but ${pc.bold('backend/Dockerfile')} predates ` +
+ `${pc.bold('apps/dashboard/')} exists, but ${pc.bold(`${plan.apiDir}/Dockerfile`)} predates ` +
`dashboard support — the image will NOT include your dashboard. Update the ` +
`Dockerfile from the spree-starter template to bake it in.`,
)
diff --git a/packages/cli/src/commands/db.ts b/packages/cli/src/commands/db.ts
index f25390dc54..69ecb1b372 100644
--- a/packages/cli/src/commands/db.ts
+++ b/packages/cli/src/commands/db.ts
@@ -75,7 +75,7 @@ export function registerDbCommand(program: Command): void {
} catch (err) {
// `compose ps` itself failed: broken/stale compose, daemon down, unknown
// service. Point home rather than dumping the raw env-file error (mirrors
- // upgrade.ts; backstop for a stale backend/ past detectProject re-rooting).
+ // upgrade.ts; backstop for a stale API directory past detectProject re-rooting).
// `return` is load-bearing: it tells TS `stackUp` is assigned past here.
return refuse([
'Could not inspect the Docker stack from this directory.',
diff --git a/packages/cli/src/commands/eject.ts b/packages/cli/src/commands/eject.ts
index d895bcfad9..cf68f9c768 100644
--- a/packages/cli/src/commands/eject.ts
+++ b/packages/cli/src/commands/eject.ts
@@ -3,11 +3,11 @@ import path from 'node:path'
import * as p from '@clack/prompts'
import type { Command } from 'commander'
import pc from 'picocolors'
-import { detectProject } from '../context.js'
+import { detectProject, findApiDir } from '../context.js'
import { dockerCompose, dockerComposeExec, primeBundleVolume } from '../docker.js'
// Switch the project from the prebuilt-image compose to the bind-mounted
-// dev compose. Source under ./backend becomes live in the container —
+// dev compose. Source under the API directory becomes live in the container —
// edits reload via Zeitwerk on next request, no rebuild needed.
//
// Image rebuilds (`spree build`) are only required for Dockerfile or
@@ -16,13 +16,14 @@ import { dockerCompose, dockerComposeExec, primeBundleVolume } from '../docker.j
export function registerEjectCommand(program: Command) {
program
.command('eject')
- .description('Switch to the dev compose: bind-mount ./backend with hot reload')
+ .description('Switch to the dev compose: bind-mount the Rails app with hot reload')
.action(async () => {
const ctx = detectProject()
- const backendDir = path.join(ctx.projectDir, 'backend')
- if (!fs.existsSync(backendDir)) {
- console.error(`\n${pc.red('Error:')} No backend/ directory found.\n`)
+ const apiDir = findApiDir(ctx.projectDir)
+ const apiPath = path.join(ctx.projectDir, apiDir)
+ if (!fs.existsSync(apiPath)) {
+ console.error(`\n${pc.red('Error:')} No ${apiDir}/ directory found.\n`)
process.exit(1)
}
@@ -38,15 +39,15 @@ export function registerEjectCommand(program: Command) {
//
// Projects scaffolded before create-spree-app 1.0.3 shipped a dev
// compose that bind-mounts the project root (`.:/rails`) instead of
- // ./backend — rewrite it so the container finds bin/rails.
+ // the API directory — rewrite it so the container finds bin/rails.
let composeContent = fs.readFileSync(devCompose, 'utf-8')
if (composeContent.includes('- .:/rails')) {
- composeContent = composeContent.replace('- .:/rails', '- ./backend:/rails')
+ composeContent = composeContent.replace('- .:/rails', `- ./${apiDir}:/rails`)
fs.writeFileSync(devCompose, composeContent)
}
fs.writeFileSync(path.join(ctx.projectDir, 'docker-compose.yml'), composeContent)
- console.log(`\n${pc.bold('Switching to dev compose (bind-mounts ./backend)...')}\n`)
+ console.log(`\n${pc.bold(`Switching to dev compose (bind-mounts ./${apiDir})...`)}\n`)
// Prime the shared bundle_cache volume with web alone so the parallel up
// below doesn't race the cold-volume copy-up (web + worker → "file exists").
await primeBundleVolume(ctx.projectDir)
@@ -60,15 +61,15 @@ export function registerEjectCommand(program: Command) {
p.note(
[
- `Backend is now bind-mounted from ${pc.bold('./backend')} — edits are live.`,
+ `The Rails API is now bind-mounted from ${pc.bold(`./${apiDir}`)} — edits are live.`,
'',
`The dev stack uses its own ${pc.bold('spree_development')} database (just`,
`created and seeded). Load demo products with ${pc.bold('spree sample-data')}.`,
'',
'You can now customize:',
- ` ${pc.dim('backend/app/')} — models, controllers, services (instant reload)`,
- ` ${pc.dim('backend/config/')} — Rails configuration (instant reload)`,
- ` ${pc.dim('backend/Gemfile')} — add gems via ${pc.bold('spree bundle add <gem>')}`,
+ ` ${pc.dim(`${apiDir}/app/`)} — models, controllers, services (instant reload)`,
+ ` ${pc.dim(`${apiDir}/config/`)} — Rails configuration (instant reload)`,
+ ` ${pc.dim(`${apiDir}/Gemfile`)} — add gems via ${pc.bold('spree bundle add <gem>')}`,
'',
`Rebuild only on Dockerfile / .ruby-version changes: ${pc.bold('spree build')}`,
].join('\n'),
diff --git a/packages/cli/src/commands/upgrade.ts b/packages/cli/src/commands/upgrade.ts
index 2c2b3f4e16..f09207abc7 100644
--- a/packages/cli/src/commands/upgrade.ts
+++ b/packages/cli/src/commands/upgrade.ts
@@ -61,7 +61,7 @@ async function assertUpgradeable(projectDir: string): Promise<void> {
} catch (err) {
// `compose ps` itself failed: broken/stale compose, daemon down, unknown
// service. Point home instead of dumping the raw env-file error. (Backstop
- // for a stale backend/ that slipped past detectProject re-rooting.)
+ // for a stale API directory that slipped past detectProject re-rooting.)
refuse([
'Could not inspect the Docker stack from this directory.',
` ${pc.dim(String((err as Error).message).split('\n')[0])}`,
@@ -157,7 +157,7 @@ async function runRakeUpgrade(
await dockerComposeExecOrRun(['bin/rake', 'spree:upgrade'], projectDir, { env })
}
-// The backend upgrade never touches frontend source — SDK bumps go through
+// The server upgrade never touches frontend source — SDK bumps go through
// the consumer's own PR/CI cycle. But we can detect the conventional
// create-spree-app storefront and tell the operator exactly what to bump.
export function sdkAdvisory(projectDir: string): string {
diff --git a/packages/cli/src/context.ts b/packages/cli/src/context.ts
index 4ee438d324..cb95b02a70 100644
--- a/packages/cli/src/context.ts
+++ b/packages/cli/src/context.ts
@@ -23,30 +23,45 @@ export function detectProject(cwd: string = process.cwd()): ProjectContext {
}
}
-// create-spree-app clones spree-starter into <root>/backend/ and copies its
+// The Rails API directory a scaffolded project keeps its app in. `server` is
+// what create-spree-app writes now; `backend` is what it wrote before the
+// Rails app became API-only, and is still accepted so existing projects keep
+// working.
+export const API_DIRS = ['server', 'backend'] as const
+
+// The API directory an existing project actually uses: whichever of API_DIRS
+// is present, preferring `server`. Falls back to `server` so error messages
+// name the current layout when neither exists.
+export function findApiDir(projectDir: string): string {
+ return API_DIRS.find((dir) => fs.existsSync(path.join(projectDir, dir))) ?? 'server'
+}
+
+// create-spree-app clones spree-starter into <root>/server/ and copies its
// compose files UP to the wrapper root, rewriting the dev bind-mount to
-// `./backend:/rails` and writing the only real `.env` at the root. The cloned
-// `backend/docker-compose.yml` is left behind as a stale leftover (mounts
+// `./server:/rails` and writing the only real `.env` at the root. The cloned
+// `server/docker-compose.yml` is left behind as a stale leftover (mounts
// `.:/rails`, expects a sibling `.env` that does not exist). Running the CLI
-// from `backend/` would target that broken file. When we can prove `cwd` is
-// the wrapper's `backend/` and the parent is the real (adjusted) root, re-root
-// there so every command runs against the runnable compose + root `.env`.
+// from `server/` would target that broken file. When we can prove `cwd` is
+// the wrapper's API directory and the parent is the real (adjusted) root,
+// re-root there so every command runs against the runnable compose + root `.env`.
function resolveProjectDir(cwd: string): string {
- if (path.basename(cwd) !== 'backend') return cwd
+ const dirName = path.basename(cwd)
+ if (!API_DIRS.includes(dirName as (typeof API_DIRS)[number])) return cwd
const parent = path.dirname(cwd)
// The parent is the real wrapper root only if its compose was adjusted by the
- // scaffold to mount THIS dir (`./backend:/rails`). The rewrite lands in the
+ // scaffold to mount THIS dir (`./server:/rails`). The rewrite lands in the
// dev overlay (the base file is copied verbatim), so scan both. A coincidental
- // nested layout — a `backend/` dir under an unrelated compose project — won't
+ // nested layout — a `server/` dir under an unrelated compose project — won't
// contain this exact marker, so re-root stays a no-op there.
+ const mountMarker = new RegExp(`\\./${dirName}:/rails(:\\w+)?(\\s|$)`, 'm')
for (const name of ['docker-compose.yml', 'docker-compose.dev.yml']) {
const file = path.join(parent, name)
if (!fs.existsSync(file)) continue
try {
- // matches "- ./backend:/rails" and "- ./backend:/rails:cached" etc.
- if (/\.\/backend:\/rails(:\w+)?(\s|$)/m.test(fs.readFileSync(file, 'utf-8'))) {
+ // matches "- ./server:/rails" and "- ./server:/rails:cached" etc.
+ if (mountMarker.test(fs.readFileSync(file, 'utf-8'))) {
return parent
}
} catch {
@@ -75,7 +90,7 @@ export function hasMonorepoSpreePath(projectDir: string): boolean {
}
// A project is "ejected" once `spree eject` swaps in the dev compose, whose
-// service carries a `build:` section pointing at ./backend — the prebuilt-image
+// service carries a `build:` section pointing at the API directory — the prebuilt-image
// compose has none. Gates steps that only apply to the bind-mounted,
// build-from-source dev stack (e.g. compiling admin assets the image would have
// baked in but the bind-mount now masks).
diff --git a/packages/cli/tests/context.test.ts b/packages/cli/tests/context.test.ts
index 7a410060c2..3665330f46 100644
--- a/packages/cli/tests/context.test.ts
+++ b/packages/cli/tests/context.test.ts
@@ -75,6 +75,23 @@ describe('detectProject', () => {
expect(ctx.port).toBe(4001) // port read from the ROOT .env, not backend/
})
+ it('re-roots to the wrapper parent when run from server/ of a create-spree-app wrapper', () => {
+ const root = makeTempDir()
+ const server = path.join(root, 'server')
+ fs.mkdirSync(server)
+ fs.writeFileSync(path.join(root, 'docker-compose.yml'), 'services:\n web:\n')
+ fs.writeFileSync(
+ path.join(root, 'docker-compose.dev.yml'),
+ 'services:\n web:\n volumes:\n - ./server:/rails\n',
+ )
+ fs.writeFileSync(path.join(root, '.env'), 'SECRET_KEY_BASE=abc\nSPREE_PORT=4002\n')
+ fs.writeFileSync(path.join(server, 'docker-compose.yml'), 'services:\n web:\n')
+
+ const ctx = detectProject(server)
+ expect(ctx.projectDir).toBe(root)
+ expect(ctx.port).toBe(4002)
+ })
+
it('does NOT re-root when the parent compose lacks the ./backend:/rails marker', () => {
const root = makeTempDir()
const backend = path.join(root, 'backend')
diff --git a/packages/cli/tests/eject.test.ts b/packages/cli/tests/eject.test.ts
index eb8306a2a7..4582a11141 100644
--- a/packages/cli/tests/eject.test.ts
+++ b/packages/cli/tests/eject.test.ts
@@ -28,6 +28,8 @@ let projectDir: string
vi.mock('../src/context', () => ({
detectProject: () => ({ mode: 'project', projectDir, port: 3000 }),
+ findApiDir: (dir: string) =>
+ ['server', 'backend'].find((name) => fs.existsSync(path.join(dir, name))) ?? 'server',
}))
vi.mock('../src/docker', () => ({
@@ -36,9 +38,9 @@ vi.mock('../src/docker', () => ({
primeBundleVolume: vi.fn().mockResolvedValue(undefined),
}))
-function makeProject(devComposeContent: string): string {
+function makeProject(devComposeContent: string, apiDir = 'server'): string {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'spree-cli-eject-test-'))
- fs.mkdirSync(path.join(dir, 'backend'))
+ fs.mkdirSync(path.join(dir, apiDir))
fs.writeFileSync(path.join(dir, 'docker-compose.yml'), 'services: {} # prebuilt-image compose\n')
fs.writeFileSync(path.join(dir, 'docker-compose.dev.yml'), devComposeContent)
return dir
@@ -69,14 +71,24 @@ describe('spree eject', () => {
const active = fs.readFileSync(path.join(projectDir, 'docker-compose.yml'), 'utf-8')
const dev = fs.readFileSync(path.join(projectDir, 'docker-compose.dev.yml'), 'utf-8')
- expect(active).toContain('- ./backend:/rails')
+ expect(active).toContain('- ./server:/rails')
expect(active).not.toContain('- .:/rails')
- expect(dev).toContain('- ./backend:/rails')
+ expect(dev).toContain('- ./server:/rails')
expect(dev).not.toContain('- .:/rails')
// Named volumes are left untouched
expect(active).toContain('- bundle_cache:/usr/local/bundle')
})
+ it('repairs the bind-mount against a legacy backend/ layout', async () => {
+ projectDir = makeProject(COMPOSE_DEV_STALE, 'backend')
+
+ await runEject()
+
+ const active = fs.readFileSync(path.join(projectDir, 'docker-compose.yml'), 'utf-8')
+ expect(active).toContain('- ./backend:/rails')
+ expect(active).not.toContain('- .:/rails')
+ })
+
it('copies an already-correct dev compose verbatim', async () => {
projectDir = makeProject(COMPOSE_DEV_FIXED)
diff --git a/packages/create-spree-app/src/constants.ts b/packages/create-spree-app/src/constants.ts
index 6a1930507e..90e93ab47b 100644
--- a/packages/create-spree-app/src/constants.ts
+++ b/packages/create-spree-app/src/constants.ts
@@ -10,4 +10,4 @@ export const STOREFRONT_REPO = 'https://github.com/spree/storefront.git'
* storefront's package.json, so this only steers corepack at the wrapper root.
*/
export const PNPM_VERSION = '10.33.4'
-export const BACKEND_REPO = 'https://github.com/spree/spree-starter.git'
+export const SERVER_REPO = 'https://github.com/spree/spree-starter.git'
diff --git a/packages/create-spree-app/src/index.ts b/packages/create-spree-app/src/index.ts
index 7baa9f34e8..d809fcbe8e 100644
--- a/packages/create-spree-app/src/index.ts
+++ b/packages/create-spree-app/src/index.ts
@@ -19,7 +19,7 @@ const program = new Command()
)
.option('--no-sample-data', 'skip loading sample data')
.option('--no-start', 'do not start Docker services')
- .option('--port <number>', 'port for the Spree backend', String(DEFAULT_SPREE_PORT))
+ .option('--port <number>', 'port for the Spree server', String(DEFAULT_SPREE_PORT))
.option('--use-npm', 'use npm as package manager')
.option('--use-yarn', 'use yarn as package manager')
.option('--use-pnpm', 'use pnpm as package manager')
diff --git a/packages/create-spree-app/src/scaffold.ts b/packages/create-spree-app/src/scaffold.ts
index e8a86bad26..60f8c961f3 100644
--- a/packages/create-spree-app/src/scaffold.ts
+++ b/packages/create-spree-app/src/scaffold.ts
@@ -3,9 +3,9 @@ import path from 'node:path'
import * as p from '@clack/prompts'
import { execa } from 'execa'
import pc from 'picocolors'
-import { downloadBackend } from './backend.js'
import { DASHBOARD_PORT, STOREFRONT_PORT, STOREFRONT_REPO } from './constants.js'
import { scaffoldDashboard } from './dashboard.js'
+import { downloadServer } from './server.js'
import {
downloadStorefront,
installRootDeps,
@@ -54,36 +54,36 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
fs.mkdirSync(projectDir, { recursive: true })
- // Phase 1: Download backend (always included)
- s.start('Downloading backend template...')
- await downloadBackend(projectDir)
- s.stop('Backend template downloaded.')
+ // Phase 1: Download server (always included)
+ s.start('Downloading server template...')
+ await downloadServer(projectDir)
+ s.stop('Server template downloaded.')
// Phase 2: Generate project files
s.start('Creating project structure...')
- // Copy compose files from backend template and adjust paths for project root
- const backendDir = path.join(projectDir, 'backend')
- const compose = fs.readFileSync(path.join(backendDir, 'docker-compose.yml'), 'utf-8')
- const composeDev = fs.readFileSync(path.join(backendDir, 'docker-compose.dev.yml'), 'utf-8')
+ // Copy compose files from server template and adjust paths for project root
+ const serverDir = path.join(projectDir, 'server')
+ const compose = fs.readFileSync(path.join(serverDir, 'docker-compose.yml'), 'utf-8')
+ const composeDev = fs.readFileSync(path.join(serverDir, 'docker-compose.dev.yml'), 'utf-8')
fs.writeFileSync(path.join(projectDir, 'docker-compose.yml'), compose)
- // Adjust build context and source bind-mount from current dir to ./backend
+ // Adjust build context and source bind-mount from current dir to ./server
// for the wrapper project (in the starter repo the compose file lives in
- // the Rails app root; here the app lives under backend/)
+ // the Rails app root; here the app lives under server/)
fs.writeFileSync(
path.join(projectDir, 'docker-compose.dev.yml'),
composeDev
- .replace('context: .', 'context: ./backend')
- .replace('- .:/rails', '- ./backend:/rails'),
+ .replace('context: .', 'context: ./server')
+ .replace('- .:/rails', '- ./server:/rails'),
)
// The compose files now live (adjusted) at the wrapper root referencing
- // ./backend + the root .env. The originals cloned into backend/ are stale
+ // ./server + the root .env. The originals cloned into server/ are stale
// leftovers (mount .:/rails, expect a sibling .env) — remove them so the CLI
- // never accidentally targets them when run from backend/.
- fs.rmSync(path.join(backendDir, 'docker-compose.yml'), { force: true })
- fs.rmSync(path.join(backendDir, 'docker-compose.dev.yml'), { force: true })
+ // never accidentally targets them when run from server/.
+ fs.rmSync(path.join(serverDir, 'docker-compose.yml'), { force: true })
+ fs.rmSync(path.join(serverDir, 'docker-compose.dev.yml'), { force: true })
fs.writeFileSync(
path.join(projectDir, '.env'),
@@ -107,7 +107,7 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
// Phases 3/3b are optional apps — their failures warn and continue. They
// must never abort the scaffold before Phase 4: `spree init` is what
// guarantees a fresh Spree image (skipping it leaves a stale local `latest`
- // to boot) and a seeded, credentialed backend.
+ // to boot) and a seeded, credentialed server.
// Phase 3: Storefront (optional)
let storefrontReady = storefront
@@ -275,7 +275,7 @@ function printSuccessWithoutDocker(
lines.push(
`${pc.bold('Customize the Spree API')}`,
` ${run} spree eject`,
- ` ${pc.dim('# Then edit backend/ — the Rails API app (Gemfile, app/, config/)')}`,
+ ` ${pc.dim('# Then edit server/ — the Rails API app (Gemfile, app/, config/)')}`,
'',
`${pc.bold('Agent skills (optional)')}`,
` ${dlxCommand(pm)} skills add spree/agent-skills`,
diff --git a/packages/create-spree-app/src/backend.ts b/packages/create-spree-app/src/server.ts
similarity index 56%
rename from packages/create-spree-app/src/backend.ts
rename to packages/create-spree-app/src/server.ts
index 455a268289..10aa99592e 100644
--- a/packages/create-spree-app/src/backend.ts
+++ b/packages/create-spree-app/src/server.ts
@@ -1,99 +1,99 @@
import fs from 'node:fs'
import path from 'node:path'
import { execa } from 'execa'
-import { BACKEND_REPO } from './constants.js'
+import { SERVER_REPO } from './constants.js'
-// Starter paths (relative to backend/) that don't belong in a generated
+// Starter paths (relative to server/) that don't belong in a generated
// project: the wrapper ships its own root README, and release.yml publishes the
// official Spree image. Dropped before the CI workflow is relocated.
-const SKIP_BACKEND_PATHS = ['README.md', '.github/workflows/release.yml']
+const SKIP_SERVER_PATHS = ['README.md', '.github/workflows/release.yml']
/**
- * Clone the spree-starter backend into `<projectDir>/backend` for the wrapper
+ * Clone the spree-starter server into `<projectDir>/server` for the wrapper
* project's nested layout. Besides fetching the repo, this drops the clone's
- * git metadata and delegates to {@link prepareBackendTemplate}, which relocates
+ * git metadata and delegates to {@link prepareServerTemplate}, which relocates
* the CI workflow to the project root and removes starter-only files — callers
- * get a ready-to-use `backend/`, not a verbatim checkout.
+ * get a ready-to-use `server/`, not a verbatim checkout.
*
* @param projectDir absolute path to the wrapper project root
*/
-export async function downloadBackend(projectDir: string): Promise<void> {
- const backendDir = path.join(projectDir, 'backend')
- await execa('git', ['clone', '--depth', '1', BACKEND_REPO, backendDir], { stdio: 'ignore' })
- fs.rmSync(path.join(backendDir, '.git'), { recursive: true, force: true })
+export async function downloadServer(projectDir: string): Promise<void> {
+ const serverDir = path.join(projectDir, 'server')
+ await execa('git', ['clone', '--depth', '1', SERVER_REPO, serverDir], { stdio: 'ignore' })
+ fs.rmSync(path.join(serverDir, '.git'), { recursive: true, force: true })
- prepareBackendTemplate(projectDir)
+ prepareServerTemplate(projectDir)
}
/**
- * Tidy the freshly-cloned starter for the nested `backend/` layout: drop files
+ * Tidy the freshly-cloned starter for the nested `server/` layout: drop files
* the wrapper project supplies itself, relocate the CI workflow to the repo
- * root (where GitHub Actions runs it) adapted to run against backend/, and
+ * root (where GitHub Actions runs it) adapted to run against server/, and
* relocate the Render Blueprint likewise (adapted so each service builds from
- * backend/).
+ * server/).
*/
-export function prepareBackendTemplate(projectDir: string): void {
- const backendDir = path.join(projectDir, 'backend')
+export function prepareServerTemplate(projectDir: string): void {
+ const serverDir = path.join(projectDir, 'server')
- for (const relPath of SKIP_BACKEND_PATHS) {
- fs.rmSync(path.join(backendDir, relPath), { recursive: true, force: true })
+ for (const relPath of SKIP_SERVER_PATHS) {
+ fs.rmSync(path.join(serverDir, relPath), { recursive: true, force: true })
}
- const srcWorkflows = path.join(backendDir, '.github', 'workflows')
+ const srcWorkflows = path.join(serverDir, '.github', 'workflows')
if (fs.existsSync(srcWorkflows)) {
const destWorkflows = path.join(projectDir, '.github', 'workflows')
fs.mkdirSync(destWorkflows, { recursive: true })
for (const file of fs.readdirSync(srcWorkflows)) {
const content = fs.readFileSync(path.join(srcWorkflows, file), 'utf-8')
- fs.writeFileSync(path.join(destWorkflows, file), adaptWorkflowForNestedBackend(content))
+ fs.writeFileSync(path.join(destWorkflows, file), adaptWorkflowForNestedServer(content))
}
// Drop the starter's whole .github — its only non-workflow file is a
// dependabot.yml scoped to the standalone starter repo, which the wrapper
- // replaces with its own root .github/dependabot.yml (covering /, /backend,
+ // replaces with its own root .github/dependabot.yml (covering /, /server,
// and the storefront). Keeping it would leave a stale, duplicate config.
- fs.rmSync(path.join(backendDir, '.github'), { recursive: true, force: true })
+ fs.rmSync(path.join(serverDir, '.github'), { recursive: true, force: true })
}
// Render reads a single Blueprint from the repository root. The starter ships
// The starter authors render.yaml for exactly this project layout (Docker
- // runtime, backend/Dockerfile built with the repo root as context, so the
- // ejected backend and apps/dashboard ship in one image) — Render just needs
+ // runtime, server/Dockerfile built with the repo root as context, so the
+ // ejected server and apps/dashboard ship in one image) — Render just needs
// it at the repo root where Blueprints are read.
- const srcRenderYaml = path.join(backendDir, 'render.yaml')
+ const srcRenderYaml = path.join(serverDir, 'render.yaml')
if (fs.existsSync(srcRenderYaml)) {
fs.renameSync(srcRenderYaml, path.join(projectDir, 'render.yaml'))
}
}
/**
- * Rewrite a Ruby/Rails CI workflow so its steps run against the `backend/`
+ * Rewrite a Ruby/Rails CI workflow so its steps run against the `server/`
* subdirectory instead of the repo root. The starter's workflow is authored for
* a repo where the Rails app *is* the root; once relocated to the wrapper
- * project root it must point at backend/ or `ruby/setup-ruby` fails to find
+ * project root it must point at server/ or `ruby/setup-ruby` fails to find
* `.ruby-version`/`Gemfile` and the `bin/rails`/`bundle` steps run in the wrong
* place. Non-Ruby workflows are returned untouched.
*/
-export function adaptWorkflowForNestedBackend(content: string): string {
+export function adaptWorkflowForNestedServer(content: string): string {
if (!content.includes('ruby/setup-ruby')) return content
let result = content
- // Run every `run:` step from backend/ via a job-level default. Anchored on the
+ // Run every `run:` step from server/ via a job-level default. Anchored on the
// first `runs-on:` so the block is inserted at the job's indentation.
result = result.replace(
/^([ \t]*)runs-on:.*$/m,
(line, indent) =>
- `${line}\n\n${indent}defaults:\n${indent} run:\n${indent} working-directory: backend`,
+ `${line}\n\n${indent}defaults:\n${indent} run:\n${indent} working-directory: server`,
)
// `ruby/setup-ruby` is an action, not a `run:` step, so job defaults don't
- // reach it — point it at backend/ explicitly so bundler-cache and the version
+ // reach it — point it at server/ explicitly so bundler-cache and the version
// file resolve there.
result = result.replace(
/^([ \t]*)- uses: ruby\/setup-ruby@[^\n]*\n([ \t]*)with:[ \t]*\n/m,
- (match, _stepIndent, withIndent) => `${match}${withIndent} working-directory: backend\n`,
+ (match, _stepIndent, withIndent) => `${match}${withIndent} working-directory: server\n`,
)
return result
diff --git a/packages/create-spree-app/src/storefront.ts b/packages/create-spree-app/src/storefront.ts
index 6e2c2960cd..54adb4b379 100644
--- a/packages/create-spree-app/src/storefront.ts
+++ b/packages/create-spree-app/src/storefront.ts
@@ -14,13 +14,13 @@ export async function downloadStorefront(projectDir: string): Promise<void> {
prepareStorefrontTemplate(projectDir)
}
-/** Local image tag the generated E2E workflow builds `backend/` into. */
+/** Local image tag the generated E2E workflow builds `server/` into. */
const PROJECT_SPREE_IMAGE = 'project-spree:e2e'
/**
* Tidy the freshly-cloned storefront for the nested `apps/storefront/` layout:
* relocate its CI workflow to the project root (adapted to run from
- * apps/storefront, and to build the project's own `backend/` image for the E2E
+ * apps/storefront, and to build the project's own `server/` image for the E2E
* suite instead of stock Spree), and drop the storefront's now-empty `.github`.
*
* The clone is otherwise left as-is: its `pnpm-lock.yaml` and `packageManager`
@@ -40,7 +40,7 @@ export function prepareStorefrontTemplate(projectDir: string): void {
const destWorkflows = path.join(projectDir, '.github', 'workflows')
fs.mkdirSync(destWorkflows, { recursive: true })
const content = fs.readFileSync(ci, 'utf-8')
- // Renamed so it doesn't collide with the backend's relocated `ci.yml`.
+ // Renamed so it doesn't collide with the server's relocated `ci.yml`.
fs.writeFileSync(
path.join(destWorkflows, 'storefront-ci.yml'),
adaptStorefrontWorkflow(content),
@@ -56,20 +56,20 @@ export function prepareStorefrontTemplate(projectDir: string): void {
/**
* Rewrite the storefront CI workflow for the wrapper project's nested layout:
*
- * - rename it (`CI` → `Storefront CI`) so it doesn't shadow the backend's check;
+ * - rename it (`CI` → `Storefront CI`) so it doesn't shadow the server's check;
* - run every job from `apps/storefront/` via a per-job default;
* - point `pnpm/action-setup` and setup-node's dependency cache at
* `apps/storefront/` — both resolve from the repo root by default, where the
* storefront's package.json and lockfile don't exist in this layout;
- * - in the E2E job, build the project's own `backend/Dockerfile` into a local
+ * - in the E2E job, build the project's own `server/Dockerfile` into a local
* image and boot the E2E stack against it (`SPREE_IMAGE`), so the storefront
- * is tested against the customized backend the project deploys — not stock
+ * is tested against the customized server the project deploys — not stock
* Spree.
*/
export function adaptStorefrontWorkflow(content: string): string {
let result = content
- // Disambiguate the workflow name from the backend's "CI".
+ // Disambiguate the workflow name from the server's "CI".
result = result.replace(/^name:\s*CI\s*$/m, 'name: Storefront CI')
// Run every job's `run:` steps from apps/storefront. Anchored on each
@@ -101,20 +101,20 @@ export function adaptStorefrontWorkflow(content: string): string {
}`,
)
- // The E2E "Boot Spree backend" step must run against the project's own
- // backend image. Insert a build step just before it (building the repo-root
- // `backend/` — checkout clones the whole project, so it's a sibling of
+ // The E2E "Boot Spree server" step must run against the project's own
+ // server image. Insert a build step just before it (building the repo-root
+ // `server/` — checkout clones the whole project, so it's a sibling of
// apps/storefront), and set SPREE_IMAGE on the boot step's env.
result = result.replace(
- /^([ \t]*)- name: Boot Spree backend[^\n]*\n([ \t]*)run: (.*)$/m,
+ /^([ \t]*)- name: Boot Spree server[^\n]*\n([ \t]*)run: (.*)$/m,
(_match, stepIndent, runIndent, runCmd) => {
const build =
- `${stepIndent}- name: Build project backend image\n` +
+ `${stepIndent}- name: Build project server image\n` +
// working-directory default targets apps/storefront, so reach the
- // sibling backend/ via the workspace root.
- `${runIndent}run: docker build -t ${PROJECT_SPREE_IMAGE} "$GITHUB_WORKSPACE/backend"\n`
+ // sibling server/ via the workspace root.
+ `${runIndent}run: docker build -t ${PROJECT_SPREE_IMAGE} "$GITHUB_WORKSPACE/server"\n`
const boot =
- `${stepIndent}- name: Boot Spree backend (project backend image)\n` +
+ `${stepIndent}- name: Boot Spree server (project server image)\n` +
`${runIndent}env:\n` +
`${runIndent} SPREE_IMAGE: ${PROJECT_SPREE_IMAGE}\n` +
`${runIndent}run: ${runCmd}`
diff --git a/packages/create-spree-app/src/templates/claude-md.ts b/packages/create-spree-app/src/templates/claude-md.ts
index 8c1e1abef2..fe4161bde7 100644
--- a/packages/create-spree-app/src/templates/claude-md.ts
+++ b/packages/create-spree-app/src/templates/claude-md.ts
@@ -39,7 +39,7 @@ export function rootClaudeMdContent(
'',
'| Directory | Description |',
'|-----------|-------------|',
- '| `backend/` | Rails API application (Spree Commerce) |',
+ '| `server/` | Rails API application (Spree Commerce) |',
]
if (hasStorefront) {
@@ -54,7 +54,7 @@ export function rootClaudeMdContent(
'',
'## Agent Instructions',
'',
- '- **Backend work** (Ruby/Rails, Spree models, API, database): See `backend/CLAUDE.md`',
+ '- **Server work** (Ruby/Rails, Spree models, API, database): See `server/CLAUDE.md`',
)
if (hasStorefront) {
@@ -118,9 +118,9 @@ export function rootClaudeMdContent(
`${pm} run dev # Start the Spree API (Docker)`,
`${pm} run stop # Stop services`,
`${pm} run console # Rails console`,
- `${pm} run logs # Backend logs`,
+ `${pm} run logs # Server logs`,
`${run} spree api get products # Query the Admin API (read-only key preconfigured)`,
- `${run} spree eject # Build the API locally from backend/`,
+ `${run} spree eject # Build the API locally from server/`,
'```',
'',
)
diff --git a/packages/create-spree-app/src/templates/dependabot.ts b/packages/create-spree-app/src/templates/dependabot.ts
index 542fd392f5..835bb9bbbd 100644
--- a/packages/create-spree-app/src/templates/dependabot.ts
+++ b/packages/create-spree-app/src/templates/dependabot.ts
@@ -31,9 +31,9 @@ function ecosystemBlock({ comment, ecosystem, directory, group }: Ecosystem): st
/**
* Dependabot config for a generated project. Covers each package ecosystem in
- * the scaffold: the npm wrapper at the root, the Rails backend gems, GitHub
+ * the scaffold: the npm wrapper at the root, the Rails server gems, GitHub
* Actions, and — when included — the Next.js storefront. Dockerfile base
- * images are intentionally left out: the backend runs a prebuilt image until
+ * images are intentionally left out: the server runs a prebuilt image until
* `spree eject`, and the base tags are pinned via ARG defaults.
*
* Security updates additionally require the "Dependabot security updates"
@@ -49,10 +49,10 @@ export function dependabotContent(hasStorefront: boolean, hasDashboard = false):
group: 'root',
},
{
- comment: 'Rails backend gems',
+ comment: 'Rails server gems',
ecosystem: 'bundler',
- directory: '/backend',
- group: 'backend',
+ directory: '/server',
+ group: 'server',
},
{
comment: 'CI workflows',
diff --git a/packages/create-spree-app/src/templates/env.ts b/packages/create-spree-app/src/templates/env.ts
index 610de9d0ba..f01659eae7 100644
--- a/packages/create-spree-app/src/templates/env.ts
+++ b/packages/create-spree-app/src/templates/env.ts
@@ -1,5 +1,5 @@
/**
- * The project root `.env`: Rails secret, backend port, image tag, and the
+ * The project root `.env`: Rails secret, server port, image tag, and the
* persisted sample-data choice (`SPREE_SAMPLE_DATA`) that first-run setup
* reads back when it runs deferred (through `spree dev`).
*/
diff --git a/packages/create-spree-app/src/templates/gitignore.ts b/packages/create-spree-app/src/templates/gitignore.ts
index 47bbf61e8c..5452ccbc73 100644
--- a/packages/create-spree-app/src/templates/gitignore.ts
+++ b/packages/create-spree-app/src/templates/gitignore.ts
@@ -9,21 +9,21 @@ export function gitignoreContent(): string {
}
/**
- * Build context for backend/Dockerfile (repo root): the image build ships
- * the ejected backend plus apps/dashboard, so keep the context to sources.
+ * Build context for server/Dockerfile (repo root): the image build ships
+ * the ejected server plus apps/dashboard, so keep the context to sources.
* Mirrors @spree/cli's ensureRootDockerignore for pre-existing projects.
*/
export function dockerignoreContent(): string {
- return `# Build context for backend/Dockerfile (repo root): keep it to sources.
+ return `# Build context for server/Dockerfile (repo root): keep it to sources.
**/node_modules
**/.git
.spree
apps/storefront
apps/dashboard/dist
apps/dashboard/.tanstack
-backend/log
-backend/tmp
-backend/storage
-backend/.env*
+server/log
+server/tmp
+server/storage
+server/.env*
`
}
diff --git a/packages/create-spree-app/src/templates/readme.ts b/packages/create-spree-app/src/templates/readme.ts
index af9c36b0db..d418e74f37 100644
--- a/packages/create-spree-app/src/templates/readme.ts
+++ b/packages/create-spree-app/src/templates/readme.ts
@@ -92,16 +92,16 @@ To learn how to add pages, tweak tables, or build plugins, see the
content += `
## Customizing the Spree API
-The \`backend/\` directory is the Spree API — a full Rails application serving the Store and Admin APIs (plus background jobs and transactional emails) that your storefront and dashboard talk to. By default, the project runs it from a prebuilt Docker image. To switch to building from your local copy:
+The \`server/\` directory is the Spree API — a full Rails application serving the Store and Admin APIs (plus background jobs and transactional emails) that your storefront and dashboard talk to. By default, the project runs it from a prebuilt Docker image. To switch to building from your local copy:
\`\`\`bash
${run} spree eject
\`\`\`
-This rebuilds the Docker image from \`backend/\` and restarts services. You can then:
+This rebuilds the Docker image from \`server/\` and restarts services. You can then:
-- **Customize the API** by editing the files in \`backend/\`
-- **Add gems** to \`backend/Gemfile\`
+- **Customize the API** by editing the files in \`server/\`
+- **Add gems** to \`server/Gemfile\`
- **Add new resources** with \`spree generate model <name> <attributes>\`
## Spree CLI
@@ -115,7 +115,7 @@ This project uses [\`@spree/cli\`](https://spreecommerce.org/docs/developer/cli/
| \`spree dev\` | Run the app in the foreground — streams logs, Ctrl+C stops it. First run completes setup automatically |
| \`spree stop\` | Stop the API services |
| \`spree update\` | Pull latest Spree image and restart (runs migrations automatically) |
-| \`spree eject\` | Switch from prebuilt image to building from \`backend/\` |
+| \`spree eject\` | Switch from prebuilt image to building from \`server/\` |
| \`spree build --production\` | Build the production image — includes \`apps/dashboard\` when present |
| \`spree logs\` | View web server logs |
| \`spree logs worker\` | View background jobs logs |
diff --git a/packages/create-spree-app/tests/scaffold.test.ts b/packages/create-spree-app/tests/scaffold.test.ts
index 77119763ce..2910a99105 100644
--- a/packages/create-spree-app/tests/scaffold.test.ts
+++ b/packages/create-spree-app/tests/scaffold.test.ts
@@ -75,13 +75,13 @@ vi.mock('../src/dashboard', () => ({
scaffoldDashboard: vi.fn(),
}))
-vi.mock('../src/backend', () => ({
- downloadBackend: vi.fn(async (projectDir: string) => {
- // Simulate what downloadBackend does: create backend/ with compose files
- const backendDir = path.join(projectDir, 'backend')
- fs.mkdirSync(backendDir, { recursive: true })
- fs.writeFileSync(path.join(backendDir, 'docker-compose.yml'), FAKE_COMPOSE)
- fs.writeFileSync(path.join(backendDir, 'docker-compose.dev.yml'), FAKE_COMPOSE_DEV)
+vi.mock('../src/server', () => ({
+ downloadServer: vi.fn(async (projectDir: string) => {
+ // Simulate what downloadServer does: create server/ with compose files
+ const serverDir = path.join(projectDir, 'server')
+ fs.mkdirSync(serverDir, { recursive: true })
+ fs.writeFileSync(path.join(serverDir, 'docker-compose.yml'), FAKE_COMPOSE)
+ fs.writeFileSync(path.join(serverDir, 'docker-compose.dev.yml'), FAKE_COMPOSE_DEV)
}),
}))
@@ -153,7 +153,7 @@ describe('scaffold (no-start)', () => {
expect(writeStorefrontEnv).toHaveBeenLastCalledWith(expect.any(String), 3000, false)
})
- it('copies docker-compose.yml from backend template', async () => {
+ it('copies docker-compose.yml from server template', async () => {
const projectDir = getTempProjectDir()
await scaffold({
@@ -172,7 +172,7 @@ describe('scaffold (no-start)', () => {
expect(compose).toBe(FAKE_COMPOSE)
})
- it('adjusts docker-compose.dev.yml build context to ./backend', async () => {
+ it('adjusts docker-compose.dev.yml build context to ./server', async () => {
const projectDir = getTempProjectDir()
await scaffold({
@@ -186,11 +186,11 @@ describe('scaffold (no-start)', () => {
})
const compose = fs.readFileSync(path.join(projectDir, 'docker-compose.dev.yml'), 'utf-8')
- expect(compose).toContain('context: ./backend')
+ expect(compose).toContain('context: ./server')
expect(compose).not.toContain('ghcr.io/spree/spree')
})
- it('adjusts docker-compose.dev.yml source bind-mount to ./backend', async () => {
+ it('adjusts docker-compose.dev.yml source bind-mount to ./server', async () => {
const projectDir = getTempProjectDir()
await scaffold({
@@ -204,7 +204,7 @@ describe('scaffold (no-start)', () => {
})
const compose = fs.readFileSync(path.join(projectDir, 'docker-compose.dev.yml'), 'utf-8')
- expect(compose).toContain('- ./backend:/rails')
+ expect(compose).toContain('- ./server:/rails')
expect(compose).not.toContain('- .:/rails')
// Named volumes are left untouched
expect(compose).toContain('- bundle_cache:/usr/local/bundle')
diff --git a/packages/create-spree-app/tests/backend.test.ts b/packages/create-spree-app/tests/server.test.ts
similarity index 62%
rename from packages/create-spree-app/tests/backend.test.ts
rename to packages/create-spree-app/tests/server.test.ts
index e8bff4c141..0c42c2c12f 100644
--- a/packages/create-spree-app/tests/backend.test.ts
+++ b/packages/create-spree-app/tests/server.test.ts
@@ -2,11 +2,11 @@ import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
-import { adaptWorkflowForNestedBackend, prepareBackendTemplate } from '../src/backend'
+import { adaptWorkflowForNestedServer, prepareServerTemplate } from '../src/server'
-// Mirrors spree-starter's .github/workflows/backend-ci.yml (the workflow that
+// Mirrors spree-starter's .github/workflows/server-ci.yml (the workflow that
// create-spree-app relocates to the generated project root).
-const BACKEND_CI = `name: CI
+const SERVER_CI = `name: CI
on:
push:
@@ -73,57 +73,57 @@ const RENDER_YAML = `services:
plan: free
`
-describe('adaptWorkflowForNestedBackend', () => {
- it('points ruby/setup-ruby at the backend/ subdirectory', () => {
- const result = adaptWorkflowForNestedBackend(BACKEND_CI)
+describe('adaptWorkflowForNestedServer', () => {
+ it('points ruby/setup-ruby at the server/ subdirectory', () => {
+ const result = adaptWorkflowForNestedServer(SERVER_CI)
expect(result).toContain(
' - uses: ruby/setup-ruby@v1\n' +
' with:\n' +
- ' working-directory: backend\n' +
+ ' working-directory: server\n' +
' bundler-cache: true',
)
})
- it('runs job steps from backend/ via a job-level default', () => {
- const result = adaptWorkflowForNestedBackend(BACKEND_CI)
+ it('runs job steps from server/ via a job-level default', () => {
+ const result = adaptWorkflowForNestedServer(SERVER_CI)
expect(result).toContain(
' runs-on: ubuntu-latest\n' +
'\n' +
' defaults:\n' +
' run:\n' +
- ' working-directory: backend',
+ ' working-directory: server',
)
})
it('inserts the defaults block exactly once', () => {
- const result = adaptWorkflowForNestedBackend(BACKEND_CI)
+ const result = adaptWorkflowForNestedServer(SERVER_CI)
expect(result.match(/defaults:/g)).toHaveLength(1)
})
it('leaves the run-step commands unchanged', () => {
- const result = adaptWorkflowForNestedBackend(BACKEND_CI)
+ const result = adaptWorkflowForNestedServer(SERVER_CI)
expect(result).toContain('run: bin/rails db:prepare')
expect(result).toContain('run: bundle exec rspec')
})
it('leaves non-Ruby workflows untouched', () => {
- expect(adaptWorkflowForNestedBackend(RELEASE)).toBe(RELEASE)
+ expect(adaptWorkflowForNestedServer(RELEASE)).toBe(RELEASE)
})
})
-describe('prepareBackendTemplate', () => {
+describe('prepareServerTemplate', () => {
const tempDirs: string[] = []
- function seedClonedBackend(): string {
- const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'create-spree-app-backend-'))
+ function seedClonedServer(): string {
+ const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'create-spree-app-server-'))
tempDirs.push(projectDir)
- const workflows = path.join(projectDir, 'backend', '.github', 'workflows')
+ const workflows = path.join(projectDir, 'server', '.github', 'workflows')
fs.mkdirSync(workflows, { recursive: true })
- fs.writeFileSync(path.join(workflows, 'backend-ci.yml'), BACKEND_CI)
+ fs.writeFileSync(path.join(workflows, 'server-ci.yml'), SERVER_CI)
fs.writeFileSync(path.join(workflows, 'release.yml'), RELEASE)
- fs.writeFileSync(path.join(projectDir, 'backend', 'README.md'), '# Spree starter')
- fs.writeFileSync(path.join(projectDir, 'backend', 'render.yaml'), RENDER_YAML)
+ fs.writeFileSync(path.join(projectDir, 'server', 'README.md'), '# Spree starter')
+ fs.writeFileSync(path.join(projectDir, 'server', 'render.yaml'), RENDER_YAML)
return projectDir
}
@@ -133,39 +133,39 @@ describe('prepareBackendTemplate', () => {
tempDirs.length = 0
})
- it('relocates the CI workflow to the project root, adapted for backend/', () => {
- const projectDir = seedClonedBackend()
- prepareBackendTemplate(projectDir)
+ it('relocates the CI workflow to the project root, adapted for server/', () => {
+ const projectDir = seedClonedServer()
+ prepareServerTemplate(projectDir)
- const moved = path.join(projectDir, '.github', 'workflows', 'backend-ci.yml')
+ const moved = path.join(projectDir, '.github', 'workflows', 'server-ci.yml')
expect(fs.existsSync(moved)).toBe(true)
- expect(fs.readFileSync(moved, 'utf-8')).toContain('working-directory: backend')
+ expect(fs.readFileSync(moved, 'utf-8')).toContain('working-directory: server')
})
it('drops the release workflow instead of copying it', () => {
- const projectDir = seedClonedBackend()
- prepareBackendTemplate(projectDir)
+ const projectDir = seedClonedServer()
+ prepareServerTemplate(projectDir)
expect(fs.existsSync(path.join(projectDir, '.github', 'workflows', 'release.yml'))).toBe(false)
- expect(fs.existsSync(path.join(projectDir, 'backend', '.github'))).toBe(false)
+ expect(fs.existsSync(path.join(projectDir, 'server', '.github'))).toBe(false)
})
it("drops the starter's README", () => {
- const projectDir = seedClonedBackend()
- prepareBackendTemplate(projectDir)
+ const projectDir = seedClonedServer()
+ prepareServerTemplate(projectDir)
- expect(fs.existsSync(path.join(projectDir, 'backend', 'README.md'))).toBe(false)
+ expect(fs.existsSync(path.join(projectDir, 'server', 'README.md'))).toBe(false)
})
it('relocates render.yaml to the project root verbatim', () => {
- const projectDir = seedClonedBackend()
- prepareBackendTemplate(projectDir)
+ const projectDir = seedClonedServer()
+ prepareServerTemplate(projectDir)
const moved = path.join(projectDir, 'render.yaml')
expect(fs.existsSync(moved)).toBe(true)
// Authored by the starter for exactly this layout — no rewriting.
expect(fs.readFileSync(moved, 'utf-8')).toBe(RENDER_YAML)
- // The original in backend/ is removed so Render never reads a stale copy.
- expect(fs.existsSync(path.join(projectDir, 'backend', 'render.yaml'))).toBe(false)
+ // The original in server/ is removed so Render never reads a stale copy.
+ expect(fs.existsSync(path.join(projectDir, 'server', 'render.yaml'))).toBe(false)
})
})
diff --git a/packages/create-spree-app/tests/storefront.test.ts b/packages/create-spree-app/tests/storefront.test.ts
index 53c8f3b34f..3de09dce8c 100644
--- a/packages/create-spree-app/tests/storefront.test.ts
+++ b/packages/create-spree-app/tests/storefront.test.ts
@@ -39,14 +39,14 @@ jobs:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- - name: Boot Spree backend (Postgres + Redis + latest Spree)
- run: docker compose -f e2e-backend/docker-compose.yml up -d --wait
+ - name: Boot Spree server (Postgres + Redis + latest Spree)
+ run: docker compose -f e2e-server/docker-compose.yml up -d --wait
- name: Run Playwright tests
run: pnpm run test:e2e
`
describe('adaptStorefrontWorkflow', () => {
- it('renames the workflow so it does not shadow the backend CI', () => {
+ it('renames the workflow so it does not shadow the server CI', () => {
const result = adaptStorefrontWorkflow(STOREFRONT_CI)
expect(result).toContain('name: Storefront CI')
expect(result).not.toMatch(/^name:\s*CI\s*$/m)
@@ -65,25 +65,25 @@ describe('adaptStorefrontWorkflow', () => {
)
})
- it('builds the project backend image before booting the E2E stack', () => {
+ it('builds the project server image before booting the E2E stack', () => {
const result = adaptStorefrontWorkflow(STOREFRONT_CI)
expect(result).toContain(
- '- name: Build project backend image\n' +
- ' run: docker build -t project-spree:e2e "$GITHUB_WORKSPACE/backend"',
+ '- name: Build project server image\n' +
+ ' run: docker build -t project-spree:e2e "$GITHUB_WORKSPACE/server"',
)
// Build step comes before the boot step.
- expect(result.indexOf('Build project backend image')).toBeLessThan(
- result.indexOf('Boot Spree backend'),
+ expect(result.indexOf('Build project server image')).toBeLessThan(
+ result.indexOf('Boot Spree server'),
)
})
it('boots the E2E stack against the project image via SPREE_IMAGE', () => {
const result = adaptStorefrontWorkflow(STOREFRONT_CI)
expect(result).toContain(
- '- name: Boot Spree backend (project backend image)\n' +
+ '- name: Boot Spree server (project server image)\n' +
' env:\n' +
' SPREE_IMAGE: project-spree:e2e\n' +
- ' run: docker compose -f e2e-backend/docker-compose.yml up -d --wait',
+ ' run: docker compose -f e2e-server/docker-compose.yml up -d --wait',
)
})
diff --git a/packages/create-spree-app/tests/templates.test.ts b/packages/create-spree-app/tests/templates.test.ts
index 1e5242abd6..271c1c6328 100644
--- a/packages/create-spree-app/tests/templates.test.ts
+++ b/packages/create-spree-app/tests/templates.test.ts
@@ -143,7 +143,7 @@ describe('readmeContent', () => {
it('includes eject instructions', () => {
const content = readmeContent('my-store', true, 3000)
expect(content).toContain('spree eject')
- expect(content).toContain('backend/')
+ expect(content).toContain('server/')
})
it('uses spree cli commands', () => {
@@ -234,11 +234,11 @@ describe('gitignoreContent', () => {
})
describe('dependabotContent', () => {
- it('covers the root wrapper, backend gems, and CI', () => {
+ it('covers the root wrapper, server gems, and CI', () => {
const content = dependabotContent(false)
expect(content).toContain('version: 2')
expect(content).toContain('package-ecosystem: npm\n directory: "/"')
- expect(content).toContain('package-ecosystem: bundler\n directory: "/backend"')
+ expect(content).toContain('package-ecosystem: bundler\n directory: "/server"')
expect(content).toContain('package-ecosystem: github-actions')
})
@@ -277,7 +277,7 @@ describe('dependabotContent', () => {
expect(content.match(/applies-to: version-updates/g)).toHaveLength(4)
// Group names are unique per ecosystem.
expect(content).toContain('root-security:')
- expect(content).toContain('backend-version:')
+ expect(content).toContain('server-version:')
expect(content).toContain('storefront-security:')
})
})