@ankurhalder/codebase-snapshot 2.1.1 → 3.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.
@@ -3914,11 +3914,12 @@ var PRESET_NAMES = [
3914
3914
  "java-spring \xB7 dotnet \xB7 php-laravel \xB7 ruby-rails",
3915
3915
  "monorepo \xB7 docs \xB7 infra \xB7 generic"
3916
3916
  ];
3917
+ var CONFIG_HEADER = `// Generated by codebase-snapshot. A plain object on purpose: this file must load
3918
+ // even when the package itself is only run through npx.
3919
+ `;
3917
3920
  function renderConfig(answers) {
3918
3921
  const { artifacts } = answers;
3919
- return `import { defineConfig } from "@ankurhalder/codebase-snapshot";
3920
-
3921
- export default defineConfig({
3922
+ return `${CONFIG_HEADER}export default {
3922
3923
  // \u2500\u2500 Project \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
3923
3924
  // Which project shape to use. Detected from the repo when omitted.
3924
3925
  // ${PRESET_NAMES.join("\n // ")}
@@ -3987,7 +3988,7 @@ export default defineConfig({
3987
3988
  // \u2500\u2500 Advanced \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
3988
3989
  // afterGenerate: (manifest) => { /* write your own artifact */ }
3989
3990
  hooks: {},
3990
- });
3991
+ };
3991
3992
  `;
3992
3993
  }
3993
3994
  function renderMinimalConfig(answers) {
@@ -4015,16 +4016,12 @@ ${entries},
4015
4016
  },`);
4016
4017
  }
4017
4018
  if (lines.length === 0) {
4018
- return `import { defineConfig } from "@ankurhalder/codebase-snapshot";
4019
-
4020
- export default defineConfig({});
4019
+ return `${CONFIG_HEADER}export default {};
4021
4020
  `;
4022
4021
  }
4023
- return `import { defineConfig } from "@ankurhalder/codebase-snapshot";
4024
-
4025
- export default defineConfig({
4022
+ return `${CONFIG_HEADER}export default {
4026
4023
  ${lines.join("\n")}
4027
- });
4024
+ };
4028
4025
  `;
4029
4026
  }
4030
4027
  var PromptCancelled = class extends Error {
@@ -4285,6 +4282,17 @@ var CONFIG_CANDIDATES = [
4285
4282
  ".snapshotrc.json",
4286
4283
  ".snapshotrc"
4287
4284
  ];
4285
+ function chooseConfigFileName(cwd) {
4286
+ if (!supportsTypeScriptImports()) return "snapshot.config.mjs";
4287
+ const pkgPath = path10.join(cwd, "package.json");
4288
+ if (!fs9.existsSync(pkgPath)) return "snapshot.config.mjs";
4289
+ try {
4290
+ const parsed = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
4291
+ return parsed.type === "module" ? "snapshot.config.ts" : "snapshot.config.mjs";
4292
+ } catch {
4293
+ return "snapshot.config.mjs";
4294
+ }
4295
+ }
4288
4296
  var SIZE_CHOICES = [
4289
4297
  { value: "60k", label: "Small", hint: "60 KB \xB7 ~15k tokens \xB7 tight context windows" },
4290
4298
  { value: "120k", label: "Medium", hint: "120 KB \xB7 ~30k tokens \xB7 recommended" },
@@ -4490,7 +4498,7 @@ async function runInit(options) {
4490
4498
  if (!proceed) throw new PromptCancelled();
4491
4499
  }
4492
4500
  const configText = options.minimal ? renderMinimalConfig(answers) : renderConfig(answers);
4493
- const configName = supportsTypeScriptImports() ? "snapshot.config.ts" : "snapshot.config.mjs";
4501
+ const configName = chooseConfigFileName(options.cwd);
4494
4502
  const configPath = path10.join(options.cwd, configName);
4495
4503
  if (options.dryRun) {
4496
4504
  return {
@@ -4528,7 +4536,7 @@ async function runInit(options) {
4528
4536
 
4529
4537
  // src/index.ts
4530
4538
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
4531
- var GENERATOR_VERSION = "2.1.1";
4539
+ var GENERATOR_VERSION = "3.0.0";
4532
4540
  var SCHEMA_VERSION = "3.0.0";
4533
4541
  function sha256Hex2(input) {
4534
4542
  return crypto.createHash("sha256").update(input).digest("hex");
@@ -5105,5 +5113,5 @@ async function generateSnapshotAsync(configInput, options) {
5105
5113
  }
5106
5114
 
5107
5115
  export { ARTIFACT_NAMES, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, GENERATOR_NAME, GENERATOR_VERSION, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, PRESETS, PromptCancelled, SCHEMA_VERSION, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isInteractive, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, profileForPath, renderConfig, renderDiffText, renderExplainText, renderMinimalConfig, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, unknownPresetMessage, validateSnapshot };
5108
- //# sourceMappingURL=chunk-SUOJL5EX.js.map
5109
- //# sourceMappingURL=chunk-SUOJL5EX.js.map
5116
+ //# sourceMappingURL=chunk-5B4UVQLR.js.map
5117
+ //# sourceMappingURL=chunk-5B4UVQLR.js.map