@slip-stream-kit/config 0.17.0 → 0.18.1
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/dist/package-type.js.map +1 -1
- package/package.json +1 -1
package/dist/package-type.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/lib/package-type/package-type.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'node:path'\n\n/**\n * The kind of workspace package a guidance block is written for. The repo root\n * has its own body and is deliberately not a `PackageType`.\n */\nexport type PackageType = 'frontend' | 'backend' | 'lib' | 'e2e' | 'mobile'\n\n/** Every package type, in registry order. Useful for exhaustive table-driven tests. */\nexport const PACKAGE_TYPES: readonly PackageType[] = ['frontend', 'backend', 'lib', 'e2e', 'mobile']\n\n/** The `package.json` fields package-type detection reads. */\nexport interface PackageTypeManifest {\n scripts?: Record<string, string>\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n}\n\nexport interface DetectPackageTypeArgs {\n /** Absolute path to the package directory. */\n packageDir: string\n /** Absolute path to the repo root the directory convention is measured against. */\n repoRoot: string\n /** The package's parsed `package.json` (an empty object when it is missing or unreadable). */\n pkgJson: PackageTypeManifest\n /** `type` declared in the package's `infra-kit.config.ts`. Wins over every detected signal. */\n declaredType?: PackageType\n}\n\n/** Directory names under `apps/<app>/` that carry declared semantics inside infra-kit. */\nconst APP_DIRECTORY_TYPES: Readonly<Record<string, PackageType>> = {\n ui: 'frontend',\n api: 'backend',\n tests: 'e2e',\n}\n\n/** A directory with this basename is a Capacitor shell wherever it sits in the tree. */\nconst MOBILE_BASENAME = 'mobile-app'\n\n/**\n * Dependency signals, first match wins. `react` alone is deliberately absent:\n * component libraries carry it too, so `vite` + `react` + a `dev` script is what\n * separates an app from a library (handled separately below).\n */\nconst DEPENDENCY_SIGNALS: ReadonlyArray<{ type: PackageType; packages: readonly string[] }> = [\n { type: 'e2e', packages: ['@playwright/test'] },\n { type: 'mobile', packages: ['@capacitor/core', '@capacitor/cli'] },\n // `aws-lambda` / `@types/aws-lambda` are deliberately NOT signals: every consumer backend already\n // lives at `apps/<app>/api` (row 2), while the only packages those two deps would catch are\n // libraries (`packages/lib-core` in both consumers, the infra-kit CLI itself) \u2014 a lambda types\n // dependency alone never means backend, exactly as `react` alone never means frontend.\n { type: 'backend', packages: ['serverless'] },\n]\n\n/**\n * Type implied by where the package sits, or `null` when the path carries no\n * declared semantics. `apps/<app>/{ui,api,tests}` is already load-bearing inside\n * infra-kit (`
|
|
4
|
+
"sourcesContent": ["import path from 'node:path'\n\n/**\n * The kind of workspace package a guidance block is written for. The repo root\n * has its own body and is deliberately not a `PackageType`.\n */\nexport type PackageType = 'frontend' | 'backend' | 'lib' | 'e2e' | 'mobile'\n\n/** Every package type, in registry order. Useful for exhaustive table-driven tests. */\nexport const PACKAGE_TYPES: readonly PackageType[] = ['frontend', 'backend', 'lib', 'e2e', 'mobile']\n\n/** The `package.json` fields package-type detection reads. */\nexport interface PackageTypeManifest {\n scripts?: Record<string, string>\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n}\n\nexport interface DetectPackageTypeArgs {\n /** Absolute path to the package directory. */\n packageDir: string\n /** Absolute path to the repo root the directory convention is measured against. */\n repoRoot: string\n /** The package's parsed `package.json` (an empty object when it is missing or unreadable). */\n pkgJson: PackageTypeManifest\n /** `type` declared in the package's `infra-kit.config.ts`. Wins over every detected signal. */\n declaredType?: PackageType\n}\n\n/** Directory names under `apps/<app>/` that carry declared semantics inside infra-kit. */\nconst APP_DIRECTORY_TYPES: Readonly<Record<string, PackageType>> = {\n ui: 'frontend',\n api: 'backend',\n tests: 'e2e',\n}\n\n/** A directory with this basename is a Capacitor shell wherever it sits in the tree. */\nconst MOBILE_BASENAME = 'mobile-app'\n\n/**\n * Dependency signals, first match wins. `react` alone is deliberately absent:\n * component libraries carry it too, so `vite` + `react` + a `dev` script is what\n * separates an app from a library (handled separately below).\n */\nconst DEPENDENCY_SIGNALS: ReadonlyArray<{ type: PackageType; packages: readonly string[] }> = [\n { type: 'e2e', packages: ['@playwright/test'] },\n { type: 'mobile', packages: ['@capacitor/core', '@capacitor/cli'] },\n // `aws-lambda` / `@types/aws-lambda` are deliberately NOT signals: every consumer backend already\n // lives at `apps/<app>/api` (row 2), while the only packages those two deps would catch are\n // libraries (`packages/lib-core` in both consumers, the infra-kit CLI itself) \u2014 a lambda types\n // dependency alone never means backend, exactly as `react` alone never means frontend.\n { type: 'backend', packages: ['serverless'] },\n]\n\n/**\n * Type implied by where the package sits, or `null` when the path carries no\n * declared semantics. `apps/<app>/{ui,api,tests}` is already load-bearing inside\n * infra-kit (`infra-kit dev --target` keys must be `<app>/api` or `<app>/ui`), so this\n * is the repo's own convention rather than a heuristic \u2014 which is why it beats\n * the dependency signals.\n *\n * @example\n * fromDirectory('/repo/apps/client/ui', '/repo') // => 'frontend'\n * fromDirectory('/repo/packages/mobile-app', '/repo') // => 'mobile'\n */\nconst fromDirectory = (packageDir: string, repoRoot: string): PackageType | null => {\n const segments = path\n .relative(repoRoot, packageDir)\n .split(path.sep)\n .filter((segment) => {\n return segment !== '' && segment !== '.'\n })\n\n const [first, , third] = segments\n\n if (segments.length === 3 && first === 'apps' && third !== undefined) {\n const appType = APP_DIRECTORY_TYPES[third]\n\n if (appType) return appType\n }\n\n return segments.at(-1) === MOBILE_BASENAME ? 'mobile' : null\n}\n\n/**\n * Type implied by the merged `dependencies` / `devDependencies` / `peerDependencies`\n * plus the `dev` script, or `null` when nothing matches.\n *\n * @example\n * fromDependencies({ dependencies: { '@playwright/test': '^1' } }) // => 'e2e'\n * fromDependencies({ dependencies: { react: '^19' } }) // => null (react alone is not a frontend)\n */\nconst fromDependencies = (pkgJson: PackageTypeManifest): PackageType | null => {\n const deps = new Set([\n ...Object.keys(pkgJson.dependencies ?? {}),\n ...Object.keys(pkgJson.devDependencies ?? {}),\n ...Object.keys(pkgJson.peerDependencies ?? {}),\n ])\n\n for (const signal of DEPENDENCY_SIGNALS) {\n if (\n signal.packages.some((name) => {\n return deps.has(name)\n })\n )\n return signal.type\n }\n\n const isViteReactApp = deps.has('vite') && deps.has('react') && Boolean(pkgJson.scripts?.dev)\n\n return isViteReactApp ? 'frontend' : null\n}\n\n/**\n * Resolve a package's type by the \u00A73.2 precedence: an explicit `type` in\n * `infra-kit.config.ts` beats the directory convention, which beats the\n * dependency signals, which fall back to `lib`. There is no `unknown` \u2014 the\n * fallback is the least opinionated body, so an unrecognised package still gets\n * a usable block rather than a failing check.\n *\n * @example\n * detectPackageType({\n * packageDir: '/repo/apps/client/ui',\n * repoRoot: '/repo',\n * pkgJson: { dependencies: { '@playwright/test': '^1' } },\n * })\n * // => 'frontend' (the directory convention beats the dependency signal)\n */\nexport const detectPackageType = ({\n packageDir,\n repoRoot,\n pkgJson,\n declaredType,\n}: DetectPackageTypeArgs): PackageType => {\n return declaredType ?? fromDirectory(packageDir, repoRoot) ?? fromDependencies(pkgJson) ?? 'lib'\n}\n"],
|
|
5
5
|
"mappings": ";AAAA,OAAO,UAAU;AASV,IAAM,gBAAwC,CAAC,YAAY,WAAW,OAAO,OAAO,QAAQ;AAsBnG,IAAM,sBAA6D;AAAA,EACjE,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,OAAO;AACT;AAGA,IAAM,kBAAkB;AAOxB,IAAM,qBAAwF;AAAA,EAC5F,EAAE,MAAM,OAAO,UAAU,CAAC,kBAAkB,EAAE;AAAA,EAC9C,EAAE,MAAM,UAAU,UAAU,CAAC,mBAAmB,gBAAgB,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlE,EAAE,MAAM,WAAW,UAAU,CAAC,YAAY,EAAE;AAC9C;AAaA,IAAM,gBAAgB,CAAC,YAAoB,aAAyC;AAClF,QAAM,WAAW,KACd,SAAS,UAAU,UAAU,EAC7B,MAAM,KAAK,GAAG,EACd,OAAO,CAAC,Y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