anhedral 0.13.0 → 0.15.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 +35 -232
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +33 -0
- package/assets/ui/native/button.tsx +85 -0
- package/assets/ui/native/card.tsx +33 -0
- package/assets/ui/native/dialog.tsx +75 -0
- package/assets/ui/native/input.tsx +27 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/capabilities.d.ts +5 -5
- package/dist/capabilities.js +3 -21
- package/dist/capability-contract.d.ts +3 -3
- package/dist/capability-contract.js +11 -50
- package/dist/cli-delivery.d.ts +1 -1
- package/dist/cli-delivery.js +5 -65
- package/dist/cli-output.js +3 -3
- package/dist/command-schema.js +35 -86
- package/dist/delivery-evidence.d.ts +1 -1
- package/dist/delivery-evidence.js +7 -36
- package/dist/delivery.d.ts +2 -8
- package/dist/delivery.js +20 -101
- package/dist/dependencies.d.ts +6 -57
- package/dist/dependencies.js +54 -188
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/inspector-model.d.ts +2 -2
- package/dist/integration-service-readers.d.ts +1 -2
- package/dist/integration-service-readers.js +3 -84
- package/dist/lifecycle-model.d.ts +1 -1
- package/dist/lifecycle-model.js +1 -1
- package/dist/mobile-delivery.d.ts +1 -1
- package/dist/mobile-delivery.js +4 -0
- package/dist/platforms/mobile.js +30 -121
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +299 -0
- package/dist/project-config.d.ts +1 -1
- package/dist/project-config.js +0 -1
- package/dist/project-inspector.js +5 -36
- package/dist/project-state.d.ts +1 -3
- package/dist/project-state.js +2 -85
- package/dist/provider-auth.js +3 -38
- package/dist/provider-readiness.d.ts +1 -1
- package/dist/provider-readiness.js +5 -24
- package/dist/providers/adapters.js +0 -175
- package/dist/providers/api.d.ts +1 -1
- package/dist/providers/api.js +3 -3
- package/dist/providers/config.js +2 -48
- package/dist/providers/definitions.d.ts +1 -204
- package/dist/providers/definitions.js +0 -85
- package/dist/providers/provision.d.ts +1 -1
- package/dist/providers/receipts.js +1 -11
- package/dist/providers/recovery-verification.js +1 -61
- package/dist/providers/runtime.js +4 -35
- package/dist/providers/state.js +1 -7
- package/dist/provision.d.ts +5 -13
- package/dist/provision.js +4 -80
- package/dist/readiness.d.ts +1 -1
- package/dist/readiness.js +3 -8
- package/dist/registry/add.js +10 -70
- package/dist/registry/bootstrap.d.ts +3 -2
- package/dist/registry/bootstrap.js +4 -13
- package/dist/registry/commands.js +8 -10
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +8 -38
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +26 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +2 -2
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/auth.d.ts +1 -2
- package/dist/scaffold/auth.js +55 -130
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -186
- package/dist/scaffold/billing-schema.d.ts +1 -1
- package/dist/scaffold/billing-schema.js +4 -4
- package/dist/scaffold/billing.js +11 -19
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +18 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +22 -86
- package/dist/scaffold/expo-auth.js +33 -22
- package/dist/scaffold/expo-billing.js +17 -52
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +6 -97
- package/dist/scaffold/integrations.d.ts +1 -3
- package/dist/scaffold/integrations.js +9 -10
- package/dist/scaffold/managed-email.d.ts +3 -0
- package/dist/scaffold/managed-email.js +47 -0
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +69 -0
- package/dist/scaffold/password-reset.d.ts +1 -0
- package/dist/scaffold/password-reset.js +99 -0
- package/dist/scaffold/private-files.d.ts +2 -0
- package/dist/scaffold/private-files.js +78 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/web-billing.d.ts +2 -0
- package/dist/scaffold/web-billing.js +48 -0
- package/dist/scaffold/workspace.js +53 -194
- package/dist/service-deletion.js +1 -1
- package/dist/service-descriptor.js +5 -12
- package/dist/service-model.d.ts +1 -1
- package/dist/service-operations.js +2 -32
- package/dist/service-readers.js +1 -32
- package/dist/services-command.d.ts +1 -1
- package/dist/services-command.js +3 -9
- package/dist/ship.d.ts +3 -316
- package/dist/ship.js +10 -142
- package/dist/stack-registry.d.ts +2 -52
- package/dist/stack-registry.js +55 -403
- package/dist/standard.js +7 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +23 -122
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/software-factory.md +24 -557
- package/docs/stack-standard.md +47 -294
- package/docs/verification.md +320 -0
- package/package.json +20 -22
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { NATIVE_ESLINT_VERSION } from '../dependencies.js';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { writeReactLintConfig } from './lint.js';
|
|
4
|
-
import { writeFile } from '../util.js';
|
|
5
|
-
import { EXTENSION_DEPENDENCIES } from '../dependencies.js';
|
|
6
|
-
import { childPackageName, htmlText, jsString, markdownHeading } from '../render.js';
|
|
7
|
-
export async function scaffoldWxt({ root, options }) {
|
|
8
|
-
const projectName = options.name;
|
|
9
|
-
const displayName = options.name;
|
|
10
|
-
const dir = path.join(root, 'apps/extension');
|
|
11
|
-
writePackageJson(dir, projectName);
|
|
12
|
-
writeFile(path.join(dir, 'tsconfig.json'), JSON.stringify({
|
|
13
|
-
extends: './.wxt/tsconfig.json',
|
|
14
|
-
compilerOptions: { strict: true, jsx: 'react-jsx', paths: { '@/*': ['./src/*'] } },
|
|
15
|
-
}, null, 2) + '\n');
|
|
16
|
-
writeReactLintConfig(dir);
|
|
17
|
-
writeWxtConfig(dir, displayName);
|
|
18
|
-
writeEnvExample(dir);
|
|
19
|
-
writePostcssConfig(dir);
|
|
20
|
-
writeTailwindConfig(dir);
|
|
21
|
-
writeShadcnConfig(dir);
|
|
22
|
-
writeReadme(dir, displayName);
|
|
23
|
-
writeCnUtil(dir);
|
|
24
|
-
writeButtonComponent(dir);
|
|
25
|
-
writeBackground(dir);
|
|
26
|
-
writeSidepanelEntry(dir);
|
|
27
|
-
writeSidepanelHtml(dir, displayName);
|
|
28
|
-
writeSidepanelApp(dir);
|
|
29
|
-
writeStyles(dir);
|
|
30
|
-
}
|
|
31
|
-
function writePackageJson(dir, projectName) {
|
|
32
|
-
writeFile(path.join(dir, 'package.json'), JSON.stringify({
|
|
33
|
-
name: childPackageName(projectName, 'chrome-ext'),
|
|
34
|
-
version: '0.1.0',
|
|
35
|
-
private: true,
|
|
36
|
-
type: 'module',
|
|
37
|
-
scripts: {
|
|
38
|
-
dev: 'wxt',
|
|
39
|
-
build: 'wxt build',
|
|
40
|
-
postinstall: 'wxt prepare',
|
|
41
|
-
zip: 'wxt zip',
|
|
42
|
-
typecheck: 'tsc --noEmit',
|
|
43
|
-
lint: 'eslint src --max-warnings 0',
|
|
44
|
-
},
|
|
45
|
-
dependencies: {
|
|
46
|
-
...EXTENSION_DEPENDENCIES.dependencies,
|
|
47
|
-
'@workspace/styling': 'workspace:*',
|
|
48
|
-
},
|
|
49
|
-
devDependencies: {
|
|
50
|
-
...EXTENSION_DEPENDENCIES.devDependencies,
|
|
51
|
-
'@workspace/eslint-config': 'workspace:*',
|
|
52
|
-
eslint: NATIVE_ESLINT_VERSION,
|
|
53
|
-
},
|
|
54
|
-
}, null, 2) + '\n');
|
|
55
|
-
}
|
|
56
|
-
function writeWxtConfig(dir, displayName) {
|
|
57
|
-
const nameLiteral = jsString(displayName);
|
|
58
|
-
const descriptionLiteral = jsString(`${displayName} Chrome Extension`);
|
|
59
|
-
const actionTitleLiteral = jsString(`Open ${displayName}`);
|
|
60
|
-
writeFile(path.join(dir, 'wxt.config.ts'), `import { defineConfig } from 'wxt';
|
|
61
|
-
|
|
62
|
-
export default defineConfig({
|
|
63
|
-
srcDir: 'src',
|
|
64
|
-
dev: { server: { port: 3001, strictPort: true } },
|
|
65
|
-
manifest: () => {
|
|
66
|
-
const crxPublicKey = import.meta.env.VITE_CRX_PUBLIC_KEY || '';
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
name: ${nameLiteral},
|
|
70
|
-
description: ${descriptionLiteral},
|
|
71
|
-
version: '0.1.0',
|
|
72
|
-
...(crxPublicKey ? { key: crxPublicKey } : {}),
|
|
73
|
-
minimum_chrome_version: '114',
|
|
74
|
-
permissions: ['activeTab', 'scripting', 'sidePanel'],
|
|
75
|
-
host_permissions: [],
|
|
76
|
-
action: {
|
|
77
|
-
default_title: ${actionTitleLiteral},
|
|
78
|
-
},
|
|
79
|
-
side_panel: {
|
|
80
|
-
default_path: 'sidepanel.html',
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
modules: ['@wxt-dev/module-react'],
|
|
85
|
-
vite: () => ({
|
|
86
|
-
build: {
|
|
87
|
-
chunkSizeWarningLimit: 3000,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
`);
|
|
92
|
-
}
|
|
93
|
-
function extensionEnvContents() {
|
|
94
|
-
const sections = [];
|
|
95
|
-
sections.push(`# Chrome Extension CRX public key (optional, for stable extension ID)
|
|
96
|
-
VITE_CRX_PUBLIC_KEY=`);
|
|
97
|
-
return `${sections.join('\n\n')}\n`;
|
|
98
|
-
}
|
|
99
|
-
function writeEnvExample(dir) {
|
|
100
|
-
writeFile(path.join(dir, '.env.example'), extensionEnvContents());
|
|
101
|
-
}
|
|
102
|
-
function writePostcssConfig(dir) {
|
|
103
|
-
writeFile(path.join(dir, 'postcss.config.cjs'), `module.exports = {
|
|
104
|
-
plugins: {
|
|
105
|
-
tailwindcss: {},
|
|
106
|
-
autoprefixer: {},
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
`);
|
|
110
|
-
}
|
|
111
|
-
function writeShadcnConfig(dir) {
|
|
112
|
-
writeFile(path.join(dir, 'components.json'), JSON.stringify({
|
|
113
|
-
$schema: 'https://ui.shadcn.com/schema.json',
|
|
114
|
-
style: 'new-york',
|
|
115
|
-
rsc: false,
|
|
116
|
-
tsx: true,
|
|
117
|
-
tailwind: {
|
|
118
|
-
config: '',
|
|
119
|
-
css: 'src/styles/main.css',
|
|
120
|
-
baseColor: 'neutral',
|
|
121
|
-
cssVariables: true,
|
|
122
|
-
prefix: '',
|
|
123
|
-
},
|
|
124
|
-
aliases: {
|
|
125
|
-
components: '@/components',
|
|
126
|
-
utils: '@/lib/utils',
|
|
127
|
-
ui: '@/components/ui',
|
|
128
|
-
lib: '@/lib',
|
|
129
|
-
hooks: '@/hooks',
|
|
130
|
-
},
|
|
131
|
-
iconLibrary: 'lucide',
|
|
132
|
-
}, null, 2) + '\n');
|
|
133
|
-
}
|
|
134
|
-
function writeCnUtil(dir) {
|
|
135
|
-
writeFile(path.join(dir, 'src/lib/utils.ts'), `import { clsx, type ClassValue } from 'clsx';
|
|
136
|
-
import { twMerge } from 'tailwind-merge';
|
|
137
|
-
|
|
138
|
-
export function cn(...inputs: ClassValue[]) {
|
|
139
|
-
return twMerge(clsx(inputs));
|
|
140
|
-
}
|
|
141
|
-
`);
|
|
142
|
-
}
|
|
143
|
-
function writeButtonComponent(dir) {
|
|
144
|
-
writeFile(path.join(dir, 'src/components/ui/button.tsx'), `import * as React from 'react';
|
|
145
|
-
import { cn } from '@/lib/utils';
|
|
146
|
-
|
|
147
|
-
type ButtonVariant = 'default' | 'outline';
|
|
148
|
-
|
|
149
|
-
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
150
|
-
variant?: ButtonVariant;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const variantClasses: Record<ButtonVariant, string> = {
|
|
154
|
-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
155
|
-
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
159
|
-
({ className, variant = 'default', type = 'button', ...props }, ref) => {
|
|
160
|
-
return (
|
|
161
|
-
<button
|
|
162
|
-
ref={ref}
|
|
163
|
-
type={type}
|
|
164
|
-
className={cn(
|
|
165
|
-
'inline-flex h-9 items-center justify-center whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50',
|
|
166
|
-
variantClasses[variant],
|
|
167
|
-
className,
|
|
168
|
-
)}
|
|
169
|
-
{...props}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
},
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
Button.displayName = 'Button';
|
|
176
|
-
`);
|
|
177
|
-
}
|
|
178
|
-
function writeTailwindConfig(dir) {
|
|
179
|
-
writeFile(path.join(dir, 'tailwind.config.cjs'), `/** @type {import('tailwindcss').Config} */
|
|
180
|
-
module.exports = {
|
|
181
|
-
content: ['./src/**/*.{ts,tsx,html}'],
|
|
182
|
-
presets: [require('@workspace/styling/tailwind')],
|
|
183
|
-
};
|
|
184
|
-
`);
|
|
185
|
-
}
|
|
186
|
-
function writeReadme(dir, displayName) {
|
|
187
|
-
writeFile(path.join(dir, 'README.md'), `# ${markdownHeading(displayName)} Chrome Extension
|
|
188
|
-
|
|
189
|
-
WXT side-panel extension generated by anhedral.
|
|
190
|
-
|
|
191
|
-
## Development
|
|
192
|
-
|
|
193
|
-
\`\`\`bash
|
|
194
|
-
cp .env.example .env
|
|
195
|
-
pnpm dev
|
|
196
|
-
pnpm build
|
|
197
|
-
pnpm zip
|
|
198
|
-
\`\`\`
|
|
199
|
-
|
|
200
|
-
Run these commands from \`apps/extension\`. Anhedral generates only \`.env.example\`; keep the local \`.env\` file uncommitted. Set \`VITE_CRX_PUBLIC_KEY\` only when you need a stable Chrome extension ID.
|
|
201
|
-
|
|
202
|
-
## Chrome
|
|
203
|
-
|
|
204
|
-
Run \`pnpm build\`, then load \`.output/chrome-mv3\` as an unpacked extension from \`chrome://extensions\`.
|
|
205
|
-
|
|
206
|
-
The extension uses Chrome's Side Panel API. The browser action opens \`sidepanel.html\`, \`wxt.config.ts\` declares the \`sidePanel\` permission and Chrome 114+ minimum version, and active-page reads use a user-triggered \`activeTab\` + \`scripting\` grant instead of persistent site access.
|
|
207
|
-
`);
|
|
208
|
-
}
|
|
209
|
-
function writeBackground(dir) {
|
|
210
|
-
writeFile(path.join(dir, 'src/entrypoints/background.ts'), `type ChromeWithSidePanel = typeof chrome & {
|
|
211
|
-
sidePanel: {
|
|
212
|
-
setPanelBehavior: (behavior: { openPanelOnActionClick: boolean }) => Promise<void>;
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export default defineBackground(() => {
|
|
217
|
-
|
|
218
|
-
// Open the side panel when the extension icon is clicked.
|
|
219
|
-
(chrome as ChromeWithSidePanel).sidePanel
|
|
220
|
-
.setPanelBehavior({ openPanelOnActionClick: true })
|
|
221
|
-
.catch((error) => console.error('Unable to configure the side panel:', error));
|
|
222
|
-
});
|
|
223
|
-
`);
|
|
224
|
-
}
|
|
225
|
-
function writeSidepanelEntry(dir) {
|
|
226
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/main.tsx'), `import * as React from 'react';
|
|
227
|
-
import { createRoot } from 'react-dom/client';
|
|
228
|
-
import { SidePanelApp } from './app';
|
|
229
|
-
import '../../styles/main.css';
|
|
230
|
-
|
|
231
|
-
const container = document.getElementById('root');
|
|
232
|
-
if (container) {
|
|
233
|
-
const root = createRoot(container);
|
|
234
|
-
root.render(
|
|
235
|
-
<React.StrictMode>
|
|
236
|
-
<SidePanelApp />
|
|
237
|
-
</React.StrictMode>
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
`);
|
|
241
|
-
}
|
|
242
|
-
function writeSidepanelHtml(dir, displayName) {
|
|
243
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/index.html'), `<!DOCTYPE html>
|
|
244
|
-
<html lang="en">
|
|
245
|
-
<head>
|
|
246
|
-
<meta charset="UTF-8" />
|
|
247
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
248
|
-
<title>${htmlText(displayName)}</title>
|
|
249
|
-
</head>
|
|
250
|
-
<body>
|
|
251
|
-
<div id="root"></div>
|
|
252
|
-
<script type="module" src="./main.tsx"></script>
|
|
253
|
-
</body>
|
|
254
|
-
</html>
|
|
255
|
-
`);
|
|
256
|
-
}
|
|
257
|
-
function writeSidepanelApp(dir) {
|
|
258
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/app.tsx'), `import * as React from 'react';
|
|
259
|
-
import { Button } from '../../components/ui/button';
|
|
260
|
-
|
|
261
|
-
type PageSnapshot = {
|
|
262
|
-
title: string;
|
|
263
|
-
location: string;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
async function readPageSnapshot(): Promise<PageSnapshot> {
|
|
267
|
-
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
|
268
|
-
if (!tab?.id) throw new Error('No active tab is available.');
|
|
269
|
-
const [{ result }] = await chrome.scripting.executeScript({
|
|
270
|
-
target: { tabId: tab.id },
|
|
271
|
-
func: () => ({ title: document.title, location: window.location.href }),
|
|
272
|
-
});
|
|
273
|
-
if (!result) throw new Error('The active page did not return a snapshot.');
|
|
274
|
-
return result as PageSnapshot;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export function SidePanelApp() {
|
|
278
|
-
const [page, setPage] = React.useState<PageSnapshot | null>(null);
|
|
279
|
-
const [pageError, setPageError] = React.useState<string | null>(null);
|
|
280
|
-
|
|
281
|
-
const readActivePage = React.useCallback(async () => {
|
|
282
|
-
setPageError(null);
|
|
283
|
-
try {
|
|
284
|
-
setPage(await readPageSnapshot());
|
|
285
|
-
} catch {
|
|
286
|
-
setPageError('Chrome does not allow this page to be inspected. Open a normal website and try again.');
|
|
287
|
-
}
|
|
288
|
-
}, []);
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<div style={{ padding: 24 }}>
|
|
292
|
-
<h2>Welcome!</h2>
|
|
293
|
-
<Button type="button" onClick={() => void readActivePage()}>Read active page</Button>
|
|
294
|
-
{page ? (
|
|
295
|
-
<div role="status" aria-live="polite" style={{ marginTop: 16 }}>
|
|
296
|
-
<strong>{page.title || 'Untitled page'}</strong>
|
|
297
|
-
<p style={{ overflowWrap: 'anywhere' }}>{page.location}</p>
|
|
298
|
-
</div>
|
|
299
|
-
) : null}
|
|
300
|
-
{pageError ? <p role="alert" aria-live="assertive" style={{ color: 'hsl(var(--destructive))' }}>{pageError}</p> : null}
|
|
301
|
-
</div>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
`);
|
|
305
|
-
}
|
|
306
|
-
function writeStyles(dir) {
|
|
307
|
-
writeFile(path.join(dir, 'src/styles/main.css'), `@tailwind base;
|
|
308
|
-
@tailwind components;
|
|
309
|
-
@tailwind utilities;
|
|
310
|
-
|
|
311
|
-
@layer base {
|
|
312
|
-
|
|
313
|
-
* {
|
|
314
|
-
border-color: hsl(var(--border));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
body {
|
|
318
|
-
background: hsl(var(--background));
|
|
319
|
-
color: hsl(var(--foreground));
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
body {
|
|
324
|
-
margin: 0;
|
|
325
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
326
|
-
}
|
|
327
|
-
`);
|
|
328
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StandardProduct } from './types.js';
|
|
2
|
-
/** A compatible product selection, not mutually exclusive catalog alternatives. */
|
|
3
|
-
export declare const FULL_PRODUCT: readonly StandardProduct[];
|
|
4
|
-
export declare function applyPreset(name: string, selected: Set<StandardProduct>): void;
|
package/dist/registry/presets.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** A compatible product selection, not mutually exclusive catalog alternatives. */
|
|
2
|
-
export const FULL_PRODUCT = Object.freeze([
|
|
3
|
-
'expo',
|
|
4
|
-
'hono',
|
|
5
|
-
'wxt',
|
|
6
|
-
'd1',
|
|
7
|
-
'better-auth',
|
|
8
|
-
'r2',
|
|
9
|
-
'kv',
|
|
10
|
-
'stripe',
|
|
11
|
-
'revenuecat',
|
|
12
|
-
'workers-ai',
|
|
13
|
-
'analytics-engine',
|
|
14
|
-
'basin',
|
|
15
|
-
'realtime',
|
|
16
|
-
'realtimekit',
|
|
17
|
-
'images',
|
|
18
|
-
'stream',
|
|
19
|
-
'video',
|
|
20
|
-
'queues',
|
|
21
|
-
'cron',
|
|
22
|
-
'workflows',
|
|
23
|
-
'resend',
|
|
24
|
-
'sentry',
|
|
25
|
-
]);
|
|
26
|
-
export function applyPreset(name, selected) {
|
|
27
|
-
if (!['minimal', 'full-product'].includes(name))
|
|
28
|
-
throw new Error('preset must be minimal or full-product.');
|
|
29
|
-
if (name === 'minimal')
|
|
30
|
-
return;
|
|
31
|
-
// Explicit provider/frontend choices replace the preset's corresponding default.
|
|
32
|
-
for (const id of FULL_PRODUCT) {
|
|
33
|
-
if (id === 'expo' && (selected.has('next') || selected.has('vinext')))
|
|
34
|
-
continue;
|
|
35
|
-
if (id === 'd1' && (selected.has('neon') || selected.has('neon-realtime')))
|
|
36
|
-
continue;
|
|
37
|
-
if (id === 'better-auth' && selected.has('clerk'))
|
|
38
|
-
continue;
|
|
39
|
-
selected.add(id);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
export declare function scaffoldAnalyticsEngine(context: RecipeContext): void;
|
|
3
|
-
export declare function scaffoldImages(context: RecipeContext): void;
|
|
4
|
-
export declare function scaffoldCloudflareTransport({ root }: RecipeContext): void;
|
|
5
|
-
export declare function scaffoldRealtimeKit(context: RecipeContext): void;
|
|
6
|
-
export declare function scaffoldVideo(context: RecipeContext): void;
|
|
7
|
-
/** Lazy Hono adapters wire selected helpers without exposing generic public routes. */
|
|
8
|
-
export declare function scaffoldCloudflareServiceContext({ root, has }: RecipeContext): void;
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { STACK_DEPENDENCIES } from '../dependencies.js';
|
|
2
|
-
import { rmSync, readFileSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { patchPackage, put, sharedPackage } from './files.js';
|
|
5
|
-
import { writeEnvironmentFile } from './environment.js';
|
|
6
|
-
/** Server-only packages are linked to their owner, never to client manifests. */
|
|
7
|
-
function serverPackage(context, name, source, guide, secrets = []) {
|
|
8
|
-
const { root, runtimeApp } = context;
|
|
9
|
-
sharedPackage(root, name, '', {});
|
|
10
|
-
rmSync(path.join(root, `packages/${name}/src/index.ts`));
|
|
11
|
-
patchPackage(root, `packages/${name}/package.json`, {
|
|
12
|
-
exports: { './server': './src/server.ts' },
|
|
13
|
-
});
|
|
14
|
-
put(root, `packages/${name}/src/server.ts`, source);
|
|
15
|
-
put(root, `packages/${name}/README.md`, guide);
|
|
16
|
-
patchPackage(root, `apps/${runtimeApp}/package.json`, {
|
|
17
|
-
dependencies: { [`@workspace/${name}`]: 'workspace:*' },
|
|
18
|
-
});
|
|
19
|
-
if (['video', 'realtimekit'].includes(name))
|
|
20
|
-
patchPackage(root, `packages/${name}/package.json`, {
|
|
21
|
-
dependencies: { '@workspace/cloudflare-api': 'workspace:*', zod: STACK_DEPENDENCIES.zod },
|
|
22
|
-
});
|
|
23
|
-
if (secrets.length) {
|
|
24
|
-
writeEnvironmentFile(root, `apps/${runtimeApp}/.dev.vars.example`, Object.fromEntries(secrets.map((key) => [key, ''])));
|
|
25
|
-
put(root, `apps/${runtimeApp}/src/${name}-secrets.d.ts`, `interface Env { ${secrets.map((key) => `${key}: string;`).join(' ')} }\n`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export function scaffoldAnalyticsEngine(context) {
|
|
29
|
-
serverPackage(context, 'analytics-engine', `export interface AnalyticsBinding {
|
|
30
|
-
writeDataPoint(point: { indexes: string[]; blobs: string[]; doubles: number[] }): void;
|
|
31
|
-
}
|
|
32
|
-
// Use a stable, non-sensitive tenant key. Never log credentials or raw user content.
|
|
33
|
-
export function recordEvent(binding: AnalyticsBinding, tenantKey: string, event: string, value = 1): void {
|
|
34
|
-
if (!tenantKey || !event || !Number.isFinite(value)) throw new Error('Invalid analytics event.');
|
|
35
|
-
binding.writeDataPoint({ indexes: [tenantKey], blobs: [event], doubles: [value] });
|
|
36
|
-
}
|
|
37
|
-
`, `# Workers Analytics Engine
|
|
38
|
-
|
|
39
|
-
In Hono product routes, use c.get('services').analytics(tenant, event, value), or import recordEvent from @workspace/analytics-engine/server and pass env.EVENTS, an authorized non-sensitive tenant key, a server-controlled event name and a numeric value. Define consent, retention and event semantics before recording production events. The helper does not create a public ingestion route. writeDataPoint is non-blocking; analytics is not a billing ledger or transactional quota authority. Verify dataset receipt and sampled SQL query semantics with the selected account. Dataset binding is configured on deployment; account activation and analytics read credentials remain explicit.
|
|
40
|
-
|
|
41
|
-
https://developers.cloudflare.com/analytics/analytics-engine/get-started/
|
|
42
|
-
`);
|
|
43
|
-
}
|
|
44
|
-
export function scaffoldImages(context) {
|
|
45
|
-
serverPackage(context, 'images', `export interface ImagesBinding {
|
|
46
|
-
input(stream: ReadableStream<Uint8Array>): {
|
|
47
|
-
transform(options: { width: number; fit: 'scale-down' }): {
|
|
48
|
-
output(options: { format: 'image/webp' }): Promise<{ response(): Response }>;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// Pass bytes from an already authorized R2 object, not an arbitrary caller URL.
|
|
53
|
-
export async function resizeImage(images: ImagesBinding, body: ReadableStream<Uint8Array>, width: number): Promise<Response> {
|
|
54
|
-
if (!Number.isInteger(width) || width < 1 || width > 2048) throw new Error('Invalid image width.');
|
|
55
|
-
const result = await images.input(body).transform({ width, fit: 'scale-down' }).output({ format: 'image/webp' });
|
|
56
|
-
const response = result.response();
|
|
57
|
-
response.headers.set('cache-control', 'private, no-store');
|
|
58
|
-
return response;
|
|
59
|
-
}
|
|
60
|
-
`, `# Cloudflare Images
|
|
61
|
-
|
|
62
|
-
In Hono product routes, use c.get('services').images(body, width) after authorizing source access, or import resizeImage from @workspace/images/server with env.IMAGES and an R2 object's body. The binding transforms raw bytes; it is not an Images hosted-upload service or an R2 replacement. Public image caching requires a separate reviewed visibility/cache policy; private responses are no-store. Enforce upload size/type, allowed dimensions and usage limits in product routes. No public transform/upload endpoint is generated. Activate the selected account's Images entitlement and verify actual transforms before claiming acceptance.
|
|
63
|
-
|
|
64
|
-
https://developers.cloudflare.com/images/optimization/binding/
|
|
65
|
-
`);
|
|
66
|
-
}
|
|
67
|
-
// Both services use fixed provider origins and redact provider responses in errors.
|
|
68
|
-
export function scaffoldCloudflareTransport({ root }) {
|
|
69
|
-
sharedPackage(root, 'cloudflare-api', '', { zod: STACK_DEPENDENCIES.zod });
|
|
70
|
-
rmSync(path.join(root, 'packages/cloudflare-api/src/index.ts'));
|
|
71
|
-
patchPackage(root, 'packages/cloudflare-api/package.json', {
|
|
72
|
-
exports: { './server': './src/server.ts' },
|
|
73
|
-
});
|
|
74
|
-
put(root, 'packages/cloudflare-api/src/server.ts', `import { z } from 'zod';
|
|
75
|
-
const account = z.string().regex(/^[a-f0-9]{32}$/i);
|
|
76
|
-
const payload = z.record(z.string(), z.unknown());
|
|
77
|
-
const envelope = z.object({ success: z.literal(true), result: payload.optional(), data: payload.optional() });
|
|
78
|
-
function readResult(value: unknown): Record<string, unknown> {
|
|
79
|
-
const parsed = envelope.safeParse(value);
|
|
80
|
-
if (!parsed.success) throw new Error('Invalid Cloudflare service response.');
|
|
81
|
-
const result = parsed.data.result ?? parsed.data.data;
|
|
82
|
-
if (!result) throw new Error('Missing Cloudflare service response.');
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
export function cloudflareClient(accountId: string, apiToken: string, service: string) {
|
|
86
|
-
account.parse(accountId);
|
|
87
|
-
z.string().trim().min(1).parse(apiToken);
|
|
88
|
-
const base = 'https://api.cloudflare.com/client/v4/accounts/' + accountId + '/' + service;
|
|
89
|
-
return async (route: string, body: unknown): Promise<Record<string, unknown>> => {
|
|
90
|
-
const response = await fetch(base + route, { method: 'POST', redirect: 'error',
|
|
91
|
-
headers: { authorization: 'Bearer ' + apiToken, 'content-type': 'application/json' },
|
|
92
|
-
body: JSON.stringify(body), signal: AbortSignal.timeout(15000) });
|
|
93
|
-
if (!response.ok) throw new Error('Cloudflare service request failed (' + response.status + ').');
|
|
94
|
-
const value = await response.json().catch(() => { throw new Error('Invalid Cloudflare JSON response.'); });
|
|
95
|
-
return readResult(value);
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
`);
|
|
99
|
-
}
|
|
100
|
-
const cloudflareRequest = "import { cloudflareClient } from '@workspace/cloudflare-api/server';\nimport { z } from 'zod';\n";
|
|
101
|
-
export function scaffoldRealtimeKit(context) {
|
|
102
|
-
serverPackage(context, 'realtimekit', cloudflareRequest +
|
|
103
|
-
`
|
|
104
|
-
export function createRealtimeKit(options: { accountId: string; appId: string; apiToken: string }) {
|
|
105
|
-
z.string().regex(/^[a-zA-Z0-9_-]{1,128}$/).parse(options.appId);
|
|
106
|
-
const request = cloudflareClient(options.accountId, options.apiToken, 'realtime/kit/' + options.appId);
|
|
107
|
-
return {
|
|
108
|
-
// Authorize meeting creation and persist its ID/owner. Reconcile uncertain creates before retrying.
|
|
109
|
-
async createMeeting(title: string): Promise<{ id: string }> {
|
|
110
|
-
z.string().trim().min(1).max(256).parse(title);
|
|
111
|
-
const result = await request('/meetings', { title });
|
|
112
|
-
return z.object({ id: z.string().min(1) }).parse(result);
|
|
113
|
-
},
|
|
114
|
-
// Derive subject and preset on the server after checking membership; never trust a requested role.
|
|
115
|
-
async addParticipant(meetingId: string, subject: string, preset: string): Promise<{ id: string; token: string }> {
|
|
116
|
-
z.uuid().parse(meetingId);
|
|
117
|
-
z.string().min(1).parse(subject);
|
|
118
|
-
z.string().min(1).parse(preset);
|
|
119
|
-
const result = await request('/meetings/' + meetingId + '/participants', { custom_participant_id: subject, preset_name: preset });
|
|
120
|
-
return z.object({ id: z.string().min(1), token: z.string().min(1) }).parse(result);
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
`, `# Cloudflare RealtimeKit
|
|
125
|
-
|
|
126
|
-
In Hono product routes, c.get('services').realtimekit() creates the server client lazily. Alternatively import createRealtimeKit from @workspace/realtimekit/server. Configure REALTIMEKIT_ACCOUNT_ID, REALTIMEKIT_APP_ID and server-only REALTIMEKIT_API_TOKEN (scoped Realtime permission). Activate/select the app and configure participant presets manually. After authenticating and authorizing membership, derive the participant subject/preset server-side, call addParticipant, and return only that participant's token with Cache-Control: no-store. Store meeting IDs with their tenant owner; reconcile uncertain creates before retrying. No public meeting/token endpoint is generated.
|
|
127
|
-
|
|
128
|
-
Install the platform-supported RealtimeKit client SDK and implement media UI separately. Media travels between clients and Cloudflare RealtimeKit, not through Hono or D1. Verify camera/microphone permissions, tenant isolation, token revocation/expiry, reconnect and track teardown on actual target devices. RealtimeKit conferencing is distinct from Durable Object messaging (--realtime) and Stream one-to-many video (--stream / --video). Source helpers do not activate the provider or establish working calls.
|
|
129
|
-
|
|
130
|
-
https://developers.cloudflare.com/realtime/realtimekit/quickstart/
|
|
131
|
-
`, ['REALTIMEKIT_ACCOUNT_ID', 'REALTIMEKIT_APP_ID', 'REALTIMEKIT_API_TOKEN']);
|
|
132
|
-
}
|
|
133
|
-
export function scaffoldVideo(context) {
|
|
134
|
-
serverPackage(context, 'video', cloudflareRequest +
|
|
135
|
-
`
|
|
136
|
-
export function createVideo(options: { accountId: string; apiToken: string }) {
|
|
137
|
-
const request = cloudflareClient(options.accountId, options.apiToken, 'stream');
|
|
138
|
-
return {
|
|
139
|
-
// Authorize uploads and enforce tenant quotas before reserving Stream capacity.
|
|
140
|
-
async createUpload(maxDurationSeconds: number): Promise<{ uid: string; uploadURL: string }> {
|
|
141
|
-
z.number().int().min(1).max(3600).parse(maxDurationSeconds);
|
|
142
|
-
const result = await request('/direct_upload', { maxDurationSeconds, requireSignedURLs: true,
|
|
143
|
-
expiry: new Date(Date.now() + 15 * 60 * 1000).toISOString() });
|
|
144
|
-
const value = z.object({ uid: z.string().min(1), uploadURL: z.url() }).parse(result);
|
|
145
|
-
const url = new URL(value.uploadURL);
|
|
146
|
-
z.literal('https:').parse(url.protocol);
|
|
147
|
-
z.string().endsWith('.videodelivery.net').parse(url.hostname);
|
|
148
|
-
z.literal('').parse(url.username + url.password);
|
|
149
|
-
return value;
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
`, `# Cloudflare Stream video uploads
|
|
154
|
-
|
|
155
|
-
In Hono product routes, use c.get('services').video() after authorization. Alternatively import createVideo from @workspace/video/server with STREAM_ACCOUNT_ID and STREAM_API_TOKEN (Stream Write). This is on-demand uploaded video, separate from --stream's WHIP/WHEP live input helper. Authenticate/authorize creators, enforce tenant quotas, then issue a one-time direct upload URL; persist uid and ownership and return it only to the authorized creator with no-store. Basic POST uploads are limited to 200 MB; implement TUS separately for larger/unreliable uploads. Processing completion/webhooks, video UI, retention/deletion and private playback token issuance remain product work. Upload completion is not processing readiness. Signed playback is required by this helper; implement and verify short-lived viewer tokens before exposing playback. Do not proxy video bytes through Hono or expose the management token. Stream account activation and stored/delivered video billing are explicit owner setup, not init side effects.
|
|
156
|
-
|
|
157
|
-
https://developers.cloudflare.com/stream/uploading-videos/direct-creator-uploads/
|
|
158
|
-
`, ['STREAM_ACCOUNT_ID', 'STREAM_API_TOKEN']);
|
|
159
|
-
}
|
|
160
|
-
/** Lazy Hono adapters wire selected helpers without exposing generic public routes. */
|
|
161
|
-
export function scaffoldCloudflareServiceContext({ root, has }) {
|
|
162
|
-
const selected = ['analytics-engine', 'images', 'realtimekit', 'video'].filter(has);
|
|
163
|
-
if (!selected.length)
|
|
164
|
-
return;
|
|
165
|
-
const imports = [];
|
|
166
|
-
const adapters = [];
|
|
167
|
-
if (has('analytics-engine')) {
|
|
168
|
-
imports.push("import { recordEvent } from '@workspace/analytics-engine/server';");
|
|
169
|
-
adapters.push('analytics: (tenant: string, event: string, value = 1) => recordEvent(env.EVENTS, tenant, event, value)');
|
|
170
|
-
}
|
|
171
|
-
if (has('images')) {
|
|
172
|
-
imports.push("import { resizeImage } from '@workspace/images/server';");
|
|
173
|
-
adapters.push('images: (body: ReadableStream<Uint8Array>, width: number) => resizeImage(env.IMAGES, body, width)');
|
|
174
|
-
}
|
|
175
|
-
if (has('realtimekit')) {
|
|
176
|
-
imports.push("import { createRealtimeKit } from '@workspace/realtimekit/server';");
|
|
177
|
-
adapters.push('realtimekit: () => createRealtimeKit({ accountId: env.REALTIMEKIT_ACCOUNT_ID, appId: env.REALTIMEKIT_APP_ID, apiToken: env.REALTIMEKIT_API_TOKEN })');
|
|
178
|
-
}
|
|
179
|
-
if (has('video')) {
|
|
180
|
-
imports.push("import { createVideo } from '@workspace/video/server';");
|
|
181
|
-
adapters.push('video: () => createVideo({ accountId: env.STREAM_ACCOUNT_ID, apiToken: env.STREAM_API_TOKEN })');
|
|
182
|
-
}
|
|
183
|
-
put(root, 'apps/api/src/services.ts', imports.join('\n') +
|
|
184
|
-
'\n\n// Call after product authorization and quota checks; no service is activated at startup.\nexport function createServices(env: Env) {\n return {\n ' +
|
|
185
|
-
adapters.join(',\n ') +
|
|
186
|
-
',\n };\n}\n');
|
|
187
|
-
const file = 'apps/api/src/index.ts';
|
|
188
|
-
let source = readFileSync(path.join(root, file), 'utf8');
|
|
189
|
-
if (source.includes("import { createServices } from './services';"))
|
|
190
|
-
return;
|
|
191
|
-
source = "import { createServices } from './services';\n" + source;
|
|
192
|
-
if (source.includes('Variables: {'))
|
|
193
|
-
source = source.replace('Variables: {', 'Variables: { services: ReturnType<typeof createServices>;');
|
|
194
|
-
else
|
|
195
|
-
source = source.replace('Bindings: Env', 'Bindings: Env; Variables: { services: ReturnType<typeof createServices> }');
|
|
196
|
-
source = source.replace('const health = createRoute({', "// Product routes use c.get('services') after authorization.\napp.use('/api/*', async (c, next) => {\n c.set('services', createServices(c.env));\n await next();\n});\nconst health = createRoute({");
|
|
197
|
-
put(root, file, source);
|
|
198
|
-
}
|
package/dist/scaffold/lint.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Fresh bootstrap only: framework-specific lint tooling belongs to its app. */
|
|
2
|
-
export declare function normalizeSharedLint(root: string): void;
|
|
3
|
-
/** Keep the starter's React/TypeScript rules and add the web app's Next API rules. */
|
|
4
|
-
export declare function writeWebLint(root: string): void;
|
package/dist/scaffold/lint.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { existsSync, rmSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { json, put, readJson } from './files.js';
|
|
4
|
-
/** Fresh bootstrap only: framework-specific lint tooling belongs to its app. */
|
|
5
|
-
export function normalizeSharedLint(root) {
|
|
6
|
-
const file = 'packages/eslint-config/package.json';
|
|
7
|
-
if (!existsSync(path.join(root, file)))
|
|
8
|
-
return;
|
|
9
|
-
const manifest = readJson(root, file);
|
|
10
|
-
for (const group of [
|
|
11
|
-
'dependencies',
|
|
12
|
-
'devDependencies',
|
|
13
|
-
'peerDependencies',
|
|
14
|
-
'optionalDependencies',
|
|
15
|
-
]) {
|
|
16
|
-
const dependencies = manifest[group];
|
|
17
|
-
if (dependencies && typeof dependencies === 'object' && !Array.isArray(dependencies))
|
|
18
|
-
delete dependencies['@next/eslint-plugin-next'];
|
|
19
|
-
}
|
|
20
|
-
if (manifest.exports && typeof manifest.exports === 'object' && !Array.isArray(manifest.exports))
|
|
21
|
-
delete manifest.exports['./next-js'];
|
|
22
|
-
json(root, file, manifest);
|
|
23
|
-
rmSync(path.join(root, 'packages/eslint-config/next.js'), { force: true });
|
|
24
|
-
}
|
|
25
|
-
/** Keep the starter's React/TypeScript rules and add the web app's Next API rules. */
|
|
26
|
-
export function writeWebLint(root) {
|
|
27
|
-
put(root, 'apps/web/eslint.config.js', `import { globalIgnores } from 'eslint/config';
|
|
28
|
-
import pluginNext from '@next/eslint-plugin-next';
|
|
29
|
-
import typescriptParser from '@typescript-eslint/parser';
|
|
30
|
-
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
31
|
-
import { config as reactConfig } from '@workspace/eslint-config/react-internal';
|
|
32
|
-
|
|
33
|
-
export default [
|
|
34
|
-
...reactConfig,
|
|
35
|
-
{
|
|
36
|
-
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
|
|
37
|
-
languageOptions: { parser: typescriptParser, parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
38
|
-
plugins: { '@typescript-eslint': typescriptPlugin },
|
|
39
|
-
rules: { 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'error' },
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
files: ['**/*.{ts,tsx}'],
|
|
43
|
-
// TypeScript checks undefined names; ESLint's core rule cannot model types.
|
|
44
|
-
rules: { 'no-undef': 'off' },
|
|
45
|
-
},
|
|
46
|
-
globalIgnores(['.next/**', 'out/**', 'build/**', 'next-env.d.ts', '.open-next/**', '.wrangler/**', '.void/**', 'dist/**', 'cloudflare-env.d.ts']),
|
|
47
|
-
{
|
|
48
|
-
plugins: { '@next/next': pluginNext },
|
|
49
|
-
rules: {
|
|
50
|
-
...pluginNext.configs.recommended.rules,
|
|
51
|
-
...pluginNext.configs['core-web-vitals'].rules,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
`);
|
|
56
|
-
}
|