@databricks-solutions/lakebase-scm-utils 0.3.10 → 0.3.11

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.
Files changed (48) hide show
  1. package/dist/{pr-e-E4aP4j.d.cts → pr-D-eayWyJ.d.cts} +59 -1
  2. package/dist/{pr-e-E4aP4j.d.ts → pr-D-eayWyJ.d.ts} +59 -1
  3. package/dist/scripts/git/index.cjs +30 -14
  4. package/dist/scripts/git/index.d.cts +32 -1
  5. package/dist/scripts/git/index.d.ts +32 -1
  6. package/dist/scripts/git/index.js +28 -14
  7. package/dist/scripts/github/index.d.cts +2 -60
  8. package/dist/scripts/github/index.d.ts +2 -60
  9. package/dist/scripts/index.cjs +244 -76
  10. package/dist/scripts/index.d.cts +4 -4
  11. package/dist/scripts/index.d.ts +4 -4
  12. package/dist/scripts/index.js +239 -76
  13. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +2 -2
  14. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +2 -2
  15. package/dist/scripts/lakebase/collapse-heads.cli.cjs +2 -2
  16. package/dist/scripts/lakebase/collapse-heads.cli.js +2 -2
  17. package/dist/scripts/lakebase/detect-language.cli.cjs +2 -2
  18. package/dist/scripts/lakebase/detect-language.cli.js +2 -2
  19. package/dist/scripts/lakebase/doctor.cli.cjs +2 -2
  20. package/dist/scripts/lakebase/doctor.cli.js +2 -2
  21. package/dist/scripts/lakebase/get-connection.cli.cjs +2 -2
  22. package/dist/scripts/lakebase/get-connection.cli.js +2 -2
  23. package/dist/scripts/lakebase/index.cjs +256 -77
  24. package/dist/scripts/lakebase/index.d.cts +74 -2
  25. package/dist/scripts/lakebase/index.d.ts +74 -2
  26. package/dist/scripts/lakebase/index.js +253 -77
  27. package/dist/scripts/lakebase/infra-runner.cli.cjs +2 -2
  28. package/dist/scripts/lakebase/infra-runner.cli.js +2 -2
  29. package/dist/scripts/lakebase/new-migration.cli.cjs +2 -2
  30. package/dist/scripts/lakebase/new-migration.cli.js +2 -2
  31. package/dist/scripts/lakebase/schema-diff.cli.cjs +2 -2
  32. package/dist/scripts/lakebase/schema-diff.cli.js +2 -2
  33. package/dist/scripts/lakebase/schema-migrate.cli.cjs +2 -2
  34. package/dist/scripts/lakebase/schema-migrate.cli.js +2 -2
  35. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +2 -2
  36. package/dist/scripts/lakebase/scm-claim-feature.cli.js +2 -2
  37. package/dist/scripts/lakebase/scm-doctor.cli.cjs +2 -2
  38. package/dist/scripts/lakebase/scm-doctor.cli.js +2 -2
  39. package/dist/scripts/lakebase/scm-merge.cli.cjs +2 -2
  40. package/dist/scripts/lakebase/scm-merge.cli.js +2 -2
  41. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +2 -2
  42. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +2 -2
  43. package/dist/scripts/util/index.cjs +2 -2
  44. package/dist/scripts/util/index.js +2 -2
  45. package/package.json +1 -1
  46. package/scripts/git/commit-push.ts +60 -14
  47. package/scripts/lakebase/create-preflight.ts +213 -1
  48. package/scripts/lakebase/create-project.ts +98 -30
@@ -1,4 +1,4 @@
1
- import { W as WorkflowRunSummary, e as PullRequestInfo, o as mergePairedPullRequest } from '../../pr-e-E4aP4j.js';
1
+ import { W as WorkflowRunSummary, c as GitHubScopeStatus, h as PullRequestInfo, x as mergePairedPullRequest } from '../../pr-D-eayWyJ.js';
2
2
  import { Pool } from 'pg';
3
3
  import { b as CiFreshnessResult } from '../../ci-secrets-CnGrdQV-.js';
4
4
 
