chore: use endpointId if it exists in package.json (#200)
* chore: use endpointId if package.json has it * minor * add changeset * chore: include changeset * chore: add proper summary to changeset * chore: remove redundant changeset file
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/cli": patch
|
||||
---
|
||||
|
||||
allow trigger CLI init command to use endpointId if it is present in package.json
|
||||
@@ -19,9 +19,8 @@ import { renderTitle } from "../utils/renderTitle.js";
|
||||
import { detectNextJsProject } from "../utils/detectNextJsProject.js";
|
||||
import { TriggerApi, WhoamiResponse } from "../utils/triggerApi.js";
|
||||
import { readFile } from "tsconfig";
|
||||
import { pathExists } from "../utils/fileSystem.js";
|
||||
import { pathToFileURL } from 'url'
|
||||
|
||||
import { pathExists, readJSONFile } from "../utils/fileSystem.js";
|
||||
import { pathToFileURL } from "url";
|
||||
|
||||
export type InitCommandOptions = {
|
||||
projectPath: string;
|
||||
@@ -197,6 +196,19 @@ const resolveOptionsWithPrompts = async (
|
||||
}
|
||||
|
||||
if (!options.endpointSlug) {
|
||||
const packageJSONPath = pathModule.join(path, "package.json");
|
||||
const packageJSON = await readJSONFile(packageJSONPath);
|
||||
|
||||
if (
|
||||
packageJSON &&
|
||||
packageJSON["trigger.dev"] &&
|
||||
packageJSON["trigger.dev"].endpointId
|
||||
) {
|
||||
options.endpointSlug = packageJSON["trigger.dev"].endpointId;
|
||||
} else {
|
||||
options.endpointSlug = await promptEndpointSlug(path);
|
||||
}
|
||||
|
||||
resolvedOptions.endpointSlug = await promptEndpointSlug(path);
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user