@sanity/pkg-utils 13.0.0 → 13.0.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.
@@ -1,7 +1,7 @@
1
1
  import { n as createLogger, r as isRecord, t as handleError } from "./handleError-83GwKIFM.js";
2
- import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-i4HOnPda.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-Cp6bOuom.js";
3
3
  import { t as createSpinner } from "./spinner-DAHe7SuT.js";
4
- import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-orfQXkE6.js";
4
+ import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-QaIhKS-s.js";
5
5
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import { up } from "empathic/package";
@@ -32,7 +32,7 @@ async function build$1(options) {
32
32
  let config = await loadConfig({
33
33
  cwd,
34
34
  pkgPath
35
- }), { parseStrictOptions } = await import("./resolveBuildContext-i4HOnPda.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
35
+ }), { parseStrictOptions } = await import("./resolveBuildContext-Cp6bOuom.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
36
36
  pkgPath,
37
37
  logger,
38
38
  strict,
@@ -147,4 +147,4 @@ async function buildAction(options) {
147
147
  }
148
148
  export { buildAction };
149
149
 
150
- //# sourceMappingURL=buildAction-kavz9FnJ.js.map
150
+ //# sourceMappingURL=buildAction-BbznO37s.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildAction-kavz9FnJ.js","names":["build","findPkgPath","tsdownBuild","build"],"sources":["../src/node/build.ts","../src/cli/buildAction.ts"],"sourcesContent":["import {existsSync, readFileSync, rmSync, writeFileSync} from 'node:fs'\nimport path from 'node:path'\nimport {up as findPkgPath} from 'empathic/package'\nimport {build as tsdownBuild, type TsdownBundle} from 'tsdown'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {isRecord} from './core/isRecord.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger, type Logger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\nimport {\n resolveTsdownBuilds,\n type TsdownBuild as TsdownBuildDef,\n} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst RE_TS_SOURCE = /\\.[cm]?tsx?$/\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n // `--no-clean` skips cleaning for this run; `true` (the CLI default — `--clean` still\n // parses as a no-op for v11 compatibility) defers to the `clean` config option\n clean = true,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n warnAboutTsdownConfigFiles(cwd, logger)\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n // A types-only run skips builds without TypeScript sources entirely\n if (\n ctx.emitDeclarationOnly &&\n !buildDef.entries.some((entry) => RE_TS_SOURCE.test(entry.source))\n ) {\n continue\n }\n\n const taskName = buildTaskName(buildDef)\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {clean: first && clean})\n first = false\n\n const {bundles} = await tsdownBuild(inlineConfig)\n\n if (ctx.emitDeclarationOnly) {\n // `dts.emitDtsOnly` suppresses the JS chunks of the ES pass, but the CJS pass emits\n // its JS regardless (only its extra dts pass runs the dts plugin) — a types-only\n // build removes everything that is not a declaration file\n removeNonDeclarationOutputs(bundles)\n }\n\n if (buildDef.canonical) {\n restoreAuthoredTypes(ctx)\n }\n\n spinner.complete()\n ctx.logger.log()\n\n printBuildOutputs(ctx, bundles, buildDef)\n ctx.logger.log()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(escapeRegExp(cwd), 'g')\n\n ctx.logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n process.exit(1)\n }\n }\n}\n\nfunction buildTaskName(buildDef: TsdownBuildDef): string {\n const formats = Array.from(new Set(buildDef.entries.flatMap((entry) => entry.formats)))\n return `build ${buildDef.key} (${formats.join(', ') || 'types'})`\n}\n\nconst RE_DTS_OUTPUT = /\\.d\\.[mc]?ts(\\.map)?$/\n\n/** Removes every emitted file that is not a declaration file (or its sourcemap). */\nfunction removeNonDeclarationOutputs(bundles: TsdownBundle[]): void {\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (RE_DTS_OUTPUT.test(chunk.fileName)) continue\n rmSync(path.join(chunk.outDir, chunk.fileName), {force: true})\n rmSync(path.join(chunk.outDir, `${chunk.fileName}.map`), {force: true})\n }\n }\n}\n\n/**\n * Prints `<pkg>: <source> → <output>` for every entry chunk (JS and `.d.ts`) that tsdown\n * emitted, mirroring the per-file output of previous majors.\n */\nfunction printBuildOutputs(\n ctx: {\n cwd: string\n distPath: string\n emitDeclarationOnly: boolean\n logger: Logger\n pkg: {name: string}\n },\n bundles: TsdownBundle[],\n buildDef: TsdownBuildDef,\n): void {\n const {cwd, logger, pkg} = ctx\n const lines = new Set<string>()\n\n // Stylesheets are emitted as assets, which carry no `facadeModuleId` back to their source,\n // so the stylesheet build's lines come from its entry map instead.\n if (buildDef.css) {\n for (const entry of buildDef.entries) {\n const output = `./${path\n .relative(cwd, path.join(ctx.distPath, `${entry.alias}.css`))\n .replaceAll('\\\\', '/')}`\n lines.add(\n `${pkg.name}: ./${path.relative(cwd, path.resolve(cwd, entry.source)).replaceAll('\\\\', '/')} \\u2192 ${output}`,\n )\n }\n }\n\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (chunk.type !== 'chunk' || !chunk.isEntry || !chunk.facadeModuleId) continue\n if (ctx.emitDeclarationOnly && !RE_DTS_OUTPUT.test(chunk.fileName)) continue\n const source = `./${path\n .relative(cwd, chunk.facadeModuleId)\n .replaceAll('\\\\', '/')\n // the dts chunks facade the fake `.d.ts` module ids of rolldown-plugin-dts; print the\n // actual `.ts` source instead\n .replace(/\\.d\\.([mc]?)ts$/, '.$1ts')}`\n const output = `./${path\n .relative(cwd, path.join(chunk.outDir, chunk.fileName))\n .replaceAll('\\\\', '/')}`\n lines.add(`${pkg.name}: ${source} \\u2192 ${output}`)\n }\n }\n\n for (const line of Array.from(lines).toSorted()) {\n logger.log(line)\n }\n}\n\n/**\n * tsdown's exports generation rewrites the top-level `types` field alongside `main`/`module`\n * when the `legacy` fields are maintained, preferring the CJS declarations (`.d.cts`) for\n * dual-format packages. The hand-written value is authoritative here (the Sanity convention\n * points `types` at the ESM `.d.ts`), so it is restored after the canonical build.\n */\nfunction restoreAuthoredTypes(ctx: {cwd: string; pkg: {types?: string | undefined}}): void {\n const authoredTypes = ctx.pkg.types\n if (!authoredTypes) return\n\n const pkgPath = path.resolve(ctx.cwd, 'package.json')\n let text: string\n try {\n text = readFileSync(pkgPath, 'utf8')\n } catch {\n return\n }\n const json: unknown = JSON.parse(text)\n if (!isRecord(json) || json['types'] === authoredTypes) return\n json['types'] = authoredTypes\n\n const indent = /^([ \\t]+)\\S/m.exec(text)?.[1] ?? 2\n let output = JSON.stringify(json, null, indent)\n if (text.endsWith('\\n')) output += '\\n'\n writeFileSync(pkgPath, output, 'utf8')\n}\n\n/**\n * pkg-utils owns its own experience: `tsdown.config.*` files are never loaded in pkg-utils\n * mode (`package.config.ts` is the sole config source), so their presence is worth a warning.\n */\nfunction warnAboutTsdownConfigFiles(cwd: string, logger: Logger): void {\n const candidates = [\n 'tsdown.config.ts',\n 'tsdown.config.mts',\n 'tsdown.config.cts',\n 'tsdown.config.js',\n 'tsdown.config.mjs',\n 'tsdown.config.cjs',\n 'tsdown.config.json',\n ]\n const found = candidates.find((candidate) => existsSync(path.resolve(cwd, candidate)))\n if (found) {\n logger.warn(\n `found \\`${found}\\`, which @sanity/pkg-utils does not load — \\`package.config.ts\\` is the only config source of \\`pkg build\\`. Either migrate the package fully to tsdown (and drop @sanity/pkg-utils), or move the configuration into \\`package.config.ts\\`.`,\n )\n }\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n","import {build} from '../node/build.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function buildAction(options: {\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n try {\n await build({\n cwd: process.cwd(),\n emitDeclarationOnly: options.emitDeclarationOnly,\n strict: options.strict,\n tsconfig: options.tsconfig,\n clean: options.clean,\n quiet: options.quiet,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;A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ACL,WAAW,MAAM,6OACnB;AAEJ;AAEA,SAAS,aAAa,OAAuB;CAC3C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AC5PA,eAAsB,YAAY,SAMhB;CAChB,IAAI;EACF,MAAMC,QAAM;GACV,KAAK,QAAQ,IAAI;GACjB,qBAAqB,QAAQ;GAC7B,QAAQ,QAAQ;GAChB,UAAU,QAAQ;GAClB,OAAO,QAAQ;GACf,OAAO,QAAQ;EACjB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
1
+ {"version":3,"file":"buildAction-BbznO37s.js","names":["build","findPkgPath","tsdownBuild","build"],"sources":["../src/node/build.ts","../src/cli/buildAction.ts"],"sourcesContent":["import {existsSync, readFileSync, rmSync, writeFileSync} from 'node:fs'\nimport path from 'node:path'\nimport {up as findPkgPath} from 'empathic/package'\nimport {build as tsdownBuild, type TsdownBundle} from 'tsdown'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {isRecord} from './core/isRecord.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger, type Logger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\nimport {\n resolveTsdownBuilds,\n type TsdownBuild as TsdownBuildDef,\n} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst RE_TS_SOURCE = /\\.[cm]?tsx?$/\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n // `--no-clean` skips cleaning for this run; `true` (the CLI default — `--clean` still\n // parses as a no-op for v11 compatibility) defers to the `clean` config option\n clean = true,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n warnAboutTsdownConfigFiles(cwd, logger)\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n // A types-only run skips builds without TypeScript sources entirely\n if (\n ctx.emitDeclarationOnly &&\n !buildDef.entries.some((entry) => RE_TS_SOURCE.test(entry.source))\n ) {\n continue\n }\n\n const taskName = buildTaskName(buildDef)\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {clean: first && clean})\n first = false\n\n const {bundles} = await tsdownBuild(inlineConfig)\n\n if (ctx.emitDeclarationOnly) {\n // `dts.emitDtsOnly` suppresses the JS chunks of the ES pass, but the CJS pass emits\n // its JS regardless (only its extra dts pass runs the dts plugin) — a types-only\n // build removes everything that is not a declaration file\n removeNonDeclarationOutputs(bundles)\n }\n\n if (buildDef.canonical) {\n restoreAuthoredTypes(ctx)\n }\n\n spinner.complete()\n ctx.logger.log()\n\n printBuildOutputs(ctx, bundles, buildDef)\n ctx.logger.log()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(escapeRegExp(cwd), 'g')\n\n ctx.logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n process.exit(1)\n }\n }\n}\n\nfunction buildTaskName(buildDef: TsdownBuildDef): string {\n const formats = Array.from(new Set(buildDef.entries.flatMap((entry) => entry.formats)))\n return `build ${buildDef.key} (${formats.join(', ') || 'types'})`\n}\n\nconst RE_DTS_OUTPUT = /\\.d\\.[mc]?ts(\\.map)?$/\n\n/** Removes every emitted file that is not a declaration file (or its sourcemap). */\nfunction removeNonDeclarationOutputs(bundles: TsdownBundle[]): void {\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (RE_DTS_OUTPUT.test(chunk.fileName)) continue\n rmSync(path.join(chunk.outDir, chunk.fileName), {force: true})\n rmSync(path.join(chunk.outDir, `${chunk.fileName}.map`), {force: true})\n }\n }\n}\n\n/**\n * Prints `<pkg>: <source> → <output>` for every entry chunk (JS and `.d.ts`) that tsdown\n * emitted, mirroring the per-file output of previous majors.\n */\nfunction printBuildOutputs(\n ctx: {\n cwd: string\n distPath: string\n emitDeclarationOnly: boolean\n logger: Logger\n pkg: {name: string}\n },\n bundles: TsdownBundle[],\n buildDef: TsdownBuildDef,\n): void {\n const {cwd, logger, pkg} = ctx\n const lines = new Set<string>()\n\n // Stylesheets are emitted as assets, which carry no `facadeModuleId` back to their source,\n // so the stylesheet build's lines come from its entry map instead.\n if (buildDef.css) {\n for (const entry of buildDef.entries) {\n const output = `./${path\n .relative(cwd, path.join(ctx.distPath, `${entry.alias}.css`))\n .replaceAll('\\\\', '/')}`\n lines.add(\n `${pkg.name}: ./${path.relative(cwd, path.resolve(cwd, entry.source)).replaceAll('\\\\', '/')} \\u2192 ${output}`,\n )\n }\n }\n\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (chunk.type !== 'chunk' || !chunk.isEntry || !chunk.facadeModuleId) continue\n if (ctx.emitDeclarationOnly && !RE_DTS_OUTPUT.test(chunk.fileName)) continue\n const source = `./${path\n .relative(cwd, chunk.facadeModuleId)\n .replaceAll('\\\\', '/')\n // the dts chunks facade the fake `.d.ts` module ids of rolldown-plugin-dts; print the\n // actual `.ts` source instead\n .replace(/\\.d\\.([mc]?)ts$/, '.$1ts')}`\n const output = `./${path\n .relative(cwd, path.join(chunk.outDir, chunk.fileName))\n .replaceAll('\\\\', '/')}`\n lines.add(`${pkg.name}: ${source} \\u2192 ${output}`)\n }\n }\n\n for (const line of Array.from(lines).toSorted()) {\n logger.log(line)\n }\n}\n\n/**\n * tsdown's exports generation rewrites the top-level `types` field alongside `main`/`module`\n * when the `legacy` fields are maintained, preferring the CJS declarations (`.d.cts`) for\n * dual-format packages. The hand-written value is authoritative here (the Sanity convention\n * points `types` at the ESM `.d.ts`), so it is restored after the canonical build.\n */\nfunction restoreAuthoredTypes(ctx: {cwd: string; pkg: {types?: string | undefined}}): void {\n const authoredTypes = ctx.pkg.types\n if (!authoredTypes) return\n\n const pkgPath = path.resolve(ctx.cwd, 'package.json')\n let text: string\n try {\n text = readFileSync(pkgPath, 'utf8')\n } catch {\n return\n }\n const json: unknown = JSON.parse(text)\n if (!isRecord(json) || json['types'] === authoredTypes) return\n json['types'] = authoredTypes\n\n const indent = /^([ \\t]+)\\S/m.exec(text)?.[1] ?? 2\n let output = JSON.stringify(json, null, indent)\n if (text.endsWith('\\n')) output += '\\n'\n writeFileSync(pkgPath, output, 'utf8')\n}\n\n/**\n * pkg-utils owns its own experience: `tsdown.config.*` files are never loaded in pkg-utils\n * mode (`package.config.ts` is the sole config source), so their presence is worth a warning.\n */\nfunction warnAboutTsdownConfigFiles(cwd: string, logger: Logger): void {\n const candidates = [\n 'tsdown.config.ts',\n 'tsdown.config.mts',\n 'tsdown.config.cts',\n 'tsdown.config.js',\n 'tsdown.config.mjs',\n 'tsdown.config.cjs',\n 'tsdown.config.json',\n ]\n const found = candidates.find((candidate) => existsSync(path.resolve(cwd, candidate)))\n if (found) {\n logger.warn(\n `found \\`${found}\\`, which @sanity/pkg-utils does not load — \\`package.config.ts\\` is the only config source of \\`pkg build\\`. Either migrate the package fully to tsdown (and drop @sanity/pkg-utils), or move the configuration into \\`package.config.ts\\`.`,\n )\n }\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n","import {build} from '../node/build.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function buildAction(options: {\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n try {\n await build({\n cwd: process.cwd(),\n emitDeclarationOnly: options.emitDeclarationOnly,\n strict: options.strict,\n tsconfig: options.tsconfig,\n clean: options.clean,\n quiet: options.quiet,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;AAqBrB,eAAsBA,QAAM,SAOV;CAChB,IAAM,EACJ,KACA,qBACA,SAAS,IACT,UAAU,gBAGV,QAAQ,IACR,QAAQ,OACN,SACE,SAAS,aAAa,KAAK,GAE3B,UAAUC,GAAY,EAAC,IAAG,CAAC;CACjC,IAAI,CAAC,SACH,MAAU,MAAM,yBAAyB,EAAC,OAAO,EAAC,IAAG,EAAC,CAAC;CAEzD,IAAM,SAAS,MAAM,WAAW;EAAC;EAAK;CAAO,CAAC,GAExC,EAAC,uBAAsB,MAAM,OAAO,oCAAc,CAAA,MAAA,MAAA,EAAA,CAAA,GAClD,gBAAgB,mBAAmB,QAAQ,iBAAiB,CAAC,CAAC,GAC9D,MAAM,MAAM,qBAAqB;EAAC;EAAS;EAAQ;EAAQ;CAAa,CAAC,GAEzE,WAAW,kBAAkB,QAAQ,YAAY,iBAEjD,MAAM,MAAM,oBAAoB;EACpC;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,2BAA2B,KAAK,MAAM;CAEtC,IAAM,SAAS,oBAAoB,GAAG,GAElC,QAAQ;CACZ,KAAK,IAAM,YAAY,QAAQ;EAE7B,I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F;CACA,IAAM,OAAgB,KAAK,MAAM,IAAI;CACrC,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,UAAa,eAAe;CACxD,KAAK,QAAW;CAEhB,IAAM,SAAS,eAAe,KAAK,IAAI,CAAC,GAAG,MAAM,GAC7C,SAAS,KAAK,UAAU,MAAM,MAAM,MAAM;CAE9C,AADI,KAAK,SAAS,IAAI,MAAG,UAAU,OACnC,cAAc,SAAS,QAAQ,MAAM;AACvC;;;;;AAMA,SAAS,2BAA2B,KAAa,QAAsB;CAUrE,IAAM,QAAQ;EARZ;EACA;EACA;EACA;EACA;EACA;EACA;CAEqB,CAAC,CAAC,MAAM,cAAc,WAAW,KAAK,QAAQ,KAAK,SAAS,CAAC,CAAC;CACrF,AAAI,SACF,OAAO,KACL,WAAW,MAAM,6OACnB;AAEJ;AAEA,SAAS,aAAa,OAAuB;CAC3C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AC5PA,eAAsB,YAAY,SAMhB;CAChB,IAAI;EACF,MAAMC,QAAM;GACV,KAAK,QAAQ,IAAI;GACjB,qBAAqB,QAAQ;GAC7B,QAAQ,QAAQ;GAChB,UAAU,QAAQ;GAClB,OAAO,QAAQ;GACf,OAAO,QAAQ;EACjB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { i as fileExists, n as createLogger, t as handleError } from "./handleError-83GwKIFM.js";
2
- import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-i4HOnPda.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-Cp6bOuom.js";
3
3
  import { t as createSpinner } from "./spinner-DAHe7SuT.js";
4
4
  import { statSync } from "node:fs";
5
5
  import path from "node:path";
@@ -50,7 +50,7 @@ async function check(options) {
50
50
  let config = await loadConfig({
51
51
  cwd,
52
52
  pkgPath
53
- }), { parseStrictOptions } = await import("./resolveBuildContext-i4HOnPda.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
53
+ }), { parseStrictOptions } = await import("./resolveBuildContext-Cp6bOuom.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
54
54
  pkgPath,
55
55
  logger,
56
56
  strict,
@@ -143,4 +143,4 @@ async function checkAction(options) {
143
143
  }
144
144
  export { checkAction };
145
145
 
146
- //# sourceMappingURL=checkAction-BSYijAy1.js.map
146
+ //# sourceMappingURL=checkAction-hzCSdRlj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkAction-BSYijAy1.js","names":["findPkgPath"],"sources":["../src/node/getFilesize.ts","../src/node/printPackageTree.ts","../src/node/check.ts","../src/cli/checkAction.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n if (entry.browser.default) exp.browser.default = fileInfo(entry.browser.default)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n if (entry.node.default) exp.node.default = fileInfo(entry.node.default)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport {checkTsdoc} from '@sanity/tsdown-config/tsdoc'\nimport {up as findPkgPath} from 'empathic/package'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n }\n\n // publint validates that the built package resolves in every runtime/bundler — it packs\n // the package (which applies `publishConfig`, so the source-condition convention checks\n // out the way consumers see it) and lints the result. This replaced the bespoke\n // esbuild-based resolution checks of previous majors.\n await runPublint(ctx)\n\n if (ctx.config?.tsdoc !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function runPublint(ctx: BuildContext): Promise<void> {\n const {cwd, logger, strict} = ctx\n const [{publint}, {formatMessage}] = await Promise.all([\n import('publint'),\n import('publint/utils'),\n ])\n\n const {messages, pkg} = await publint({pkgDir: cwd, strict})\n\n let hasErrors = false\n\n for (const message of messages) {\n const formatted = formatMessage(message, pkg)\n if (message.type === 'error') {\n hasErrors = true\n logger.error(`publint: ${formatted}`)\n } else if (message.type === 'warning') {\n logger.warn(`publint: ${formatted}`)\n } else {\n logger.log(`publint: ${formatted}`)\n }\n }\n\n if (hasErrors) {\n process.exit(1)\n }\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const tsdoc =\n ctx.config?.tsdoc === false || ctx.config?.tsdoc === true ? undefined : ctx.config?.tsdoc\n const entryDtsFiles: string[] = []\n const seen = new Set<string>()\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n // Prefer an explicit `types` condition; otherwise derive declarations from every runtime\n // file (`.js` → `.d.ts`, `.mjs` → `.d.mts`, `.cjs` → `.d.cts`) so dual-format / fixed-\n // extension packages are checked the same way as the build-time `tsdoc` hook.\n const candidates = new Set<string>()\n if (exp.types) candidates.add(exp.types)\n for (const js of [exp.default, exp.import, exp.require]) {\n if (!js) continue\n const dts = jsFileToDts(js)\n if (dts) candidates.add(dts)\n }\n for (const dtsPath of candidates) {\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n // JS-only entries emit no declarations; there is nothing to check\n if (!fileExists(exportPath) || seen.has(exportPath)) continue\n seen.add(exportPath)\n entryDtsFiles.push(exportPath)\n }\n }\n\n if (entryDtsFiles.length === 0) return\n\n await checkTsdoc({\n cwd: ctx.cwd,\n entryDtsFiles,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n outDir: ctx.ts.config?.options.outDir ?? ctx.distPath,\n bundledPackages: ctx.bundledPackages,\n customTags: tsdoc?.customTags,\n rules: tsdoc?.rules,\n logger: {\n log: (...args) => ctx.logger.log(...args),\n warn: (...args) => ctx.logger.warn(...args),\n error: (...args) => ctx.logger.error(...args),\n },\n })\n}\n\n/** `./dist/index.js` → `./dist/index.d.ts` (`.mjs` → `.d.mts`, `.cjs` → `.d.cts`). */\nfunction jsFileToDts(file: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(file)) return file\n if (file.endsWith('.mjs')) return file.replace(/\\.mjs$/, '.d.mts')\n if (file.endsWith('.cjs')) return file.replace(/\\.cjs$/, '.d.cts')\n if (file.endsWith('.js')) return file.replace(/\\.js$/, '.d.ts')\n return undefined\n}\n","import {check} from '../node/check.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function checkAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await check({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,MAAsB;CAChD,IAAM,QAAQ,SAAS,IAAI;CAE3B,OAAO,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;CAClD,IAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC;CAG3B,OAAO;EAAC;EAAQ,MAFH,SAAS,YAAY,CAAC,IAAI,KAAA;CAEnB;AACtB;AAEA,SAAgB,iBAAiB,KAAyB;CACxD,IAAM,EAAC,KAAK,SAAS,QAAQ,QAAO;CAEpC,IAAI,CAAC,SAAS;CAEd,OAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,EAAE,GAAG,MAAM,MAAM,IAAI,OAAO,GAAG;CAEhE,IAAM,OAAgC,CAAC;CAMvC,AAJI,IAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGlC,IAAI,QACN,KAAK,MAAS,OAAO,YACnB,OAAO,QAAQ,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,C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AAS,KAAK,GAAG,OAAO,KAAK,QAAQ,SAAS,OAAO;AAEhE;ACrKA,eAAsB,YAAY,SAA+D;CAC/F,IAAI;EACF,MAAM,MAAM;GACV,KAAK,QAAQ,IAAI;GACjB,QAAQ,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
1
+ {"version":3,"file":"checkAction-hzCSdRlj.js","names":["findPkgPath"],"sources":["../src/node/getFilesize.ts","../src/node/printPackageTree.ts","../src/node/check.ts","../src/cli/checkAction.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n if (entry.browser.default) exp.browser.default = fileInfo(entry.browser.default)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n if (entry.node.default) exp.node.default = fileInfo(entry.node.default)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport {checkTsdoc} from '@sanity/tsdown-config/tsdoc'\nimport {up as findPkgPath} from 'empathic/package'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n }\n\n // publint validates that the built package resolves in every runtime/bundler — it packs\n // the package (which applies `publishConfig`, so the source-condition convention checks\n // out the way consumers see it) and lints the result. This replaced the bespoke\n // esbuild-based resolution checks of previous majors.\n await runPublint(ctx)\n\n if (ctx.config?.tsdoc !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function runPublint(ctx: BuildContext): Promise<void> {\n const {cwd, logger, strict} = ctx\n const [{publint}, {formatMessage}] = await Promise.all([\n import('publint'),\n import('publint/utils'),\n ])\n\n const {messages, pkg} = await publint({pkgDir: cwd, strict})\n\n let hasErrors = false\n\n for (const message of messages) {\n const formatted = formatMessage(message, pkg)\n if (message.type === 'error') {\n hasErrors = true\n logger.error(`publint: ${formatted}`)\n } else if (message.type === 'warning') {\n logger.warn(`publint: ${formatted}`)\n } else {\n logger.log(`publint: ${formatted}`)\n }\n }\n\n if (hasErrors) {\n process.exit(1)\n }\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const tsdoc =\n ctx.config?.tsdoc === false || ctx.config?.tsdoc === true ? undefined : ctx.config?.tsdoc\n const entryDtsFiles: string[] = []\n const seen = new Set<string>()\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n // Prefer an explicit `types` condition; otherwise derive declarations from every runtime\n // file (`.js` → `.d.ts`, `.mjs` → `.d.mts`, `.cjs` → `.d.cts`) so dual-format / fixed-\n // extension packages are checked the same way as the build-time `tsdoc` hook.\n const candidates = new Set<string>()\n if (exp.types) candidates.add(exp.types)\n for (const js of [exp.default, exp.import, exp.require]) {\n if (!js) continue\n const dts = jsFileToDts(js)\n if (dts) candidates.add(dts)\n }\n for (const dtsPath of candidates) {\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n // JS-only entries emit no declarations; there is nothing to check\n if (!fileExists(exportPath) || seen.has(exportPath)) continue\n seen.add(exportPath)\n entryDtsFiles.push(exportPath)\n }\n }\n\n if (entryDtsFiles.length === 0) return\n\n await checkTsdoc({\n cwd: ctx.cwd,\n entryDtsFiles,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n outDir: ctx.ts.config?.options.outDir ?? ctx.distPath,\n bundledPackages: ctx.bundledPackages,\n customTags: tsdoc?.customTags,\n rules: tsdoc?.rules,\n logger: {\n log: (...args) => ctx.logger.log(...args),\n warn: (...args) => ctx.logger.warn(...args),\n error: (...args) => ctx.logger.error(...args),\n },\n })\n}\n\n/** `./dist/index.js` → `./dist/index.d.ts` (`.mjs` → `.d.mts`, `.cjs` → `.d.cts`). */\nfunction jsFileToDts(file: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(file)) return file\n if (file.endsWith('.mjs')) return file.replace(/\\.mjs$/, '.d.mts')\n if (file.endsWith('.cjs')) return file.replace(/\\.cjs$/, '.d.cts')\n if (file.endsWith('.js')) return file.replace(/\\.js$/, '.d.ts')\n return undefined\n}\n","import {check} from '../node/check.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function checkAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await check({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,MAAsB;CAChD,IAAM,QAAQ,SAAS,IAAI;CAE3B,OAAO,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;CAClD,IAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC;CAG3B,OAAO;EAAC;EAAQ,MAFH,SAAS,YAAY,CAAC,IAAI,KAAA;CAEnB;AACtB;AAEA,SAAgB,iBAAiB,KAAyB;CACxD,IAAM,EAAC,KAAK,SAAS,QAAQ,QAAO;CAEpC,IAAI,CAAC,SAAS;CAEd,OAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,EAAE,GAAG,MAAM,MAAM,IAAI,OAAO,GAAG;CAEhE,IAAM,OAAgC,CAAC;CAMvC,AAJI,IAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGlC,IAAI,QACN,KAAK,MAAS,OAAO,YACnB,OAAO,QAAQ,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,CAClF;CAGF,SAAS,SAAS,MAAc;EAC9B,IAAM,OAAO,YAAY,KAAK,IAAI;EAMlC,OAJK,KAAK,OAIH,GAAG,MAAM,OAAO,IAAI,EAAE,GAAG,MAAM,KA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,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { cac } from "cac";
2
- var version = "13.0.0";
2
+ var version = "13.0.1";
3
3
  const cli = cac();
4
4
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
5
- let { checkAction } = await import("./checkAction-BSYijAy1.js");
5
+ let { checkAction } = await import("./checkAction-hzCSdRlj.js");
6
6
  return checkAction(options);
7
7
  }), cli.command("build", "Build package").option("--emitDeclarationOnly", "Emit d.ts only").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").option("--check", "Run the check command after build (same as running `pkg build && pkg check`)").option("--no-clean", "Skip cleaning the `dist` folder before the build").option("--quiet", "Suppress all output except errors, warnings, and checks").action(async (options) => {
8
- let { check = !1, ...buildOptions } = options, { buildAction } = await import("./buildAction-kavz9FnJ.js");
8
+ let { check = !1, ...buildOptions } = options, { buildAction } = await import("./buildAction-BbznO37s.js");
9
9
  if (await buildAction(buildOptions), check) {
10
- let { checkAction } = await import("./checkAction-BSYijAy1.js");
10
+ let { checkAction } = await import("./checkAction-hzCSdRlj.js");
11
11
  await checkAction({
12
12
  strict: options.strict,
13
13
  tsconfig: options.tsconfig
@@ -17,7 +17,7 @@ cli.command("", "Check").alias("check").option("--strict", "Strict mode").option
17
17
  let { initAction } = await import("./initAction-CmOO8eod.js");
18
18
  return initAction({ path: p });
19
19
  }), cli.command("watch", "Watch package").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
20
- let { watchAction } = await import("./watchAction-CIMqTWfx.js");
20
+ let { watchAction } = await import("./watchAction-fgVjJMTR.js");
21
21
  return watchAction(options);
22
22
  }), cli.help(), cli.version(version), cli.parse();
23
23
  export {};
package/dist/index.d.ts CHANGED
@@ -58,7 +58,10 @@ interface StrictOptions {
58
58
  */
59
59
  preferModuleType: ToggleType;
60
60
  /**
61
- * Warns if `publishConfig.exports` is missing when `source`, `development`, or `monorepo` conditions are used in exports.
61
+ * Warns if `publishConfig.exports` is missing when `source` or `monorepo` conditions are used in exports.
62
+ *
63
+ * A missing `publishConfig.exports` is always an error when `development` is used because
64
+ * publishing that condition breaks consumers whose tools select it.
62
65
  * @defaultValue 'warn'
63
66
  */
64
67
  noPublishConfigExports: ToggleType;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/node/strict.ts","../src/node/core/config/types.ts","../src/node/core/config/defineConfig.ts","../src/node/core/config/loadConfig.ts","../src/node/core/defaults.ts","../src/node/core/template/types.ts","../src/node/core/template/define.ts"],"mappings":";;;;;KAKK;;;;UAwCY;;;;;EAKf,sBAAsB;;;;;EAKtB,uBAAuB;;;;;;;;;EASvB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,cAAc;;;;;EAKd,sBAAsB;;;;;EAKtB,4BAA4B;;;;;EAK5B,kBAAkB;;;;;EAKlB,wBAAwB;;;;;EAKxB,yBAAyB;;;;;EAKzB,0BAA0B;;;;;EAK1B,6BAA6B;;;;;EAK7B,oBAAoB;;;;;EAKpB,8BAA8B;;;;;EAK9B,mBAAmB;;;;;EAKnB,sBAAsB;;;;;EAKtB,wBAAwB;;;;;EAKxB,2BAA2B;;;;;EAK3B,uBAAuB;;;;;EAKvB,sBAAsB;;;;;EAKtB,8BAA8B;;;;;;;UCzHf,kCACP,QAAQ,gBAAkC;;;;;EAKlD;;;;;;;UAQe,gCACP,wBAAyB;;EAEjC;;;;;;KAOU,uBAAuB,4BAA4B;;KAGnD;;KAGA;;KAGA,0BAA0B,MAAM,MAAM,MAAM;;KAG5C,kBAAkB,KAAK,0BAA0B,KAAK;;UAGjD;EACf;EACA;EACA;EACA,UAAU;;;;;;KAOA,eAAe;;;;;KAMf,iBAAiB;;;;;;;KAQjB,kBAAkB;;UAGb;EACf,UAAU;;;;;;;;;;;;;;;;;;;EAmBV,2BAA2B;;;;;;;;;EAS3B,QAAQ;;;;;;;;;;;;;;;;;;;;EAoBR,MAAM;;EAEN,SAAS;;;;;;;;EAQT,OAAO;;;;EAIP;;;;;;;EAOA,cAAc,QAAQ,YAAY;EAClC,UAAU,kBAAkB;;;;;;;;;;;EAW5B,WAAW;;;;;;;;EAQX;;;;;;;;EAQA;;;;;;;EAOA,UAAU;;;;;;;;EAQV,0BAA0B;;;;EAI1B,UAAU;EACV;;;;EAIA;;;;EAIA,gBAAgB,QAAQ;;;;;;;EAOxB,6BAA6B;EAC7B;;;;;;;EAOA,kBAAkB;;;;;;;;;;EAUlB,2BAA2B;;;;;;;EAa3B;;;;;;;;EAQA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;;;;EAQA;;;;;EAKA;;;wBCxTc,mBAAmB,UAAU,kBAAkB,eAAe,IAAI;;wBCK5D,WAAW;EAC/B;EACA;IACE,QAAQ;;qBCRC;;UCMI,wBAAwB;EACvC;EACA;EACA;EACA,UAAU,MAAM,SAAS,wBAAwB;EACjD,SAAS,cAAc;EACvB,YAAY;;;KAIF,kBAAkB,cAAc,wBAAwB;;wBChBpD,qBAAqB,GAAG,QAAQ,kBAAkB,KAAK,kBAAkB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/node/strict.ts","../src/node/core/config/types.ts","../src/node/core/config/defineConfig.ts","../src/node/core/config/loadConfig.ts","../src/node/core/defaults.ts","../src/node/core/template/types.ts","../src/node/core/template/define.ts"],"mappings":";;;;;KAKK;;;;UAwCY;;;;;EAKf,sBAAsB;;;;;EAKtB,uBAAuB;;;;;;;;;EASvB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,cAAc;;;;;EAKd,sBAAsB;;;;;EAKtB,4BAA4B;;;;;EAK5B,kBAAkB;;;;;;;;EAQlB,wBAAwB;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,SAAS,wBAAwB;EACjD,SAAS,cAAc;EACvB,YAAY;;;KAIF,kBAAkB,cAAc,wBAAwB;;wBChBpD,qBAAqB,GAAG,QAAQ,kBAAkB,KAAK,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"initAction-CmOO8eod.js","names":["parseGithubUrl","prettierConfig"],"sources":["../src/node/core/template/createFromTemplate.ts","../src/node/core/template/define.ts","../src/node/isEmptyDirectory.ts","../../../../node_modules/.pnpm/@sanity+prettier-config@3.0.0_prettier@3.9.6/node_modules/@sanity/prettier-config/dist/index.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/parse-url.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/index.js","../src/node/templates/default/template.ts","../src/node/init.ts","../src/cli/initAction.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\nimport {dirname, relative, resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport prompts from 'prompts'\nimport type {Logger} from '../../logger.ts'\nimport type {PkgTemplate} from './types.ts'\n\nconst promptsTypes = {\n string: 'text' as const,\n}\n\n/** @internal */\nexport async function createFromTemplate(options: {\n cwd: string\n logger: Logger\n packagePath: string\n template: PkgTemplate\n}): Promise<void> {\n const {cwd, logger, packagePath, template: templateOrResolver} = options\n\n const template =\n typeof templateOrResolver === 'function'\n ? await templateOrResolver({cwd, logger, packagePath})\n : templateOrResolver\n\n logger.log('create new package at', relative(cwd, packagePath))\n\n const templateOptions: Record<string, string> = {}\n\n for (const templateOption of template.options) {\n const templateValidate = templateOption.validate\n\n const res = await prompts(\n {\n type: promptsTypes[templateOption.type],\n name: templateOption.name,\n message: templateOption.description,\n validate: templateValidate ? (prev) => templateValidate(prev) : undefined,\n initial:\n typeof templateOption.initial === 'function'\n ? templateOption.initial(templateOptions)\n : templateOption.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n\n templateOptions[templateOption.name] = templateOption.parse\n ? templateOption.parse(res[templateOption.name])\n : res[templateOption.name]\n }\n\n const features: Record<string, boolean> = {}\n\n for (const templateFeature of template.features) {\n const res = templateFeature.optional\n ? await prompts(\n {\n type: 'confirm',\n name: 'confirm',\n message: `use ${templateFeature.name}?`,\n initial: templateFeature.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n : undefined\n\n features[templateFeature.name] = res?.confirm || !templateFeature.optional\n }\n\n const files = await template.getFiles(templateOptions, features)\n\n files.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n for (const file of files) {\n const filePath = resolve(packagePath, file.name)\n\n await mkdirp(dirname(filePath))\n await writeFile(filePath, file.contents.trim() + '\\n')\n\n logger.success(`wrote ${relative(cwd, filePath)}`)\n }\n}\n","import type {PkgTemplateOption} from './types.ts'\n\n/** @public */\nexport function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T> {\n return option\n}\n","import {readdir} from 'node:fs/promises'\n\nexport async function isEmptyDirectory(dirPath: string): Promise<boolean> {\n return (await readdir(dirPath)).length === 0\n}\n","const overridableDefaults = {\n endOfLine: \"lf\",\n tabWidth: 2,\n useTabs: !1\n}, json5 = {\n files: [\"*.json5\"],\n options: {\n quoteProps: \"preserve\",\n singleQuote: !1\n }\n}, yaml = {\n files: [\"*.yml\"],\n options: {\n singleQuote: !1\n }\n}, config = {\n ...overridableDefaults,\n printWidth: 100,\n semi: !1,\n singleQuote: !0,\n quoteProps: \"consistent\",\n bracketSpacing: !1,\n plugins: [\"prettier-plugin-packagejson\"],\n overrides: [json5, yaml]\n};\nexport {\n config as default\n};\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nvar urlModule = require('url');\nvar URLCtor = typeof URL === 'undefined' ? urlModule.URL || null : URL;\nvar legacyURLParse = URLCtor ? null : urlModule.parse;\n\nfunction parseWHATWG(str) {\n\ttry {\n\t\tvar u = new URLCtor(str);\n\t\tvar auth = null;\n\t\tif (u.username) {\n\t\t\tauth = u.password ? u.username + ':' + u.password : u.username;\n\t\t}\n\t\tvar host = u.host || null;\n\t\tvar hostname = u.hostname || null;\n\t\tvar pathname = u.pathname || null;\n\t\tvar path = u.pathname + (u.search || '') || null;\n\n\t\t// For non-special schemes without '//' (e.g. 'github:user/repo', 'foo:bar'),\n\t\t// the WHATWG URL API produces an opaque path (host is empty). Replicate the\n\t\t// legacy url.parse() behavior: treat the first path segment as the host.\n\t\tif (!host && pathname && str.indexOf('//') === -1) {\n\t\t\tvar slashIdx = pathname.indexOf('/');\n\t\t\tif (slashIdx === -1) {\n\t\t\t\t// e.g. 'foo:bar' — no path segment, only a host-like token → null path\n\t\t\t\thost = pathname;\n\t\t\t\thostname = pathname;\n\t\t\t\tpathname = null;\n\t\t\t\tpath = null;\n\t\t\t} else {\n\t\t\t\t// e.g. 'github:user/repo' — first segment is host, rest is path\n\t\t\t\thost = pathname.slice(0, slashIdx);\n\t\t\t\thostname = host;\n\t\t\t\tpathname = pathname.slice(slashIdx);\n\t\t\t\tpath = pathname + (u.search || '');\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tauth: auth,\n\t\t\thash: u.hash || null,\n\t\t\thost: host,\n\t\t\thostname: hostname,\n\t\t\thref: u.href,\n\t\t\tpath: path,\n\t\t\tpathname: pathname,\n\t\t\tport: u.port || null,\n\t\t\tprotocol: u.protocol || null,\n\t\t\tquery: u.search ? u.search.slice(1) : null,\n\t\t\tsearch: u.search || null,\n\t\t\tslashes: str.indexOf('//') === -1 ? null : true\n\t\t};\n\t} catch (_) {\n\t\t// Fall back for non-standard strings (bare paths, git@ URLs, etc.)\n\t\tvar hashIdx = str.indexOf('#');\n\t\tvar hash = hashIdx === -1 ? null : str.slice(hashIdx);\n\t\tvar pathPart = hashIdx === -1 ? str : str.slice(0, hashIdx);\n\t\tvar queryIdx = pathPart.indexOf('?');\n\t\tvar search = queryIdx === -1 ? null : pathPart.slice(queryIdx);\n\t\tvar pathnamePart = queryIdx === -1 ? pathPart : pathPart.slice(0, queryIdx);\n\t\treturn {\n\t\t\tauth: null,\n\t\t\thash: hash,\n\t\t\thost: null,\n\t\t\thostname: null,\n\t\t\thref: str,\n\t\t\tpath: pathPart || null,\n\t\t\tpathname: pathnamePart || null,\n\t\t\tport: null,\n\t\t\tprotocol: null,\n\t\t\tquery: search ? search.slice(1) : null,\n\t\t\tsearch: search,\n\t\t\tslashes: null\n\t\t};\n\t}\n}\n\nmodule.exports = URLCtor ? parseWHATWG : legacyURLParse;\n","/*!\n * parse-github-url <https://github.com/jonschlinkert/parse-github-url>\n *\n * Copyright (c) 2015-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n'use strict';\n\nvar parseURL = require('./parse-url');\nvar cache = { __proto__: null };\n\nfunction isChecksum(str) {\n\treturn (/^[a-f0-9]{40}$/i).test(str);\n}\n\nfunction getBranch(str, obj) {\n\tvar segs = str.split('#');\n\tvar branch;\n\tif (segs.length > 1) {\n\t\tbranch = segs[segs.length - 1];\n\t}\n\tif (!branch && obj.hash && obj.hash.charAt(0) === '#') {\n\t\tbranch = obj.hash.slice(1);\n\t}\n\treturn branch || 'master';\n}\n\nfunction trimSlash(path) {\n\treturn path.charAt(0) === '/' ? path.slice(1) : path;\n}\n\nfunction name(str) {\n\treturn str ? str.replace(/\\.git$/, '') : null;\n}\n\nfunction owner(str) {\n\tif (!str) {\n\t\treturn null;\n\t}\n\tvar idx = str.indexOf(':');\n\tif (idx > -1) {\n\t\treturn str.slice(idx + 1);\n\t}\n\treturn str;\n}\n\n/**\n * Extract the host from a git@ URL using the WHATWG URL API.\n */\nfunction getGitAtHost(str) {\n\tvar transformed = 'http://' + str.replace(/git@([^:]+):/, '$1/');\n\treturn parseURL(transformed).host || null;\n}\n\nfunction parse(str) {\n\tif (typeof str !== 'string' || !str.length) {\n\t\treturn null;\n\t}\n\n\tif (str.indexOf('git@gist') !== -1 || str.indexOf('//gist') !== -1) {\n\t\treturn null;\n\t}\n\n\t// parse the URL\n\tvar obj = parseURL(str);\n\tif (typeof obj.path !== 'string' || !obj.path.length || typeof obj.pathname !== 'string' || !obj.pathname.length) {\n\t\treturn null;\n\t}\n\n\tif (!obj.host && (/^git@/).test(str) === true) {\n\t\t// return the correct host for git@ URLs\n\t\tobj.host = getGitAtHost(str);\n\t}\n\n\tobj.path = trimSlash(obj.path);\n\tobj.pathname = trimSlash(obj.pathname);\n\tobj.filepath = null;\n\n\tif (obj.path.indexOf('repos') === 0) {\n\t\tobj.path = obj.path.slice(6);\n\t}\n\n\tvar seg = obj.path.split('/').filter(Boolean);\n\tvar hasBlob = seg[2] === 'blob';\n\tif (hasBlob && !isChecksum(seg[3])) {\n\t\tobj.branch = seg[3];\n\t\tif (seg.length > 4) {\n\t\t\tobj.filepath = seg.slice(4).join('/');\n\t\t}\n\t}\n\n\tvar blob = str.indexOf('blob');\n\tif (hasBlob && blob !== -1) {\n\t\tobj.blob = str.slice(blob + 5);\n\t}\n\n\tvar hasTree = seg[2] === 'tree';\n\tvar tree = str.indexOf('tree');\n\tif (hasTree && tree !== -1) {\n\t\tvar idx = tree + 5;\n\t\tvar branch = str.slice(idx);\n\t\tvar slash = branch.indexOf('/');\n\t\tif (slash !== -1) {\n\t\t\tbranch = branch.slice(0, slash);\n\t\t}\n\t\tobj.branch = branch;\n\t}\n\n\tobj.owner = owner(seg[0]);\n\tobj.name = name(seg[1]);\n\n\tif (seg.length > 1 && obj.owner && obj.name) {\n\t\tobj.repo = obj.owner + '/' + obj.name;\n\t} else {\n\t\tvar href = obj.href.split(':');\n\t\tif (href.length === 2 && obj.href.indexOf('//') === -1) {\n\t\t\tobj.repo = obj.repo || href[href.length - 1];\n\t\t\tvar repoSegments = obj.repo.split('/');\n\t\t\tobj.owner = repoSegments[0];\n\t\t\tobj.name = repoSegments[1];\n\n\t\t} else {\n\t\t\tvar match = obj.href.match(/\\/([^/]*)$/);\n\t\t\tobj.owner = match ? match[1] : null;\n\t\t\tobj.repo = null;\n\t\t}\n\n\t\tif (obj.repo && (!obj.owner || !obj.name)) {\n\t\t\tvar segs = obj.repo.split('/');\n\t\t\tif (segs.length === 2) {\n\t\t\t\tobj.owner = segs[0];\n\t\t\t\tobj.name = segs[1];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!obj.branch) {\n\t\tobj.branch = seg[2] || getBranch(obj.path, obj);\n\t\tif (seg.length > 3) {\n\t\t\tobj.filepath = seg.slice(3).join('/');\n\t\t}\n\t}\n\n\tobj.host = obj.host || 'github.com';\n\tobj.owner = obj.owner || null;\n\tobj.name = obj.name || null;\n\tobj.repository = obj.repo;\n\treturn obj;\n}\n\nmodule.exports = function parseGithubUrl(str) {\n\tif (!cache[str]) {\n\t\tcache[str] = parse(str);\n\t}\n\treturn cache[str];\n};\n","import {execSync} from 'node:child_process'\nimport {resolve} from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport prettierConfig from '@sanity/prettier-config'\nimport {getLatestVersion} from 'get-latest-version'\nimport {outdent} from 'outdent'\nimport parseGithubUrl from 'parse-github-url'\nimport {format, type Config as PrettierConfig} from 'prettier'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {defineTemplateOption} from '../../core/template/define.ts'\nimport {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types.ts'\n\nconst RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\\/)?[a-z0-9-~][a-z0-9-._~]*$/i\n\nexport const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {\n const gitConfig = getGitUserConfig(cwd)\n\n return {\n options: [\n defineTemplateOption<{owner: string; name: string}>({\n name: 'repo',\n type: 'string',\n description: 'git url',\n validate: (v) => {\n if (!v) return true\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n return 'invalid git url'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) return null\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n throw new Error('invalid git url')\n }\n\n return {source: result.host, owner: result.owner, name: result.name}\n },\n }),\n defineTemplateOption({\n name: 'pkgName',\n type: 'string',\n description: 'package name',\n initial: (options) => options['repo']?.name || undefined,\n validate: (v) => {\n if (!v) return 'package name is required'\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n return 'invalid package name'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) {\n throw new Error('package name is required')\n }\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n throw new Error('invalid package name')\n }\n\n const [scope, name] = v.split('/')\n\n return {scope, name, fullName: v}\n },\n }),\n defineTemplateOption({\n name: 'description',\n type: 'string',\n description: 'package description',\n }),\n defineTemplateOption({\n name: 'authorName',\n type: 'string',\n description: 'package author name',\n initial: gitConfig.user,\n }),\n defineTemplateOption({\n name: 'authorEmail',\n type: 'string',\n description: 'package author email',\n initial: gitConfig.email,\n }),\n defineTemplateOption({\n name: 'license',\n type: 'string',\n description: 'package license',\n initial: 'MIT',\n validate: (v) => {\n if (!v) return 'license is required'\n\n return true\n },\n }),\n ],\n\n features: [\n {\n name: 'eslint',\n optional: true,\n initial: true,\n },\n {\n name: 'prettier',\n optional: true,\n initial: true,\n },\n {\n name: 'typescript',\n optional: true,\n initial: true,\n },\n ],\n\n async getFiles(options, features) {\n const {pkgName, repo} = options\n const {fullName: name} = pkgName\n\n const author =\n [options['authorName'], options['authorEmail'] && `<${options['authorEmail']}>`]\n .filter(Boolean)\n .join(' ') ?? undefined\n\n const pkgJson: PackageJSON & {\n prettier?: '@sanity/prettier-config'\n ['lint-staged']?: Record<string, string[]>\n } = {\n name,\n 'version': '0.0.0',\n 'description': options['description'] ?? undefined,\n 'keywords': [],\n 'homepage': undefined,\n 'bugs': undefined,\n 'repository': undefined,\n 'license': options['license'],\n author,\n 'sideEffects': false,\n 'type': 'module',\n 'exports': {\n '.': {\n source: features['typescript'] ? './src/index.ts' : './src/index.js',\n require: './dist/index.cjs',\n default: './dist/index.js',\n },\n './package.json': './package.json',\n },\n 'main': './dist/index.cjs',\n 'module': './dist/index.js',\n 'types': undefined,\n 'files': ['dist', 'src'],\n 'scripts': {\n build: 'pkg build --strict --clean --check',\n format: features['prettier'] ? 'prettier --write --cache --ignore-unknown .' : undefined,\n },\n 'lint-staged': features['prettier']\n ? {\n '*': ['prettier --write --cache --ignore-unknown'],\n }\n : undefined,\n 'browserslist': 'extends @sanity/browserslist-config',\n 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,\n 'dependencies': {},\n 'devDependencies': {\n '@sanity/tsconfig': features['typescript'] ? '^1' : undefined,\n '@sanity/pkg-utils': '^9',\n '@sanity/prettier-config': features['prettier'] ? '^1' : undefined,\n '@typescript-eslint/eslint-plugin': undefined,\n '@typescript-eslint/parser': undefined,\n 'eslint': undefined,\n 'eslint-config-prettier': undefined,\n 'eslint-plugin-import': undefined,\n 'eslint-plugin-prettier': undefined,\n 'eslint-plugin-simple-import-sort': undefined,\n 'lint-staged': '^15',\n 'prettier': features['prettier'] ? '^3' : undefined,\n 'typescript': undefined,\n },\n 'engines': {\n node: '>=20.19 <22 || >=22.12',\n },\n }\n\n const files: PkgTemplateFile[] = []\n\n // .editorconfig\n files.push({\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n charset = utf-8\n indent_style = space\n indent_size = 2\n end_of_line = lf\n insert_final_newline = true\n trim_trailing_whitespace = true\n `,\n })\n\n // .gitignore\n files.push({\n name: '.gitignore',\n contents: outdent`\n *.local\n *.log\n *.tgz\n\n .DS_Store\n dist\n etc\n node_modules\n `,\n })\n\n if (features['prettier']) {\n files.push({\n name: '.prettierignore',\n contents: outdent`\n dist\n pnpm-lock.yaml\n `,\n })\n }\n\n if (repo) {\n pkgJson.repository = {\n type: 'git',\n url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`,\n }\n pkgJson.bugs = {\n url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`,\n }\n pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`\n }\n\n if (features['typescript']) {\n pkgJson.types = './dist/index.d.ts'\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n ['ts:check']: 'tsc --noEmit',\n }\n\n const devDependencies = pkgJson.devDependencies\n\n if (isRecord(devDependencies)) {\n devDependencies['typescript'] = '^5.9'\n }\n }\n\n if (features['eslint']) {\n const eslintConfig: any = {\n root: true,\n env: {\n browser: true,\n es6: true,\n node: true,\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n ].filter(Boolean),\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n plugins: [\n 'import',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n 'no-console': 'error',\n 'no-shadow': 'error',\n 'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],\n 'quote-props': ['warn', 'consistent-as-needed'],\n 'simple-import-sort/exports': 'warn',\n 'simple-import-sort/imports': 'warn',\n 'strict': ['warn', 'global'],\n },\n }\n\n files.push({\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n })\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n lint: features['typescript']\n ? 'eslint . --ext .cjs,.js,.ts,.tsx'\n : 'eslint . --ext .cjs,.js',\n }\n\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n 'eslint': '^8',\n 'eslint-config-prettier': features['prettier'] ? '^9' : undefined,\n 'eslint-plugin-import': '^2',\n 'eslint-plugin-prettier': features['prettier'] ? '^5' : undefined,\n 'eslint-plugin-simple-import-sort': '^12',\n }\n\n if (features['typescript']) {\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n '@typescript-eslint/eslint-plugin': '^7',\n '@typescript-eslint/parser': '^7',\n }\n\n const eslintConfigOverride: any = {\n files: ['**/*.ts', '**/*.tsx'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n project: ['./tsconfig.json'],\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n 'plugin:@typescript-eslint/eslint-recommended',\n 'plugin:@typescript-eslint/recommended',\n ].filter(Boolean),\n plugins: [\n 'import',\n '@typescript-eslint',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n '@typescript-eslint/explicit-module-boundary-types': 'error',\n '@typescript-eslint/interface-name-prefix': 'off',\n '@typescript-eslint/member-delimiter-style': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n },\n }\n\n eslintConfig.overrides = [eslintConfigOverride]\n }\n\n files.push({\n name: '.eslintrc.cjs',\n contents: await prettierFormat(\n resolve(packagePath, '.eslintrc.cjs'),\n outdent`\n 'use strict'\n\n /** @type import('eslint').Linter.Config */\n module.exports = ${JSON.stringify(eslintConfig, null, 2)}\n `,\n prettierConfig,\n ),\n })\n }\n\n if (features['typescript']) {\n files.push({\n name: 'tsconfig.settings.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.settings.json'),\n outdent`\n {\n \"extends\": \"@sanity/tsconfig/strictest\",\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./dist\"\n }\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.dist.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.dist.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\"./src/**/*.test.ts\"]\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./**/*.cjs\", \"./**/*.ts\", \"./**/*.tsx\"],\n \"exclude\": [\"./node_modules\"]\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // source file\n if (features['typescript']) {\n files.push({\n name: 'package.config.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.ts'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n // https://github.com/sanity-io/pkg-utils#configuration\n export default defineConfig({\n // the path to the tsconfig file for distributed builds\n tsconfig: 'tsconfig.dist.json',\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.ts'),\n outdent`\n /** @public */\n export function main(): void {\n //\n }\n `,\n prettierConfig,\n ),\n })\n } else {\n files.push({\n name: 'package.config.js',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.js'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n extract: {\n rules: {\n // do not require internal members to be prefixed with \\`_\\`\n 'ae-internal-missing-underscore': 'off',\n },\n },\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.js',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.js'),\n outdent`\n /** @public */\n export function main() {\n //\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // Resolve latest dependencies\n try {\n pkgJson.dependencies = await resolveLatestDeps(pkgJson.dependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n // Resolve latest devDependencies\n try {\n pkgJson.devDependencies = await resolveLatestDeps(pkgJson.devDependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n files.push({\n name: 'package.json',\n contents: await prettierFormat(\n resolve(packagePath, 'package.json'),\n JSON.stringify(pkgJson, null, 2),\n prettierConfig,\n ),\n })\n\n return files\n },\n }\n}\n\nfunction prettierFormat(\n filepath: string,\n input: string,\n prettierOptions: PrettierConfig | undefined,\n) {\n return format(input, {...prettierOptions, plugins: [], filepath})\n}\n\nasync function resolveLatestDeps(deps: Record<string, string | undefined>) {\n const depsEntries = Object.entries(deps)\n const latestDeps: Record<string, string> = {}\n\n for (const entry of depsEntries) {\n const [name, version] = entry\n\n if (version) {\n const latestVersion = await getLatestVersion(name, {range: version})\n\n latestDeps[name] = latestVersion ? `^${latestVersion}` : version\n }\n }\n\n return latestDeps\n}\n\nfunction getGitUserConfig(cwd: string): {user: string | undefined; email: string | undefined} {\n let user: string | undefined\n let email: string | undefined\n\n try {\n user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined\n email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined\n } catch {\n /* ignore */\n }\n\n return {user, email}\n}\n","import {lstat} from 'node:fs/promises'\nimport {resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport {createFromTemplate} from './core/template/index.ts'\nimport {fileExists} from './fileExists.ts'\nimport {isEmptyDirectory} from './isEmptyDirectory.ts'\nimport {createLogger} from './logger.ts'\nimport {defaultTemplate} from './templates/default/template.ts'\n\n/** @public */\nexport async function init(options: {cwd: string; path: string}): Promise<void> {\n if (!options.cwd) {\n throw new Error('Missing required option: cwd')\n }\n\n if (!options.path) {\n throw new Error('Missing required option: path')\n }\n\n const logger = createLogger()\n\n const packagePath = resolve(options.cwd, options.path)\n\n await ensurePackagePath(packagePath)\n\n await createFromTemplate({\n cwd: options.cwd,\n logger,\n template: defaultTemplate,\n packagePath,\n })\n}\n\nasync function ensurePackagePath(packagePath: string): Promise<void> {\n const exists = fileExists(packagePath)\n\n if (!exists) {\n await mkdirp(packagePath)\n\n return\n }\n\n const dir = (await lstat(packagePath)).isDirectory()\n\n if (!dir) {\n throw new Error('the package path is a file, not a directory')\n }\n\n const empty = await isEmptyDirectory(packagePath)\n\n if (!empty) {\n throw new Error('the package directory is not empty')\n }\n}\n","import {init} from '../node/init.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function initAction(options: {path: string}): Promise<void> {\n try {\n await init({\n cwd: process.cwd(),\n path: options.path,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"x_google_ignoreList":[3,4,5],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,EACnB,QAAQ,OACV;;AAGA,eAAsB,mBAAmB,SAKvB;CAChB,IAAM,EAAC,KAAK,QAAQ,aAAa,UAAU,uBAAsB,SAE3D,WACJ,OAAO,sBAAuB,aAC1B,M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WAAW,GAG9C,MAAU,MAAM,oCAAoC;AAExD;AClDA,eAAsB,WAAW,SAAwC;CACvE,IAAI;EACF,MAAM,KAAK;GACT,KAAK,QAAQ,IAAI;GACjB,MAAM,QAAQ;EAChB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
1
+ {"version":3,"file":"initAction-CmOO8eod.js","names":["parseGithubUrl","prettierConfig"],"sources":["../src/node/core/template/createFromTemplate.ts","../src/node/core/template/define.ts","../src/node/isEmptyDirectory.ts","../../../../node_modules/.pnpm/@sanity+prettier-config@3.0.0_prettier@3.9.8/node_modules/@sanity/prettier-config/dist/index.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/parse-url.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/index.js","../src/node/templates/default/template.ts","../src/node/init.ts","../src/cli/initAction.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\nimport {dirname, relative, resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport prompts from 'prompts'\nimport type {Logger} from '../../logger.ts'\nimport type {PkgTemplate} from './types.ts'\n\nconst promptsTypes = {\n string: 'text' as const,\n}\n\n/** @internal */\nexport async function createFromTemplate(options: {\n cwd: string\n logger: Logger\n packagePath: string\n template: PkgTemplate\n}): Promise<void> {\n const {cwd, logger, packagePath, template: templateOrResolver} = options\n\n const template =\n typeof templateOrResolver === 'function'\n ? await templateOrResolver({cwd, logger, packagePath})\n : templateOrResolver\n\n logger.log('create new package at', relative(cwd, packagePath))\n\n const templateOptions: Record<string, string> = {}\n\n for (const templateOption of template.options) {\n const templateValidate = templateOption.validate\n\n const res = await prompts(\n {\n type: promptsTypes[templateOption.type],\n name: templateOption.name,\n message: templateOption.description,\n validate: templateValidate ? (prev) => templateValidate(prev) : undefined,\n initial:\n typeof templateOption.initial === 'function'\n ? templateOption.initial(templateOptions)\n : templateOption.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n\n templateOptions[templateOption.name] = templateOption.parse\n ? templateOption.parse(res[templateOption.name])\n : res[templateOption.name]\n }\n\n const features: Record<string, boolean> = {}\n\n for (const templateFeature of template.features) {\n const res = templateFeature.optional\n ? await prompts(\n {\n type: 'confirm',\n name: 'confirm',\n message: `use ${templateFeature.name}?`,\n initial: templateFeature.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n : undefined\n\n features[templateFeature.name] = res?.confirm || !templateFeature.optional\n }\n\n const files = await template.getFiles(templateOptions, features)\n\n files.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n for (const file of files) {\n const filePath = resolve(packagePath, file.name)\n\n await mkdirp(dirname(filePath))\n await writeFile(filePath, file.contents.trim() + '\\n')\n\n logger.success(`wrote ${relative(cwd, filePath)}`)\n }\n}\n","import type {PkgTemplateOption} from './types.ts'\n\n/** @public */\nexport function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T> {\n return option\n}\n","import {readdir} from 'node:fs/promises'\n\nexport async function isEmptyDirectory(dirPath: string): Promise<boolean> {\n return (await readdir(dirPath)).length === 0\n}\n","const overridableDefaults = {\n endOfLine: \"lf\",\n tabWidth: 2,\n useTabs: !1\n}, json5 = {\n files: [\"*.json5\"],\n options: {\n quoteProps: \"preserve\",\n singleQuote: !1\n }\n}, yaml = {\n files: [\"*.yml\"],\n options: {\n singleQuote: !1\n }\n}, config = {\n ...overridableDefaults,\n printWidth: 100,\n semi: !1,\n singleQuote: !0,\n quoteProps: \"consistent\",\n bracketSpacing: !1,\n plugins: [\"prettier-plugin-packagejson\"],\n overrides: [json5, yaml]\n};\nexport {\n config as default\n};\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nvar urlModule = require('url');\nvar URLCtor = typeof URL === 'undefined' ? urlModule.URL || null : URL;\nvar legacyURLParse = URLCtor ? null : urlModule.parse;\n\nfunction parseWHATWG(str) {\n\ttry {\n\t\tvar u = new URLCtor(str);\n\t\tvar auth = null;\n\t\tif (u.username) {\n\t\t\tauth = u.password ? u.username + ':' + u.password : u.username;\n\t\t}\n\t\tvar host = u.host || null;\n\t\tvar hostname = u.hostname || null;\n\t\tvar pathname = u.pathname || null;\n\t\tvar path = u.pathname + (u.search || '') || null;\n\n\t\t// For non-special schemes without '//' (e.g. 'github:user/repo', 'foo:bar'),\n\t\t// the WHATWG URL API produces an opaque path (host is empty). Replicate the\n\t\t// legacy url.parse() behavior: treat the first path segment as the host.\n\t\tif (!host && pathname && str.indexOf('//') === -1) {\n\t\t\tvar slashIdx = pathname.indexOf('/');\n\t\t\tif (slashIdx === -1) {\n\t\t\t\t// e.g. 'foo:bar' — no path segment, only a host-like token → null path\n\t\t\t\thost = pathname;\n\t\t\t\thostname = pathname;\n\t\t\t\tpathname = null;\n\t\t\t\tpath = null;\n\t\t\t} else {\n\t\t\t\t// e.g. 'github:user/repo' — first segment is host, rest is path\n\t\t\t\thost = pathname.slice(0, slashIdx);\n\t\t\t\thostname = host;\n\t\t\t\tpathname = pathname.slice(slashIdx);\n\t\t\t\tpath = pathname + (u.search || '');\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tauth: auth,\n\t\t\thash: u.hash || null,\n\t\t\thost: host,\n\t\t\thostname: hostname,\n\t\t\thref: u.href,\n\t\t\tpath: path,\n\t\t\tpathname: pathname,\n\t\t\tport: u.port || null,\n\t\t\tprotocol: u.protocol || null,\n\t\t\tquery: u.search ? u.search.slice(1) : null,\n\t\t\tsearch: u.search || null,\n\t\t\tslashes: str.indexOf('//') === -1 ? null : true\n\t\t};\n\t} catch (_) {\n\t\t// Fall back for non-standard strings (bare paths, git@ URLs, etc.)\n\t\tvar hashIdx = str.indexOf('#');\n\t\tvar hash = hashIdx === -1 ? null : str.slice(hashIdx);\n\t\tvar pathPart = hashIdx === -1 ? str : str.slice(0, hashIdx);\n\t\tvar queryIdx = pathPart.indexOf('?');\n\t\tvar search = queryIdx === -1 ? null : pathPart.slice(queryIdx);\n\t\tvar pathnamePart = queryIdx === -1 ? pathPart : pathPart.slice(0, queryIdx);\n\t\treturn {\n\t\t\tauth: null,\n\t\t\thash: hash,\n\t\t\thost: null,\n\t\t\thostname: null,\n\t\t\thref: str,\n\t\t\tpath: pathPart || null,\n\t\t\tpathname: pathnamePart || null,\n\t\t\tport: null,\n\t\t\tprotocol: null,\n\t\t\tquery: search ? search.slice(1) : null,\n\t\t\tsearch: search,\n\t\t\tslashes: null\n\t\t};\n\t}\n}\n\nmodule.exports = URLCtor ? parseWHATWG : legacyURLParse;\n","/*!\n * parse-github-url <https://github.com/jonschlinkert/parse-github-url>\n *\n * Copyright (c) 2015-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n'use strict';\n\nvar parseURL = require('./parse-url');\nvar cache = { __proto__: null };\n\nfunction isChecksum(str) {\n\treturn (/^[a-f0-9]{40}$/i).test(str);\n}\n\nfunction getBranch(str, obj) {\n\tvar segs = str.split('#');\n\tvar branch;\n\tif (segs.length > 1) {\n\t\tbranch = segs[segs.length - 1];\n\t}\n\tif (!branch && obj.hash && obj.hash.charAt(0) === '#') {\n\t\tbranch = obj.hash.slice(1);\n\t}\n\treturn branch || 'master';\n}\n\nfunction trimSlash(path) {\n\treturn path.charAt(0) === '/' ? path.slice(1) : path;\n}\n\nfunction name(str) {\n\treturn str ? str.replace(/\\.git$/, '') : null;\n}\n\nfunction owner(str) {\n\tif (!str) {\n\t\treturn null;\n\t}\n\tvar idx = str.indexOf(':');\n\tif (idx > -1) {\n\t\treturn str.slice(idx + 1);\n\t}\n\treturn str;\n}\n\n/**\n * Extract the host from a git@ URL using the WHATWG URL API.\n */\nfunction getGitAtHost(str) {\n\tvar transformed = 'http://' + str.replace(/git@([^:]+):/, '$1/');\n\treturn parseURL(transformed).host || null;\n}\n\nfunction parse(str) {\n\tif (typeof str !== 'string' || !str.length) {\n\t\treturn null;\n\t}\n\n\tif (str.indexOf('git@gist') !== -1 || str.indexOf('//gist') !== -1) {\n\t\treturn null;\n\t}\n\n\t// parse the URL\n\tvar obj = parseURL(str);\n\tif (typeof obj.path !== 'string' || !obj.path.length || typeof obj.pathname !== 'string' || !obj.pathname.length) {\n\t\treturn null;\n\t}\n\n\tif (!obj.host && (/^git@/).test(str) === true) {\n\t\t// return the correct host for git@ URLs\n\t\tobj.host = getGitAtHost(str);\n\t}\n\n\tobj.path = trimSlash(obj.path);\n\tobj.pathname = trimSlash(obj.pathname);\n\tobj.filepath = null;\n\n\tif (obj.path.indexOf('repos') === 0) {\n\t\tobj.path = obj.path.slice(6);\n\t}\n\n\tvar seg = obj.path.split('/').filter(Boolean);\n\tvar hasBlob = seg[2] === 'blob';\n\tif (hasBlob && !isChecksum(seg[3])) {\n\t\tobj.branch = seg[3];\n\t\tif (seg.length > 4) {\n\t\t\tobj.filepath = seg.slice(4).join('/');\n\t\t}\n\t}\n\n\tvar blob = str.indexOf('blob');\n\tif (hasBlob && blob !== -1) {\n\t\tobj.blob = str.slice(blob + 5);\n\t}\n\n\tvar hasTree = seg[2] === 'tree';\n\tvar tree = str.indexOf('tree');\n\tif (hasTree && tree !== -1) {\n\t\tvar idx = tree + 5;\n\t\tvar branch = str.slice(idx);\n\t\tvar slash = branch.indexOf('/');\n\t\tif (slash !== -1) {\n\t\t\tbranch = branch.slice(0, slash);\n\t\t}\n\t\tobj.branch = branch;\n\t}\n\n\tobj.owner = owner(seg[0]);\n\tobj.name = name(seg[1]);\n\n\tif (seg.length > 1 && obj.owner && obj.name) {\n\t\tobj.repo = obj.owner + '/' + obj.name;\n\t} else {\n\t\tvar href = obj.href.split(':');\n\t\tif (href.length === 2 && obj.href.indexOf('//') === -1) {\n\t\t\tobj.repo = obj.repo || href[href.length - 1];\n\t\t\tvar repoSegments = obj.repo.split('/');\n\t\t\tobj.owner = repoSegments[0];\n\t\t\tobj.name = repoSegments[1];\n\n\t\t} else {\n\t\t\tvar match = obj.href.match(/\\/([^/]*)$/);\n\t\t\tobj.owner = match ? match[1] : null;\n\t\t\tobj.repo = null;\n\t\t}\n\n\t\tif (obj.repo && (!obj.owner || !obj.name)) {\n\t\t\tvar segs = obj.repo.split('/');\n\t\t\tif (segs.length === 2) {\n\t\t\t\tobj.owner = segs[0];\n\t\t\t\tobj.name = segs[1];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!obj.branch) {\n\t\tobj.branch = seg[2] || getBranch(obj.path, obj);\n\t\tif (seg.length > 3) {\n\t\t\tobj.filepath = seg.slice(3).join('/');\n\t\t}\n\t}\n\n\tobj.host = obj.host || 'github.com';\n\tobj.owner = obj.owner || null;\n\tobj.name = obj.name || null;\n\tobj.repository = obj.repo;\n\treturn obj;\n}\n\nmodule.exports = function parseGithubUrl(str) {\n\tif (!cache[str]) {\n\t\tcache[str] = parse(str);\n\t}\n\treturn cache[str];\n};\n","import {execSync} from 'node:child_process'\nimport {resolve} from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport prettierConfig from '@sanity/prettier-config'\nimport {getLatestVersion} from 'get-latest-version'\nimport {outdent} from 'outdent'\nimport parseGithubUrl from 'parse-github-url'\nimport {format, type Config as PrettierConfig} from 'prettier'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {defineTemplateOption} from '../../core/template/define.ts'\nimport {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types.ts'\n\nconst RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\\/)?[a-z0-9-~][a-z0-9-._~]*$/i\n\nexport const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {\n const gitConfig = getGitUserConfig(cwd)\n\n return {\n options: [\n defineTemplateOption<{owner: string; name: string}>({\n name: 'repo',\n type: 'string',\n description: 'git url',\n validate: (v) => {\n if (!v) return true\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n return 'invalid git url'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) return null\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n throw new Error('invalid git url')\n }\n\n return {source: result.host, owner: result.owner, name: result.name}\n },\n }),\n defineTemplateOption({\n name: 'pkgName',\n type: 'string',\n description: 'package name',\n initial: (options) => options['repo']?.name || undefined,\n validate: (v) => {\n if (!v) return 'package name is required'\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n return 'invalid package name'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) {\n throw new Error('package name is required')\n }\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n throw new Error('invalid package name')\n }\n\n const [scope, name] = v.split('/')\n\n return {scope, name, fullName: v}\n },\n }),\n defineTemplateOption({\n name: 'description',\n type: 'string',\n description: 'package description',\n }),\n defineTemplateOption({\n name: 'authorName',\n type: 'string',\n description: 'package author name',\n initial: gitConfig.user,\n }),\n defineTemplateOption({\n name: 'authorEmail',\n type: 'string',\n description: 'package author email',\n initial: gitConfig.email,\n }),\n defineTemplateOption({\n name: 'license',\n type: 'string',\n description: 'package license',\n initial: 'MIT',\n validate: (v) => {\n if (!v) return 'license is required'\n\n return true\n },\n }),\n ],\n\n features: [\n {\n name: 'eslint',\n optional: true,\n initial: true,\n },\n {\n name: 'prettier',\n optional: true,\n initial: true,\n },\n {\n name: 'typescript',\n optional: true,\n initial: true,\n },\n ],\n\n async getFiles(options, features) {\n const {pkgName, repo} = options\n const {fullName: name} = pkgName\n\n const author =\n [options['authorName'], options['authorEmail'] && `<${options['authorEmail']}>`]\n .filter(Boolean)\n .join(' ') ?? undefined\n\n const pkgJson: PackageJSON & {\n prettier?: '@sanity/prettier-config'\n ['lint-staged']?: Record<string, string[]>\n } = {\n name,\n 'version': '0.0.0',\n 'description': options['description'] ?? undefined,\n 'keywords': [],\n 'homepage': undefined,\n 'bugs': undefined,\n 'repository': undefined,\n 'license': options['license'],\n author,\n 'sideEffects': false,\n 'type': 'module',\n 'exports': {\n '.': {\n source: features['typescript'] ? './src/index.ts' : './src/index.js',\n require: './dist/index.cjs',\n default: './dist/index.js',\n },\n './package.json': './package.json',\n },\n 'main': './dist/index.cjs',\n 'module': './dist/index.js',\n 'types': undefined,\n 'files': ['dist', 'src'],\n 'scripts': {\n build: 'pkg build --strict --clean --check',\n format: features['prettier'] ? 'prettier --write --cache --ignore-unknown .' : undefined,\n },\n 'lint-staged': features['prettier']\n ? {\n '*': ['prettier --write --cache --ignore-unknown'],\n }\n : undefined,\n 'browserslist': 'extends @sanity/browserslist-config',\n 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,\n 'dependencies': {},\n 'devDependencies': {\n '@sanity/tsconfig': features['typescript'] ? '^1' : undefined,\n '@sanity/pkg-utils': '^9',\n '@sanity/prettier-config': features['prettier'] ? '^1' : undefined,\n '@typescript-eslint/eslint-plugin': undefined,\n '@typescript-eslint/parser': undefined,\n 'eslint': undefined,\n 'eslint-config-prettier': undefined,\n 'eslint-plugin-import': undefined,\n 'eslint-plugin-prettier': undefined,\n 'eslint-plugin-simple-import-sort': undefined,\n 'lint-staged': '^15',\n 'prettier': features['prettier'] ? '^3' : undefined,\n 'typescript': undefined,\n },\n 'engines': {\n node: '>=20.19 <22 || >=22.12',\n },\n }\n\n const files: PkgTemplateFile[] = []\n\n // .editorconfig\n files.push({\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n charset = utf-8\n indent_style = space\n indent_size = 2\n end_of_line = lf\n insert_final_newline = true\n trim_trailing_whitespace = true\n `,\n })\n\n // .gitignore\n files.push({\n name: '.gitignore',\n contents: outdent`\n *.local\n *.log\n *.tgz\n\n .DS_Store\n dist\n etc\n node_modules\n `,\n })\n\n if (features['prettier']) {\n files.push({\n name: '.prettierignore',\n contents: outdent`\n dist\n pnpm-lock.yaml\n `,\n })\n }\n\n if (repo) {\n pkgJson.repository = {\n type: 'git',\n url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`,\n }\n pkgJson.bugs = {\n url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`,\n }\n pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`\n }\n\n if (features['typescript']) {\n pkgJson.types = './dist/index.d.ts'\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n ['ts:check']: 'tsc --noEmit',\n }\n\n const devDependencies = pkgJson.devDependencies\n\n if (isRecord(devDependencies)) {\n devDependencies['typescript'] = '^5.9'\n }\n }\n\n if (features['eslint']) {\n const eslintConfig: any = {\n root: true,\n env: {\n browser: true,\n es6: true,\n node: true,\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n ].filter(Boolean),\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n plugins: [\n 'import',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n 'no-console': 'error',\n 'no-shadow': 'error',\n 'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],\n 'quote-props': ['warn', 'consistent-as-needed'],\n 'simple-import-sort/exports': 'warn',\n 'simple-import-sort/imports': 'warn',\n 'strict': ['warn', 'global'],\n },\n }\n\n files.push({\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n })\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n lint: features['typescript']\n ? 'eslint . --ext .cjs,.js,.ts,.tsx'\n : 'eslint . --ext .cjs,.js',\n }\n\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n 'eslint': '^8',\n 'eslint-config-prettier': features['prettier'] ? '^9' : undefined,\n 'eslint-plugin-import': '^2',\n 'eslint-plugin-prettier': features['prettier'] ? '^5' : undefined,\n 'eslint-plugin-simple-import-sort': '^12',\n }\n\n if (features['typescript']) {\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n '@typescript-eslint/eslint-plugin': '^7',\n '@typescript-eslint/parser': '^7',\n }\n\n const eslintConfigOverride: any = {\n files: ['**/*.ts', '**/*.tsx'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n project: ['./tsconfig.json'],\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n 'plugin:@typescript-eslint/eslint-recommended',\n 'plugin:@typescript-eslint/recommended',\n ].filter(Boolean),\n plugins: [\n 'import',\n '@typescript-eslint',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n '@typescript-eslint/explicit-module-boundary-types': 'error',\n '@typescript-eslint/interface-name-prefix': 'off',\n '@typescript-eslint/member-delimiter-style': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n },\n }\n\n eslintConfig.overrides = [eslintConfigOverride]\n }\n\n files.push({\n name: '.eslintrc.cjs',\n contents: await prettierFormat(\n resolve(packagePath, '.eslintrc.cjs'),\n outdent`\n 'use strict'\n\n /** @type import('eslint').Linter.Config */\n module.exports = ${JSON.stringify(eslintConfig, null, 2)}\n `,\n prettierConfig,\n ),\n })\n }\n\n if (features['typescript']) {\n files.push({\n name: 'tsconfig.settings.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.settings.json'),\n outdent`\n {\n \"extends\": \"@sanity/tsconfig/strictest\",\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./dist\"\n }\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.dist.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.dist.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\"./src/**/*.test.ts\"]\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./**/*.cjs\", \"./**/*.ts\", \"./**/*.tsx\"],\n \"exclude\": [\"./node_modules\"]\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // source file\n if (features['typescript']) {\n files.push({\n name: 'package.config.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.ts'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n // https://github.com/sanity-io/pkg-utils#configuration\n export default defineConfig({\n // the path to the tsconfig file for distributed builds\n tsconfig: 'tsconfig.dist.json',\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.ts'),\n outdent`\n /** @public */\n export function main(): void {\n //\n }\n `,\n prettierConfig,\n ),\n })\n } else {\n files.push({\n name: 'package.config.js',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.js'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n extract: {\n rules: {\n // do not require internal members to be prefixed with \\`_\\`\n 'ae-internal-missing-underscore': 'off',\n },\n },\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.js',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.js'),\n outdent`\n /** @public */\n export function main() {\n //\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // Resolve latest dependencies\n try {\n pkgJson.dependencies = await resolveLatestDeps(pkgJson.dependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n // Resolve latest devDependencies\n try {\n pkgJson.devDependencies = await resolveLatestDeps(pkgJson.devDependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n files.push({\n name: 'package.json',\n contents: await prettierFormat(\n resolve(packagePath, 'package.json'),\n JSON.stringify(pkgJson, null, 2),\n prettierConfig,\n ),\n })\n\n return files\n },\n }\n}\n\nfunction prettierFormat(\n filepath: string,\n input: string,\n prettierOptions: PrettierConfig | undefined,\n) {\n return format(input, {...prettierOptions, plugins: [], filepath})\n}\n\nasync function resolveLatestDeps(deps: Record<string, string | undefined>) {\n const depsEntries = Object.entries(deps)\n const latestDeps: Record<string, string> = {}\n\n for (const entry of depsEntries) {\n const [name, version] = entry\n\n if (version) {\n const latestVersion = await getLatestVersion(name, {range: version})\n\n latestDeps[name] = latestVersion ? `^${latestVersion}` : version\n }\n }\n\n return latestDeps\n}\n\nfunction getGitUserConfig(cwd: string): {user: string | undefined; email: string | undefined} {\n let user: string | undefined\n let email: string | undefined\n\n try {\n user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined\n email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined\n } catch {\n /* ignore */\n }\n\n return {user, email}\n}\n","import {lstat} from 'node:fs/promises'\nimport {resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport {createFromTemplate} from './core/template/index.ts'\nimport {fileExists} from './fileExists.ts'\nimport {isEmptyDirectory} from './isEmptyDirectory.ts'\nimport {createLogger} from './logger.ts'\nimport {defaultTemplate} from './templates/default/template.ts'\n\n/** @public */\nexport async function init(options: {cwd: string; path: string}): Promise<void> {\n if (!options.cwd) {\n throw new Error('Missing required option: cwd')\n }\n\n if (!options.path) {\n throw new Error('Missing required option: path')\n }\n\n const logger = createLogger()\n\n const packagePath = resolve(options.cwd, options.path)\n\n await ensurePackagePath(packagePath)\n\n await createFromTemplate({\n cwd: options.cwd,\n logger,\n template: defaultTemplate,\n packagePath,\n })\n}\n\nasync function ensurePackagePath(packagePath: string): Promise<void> {\n const exists = fileExists(packagePath)\n\n if (!exists) {\n await mkdirp(packagePath)\n\n return\n }\n\n const dir = (await lstat(packagePath)).isDirectory()\n\n if (!dir) {\n throw new Error('the package path is a file, not a directory')\n }\n\n const empty = await isEmptyDirectory(packagePath)\n\n if (!empty) {\n throw new Error('the package directory is not empty')\n }\n}\n","import {init} from '../node/init.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function initAction(options: {path: string}): Promise<void> {\n try {\n await init({\n cwd: process.cwd(),\n path: options.path,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"x_google_ignoreList":[3,4,5],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,EACnB,QAAQ,OACV;;AAGA,eAAsB,mBAAmB,SAKvB;CAChB,IAAM,EAAC,KAAK,QAAQ,aAAa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AU,MAAM,6CAA6C;CAK/D,IAAI,CAAC,MAFe,iBAAiB,WAAW,GAG9C,MAAU,MAAM,oCAAoC;AAExD;AClDA,eAAsB,WAAW,SAAwC;CACvE,IAAI;EACF,MAAM,KAAK;GACT,KAAK,QAAQ,IAAI;GACjB,MAAM,QAAQ;EAChB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
@@ -366,6 +366,10 @@ function areExportValuesEqual(input1, input2) {
366
366
  }
367
367
  return !1;
368
368
  }
369
+ /** @internal */
370
+ function containsExportCondition(value, condition) {
371
+ return Array.isArray(value) ? value.some((nestedValue) => containsExportCondition(nestedValue, condition)) : typeof value != "object" || !value ? !1 : Object.entries(value).some(([key, nestedValue]) => key === condition || containsExportCondition(nestedValue, condition));
372
+ }
369
373
  /** @alpha */
370
374
  async function loadPkgWithReporting(options) {
371
375
  let { pkgPath, logger, strict, strictOptions } = options;
@@ -403,7 +407,9 @@ async function loadPkgWithReporting(options) {
403
407
  exp.types && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`types\` condition shouldn't be used as dts files are generated in such a way that both CJS and ESM is supported`)), exp.module && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`module\` condition shouldn't be used as it's not well supported in all bundlers.`)), exp.development && exp.source && exp.development !== exp.source && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`development\` condition must have the same value as \`source\` when both are present. Expected "${exp.source}" but got "${exp.development}"`)), exp.monorepo && exp.source && exp.monorepo !== exp.source && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`monorepo\` condition must have the same value as \`source\` when both are present. Expected "${exp.source}" but got "${exp.monorepo}"`)), exp.node ? (exp.import && exp.node.import && !assertOrder("node", "import", keys) && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`node\` property should come before the \`import\` property`)), exp.node.module && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`node.module\` condition shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`)), !exp.node.source && exp.node.import && (exp.node.require || exp.require) && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs")) && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`node.import\` re-export pattern shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`)), exp.require && exp.node.require && exp.require === exp.node.require ? (shouldError = !0, logger.error(`exports["${expPath}"]: the \`node.require\` property isn't necessary as it's identical to \`require\``)) : exp.require && exp.node.require && !assertOrder("node", "require", keys) && (shouldError = !0, logger.error(`exports["${expPath}"]: the \`node\` property should come before the \`require\` property`))) : assertOrder("import", "require", keys) || logger.warn(`exports["${expPath}"]: the \`import\` property should come before the \`require\` property`), assertLast("default", keys) || (shouldError = !0, logger.error(`exports["${expPath}"]: the \`default\` property should be the last property`));