@@ -1647,6 +1647,47 @@ type ScopeProbe = () => Promise<{
1647
1647
  * (a genuinely bad/absent token surfaces clearly at repo creation, not here).
1648
1648
  */
1649
1649
  declare function checkGitHubWorkflowScope(probe?: ScopeProbe): Promise<PreflightResult>;
1650
+ interface GitHubPreflightInput {
1651
+ /** Target repo owner (user or org). */
1652
+ owner: string;
1653
+ /** Bare repo name (the project name). */
1654
+ repoName: string;
1655
+ /** Scopes whose absence BLOCKS the happy path (create + push). Default ["repo","workflow"]. */
1656
+ hardScopes?: readonly string[];
1657
+ /** Scopes whose absence only WARNS (e.g. delete_repo, needed for rollback repo-delete). Default ["delete_repo"]. */
1658
+ advisoryScopes?: readonly string[];
1659
+ /** Injected probes (default to the real GitHub reads). */
1660
+ currentUser?: () => Promise<string>;
1661
+ scopes?: (required: readonly string[]) => Promise<GitHubScopeStatus>;
1662
+ repoExists?: (fullName: string) => Promise<boolean>;
1663
+ }
1664
+ interface GitHubPreflightResult extends PreflightResult {
1665
+ /** Non-blocking notes (org/owner mismatch, missing advisory scope, invisible scopes). */
1666
+ warnings: string[];
1667
+ /** The resolved authenticated login, when B1 succeeded. */
1668
+ activeUser?: string;
1669
+ }
1670
+ /**
1671
+ * One up-front GitHub preflight run BEFORE any repo / Lakebase project is created,
1672
+ * so a missing requisite fails in seconds with a fix instead of mid-create (where
1673
+ * it orphans partially-created artifacts). Supersedes the workflow-only check:
1674
+ *
1675
+ * B1 active account getCurrentUser() must resolve (a valid token) — else a
1676
+ * wrong/absent token otherwise 403s LATE at the push.
1677
+ * B2 scope set checkGitHubScopes([...hard, ...advisory]): a missing HARD
1678
+ * scope (repo/workflow) fails; a missing ADVISORY scope
1679
+ * (delete_repo) warns (rollback repo-delete unavailable);
1680
+ * granted null (fine-grained PAT / App) can't be asserted.
1681
+ * B3 name availability repoExists(owner/name) → fail before anything exists.
1682
+ * B4 owner note login != owner ⇒ creating under an org/other account —
1683
+ * surfaced (createRepo enforces the real org-create right).
1684
+ *
1685
+ * CONSERVATIVE: hard-fails ONLY on the clear blockers (invalid token, missing
1686
+ * happy-path scope, name taken); every other uncertainty is a warning, never a
1687
+ * false block (same ethos as checkGitHubWorkflowScope). All probes injected, so
1688
+ * this is unit-testable with no network.
1689
+ */
1690
+ declare function checkGitHubPreflight(input: GitHubPreflightInput): Promise<GitHubPreflightResult>;
1650
1691
  /** The actionable prereq message for a GitHub token missing the `workflow` scope. */
1651
1692
  declare function githubWorkflowScopePrereqMessage(reason?: string): string;
1652
1693
  /** The actionable prereq message for a failed auth probe (W5). */
@@ -1677,6 +1718,37 @@ interface RollbackOptions {
1677
1718
  * gone. Use ONLY to wrap the steps that run AFTER createLakebaseProject.
1678
1719
  */
1679
1720
  declare function withLakebaseRollback<T>(opts: RollbackOptions, fn: () => Promise<T>): Promise<T>;
1721
+ interface RollbackStep {
1722
+ label: string;
1723
+ undo: () => Promise<void> | void;
1724
+ }
1725
+ interface RollbackLedger {
1726
+ /** Record a teardown for a resource the moment it is created. */
1727
+ register(label: string, undo: () => Promise<void> | void): void;
1728
+ /** The steps, in registration order (teardown runs them REVERSED). */
1729
+ steps(): readonly RollbackStep[];
1730
+ }
1731
+ /** A created-resources ledger for the full create flow (A3). */
1732
+ declare function createRollbackLedger(): RollbackLedger;
1733
+ interface CreateRollbackOptions {
1734
+ report?: (step: string, detail?: string) => void;
1735
+ }
1736
+ /**
1737
+ * A3: run `fn`; on a throw, tear down EVERY resource the ledger recorded, in
1738
+ * REVERSE order (last-created first), then rethrow with a summary of what was
1739
+ * and wasn't cleaned up.
1740
+ *
1741
+ * Unlike {@link withLakebaseRollback} (Lakebase project only), this undoes the
1742
+ * GitHub repo, the self-hosted runner, the local dir, AND the Lakebase project
1743
+ * together — so a genuine provisioning fault leaves a clean "name is free" state
1744
+ * instead of orphaning three of the four artifacts (the exact 4-artifact manual
1745
+ * cleanup the cold-download incident caused). A step's own failure is captured +
1746
+ * reported, never thrown, so one stuck teardown can't block the others; a
1747
+ * "not found" teardown counts as already-gone. The caller registers a step the
1748
+ * instant each resource is created, so a failure anywhere inside `fn` rolls back
1749
+ * exactly what existed at that point.
1750
+ */
1751
+ declare function withCreateRollback<T>(ledger: RollbackLedger, opts: CreateRollbackOptions, fn: () => Promise<T>): Promise<T>;
1680
1752
 
1681
1753
  /**
1682
1754
  * Read a single key's value from a .env file (the last assignment wins, matching
@@ -4238,4 +4310,4 @@ declare function applySchemaMigrations(args: ApplySchemaMigrationsArgs): Promise
4238
4310
  declare function rollbackSchemaMigration(args: RollbackSchemaMigrationArgs): Promise<RollbackSchemaMigrationResult>;
4239
4311
  declare function schemaMigrationStatus(args: SchemaMigrationStatusArgs): Promise<SchemaMigrationStatusResult>;
4240
4312
 
4241
- export { type AbandonFeatureArgs, type AbandonFeatureResult, type AddE2eToRunTestsScriptArgs, type AddE2eToRunTestsScriptResult, type AddInfraToPackageJsonArgs, type AddInfraToPackageJsonResult, type AddInfraToRunTestsScriptArgs, type AddInfraToRunTestsScriptResult, type AddPlaywrightToPackageJsonArgs, type AddPlaywrightToPackageJsonResult, type AddPythonE2eDepsArgs, type AddPythonE2eDepsResult, type AdoptLakebaseProjectArgs, type AdoptLakebaseProjectResult, type AdoptStateArgs, type AdoptStateResult, type AppServicePrincipal, type AppliedSchemaMigration, type ApplySchemaMigrationsArgs, type ApplySchemaMigrationsResult, type BranchLookupOpts, type BranchMetadata, CONVENTION_TIER_DEFAULTS, type CatalogExistsArgs, type CheckoutMode, type CheckoutPairedArgs, type CheckoutPairedResult, type ClaimFeatureBranchArgs, type ClaimFeatureBranchResult, type ClaimedOrphan, type ClientFramework, type CommandDriftReport, type CommandFileEntry, type CommandFileStatus, type ConnectionArgs, type ConsortSetupHooks, type CreateBranchArgs, type CreateConventionBranchArgs, type CreateConventionPairedBranchArgs, type CreateLongRunningBranchArgs, type CreateLongRunningBranchResult, type CreatePairedBranchArgs, type CreatePairedBranchResult, type CreateProjectArgs, type CreateProjectResult, type CutBackupArgs, type CutBackupResult, DEFAULT_PROTECTED_TIER_NAMES, DOTNET_EFCORE_DEFAULTS, DOTNET_FLYWAY_DIR, type DatabricksProfile, type DeleteAppEndpointArgs, type DeleteAppEndpointResult, type DeleteBranchArgs, type DeletePairedBranchArgs, type DeletePairedBranchResult, type DeployClaudeCommandsOptions, type DeployClaudeCommandsResult, type DeployEnvExampleArgs, type DeployLanguageProjectArgs, type DeploySpringStarterArgs, type DeployTarget, type DeployTargetsConfig, type DetectCommandDriftArgs, type DetectScaffoldedDriftArgs, type DetectWorkflowDriftArgs, type DoctorArgs$1 as DoctorArgs, type DoctorFinding, type DoctorReport$1 as DoctorReport, type DoctorSeverity, type DotnetMigrationTool, type DsnArgs, type DsnResult, EF_DESIGN_PACKAGE, type EfCoreProject, type EnableE2eForProjectArgs, type EnableE2eForProjectResult, type EnableInfraForProjectArgs, type EnableInfraForProjectResult, type EndpointInfo, type EnsureAppEndpointArgs, type EnsureAppEndpointResult, type EnsureEndpointArgs, type EnsureLakebaseSecretAuthArgs, type EnsureLakebaseSecretAuthResult, type EnsureProfilePinnedArgs, type EnsureProfilePinnedResult, type EnsureSchemaAndVolumeArgs, type EnsureSchemaAndVolumeResult, FIXABLE_FINDING_IDS, type FixFindingArgs, type FixFindingResult, type FixableFindingId, type GateInvariant, type GateStatus, type GenerateAppYamlOptions, type GenerateMavenProjectOptions, type GetAppEndpointArgs, type GetAppEndpointResult, type GetAppServicePrincipalArgs, type GetCiAppEndpointArgs, type GetCiAppEndpointResult, type GetConnectionArgs, type GetCredentialArgs, type GetEndpointArgs, type GetSchemaDiffArgs, type GrantLakebasePermissionArgs, type GrantLakebasePermissionResult, type GrantUcCatalogPermissionArgs, type GrantUcCatalogPermissionResult, type DoctorReport as HealthDoctorReport, type HookVerification, type InfraCheckResult, type InfraSuiteResult, type InitWorkflowStateArgs, type InitializrMetadata, InitializrNetworkError, InitializrParseError, type InstallPlaywrightArgs, type InstallPlaywrightOptions, type InstallPlaywrightResult, LakebaseBranchError, type LakebaseBranchInfo, LakebaseBranchTtlTooLongError, type LakebasePermissionLevel, type LakebaseProjectArgs, LakebaseProjectError, type LakebaseProjectInfo, type LakebaseProjectMetadata, type ListSchemaMigrationsArgs, MAVEN_FLYWAY_DIR, MIGRATION_DEFAULTS, type MergeArgs, type MergePairedArgs, type MergePairedResult, type MergeResult, type MigrationDefaults, type MigrationLanguage, type MigrationLayout, type ModifiedSchemaObject, NODE_E2E_TEMPLATE_FILES, type OrphanCandidate, PLAYWRIGHT_TEMPLATE_FILES, PLAYWRIGHT_TEST_VERSION_RANGE, PYTEST_BDD_VERSION_RANGE, PYTEST_PLAYWRIGHT_VERSION_RANGE, PYTHON_E2E_TEMPLATE_FILES, type PendingSchemaMigration, type PoolArgs, type PreflightResult, type PreparePrArgs, type PreparePrResult, type ProgressCallback, type ProjectLanguage, type PropagateCredentialsArgs, type PropagateCredentialsResult, ProtectedBranchCommitError, type QueryBranchSchemaArgs, type RecoverOrphansArgs, type RecoverOrphansResult, type ReleaseArgs, type ReleaseResult, type RemoveRunnerArgs, type ResolveDatabricksHostArgs, type ResolveMigrationLayoutArgs, type RollbackDeployArgs, type RollbackDeployResult, type RollbackOptions, type RollbackSchemaMigrationArgs, type RollbackSchemaMigrationResult, type RunDoctorDeps, type RunInfraSuiteArgs, type RunPlaywrightInstallArgs, type RunPlaywrightInstallResult, type RunnerInfo, type RunnerReportFn, type RunnerType, SCM_STATES, STATE_FILE_REL, type ScaffoldAllArgs, type ScaffoldOptions, type ScaffoldReportFn, type ScaffoldStaticAllArgs, type ScaffoldStaticAllResult, type ScaffoldedDriftReport, type SchemaColumn, type SchemaDiffResult, SchemaMigrationError, type SchemaMigrationFile, type SchemaMigrationLanguage, type SchemaMigrationStatusArgs, type SchemaMigrationStatusResult, type SchemaMigrationToolName, type SchemaObject, type SchemaQueryRow, ScmAbandonError, ScmAdoptError, ScmClaimError, ScmDoctorFixError, ScmMergeError, ScmPreparePrError, ScmRecoverError, ScmReleaseError, type ScmState, ScmWaitCiError, type ScmWorkflowState, type SetupRunnerArgs, type SftddSetupHooks, SpringInitializrClient, type SpringJvmLanguage, type StaleBranchFinding, type SyncEnvArgs, type SyncEnvResult, type TableSchema, type TierTopology, type TryCreateCatalogArgs, type TryCreateCatalogResult, type UcCatalogPermission, type UpdateEnvConnectionArgs, type UpdateWorkflowsArgs, type UpdateWorkflowsResult, type UploadDirectoryArgs, type UploadDirectoryResult, type ValidateAppOptions, type ValidateAppResult, type ValidationError, type ValidationResult, type WaitCiArgs, type WaitCiResult, type WaitForBranchAuthReadyArgs, type WaitForBranchReadyArgs, type WorkflowDriftReport, type WorkflowFileStatus, type WorkflowFileUpdate, type WorkflowStatus, type WorkflowUpdateOutcome, type WorkflowVerification, type WriteEnvFileArgs, type WritePlaywrightTemplatesArgs, type WritePlaywrightTemplatesResult, _testMakeBrownfieldFixture, abandonFeatureBranch, addE2eToRunTestsScript, addInfraToPackageJson, addInfraToRunTestsScript, addPlaywrightToPackageJson, adoptLakebaseProject, adoptScmState, applySchemaMigrations, assertAdoptionPreflight, assertCleanForFork, assertCommitTargetNotProtected, assertCreatedProjectReady, buildPostgresUrl, buildSchemaQuery, cacheProjectRetention, catalogExists, catalogExplorerUrl, checkDatabricksAuth, checkGitHubWorkflowScope, checkoutPaired, claimFeatureBranch, clearRetentionCache, compileMigrationPattern, connectionApplicationName, createBranch, createFeaturePairedBranch, createLakebaseProject, createLongRunningBranch, createPairedBranch, createPerfPairedBranch, createProject, createTestPairedBranch, createUatPairedBranch, cutBackup, databricksAuthPrereqMessage, defaultRefreshPromoteWorkflows, deleteAppEndpoint, deleteBranch, deleteLakebaseProject, deletePairedBranch, deleteProjectArgs, deployClaudeAgents, deployClaudeCommands, deployClaudeSettings, deployClaudeSkills, deployClientProject, deployDeployTargets, deployEnv, deployEnvExample, deployGitignore, deployLanguageProject, deployScripts, deploySpringStarter, deployVscodeSettings, deployWorkflows, deriveCiAppName, describeGates, detectCommandDrift, detectLanguage, detectLanguageAt, detectScaffoldedDrift, detectWorkflowDrift, dirIsEmpty, enableE2eForProject, enableInfraForProject, endpointPath, ensureAppEndpoint, ensureCachedArchive, ensureEndpoint, ensureLakebaseSecretAuth, ensureProfilePinned, ensurePythonBddDeps, ensurePythonE2eDeps, ensureSchemaAndVolume, extractPullNumber, featureBranchName, findCsprojFiles, findDefaultBranchName, findEfCoreProject, findHistoryRetentionDuration, fixFinding, flywayMigrationsDir, formatJUnit, formatSchemaDiffAsMarkdown, generateAppYaml, getAppEndpoint, getAppServicePrincipal, getBranchByName, getCachedProjectRetention, getCiAppEndpoint, getConnection, getCredential, getDefaultBranch, getDefaultBranchId, getDefaultBranchName, getEndpoint, getProjectInfo, getProjectRetentionDuration, getRunnerInfo, getSchemaDiff, getTargetNames, githubWorkflowScopePrereqMessage, grantLakebasePermission, grantUcCatalogPermission, hasDotnetMarker, inferTierTopology, initWorkflowState, installHooks, installPlaywright, isAllSchemas, isDotnetFlywayProject, isDotnetProject, isForeignFeatureClaim, isGitTracked, isLongRunningTierBranch, isLtsJavaVersion, isPrereleaseBootVersion, isRunning, isTier, isTtlTooLongError, kitWarmWarning, listAppDeployments, listBranches, listSchemaMigrations, mergeFeature, mergePaired, minLakebaseTtl, mintCredential, normalizeHost, normalizeTierName, parseHostFromAuthDescribe, parseLakebaseTtl, parseTargetsYaml, patchWorkflowsForRunnerType, preparePr, projectPath, propagateCredentials, protectedTierNamesFromEnv, pushFailureHint, queryBranchSchema, queryBranchTables, readEnvVar, readTargets, readWorkflowState, reconcilePromoteRunState, reconcileTierToOrigin, recoverOrphans, release, removeRunner, resolveBranchId, resolveBranchPath, resolveCurrentUser, resolveDatabricksHost, resolveEndpointHost, resolveFeatureStartPoint, resolveJavaHome, resolveLatestBootVersion, resolveLatestLtsJavaVersion, resolveMigrationLanguage, resolveMigrationLayout, resolveParentBranch, resolveProfileForHost, resolveProfileForHostSync, resolveProtectedTierNames, rollbackDeploy, rollbackSchemaMigration, runDoctor$1 as runDoctor, runDoctor as runHealthDoctor, runInfraSuite, runPlaywrightInstall, runnerDir, runnerName, sanitizeFeatureSlug, scaffoldAll, scaffoldStaticAll, schemaMigrationStatus, schemaObjectName, selectProfileForHost, setupRunner, stateFilePath, stopRunner, substituteScmUtilsVersion, substrateVersion, syncEnvToCurrentBranch, tierBranchNames, toolForLanguage, tryCreateCatalog, updateEnvConnection, updateWorkflows, uploadDirectory, validateApp, validateCreateInputs, validateWorkflowState, verifyHooks, verifyProject, verifyWorkflows, waitForBranchAuthReady, waitForBranchReady, waitForCi, warmAndVerifyKit, withLakebaseRollback, workflowStateFileExists, writeEnvFile, writePlaywrightTemplates, writeTargets, writeWorkflowState };
4313
+ export { type AbandonFeatureArgs, type AbandonFeatureResult, type AddE2eToRunTestsScriptArgs, type AddE2eToRunTestsScriptResult, type AddInfraToPackageJsonArgs, type AddInfraToPackageJsonResult, type AddInfraToRunTestsScriptArgs, type AddInfraToRunTestsScriptResult, type AddPlaywrightToPackageJsonArgs, type AddPlaywrightToPackageJsonResult, type AddPythonE2eDepsArgs, type AddPythonE2eDepsResult, type AdoptLakebaseProjectArgs, type AdoptLakebaseProjectResult, type AdoptStateArgs, type AdoptStateResult, type AppServicePrincipal, type AppliedSchemaMigration, type ApplySchemaMigrationsArgs, type ApplySchemaMigrationsResult, type BranchLookupOpts, type BranchMetadata, CONVENTION_TIER_DEFAULTS, type CatalogExistsArgs, type CheckoutMode, type CheckoutPairedArgs, type CheckoutPairedResult, type ClaimFeatureBranchArgs, type ClaimFeatureBranchResult, type ClaimedOrphan, type ClientFramework, type CommandDriftReport, type CommandFileEntry, type CommandFileStatus, type ConnectionArgs, type ConsortSetupHooks, type CreateBranchArgs, type CreateConventionBranchArgs, type CreateConventionPairedBranchArgs, type CreateLongRunningBranchArgs, type CreateLongRunningBranchResult, type CreatePairedBranchArgs, type CreatePairedBranchResult, type CreateProjectArgs, type CreateProjectResult, type CreateRollbackOptions, type CutBackupArgs, type CutBackupResult, DEFAULT_PROTECTED_TIER_NAMES, DOTNET_EFCORE_DEFAULTS, DOTNET_FLYWAY_DIR, type DatabricksProfile, type DeleteAppEndpointArgs, type DeleteAppEndpointResult, type DeleteBranchArgs, type DeletePairedBranchArgs, type DeletePairedBranchResult, type DeployClaudeCommandsOptions, type DeployClaudeCommandsResult, type DeployEnvExampleArgs, type DeployLanguageProjectArgs, type DeploySpringStarterArgs, type DeployTarget, type DeployTargetsConfig, type DetectCommandDriftArgs, type DetectScaffoldedDriftArgs, type DetectWorkflowDriftArgs, type DoctorArgs$1 as DoctorArgs, type DoctorFinding, type DoctorReport$1 as DoctorReport, type DoctorSeverity, type DotnetMigrationTool, type DsnArgs, type DsnResult, EF_DESIGN_PACKAGE, type EfCoreProject, type EnableE2eForProjectArgs, type EnableE2eForProjectResult, type EnableInfraForProjectArgs, type EnableInfraForProjectResult, type EndpointInfo, type EnsureAppEndpointArgs, type EnsureAppEndpointResult, type EnsureEndpointArgs, type EnsureLakebaseSecretAuthArgs, type EnsureLakebaseSecretAuthResult, type EnsureProfilePinnedArgs, type EnsureProfilePinnedResult, type EnsureSchemaAndVolumeArgs, type EnsureSchemaAndVolumeResult, FIXABLE_FINDING_IDS, type FixFindingArgs, type FixFindingResult, type FixableFindingId, type GateInvariant, type GateStatus, type GenerateAppYamlOptions, type GenerateMavenProjectOptions, type GetAppEndpointArgs, type GetAppEndpointResult, type GetAppServicePrincipalArgs, type GetCiAppEndpointArgs, type GetCiAppEndpointResult, type GetConnectionArgs, type GetCredentialArgs, type GetEndpointArgs, type GetSchemaDiffArgs, type GitHubPreflightInput, type GitHubPreflightResult, type GrantLakebasePermissionArgs, type GrantLakebasePermissionResult, type GrantUcCatalogPermissionArgs, type GrantUcCatalogPermissionResult, type DoctorReport as HealthDoctorReport, type HookVerification, type InfraCheckResult, type InfraSuiteResult, type InitWorkflowStateArgs, type InitializrMetadata, InitializrNetworkError, InitializrParseError, type InstallPlaywrightArgs, type InstallPlaywrightOptions, type InstallPlaywrightResult, LakebaseBranchError, type LakebaseBranchInfo, LakebaseBranchTtlTooLongError, type LakebasePermissionLevel, type LakebaseProjectArgs, LakebaseProjectError, type LakebaseProjectInfo, type LakebaseProjectMetadata, type ListSchemaMigrationsArgs, MAVEN_FLYWAY_DIR, MIGRATION_DEFAULTS, type MergeArgs, type MergePairedArgs, type MergePairedResult, type MergeResult, type MigrationDefaults, type MigrationLanguage, type MigrationLayout, type ModifiedSchemaObject, NODE_E2E_TEMPLATE_FILES, type OrphanCandidate, PLAYWRIGHT_TEMPLATE_FILES, PLAYWRIGHT_TEST_VERSION_RANGE, PYTEST_BDD_VERSION_RANGE, PYTEST_PLAYWRIGHT_VERSION_RANGE, PYTHON_E2E_TEMPLATE_FILES, type PendingSchemaMigration, type PoolArgs, type PreflightResult, type PreparePrArgs, type PreparePrResult, type ProgressCallback, type ProjectLanguage, type PropagateCredentialsArgs, type PropagateCredentialsResult, ProtectedBranchCommitError, type QueryBranchSchemaArgs, type RecoverOrphansArgs, type RecoverOrphansResult, type ReleaseArgs, type ReleaseResult, type RemoveRunnerArgs, type ResolveDatabricksHostArgs, type ResolveMigrationLayoutArgs, type RollbackDeployArgs, type RollbackDeployResult, type RollbackLedger, type RollbackOptions, type RollbackSchemaMigrationArgs, type RollbackSchemaMigrationResult, type RollbackStep, type RunDoctorDeps, type RunInfraSuiteArgs, type RunPlaywrightInstallArgs, type RunPlaywrightInstallResult, type RunnerInfo, type RunnerReportFn, type RunnerType, SCM_STATES, STATE_FILE_REL, type ScaffoldAllArgs, type ScaffoldOptions, type ScaffoldReportFn, type ScaffoldStaticAllArgs, type ScaffoldStaticAllResult, type ScaffoldedDriftReport, type SchemaColumn, type SchemaDiffResult, SchemaMigrationError, type SchemaMigrationFile, type SchemaMigrationLanguage, type SchemaMigrationStatusArgs, type SchemaMigrationStatusResult, type SchemaMigrationToolName, type SchemaObject, type SchemaQueryRow, ScmAbandonError, ScmAdoptError, ScmClaimError, ScmDoctorFixError, ScmMergeError, ScmPreparePrError, ScmRecoverError, ScmReleaseError, type ScmState, ScmWaitCiError, type ScmWorkflowState, type SetupRunnerArgs, type SftddSetupHooks, SpringInitializrClient, type SpringJvmLanguage, type StaleBranchFinding, type SyncEnvArgs, type SyncEnvResult, type TableSchema, type TierTopology, type TryCreateCatalogArgs, type TryCreateCatalogResult, type UcCatalogPermission, type UpdateEnvConnectionArgs, type UpdateWorkflowsArgs, type UpdateWorkflowsResult, type UploadDirectoryArgs, type UploadDirectoryResult, type ValidateAppOptions, type ValidateAppResult, type ValidationError, type ValidationResult, type WaitCiArgs, type WaitCiResult, type WaitForBranchAuthReadyArgs, type WaitForBranchReadyArgs, type WorkflowDriftReport, type WorkflowFileStatus, type WorkflowFileUpdate, type WorkflowStatus, type WorkflowUpdateOutcome, type WorkflowVerification, type WriteEnvFileArgs, type WritePlaywrightTemplatesArgs, type WritePlaywrightTemplatesResult, _testMakeBrownfieldFixture, abandonFeatureBranch, addE2eToRunTestsScript, addInfraToPackageJson, addInfraToRunTestsScript, addPlaywrightToPackageJson, adoptLakebaseProject, adoptScmState, applySchemaMigrations, assertAdoptionPreflight, assertCleanForFork, assertCommitTargetNotProtected, assertCreatedProjectReady, buildPostgresUrl, buildSchemaQuery, cacheProjectRetention, catalogExists, catalogExplorerUrl, checkDatabricksAuth, checkGitHubPreflight, checkGitHubWorkflowScope, checkoutPaired, claimFeatureBranch, clearRetentionCache, compileMigrationPattern, connectionApplicationName, createBranch, createFeaturePairedBranch, createLakebaseProject, createLongRunningBranch, createPairedBranch, createPerfPairedBranch, createProject, createRollbackLedger, createTestPairedBranch, createUatPairedBranch, cutBackup, databricksAuthPrereqMessage, defaultRefreshPromoteWorkflows, deleteAppEndpoint, deleteBranch, deleteLakebaseProject, deletePairedBranch, deleteProjectArgs, deployClaudeAgents, deployClaudeCommands, deployClaudeSettings, deployClaudeSkills, deployClientProject, deployDeployTargets, deployEnv, deployEnvExample, deployGitignore, deployLanguageProject, deployScripts, deploySpringStarter, deployVscodeSettings, deployWorkflows, deriveCiAppName, describeGates, detectCommandDrift, detectLanguage, detectLanguageAt, detectScaffoldedDrift, detectWorkflowDrift, dirIsEmpty, enableE2eForProject, enableInfraForProject, endpointPath, ensureAppEndpoint, ensureCachedArchive, ensureEndpoint, ensureLakebaseSecretAuth, ensureProfilePinned, ensurePythonBddDeps, ensurePythonE2eDeps, ensureSchemaAndVolume, extractPullNumber, featureBranchName, findCsprojFiles, findDefaultBranchName, findEfCoreProject, findHistoryRetentionDuration, fixFinding, flywayMigrationsDir, formatJUnit, formatSchemaDiffAsMarkdown, generateAppYaml, getAppEndpoint, getAppServicePrincipal, getBranchByName, getCachedProjectRetention, getCiAppEndpoint, getConnection, getCredential, getDefaultBranch, getDefaultBranchId, getDefaultBranchName, getEndpoint, getProjectInfo, getProjectRetentionDuration, getRunnerInfo, getSchemaDiff, getTargetNames, githubWorkflowScopePrereqMessage, grantLakebasePermission, grantUcCatalogPermission, hasDotnetMarker, inferTierTopology, initWorkflowState, installHooks, installPlaywright, isAllSchemas, isDotnetFlywayProject, isDotnetProject, isForeignFeatureClaim, isGitTracked, isLongRunningTierBranch, isLtsJavaVersion, isPrereleaseBootVersion, isRunning, isTier, isTtlTooLongError, kitWarmWarning, listAppDeployments, listBranches, listSchemaMigrations, mergeFeature, mergePaired, minLakebaseTtl, mintCredential, normalizeHost, normalizeTierName, parseHostFromAuthDescribe, parseLakebaseTtl, parseTargetsYaml, patchWorkflowsForRunnerType, preparePr, projectPath, propagateCredentials, protectedTierNamesFromEnv, pushFailureHint, queryBranchSchema, queryBranchTables, readEnvVar, readTargets, readWorkflowState, reconcilePromoteRunState, reconcileTierToOrigin, recoverOrphans, release, removeRunner, resolveBranchId, resolveBranchPath, resolveCurrentUser, resolveDatabricksHost, resolveEndpointHost, resolveFeatureStartPoint, resolveJavaHome, resolveLatestBootVersion, resolveLatestLtsJavaVersion, resolveMigrationLanguage, resolveMigrationLayout, resolveParentBranch, resolveProfileForHost, resolveProfileForHostSync, resolveProtectedTierNames, rollbackDeploy, rollbackSchemaMigration, runDoctor$1 as runDoctor, runDoctor as runHealthDoctor, runInfraSuite, runPlaywrightInstall, runnerDir, runnerName, sanitizeFeatureSlug, scaffoldAll, scaffoldStaticAll, schemaMigrationStatus, schemaObjectName, selectProfileForHost, setupRunner, stateFilePath, stopRunner, substituteScmUtilsVersion, substrateVersion, syncEnvToCurrentBranch, tierBranchNames, toolForLanguage, tryCreateCatalog, updateEnvConnection, updateWorkflows, uploadDirectory, validateApp, validateCreateInputs, validateWorkflowState, verifyHooks, verifyProject, verifyWorkflows, waitForBranchAuthReady, waitForBranchReady, waitForCi, warmAndVerifyKit, withCreateRollback, withLakebaseRollback, workflowStateFileExists, writeEnvFile, writePlaywrightTemplates, writeTargets, writeWorkflowState };
@@ -2554,8 +2554,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
2554
2554
  var cached;
2555
2555
  function substrateSelfVersion() {
2556
2556
  if (cached !== void 0) return cached;
2557
- if ("0.3.10".length > 0) {
2558
- cached = "0.3.10";
2557
+ if ("0.3.11".length > 0) {
2558
+ cached = "0.3.11";
2559
2559
  return cached;
2560
2560
  }
2561
2561
  cached = "unknown";
@@ -11135,6 +11135,26 @@ async function createRepo(name, opts = {}) {
11135
11135
  wrap2(err, `Failed to create repository "${name}"`);
11136
11136
  }
11137
11137
  }
11138
+ async function deleteRepo(name) {
11139
+ try {
11140
+ const { owner, repo } = parseOwnerRepo(name);
11141
+ const ctx = await newContext();
11142
+ await ctx.octokit.rest.repos.delete({ owner, repo });
11143
+ } catch (err) {
11144
+ wrap2(err, `Failed to delete repository "${name}"`);
11145
+ }
11146
+ }
11147
+ async function repoExists(name) {
11148
+ try {
11149
+ const { owner, repo } = parseOwnerRepo(name);
11150
+ const ctx = await newContext();
11151
+ await ctx.octokit.rest.repos.get({ owner, repo });
11152
+ return true;
11153
+ } catch (err) {
11154
+ if (err instanceof RequestError && err.status === 404) return false;
11155
+ wrap2(err, `Failed to check repository "${name}"`);
11156
+ }
11157
+ }
11138
11158
  async function getActionsEnabled(ownerRepo) {
11139
11159
  try {
11140
11160
  const { owner, repo } = parseOwnerRepo(ownerRepo);
@@ -11203,6 +11223,70 @@ async function checkGitHubWorkflowScope(probe = () => checkGitHubScopes(["workfl
11203
11223
  return { ok: true };
11204
11224
  }
11205
11225
  }
11226
+ async function checkGitHubPreflight(input) {
11227
+ const warnings = [];
11228
+ const hard = input.hardScopes ?? ["repo", "workflow"];
11229
+ const advisory = input.advisoryScopes ?? ["delete_repo"];
11230
+ const currentUserProbe = input.currentUser ?? getCurrentUser;
11231
+ const scopesProbe = input.scopes ?? ((req) => checkGitHubScopes(req));
11232
+ const repoExistsProbe = input.repoExists ?? repoExists;
11233
+ let activeUser;
11234
+ try {
11235
+ activeUser = await currentUserProbe();
11236
+ } catch (err) {
11237
+ return {
11238
+ ok: false,
11239
+ warnings,
11240
+ reason: `GitHub authentication failed: ${err instanceof Error ? err.message : String(err)}. Sign in with \`gh auth login\`, or set GITHUB_TOKEN to a valid token, then re-run.`
11241
+ };
11242
+ }
11243
+ if (activeUser.toLowerCase() !== input.owner.toLowerCase()) {
11244
+ warnings.push(
11245
+ `Signed in to GitHub as "${activeUser}" but creating under "${input.owner}" (an org or another account); ensure "${activeUser}" can create repositories there.`
11246
+ );
11247
+ }
11248
+ try {
11249
+ const { granted, missing } = await scopesProbe([...hard, ...advisory]);
11250
+ if (granted !== null) {
11251
+ const missingHard = missing.filter((s) => hard.includes(s));
11252
+ const missingAdvisory = missing.filter((s) => advisory.includes(s));
11253
+ if (missingHard.length > 0) {
11254
+ return {
11255
+ ok: false,
11256
+ warnings,
11257
+ activeUser,
11258
+ reason: `GitHub token missing required scope(s): ${missingHard.join(", ")} (grants [${granted.join(", ") || "none"}]). Fix: gh auth refresh -h github.com -s ${[...hard].join(",")}`
11259
+ };
11260
+ }
11261
+ if (missingAdvisory.length > 0) {
11262
+ warnings.push(
11263
+ `GitHub token missing the ${missingAdvisory.join(", ")} scope \u2014 automatic rollback of the repo on a failed create is unavailable (you would delete it by hand). Grant it with: gh auth refresh -h github.com -s delete_repo`
11264
+ );
11265
+ }
11266
+ } else {
11267
+ warnings.push(
11268
+ "GitHub token scopes are not visible (fine-grained PAT or App token); cannot pre-verify repo/workflow access , the create will surface any gap when it pushes."
11269
+ );
11270
+ }
11271
+ } catch {
11272
+ warnings.push("Could not read GitHub token scopes (probe error); skipping the scope pre-check.");
11273
+ }
11274
+ try {
11275
+ if (await repoExistsProbe(`${input.owner}/${input.repoName}`)) {
11276
+ return {
11277
+ ok: false,
11278
+ warnings,
11279
+ activeUser,
11280
+ reason: `GitHub repo "${input.owner}/${input.repoName}" already exists. Pick a different project name, or delete the existing repo first.`
11281
+ };
11282
+ }
11283
+ } catch {
11284
+ warnings.push(
11285
+ `Could not check whether "${input.owner}/${input.repoName}" already exists (probe error); the create will fail clearly if it does.`
11286
+ );
11287
+ }
11288
+ return { ok: true, warnings, activeUser };
11289
+ }
11206
11290
  function githubWorkflowScopePrereqMessage(reason) {
11207
11291
  return "The GitHub token lacks the `workflow` OAuth scope, required to push the project's `.github/workflows/*` CI files. (Without this check, scaffolding runs all the way to the final push, is rejected, and rolls back.) Grant the scope, then re-run:\n - gh CLI: gh auth refresh -h github.com -s workflow\n - VS Code: re-sign in to GitHub and approve the workflow scope\n - token: set GITHUB_TOKEN to a PAT that includes the `workflow` scope" + (reason ? `
11208
11292
  (${reason})` : "");
@@ -11268,6 +11352,53 @@ async function withLakebaseRollback(opts, fn) {
11268
11352
  throw wrapped;
11269
11353
  }
11270
11354
  }
11355
+ function createRollbackLedger() {
11356
+ const steps = [];
11357
+ return {
11358
+ register: (label, undo) => {
11359
+ steps.push({ label, undo });
11360
+ },
11361
+ steps: () => steps
11362
+ };
11363
+ }
11364
+ async function withCreateRollback(ledger, opts, fn) {
11365
+ try {
11366
+ return await fn();
11367
+ } catch (err) {
11368
+ const report = opts.report ?? (() => {
11369
+ });
11370
+ const steps = [...ledger.steps()].reverse();
11371
+ const rolledBack = [];
11372
+ const failed = [];
11373
+ if (steps.length > 0) report(`Create failed; rolling back ${steps.length} created resource(s)...`);
11374
+ for (const s of steps) {
11375
+ try {
11376
+ report(` rolling back: ${s.label}`);
11377
+ await s.undo();
11378
+ rolledBack.push(s.label);
11379
+ } catch (e) {
11380
+ const m = e instanceof Error ? e.message : String(e);
11381
+ if (/not.?found/i.test(m)) {
11382
+ rolledBack.push(s.label);
11383
+ continue;
11384
+ }
11385
+ failed.push(`${s.label} (${m})`);
11386
+ }
11387
+ }
11388
+ const base = err instanceof Error ? err.message : String(err);
11389
+ const parts = [];
11390
+ if (rolledBack.length) parts.push(`rolled back: ${rolledBack.join(", ")}`);
11391
+ if (failed.length) {
11392
+ parts.push(
11393
+ `COULD NOT roll back: ${failed.join("; ")} , clean these up by hand before retrying the same name`
11394
+ );
11395
+ }
11396
+ const suffix = parts.length ? ` (${parts.join("; ")})` : "";
11397
+ const wrapped = err instanceof Error ? err : new Error(base);
11398
+ wrapped.message = `${base}${suffix}`;
11399
+ throw wrapped;
11400
+ }
11401
+ }
11271
11402
 
11272
11403
  // scripts/lakebase/create-project.ts
11273
11404
  init_esm_shims();
@@ -11335,27 +11466,34 @@ To finish:
11335
11466
  this.name = "WorkflowScopeError";
11336
11467
  }
11337
11468
  };
11338
- async function commitAndPush(args) {
11339
- await exec2("git add -A", { cwd: args.projectDir });
11340
- await exec2(`git commit -m ${JSON.stringify(args.message)}`, {
11341
- cwd: args.projectDir,
11469
+ async function commitInitial(projectDir, message) {
11470
+ await exec2("git add -A", { cwd: projectDir });
11471
+ await exec2(`git commit -m ${JSON.stringify(message)}`, {
11472
+ cwd: projectDir,
11342
11473
  timeout: 3e4
11343
11474
  });
11344
- if (args.push === false) return;
11475
+ }
11476
+ async function pushInitial(args) {
11345
11477
  const remote = args.remote ?? "origin";
11346
11478
  const branch = args.branch ?? "main";
11347
- try {
11348
- await exec2(`git push -u ${remote} ${branch}`, {
11349
- cwd: args.projectDir,
11350
- timeout: 3e4
11351
- });
11352
- } catch (err) {
11353
- const msg = err instanceof Error ? err.message : String(err);
11354
- if (/without `?workflow`? scope|workflow scope/i.test(msg)) {
11355
- throw new WorkflowScopeError(args.projectDir);
11479
+ const attempts = Math.max(1, args.attempts ?? 1);
11480
+ const sleep2 = args.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
11481
+ const run = args.run ?? ((cmd, cwd) => exec2(cmd, { cwd, timeout: 3e4 }).then(() => void 0));
11482
+ let lastErr;
11483
+ for (let i = 1; i <= attempts; i++) {
11484
+ try {
11485
+ await run(`git push -u ${remote} ${branch}`, args.projectDir);
11486
+ return;
11487
+ } catch (err) {
11488
+ const msg = err instanceof Error ? err.message : String(err);
11489
+ if (/without `?workflow`? scope|workflow scope/i.test(msg)) {
11490
+ throw new WorkflowScopeError(args.projectDir);
11491
+ }
11492
+ lastErr = err;
11493
+ if (i < attempts) await sleep2(args.delayMs ?? 1500);
11356
11494
  }
11357
- throw err;
11358
11495
  }
11496
+ throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
11359
11497
  }
11360
11498
 
11361
11499
  // scripts/lakebase/scaffold.ts
@@ -13661,64 +13799,72 @@ async function createProject(input, progress) {
13661
13799
  throw new Error(databricksAuthPrereqMessage(host, auth7.reason));
13662
13800
  }
13663
13801
  if (useGithub) {
13664
- report("Checking GitHub token scopes...");
13665
- const scope = await checkGitHubWorkflowScope();
13666
- if (!scope.ok) {
13667
- throw new Error(githubWorkflowScopePrereqMessage(scope.reason));
13668
- }
13669
- }
13670
- if (useGithub) {
13671
- report("Creating GitHub repository...", fullRepoName);
13672
- await createRepo(fullRepoName, {
13673
- private: input.privateRepo !== false,
13674
- description: `Lakebase project: ${input.projectName}`
13675
- });
13676
- report("Waiting for GitHub repo to be visible...", fullRepoName);
13677
- const probeDelays = [1e3, 2e3, 3e3, 5e3, 8e3];
13678
- let probeErr = "";
13679
- let visible = false;
13680
- for (const waitMs of probeDelays) {
13681
- try {
13682
- await getRepoFullName(fullRepoName);
13683
- visible = true;
13684
- break;
13685
- } catch (err) {
13686
- probeErr = err instanceof Error ? err.message : String(err);
13687
- await delay(waitMs);
13688
- }
13689
- }
13690
- if (!visible) {
13691
- let activeUser = "";
13692
- try {
13693
- activeUser = await getCurrentUser();
13694
- } catch {
13695
- }
13696
- const samlHint = /SAML|scope does not match|sso/i.test(probeErr) ? "\n\nThe error mentions SAML \u2013 re-sign in to GitHub and authorize SSO for this org." : "";
13697
- const userHint = activeUser && activeUser !== input.githubOwner ? `
13802
+ report("Checking GitHub account + token requisites...");
13803
+ const gh = await checkGitHubPreflight({ owner: input.githubOwner, repoName: input.projectName });
13804
+ for (const w of gh.warnings) {
13805
+ warnings.push(w);
13806
+ report(`Note: ${w}`);
13807
+ }
13808
+ if (!gh.ok) throw new Error(gh.reason);
13809
+ }
13810
+ const rollback = createRollbackLedger();
13811
+ return await withCreateRollback(
13812
+ rollback,
13813
+ { report },
13814
+ async () => {
13815
+ if (useGithub) {
13816
+ report("Creating GitHub repository...", fullRepoName);
13817
+ await createRepo(fullRepoName, {
13818
+ private: input.privateRepo !== false,
13819
+ description: `Lakebase project: ${input.projectName}`
13820
+ });
13821
+ rollback.register(`GitHub repo ${fullRepoName}`, () => deleteRepo(fullRepoName));
13822
+ report("Waiting for GitHub repo to be visible...", fullRepoName);
13823
+ const probeDelays = [1e3, 2e3, 3e3, 5e3, 8e3];
13824
+ let probeErr = "";
13825
+ let visible = false;
13826
+ for (const waitMs of probeDelays) {
13827
+ try {
13828
+ await getRepoFullName(fullRepoName);
13829
+ visible = true;
13830
+ break;
13831
+ } catch (err) {
13832
+ probeErr = err instanceof Error ? err.message : String(err);
13833
+ await delay(waitMs);
13834
+ }
13835
+ }
13836
+ if (!visible) {
13837
+ let activeUser = "";
13838
+ try {
13839
+ activeUser = await getCurrentUser();
13840
+ } catch {
13841
+ }
13842
+ const samlHint = /SAML|scope does not match|sso/i.test(probeErr) ? "\n\nThe error mentions SAML \u2013 re-sign in to GitHub and authorize SSO for this org." : "";
13843
+ const userHint = activeUser && activeUser !== input.githubOwner ? `
13698
13844
 
13699
13845
  Note: signed in as "${activeUser}", but the repo was created under "${input.githubOwner}".` : "";
13700
- throw new Error(
13701
- `GitHub repo "${fullRepoName}" was created but isn't visible after ~19s of polling.${samlHint}${userHint}
13846
+ throw new Error(
13847
+ `GitHub repo "${fullRepoName}" was created but isn't visible after ~19s of polling.${samlHint}${userHint}
13702
13848
 
13703
13849
  Last probe error:
13704
13850
  ${probeErr.split("\n")[0].slice(0, 200)}`
13705
- );
13706
- }
13707
- report("Cloning repository...", projectDir);
13708
- await cloneRepo({
13709
- repoUrl: `https://github.com/${fullRepoName}.git`,
13710
- parentDir: input.parentDir
13711
- });
13712
- } else {
13713
- report("Creating local project directory...", projectDir);
13714
- fs19.mkdirSync(projectDir, { recursive: true });
13715
- await gitInit(projectDir);
13716
- }
13717
- report("Creating Lakebase database (provisioning Postgres)...", lakebaseProjectId);
13718
- await createLakebaseProject({ projectId: lakebaseProjectId, host });
13719
- return await withLakebaseRollback(
13720
- { projectId: lakebaseProjectId, host, report },
13721
- async () => {
13851
+ );
13852
+ }
13853
+ report("Cloning repository...", projectDir);
13854
+ await cloneRepo({
13855
+ repoUrl: `https://github.com/${fullRepoName}.git`,
13856
+ parentDir: input.parentDir
13857
+ });
13858
+ rollback.register(`local project dir ${projectDir}`, () => fs19.rmSync(projectDir, { recursive: true, force: true }));
13859
+ } else {
13860
+ report("Creating local project directory...", projectDir);
13861
+ fs19.mkdirSync(projectDir, { recursive: true });
13862
+ await gitInit(projectDir);
13863
+ rollback.register(`local project dir ${projectDir}`, () => fs19.rmSync(projectDir, { recursive: true, force: true }));
13864
+ }
13865
+ report("Creating Lakebase database (provisioning Postgres)...", lakebaseProjectId);
13866
+ await createLakebaseProject({ projectId: lakebaseProjectId, host });
13867
+ rollback.register(`Lakebase project ${lakebaseProjectId}`, () => deleteLakebaseProject({ projectId: lakebaseProjectId, host }));
13722
13868
  report("Resolving database endpoint...");
13723
13869
  const defaultBranchId = await getDefaultBranchId({
13724
13870
  projectId: lakebaseProjectId,
@@ -13802,6 +13948,10 @@ Last probe error:
13802
13948
  projectName: input.projectName,
13803
13949
  report: (m) => report(m)
13804
13950
  });
13951
+ rollback.register(
13952
+ `self-hosted runner ${input.projectName}`,
13953
+ () => removeRunner({ fullRepoName, projectName: input.projectName })
13954
+ );
13805
13955
  } catch (err) {
13806
13956
  const msg = err instanceof Error ? err.message : String(err);
13807
13957
  warnings.push(`Runner setup failed: ${msg}`);
@@ -13870,6 +14020,16 @@ Last probe error:
13870
14020
  "The Consort toolkit downloads on first use , run `./scripts/lk --refresh`, or just your first `./scripts/lk` command, and it installs then."
13871
14021
  );
13872
14022
  }
14023
+ if (enableSftdd && useGithub) {
14024
+ report("Warming the Consort toolkit (so the first push doesn't cold-download mid-hook)...");
14025
+ let warm = warmAndVerifyKit(projectDir);
14026
+ if (!warm.ok) warm = warmAndVerifyKit(projectDir);
14027
+ if (!warm.ok) {
14028
+ const m = kitWarmWarning(projectDir, warm.reason);
14029
+ warnings.push(m);
14030
+ report(`Note: ${m}`);
14031
+ }
14032
+ }
13873
14033
  const langLabels = {
13874
14034
  java: "Java/Spring Boot",
13875
14035
  kotlin: "Kotlin/Spring Boot",
@@ -13890,12 +14050,25 @@ Last probe error:
13890
14050
  }
13891
14051
  }
13892
14052
  report("Creating initial commit...");
13893
- await commitAndPush({
13894
- projectDir,
13895
- message: `Initial project scaffold (${langLabel} + Lakebase)`,
13896
- push: useGithub
13897
- });
13898
- if (tiers === 2 || tiers === 3) {
14053
+ await commitInitial(projectDir, `Initial project scaffold (${langLabel} + Lakebase)`);
14054
+ let pushLanded = !useGithub;
14055
+ if (useGithub) {
14056
+ try {
14057
+ await pushInitial({ projectDir, attempts: 2 });
14058
+ pushLanded = true;
14059
+ } catch (err) {
14060
+ if (err instanceof WorkflowScopeError) throw err;
14061
+ const msg = err instanceof Error ? err.message : String(err);
14062
+ const m = `Provisioning is complete, but the initial push did not land after a retry: ${msg}. The project on disk is fine , finish it with: cd ${projectDir} && git push -u origin main`;
14063
+ warnings.push(m);
14064
+ report(`WARNING: ${m}`);
14065
+ }
14066
+ }
14067
+ if ((tiers === 2 || tiers === 3) && !pushLanded) {
14068
+ const m = `INCOMPLETE TIERS: you requested ${tiers} tiers, but the initial push hasn't landed, so the tier branches can't fork off origin yet. After you finish the push (above), cut them with \`./scripts/lk lakebase-cut-tier --name staging --fork-from main\`${tiers === 3 ? " and `--name dev --fork-from staging`" : ""}.`;
14069
+ warnings.push(m);
14070
+ report(`WARNING: ${m}`);
14071
+ } else if (tiers === 2 || tiers === 3) {
13899
14072
  report(`Cutting staging tier (tiers=${tiers}) via createLongRunningBranch...`);
13900
14073
  try {
13901
14074
  await createLongRunningBranch({
@@ -13946,7 +14119,7 @@ Last probe error:
13946
14119
  warnings
13947
14120
  };
13948
14121
  }
13949
- // end withLakebaseRollback closure
14122
+ // end withCreateRollback closure
13950
14123
  );
13951
14124
  }
13952
14125
 
@@ -18744,6 +18917,7 @@ export {
18744
18917
  catalogExists,
18745
18918
  catalogExplorerUrl,
18746
18919
  checkDatabricksAuth,
18920
+ checkGitHubPreflight,
18747
18921
  checkGitHubWorkflowScope,
18748
18922
  checkoutPaired,
18749
18923
  claimFeatureBranch,
@@ -18757,6 +18931,7 @@ export {
18757
18931
  createPairedBranch,
18758
18932
  createPerfPairedBranch,
18759
18933
  createProject,
18934
+ createRollbackLedger,
18760
18935
  createTestPairedBranch,
18761
18936
  createUatPairedBranch,
18762
18937
  cutBackup,
@@ -18926,6 +19101,7 @@ export {
18926
19101
  waitForBranchReady,
18927
19102
  waitForCi,
18928
19103
  warmAndVerifyKit,
19104
+ withCreateRollback,
18929
19105
  withLakebaseRollback,
18930
19106
  workflowStateFileExists,
18931
19107
  writeEnvFile,
@@ -79290,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79290
79290
  var cached;
79291
79291
  function substrateSelfVersion() {
79292
79292
  if (cached !== void 0) return cached;
79293
- if ("0.3.10".length > 0) {
79294
- cached = "0.3.10";
79293
+ if ("0.3.11".length > 0) {
79294
+ cached = "0.3.11";
79295
79295
  return cached;
79296
79296
  }
79297
79297
  cached = "unknown";
@@ -393,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
393
393
  var cached;
394
394
  function substrateSelfVersion() {
395
395
  if (cached !== void 0) return cached;
396
- if ("0.3.10".length > 0) {
397
- cached = "0.3.10";
396
+ if ("0.3.11".length > 0) {
397
+ cached = "0.3.11";
398
398
  return cached;
399
399
  }
400
400
  cached = "unknown";
@@ -79290,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79290
79290
  var cached;
79291
79291
  function substrateSelfVersion() {
79292
79292
  if (cached !== void 0) return cached;
79293
- if ("0.3.10".length > 0) {
79294
- cached = "0.3.10";
79293
+ if ("0.3.11".length > 0) {
79294
+ cached = "0.3.11";
79295
79295
  return cached;
79296
79296
  }
79297
79297
  cached = "unknown";
@@ -393,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
393
393
  var cached;
394
394
  function substrateSelfVersion() {
395
395
  if (cached !== void 0) return cached;
396
- if ("0.3.10".length > 0) {
397
- cached = "0.3.10";
396
+ if ("0.3.11".length > 0) {
397
+ cached = "0.3.11";
398
398
  return cached;
399
399
  }
400
400
  cached = "unknown";
@@ -79288,8 +79288,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79288
79288
  var cached;
79289
79289
  function substrateSelfVersion() {
79290
79290
  if (cached !== void 0) return cached;
79291
- if ("0.3.10".length > 0) {
79292
- cached = "0.3.10";
79291
+ if ("0.3.11".length > 0) {
79292
+ cached = "0.3.11";
79293
79293
  return cached;
79294
79294
  }
79295
79295
  cached = "unknown";
@@ -389,8 +389,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
389
389
  var cached;
390
390
  function substrateSelfVersion() {
391
391
  if (cached !== void 0) return cached;
392
- if ("0.3.10".length > 0) {
393
- cached = "0.3.10";
392
+ if ("0.3.11".length > 0) {
393
+ cached = "0.3.11";
394
394
  return cached;
395
395
  }
396
396
  cached = "unknown";
@@ -79324,8 +79324,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79324
79324
  var cached;
79325
79325
  function substrateSelfVersion() {
79326
79326
  if (cached !== void 0) return cached;
79327
- if ("0.3.10".length > 0) {
79328
- cached = "0.3.10";
79327
+ if ("0.3.11".length > 0) {
79328
+ cached = "0.3.11";
79329
79329
  return cached;
79330
79330
  }
79331
79331
  cached = "unknown";