@bettercms-ai/convert 0.24.1 → 0.25.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/index.d.ts CHANGED
@@ -1853,6 +1853,36 @@ declare function readBrief(value: unknown): Brief;
1853
1853
  */
1854
1854
  declare function readPlan(value: unknown): ComponentizePlan;
1855
1855
 
1856
+ /**
1857
+ * `build:bcms` — the build BetterCMS runs instead of `build`, when a repository declares one.
1858
+ *
1859
+ * The builder runs `build:bcms` in place of `build` (as Vercel runs `vercel-build`), and never edits
1860
+ * a project's build script itself. A converted repository's `build` usually chains the checks its
1861
+ * own CI wants in front of the build — `astro check && astro build` — and every BetterCMS deploy
1862
+ * paid for them: the type check alone was 8–10 s of a warm ScrewFast build. This writes the same
1863
+ * build without those checks, once, beside the script it came from. `build` is left exactly as it
1864
+ * was, so the project's own CI still checks everything.
1865
+ *
1866
+ * Only a script it can read with certainty: steps joined by `&&` and nothing else. A `;`, `||`,
1867
+ * pipe, background `&` or substitution means the steps do not simply run in order, and that script
1868
+ * is left alone. `prebuild` and `postbuild` are folded in (minus their own checks), because a run
1869
+ * of `build:bcms` triggers `prebuild:bcms`, not `prebuild` — dropping them would lose a step the
1870
+ * build needs (ScrewFast splits its content snapshot in `prebuild`).
1871
+ */
1872
+ interface BcmsBuild {
1873
+ /** The new package.json, formatted as the original was. */
1874
+ content: string;
1875
+ /** The `build:bcms` it adds. */
1876
+ script: string;
1877
+ /** The steps of `build` (and its pre/post hooks) left out of it. */
1878
+ dropped: string[];
1879
+ }
1880
+ /**
1881
+ * The package.json with a `build:bcms` added, or null when there is nothing to add: one already
1882
+ * exists, no `build` chains a check, or a script is not one it can read with certainty.
1883
+ */
1884
+ declare function bcmsBuildScript(packageJson: string): BcmsBuild | null;
1885
+
1856
1886
  /** The plan's own file shape, restated rather than imported to keep `index.ts` acyclic. */
1857
1887
  interface UpgradeFile {
1858
1888
  path: string;
@@ -1965,4 +1995,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
1965
1995
  receipt: ConversionReceipt;
1966
1996
  }>;
1967
1997
 
1968
- export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, FORM_SCRIPT, type FileDeclaration, type FindSitesResult, type FixAction, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type HelperUpgrade, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingFix, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionUpgradeReceipt, type SectionsReceipt, type Site, type SiteWhere, type SkippedRoot, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, UpgradeError, type UpgradeOptions, type UpgradeRootRef, type UpgradeSkipReason, type UpgradedRoot, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, helperUpgrades, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, upgradeSections, walkAst, wireForms };
1998
+ export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type BcmsBuild, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, FORM_SCRIPT, type FileDeclaration, type FindSitesResult, type FixAction, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type HelperUpgrade, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingFix, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionUpgradeReceipt, type SectionsReceipt, type Site, type SiteWhere, type SkippedRoot, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, UpgradeError, type UpgradeOptions, type UpgradeRootRef, type UpgradeSkipReason, type UpgradedRoot, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bcmsBuildScript, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, helperUpgrades, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, upgradeSections, walkAst, wireForms };
package/dist/index.js CHANGED
@@ -7690,6 +7690,54 @@ function moduleScope(parsed, content) {
7690
7690
  return out;
7691
7691
  }
7692
7692
 
7693
+ // src/build-script.ts
7694
+ var CHECK = /^(?:npx\s+|pnpm\s+(?:exec\s+)?|yarn\s+|bunx\s+)?(?:astro\s+check|svelte-check|vue-tsc|tsc(?:\s|$)|eslint|next\s+lint|biome\s+(?:check|lint|ci)|prettier\s+(?:--check|-c)\b|stylelint|oxlint)/;
7695
+ var RUN_CHECK = /^(?:npm\s+run|pnpm(?:\s+run)?|yarn(?:\s+run)?|bun\s+run)\s+(?:lint|typecheck|type-check|check|check:types|types|format:check|test)(?::[\w-]+)?\s*$/;
7696
+ var UNSAFE = /;|\|\||\||(?:^|[^&])&(?:[^&]|$)|\$\(|`|\n/;
7697
+ var isCheck = (step) => CHECK.test(step) || RUN_CHECK.test(step);
7698
+ function steps(script) {
7699
+ if (UNSAFE.test(script)) return null;
7700
+ const out = script.split("&&").map((s) => s.trim());
7701
+ return out.some((s) => s === "") ? null : out;
7702
+ }
7703
+ function bcmsBuildScript(packageJson) {
7704
+ let pkg;
7705
+ try {
7706
+ pkg = JSON.parse(packageJson);
7707
+ } catch {
7708
+ return null;
7709
+ }
7710
+ const scripts = pkg?.scripts;
7711
+ if (!scripts || typeof scripts !== "object" || "build:bcms" in scripts) return null;
7712
+ const build = scripts.build;
7713
+ if (typeof build !== "string") return null;
7714
+ const parts = [];
7715
+ for (const name of ["prebuild", "build", "postbuild"]) {
7716
+ const value = scripts[name];
7717
+ if (value === void 0) continue;
7718
+ if (typeof value !== "string") return null;
7719
+ const s = steps(value);
7720
+ if (!s) return null;
7721
+ parts.push(s);
7722
+ }
7723
+ const all = parts.flat();
7724
+ const dropped = all.filter(isCheck);
7725
+ const kept = all.filter((s) => !isCheck(s));
7726
+ if (dropped.length === 0 || kept.length === 0) return null;
7727
+ const script = kept.join(" && ");
7728
+ const next = {};
7729
+ for (const [key, value] of Object.entries(scripts)) {
7730
+ next[key] = value;
7731
+ if (key === "build") next["build:bcms"] = script;
7732
+ }
7733
+ const indent = /^[ \t]+(?=")/m.exec(packageJson)?.[0] ?? " ";
7734
+ const eol = packageJson.includes("\r\n") ? "\r\n" : "\n";
7735
+ let content = JSON.stringify({ ...pkg, scripts: next }, null, indent);
7736
+ if (eol !== "\n") content = content.replace(/\n/g, eol);
7737
+ if (/\r?\n$/.test(packageJson)) content += eol;
7738
+ return { content, script, dropped };
7739
+ }
7740
+
7693
7741
  // src/componentize.ts
7694
7742
  import MagicString5 from "magic-string";
7695
7743
  var SectionInvariantError = class extends Error {
@@ -10788,6 +10836,7 @@ export {
10788
10836
  assetCandidates,
10789
10837
  assetImport,
10790
10838
  attrsFor,
10839
+ bcmsBuildScript,
10791
10840
  bindDataLiterals,
10792
10841
  bindImages,
10793
10842
  briefDigest,