404
408
  }
405
409
  }
406
- if (strict && pkg.exports && Object.keys(pkg.exports).length > 0 && Object.entries(pkg.exports).some(([, exp]) => typeof exp == "string" || typeof exp == "object" && "svelte" in exp ? !1 : !!(exp.source || exp.development || exp.monorepo))) {
410
+ let hasDevelopmentCondition = containsExportCondition(pkg.exports, "development");
411
+ for (let [exportPath, publishExp] of Object.entries(pkg.publishConfig?.exports ?? {})) (exportPath === "development" || containsExportCondition(publishExp, "development")) && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`development\` condition; it must be filtered out before publishing`));
412
+ if ((strict || hasDevelopmentCondition) && pkg.exports && Object.keys(pkg.exports).length > 0 && (hasDevelopmentCondition || Object.entries(pkg.exports).some(([, exp]) => typeof exp == "string" || typeof exp == "object" && "svelte" in exp ? !1 : !!(exp.source || exp.monorepo)))) {
407
413
  if (pkg.publishConfig?.exports) {
408
414
  let publishExports = pkg.publishConfig.exports, isBuiltCssExport = (exportPath) => {
409
415
  if (!exportPath.endsWith(".css")) return !1;
@@ -432,7 +438,7 @@ async function loadPkgWithReporting(options) {
432
438
  }
433
439
  if ("svelte" in publishExp) continue;
434
440
  let exportConditions = Object.keys(exp).filter((k) => k !== "source" && k !== "development" && k !== "monorepo"), publishConditions = Object.keys(publishExp);
435
- "source" in publishExp && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`source\` condition`)), "development" in publishExp && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`development\` condition`)), "monorepo" in publishExp && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`monorepo\` condition`));
441
+ containsExportCondition(publishExp, "source") && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`source\` condition`)), containsExportCondition(publishExp, "monorepo") && (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: should not contain the \`monorepo\` condition`));
436
442
  for (let condition of exportConditions) condition in publishExp || (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: missing \`${condition}\` condition that exists in exports["${exportPath}"]`));
