diff --git a/crates/database/src/bootstrap_model/user_facing.rs b/crates/database/src/bootstrap_model/user_facing.rs index b7d73f00..54349710 100644 --- a/crates/database/src/bootstrap_model/user_facing.rs +++ b/crates/database/src/bootstrap_model/user_facing.rs @@ -166,7 +166,7 @@ impl<'a, RT: Runtime> UserFacingModel<'a, RT> { anyhow::bail!(ErrorMetadata::bad_request( "UnmountedComponent", "Cannot perform write operations in an unmounted component. Make sure \ - your component is installed in your `app.config.ts` file.", + your component is installed in your `convex.config.ts` file.", )); }, } diff --git a/crates/isolate/src/environment/component_definitions.rs b/crates/isolate/src/environment/component_definitions.rs index 5fc35a16..d1f45955 100644 --- a/crates/isolate/src/environment/component_definitions.rs +++ b/crates/isolate/src/environment/component_definitions.rs @@ -437,16 +437,16 @@ impl ComponentInitializerEvaluator { } } -const COMPONENT_CONFIG_FILE_NAME: &str = "component.config.js"; -const APP_CONFIG_FILE_NAME: &str = "app.config.js"; +const COMPONENT_CONFIG_FILE_NAME: &str = "convex.config.js"; +const APP_CONFIG_FILE_NAME: &str = "convex.config.js"; struct DefinitionEnvironment { expected_filename: String, source: FullModuleSource, evaluated_definitions: BTreeMap, - /// Environment variables are allowed in app.config.ts but not in - /// component.config.ts + /// Environment variables are allowed in app but not in + /// component config. environment_variables: Option>, /// System env vars are allowed everywhere. system_env_vars: BTreeMap, @@ -487,8 +487,8 @@ impl IsolateEnvironment for DefinitionEnvironment { .map(|env_vars| env_vars.get(&name).cloned()) .context(ErrorMetadata::bad_request( "EnvironmentVariablesUnsupported", - "Environment variables not supported in component.config.ts. Consider passing \ - them into your component via arguments in app.config.ts.", + "Environment variables not supported in the component's convex.config.ts. \ + Consider passing them into your component via arguments.", )) } diff --git a/crates/model/src/components/types.rs b/crates/model/src/components/types.rs index 6a17c3cd..574f0d6b 100644 --- a/crates/model/src/components/types.rs +++ b/crates/model/src/components/types.rs @@ -46,7 +46,7 @@ pub struct ProjectConfig { #[derive(Debug)] pub struct AppDefinitionConfig { - // Bundled `app.config.js` if present, with dependencies on other components marked external + // Bundled `convex.config.js` if present, with dependencies on other components marked external // and unresolved. Not available at runtime. pub definition: Option, // Dependencies on other components discovered at bundling time. @@ -80,7 +80,7 @@ pub struct ComponentDefinitionConfig { // Relative path from the root `convex/` directory to the component's directory. pub definition_path: ComponentDefinitionPath, - // Bundled component definition at `component.config.js` with dependencies on other components + // Bundled component definition at `convex.config.js` with dependencies on other components // unresolved. pub definition: ModuleConfig, // Dependencies on other components discovered at bundling time. diff --git a/npm-packages/component-tests/README.md b/npm-packages/component-tests/README.md index 7a92dab8..8c288ea4 100644 --- a/npm-packages/component-tests/README.md +++ b/npm-packages/component-tests/README.md @@ -15,8 +15,8 @@ directory in this directory. To test a new component layout, 1. Add a project to the `projects` directory. The project should have a `convex` - folder inside and `app.config.ts` (If your test does not use components, use - `udf-tests`). + folder inside and `convex.config.ts` (If your test does not use components, + use `udf-tests`). 2. Add the project to `COMPONENT_TESTS_LAYOUTS` in `isolate/build.rs. 3. Add the project to `rush.json` and `rush.oss.json`. 4. Run `just rush update` and `just update-oss-js`. @@ -26,4 +26,4 @@ To test a new component layout, To test a new component, add the component to this directory (`component-tests`) and `COMPONENTS` in `isolate/build.rs`. Use it in a project in the `projects` -directory by installing it in the project's `app.config.ts`. +directory by installing it in the project's `convex.config.ts`. diff --git a/npm-packages/component-tests/component/component.config.ts b/npm-packages/component-tests/component/convex.config.ts similarity index 100% rename from npm-packages/component-tests/component/component.config.ts rename to npm-packages/component-tests/component/convex.config.ts diff --git a/npm-packages/component-tests/envVars/component.config.ts b/npm-packages/component-tests/envVars/convex.config.ts similarity index 88% rename from npm-packages/component-tests/envVars/component.config.ts rename to npm-packages/component-tests/envVars/convex.config.ts index bf78d5a7..5bfa3aa4 100644 --- a/npm-packages/component-tests/envVars/component.config.ts +++ b/npm-packages/component-tests/envVars/convex.config.ts @@ -2,7 +2,7 @@ // @ts-ignore import { defineComponent } from "convex/server"; import { v } from "convex/values"; -import { default as otherComponent } from "../component/component.config"; +import { default as otherComponent } from "../component/convex.config"; const component = defineComponent("envVars", { args: { name: v.optional(v.string()), url: v.optional(v.string()) }, diff --git a/npm-packages/component-tests/errors/component.config.ts b/npm-packages/component-tests/errors/convex.config.ts similarity index 100% rename from npm-packages/component-tests/errors/component.config.ts rename to npm-packages/component-tests/errors/convex.config.ts diff --git a/npm-packages/component-tests/projects/basic/convex/app.config.ts b/npm-packages/component-tests/projects/basic/convex/convex.config.ts similarity index 77% rename from npm-packages/component-tests/projects/basic/convex/app.config.ts rename to npm-packages/component-tests/projects/basic/convex/convex.config.ts index 6303755f..85289f2a 100644 --- a/npm-packages/component-tests/projects/basic/convex/app.config.ts +++ b/npm-packages/component-tests/projects/basic/convex/convex.config.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { defineApp } from "convex/server"; -import envVars from "../../../envVars/component.config"; -import errors from "../../../errors/component.config"; +import envVars from "../../../envVars/convex.config"; +import errors from "../../../errors/convex.config"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore diff --git a/npm-packages/component-tests/projects/empty/convex/app.config.ts b/npm-packages/component-tests/projects/empty/convex/convex.config.ts similarity index 100% rename from npm-packages/component-tests/projects/empty/convex/app.config.ts rename to npm-packages/component-tests/projects/empty/convex/convex.config.ts diff --git a/npm-packages/component-tests/projects/mounted/convex/app.config.ts b/npm-packages/component-tests/projects/mounted/convex/convex.config.ts similarity index 77% rename from npm-packages/component-tests/projects/mounted/convex/app.config.ts rename to npm-packages/component-tests/projects/mounted/convex/convex.config.ts index ac833fb2..3f34dc54 100644 --- a/npm-packages/component-tests/projects/mounted/convex/app.config.ts +++ b/npm-packages/component-tests/projects/mounted/convex/convex.config.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { defineApp } from "convex/server"; -import component from "../../../component/component.config"; -import envVars from "../../../envVars/component.config"; +import component from "../../../component/convex.config"; +import envVars from "../../../envVars/convex.config"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore diff --git a/npm-packages/component-tests/projects/with-schema/convex/app.config.ts b/npm-packages/component-tests/projects/with-schema/convex/convex.config.ts similarity index 84% rename from npm-packages/component-tests/projects/with-schema/convex/app.config.ts rename to npm-packages/component-tests/projects/with-schema/convex/convex.config.ts index 38997ba5..dbfaf574 100644 --- a/npm-packages/component-tests/projects/with-schema/convex/app.config.ts +++ b/npm-packages/component-tests/projects/with-schema/convex/convex.config.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { defineApp } from "convex/server"; -import component from "../../../component/component.config"; +import component from "../../../component/convex.config"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore diff --git a/npm-packages/convex/src/cli/lib/components/constants.ts b/npm-packages/convex/src/cli/lib/components/constants.ts index 9232a901..16e6c3e3 100644 --- a/npm-packages/convex/src/cli/lib/components/constants.ts +++ b/npm-packages/convex/src/cli/lib/components/constants.ts @@ -1,2 +1,2 @@ -export const ROOT_DEFINITION_FILENAME = "app.config.ts"; -export const DEFINITION_FILENAME = "component.config.ts"; +export const ROOT_DEFINITION_FILENAME = "convex.config.ts"; +export const DEFINITION_FILENAME = "convex.config.ts"; diff --git a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts index c07b8bf4..1e71864a 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts @@ -54,8 +54,8 @@ function componentPlugin({ name: `convex-${mode === "discover" ? "discover-components" : "bundle-components"}`, async setup(build) { // This regex can't be really precise since developers could import - // "component.config", "component.config.js", "component.config.ts", etc. - build.onResolve({ filter: /.*component.config.*/ }, async (args) => { + // "convex.config", "convex.config.js", "convex.config.ts", etc. + build.onResolve({ filter: /.*convex.config.*/ }, async (args) => { verbose && logMessage(ctx, "esbuild resolving import:", args); if (args.namespace !== "file") { verbose && logMessage(ctx, " Not a file."); @@ -570,8 +570,7 @@ async function registerEsbuildReads( for (const [relPath, input] of Object.entries(metafile.inputs)) { if ( // We rewrite these files so this integrity check isn't useful. - path.basename(relPath).includes("app.config") || - path.basename(relPath).includes("component.config") || + path.basename(relPath).includes("convex.config") || // TODO: esbuild outputs paths prefixed with "(disabled)" when bundling our internal // udf-system package. The files do actually exist locally, though. relPath.indexOf("(disabled):") !== -1 || diff --git a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts index 2e7d23cf..98492ef0 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts @@ -1,6 +1,7 @@ import path from "path"; import { Context } from "../../../../bundler/context.js"; import { DEFINITION_FILENAME, ROOT_DEFINITION_FILENAME } from "../constants.js"; +import { getFunctionsDirectoryPath } from "../../config.js"; /** * A component definition's location on the local filesystem, @@ -11,7 +12,7 @@ import { DEFINITION_FILENAME, ROOT_DEFINITION_FILENAME } from "../constants.js"; * understood from their symlink location. * * None of these properties are the import string, which might have been an unqualifed import - * (e.g. 'convex-waitlist' instead of '../node_modules/convex-waitlist/component.config.ts') + * (e.g. 'convex-waitlist' instead of '../node_modules/convex-waitlist/convex.config.ts') */ export type ComponentDirectory = { isRoot: boolean; @@ -81,7 +82,8 @@ export async function buildComponentDirectory( ctx: Context, definitionPath: string, ): Promise { - const isRoot = path.basename(definitionPath) === ROOT_DEFINITION_FILENAME; + const convexDir = path.resolve(await getFunctionsDirectoryPath(ctx)); + const isRoot = path.dirname(path.resolve(definitionPath)) === convexDir; const isComponent = isComponentDirectory( ctx, path.dirname(definitionPath), diff --git a/npm-packages/convex/src/cli/run.ts b/npm-packages/convex/src/cli/run.ts index ec989e84..10aee609 100644 --- a/npm-packages/convex/src/cli/run.ts +++ b/npm-packages/convex/src/cli/run.ts @@ -44,7 +44,7 @@ export const run = new Command("run") .addOption( new Option( "--component-path ", - "Path to the component in the component tree defined in app.config.ts", + "Path to the component in the component tree defined in convex.config.ts", // TODO(ENG-6967): Remove hideHelp before launching components ).hideHelp(), ) diff --git a/npm-packages/convex/src/server/components/index.ts b/npm-packages/convex/src/server/components/index.ts index 0d523f8a..511e0190 100644 --- a/npm-packages/convex/src/server/components/index.ts +++ b/npm-packages/convex/src/server/components/index.ts @@ -72,7 +72,7 @@ export interface InitCtx {} /** * An object of this type should be the default export of a - * component.config.ts file in a component definition directory. + * convex.config.ts file in a component definition directory. * * @internal */ // eslint-disable-next-line @typescript-eslint/ban-types @@ -134,7 +134,7 @@ type ComponentDefinitionExports> = /** * An object of this type should be the default export of a - * app.config.ts file in a component definition directory. + * convex.config.ts file in a component-aware convex directory. * * @internal */