create-obsession 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +160 -2
- package/bin/README.md +6 -0
- package/bin/obsession.exe +0 -0
- package/bin/obsession.out +0 -0
- package/frontend/README.md +41 -0
- package/frontend/project-type.json +8 -0
- package/frontend/template/.agent/task-scope.example.json +7 -0
- package/frontend/template/.editorconfig +11 -0
- package/frontend/template/.env +2 -0
- package/frontend/template/.env.example +2 -0
- package/frontend/template/.github/dependabot.yml +11 -0
- package/frontend/template/.github/workflows/quality.yml +28 -0
- package/frontend/template/.gitignore.tpl +28 -0
- package/frontend/template/.vscode/extensions.json +3 -0
- package/frontend/template/.vscode/settings.json +13 -0
- package/frontend/template/.vscode/tasks.json +39 -0
- package/frontend/template/AGENTS.md +56 -0
- package/frontend/template/CLAUDE.md +18 -0
- package/frontend/template/README.md.tpl +57 -0
- package/frontend/template/docs/CHAPTER_8_9_10_ENFORCEMENT.md +82 -0
- package/frontend/template/docs/FEATURE_BLUEPRINT.md +164 -0
- package/frontend/template/docs/FRONTEND_ARCHITECTURE.md +132 -0
- package/frontend/template/docs/SECURITY_BASELINE.md +32 -0
- package/frontend/template/docs/STATE_OWNERSHIP.md +33 -0
- package/frontend/template/docs/TASK_PROTOCOL.md +50 -0
- package/frontend/template/docs/TASK_SCOPE.md +35 -0
- package/frontend/template/docs/TECHNOLOGY_AND_CONFIG.md +96 -0
- package/frontend/template/docs/TESTING_AND_GATES.md +109 -0
- package/frontend/template/docs/TESTING_STRATEGY.md +34 -0
- package/frontend/template/docs/UI_STATES.md +26 -0
- package/frontend/template/docs/reference/front-end-structure-course.html +1606 -0
- package/frontend/template/docs/reference/frontend-project-setup-manual.docx +0 -0
- package/frontend/template/e2e/smoke.spec.ts +12 -0
- package/frontend/template/index.html.tpl +13 -0
- package/frontend/template/package.json.tpl +45 -0
- package/frontend/template/playwright.config.ts +18 -0
- package/frontend/template/scripts/check-architecture.mjs +291 -0
- package/frontend/template/scripts/check-architecture.test.mjs +93 -0
- package/frontend/template/scripts/task-scope.mjs +70 -0
- package/frontend/template/scripts/task-scope.test.mjs +46 -0
- package/frontend/template/src/app/NotFoundPage.tsx +5 -0
- package/frontend/template/src/app/RootLayout.tsx +15 -0
- package/frontend/template/src/app/RouteErrorBoundary.tsx +12 -0
- package/frontend/template/src/app/main.tsx +11 -0
- package/frontend/template/src/app/providers.tsx +12 -0
- package/frontend/template/src/app/router.tsx +14 -0
- package/frontend/template/src/app/store.ts +12 -0
- package/frontend/template/src/features/counter/index.ts +2 -0
- package/frontend/template/src/features/counter/model/counterSlice.test.ts +12 -0
- package/frontend/template/src/features/counter/model/counterSlice.ts +16 -0
- package/frontend/template/src/features/counter/model/selectors.ts +4 -0
- package/frontend/template/src/features/counter/ui/CounterWidget.tsx +16 -0
- package/frontend/template/src/features/home/index.ts +1 -0
- package/frontend/template/src/features/home/routes.tsx +8 -0
- package/frontend/template/src/features/home/ui/HomePage.test.tsx +11 -0
- package/frontend/template/src/features/home/ui/HomePage.tsx +13 -0
- package/frontend/template/src/shared/api/baseApi.ts +9 -0
- package/frontend/template/src/shared/api/index.ts +1 -0
- package/frontend/template/src/shared/config/env.ts +3 -0
- package/frontend/template/src/shared/config/index.ts +1 -0
- package/frontend/template/src/shared/ui/Button.tsx +6 -0
- package/frontend/template/src/shared/ui/StatusPanel.test.tsx +25 -0
- package/frontend/template/src/shared/ui/StatusPanel.tsx +36 -0
- package/frontend/template/src/shared/ui/index.ts +4 -0
- package/frontend/template/src/shared/ui/styles.css +27 -0
- package/frontend/template/src/vite-env.d.ts +1 -0
- package/frontend/template/tests/setup.ts +1 -0
- package/frontend/template/tsconfig.json +21 -0
- package/frontend/template/vite.config.ts +73 -0
- package/npm/cli.js +53 -0
- package/package.json +30 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Provider } from 'react-redux'
|
|
2
|
+
import { RouterProvider } from 'react-router'
|
|
3
|
+
import { router } from './router'
|
|
4
|
+
import { store } from './store'
|
|
5
|
+
|
|
6
|
+
export function Providers() {
|
|
7
|
+
return (
|
|
8
|
+
<Provider store={store}>
|
|
9
|
+
<RouterProvider router={router} />
|
|
10
|
+
</Provider>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createBrowserRouter } from 'react-router'
|
|
2
|
+
import { homeRoutes } from '@/features/home'
|
|
3
|
+
import { RootLayout } from './RootLayout'
|
|
4
|
+
import { NotFoundPage } from './NotFoundPage'
|
|
5
|
+
import { RouteErrorBoundary } from './RouteErrorBoundary'
|
|
6
|
+
|
|
7
|
+
export const router = createBrowserRouter([
|
|
8
|
+
{
|
|
9
|
+
path: '/',
|
|
10
|
+
element: <RootLayout />,
|
|
11
|
+
errorElement: <RouteErrorBoundary />,
|
|
12
|
+
children: [...homeRoutes, { path: '*', element: <NotFoundPage /> }],
|
|
13
|
+
},
|
|
14
|
+
])
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { configureStore } from '@reduxjs/toolkit'
|
|
2
|
+
import { counterReducer } from '@/features/counter'
|
|
3
|
+
import { baseApi } from '@/shared/api'
|
|
4
|
+
|
|
5
|
+
export const store = configureStore({
|
|
6
|
+
reducer: {
|
|
7
|
+
counter: counterReducer,
|
|
8
|
+
[baseApi.reducerPath]: baseApi.reducer,
|
|
9
|
+
},
|
|
10
|
+
middleware: (getDefaultMiddleware) =>
|
|
11
|
+
getDefaultMiddleware().concat(baseApi.middleware),
|
|
12
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vite-plus/test'
|
|
2
|
+
import { counterReducer, decrement, increment } from './counterSlice'
|
|
3
|
+
|
|
4
|
+
describe('counter feature model', () => {
|
|
5
|
+
it('increments and decrements without mutating the initial state', () => {
|
|
6
|
+
const original = { value: 0 }
|
|
7
|
+
const increased = counterReducer(original, increment())
|
|
8
|
+
expect(increased.value).toBe(1)
|
|
9
|
+
expect(original.value).toBe(0)
|
|
10
|
+
expect(counterReducer(increased, decrement()).value).toBe(0)
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit'
|
|
2
|
+
|
|
3
|
+
export type CounterState = { value: number }
|
|
4
|
+
const initialState: CounterState = { value: 0 }
|
|
5
|
+
|
|
6
|
+
const slice = createSlice({
|
|
7
|
+
name: 'counter',
|
|
8
|
+
initialState,
|
|
9
|
+
reducers: {
|
|
10
|
+
increment(state) { state.value += 1 },
|
|
11
|
+
decrement(state) { state.value -= 1 },
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const { increment, decrement } = slice.actions
|
|
16
|
+
export const counterReducer = slice.reducer
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useDispatch, useSelector } from 'react-redux'
|
|
2
|
+
import { Button } from '@/shared/ui'
|
|
3
|
+
import { increment, decrement } from '../model/counterSlice'
|
|
4
|
+
import { selectCount } from '../model/selectors'
|
|
5
|
+
|
|
6
|
+
export function CounterWidget() {
|
|
7
|
+
const dispatch = useDispatch()
|
|
8
|
+
const count = useSelector(selectCount)
|
|
9
|
+
return (
|
|
10
|
+
<div className="counter" aria-label="Redux sample counter">
|
|
11
|
+
<Button onClick={() => dispatch(decrement())} aria-label="Decrease counter">-</Button>
|
|
12
|
+
<output>{count}</output>
|
|
13
|
+
<Button onClick={() => dispatch(increment())} aria-label="Increase counter">+</Button>
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { homeRoutes } from './routes'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import { HomePage } from './HomePage'
|
|
4
|
+
|
|
5
|
+
describe('HomePage', () => {
|
|
6
|
+
it('renders the starter heading and an action', () => {
|
|
7
|
+
render(<HomePage />)
|
|
8
|
+
expect(screen.getByRole('heading', { name: 'OBSESSION' })).toBeInTheDocument()
|
|
9
|
+
expect(screen.getByRole('button', { name: 'TEST UI' })).toBeInTheDocument()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Button } from '@/shared/ui'
|
|
2
|
+
|
|
3
|
+
export function HomePage() {
|
|
4
|
+
return (
|
|
5
|
+
<section className="hero">
|
|
6
|
+
<p className="eyebrow">SYSTEM INITIALIZED</p>
|
|
7
|
+
<h1>OBSESSION<span className="blink" aria-hidden="true">_</span></h1>
|
|
8
|
+
<p>React / Router / Redux Toolkit / RTK Query / Vite+</p>
|
|
9
|
+
<p className="subtext">Your frontend architecture is online. Add features through their index.ts public API.</p>
|
|
10
|
+
<Button onClick={() => window.alert('Your first feature is ready.')}>TEST UI</Button>
|
|
11
|
+
</section>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
|
2
|
+
import { env } from '@/shared/config'
|
|
3
|
+
|
|
4
|
+
/** Generic transport only: never declare feature endpoints or tag names here. */
|
|
5
|
+
export const baseApi = createApi({
|
|
6
|
+
reducerPath: 'api',
|
|
7
|
+
baseQuery: fetchBaseQuery({ baseUrl: env.apiUrl }),
|
|
8
|
+
endpoints: () => ({}),
|
|
9
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { baseApi } from './baseApi'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { env } from './env'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react'
|
|
2
|
+
|
|
3
|
+
type Props = ButtonHTMLAttributes<HTMLButtonElement>
|
|
4
|
+
export function Button({ children, type = 'button', ...props }: Props) {
|
|
5
|
+
return <button type={type} className="retro-button" {...props}>{children}</button>
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import userEvent from '@testing-library/user-event'
|
|
4
|
+
import { StatusPanel } from './StatusPanel'
|
|
5
|
+
|
|
6
|
+
describe('StatusPanel', () => {
|
|
7
|
+
it.each([
|
|
8
|
+
['loading', 'Loading'],
|
|
9
|
+
['empty', 'Nothing here yet'],
|
|
10
|
+
['error', 'Something went wrong'],
|
|
11
|
+
['unauthorized', 'Access required'],
|
|
12
|
+
['not-found', 'Page not found'],
|
|
13
|
+
] as const)('renders %s state', (kind, heading) => {
|
|
14
|
+
render(<StatusPanel kind={kind} />)
|
|
15
|
+
expect(screen.getByRole('heading', { name: heading })).toBeInTheDocument()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('runs retry callback for error', async () => {
|
|
19
|
+
const onRetry = vi.fn()
|
|
20
|
+
const user = userEvent.setup()
|
|
21
|
+
render(<StatusPanel kind="error" onRetry={onRetry} />)
|
|
22
|
+
await user.click(screen.getByRole('button', { name: 'Try again' }))
|
|
23
|
+
expect(onRetry).toHaveBeenCalledOnce()
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type StatusKind = 'loading' | 'empty' | 'error' | 'unauthorized' | 'not-found'
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
kind: StatusKind
|
|
7
|
+
title?: string
|
|
8
|
+
description?: string
|
|
9
|
+
onRetry?: () => void
|
|
10
|
+
children?: ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const defaults: Record<StatusKind, { title: string; description: string }> = {
|
|
14
|
+
loading: { title: 'Loading', description: 'Getting things ready.' },
|
|
15
|
+
empty: { title: 'Nothing here yet', description: 'There is no data to display.' },
|
|
16
|
+
error: { title: 'Something went wrong', description: 'Please try again.' },
|
|
17
|
+
unauthorized: { title: 'Access required', description: 'You cannot view this page.' },
|
|
18
|
+
'not-found': { title: 'Page not found', description: 'This address does not exist.' },
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Generic UI only: do not fetch or read application state here. */
|
|
22
|
+
export function StatusPanel({ kind, title, description, onRetry, children }: Props) {
|
|
23
|
+
const preset = defaults[kind]
|
|
24
|
+
return (
|
|
25
|
+
<section
|
|
26
|
+
className={`status-panel status-panel--${kind}`}
|
|
27
|
+
role={kind === 'error' ? 'alert' : 'status'}
|
|
28
|
+
aria-busy={kind === 'loading' ? true : undefined}
|
|
29
|
+
>
|
|
30
|
+
<h1>{title ?? preset.title}</h1>
|
|
31
|
+
<p>{description ?? preset.description}</p>
|
|
32
|
+
{children}
|
|
33
|
+
{onRetry && kind === 'error' ? <button type="button" onClick={onRetry}>Try again</button> : null}
|
|
34
|
+
</section>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');
|
|
2
|
+
:root { font-family: 'Space Mono', ui-monospace, Consolas, monospace; background: #0e1115; color: #f0eadc; font-synthesis: none; }
|
|
3
|
+
* { box-sizing: border-box; }
|
|
4
|
+
body { margin: 0; min-height: 100vh; }
|
|
5
|
+
button { font: inherit; }
|
|
6
|
+
.app-frame { margin: 0 auto; max-width: 1120px; min-height: 100vh; padding: 24px; display: flex; flex-direction: column; }
|
|
7
|
+
.app-header { border: 1px solid #7f866e; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 16px; }
|
|
8
|
+
.app-brand { letter-spacing: .1em; color: #c6e18c; font-size: 13px; font-weight: 700; }
|
|
9
|
+
.app-footer { margin-top: auto; padding-top: 24px; opacity: .6; font-size: 12px; }
|
|
10
|
+
.hero { padding: min(13vh, 96px) 0; }
|
|
11
|
+
.hero h1 { font-size: clamp(48px, 9vw, 110px); line-height: 1; margin: 10px 0 24px; letter-spacing: -.08em; color: #c6e18c; }
|
|
12
|
+
.hero > p { max-width: 640px; }
|
|
13
|
+
.eyebrow { color: #ffb983; font-size: 12px; letter-spacing: .2em; }
|
|
14
|
+
.subtext { color: #a6aaa2; margin-bottom: 28px; }
|
|
15
|
+
.blink { animation: blink .8s step-end infinite; }
|
|
16
|
+
@keyframes blink { 50% { opacity: 0; } }
|
|
17
|
+
@media (prefers-reduced-motion: reduce) { .blink { animation: none; } }
|
|
18
|
+
.retro-button { background: #c6e18c; color: #0e1115; font-weight: 700; border: 2px solid #c6e18c; padding: 8px 14px; cursor: pointer; }
|
|
19
|
+
.retro-button:focus-visible { outline: 2px dashed #fff; outline-offset: 4px; }
|
|
20
|
+
.retro-button:hover { background: #d9ffac; }
|
|
21
|
+
.counter { display: inline-flex; align-items: center; gap: 10px; }
|
|
22
|
+
.counter output { min-width: 2ch; text-align: center; }
|
|
23
|
+
|
|
24
|
+
.status-panel { max-width: 42rem; margin: 10vh auto; padding: 2rem; border: 1px solid #566052; background: #191e20; }
|
|
25
|
+
.status-panel h1 { color: #c6e18c; }
|
|
26
|
+
.status-panel p { color: #b4b9af; }
|
|
27
|
+
.status-panel button { background: #c6e18c; border: 0; padding: 0.7rem 1rem; cursor: pointer; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"useDefineForClassFields": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"noUnusedParameters": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"types": ["vite/client"],
|
|
18
|
+
"paths": { "@/*": ["./src/*"] }
|
|
19
|
+
},
|
|
20
|
+
"include": ["src", "vite.config.ts"]
|
|
21
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { defineConfig } from 'vite-plus'
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
|
|
5
|
+
// Chapter 8: Rules A (downward imports), B (public doors), C (no cycles).
|
|
6
|
+
// The separate structural checker resolves paths and validates the full graph,
|
|
7
|
+
// including type-only imports and relative-path bypass attempts.
|
|
8
|
+
const deepFeatureImport = {
|
|
9
|
+
regex: '^@/features/[^/]+/.+',
|
|
10
|
+
message: 'Rule B: import a feature only via @/features/<name>.',
|
|
11
|
+
}
|
|
12
|
+
const deepRelativeImport = {
|
|
13
|
+
regex: '^(\\.\\./){2,}',
|
|
14
|
+
message: 'Rule B: avoid ../../; cross architectural zones via @/ public APIs.',
|
|
15
|
+
}
|
|
16
|
+
const featureUpwardImport = {
|
|
17
|
+
regex: '^@/app(/|$)',
|
|
18
|
+
message: 'Rule A: feature code must never import app/.',
|
|
19
|
+
}
|
|
20
|
+
const sharedUpwardImport = {
|
|
21
|
+
regex: '^@/(features|app)(/|$)',
|
|
22
|
+
message: 'Rule A: shared code must not import app/ or features/.',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
plugins: [react()],
|
|
27
|
+
resolve: {
|
|
28
|
+
alias: {
|
|
29
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
lint: {
|
|
33
|
+
plugins: ['import', 'typescript', 'react'],
|
|
34
|
+
options: { typeAware: true, typeCheck: true },
|
|
35
|
+
ignorePatterns: ['dist/**', 'coverage/**'],
|
|
36
|
+
rules: {
|
|
37
|
+
'import/no-cycle': ['error', { ignoreTypes: false }],
|
|
38
|
+
'no-restricted-imports': [
|
|
39
|
+
'error',
|
|
40
|
+
{ patterns: [deepFeatureImport, deepRelativeImport] },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
// Oxlint overrides replace the rule for their matching files, so repeat
|
|
44
|
+
// the global patterns in each override. The standalone structural checker
|
|
45
|
+
// also catches indirect and relative-path violations.
|
|
46
|
+
overrides: [
|
|
47
|
+
{
|
|
48
|
+
files: ['src/features/**/*.{ts,tsx,js,jsx}'],
|
|
49
|
+
rules: {
|
|
50
|
+
'no-restricted-imports': [
|
|
51
|
+
'error',
|
|
52
|
+
{ patterns: [deepFeatureImport, deepRelativeImport, featureUpwardImport] },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ['src/shared/**/*.{ts,tsx,js,jsx}'],
|
|
58
|
+
rules: {
|
|
59
|
+
'no-restricted-imports': [
|
|
60
|
+
'error',
|
|
61
|
+
{ patterns: [deepRelativeImport, sharedUpwardImport] },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
test: {
|
|
68
|
+
include: ['src/**/*.test.{ts,tsx}'],
|
|
69
|
+
environment: 'jsdom',
|
|
70
|
+
setupFiles: ['./tests/setup.ts'],
|
|
71
|
+
css: true,
|
|
72
|
+
},
|
|
73
|
+
})
|
package/npm/cli.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// npm entry point for create-obsession / obsession.
|
|
5
|
+
// Runs the prebuilt native OBSESSION binary for this platform. The binary finds
|
|
6
|
+
// frontend/template/ relative to its own location, so the package keeps the
|
|
7
|
+
// repository layout: bin/ and frontend/ side by side.
|
|
8
|
+
|
|
9
|
+
const { spawnSync } = require('node:child_process');
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const path = require('node:path');
|
|
12
|
+
|
|
13
|
+
const BINARIES = {
|
|
14
|
+
win32: 'obsession.exe', // x64 build; also runs on Windows on Arm through emulation
|
|
15
|
+
linux: process.arch === 'x64' ? 'obsession.out' : null,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const file = BINARIES[process.platform];
|
|
19
|
+
if (!file) {
|
|
20
|
+
console.error(`create-obsession: ${process.platform}/${process.arch} is not supported yet (Windows x64 and Linux x64 only).`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binary = path.join(__dirname, '..', 'bin', file);
|
|
25
|
+
if (!fs.existsSync(binary)) {
|
|
26
|
+
console.error(`create-obsession: the bundled binary is missing (${binary}). Reinstall the package.`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (process.platform !== 'win32') {
|
|
31
|
+
try {
|
|
32
|
+
fs.accessSync(binary, fs.constants.X_OK);
|
|
33
|
+
} catch {
|
|
34
|
+
try {
|
|
35
|
+
fs.chmodSync(binary, 0o755);
|
|
36
|
+
} catch {
|
|
37
|
+
// Read-only install location; spawn below reports the real error.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Allow `npm create obsession my-app` as shorthand for `--name my-app`.
|
|
43
|
+
const args = process.argv.slice(2);
|
|
44
|
+
if (args.length > 0 && !args[0].startsWith('-')) {
|
|
45
|
+
args.splice(0, 1, '--name', args[0]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = spawnSync(binary, args, { stdio: 'inherit' });
|
|
49
|
+
if (result.error) {
|
|
50
|
+
console.error(`create-obsession: could not start ${binary}: ${result.error.message}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-obsession",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Retro terminal project initializer: scaffolds a React + TypeScript + Vite+ frontend with architecture guards, tests and CI.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"create",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"react",
|
|
9
|
+
"typescript",
|
|
10
|
+
"vite",
|
|
11
|
+
"template"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"bin": {
|
|
15
|
+
"create-obsession": "npm/cli.js",
|
|
16
|
+
"obsession": "npm/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"npm/",
|
|
20
|
+
"bin/obsession.exe",
|
|
21
|
+
"bin/obsession.out",
|
|
22
|
+
"frontend/",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"os": [
|
|
26
|
+
"win32",
|
|
27
|
+
"linux"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
}
|
|
32
|
+
}
|