437
443
  for (let condition of publishConditions) exportConditions.includes(condition) || (shouldError = !0, logger.error(`publishConfig.exports["${exportPath}"]: unexpected \`${condition}\` condition that does not exist in exports["${exportPath}"]`));
438
444
  for (let condition of exportConditions) if (condition in publishExp) {
@@ -443,9 +449,10 @@ async function loadPkgWithReporting(options) {
443
449
  }
444
450
  }
445
451
  }
446
- } else {
447
- let msg = "package.json: `publishConfig.exports` is missing. Adding it helps avoid publishing to npm with the `source`, `development`, or `monorepo` condition that points to code that cannot be used by the resolver. See https://tsdown.dev/options/package-exports#dev-exports for more information.";
448
- strictOptions.noPublishConfigExports === "error" ? (shouldError = !0, logger.error(msg)) : strictOptions.noPublishConfigExports !== "off" && logger.warn(msg);
452
+ } else if (hasDevelopmentCondition) shouldError = !0, logger.error("package.json: `publishConfig.exports` is required when `exports` contains a `development` condition. It must define the published export map without `development`; otherwise tools such as Vite and Turbopack can select that condition from the published package. See https://tsdown.dev/options/package-exports#dev-exports for more information.");
453
+ else if (strictOptions.noPublishConfigExports !== "off") {
454
+ let msg = "package.json: `publishConfig.exports` is missing. Adding it helps avoid publishing to npm with the `source` or `monorepo` condition that points to code that cannot be used by the resolver. See https://tsdown.dev/options/package-exports#dev-exports for more information.";
455
+ strictOptions.noPublishConfigExports === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
449
456
  }
450
457
  }
451
458
  return shouldError && process.exit(1), pkg;
@@ -759,4 +766,4 @@ function transformPackageName(packageName) {
759
766
  }
760
767
  export { loadPkgWithReporting as a, pkgExtMap as i, strict_exports as n, loadConfig as o, fileEnding as r, resolveBuildContext as t };
761
768
 
762
- //# sourceMappingURL=resolveBuildContext-i4HOnPda.js.map
769
+ //# sourceMappingURL=resolveBuildContext-Cp6bOuom.js.map