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:
alubọsa
2023-07-25 13:27:35 +01:00
committed by GitHub
parent ba03a9ed20
commit 27a9812194
2 changed files with 20 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/cli": patch
---
allow trigger CLI init command to use endpointId if it is present in package.json
+15 -3
View File
@@ -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) {