Skip to content

Commit

Permalink
[ENG-7179] rename component.config.ts and app.config.ts to convex.con…
Browse files Browse the repository at this point in the history
…fig.ts (#29011)

GitOrigin-RevId: e93454c888c772d60fabcbef1fe8c1c8ec7f5769
  • Loading branch information
ldanilek authored and Convex, Inc. committed Aug 21, 2024
1 parent 009322a commit d25cba2
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion crates/database/src/bootstrap_model/user_facing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
));
},
}
Expand Down
12 changes: 6 additions & 6 deletions crates/isolate/src/environment/component_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComponentDefinitionPath, ComponentDefinitionMetadata>,
/// 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<BTreeMap<EnvVarName, EnvVarValue>>,
/// System env vars are allowed everywhere.
system_env_vars: BTreeMap<EnvVarName, EnvVarValue>,
Expand Down Expand Up @@ -487,8 +487,8 @@ impl<RT: Runtime> IsolateEnvironment<RT> 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.",
))
}

Expand Down
4 changes: 2 additions & 2 deletions crates/model/src/components/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleConfig>,
// Dependencies on other components discovered at bundling time.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions npm-packages/component-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) },
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions npm-packages/convex/src/cli/lib/components/constants.ts
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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 ||
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -81,7 +82,8 @@ export async function buildComponentDirectory(
ctx: Context,
definitionPath: string,
): Promise<ComponentDirectory> {
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),
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/convex/src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const run = new Command("run")
.addOption(
new Option(
"--component-path <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(),
)
Expand Down
4 changes: 2 additions & 2 deletions npm-packages/convex/src/server/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -134,7 +134,7 @@ type ComponentDefinitionExports<T extends ComponentDefinition<any, any>> =

/**
* 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
*/
Expand Down

0 comments on commit d25cba2

Please sign in to comment.