Skip to content

Commit 0c77fb5

Browse files
jordanhunt22Convex, Inc.
authored andcommitted
[Components] Remove the non-components push path (#42972)
We put out a release ~2 weeks ago that moved all customers to the new push path. The rollout has gone smoothly, so we can delete the old path now. We will only have to maintain one path now! GitOrigin-RevId: 62a1841a97cfd5005da6176f774986ae402b93ff
1 parent f6f4b0c commit 0c77fb5

File tree

9 files changed

+35
-778
lines changed

9 files changed

+35
-778
lines changed

npm-packages/convex/src/cli/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
isNonProdBuildEnvironment,
1212
suggestedEnvVarName,
1313
} from "./lib/envvars.js";
14-
import { PushOptions } from "./lib/push.js";
14+
import { PushOptions } from "./lib/components.js";
1515
import {
1616
CONVEX_DEPLOY_KEY_ENV_VAR_NAME,
1717
CONVEX_SELF_HOSTED_URL_VAR_NAME,

npm-packages/convex/src/cli/lib/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
rootComponentApiCJS,
4444
} from "../codegen_templates/component_api.js";
4545
import { functionsDir } from "./utils/utils.js";
46-
import { LargeIndexDeletionCheck } from "./push.js";
46+
import { LargeIndexDeletionCheck } from "./indexes.js";
4747

