@bleedingdev/modern-js-sandpack-react 3.2.0-ultramodern.28 → 3.2.0-ultramodern.29
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.
|
@@ -47,8 +47,8 @@ const MWAFiles = {
|
|
|
47
47
|
"scripts/bootstrap-agent-skills.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst lockPath = path.join(root, '.agents/skills-lock.json');\nconst checkOnly = process.argv.includes('--check');\nconst force = process.argv.includes('--force');\n\nconst readJson = (filePath) => JSON.parse(fs.readFileSync(filePath, 'utf-8'));\n\nconst run = (command, args, options = {}) =>\n execFileSync(command, args, {\n cwd: options.cwd ?? root,\n encoding: 'utf-8',\n stdio: options.stdio ?? ['ignore', 'pipe', 'pipe'],\n });\n\nconst cloneSource = (source, targetDir) => {\n const repo = source.repository.replace(/^https:\\/\\/github.com\\//u, '');\n try {\n run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1'], {\n stdio: 'inherit',\n });\n } catch {\n run('git', ['clone', '--depth', '1', source.repository, targetDir], {\n stdio: 'inherit',\n });\n }\n};\n\nconst resolveSkillDir = (sourceRoot, skillName) => {\n const candidates = [\n path.join(sourceRoot, skillName),\n path.join(sourceRoot, 'skills', skillName),\n path.join(sourceRoot, 'skills', 'engineering', skillName),\n path.join(sourceRoot, 'skills', 'productivity', skillName),\n ];\n return candidates.find((candidate) => fs.existsSync(path.join(candidate, 'SKILL.md')));\n};\n\nif (!fs.existsSync(lockPath)) {\n console.error('Missing .agents/skills-lock.json');\n process.exit(1);\n}\n\nconst lock = readJson(lockPath);\nconst installDir = path.join(root, lock.installDir ?? '.agents/skills');\nconst privateSources = (lock.sources ?? []).filter(\n (source) => source.install === 'clone-if-authorized',\n);\n\nif (checkOnly) {\n const missing = privateSources.flatMap((source) =>\n (source.baseline ?? [])\n .map((skill) => skill.name)\n .filter((skillName) => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md'))),\n );\n if (missing.length > 0) {\n console.warn(\n `Private skills not installed: ${missing.join(', ')}. Run pnpm skills:install if you have access.`,\n );\n } else {\n console.log('Agent skills are installed.');\n }\n process.exit(0);\n}\n\nfs.mkdirSync(installDir, { recursive: true });\n\nfor (const source of privateSources) {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ultramodern-skills-'));\n try {\n cloneSource(source, tempDir);\n for (const skill of source.baseline ?? []) {\n const sourceSkillDir = resolveSkillDir(tempDir, skill.name);\n if (!sourceSkillDir) {\n throw new Error(`Skill ${skill.name} not found in ${source.repository}`);\n }\n const targetSkillDir = path.join(installDir, skill.name);\n if (fs.existsSync(targetSkillDir)) {\n if (!force) {\n console.log(`Skipping existing ${skill.name}`);\n continue;\n }\n fs.rmSync(targetSkillDir, { force: true, recursive: true });\n }\n fs.cpSync(sourceSkillDir, targetSkillDir, { recursive: true });\n console.log(`Installed ${skill.name}`);\n }\n } finally {\n fs.rmSync(tempDir, { force: true, recursive: true });\n }\n}\n",
|
|
48
48
|
"scripts/check-i18n-strings.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst scanRoots = ['src'].map((scanRoot) => path.join(root, scanRoot));\nconst ignoredDirectories = new Set(['.modern', '.modernjs', 'dist', 'node_modules']);\nconst visibleAttributePattern =\n /\\s(?:aria-label|alt|placeholder|title)=[\"']([^\"']*[A-Za-z][^\"']*)[\"']/gu;\nconst jsxTextPattern = />([^<>{}]*[A-Za-z][^<>{}]*)</gu;\n\nconst collectFiles = (directory) => {\n if (!fs.existsSync(directory)) {\n return [];\n }\n\n const files = [];\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!ignoredDirectories.has(entry.name)) {\n files.push(...collectFiles(path.join(directory, entry.name)));\n }\n continue;\n }\n\n if (entry.isFile() && /\\.(jsx|tsx)$/u.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n files.push(path.join(directory, entry.name));\n }\n }\n return files;\n};\n\nconst lineNumberForIndex = (content, index) => content.slice(0, index).split('\\n').length;\nconst isIgnoredLine = (content, index) => {\n const lineStart = content.lastIndexOf('\\n', index) + 1;\n const lineEnd = content.indexOf('\\n', index);\n const currentLineEnd = lineEnd === -1 ? content.length : lineEnd;\n const previousLineStart = content.lastIndexOf('\\n', Math.max(0, lineStart - 2)) + 1;\n const nextLineEnd = content.indexOf('\\n', currentLineEnd + 1);\n const context = content.slice(\n previousLineStart,\n nextLineEnd === -1 ? content.length : nextLineEnd,\n );\n return /i18n-ignore/u.test(context);\n};\n\nconst violations = [];\nfor (const filePath of scanRoots.flatMap(collectFiles)) {\n const content = fs.readFileSync(filePath, 'utf-8');\n for (const match of content.matchAll(visibleAttributePattern)) {\n if (!isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text: match[1].trim(),\n });\n }\n }\n\n for (const match of content.matchAll(jsxTextPattern)) {\n const text = match[1].replaceAll(/\\s+/gu, ' ').trim();\n if (text && !isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text,\n });\n }\n }\n}\n\nif (violations.length > 0) {\n console.error('Hardcoded user-visible JSX strings found. Move copy to locale JSON files.');\n for (const violation of violations) {\n console.error(\n `${path.relative(root, violation.filePath)}:${violation.line} ${JSON.stringify(\n violation.text,\n )}`,\n );\n }\n process.exit(1);\n}\n\nconsole.log('No hardcoded user-visible JSX strings found.');\n",
|
|
49
49
|
"scripts/validate-ultramodern.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(process.cwd(), '.modernjs/mv-template-manifest.json');\nconst packageSourcePath = path.resolve(\n process.cwd(),\n '.modernjs/ultramodern-package-source.json',\n);\nconst readPnpmConfig = (key) => {\n const env = { ...process.env };\n for (const envKey of Object.keys(env)) {\n if (/^(?:npm|pnpm)_config_/i.test(envKey)) {\n delete env[envKey];\n }\n }\n const output = execFileSync('pnpm', ['config', 'get', key, '--json'], {\n cwd: process.cwd(),\n env,\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'pipe'],\n }).trim();\n return output ? JSON.parse(output) : undefined;\n};\nconst isSubproject = ;\nconst enableTailwind = ;\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf-8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n 'i18nPlugin(',\n 'localePathRedirect: true',\n 'ULTRAMODERN_SITE_URL',\n 'MODERN_PUBLIC_SITE_URL must be set for production builds',\n 'globalVars',\n];\nconst missing = requiredTokens.filter((token) => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(`Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`);\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(fs.readFileSync(templateManifestPath, 'utf-8'));\nconst requiredDeniedPaths = [\n '.git/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'github-workflow-security-enforced',\n 'package-source-retained',\n 'pnpm-11-policy-enforced',\n 'rstest-smoke-tests',\n 'template-manifest-retained',\n];\nconst requiredPaths = [\n 'AGENTS.md',\n '.agents/skills-lock.json',\n '.github/renovate.json',\n '.github/workflows/ultramodern-gates.yml',\n 'oxlint.config.ts',\n 'oxfmt.config.ts',\n 'scripts/bootstrap-agent-skills.mjs',\n '.mise.toml',\n '.modernjs/ultramodern-package-source.json',\n 'pnpm-workspace.yaml',\n 'rstest.config.mts',\n 'scripts/check-i18n-strings.mjs',\n 'config/public/locales/en/translation.json',\n 'config/public/locales/cs/translation.json',\n 'src/modern-app-env.d.ts',\n 'src/routes/index.css',\n 'src/routes/[lang]/page.tsx',\n 'tests/ultramodern.contract.test.ts',\n];\nconst manifestErrors = [];\n\nfor (const requiredPath of requiredPaths) {\n if (!fs.existsSync(path.resolve(process.cwd(), requiredPath))) {\n console.error(`${requiredPath} not found`);\n process.exit(1);\n }\n}\n\nif (fs.existsSync(path.resolve(process.cwd(), 'src/routes/page.tsx'))) {\n console.error('src/routes/page.tsx must move under src/routes/[lang]/page.tsx');\n process.exit(1);\n}\n\nconst routeCss = fs.readFileSync(path.resolve(process.cwd(), 'src/routes/index.css'), 'utf-8');\nif (enableTailwind) {\n if (!routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must import Tailwind CSS by default');\n process.exit(1);\n }\n const postcssConfig = fs.readFileSync(path.resolve(process.cwd(), 'postcss.config.mjs'), 'utf-8');\n if (!postcssConfig.includes(\"'@tailwindcss/postcss'\")) {\n console.error('postcss.config.mjs must configure @tailwindcss/postcss');\n process.exit(1);\n }\n const tailwindConfig = fs.readFileSync(path.resolve(process.cwd(), 'tailwind.config.ts'), 'utf-8');\n if (!tailwindConfig.includes(\"content: ['./src/**/*.{js,ts,jsx,tsx}']\")) {\n console.error('tailwind.config.ts must scan generated source files');\n process.exit(1);\n }\n} else {\n if (routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must omit Tailwind CSS when disabled');\n process.exit(1);\n }\n if (\n fs.existsSync(path.resolve(process.cwd(), 'postcss.config.mjs')) ||\n fs.existsSync(path.resolve(process.cwd(), 'tailwind.config.ts'))\n ) {\n console.error('Tailwind config files must not be written when Tailwind is disabled');\n process.exit(1);\n }\n}\n\nconst workflowContent = fs.readFileSync(\n path.resolve(process.cwd(), '.github/workflows/ultramodern-gates.yml'),\n 'utf-8',\n);\nconst renovateConfig = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.github/renovate.json'), 'utf-8'),\n);\nfor (const requiredSnippet of [\n 'permissions:\\n contents: read',\n 'pull_request:',\n 'persist-credentials: false',\n 'pnpm install --frozen-lockfile',\n 'MODERN_PUBLIC_SITE_URL: http://localhost:8080',\n 'timeout-minutes:',\n 'egress-policy: audit',\n]) {\n if (!workflowContent.includes(requiredSnippet)) {\n console.error(`Generated workflow must retain ${requiredSnippet.split('\\n')[0]}`);\n process.exit(1);\n }\n}\nif (workflowContent.includes('pull_request_target')) {\n console.error('Generated workflow must not use pull_request_target');\n process.exit(1);\n}\nfor (const match of workflowContent.matchAll(/^\\s*uses:\\s*([^@\\s]+)@([^\\s#]+)/gmu)) {\n const [, actionName, actionRef] = match;\n if (!/^[a-f0-9]{40}$/u.test(actionRef)) {\n console.error(`Generated workflow must pin ${actionName}@${actionRef} to a commit SHA`);\n process.exit(1);\n }\n}\nif (\n renovateConfig.dependencyDashboard !== true ||\n renovateConfig.minimumReleaseAge !== '1 day' ||\n !renovateConfig.extends?.includes('helpers:pinGitHubActionDigests') ||\n !renovateConfig.packageRules?.some(\n (rule) =>\n rule.dependencyDashboardApproval === true && rule.matchUpdateTypes?.includes('major'),\n )\n) {\n console.error('Generated Renovate config must retain dashboard, release-age, action pinning, and major-approval policy');\n process.exit(1);\n}\n\nconst pageContent = fs.readFileSync(\n path.resolve(process.cwd(), 'src/routes/[lang]/page.tsx'),\n 'utf-8',\n);\nfor (const token of [\n 'rel=\"canonical\"',\n 'rel=\"alternate\"',\n 'hrefLang=\"x-default\"',\n 'localizedPath(',\n '<a',\n]) {\n if (!pageContent.includes(token)) {\n console.error(`Localized route is missing ${token}`);\n process.exit(1);\n }\n}\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n (checksum) =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/u.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(', ')}`,\n );\n process.exit(1);\n}\n\nconst packageJson = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8'),\n);\nconst packageSource = JSON.parse(fs.readFileSync(packageSourcePath, 'utf-8'));\nconst unresolvedTemplateMarker = String.fromCodePoint(123, 123);\nif (JSON.stringify(packageJson).includes(unresolvedTemplateMarker)) {\n console.error('package.json contains unresolved template markers');\n process.exit(1);\n}\nif (JSON.stringify(packageSource).includes(unresolvedTemplateMarker)) {\n console.error('package source metadata contains unresolved template markers');\n process.exit(1);\n}\nconst skillsLock = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.agents/skills-lock.json'), 'utf-8'),\n);\nconst requiredScripts = {\n 'i18n:check': 'node ./scripts/check-i18n-strings.mjs',\n test: 'rstest run',\n format: 'oxfmt .',\n 'format:check': 'oxfmt --check .',\n lint: 'oxlint .',\n 'lint:fix': 'oxlint . --fix',\n 'skills:check': 'node ./scripts/bootstrap-agent-skills.mjs --check',\n 'skills:install': 'node ./scripts/bootstrap-agent-skills.mjs',\n};\n\nfor (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {\n if (packageJson.scripts?.[scriptName] !== scriptCommand) {\n console.error(`Missing or invalid package script: ${scriptName}`);\n process.exit(1);\n }\n}\n\nif (\n !packageJson.scripts?.typecheck?.includes('effect-tsgo') ||\n !packageJson.scripts.typecheck.includes('get-exe-path')\n) {\n console.error('typecheck must use effect-tsgo as the TypeScript checker');\n process.exit(1);\n}\n\nif (!packageJson.scripts?.['ultramodern:check']?.includes('pnpm test')) {\n console.error('ultramodern:check must run the generated Rstest suite');\n process.exit(1);\n}\n\nif (packageJson.private !== true) {\n console.error('Generated app package must be private by default');\n process.exit(1);\n}\n\nif (packageJson.packageManager !== 'pnpm@11.4.0') {\n console.error('Generated app package must pin pnpm@11.4.0');\n process.exit(1);\n}\n\nif (packageJson.engines?.pnpm !== '>=11.4.0 <11.5.0') {\n console.error('Generated app package must require pnpm >=11.4.0 <11.5.0');\n process.exit(1);\n}\n\nif (packageJson.pnpm !== undefined) {\n console.error('Generated app must keep pnpm policy in pnpm-workspace.yaml, not package.json');\n process.exit(1);\n}\n\nif (readPnpmConfig('minimumReleaseAge') !== 1440) {\n console.error('pnpm minimumReleaseAge must be 1440');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeStrict') !== true) {\n console.error('pnpm minimumReleaseAgeStrict must be true');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeIgnoreMissingTime') !== false) {\n console.error('pnpm minimumReleaseAgeIgnoreMissingTime must be false');\n process.exit(1);\n}\nif (\n JSON.stringify(readPnpmConfig('minimumReleaseAgeExclude')) !==\n JSON.stringify([\n '@modern-js/*',\n '@bleedingdev/*',\n '@effect/tsgo',\n '@effect/tsgo-*',\n '@typescript/native-preview',\n '@typescript/native-preview-*',\n ])\n) {\n console.error('pnpm minimumReleaseAgeExclude must retain framework exceptions');\n process.exit(1);\n}\nif (readPnpmConfig('trustPolicy') !== 'no-downgrade') {\n console.error('pnpm trustPolicy must be no-downgrade');\n process.exit(1);\n}\nfor (const [key, expected] of [\n ['trustPolicyIgnoreAfter', 1440],\n ['blockExoticSubdeps', true],\n ['engineStrict', true],\n ['pmOnFail', 'error'],\n ['verifyDepsBeforeRun', 'error'],\n ['strictDepBuilds', true],\n]) {\n if (readPnpmConfig(key) !== expected) {\n console.error(`pnpm ${key} must be ${String(expected)}`);\n process.exit(1);\n }\n}\nif (\n JSON.stringify(readPnpmConfig('allowBuilds')) !==\n JSON.stringify({\n '@swc/core': true,\n 'core-js': true,\n esbuild: true,\n 'msgpackr-extract': true,\n sharp: true,\n 'simple-git-hooks': true,\n workerd: true,\n })\n) {\n console.error('pnpm allowBuilds must approve only the generated app build dependencies');\n process.exit(1);\n}\nif (readPnpmConfig('onlyBuiltDependencies') !== undefined) {\n console.error('pnpm onlyBuiltDependencies must not be set');\n process.exit(1);\n}\n\nif (packageJson.modernjs?.preset !== 'presetUltramodern') {\n console.error('package.json must declare presetUltramodern metadata');\n process.exit(1);\n}\n\nif (\n packageJson.modernjs?.packageSource?.config !== './.modernjs/ultramodern-package-source.json'\n) {\n console.error('package.json must retain package source metadata location');\n process.exit(1);\n}\n\nif (packageSource.schemaVersion !== 1) {\n console.error('Package source metadata must use schemaVersion 1');\n process.exit(1);\n}\n\nif (packageSource.preset !== 'presetUltramodern') {\n console.error('Package source metadata must declare presetUltramodern');\n process.exit(1);\n}\n\nif (packageSource.strategy !== 'workspace' && packageSource.strategy !== 'install') {\n console.error('Package source strategy must be workspace or install');\n process.exit(1);\n}\n\nconst expectedModernPackages = [\n '@modern-js/runtime',\n '@modern-js/app-tools',\n '@modern-js/tsconfig',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n '@modern-js/plugin-bff',\n '@modern-js/adapter-rstest',\n];\n\nfor (const packageName of expectedModernPackages) {\n if (!packageSource.modernPackages?.packages?.includes(packageName)) {\n console.error(`Package source metadata must include ${packageName}`);\n process.exit(1);\n }\n}\n\nconst expectedModernSpecifier = packageSource.modernPackages?.specifier;\nif (typeof expectedModernSpecifier !== 'string' || expectedModernSpecifier.length === 0) {\n console.error('Package source metadata must provide a Modern package specifier');\n process.exit(1);\n}\n\nconst expectedModernDependency = (packageName) => {\n const alias = packageSource.modernPackages?.aliases?.[packageName];\n return typeof alias === 'string'\n ? `npm:${alias}@${expectedModernSpecifier}`\n : expectedModernSpecifier;\n};\n\nfor (const packageName of [\n '@modern-js/runtime',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n]) {\n if (\n packageJson.dependencies?.[packageName] &&\n packageJson.dependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const packageName of [\n '@modern-js/app-tools',\n '@modern-js/adapter-rstest',\n '@modern-js/tsconfig',\n '@modern-js/plugin-bff',\n]) {\n if (\n packageJson.devDependencies?.[packageName] &&\n packageJson.devDependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dev dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const dependency of ['@modern-js/plugin-i18n', 'i18next', 'react-i18next']) {\n if (!packageJson.dependencies?.[dependency]) {\n console.error(`Missing dependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nfor (const dependency of [\n '@effect/tsgo',\n '@modern-js/adapter-rstest',\n '@rstest/core',\n '@typescript/native-preview',\n 'happy-dom',\n 'oxlint',\n 'oxfmt',\n 'ultracite',\n]) {\n if (!packageJson.devDependencies?.[dependency]) {\n console.error(`Missing devDependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nif (\n packageJson.devDependencies?.tailwindcss ||\n packageJson.devDependencies?.['@tailwindcss/postcss'] ||\n packageJson.devDependencies?.postcss\n) {\n console.error('Tailwind CSS dependencies must be absent when Tailwind is disabled');\n process.exit(1);\n}\n\nconst privateSource = skillsLock.sources?.find(\n (source) => source.repository === 'https://github.com/TechsioCZ/skills',\n);\nconst privateSkills = new Set(privateSource?.baseline?.map((skill) => skill.name));\nfor (const skillName of ['plan-graph', 'dag', 'subagent-graph', 'helm', 'debugger-mode']) {\n if (!privateSkills.has(skillName)) {\n console.error(`Missing private skill allowlist entry: ${skillName}`);\n process.exit(1);\n }\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
50
|
-
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
51
50
|
"tests/ultramodern.contract.test.ts": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { describe, expect, test } from '@rstest/core';\n\nconst root = process.cwd();\nconst readText = (relativePath: string) =>\n fs.readFileSync(path.join(root, relativePath), 'utf-8');\nconst readJson = <T>(relativePath: string): T =>\n JSON.parse(readText(relativePath)) as T;\n\ndescribe('generated UltraModern contract', () => {\n test('keeps localized route metadata and Rstest wiring', () => {\n expect(fs.existsSync(path.join(root, 'src/routes/[lang]/page.tsx'))).toBe(\n true,\n );\n expect(fs.existsSync(path.join(root, 'src/routes/page.tsx'))).toBe(false);\n\n const page = readText('src/routes/[lang]/page.tsx');\n expect(page).toContain('rel=\"canonical\"');\n expect(page).toContain('rel=\"alternate\"');\n expect(page).toContain('hrefLang=\"x-default\"');\n expect(page).toContain('localizedPath(');\n expect(readText('src/routes/index.css')).not.toContain(\n \"@import 'tailwindcss';\",\n );\n expect(fs.existsSync(path.join(root, 'postcss.config.mjs'))).toBe(false);\n expect(fs.existsSync(path.join(root, 'tailwind.config.ts'))).toBe(false);\n\n const config = readText('rstest.config.mts');\n expect(config).toContain(\"withModernConfig()\");\n expect(config).toContain(\"testEnvironment: 'happy-dom'\");\n });\n\n test('retains package-source metadata for generated Modern.js packages', () => {\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n modernjs?: {\n packageSource?: {\n config?: string;\n };\n preset?: string;\n };\n }>('package.json');\n const packageSource = readJson<{\n modernPackages?: {\n packages?: string[];\n specifier?: string;\n };\n strategy?: string;\n }>('.modernjs/ultramodern-package-source.json');\n\n expect(packageJson.modernjs?.preset).toBe('presetUltramodern');\n expect(packageJson.modernjs?.packageSource?.config).toBe(\n './.modernjs/ultramodern-package-source.json',\n );\n expect(packageSource.strategy).toMatch(/^(workspace|install)$/u);\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/runtime',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/app-tools',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/adapter-rstest',\n );\n expect(packageSource.modernPackages?.specifier).toBeTruthy();\n expect(\n packageJson.devDependencies?.['@modern-js/adapter-rstest'],\n ).toBeTruthy();\n expect(packageJson.devDependencies?.tailwindcss).toBeUndefined();\n expect(\n packageJson.devDependencies?.['@tailwindcss/postcss'],\n ).toBeUndefined();\n });\n});\n",
|
|
51
|
+
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
52
52
|
".github/renovate.json": "{\n \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n \"extends\": [\n \"config:recommended\",\n \"helpers:pinGitHubActionDigests\"\n ],\n \"dependencyDashboard\": true,\n \"minimumReleaseAge\": \"1 day\",\n \"prConcurrentLimit\": 5,\n \"prHourlyLimit\": 2,\n \"rangeStrategy\": \"bump\",\n \"schedule\": [\n \"before 5am on monday\"\n ],\n \"timezone\": \"Etc/UTC\",\n \"packageRules\": [\n {\n \"matchManagers\": [\n \"github-actions\"\n ],\n \"groupName\": \"github-actions\",\n \"labels\": [\n \"dependencies\",\n \"github-actions\",\n \"security\"\n ]\n },\n {\n \"matchManagers\": [\n \"npm\"\n ],\n \"matchUpdateTypes\": [\n \"patch\",\n \"minor\"\n ],\n \"groupName\": \"npm minor and patch updates\",\n \"labels\": [\n \"dependencies\",\n \"npm\"\n ]\n },\n {\n \"matchUpdateTypes\": [\n \"major\"\n ],\n \"dependencyDashboardApproval\": true,\n \"labels\": [\n \"dependencies\",\n \"major\"\n ]\n }\n ]\n}\n",
|
|
53
53
|
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\npermissions:\n contents: read\n\ndefaults:\n run:\n shell: bash\n\nenv:\n FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true\n\nconcurrency:\n group: ultramodern-gates-$-$\n cancel-in-progress: true\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n timeout-minutes: 20\n steps:\n - name: Harden Runner\n uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2\n with:\n egress-policy: audit\n\n - name: Checkout\n uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5\n with:\n fetch-depth: 1\n persist-credentials: false\n\n - name: Setup pnpm\n uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8\n\n - name: Setup Node.js\n uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5\n with:\n node-version: 24\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install --frozen-lockfile\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n env:\n MODERN_PUBLIC_SITE_URL: http://localhost:8080\n run: pnpm run build\n",
|
|
54
54
|
"api/effect/index.ts": "\n",
|
|
@@ -19,8 +19,8 @@ const MWAFiles = {
|
|
|
19
19
|
"scripts/bootstrap-agent-skills.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst lockPath = path.join(root, '.agents/skills-lock.json');\nconst checkOnly = process.argv.includes('--check');\nconst force = process.argv.includes('--force');\n\nconst readJson = (filePath) => JSON.parse(fs.readFileSync(filePath, 'utf-8'));\n\nconst run = (command, args, options = {}) =>\n execFileSync(command, args, {\n cwd: options.cwd ?? root,\n encoding: 'utf-8',\n stdio: options.stdio ?? ['ignore', 'pipe', 'pipe'],\n });\n\nconst cloneSource = (source, targetDir) => {\n const repo = source.repository.replace(/^https:\\/\\/github.com\\//u, '');\n try {\n run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1'], {\n stdio: 'inherit',\n });\n } catch {\n run('git', ['clone', '--depth', '1', source.repository, targetDir], {\n stdio: 'inherit',\n });\n }\n};\n\nconst resolveSkillDir = (sourceRoot, skillName) => {\n const candidates = [\n path.join(sourceRoot, skillName),\n path.join(sourceRoot, 'skills', skillName),\n path.join(sourceRoot, 'skills', 'engineering', skillName),\n path.join(sourceRoot, 'skills', 'productivity', skillName),\n ];\n return candidates.find((candidate) => fs.existsSync(path.join(candidate, 'SKILL.md')));\n};\n\nif (!fs.existsSync(lockPath)) {\n console.error('Missing .agents/skills-lock.json');\n process.exit(1);\n}\n\nconst lock = readJson(lockPath);\nconst installDir = path.join(root, lock.installDir ?? '.agents/skills');\nconst privateSources = (lock.sources ?? []).filter(\n (source) => source.install === 'clone-if-authorized',\n);\n\nif (checkOnly) {\n const missing = privateSources.flatMap((source) =>\n (source.baseline ?? [])\n .map((skill) => skill.name)\n .filter((skillName) => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md'))),\n );\n if (missing.length > 0) {\n console.warn(\n `Private skills not installed: ${missing.join(', ')}. Run pnpm skills:install if you have access.`,\n );\n } else {\n console.log('Agent skills are installed.');\n }\n process.exit(0);\n}\n\nfs.mkdirSync(installDir, { recursive: true });\n\nfor (const source of privateSources) {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ultramodern-skills-'));\n try {\n cloneSource(source, tempDir);\n for (const skill of source.baseline ?? []) {\n const sourceSkillDir = resolveSkillDir(tempDir, skill.name);\n if (!sourceSkillDir) {\n throw new Error(`Skill ${skill.name} not found in ${source.repository}`);\n }\n const targetSkillDir = path.join(installDir, skill.name);\n if (fs.existsSync(targetSkillDir)) {\n if (!force) {\n console.log(`Skipping existing ${skill.name}`);\n continue;\n }\n fs.rmSync(targetSkillDir, { force: true, recursive: true });\n }\n fs.cpSync(sourceSkillDir, targetSkillDir, { recursive: true });\n console.log(`Installed ${skill.name}`);\n }\n } finally {\n fs.rmSync(tempDir, { force: true, recursive: true });\n }\n}\n",
|
|
20
20
|
"scripts/check-i18n-strings.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst scanRoots = ['src'].map((scanRoot) => path.join(root, scanRoot));\nconst ignoredDirectories = new Set(['.modern', '.modernjs', 'dist', 'node_modules']);\nconst visibleAttributePattern =\n /\\s(?:aria-label|alt|placeholder|title)=[\"']([^\"']*[A-Za-z][^\"']*)[\"']/gu;\nconst jsxTextPattern = />([^<>{}]*[A-Za-z][^<>{}]*)</gu;\n\nconst collectFiles = (directory) => {\n if (!fs.existsSync(directory)) {\n return [];\n }\n\n const files = [];\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!ignoredDirectories.has(entry.name)) {\n files.push(...collectFiles(path.join(directory, entry.name)));\n }\n continue;\n }\n\n if (entry.isFile() && /\\.(jsx|tsx)$/u.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n files.push(path.join(directory, entry.name));\n }\n }\n return files;\n};\n\nconst lineNumberForIndex = (content, index) => content.slice(0, index).split('\\n').length;\nconst isIgnoredLine = (content, index) => {\n const lineStart = content.lastIndexOf('\\n', index) + 1;\n const lineEnd = content.indexOf('\\n', index);\n const currentLineEnd = lineEnd === -1 ? content.length : lineEnd;\n const previousLineStart = content.lastIndexOf('\\n', Math.max(0, lineStart - 2)) + 1;\n const nextLineEnd = content.indexOf('\\n', currentLineEnd + 1);\n const context = content.slice(\n previousLineStart,\n nextLineEnd === -1 ? content.length : nextLineEnd,\n );\n return /i18n-ignore/u.test(context);\n};\n\nconst violations = [];\nfor (const filePath of scanRoots.flatMap(collectFiles)) {\n const content = fs.readFileSync(filePath, 'utf-8');\n for (const match of content.matchAll(visibleAttributePattern)) {\n if (!isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text: match[1].trim(),\n });\n }\n }\n\n for (const match of content.matchAll(jsxTextPattern)) {\n const text = match[1].replaceAll(/\\s+/gu, ' ').trim();\n if (text && !isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text,\n });\n }\n }\n}\n\nif (violations.length > 0) {\n console.error('Hardcoded user-visible JSX strings found. Move copy to locale JSON files.');\n for (const violation of violations) {\n console.error(\n `${path.relative(root, violation.filePath)}:${violation.line} ${JSON.stringify(\n violation.text,\n )}`,\n );\n }\n process.exit(1);\n}\n\nconsole.log('No hardcoded user-visible JSX strings found.');\n",
|
|
21
21
|
"scripts/validate-ultramodern.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(process.cwd(), '.modernjs/mv-template-manifest.json');\nconst packageSourcePath = path.resolve(\n process.cwd(),\n '.modernjs/ultramodern-package-source.json',\n);\nconst readPnpmConfig = (key) => {\n const env = { ...process.env };\n for (const envKey of Object.keys(env)) {\n if (/^(?:npm|pnpm)_config_/i.test(envKey)) {\n delete env[envKey];\n }\n }\n const output = execFileSync('pnpm', ['config', 'get', key, '--json'], {\n cwd: process.cwd(),\n env,\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'pipe'],\n }).trim();\n return output ? JSON.parse(output) : undefined;\n};\nconst isSubproject = ;\nconst enableTailwind = ;\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf-8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n 'i18nPlugin(',\n 'localePathRedirect: true',\n 'ULTRAMODERN_SITE_URL',\n 'MODERN_PUBLIC_SITE_URL must be set for production builds',\n 'globalVars',\n];\nconst missing = requiredTokens.filter((token) => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(`Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`);\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(fs.readFileSync(templateManifestPath, 'utf-8'));\nconst requiredDeniedPaths = [\n '.git/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'github-workflow-security-enforced',\n 'package-source-retained',\n 'pnpm-11-policy-enforced',\n 'rstest-smoke-tests',\n 'template-manifest-retained',\n];\nconst requiredPaths = [\n 'AGENTS.md',\n '.agents/skills-lock.json',\n '.github/renovate.json',\n '.github/workflows/ultramodern-gates.yml',\n 'oxlint.config.ts',\n 'oxfmt.config.ts',\n 'scripts/bootstrap-agent-skills.mjs',\n '.mise.toml',\n '.modernjs/ultramodern-package-source.json',\n 'pnpm-workspace.yaml',\n 'rstest.config.mts',\n 'scripts/check-i18n-strings.mjs',\n 'config/public/locales/en/translation.json',\n 'config/public/locales/cs/translation.json',\n 'src/modern-app-env.d.ts',\n 'src/routes/index.css',\n 'src/routes/[lang]/page.tsx',\n 'tests/ultramodern.contract.test.ts',\n];\nconst manifestErrors = [];\n\nfor (const requiredPath of requiredPaths) {\n if (!fs.existsSync(path.resolve(process.cwd(), requiredPath))) {\n console.error(`${requiredPath} not found`);\n process.exit(1);\n }\n}\n\nif (fs.existsSync(path.resolve(process.cwd(), 'src/routes/page.tsx'))) {\n console.error('src/routes/page.tsx must move under src/routes/[lang]/page.tsx');\n process.exit(1);\n}\n\nconst routeCss = fs.readFileSync(path.resolve(process.cwd(), 'src/routes/index.css'), 'utf-8');\nif (enableTailwind) {\n if (!routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must import Tailwind CSS by default');\n process.exit(1);\n }\n const postcssConfig = fs.readFileSync(path.resolve(process.cwd(), 'postcss.config.mjs'), 'utf-8');\n if (!postcssConfig.includes(\"'@tailwindcss/postcss'\")) {\n console.error('postcss.config.mjs must configure @tailwindcss/postcss');\n process.exit(1);\n }\n const tailwindConfig = fs.readFileSync(path.resolve(process.cwd(), 'tailwind.config.ts'), 'utf-8');\n if (!tailwindConfig.includes(\"content: ['./src/**/*.{js,ts,jsx,tsx}']\")) {\n console.error('tailwind.config.ts must scan generated source files');\n process.exit(1);\n }\n} else {\n if (routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must omit Tailwind CSS when disabled');\n process.exit(1);\n }\n if (\n fs.existsSync(path.resolve(process.cwd(), 'postcss.config.mjs')) ||\n fs.existsSync(path.resolve(process.cwd(), 'tailwind.config.ts'))\n ) {\n console.error('Tailwind config files must not be written when Tailwind is disabled');\n process.exit(1);\n }\n}\n\nconst workflowContent = fs.readFileSync(\n path.resolve(process.cwd(), '.github/workflows/ultramodern-gates.yml'),\n 'utf-8',\n);\nconst renovateConfig = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.github/renovate.json'), 'utf-8'),\n);\nfor (const requiredSnippet of [\n 'permissions:\\n contents: read',\n 'pull_request:',\n 'persist-credentials: false',\n 'pnpm install --frozen-lockfile',\n 'MODERN_PUBLIC_SITE_URL: http://localhost:8080',\n 'timeout-minutes:',\n 'egress-policy: audit',\n]) {\n if (!workflowContent.includes(requiredSnippet)) {\n console.error(`Generated workflow must retain ${requiredSnippet.split('\\n')[0]}`);\n process.exit(1);\n }\n}\nif (workflowContent.includes('pull_request_target')) {\n console.error('Generated workflow must not use pull_request_target');\n process.exit(1);\n}\nfor (const match of workflowContent.matchAll(/^\\s*uses:\\s*([^@\\s]+)@([^\\s#]+)/gmu)) {\n const [, actionName, actionRef] = match;\n if (!/^[a-f0-9]{40}$/u.test(actionRef)) {\n console.error(`Generated workflow must pin ${actionName}@${actionRef} to a commit SHA`);\n process.exit(1);\n }\n}\nif (\n renovateConfig.dependencyDashboard !== true ||\n renovateConfig.minimumReleaseAge !== '1 day' ||\n !renovateConfig.extends?.includes('helpers:pinGitHubActionDigests') ||\n !renovateConfig.packageRules?.some(\n (rule) =>\n rule.dependencyDashboardApproval === true && rule.matchUpdateTypes?.includes('major'),\n )\n) {\n console.error('Generated Renovate config must retain dashboard, release-age, action pinning, and major-approval policy');\n process.exit(1);\n}\n\nconst pageContent = fs.readFileSync(\n path.resolve(process.cwd(), 'src/routes/[lang]/page.tsx'),\n 'utf-8',\n);\nfor (const token of [\n 'rel=\"canonical\"',\n 'rel=\"alternate\"',\n 'hrefLang=\"x-default\"',\n 'localizedPath(',\n '<a',\n]) {\n if (!pageContent.includes(token)) {\n console.error(`Localized route is missing ${token}`);\n process.exit(1);\n }\n}\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n (checksum) =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/u.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(', ')}`,\n );\n process.exit(1);\n}\n\nconst packageJson = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8'),\n);\nconst packageSource = JSON.parse(fs.readFileSync(packageSourcePath, 'utf-8'));\nconst unresolvedTemplateMarker = String.fromCodePoint(123, 123);\nif (JSON.stringify(packageJson).includes(unresolvedTemplateMarker)) {\n console.error('package.json contains unresolved template markers');\n process.exit(1);\n}\nif (JSON.stringify(packageSource).includes(unresolvedTemplateMarker)) {\n console.error('package source metadata contains unresolved template markers');\n process.exit(1);\n}\nconst skillsLock = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.agents/skills-lock.json'), 'utf-8'),\n);\nconst requiredScripts = {\n 'i18n:check': 'node ./scripts/check-i18n-strings.mjs',\n test: 'rstest run',\n format: 'oxfmt .',\n 'format:check': 'oxfmt --check .',\n lint: 'oxlint .',\n 'lint:fix': 'oxlint . --fix',\n 'skills:check': 'node ./scripts/bootstrap-agent-skills.mjs --check',\n 'skills:install': 'node ./scripts/bootstrap-agent-skills.mjs',\n};\n\nfor (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {\n if (packageJson.scripts?.[scriptName] !== scriptCommand) {\n console.error(`Missing or invalid package script: ${scriptName}`);\n process.exit(1);\n }\n}\n\nif (\n !packageJson.scripts?.typecheck?.includes('effect-tsgo') ||\n !packageJson.scripts.typecheck.includes('get-exe-path')\n) {\n console.error('typecheck must use effect-tsgo as the TypeScript checker');\n process.exit(1);\n}\n\nif (!packageJson.scripts?.['ultramodern:check']?.includes('pnpm test')) {\n console.error('ultramodern:check must run the generated Rstest suite');\n process.exit(1);\n}\n\nif (packageJson.private !== true) {\n console.error('Generated app package must be private by default');\n process.exit(1);\n}\n\nif (packageJson.packageManager !== 'pnpm@11.4.0') {\n console.error('Generated app package must pin pnpm@11.4.0');\n process.exit(1);\n}\n\nif (packageJson.engines?.pnpm !== '>=11.4.0 <11.5.0') {\n console.error('Generated app package must require pnpm >=11.4.0 <11.5.0');\n process.exit(1);\n}\n\nif (packageJson.pnpm !== undefined) {\n console.error('Generated app must keep pnpm policy in pnpm-workspace.yaml, not package.json');\n process.exit(1);\n}\n\nif (readPnpmConfig('minimumReleaseAge') !== 1440) {\n console.error('pnpm minimumReleaseAge must be 1440');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeStrict') !== true) {\n console.error('pnpm minimumReleaseAgeStrict must be true');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeIgnoreMissingTime') !== false) {\n console.error('pnpm minimumReleaseAgeIgnoreMissingTime must be false');\n process.exit(1);\n}\nif (\n JSON.stringify(readPnpmConfig('minimumReleaseAgeExclude')) !==\n JSON.stringify([\n '@modern-js/*',\n '@bleedingdev/*',\n '@effect/tsgo',\n '@effect/tsgo-*',\n '@typescript/native-preview',\n '@typescript/native-preview-*',\n ])\n) {\n console.error('pnpm minimumReleaseAgeExclude must retain framework exceptions');\n process.exit(1);\n}\nif (readPnpmConfig('trustPolicy') !== 'no-downgrade') {\n console.error('pnpm trustPolicy must be no-downgrade');\n process.exit(1);\n}\nfor (const [key, expected] of [\n ['trustPolicyIgnoreAfter', 1440],\n ['blockExoticSubdeps', true],\n ['engineStrict', true],\n ['pmOnFail', 'error'],\n ['verifyDepsBeforeRun', 'error'],\n ['strictDepBuilds', true],\n]) {\n if (readPnpmConfig(key) !== expected) {\n console.error(`pnpm ${key} must be ${String(expected)}`);\n process.exit(1);\n }\n}\nif (\n JSON.stringify(readPnpmConfig('allowBuilds')) !==\n JSON.stringify({\n '@swc/core': true,\n 'core-js': true,\n esbuild: true,\n 'msgpackr-extract': true,\n sharp: true,\n 'simple-git-hooks': true,\n workerd: true,\n })\n) {\n console.error('pnpm allowBuilds must approve only the generated app build dependencies');\n process.exit(1);\n}\nif (readPnpmConfig('onlyBuiltDependencies') !== undefined) {\n console.error('pnpm onlyBuiltDependencies must not be set');\n process.exit(1);\n}\n\nif (packageJson.modernjs?.preset !== 'presetUltramodern') {\n console.error('package.json must declare presetUltramodern metadata');\n process.exit(1);\n}\n\nif (\n packageJson.modernjs?.packageSource?.config !== './.modernjs/ultramodern-package-source.json'\n) {\n console.error('package.json must retain package source metadata location');\n process.exit(1);\n}\n\nif (packageSource.schemaVersion !== 1) {\n console.error('Package source metadata must use schemaVersion 1');\n process.exit(1);\n}\n\nif (packageSource.preset !== 'presetUltramodern') {\n console.error('Package source metadata must declare presetUltramodern');\n process.exit(1);\n}\n\nif (packageSource.strategy !== 'workspace' && packageSource.strategy !== 'install') {\n console.error('Package source strategy must be workspace or install');\n process.exit(1);\n}\n\nconst expectedModernPackages = [\n '@modern-js/runtime',\n '@modern-js/app-tools',\n '@modern-js/tsconfig',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n '@modern-js/plugin-bff',\n '@modern-js/adapter-rstest',\n];\n\nfor (const packageName of expectedModernPackages) {\n if (!packageSource.modernPackages?.packages?.includes(packageName)) {\n console.error(`Package source metadata must include ${packageName}`);\n process.exit(1);\n }\n}\n\nconst expectedModernSpecifier = packageSource.modernPackages?.specifier;\nif (typeof expectedModernSpecifier !== 'string' || expectedModernSpecifier.length === 0) {\n console.error('Package source metadata must provide a Modern package specifier');\n process.exit(1);\n}\n\nconst expectedModernDependency = (packageName) => {\n const alias = packageSource.modernPackages?.aliases?.[packageName];\n return typeof alias === 'string'\n ? `npm:${alias}@${expectedModernSpecifier}`\n : expectedModernSpecifier;\n};\n\nfor (const packageName of [\n '@modern-js/runtime',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n]) {\n if (\n packageJson.dependencies?.[packageName] &&\n packageJson.dependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const packageName of [\n '@modern-js/app-tools',\n '@modern-js/adapter-rstest',\n '@modern-js/tsconfig',\n '@modern-js/plugin-bff',\n]) {\n if (\n packageJson.devDependencies?.[packageName] &&\n packageJson.devDependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dev dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const dependency of ['@modern-js/plugin-i18n', 'i18next', 'react-i18next']) {\n if (!packageJson.dependencies?.[dependency]) {\n console.error(`Missing dependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nfor (const dependency of [\n '@effect/tsgo',\n '@modern-js/adapter-rstest',\n '@rstest/core',\n '@typescript/native-preview',\n 'happy-dom',\n 'oxlint',\n 'oxfmt',\n 'ultracite',\n]) {\n if (!packageJson.devDependencies?.[dependency]) {\n console.error(`Missing devDependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nif (\n packageJson.devDependencies?.tailwindcss ||\n packageJson.devDependencies?.['@tailwindcss/postcss'] ||\n packageJson.devDependencies?.postcss\n) {\n console.error('Tailwind CSS dependencies must be absent when Tailwind is disabled');\n process.exit(1);\n}\n\nconst privateSource = skillsLock.sources?.find(\n (source) => source.repository === 'https://github.com/TechsioCZ/skills',\n);\nconst privateSkills = new Set(privateSource?.baseline?.map((skill) => skill.name));\nfor (const skillName of ['plan-graph', 'dag', 'subagent-graph', 'helm', 'debugger-mode']) {\n if (!privateSkills.has(skillName)) {\n console.error(`Missing private skill allowlist entry: ${skillName}`);\n process.exit(1);\n }\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
22
|
-
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
23
22
|
"tests/ultramodern.contract.test.ts": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { describe, expect, test } from '@rstest/core';\n\nconst root = process.cwd();\nconst readText = (relativePath: string) =>\n fs.readFileSync(path.join(root, relativePath), 'utf-8');\nconst readJson = <T>(relativePath: string): T =>\n JSON.parse(readText(relativePath)) as T;\n\ndescribe('generated UltraModern contract', () => {\n test('keeps localized route metadata and Rstest wiring', () => {\n expect(fs.existsSync(path.join(root, 'src/routes/[lang]/page.tsx'))).toBe(\n true,\n );\n expect(fs.existsSync(path.join(root, 'src/routes/page.tsx'))).toBe(false);\n\n const page = readText('src/routes/[lang]/page.tsx');\n expect(page).toContain('rel=\"canonical\"');\n expect(page).toContain('rel=\"alternate\"');\n expect(page).toContain('hrefLang=\"x-default\"');\n expect(page).toContain('localizedPath(');\n expect(readText('src/routes/index.css')).not.toContain(\n \"@import 'tailwindcss';\",\n );\n expect(fs.existsSync(path.join(root, 'postcss.config.mjs'))).toBe(false);\n expect(fs.existsSync(path.join(root, 'tailwind.config.ts'))).toBe(false);\n\n const config = readText('rstest.config.mts');\n expect(config).toContain(\"withModernConfig()\");\n expect(config).toContain(\"testEnvironment: 'happy-dom'\");\n });\n\n test('retains package-source metadata for generated Modern.js packages', () => {\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n modernjs?: {\n packageSource?: {\n config?: string;\n };\n preset?: string;\n };\n }>('package.json');\n const packageSource = readJson<{\n modernPackages?: {\n packages?: string[];\n specifier?: string;\n };\n strategy?: string;\n }>('.modernjs/ultramodern-package-source.json');\n\n expect(packageJson.modernjs?.preset).toBe('presetUltramodern');\n expect(packageJson.modernjs?.packageSource?.config).toBe(\n './.modernjs/ultramodern-package-source.json',\n );\n expect(packageSource.strategy).toMatch(/^(workspace|install)$/u);\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/runtime',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/app-tools',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/adapter-rstest',\n );\n expect(packageSource.modernPackages?.specifier).toBeTruthy();\n expect(\n packageJson.devDependencies?.['@modern-js/adapter-rstest'],\n ).toBeTruthy();\n expect(packageJson.devDependencies?.tailwindcss).toBeUndefined();\n expect(\n packageJson.devDependencies?.['@tailwindcss/postcss'],\n ).toBeUndefined();\n });\n});\n",
|
|
23
|
+
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
24
24
|
".github/renovate.json": "{\n \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n \"extends\": [\n \"config:recommended\",\n \"helpers:pinGitHubActionDigests\"\n ],\n \"dependencyDashboard\": true,\n \"minimumReleaseAge\": \"1 day\",\n \"prConcurrentLimit\": 5,\n \"prHourlyLimit\": 2,\n \"rangeStrategy\": \"bump\",\n \"schedule\": [\n \"before 5am on monday\"\n ],\n \"timezone\": \"Etc/UTC\",\n \"packageRules\": [\n {\n \"matchManagers\": [\n \"github-actions\"\n ],\n \"groupName\": \"github-actions\",\n \"labels\": [\n \"dependencies\",\n \"github-actions\",\n \"security\"\n ]\n },\n {\n \"matchManagers\": [\n \"npm\"\n ],\n \"matchUpdateTypes\": [\n \"patch\",\n \"minor\"\n ],\n \"groupName\": \"npm minor and patch updates\",\n \"labels\": [\n \"dependencies\",\n \"npm\"\n ]\n },\n {\n \"matchUpdateTypes\": [\n \"major\"\n ],\n \"dependencyDashboardApproval\": true,\n \"labels\": [\n \"dependencies\",\n \"major\"\n ]\n }\n ]\n}\n",
|
|
25
25
|
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\npermissions:\n contents: read\n\ndefaults:\n run:\n shell: bash\n\nenv:\n FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true\n\nconcurrency:\n group: ultramodern-gates-$-$\n cancel-in-progress: true\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n timeout-minutes: 20\n steps:\n - name: Harden Runner\n uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2\n with:\n egress-policy: audit\n\n - name: Checkout\n uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5\n with:\n fetch-depth: 1\n persist-credentials: false\n\n - name: Setup pnpm\n uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8\n\n - name: Setup Node.js\n uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5\n with:\n node-version: 24\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install --frozen-lockfile\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n env:\n MODERN_PUBLIC_SITE_URL: http://localhost:8080\n run: pnpm run build\n",
|
|
26
26
|
"api/effect/index.ts": "\n",
|
|
@@ -20,8 +20,8 @@ const MWAFiles = {
|
|
|
20
20
|
"scripts/bootstrap-agent-skills.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst lockPath = path.join(root, '.agents/skills-lock.json');\nconst checkOnly = process.argv.includes('--check');\nconst force = process.argv.includes('--force');\n\nconst readJson = (filePath) => JSON.parse(fs.readFileSync(filePath, 'utf-8'));\n\nconst run = (command, args, options = {}) =>\n execFileSync(command, args, {\n cwd: options.cwd ?? root,\n encoding: 'utf-8',\n stdio: options.stdio ?? ['ignore', 'pipe', 'pipe'],\n });\n\nconst cloneSource = (source, targetDir) => {\n const repo = source.repository.replace(/^https:\\/\\/github.com\\//u, '');\n try {\n run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1'], {\n stdio: 'inherit',\n });\n } catch {\n run('git', ['clone', '--depth', '1', source.repository, targetDir], {\n stdio: 'inherit',\n });\n }\n};\n\nconst resolveSkillDir = (sourceRoot, skillName) => {\n const candidates = [\n path.join(sourceRoot, skillName),\n path.join(sourceRoot, 'skills', skillName),\n path.join(sourceRoot, 'skills', 'engineering', skillName),\n path.join(sourceRoot, 'skills', 'productivity', skillName),\n ];\n return candidates.find((candidate) => fs.existsSync(path.join(candidate, 'SKILL.md')));\n};\n\nif (!fs.existsSync(lockPath)) {\n console.error('Missing .agents/skills-lock.json');\n process.exit(1);\n}\n\nconst lock = readJson(lockPath);\nconst installDir = path.join(root, lock.installDir ?? '.agents/skills');\nconst privateSources = (lock.sources ?? []).filter(\n (source) => source.install === 'clone-if-authorized',\n);\n\nif (checkOnly) {\n const missing = privateSources.flatMap((source) =>\n (source.baseline ?? [])\n .map((skill) => skill.name)\n .filter((skillName) => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md'))),\n );\n if (missing.length > 0) {\n console.warn(\n `Private skills not installed: ${missing.join(', ')}. Run pnpm skills:install if you have access.`,\n );\n } else {\n console.log('Agent skills are installed.');\n }\n process.exit(0);\n}\n\nfs.mkdirSync(installDir, { recursive: true });\n\nfor (const source of privateSources) {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ultramodern-skills-'));\n try {\n cloneSource(source, tempDir);\n for (const skill of source.baseline ?? []) {\n const sourceSkillDir = resolveSkillDir(tempDir, skill.name);\n if (!sourceSkillDir) {\n throw new Error(`Skill ${skill.name} not found in ${source.repository}`);\n }\n const targetSkillDir = path.join(installDir, skill.name);\n if (fs.existsSync(targetSkillDir)) {\n if (!force) {\n console.log(`Skipping existing ${skill.name}`);\n continue;\n }\n fs.rmSync(targetSkillDir, { force: true, recursive: true });\n }\n fs.cpSync(sourceSkillDir, targetSkillDir, { recursive: true });\n console.log(`Installed ${skill.name}`);\n }\n } finally {\n fs.rmSync(tempDir, { force: true, recursive: true });\n }\n}\n",
|
|
21
21
|
"scripts/check-i18n-strings.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst root = process.cwd();\nconst scanRoots = ['src'].map((scanRoot) => path.join(root, scanRoot));\nconst ignoredDirectories = new Set(['.modern', '.modernjs', 'dist', 'node_modules']);\nconst visibleAttributePattern =\n /\\s(?:aria-label|alt|placeholder|title)=[\"']([^\"']*[A-Za-z][^\"']*)[\"']/gu;\nconst jsxTextPattern = />([^<>{}]*[A-Za-z][^<>{}]*)</gu;\n\nconst collectFiles = (directory) => {\n if (!fs.existsSync(directory)) {\n return [];\n }\n\n const files = [];\n for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!ignoredDirectories.has(entry.name)) {\n files.push(...collectFiles(path.join(directory, entry.name)));\n }\n continue;\n }\n\n if (entry.isFile() && /\\.(jsx|tsx)$/u.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n files.push(path.join(directory, entry.name));\n }\n }\n return files;\n};\n\nconst lineNumberForIndex = (content, index) => content.slice(0, index).split('\\n').length;\nconst isIgnoredLine = (content, index) => {\n const lineStart = content.lastIndexOf('\\n', index) + 1;\n const lineEnd = content.indexOf('\\n', index);\n const currentLineEnd = lineEnd === -1 ? content.length : lineEnd;\n const previousLineStart = content.lastIndexOf('\\n', Math.max(0, lineStart - 2)) + 1;\n const nextLineEnd = content.indexOf('\\n', currentLineEnd + 1);\n const context = content.slice(\n previousLineStart,\n nextLineEnd === -1 ? content.length : nextLineEnd,\n );\n return /i18n-ignore/u.test(context);\n};\n\nconst violations = [];\nfor (const filePath of scanRoots.flatMap(collectFiles)) {\n const content = fs.readFileSync(filePath, 'utf-8');\n for (const match of content.matchAll(visibleAttributePattern)) {\n if (!isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text: match[1].trim(),\n });\n }\n }\n\n for (const match of content.matchAll(jsxTextPattern)) {\n const text = match[1].replaceAll(/\\s+/gu, ' ').trim();\n if (text && !isIgnoredLine(content, match.index ?? 0)) {\n violations.push({\n filePath,\n line: lineNumberForIndex(content, match.index ?? 0),\n text,\n });\n }\n }\n}\n\nif (violations.length > 0) {\n console.error('Hardcoded user-visible JSX strings found. Move copy to locale JSON files.');\n for (const violation of violations) {\n console.error(\n `${path.relative(root, violation.filePath)}:${violation.line} ${JSON.stringify(\n violation.text,\n )}`,\n );\n }\n process.exit(1);\n}\n\nconsole.log('No hardcoded user-visible JSX strings found.');\n",
|
|
22
22
|
"scripts/validate-ultramodern.mjs": "import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(process.cwd(), '.modernjs/mv-template-manifest.json');\nconst packageSourcePath = path.resolve(\n process.cwd(),\n '.modernjs/ultramodern-package-source.json',\n);\nconst readPnpmConfig = (key) => {\n const env = { ...process.env };\n for (const envKey of Object.keys(env)) {\n if (/^(?:npm|pnpm)_config_/i.test(envKey)) {\n delete env[envKey];\n }\n }\n const output = execFileSync('pnpm', ['config', 'get', key, '--json'], {\n cwd: process.cwd(),\n env,\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'pipe'],\n }).trim();\n return output ? JSON.parse(output) : undefined;\n};\nconst isSubproject = ;\nconst enableTailwind = ;\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf-8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n 'i18nPlugin(',\n 'localePathRedirect: true',\n 'ULTRAMODERN_SITE_URL',\n 'MODERN_PUBLIC_SITE_URL must be set for production builds',\n 'globalVars',\n];\nconst missing = requiredTokens.filter((token) => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(`Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`);\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(fs.readFileSync(templateManifestPath, 'utf-8'));\nconst requiredDeniedPaths = [\n '.git/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'github-workflow-security-enforced',\n 'package-source-retained',\n 'pnpm-11-policy-enforced',\n 'rstest-smoke-tests',\n 'template-manifest-retained',\n];\nconst requiredPaths = [\n 'AGENTS.md',\n '.agents/skills-lock.json',\n '.github/renovate.json',\n '.github/workflows/ultramodern-gates.yml',\n 'oxlint.config.ts',\n 'oxfmt.config.ts',\n 'scripts/bootstrap-agent-skills.mjs',\n '.mise.toml',\n '.modernjs/ultramodern-package-source.json',\n 'pnpm-workspace.yaml',\n 'rstest.config.mts',\n 'scripts/check-i18n-strings.mjs',\n 'config/public/locales/en/translation.json',\n 'config/public/locales/cs/translation.json',\n 'src/modern-app-env.d.ts',\n 'src/routes/index.css',\n 'src/routes/[lang]/page.tsx',\n 'tests/ultramodern.contract.test.ts',\n];\nconst manifestErrors = [];\n\nfor (const requiredPath of requiredPaths) {\n if (!fs.existsSync(path.resolve(process.cwd(), requiredPath))) {\n console.error(`${requiredPath} not found`);\n process.exit(1);\n }\n}\n\nif (fs.existsSync(path.resolve(process.cwd(), 'src/routes/page.tsx'))) {\n console.error('src/routes/page.tsx must move under src/routes/[lang]/page.tsx');\n process.exit(1);\n}\n\nconst routeCss = fs.readFileSync(path.resolve(process.cwd(), 'src/routes/index.css'), 'utf-8');\nif (enableTailwind) {\n if (!routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must import Tailwind CSS by default');\n process.exit(1);\n }\n const postcssConfig = fs.readFileSync(path.resolve(process.cwd(), 'postcss.config.mjs'), 'utf-8');\n if (!postcssConfig.includes(\"'@tailwindcss/postcss'\")) {\n console.error('postcss.config.mjs must configure @tailwindcss/postcss');\n process.exit(1);\n }\n const tailwindConfig = fs.readFileSync(path.resolve(process.cwd(), 'tailwind.config.ts'), 'utf-8');\n if (!tailwindConfig.includes(\"content: ['./src/**/*.{js,ts,jsx,tsx}']\")) {\n console.error('tailwind.config.ts must scan generated source files');\n process.exit(1);\n }\n} else {\n if (routeCss.includes(\"@import 'tailwindcss';\")) {\n console.error('src/routes/index.css must omit Tailwind CSS when disabled');\n process.exit(1);\n }\n if (\n fs.existsSync(path.resolve(process.cwd(), 'postcss.config.mjs')) ||\n fs.existsSync(path.resolve(process.cwd(), 'tailwind.config.ts'))\n ) {\n console.error('Tailwind config files must not be written when Tailwind is disabled');\n process.exit(1);\n }\n}\n\nconst workflowContent = fs.readFileSync(\n path.resolve(process.cwd(), '.github/workflows/ultramodern-gates.yml'),\n 'utf-8',\n);\nconst renovateConfig = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.github/renovate.json'), 'utf-8'),\n);\nfor (const requiredSnippet of [\n 'permissions:\\n contents: read',\n 'pull_request:',\n 'persist-credentials: false',\n 'pnpm install --frozen-lockfile',\n 'MODERN_PUBLIC_SITE_URL: http://localhost:8080',\n 'timeout-minutes:',\n 'egress-policy: audit',\n]) {\n if (!workflowContent.includes(requiredSnippet)) {\n console.error(`Generated workflow must retain ${requiredSnippet.split('\\n')[0]}`);\n process.exit(1);\n }\n}\nif (workflowContent.includes('pull_request_target')) {\n console.error('Generated workflow must not use pull_request_target');\n process.exit(1);\n}\nfor (const match of workflowContent.matchAll(/^\\s*uses:\\s*([^@\\s]+)@([^\\s#]+)/gmu)) {\n const [, actionName, actionRef] = match;\n if (!/^[a-f0-9]{40}$/u.test(actionRef)) {\n console.error(`Generated workflow must pin ${actionName}@${actionRef} to a commit SHA`);\n process.exit(1);\n }\n}\nif (\n renovateConfig.dependencyDashboard !== true ||\n renovateConfig.minimumReleaseAge !== '1 day' ||\n !renovateConfig.extends?.includes('helpers:pinGitHubActionDigests') ||\n !renovateConfig.packageRules?.some(\n (rule) =>\n rule.dependencyDashboardApproval === true && rule.matchUpdateTypes?.includes('major'),\n )\n) {\n console.error('Generated Renovate config must retain dashboard, release-age, action pinning, and major-approval policy');\n process.exit(1);\n}\n\nconst pageContent = fs.readFileSync(\n path.resolve(process.cwd(), 'src/routes/[lang]/page.tsx'),\n 'utf-8',\n);\nfor (const token of [\n 'rel=\"canonical\"',\n 'rel=\"alternate\"',\n 'hrefLang=\"x-default\"',\n 'localizedPath(',\n '<a',\n]) {\n if (!pageContent.includes(token)) {\n console.error(`Localized route is missing ${token}`);\n process.exit(1);\n }\n}\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n (checksum) =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/u.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(', ')}`,\n );\n process.exit(1);\n}\n\nconst packageJson = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8'),\n);\nconst packageSource = JSON.parse(fs.readFileSync(packageSourcePath, 'utf-8'));\nconst unresolvedTemplateMarker = String.fromCodePoint(123, 123);\nif (JSON.stringify(packageJson).includes(unresolvedTemplateMarker)) {\n console.error('package.json contains unresolved template markers');\n process.exit(1);\n}\nif (JSON.stringify(packageSource).includes(unresolvedTemplateMarker)) {\n console.error('package source metadata contains unresolved template markers');\n process.exit(1);\n}\nconst skillsLock = JSON.parse(\n fs.readFileSync(path.resolve(process.cwd(), '.agents/skills-lock.json'), 'utf-8'),\n);\nconst requiredScripts = {\n 'i18n:check': 'node ./scripts/check-i18n-strings.mjs',\n test: 'rstest run',\n format: 'oxfmt .',\n 'format:check': 'oxfmt --check .',\n lint: 'oxlint .',\n 'lint:fix': 'oxlint . --fix',\n 'skills:check': 'node ./scripts/bootstrap-agent-skills.mjs --check',\n 'skills:install': 'node ./scripts/bootstrap-agent-skills.mjs',\n};\n\nfor (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {\n if (packageJson.scripts?.[scriptName] !== scriptCommand) {\n console.error(`Missing or invalid package script: ${scriptName}`);\n process.exit(1);\n }\n}\n\nif (\n !packageJson.scripts?.typecheck?.includes('effect-tsgo') ||\n !packageJson.scripts.typecheck.includes('get-exe-path')\n) {\n console.error('typecheck must use effect-tsgo as the TypeScript checker');\n process.exit(1);\n}\n\nif (!packageJson.scripts?.['ultramodern:check']?.includes('pnpm test')) {\n console.error('ultramodern:check must run the generated Rstest suite');\n process.exit(1);\n}\n\nif (packageJson.private !== true) {\n console.error('Generated app package must be private by default');\n process.exit(1);\n}\n\nif (packageJson.packageManager !== 'pnpm@11.4.0') {\n console.error('Generated app package must pin pnpm@11.4.0');\n process.exit(1);\n}\n\nif (packageJson.engines?.pnpm !== '>=11.4.0 <11.5.0') {\n console.error('Generated app package must require pnpm >=11.4.0 <11.5.0');\n process.exit(1);\n}\n\nif (packageJson.pnpm !== undefined) {\n console.error('Generated app must keep pnpm policy in pnpm-workspace.yaml, not package.json');\n process.exit(1);\n}\n\nif (readPnpmConfig('minimumReleaseAge') !== 1440) {\n console.error('pnpm minimumReleaseAge must be 1440');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeStrict') !== true) {\n console.error('pnpm minimumReleaseAgeStrict must be true');\n process.exit(1);\n}\nif (readPnpmConfig('minimumReleaseAgeIgnoreMissingTime') !== false) {\n console.error('pnpm minimumReleaseAgeIgnoreMissingTime must be false');\n process.exit(1);\n}\nif (\n JSON.stringify(readPnpmConfig('minimumReleaseAgeExclude')) !==\n JSON.stringify([\n '@modern-js/*',\n '@bleedingdev/*',\n '@effect/tsgo',\n '@effect/tsgo-*',\n '@typescript/native-preview',\n '@typescript/native-preview-*',\n ])\n) {\n console.error('pnpm minimumReleaseAgeExclude must retain framework exceptions');\n process.exit(1);\n}\nif (readPnpmConfig('trustPolicy') !== 'no-downgrade') {\n console.error('pnpm trustPolicy must be no-downgrade');\n process.exit(1);\n}\nfor (const [key, expected] of [\n ['trustPolicyIgnoreAfter', 1440],\n ['blockExoticSubdeps', true],\n ['engineStrict', true],\n ['pmOnFail', 'error'],\n ['verifyDepsBeforeRun', 'error'],\n ['strictDepBuilds', true],\n]) {\n if (readPnpmConfig(key) !== expected) {\n console.error(`pnpm ${key} must be ${String(expected)}`);\n process.exit(1);\n }\n}\nif (\n JSON.stringify(readPnpmConfig('allowBuilds')) !==\n JSON.stringify({\n '@swc/core': true,\n 'core-js': true,\n esbuild: true,\n 'msgpackr-extract': true,\n sharp: true,\n 'simple-git-hooks': true,\n workerd: true,\n })\n) {\n console.error('pnpm allowBuilds must approve only the generated app build dependencies');\n process.exit(1);\n}\nif (readPnpmConfig('onlyBuiltDependencies') !== undefined) {\n console.error('pnpm onlyBuiltDependencies must not be set');\n process.exit(1);\n}\n\nif (packageJson.modernjs?.preset !== 'presetUltramodern') {\n console.error('package.json must declare presetUltramodern metadata');\n process.exit(1);\n}\n\nif (\n packageJson.modernjs?.packageSource?.config !== './.modernjs/ultramodern-package-source.json'\n) {\n console.error('package.json must retain package source metadata location');\n process.exit(1);\n}\n\nif (packageSource.schemaVersion !== 1) {\n console.error('Package source metadata must use schemaVersion 1');\n process.exit(1);\n}\n\nif (packageSource.preset !== 'presetUltramodern') {\n console.error('Package source metadata must declare presetUltramodern');\n process.exit(1);\n}\n\nif (packageSource.strategy !== 'workspace' && packageSource.strategy !== 'install') {\n console.error('Package source strategy must be workspace or install');\n process.exit(1);\n}\n\nconst expectedModernPackages = [\n '@modern-js/runtime',\n '@modern-js/app-tools',\n '@modern-js/tsconfig',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n '@modern-js/plugin-bff',\n '@modern-js/adapter-rstest',\n];\n\nfor (const packageName of expectedModernPackages) {\n if (!packageSource.modernPackages?.packages?.includes(packageName)) {\n console.error(`Package source metadata must include ${packageName}`);\n process.exit(1);\n }\n}\n\nconst expectedModernSpecifier = packageSource.modernPackages?.specifier;\nif (typeof expectedModernSpecifier !== 'string' || expectedModernSpecifier.length === 0) {\n console.error('Package source metadata must provide a Modern package specifier');\n process.exit(1);\n}\n\nconst expectedModernDependency = (packageName) => {\n const alias = packageSource.modernPackages?.aliases?.[packageName];\n return typeof alias === 'string'\n ? `npm:${alias}@${expectedModernSpecifier}`\n : expectedModernSpecifier;\n};\n\nfor (const packageName of [\n '@modern-js/runtime',\n '@modern-js/plugin-i18n',\n '@modern-js/plugin-tanstack',\n]) {\n if (\n packageJson.dependencies?.[packageName] &&\n packageJson.dependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const packageName of [\n '@modern-js/app-tools',\n '@modern-js/adapter-rstest',\n '@modern-js/tsconfig',\n '@modern-js/plugin-bff',\n]) {\n if (\n packageJson.devDependencies?.[packageName] &&\n packageJson.devDependencies[packageName] !== expectedModernDependency(packageName)\n ) {\n console.error(`Dev dependency ${packageName} must match package source metadata`);\n process.exit(1);\n }\n}\n\nfor (const dependency of ['@modern-js/plugin-i18n', 'i18next', 'react-i18next']) {\n if (!packageJson.dependencies?.[dependency]) {\n console.error(`Missing dependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nfor (const dependency of [\n '@effect/tsgo',\n '@modern-js/adapter-rstest',\n '@rstest/core',\n '@typescript/native-preview',\n 'happy-dom',\n 'oxlint',\n 'oxfmt',\n 'ultracite',\n]) {\n if (!packageJson.devDependencies?.[dependency]) {\n console.error(`Missing devDependency: ${dependency}`);\n process.exit(1);\n }\n}\n\nif (\n packageJson.devDependencies?.tailwindcss ||\n packageJson.devDependencies?.['@tailwindcss/postcss'] ||\n packageJson.devDependencies?.postcss\n) {\n console.error('Tailwind CSS dependencies must be absent when Tailwind is disabled');\n process.exit(1);\n}\n\nconst privateSource = skillsLock.sources?.find(\n (source) => source.repository === 'https://github.com/TechsioCZ/skills',\n);\nconst privateSkills = new Set(privateSource?.baseline?.map((skill) => skill.name));\nfor (const skillName of ['plan-graph', 'dag', 'subagent-graph', 'helm', 'debugger-mode']) {\n if (!privateSkills.has(skillName)) {\n console.error(`Missing private skill allowlist entry: ${skillName}`);\n process.exit(1);\n }\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
23
|
-
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
24
23
|
"tests/ultramodern.contract.test.ts": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { describe, expect, test } from '@rstest/core';\n\nconst root = process.cwd();\nconst readText = (relativePath: string) =>\n fs.readFileSync(path.join(root, relativePath), 'utf-8');\nconst readJson = <T>(relativePath: string): T =>\n JSON.parse(readText(relativePath)) as T;\n\ndescribe('generated UltraModern contract', () => {\n test('keeps localized route metadata and Rstest wiring', () => {\n expect(fs.existsSync(path.join(root, 'src/routes/[lang]/page.tsx'))).toBe(\n true,\n );\n expect(fs.existsSync(path.join(root, 'src/routes/page.tsx'))).toBe(false);\n\n const page = readText('src/routes/[lang]/page.tsx');\n expect(page).toContain('rel=\"canonical\"');\n expect(page).toContain('rel=\"alternate\"');\n expect(page).toContain('hrefLang=\"x-default\"');\n expect(page).toContain('localizedPath(');\n expect(readText('src/routes/index.css')).not.toContain(\n \"@import 'tailwindcss';\",\n );\n expect(fs.existsSync(path.join(root, 'postcss.config.mjs'))).toBe(false);\n expect(fs.existsSync(path.join(root, 'tailwind.config.ts'))).toBe(false);\n\n const config = readText('rstest.config.mts');\n expect(config).toContain(\"withModernConfig()\");\n expect(config).toContain(\"testEnvironment: 'happy-dom'\");\n });\n\n test('retains package-source metadata for generated Modern.js packages', () => {\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n modernjs?: {\n packageSource?: {\n config?: string;\n };\n preset?: string;\n };\n }>('package.json');\n const packageSource = readJson<{\n modernPackages?: {\n packages?: string[];\n specifier?: string;\n };\n strategy?: string;\n }>('.modernjs/ultramodern-package-source.json');\n\n expect(packageJson.modernjs?.preset).toBe('presetUltramodern');\n expect(packageJson.modernjs?.packageSource?.config).toBe(\n './.modernjs/ultramodern-package-source.json',\n );\n expect(packageSource.strategy).toMatch(/^(workspace|install)$/u);\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/runtime',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/app-tools',\n );\n expect(packageSource.modernPackages?.packages).toContain(\n '@modern-js/adapter-rstest',\n );\n expect(packageSource.modernPackages?.specifier).toBeTruthy();\n expect(\n packageJson.devDependencies?.['@modern-js/adapter-rstest'],\n ).toBeTruthy();\n expect(packageJson.devDependencies?.tailwindcss).toBeUndefined();\n expect(\n packageJson.devDependencies?.['@tailwindcss/postcss'],\n ).toBeUndefined();\n });\n});\n",
|
|
24
|
+
"tests/tsconfig.json": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"@rstest/core/globals\"]\n },\n \"include\": [\"./\"]\n}\n",
|
|
25
25
|
".github/renovate.json": "{\n \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n \"extends\": [\n \"config:recommended\",\n \"helpers:pinGitHubActionDigests\"\n ],\n \"dependencyDashboard\": true,\n \"minimumReleaseAge\": \"1 day\",\n \"prConcurrentLimit\": 5,\n \"prHourlyLimit\": 2,\n \"rangeStrategy\": \"bump\",\n \"schedule\": [\n \"before 5am on monday\"\n ],\n \"timezone\": \"Etc/UTC\",\n \"packageRules\": [\n {\n \"matchManagers\": [\n \"github-actions\"\n ],\n \"groupName\": \"github-actions\",\n \"labels\": [\n \"dependencies\",\n \"github-actions\",\n \"security\"\n ]\n },\n {\n \"matchManagers\": [\n \"npm\"\n ],\n \"matchUpdateTypes\": [\n \"patch\",\n \"minor\"\n ],\n \"groupName\": \"npm minor and patch updates\",\n \"labels\": [\n \"dependencies\",\n \"npm\"\n ]\n },\n {\n \"matchUpdateTypes\": [\n \"major\"\n ],\n \"dependencyDashboardApproval\": true,\n \"labels\": [\n \"dependencies\",\n \"major\"\n ]\n }\n ]\n}\n",
|
|
26
26
|
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\npermissions:\n contents: read\n\ndefaults:\n run:\n shell: bash\n\nenv:\n FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true\n\nconcurrency:\n group: ultramodern-gates-$-$\n cancel-in-progress: true\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n timeout-minutes: 20\n steps:\n - name: Harden Runner\n uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2\n with:\n egress-policy: audit\n\n - name: Checkout\n uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5\n with:\n fetch-depth: 1\n persist-credentials: false\n\n - name: Setup pnpm\n uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8\n\n - name: Setup Node.js\n uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5\n with:\n node-version: 24\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install --frozen-lockfile\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n env:\n MODERN_PUBLIC_SITE_URL: http://localhost:8080\n run: pnpm run build\n",
|
|
27
27
|
"api/effect/index.ts": "\n",
|
|
@@ -19,8 +19,8 @@ export declare const MWAFiles: {
|
|
|
19
19
|
"scripts/bootstrap-agent-skills.mjs": string;
|
|
20
20
|
"scripts/check-i18n-strings.mjs": string;
|
|
21
21
|
"scripts/validate-ultramodern.mjs": string;
|
|
22
|
-
"tests/tsconfig.json": string;
|
|
23
22
|
"tests/ultramodern.contract.test.ts": string;
|
|
23
|
+
"tests/tsconfig.json": string;
|
|
24
24
|
".github/renovate.json": string;
|
|
25
25
|
".github/workflows/ultramodern-gates.yml": string;
|
|
26
26
|
"api/effect/index.ts": string;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.29",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"module": "./dist/esm/index.mjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/recursive-readdir": "^2.2.4",
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20260526.1",
|
|
50
50
|
"recursive-readdir": "^2.2.3",
|
|
51
|
-
"@modern-js/create": "npm:@bleedingdev/modern-js-create@3.2.0-ultramodern.
|
|
51
|
+
"@modern-js/create": "npm:@bleedingdev/modern-js-create@3.2.0-ultramodern.29"
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"publishConfig": {
|