@sanity/pkg-utils 9.2.3 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-es/buildAction.js +147 -2
- package/dist/_chunks-es/buildAction.js.map +1 -1
- package/dist/_chunks-es/checkAction.js +179 -2
- package/dist/_chunks-es/checkAction.js.map +1 -1
- package/dist/_chunks-es/createApiExtractorConfig.js +52 -0
- package/dist/_chunks-es/createApiExtractorConfig.js.map +1 -0
- package/dist/_chunks-es/createTSDocConfig.js +31 -0
- package/dist/_chunks-es/createTSDocConfig.js.map +1 -0
- package/dist/_chunks-es/defaults.js +39 -0
- package/dist/_chunks-es/defaults.js.map +1 -0
- package/dist/_chunks-es/define.js +7 -0
- package/dist/_chunks-es/define.js.map +1 -0
- package/dist/_chunks-es/fileExists.js +12 -0
- package/dist/_chunks-es/fileExists.js.map +1 -0
- package/dist/_chunks-es/getExtractMessagesConfig.js +83 -0
- package/dist/_chunks-es/getExtractMessagesConfig.js.map +1 -0
- package/dist/_chunks-es/handleError.js +25 -1
- package/dist/_chunks-es/handleError.js.map +1 -1
- package/dist/_chunks-es/index.js +8 -212
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/initAction.js +515 -2
- package/dist/_chunks-es/initAction.js.map +1 -1
- package/dist/_chunks-es/printExtractMessages.js +44 -0
- package/dist/_chunks-es/printExtractMessages.js.map +1 -0
- package/dist/_chunks-es/{consoleSpy.js → resolveBuildContext.js} +68 -95
- package/dist/_chunks-es/resolveBuildContext.js.map +1 -0
- package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
- package/dist/_chunks-es/watchAction.js +106 -2
- package/dist/_chunks-es/watchAction.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -183
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -10
- package/dist/_chunks-es/build.js +0 -150
- package/dist/_chunks-es/build.js.map +0 -1
- package/dist/_chunks-es/check.js +0 -189
- package/dist/_chunks-es/check.js.map +0 -1
- package/dist/_chunks-es/consoleSpy.js.map +0 -1
- package/dist/_chunks-es/init.js +0 -520
- package/dist/_chunks-es/init.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -37
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/watch.js +0 -109
- package/dist/_chunks-es/watch.js.map +0 -1
- package/tsconfig/isolated-declarations.json +0 -11
- package/tsconfig/recommended.json +0 -24
- package/tsconfig/strict.json +0 -15
- package/tsconfig/strictest.json +0 -16
|
@@ -1,5 +1,150 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { rimraf } from "rimraf";
|
|
3
|
+
import { loadConfig } from "./defaults.js";
|
|
4
|
+
import { getTargetPaths, loadPkgWithReporting, resolveBuildContext } from "./resolveBuildContext.js";
|
|
5
|
+
import { createLogger, handleError } from "./handleError.js";
|
|
6
|
+
import { createSpinner } from "./spinner.js";
|
|
7
|
+
import { buildTaskHandlers } from "./index.js";
|
|
8
|
+
function resolveBuildTasks(ctx) {
|
|
9
|
+
const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports$1 = Object.entries(ctx.exports || {}).map(
|
|
10
|
+
([_path, exp]) => ({ _path, ...exp })
|
|
11
|
+
), dtsTask = {
|
|
12
|
+
type: "build:dts",
|
|
13
|
+
entries: []
|
|
14
|
+
}, rolldownDtsTask = {}, rollupTasks = {};
|
|
15
|
+
function addRollupTaskEntry(format, runtime, entry) {
|
|
16
|
+
const buildId = `${format}:${runtime}`;
|
|
17
|
+
ctx.dts === "rolldown" && (rolldownDtsTask[buildId] ? rolldownDtsTask[buildId].entries.push(entry) : rolldownDtsTask[buildId] = {
|
|
18
|
+
type: "rolldown:dts",
|
|
19
|
+
buildId,
|
|
20
|
+
entries: [entry],
|
|
21
|
+
runtime,
|
|
22
|
+
format,
|
|
23
|
+
target: target[runtime]
|
|
24
|
+
}), ctx.emitDeclarationOnly || (rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
|
|
25
|
+
type: "build:js",
|
|
26
|
+
buildId,
|
|
27
|
+
entries: [entry],
|
|
28
|
+
runtime,
|
|
29
|
+
format,
|
|
30
|
+
target: target[runtime]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (ctx.dts === "api-extractor") {
|
|
34
|
+
for (const exp of exports$1) {
|
|
35
|
+
const importId = path.join(pkg.name, exp._path);
|
|
36
|
+
exp.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
37
|
+
importId,
|
|
38
|
+
exportPath: exp._path,
|
|
39
|
+
sourcePath: exp.source,
|
|
40
|
+
targetPaths: getTargetPaths(pkg.type, exp)
|
|
41
|
+
}), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
42
|
+
importId,
|
|
43
|
+
exportPath: exp._path,
|
|
44
|
+
sourcePath: exp.browser.source,
|
|
45
|
+
targetPaths: getTargetPaths(pkg.type, exp.browser)
|
|
46
|
+
}), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
47
|
+
importId,
|
|
48
|
+
exportPath: exp._path,
|
|
49
|
+
sourcePath: exp.node.source,
|
|
50
|
+
targetPaths: getTargetPaths(pkg.type, exp.node)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
for (const bundle of bundles)
|
|
54
|
+
if (bundle.source?.endsWith(".ts")) {
|
|
55
|
+
const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path.join(pkg.name, exportPath);
|
|
56
|
+
dtsTask.entries.push({
|
|
57
|
+
importId,
|
|
58
|
+
exportPath,
|
|
59
|
+
sourcePath: bundle.source,
|
|
60
|
+
targetPaths: getTargetPaths(pkg.type, bundle)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
dtsTask.entries.length && tasks.push(dtsTask);
|
|
64
|
+
}
|
|
65
|
+
for (const exp of exports$1) {
|
|
66
|
+
const output = exp.require;
|
|
67
|
+
output && addRollupTaskEntry("commonjs", ctx.runtime, {
|
|
68
|
+
path: exp._path,
|
|
69
|
+
source: exp.source,
|
|
70
|
+
output
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
for (const exp of exports$1) {
|
|
74
|
+
const output = exp.import;
|
|
75
|
+
output && addRollupTaskEntry("esm", ctx.runtime, {
|
|
76
|
+
path: exp._path,
|
|
77
|
+
source: exp.source,
|
|
78
|
+
output
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const exp of exports$1) {
|
|
82
|
+
const output = exp.browser?.require;
|
|
83
|
+
output && addRollupTaskEntry("commonjs", "browser", {
|
|
84
|
+
path: exp._path,
|
|
85
|
+
source: exp.browser?.source || exp.source,
|
|
86
|
+
output
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
for (const exp of exports$1) {
|
|
90
|
+
const output = exp.browser?.import;
|
|
91
|
+
output && addRollupTaskEntry("esm", "browser", {
|
|
92
|
+
path: exp._path,
|
|
93
|
+
source: exp.browser?.source || exp.source,
|
|
94
|
+
output
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
for (const bundle of bundles) {
|
|
98
|
+
const idx = bundles.indexOf(bundle);
|
|
99
|
+
bundle.require && addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
|
|
100
|
+
path: `__$$bundle_cjs_${idx}$$__`,
|
|
101
|
+
source: bundle.source,
|
|
102
|
+
output: bundle.require
|
|
103
|
+
}), bundle.import && addRollupTaskEntry("esm", bundle.runtime || ctx.runtime, {
|
|
104
|
+
path: `__$$bundle_esm_${idx}$$__`,
|
|
105
|
+
source: bundle.source,
|
|
106
|
+
output: bundle.import
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return tasks.push(...Object.values(rolldownDtsTask)), tasks.push(...Object.values(rollupTasks)), tasks;
|
|
110
|
+
}
|
|
111
|
+
async function build(options) {
|
|
112
|
+
const {
|
|
113
|
+
cwd,
|
|
114
|
+
emitDeclarationOnly,
|
|
115
|
+
strict = !1,
|
|
116
|
+
tsconfig: tsconfigOption,
|
|
117
|
+
clean = !1,
|
|
118
|
+
quiet = !1
|
|
119
|
+
} = options, logger = createLogger(quiet), config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./resolveBuildContext.js").then(function(n) {
|
|
120
|
+
return n.strict;
|
|
121
|
+
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({
|
|
122
|
+
config,
|
|
123
|
+
cwd,
|
|
124
|
+
emitDeclarationOnly,
|
|
125
|
+
logger,
|
|
126
|
+
pkg,
|
|
127
|
+
strict,
|
|
128
|
+
tsconfig
|
|
129
|
+
});
|
|
130
|
+
clean && (quiet || logger.log(
|
|
131
|
+
`Deleting the \`dist\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`
|
|
132
|
+
), await rimraf(ctx.distPath));
|
|
133
|
+
const buildTasks = resolveBuildTasks(ctx);
|
|
134
|
+
for (const task of buildTasks) {
|
|
135
|
+
const handler = buildTaskHandlers[task.type], taskName = handler.name(ctx, task), spinner = createSpinner(taskName, quiet);
|
|
136
|
+
try {
|
|
137
|
+
const result = await handler.exec(ctx, task).toPromise();
|
|
138
|
+
spinner.complete(), ctx.logger.log(), handler.complete(ctx, task, result);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
if (spinner.error(), err instanceof Error) {
|
|
141
|
+
const RE_CWD = new RegExp(cwd, "g");
|
|
142
|
+
ctx.logger.error(err.message.replace(RE_CWD, ".")), ctx.logger.log();
|
|
143
|
+
}
|
|
144
|
+
handler.error(ctx, task, err), process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
3
148
|
async function buildAction(options) {
|
|
4
149
|
try {
|
|
5
150
|
await build({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAction.js","sources":["../../src/cli/buildAction.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAGA,eAAsB,YAAY,SAMhB;AAChB,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,qBAAqB,QAAQ;AAAA,MAC7B,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
|
|
1
|
+
{"version":3,"file":"buildAction.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts","../../src/cli/buildAction.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsTask} from './tasks/dts/types.ts'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveBuildTasks} from './resolveBuildTasks.ts'\nimport {createSpinner} from './spinner.ts'\nimport {buildTaskHandlers} from './tasks/index.ts'\nimport {type BuildTask, type TaskHandler} from './tasks/types.ts'\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 clean = false,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const config = await loadConfig({cwd})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, 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 if (clean) {\n if (!quiet) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n }\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\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"],"names":["exports"],"mappings":";;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAA;AAEhD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OAAO,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;A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AAI,OAAO,IAAA;AAAA,MACb;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;ACvGA,eAAsB,YAAY,SAMhB;AAChB,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,qBAAqB,QAAQ;AAAA,MAC7B,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
|
|
@@ -1,5 +1,182 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { loadPkgWithReporting, resolveBuildContext, createConsoleSpy } from "./resolveBuildContext.js";
|
|
3
|
+
import { loadConfig } from "./defaults.js";
|
|
4
|
+
import { fileExists } from "./fileExists.js";
|
|
5
|
+
import { createLogger, handleError } from "./handleError.js";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import treeify from "treeify";
|
|
8
|
+
import { statSync } from "node:fs";
|
|
9
|
+
import prettyBytes from "pretty-bytes";
|
|
10
|
+
import { createSpinner } from "./spinner.js";
|
|
11
|
+
function getFilesize(file) {
|
|
12
|
+
const stats = statSync(file);
|
|
13
|
+
return prettyBytes(stats.size);
|
|
14
|
+
}
|
|
15
|
+
function getFileInfo(cwd, filePath) {
|
|
16
|
+
const p = path.resolve(cwd, filePath), exists = fileExists(p), size = exists ? getFilesize(p) : void 0;
|
|
17
|
+
return { exists, size };
|
|
18
|
+
}
|
|
19
|
+
function printPackageTree(ctx) {
|
|
20
|
+
const { cwd, exports: exports$1, logger, pkg } = ctx;
|
|
21
|
+
if (!exports$1) return;
|
|
22
|
+
logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`);
|
|
23
|
+
const tree = {};
|
|
24
|
+
pkg.type && (tree.type = chalk.yellow(pkg.type)), pkg.bin && (tree.bin = Object.fromEntries(
|
|
25
|
+
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)])
|
|
26
|
+
));
|
|
27
|
+
function fileInfo(file) {
|
|
28
|
+
const info = getFileInfo(cwd, file);
|
|
29
|
+
return info.size ? `${chalk.yellow(file)} ${chalk.gray(info.size)}` : `${chalk.gray(file)} ${chalk.red("does not exist")}`;
|
|
30
|
+
}
|
|
31
|
+
tree.exports = Object.fromEntries(
|
|
32
|
+
Object.entries(exports$1).filter(([, entry]) => entry._exported).map(([exportPath, entry]) => {
|
|
33
|
+
const exp = {
|
|
34
|
+
source: fileInfo(entry.source),
|
|
35
|
+
browser: void 0,
|
|
36
|
+
require: void 0,
|
|
37
|
+
node: void 0,
|
|
38
|
+
import: void 0,
|
|
39
|
+
default: fileInfo(entry.default)
|
|
40
|
+
};
|
|
41
|
+
return entry.browser ? (exp.browser = { source: fileInfo(entry.browser.source) }, entry.browser.import && (exp.browser.import = fileInfo(entry.browser.import)), entry.browser.require && (exp.browser.require = fileInfo(entry.browser.require))) : delete exp.browser, entry.require ? exp.require = fileInfo(entry.require) : delete exp.require, entry.node ? (exp.node = {}, entry.node.source && (exp.node.source = fileInfo(entry.node.source)), entry.node.import && (exp.node.import = fileInfo(entry.node.import)), entry.node.require && (exp.node.require = fileInfo(entry.node.require))) : delete exp.node, entry.import ? exp.import = fileInfo(entry.import) : delete exp.import, [chalk.cyan(path.join(pkg.name, exportPath)), exp];
|
|
42
|
+
})
|
|
43
|
+
), logger.log(treeify.asTree(tree, !0, !0));
|
|
44
|
+
}
|
|
45
|
+
async function check(options) {
|
|
46
|
+
const { cwd, strict = !1, tsconfig: tsconfigOption } = options, logger = createLogger(), spinner = createSpinner("");
|
|
47
|
+
try {
|
|
48
|
+
const config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./resolveBuildContext.js").then(function(n) {
|
|
49
|
+
return n.strict;
|
|
50
|
+
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
|
|
51
|
+
if (printPackageTree(ctx), strict) {
|
|
52
|
+
const missingFiles = [];
|
|
53
|
+
for (const [, exp] of Object.entries(ctx.exports || {}))
|
|
54
|
+
exp.source && !fileExists(path.resolve(cwd, exp.source)) && missingFiles.push(exp.source), exp.require && !fileExists(path.resolve(cwd, exp.require)) && missingFiles.push(exp.require), exp.import && !fileExists(path.resolve(cwd, exp.import)) && missingFiles.push(exp.import);
|
|
55
|
+
ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types)) && missingFiles.push(ctx.pkg.types), missingFiles.length && (logger.error(`missing files: ${missingFiles.join(", ")}`), process.exit(1));
|
|
56
|
+
const exportPaths = {
|
|
57
|
+
require: [],
|
|
58
|
+
import: []
|
|
59
|
+
};
|
|
60
|
+
for (const exp of Object.values(ctx.exports || {}))
|
|
61
|
+
exp._exported && (exp.require && exportPaths.require.push(exp.require), exp.import && exportPaths.import.push(exp.import));
|
|
62
|
+
const external = [
|
|
63
|
+
...Object.keys(pkg.dependencies || {}),
|
|
64
|
+
...Object.keys(pkg.devDependencies || {})
|
|
65
|
+
], consoleSpy = createConsoleSpy(), checks = [];
|
|
66
|
+
exportPaths.import.length && checks.push(checkExports(exportPaths.import, { cwd, external, format: "esm", logger })), exportPaths.require.length && checks.push(checkExports(exportPaths.require, { cwd, external, format: "cjs", logger })), await Promise.all(checks), consoleSpy.restore();
|
|
67
|
+
}
|
|
68
|
+
ctx.dts === "rolldown" && ctx.config?.extract?.enabled !== !1 && await checkApiExtractorReleaseTags(ctx), spinner.complete();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (spinner.error(), err instanceof Error) {
|
|
71
|
+
const RE_CWD = new RegExp(cwd, "g");
|
|
72
|
+
logger.error((err.stack || err.message).replace(RE_CWD, ".")), logger.log();
|
|
73
|
+
}
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function checkExports(exportPaths, options) {
|
|
78
|
+
const { build } = await import("esbuild"), { cwd, external, format, logger } = options, code = exportPaths.map((id) => format ? `import('${id}');` : `require('${id}');`).join(`
|
|
79
|
+
`);
|
|
80
|
+
try {
|
|
81
|
+
const esbuildResult = await build({
|
|
82
|
+
bundle: !0,
|
|
83
|
+
external,
|
|
84
|
+
format,
|
|
85
|
+
logLevel: "silent",
|
|
86
|
+
// otherwise output maps to stdout as we're using stdin
|
|
87
|
+
outfile: "/dev/null",
|
|
88
|
+
platform: "node",
|
|
89
|
+
// We're not interested in CSS files that might be imported as a side effect, so we'll treat them as empty
|
|
90
|
+
loader: { ".css": "empty" },
|
|
91
|
+
stdin: {
|
|
92
|
+
contents: code,
|
|
93
|
+
loader: "js",
|
|
94
|
+
resolveDir: cwd
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (esbuildResult.errors.length > 0) {
|
|
98
|
+
for (const msg of esbuildResult.errors)
|
|
99
|
+
printEsbuildMessage(logger.warn, msg), logger.log();
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const esbuildWarnings = esbuildResult.warnings.filter((msg) => !(msg.detail || msg.text).includes("does not affect esbuild's own target setting"));
|
|
103
|
+
for (const msg of esbuildWarnings)
|
|
104
|
+
printEsbuildMessage(logger.warn, msg), logger.log();
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (isEsbuildFailure(err)) {
|
|
107
|
+
const { errors } = err;
|
|
108
|
+
for (const msg of errors)
|
|
109
|
+
printEsbuildMessage(logger.error, msg), logger.log();
|
|
110
|
+
} else err instanceof Error ? (logger.error(err.stack || err.message), logger.log()) : (logger.error(String(err)), logger.log());
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function printEsbuildMessage(log, msg) {
|
|
115
|
+
msg.location ? log(
|
|
116
|
+
[
|
|
117
|
+
`${msg.detail || msg.text}
|
|
118
|
+
`,
|
|
119
|
+
`${msg.location.line} | ${msg.location.lineText}
|
|
120
|
+
`,
|
|
121
|
+
`in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`
|
|
122
|
+
].join("")
|
|
123
|
+
) : log(msg.detail || msg.text);
|
|
124
|
+
}
|
|
125
|
+
function isEsbuildFailure(err) {
|
|
126
|
+
return err instanceof Error && "errors" in err && Array.isArray(err.errors) && err.errors.every(isEsbuildMessage) && "warnings" in err && Array.isArray(err.warnings) && err.warnings.every(isEsbuildMessage);
|
|
127
|
+
}
|
|
128
|
+
function isEsbuildMessage(msg) {
|
|
129
|
+
return typeof msg == "object" && msg !== null && "text" in msg && typeof msg.text == "string" && "location" in msg && (msg.location === null || typeof msg.location == "object");
|
|
130
|
+
}
|
|
131
|
+
async function checkApiExtractorReleaseTags(ctx) {
|
|
132
|
+
const [
|
|
133
|
+
{ Extractor, ExtractorConfig },
|
|
134
|
+
{ createApiExtractorConfig },
|
|
135
|
+
{ createTSDocConfig },
|
|
136
|
+
{ getExtractMessagesConfig },
|
|
137
|
+
{ printExtractMessages }
|
|
138
|
+
] = await Promise.all([
|
|
139
|
+
import("@microsoft/api-extractor"),
|
|
140
|
+
import("./createApiExtractorConfig.js"),
|
|
141
|
+
import("./createTSDocConfig.js"),
|
|
142
|
+
import("./getExtractMessagesConfig.js"),
|
|
143
|
+
import("./printExtractMessages.js")
|
|
144
|
+
]), customTags = ctx.config?.extract?.customTags || [], bundledPackages = ctx.bundledPackages, distPath = ctx.distPath, outDir = ctx.ts.config?.options.outDir, rules = ctx.config?.extract?.rules || {};
|
|
145
|
+
if (!outDir)
|
|
146
|
+
throw new Error("tsconfig.json is missing `compilerOptions.outDir`");
|
|
147
|
+
for (const exp of Object.values(ctx.exports || {})) {
|
|
148
|
+
if (!exp._exported || !exp.default.endsWith(".js")) continue;
|
|
149
|
+
const dtsPath = exp.default.replace(/\.js$/, ".d.ts"), exportPath = path.resolve(ctx.cwd, dtsPath), tsdocConfigFile = await createTSDocConfig({
|
|
150
|
+
customTags
|
|
151
|
+
}), extractorConfig = ExtractorConfig.prepare({
|
|
152
|
+
configObject: createApiExtractorConfig({
|
|
153
|
+
bundledPackages,
|
|
154
|
+
distPath,
|
|
155
|
+
exportPath,
|
|
156
|
+
filePath: path.relative(outDir, dtsPath),
|
|
157
|
+
messages: getExtractMessagesConfig({ rules }),
|
|
158
|
+
projectFolder: ctx.cwd,
|
|
159
|
+
mainEntryPointFilePath: exportPath,
|
|
160
|
+
tsconfig: ctx.ts.config,
|
|
161
|
+
tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || "tsconfig.json"),
|
|
162
|
+
dtsRollupEnabled: !1
|
|
163
|
+
}),
|
|
164
|
+
configObjectFullPath: void 0,
|
|
165
|
+
tsdocConfigFile,
|
|
166
|
+
packageJsonFullPath: path.resolve(ctx.cwd, "package.json")
|
|
167
|
+
}), messages = [];
|
|
168
|
+
Extractor.invoke(extractorConfig, {
|
|
169
|
+
// Equivalent to the "--local" command-line parameter
|
|
170
|
+
localBuild: !0,
|
|
171
|
+
// Equivalent to the "--verbose" command-line parameter
|
|
172
|
+
showVerboseMessages: !0,
|
|
173
|
+
// handle messages
|
|
174
|
+
messageCallback(message) {
|
|
175
|
+
messages.push(message), message.handled = !0;
|
|
176
|
+
}
|
|
177
|
+
}), printExtractMessages(ctx, messages);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
3
180
|
async function checkAction(options) {
|
|
4
181
|
try {
|
|
5
182
|
await check({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAction.js","sources":["../../src/cli/checkAction.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAGA,eAAsB,YAAY,SAA+D;AAC/F,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
|
|
1
|
+
{"version":3,"file":"checkAction.js","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 } 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 } 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 type {ExtractorMessage} from '@microsoft/api-extractor'\nimport type {BuildFailure, Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy.ts'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/index.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger, type Logger} 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 config = await loadConfig({cwd})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, 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 // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n const checks = []\n if (exportPaths.import.length) {\n checks.push(checkExports(exportPaths.import, {cwd, external, format: 'esm', logger}))\n }\n\n if (exportPaths.require.length) {\n checks.push(checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger}))\n }\n\n await Promise.all(checks)\n\n consoleSpy.restore()\n }\n\n if (ctx.dts === 'rolldown' && ctx.config?.extract?.enabled !== 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, '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 checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {build} = await import('esbuild')\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n // We're not interested in CSS files that might be imported as a side effect, so we'll treat them as empty\n loader: {'.css': 'empty'},\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n return !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(String(err))\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const [\n {Extractor, ExtractorConfig},\n {createApiExtractorConfig},\n {createTSDocConfig},\n {getExtractMessagesConfig},\n {printExtractMessages},\n ] = await Promise.all([\n import('@microsoft/api-extractor'),\n import('./tasks/dts/createApiExtractorConfig.ts'),\n import('./tasks/dts/createTSDocConfig.ts'),\n import('./tasks/dts/getExtractMessagesConfig.ts'),\n import('./printExtractMessages.ts'),\n ])\n\n const customTags = ctx.config?.extract?.customTags || []\n const bundledPackages = ctx.bundledPackages\n const distPath = ctx.distPath\n const outDir = ctx.ts.config?.options.outDir\n const rules = ctx.config?.extract?.rules || {}\n\n if (!outDir) {\n throw new Error('tsconfig.json is missing `compilerOptions.outDir`')\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported || !exp.default.endsWith('.js')) continue\n const dtsPath = exp.default.replace(/\\.js$/, '.d.ts')\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n\n const tsdocConfigFile = await createTSDocConfig({\n customTags,\n })\n const extractorConfig = ExtractorConfig.prepare({\n configObject: createApiExtractorConfig({\n bundledPackages,\n distPath,\n exportPath,\n filePath: path.relative(outDir, dtsPath),\n messages: getExtractMessagesConfig({rules}),\n projectFolder: ctx.cwd,\n mainEntryPointFilePath: exportPath,\n tsconfig: ctx.ts.config!,\n tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || 'tsconfig.json'),\n dtsRollupEnabled: false,\n }),\n configObjectFullPath: undefined,\n tsdocConfigFile,\n packageJsonFullPath: path.resolve(ctx.cwd, 'package.json'),\n })\n const messages: ExtractorMessage[] = []\n // Invoke API Extractor\n Extractor.invoke(extractorConfig, {\n // Equivalent to the \"--local\" command-line parameter\n localBuild: true,\n // Equivalent to the \"--verbose\" command-line parameter\n showVerboseMessages: true,\n // handle messages\n messageCallback(message: ExtractorMessage) {\n messages.push(message)\n message.handled = true\n },\n })\n\n printExtractMessages(ctx, messages)\n }\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"],"names":["exports"],"mappings":";;;;;;;;;;AAGO,SAAS,YAAY,MAAsB;AAChD,QAAM,QAAQ,SAAS,IAAI;AAE3B,SAAO,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;AAClD,QAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC,GACrB,OAAO,SAAS,YAAY,CAAC,IAAI;AAEvC,SAAO,EAAC,QAAQ,KAAA;AAClB;AAEO,SAAS,iBAAiB,KAAyB;AACxD,QAAM,EAAC,KAAA,SAAKA,WAAS,QAAQ,QAAO;AAEpC,MAAI,CAACA,UAAS;AAEd,SAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,MAAM,IAAI,OAAO,CAAC,EAAE;AAEhE,QAAM,OAAgC,CAAA;AAElC,MAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGlC,IAAI,QACN,KAAK,MAAS,OAAO;AAAA,IACnB,OAAO,QAAQ,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC;AAAA,EAAA;AAIpF,WAAS,SAAS,MAAc;AAC9B,UAAM,OAAO,YAAY,KAAK,IAAI;AAElC,WAAK,KAAK,OAIH,GAAG,MAAM,OAAO,IAAI,CAAC,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AQ;AAAA,MAC9C,cAAc,yBAAyB;AAAA,QACrC;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,KAAK,SAAS,QAAQ,OAAO;AAAA,QACvC,UAAU,yBAAyB,EAAC,OAAM;AAAA,QAC1C,eAAe,IAAI;AAAA,QACnB,wBAAwB;AAAA,QACxB,UAAU,IAAI,GAAG;AAAA,QACjB,cAAc,KAAK,QAAQ,IAAI,KAAK,IAAI,GAAG,cAAc,eAAe;AAAA,QACxE,kBAAkB;AAAA,MAAA,CACnB;AAAA,MACD,sBAAsB;AAAA,MACtB;AAAA,MACA,qBAAqB,KAAK,QAAQ,IAAI,KAAK,cAAc;AAAA,IAAA,CAC1D,GACK,WAA+B,CAAA;AAErC,cAAU,OAAO,iBAAiB;AAAA;AAAA,MAEhC,YAAY;AAAA;AAAA,MAEZ,qBAAqB;AAAA;AAAA,MAErB,gBAAgB,SAA2B;AACzC,iBAAS,KAAK,OAAO,GACrB,QAAQ,UAAU;AAAA,MACpB;AAAA,IAAA,CACD,GAED,qBAAqB,KAAK,QAAQ;AAAA,EACpC;AACF;AC1RA,eAAsB,YAAY,SAA+D;AAC/F,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
function createApiExtractorConfig(options) {
|
|
3
|
+
const {
|
|
4
|
+
bundledPackages,
|
|
5
|
+
distPath,
|
|
6
|
+
exportPath,
|
|
7
|
+
filePath,
|
|
8
|
+
messages,
|
|
9
|
+
projectFolder,
|
|
10
|
+
mainEntryPointFilePath,
|
|
11
|
+
tsconfig,
|
|
12
|
+
tsconfigPath,
|
|
13
|
+
dtsRollupEnabled
|
|
14
|
+
} = options;
|
|
15
|
+
return {
|
|
16
|
+
apiReport: {
|
|
17
|
+
enabled: !1,
|
|
18
|
+
reportFileName: "<unscopedPackageName>.api.md"
|
|
19
|
+
},
|
|
20
|
+
bundledPackages,
|
|
21
|
+
// If `paths` are used for self-referencing imports (e.g. the module is named `sanity`, and the `sanity/structure` export is also importing from `sanity/router`),
|
|
22
|
+
compiler: tsconfig.options.paths ? {
|
|
23
|
+
overrideTsconfig: {
|
|
24
|
+
extends: tsconfigPath,
|
|
25
|
+
compilerOptions: {
|
|
26
|
+
// An empty object replaces whatever is in the original tsconfig file
|
|
27
|
+
paths: {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} : { tsconfigFilePath: tsconfigPath },
|
|
31
|
+
docModel: {
|
|
32
|
+
enabled: !1,
|
|
33
|
+
apiJsonFilePath: path.resolve(distPath, `${exportPath}.api.json`)
|
|
34
|
+
},
|
|
35
|
+
dtsRollup: {
|
|
36
|
+
enabled: dtsRollupEnabled,
|
|
37
|
+
untrimmedFilePath: path.resolve(distPath, filePath)
|
|
38
|
+
// betaTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-beta.d.ts')),
|
|
39
|
+
// publicTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-public.d.ts')),
|
|
40
|
+
},
|
|
41
|
+
tsdocMetadata: {
|
|
42
|
+
enabled: !1
|
|
43
|
+
},
|
|
44
|
+
messages,
|
|
45
|
+
mainEntryPointFilePath,
|
|
46
|
+
projectFolder
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
createApiExtractorConfig
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=createApiExtractorConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApiExtractorConfig.js","sources":["../../src/node/tasks/dts/createApiExtractorConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {IConfigFile, IExtractorMessagesConfig} from '@microsoft/api-extractor'\nimport ts from 'typescript'\n\nexport function createApiExtractorConfig(options: {\n bundledPackages?: string[]\n distPath: string\n exportPath: string\n filePath: string\n messages: IExtractorMessagesConfig\n projectFolder: string\n mainEntryPointFilePath: string\n tsconfig: ts.ParsedCommandLine\n tsconfigPath: string\n dtsRollupEnabled: boolean\n}): IConfigFile {\n const {\n bundledPackages,\n distPath,\n exportPath,\n filePath,\n messages,\n projectFolder,\n mainEntryPointFilePath,\n tsconfig,\n tsconfigPath,\n dtsRollupEnabled,\n } = options\n\n return {\n apiReport: {\n enabled: false,\n reportFileName: '<unscopedPackageName>.api.md',\n },\n bundledPackages,\n\n // If `paths` are used for self-referencing imports (e.g. the module is named `sanity`, and the `sanity/structure` export is also importing from `sanity/router`),\n compiler: tsconfig.options.paths\n ? {\n overrideTsconfig: {\n extends: tsconfigPath,\n compilerOptions: {\n // An empty object replaces whatever is in the original tsconfig file\n paths: {},\n },\n },\n }\n : {tsconfigFilePath: tsconfigPath},\n\n docModel: {\n enabled: false,\n apiJsonFilePath: path.resolve(distPath, `${exportPath}.api.json`),\n },\n dtsRollup: {\n enabled: dtsRollupEnabled,\n untrimmedFilePath: path.resolve(distPath, filePath),\n // betaTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-beta.d.ts')),\n // publicTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-public.d.ts')),\n },\n tsdocMetadata: {\n enabled: false,\n },\n messages,\n mainEntryPointFilePath,\n projectFolder,\n }\n}\n"],"names":[],"mappings":";AAIO,SAAS,yBAAyB,SAWzB;AACd,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAEJ,SAAO;AAAA,IACL,WAAW;AAAA,MACT,SAAS;AAAA,MACT,gBAAgB;AAAA,IAAA;AAAA,IAElB;AAAA;AAAA,IAGA,UAAU,SAAS,QAAQ,QACvB;AAAA,MACE,kBAAkB;AAAA,QAChB,SAAS;AAAA,QACT,iBAAiB;AAAA;AAAA,UAEf,OAAO,CAAA;AAAA,QAAC;AAAA,MACV;AAAA,IACF,IAEF,EAAC,kBAAkB,aAAA;AAAA,IAEvB,UAAU;AAAA,MACR,SAAS;AAAA,MACT,iBAAiB,KAAK,QAAQ,UAAU,GAAG,UAAU,WAAW;AAAA,IAAA;AAAA,IAElE,WAAW;AAAA,MACT,SAAS;AAAA,MACT,mBAAmB,KAAK,QAAQ,UAAU,QAAQ;AAAA;AAAA;AAAA,IAAA;AAAA,IAIpD,eAAe;AAAA,MACb,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { TSDocConfigFile } from "@microsoft/tsdoc-config";
|
|
4
|
+
import { parse } from "jsonc-parser";
|
|
5
|
+
const require$1 = createRequire(import.meta.url);
|
|
6
|
+
async function createTSDocConfig(opts) {
|
|
7
|
+
const { customTags } = opts;
|
|
8
|
+
if (customTags.length === 0)
|
|
9
|
+
return;
|
|
10
|
+
const tsDocBaseBuf = await readFile(
|
|
11
|
+
require$1.resolve("@microsoft/api-extractor/extends/tsdoc-base.json")
|
|
12
|
+
), tsDocBaseConfig = parse(tsDocBaseBuf.toString()), tagDefinitions = (tsDocBaseConfig.tagDefinitions || []).concat(
|
|
13
|
+
customTags.map((t) => ({
|
|
14
|
+
tagName: `@${t.name}`,
|
|
15
|
+
syntaxKind: t.syntaxKind,
|
|
16
|
+
allowMultiple: t.allowMultiple
|
|
17
|
+
}))
|
|
18
|
+
), supportForTags = { ...tsDocBaseConfig.supportForTags };
|
|
19
|
+
for (const customTag of customTags)
|
|
20
|
+
supportForTags[`@${customTag.name}`] = !0;
|
|
21
|
+
return TSDocConfigFile.loadFromObject({
|
|
22
|
+
...tsDocBaseConfig,
|
|
23
|
+
noStandardTags: !1,
|
|
24
|
+
tagDefinitions,
|
|
25
|
+
supportForTags
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
createTSDocConfig
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=createTSDocConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTSDocConfig.js","sources":["../../src/node/tasks/dts/createTSDocConfig.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {createRequire} from 'node:module'\nimport {TSDocConfigFile} from '@microsoft/tsdoc-config'\nimport {parse} from 'jsonc-parser'\n\nconst require = createRequire(import.meta.url)\n\n/** @public */\nexport interface TSDocCustomTag {\n name: string\n syntaxKind: 'block' | 'modifier'\n allowMultiple?: boolean\n}\n\n/** @internal */\nexport async function createTSDocConfig(opts: {\n customTags: TSDocCustomTag[]\n}): Promise<TSDocConfigFile | undefined> {\n const {customTags} = opts\n\n if (customTags.length === 0) {\n return undefined\n }\n\n const tsDocBaseBuf = await readFile(\n require.resolve('@microsoft/api-extractor/extends/tsdoc-base.json'),\n )\n\n // Include the definitions that are required for API Extractor\n // extends: ['@microsoft/api-extractor/extends/tsdoc-base.json'],\n const tsDocBaseConfig = parse(tsDocBaseBuf.toString())\n\n // Define custom tags and specify how they should be parsed\n const tagDefinitions = (tsDocBaseConfig.tagDefinitions || []).concat(\n customTags.map((t) => ({\n tagName: `@${t.name}`,\n syntaxKind: t.syntaxKind,\n allowMultiple: t.allowMultiple,\n })),\n )\n\n // Indicate that custom tags are supported by your tooling.\n // (Without this, warnings may be reported saying that a tag is unsupported.)\n const supportForTags = {...tsDocBaseConfig.supportForTags}\n\n for (const customTag of customTags) {\n supportForTags[`@${customTag.name}`] = true\n }\n\n return TSDocConfigFile.loadFromObject({\n ...tsDocBaseConfig,\n noStandardTags: false,\n tagDefinitions,\n supportForTags,\n })\n}\n"],"names":["require"],"mappings":";;;;AAKA,MAAMA,YAAU,cAAc,YAAY,GAAG;AAU7C,eAAsB,kBAAkB,MAEC;AACvC,QAAM,EAAC,eAAc;AAErB,MAAI,WAAW,WAAW;AACxB;AAGF,QAAM,eAAe,MAAM;AAAA,IACzBA,UAAQ,QAAQ,kDAAkD;AAAA,EAAA,GAK9D,kBAAkB,MAAM,aAAa,SAAA,CAAU,GAG/C,kBAAkB,gBAAgB,kBAAkB,CAAA,GAAI;AAAA,IAC5D,WAAW,IAAI,CAAC,OAAO;AAAA,MACrB,SAAS,IAAI,EAAE,IAAI;AAAA,MACnB,YAAY,EAAE;AAAA,MACd,eAAe,EAAE;AAAA,IAAA,EACjB;AAAA,EAAA,GAKE,iBAAiB,EAAC,GAAG,gBAAgB,eAAA;AAE3C,aAAW,aAAa;AACtB,mBAAe,IAAI,UAAU,IAAI,EAAE,IAAI;AAGzC,SAAO,gBAAgB,eAAe;AAAA,IACpC,GAAG;AAAA,IACH,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { packageUp } from "package-up";
|
|
4
|
+
import { tsImport } from "tsx/esm/api";
|
|
5
|
+
import findConfig from "find-config";
|
|
6
|
+
import { fileExists } from "./fileExists.js";
|
|
7
|
+
import config from "@sanity/browserslist-config";
|
|
8
|
+
const CONFIG_FILE_NAMES = [
|
|
9
|
+
"package.config.ts",
|
|
10
|
+
"package.config.js",
|
|
11
|
+
"package.config.cjs",
|
|
12
|
+
"package.config.mts",
|
|
13
|
+
"package.config.mjs"
|
|
14
|
+
];
|
|
15
|
+
function findConfigFile(cwd) {
|
|
16
|
+
const pkgJsonPath = findConfig("package.json", { cwd });
|
|
17
|
+
if (!pkgJsonPath) return;
|
|
18
|
+
const pkgPath = path.dirname(pkgJsonPath);
|
|
19
|
+
for (const fileName of CONFIG_FILE_NAMES) {
|
|
20
|
+
const configPath = path.resolve(pkgPath, fileName);
|
|
21
|
+
if (fileExists(configPath))
|
|
22
|
+
return configPath;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function loadConfig(options) {
|
|
26
|
+
const { cwd } = options, pkgPath = await packageUp({ cwd });
|
|
27
|
+
if (!pkgPath) return;
|
|
28
|
+
const root = path.dirname(pkgPath), configFile = findConfigFile(root);
|
|
29
|
+
if (!configFile || !configFile.startsWith(cwd))
|
|
30
|
+
return;
|
|
31
|
+
const mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url);
|
|
32
|
+
return mod?.default || mod || void 0;
|
|
33
|
+
}
|
|
34
|
+
const DEFAULT_BROWSERSLIST_QUERY = config;
|
|
35
|
+
export {
|
|
36
|
+
DEFAULT_BROWSERSLIST_QUERY,
|
|
37
|
+
loadConfig
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sources":["../../src/node/core/config/findConfigFile.ts","../../src/node/core/config/loadConfig.ts","../../src/node/core/defaults.ts"],"sourcesContent":["import path from 'node:path'\nimport findConfig from 'find-config'\nimport {fileExists} from '../../fileExists.ts'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/** @internal */\nexport function findConfigFile(cwd: string): string | undefined {\n const pkgJsonPath = findConfig('package.json', {cwd})\n\n if (!pkgJsonPath) return undefined\n\n const pkgPath = path.dirname(pkgJsonPath)\n\n for (const fileName of CONFIG_FILE_NAMES) {\n const configPath = path.resolve(pkgPath, fileName)\n\n const exists = fileExists(configPath)\n\n if (exists) {\n return configPath\n }\n }\n\n return undefined\n}\n","import path from 'node:path'\nimport {pathToFileURL} from 'node:url'\nimport {packageUp} from 'package-up'\nimport {tsImport} from 'tsx/esm/api'\nimport {findConfigFile} from './findConfigFile.ts'\nimport type {PkgConfigOptions} from './types.ts'\n\n/** @alpha */\nexport async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined> {\n const {cwd} = options\n\n const pkgPath = await packageUp({cwd})\n\n if (!pkgPath) return undefined\n\n const root = path.dirname(pkgPath)\n\n const configFile = findConfigFile(root)\n\n if (!configFile) {\n return undefined\n }\n\n // Do not accept config files outside of the root\n if (!configFile.startsWith(cwd)) {\n return undefined\n }\n\n const mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url)\n\n return mod?.default || mod || undefined\n}\n","import config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY: string[] = config\n"],"names":[],"mappings":";;;;;;;AAIA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,eAAe,KAAiC;AAC9D,QAAM,cAAc,WAAW,gBAAgB,EAAC,KAAI;AAEpD,MAAI,CAAC,YAAa;AAElB,QAAM,UAAU,KAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ;AAIjD,QAFe,WAAW,UAAU;AAGlC,aAAO;AAAA,EAEX;AAGF;ACvBA,eAAsB,WAAW,SAA+D;AAC9F,QAAM,EAAC,QAAO,SAER,UAAU,MAAM,UAAU,EAAC,KAAI;AAErC,MAAI,CAAC,QAAS;AAEd,QAAM,OAAO,KAAK,QAAQ,OAAO,GAE3B,aAAa,eAAe,IAAI;AAOtC,MALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG;AAC5B;AAGF,QAAM,MAAM,MAAM,SAAS,cAAc,UAAU,EAAE,YAAY,YAAY,GAAG;AAEhF,SAAO,KAAK,WAAW,OAAO;AAChC;AC5BO,MAAM,6BAAuC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sources":["../../src/node/core/template/define.ts"],"sourcesContent":["import type {PkgTemplateOption} from './types.ts'\n\n/** @public */\nexport function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T> {\n return option\n}\n"],"names":[],"mappings":"AAGO,SAAS,qBAAwB,QAAoD;AAC1F,SAAO;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileExists.js","sources":["../../src/node/fileExists.ts"],"sourcesContent":["import {statSync} from 'node:fs'\n\n/** @internal */\nexport function fileExists(filePath: string): boolean {\n try {\n statSync(filePath)\n\n return true\n } catch {\n return false\n }\n}\n"],"names":[],"mappings":";AAGO,SAAS,WAAW,UAA2B;AACpD,MAAI;AACF,WAAA,SAAS,QAAQ,GAEV;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
|