4848
export type CodegenOptions = {
4949
url?: string | undefined;

npm-packages/convex/src/cli/lib/components.ts

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ import {
2121
waitForSchema,
2222
} from "./deploy2.js";
2323
import { version } from "../version.js";
24-
import {
25-
LargeIndexDeletionCheck,
26-
PushOptions,
27-
runNonComponentsPush,
28-
} from "./push.js";
2924
import { ensureHasConvexDependency, functionsDir } from "./utils/utils.js";
3025
import {
3126
bundleDefinitions,
@@ -55,27 +50,30 @@ import {
5550
} from "./api.js";
5651
import { FinishPushDiff } from "./deployApi/finishPush.js";
5752
import { Reporter, Span } from "./tracing.js";
58-
import {
59-
DEFINITION_FILENAME_JS,
60-
DEFINITION_FILENAME_TS,
61-
} from "./components/constants.js";
53+
import { DEFINITION_FILENAME_TS } from "./components/constants.js";
6254
import { DeploymentSelection } from "./deploymentSelection.js";
6355
import { deploymentDashboardUrlPage } from "./dashboard.js";
64-
import { formatIndex } from "./indexes.js";
56+
import { formatIndex, LargeIndexDeletionCheck } from "./indexes.js";
6557
import { checkForLargeIndexDeletion } from "./checkForLargeIndexDeletion.js";
66-
67-
async function findComponentRootPath(ctx: Context, functionsDir: string) {
68-
// Default to `.ts` but fallback to `.js` if not present.
69-
let componentRootPath = path.resolve(
70-
path.join(functionsDir, DEFINITION_FILENAME_TS),
71-
);
72-
if (!ctx.fs.exists(componentRootPath)) {
73-
componentRootPath = path.resolve(
74-
path.join(functionsDir, DEFINITION_FILENAME_JS),
75-
);
76-
}
77-
return componentRootPath;
78-
}
58+
import { LogManager } from "./logs.js";
59+
60+
export type PushOptions = {
61+
adminKey: string;
62+
verbose: boolean;
63+
dryRun: boolean;
64+
typecheck: "enable" | "try" | "disable";
65+
typecheckComponents: boolean;
66+
debug: boolean;
67+
debugBundlePath?: string | undefined;
68+
debugNodeApis: boolean;
69+
codegen: boolean;
70+
url: string;
71+
deploymentName: string | null;
72+
writePushRequest?: string | undefined;
73+
liveComponentSources: boolean;
74+
logManager?: LogManager | undefined;
75+
largeIndexDeletionCheck: LargeIndexDeletionCheck;
76+
};
7977

8078
export async function runCodegen(
8179
ctx: Context,
@@ -88,23 +86,14 @@ export async function runCodegen(
8886
const { configPath, projectConfig } = await readProjectConfig(ctx);
8987
const functionsDirectoryPath = functionsDir(configPath, projectConfig);
9088

91-
const componentRootPath = await findComponentRootPath(
92-
ctx,
93-
functionsDirectoryPath,
94-
);
95-
9689
if (options.init) {
9790
await doInitCodegen(ctx, functionsDirectoryPath, false, {
9891
dryRun: options.dryRun,
9992
debug: options.debug,
10093
});
10194
}
10295

103-
if (
104-
(ctx.fs.exists(componentRootPath) ||
105-
process.env.USE_LEGACY_PUSH === undefined) &&
106-
!options.systemUdfs
107-
) {
96+
if (!options.systemUdfs) {
10897
// Early exit for a better error message trying to use a preview key.
10998
if (deploymentSelection.kind === "preview") {
11099
return await ctx.crash({
@@ -155,16 +144,7 @@ export async function runCodegen(
155144

156145
export async function runPush(ctx: Context, options: PushOptions) {
157146
const { configPath, projectConfig } = await readProjectConfig(ctx);
158-
const convexDir = functionsDir(configPath, projectConfig);
159-
const componentRootPath = await findComponentRootPath(ctx, convexDir);
160-
if (
161-
!ctx.fs.exists(componentRootPath) &&
162-
process.env.USE_LEGACY_PUSH !== undefined
163-
) {
164-
await runNonComponentsPush(ctx, options, configPath, projectConfig);
165-
} else {
166-
await runComponentsPush(ctx, options, configPath, projectConfig);
167-
}
147+
await runComponentsPush(ctx, options, configPath, projectConfig);
168148
}
169149

170150
async function startComponentsPushAndCodegen(

npm-packages/convex/src/cli/lib/config.ts

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import {
3232
currentPackageHomepage,
3333
} from "./utils/utils.js";
3434
import { createHash } from "crypto";
35-
import { promisify } from "util";
36-
import zlib from "zlib";
3735
import { recursivelyDelete } from "./fsUtils.js";
3836
import { NodeDependency } from "./deployApi/modules.js";
3937
import { ComponentDefinitionPath } from "./components/definition/directoryStructure.js";
@@ -45,8 +43,6 @@ import { debugIsolateBundlesSerially } from "../../bundler/debugBundle.js";
4543
import { ensureWorkosEnvironmentProvisioned } from "./workos/workos.js";
4644
export { productionProvisionHost, provisionHost } from "./utils/utils.js";
4745

48-
const brotli = promisify(zlib.brotliCompress);
49-
5046
/** Type representing auth configuration. */
5147
export interface AuthInfo {
5248
// Provider-specific application identifier. Corresponds to the `aud` field in an OIDC token.
@@ -801,114 +797,6 @@ export type AppDefinitionSpecWithoutImpls = Omit<
801797
"schema" | "functions" | "auth"
802798
>;
803799

804-
export function configJSON(
805-
config: Config,
806-
adminKey: string,
807-
schemaId?: string,
808-
pushMetrics?: PushMetrics,
809-
bundledModuleInfos?: BundledModuleInfo[],
810-
) {
811-
// Override origin with the url
812-
const projectConfig = {
813-
projectSlug: config.projectConfig.project,
814-
teamSlug: config.projectConfig.team,
815-
functions: config.projectConfig.functions,
816-
authInfo: config.projectConfig.authInfo,
817-
};
818-
return {
819-
config: projectConfig,
820-
modules: config.modules,
821-
nodeDependencies: config.nodeDependencies,
822-
udfServerVersion: config.udfServerVersion,
823-
schemaId,
824-
adminKey,
825-
pushMetrics,
826-
bundledModuleInfos,
827-
nodeVersion: config.nodeVersion,
828-
};
829-
}
830-
831-
// Time in seconds of various spans of time during a push.
832-
export type PushMetrics = {
833-
typecheck: number;
834-
bundle: number;
835-
schemaPush: number;
836-
codePull: number;
837-
totalBeforePush: number;
838-
};
839-
840-
/** Push configuration to the given remote origin. */
841-
export async function pushConfig(
842-
ctx: Context,
843-
config: Config,
844-
options: {
845-
adminKey: string;
846-
url: string;
847-
deploymentName: string | null;
848-
pushMetrics?: PushMetrics | undefined;
849-
schemaId?: string | undefined;
850-
bundledModuleInfos?: BundledModuleInfo[];
851-
},
852-
): Promise<void> {
853-
const serializedConfig = configJSON(
854-
config,
855-
options.adminKey,
856-
options.schemaId,
857-
options.pushMetrics,
858-
options.bundledModuleInfos,
859-
);
860-
const fetch = deploymentFetch(ctx, {
861-
deploymentUrl: options.url,
862-
adminKey: options.adminKey,
863-
});
864-
try {
865-
if (config.nodeDependencies.length > 0) {
866-
changeSpinner(
867-
"Installing external packages and deploying source code...",
868-
);
869-
} else {
870-
changeSpinner("Analyzing and deploying source code...");
871-
}
872-
await fetch("/api/push_config", {
873-
body: await brotli(JSON.stringify(serializedConfig), {
874-
params: {
875-
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
876-
[zlib.constants.BROTLI_PARAM_QUALITY]: 4,
877-
},
878-
}),
879-
method: "POST",
880-
headers: {
881-
"Content-Type": "application/json",
882-
"Content-Encoding": "br",
883-
},
884-
});
885-
} catch (error: unknown) {
886-
await handlePushConfigError(
887-
ctx,
888-
error,
889-
"Error: Unable to push deployment config to " + options.url,
890-
options.deploymentName,
891-
{
892-
adminKey: options.adminKey,
893-
deploymentUrl: options.url,
894-
deploymentNotice: "",
895-
},
896-
);
897-
}
898-
}
899-
900-
type Files = { source: string; filename: string }[];
901-
902-
export type CodegenResponse =
903-
| {
904-
success: true;
905-
files: Files;
906-
}
907-
| {
908-
success: false;
909-
error: string;
910-
};
911-
912800
function renderModule(module: {
913801
path: string;
914802
sourceMapSize: number;

npm-packages/convex/src/cli/lib/deploy2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { finishPushDiff, FinishPushDiff } from "./deployApi/finishPush.js";
2727
import { Reporter, Span } from "./tracing.js";
2828
import { promisify } from "node:util";
2929
import zlib from "node:zlib";
30-
import { PushOptions } from "./push.js";
30+
import { PushOptions } from "./components.js";
3131
import { runPush } from "./components.js";
3232
import { suggestedEnvVarName } from "./envvars.js";
3333
import { runSystemQuery } from "./run.js";

npm-packages/convex/src/cli/lib/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { runPush } from "./components.js";
1313
import { performance } from "perf_hooks";
1414
import path from "path";
1515
import { LogManager, LogMode, watchLogs } from "./logs.js";
16-
import { PushOptions } from "./push.js";
16+
import { PushOptions } from "./components.js";
1717
import {
1818
formatDuration,
1919
getCurrentTimeString,

npm-packages/convex/src/cli/lib/indexes.test.ts

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,7 @@
11
import { describe, test, expect } from "vitest";
2-
import {
3-
IndexMetadata,
4-
toDeveloperIndexConfig,
5-
formatIndex,
6-
} from "./indexes.js";
72
import { DeveloperIndexConfig } from "./deployApi/finishPush.js";
83
import chalk from "chalk";
9-
10-
describe("toDeveloperIndexConfig", () => {
11-
test("converts database IndexMetadata to DeveloperIndexConfig", () => {
12-
const databaseIndex: IndexMetadata = {
13-
table: "messages",
14-
name: "by_user_and_timestamp",
15-
fields: ["userId", "timestamp"],
16-
backfill: {
17-
state: "done",
18-
},
19-
staged: false,
20-
};
21-
22-
const result = toDeveloperIndexConfig(databaseIndex);
23-
24-
expect(result).toEqual({
25-
type: "database",
26-
name: "messages.by_user_and_timestamp",
27-
fields: ["userId", "timestamp"],
28-
staged: false,
29-
});
30-
});
31-
32-
test("converts text search IndexMetadata to DeveloperIndexConfig", () => {
33-
const searchIndex: IndexMetadata = {
34-
table: "articles",
35-
name: "search_by_content",
36-
fields: {
37-
searchField: "content",
38-
filterFields: ["category", "status"],
39-
},
40-
backfill: {
41-
state: "done",
42-
},
43-
staged: false,
44-
};
45-
46-
const result = toDeveloperIndexConfig(searchIndex);
47-
48-
expect(result).toEqual({
49-
type: "search",
50-
name: "articles.search_by_content",
51-
searchField: "content",
52-
filterFields: ["category", "status"],
53-
staged: false,
54-
});
55-
});
56-
57-
test("converts vector search IndexMetadata to DeveloperIndexConfig", () => {
58-
const vectorIndex: IndexMetadata = {
59-
table: "documents",
60-
name: "embedding_index",
61-
fields: {
62-
dimensions: 1536,
63-
vectorField: "embedding",
64-
filterFields: ["userId", "type"],
65-
},
66-
backfill: {
67-
state: "done",
68-
},
69-
staged: true,
70-
};
71-
72-
const result = toDeveloperIndexConfig(vectorIndex);
73-
74-
expect(result).toEqual({
75-
type: "vector",
76-
name: "documents.embedding_index",
77-
dimensions: 1536,
78-
vectorField: "embedding",
79-
filterFields: ["userId", "type"],
80-
staged: true,
81-
});
82-
});
83-
});
4+
import { formatIndex } from "./indexes.js";
845

856
describe("formatIndex", () => {
867
test("formats database index with multiple fields", () => {

0 commit comments

Comments
 (0)