11import vercelTokenAuth from "../../vercel_token_auth.app.mjs" ;
2+ import { ConfigurationError } from "@pipedream/platform" ;
23
34export default {
45 key : "vercel_token_auth-create-deployment" ,
@@ -27,18 +28,9 @@ export default {
2728 teamId : c . team ,
2829 } ) ,
2930 ] ,
30- description : "The target project identifier in which the deployment will be created. When defined, this parameter overrides name" ,
31- } ,
32- repoId : {
33- type : "string" ,
34- label : "Git Source Repository Id" ,
35- description : "Id of the source repository" ,
36- } ,
37- branch : {
38- type : "string" ,
39- label : "Branch" ,
40- description : "Branch of repository to deploy to" ,
41- default : "main" ,
31+ description : "The target project identifier in which the deployment will be created" ,
32+ optional : false ,
33+ reloadProps : true ,
4234 } ,
4335 public : {
4436 type : "boolean" ,
@@ -47,33 +39,49 @@ export default {
4739 optional : true ,
4840 } ,
4941 } ,
42+ async additionalProps ( ) {
43+ const props = { } ;
44+
45+ if ( ! this . project ) {
46+ return props ;
47+ }
48+
49+ props . branch = {
50+ type : "string" ,
51+ label : "Branch" ,
52+ description : "Branch of repository to deploy to" ,
53+ default : "main" ,
54+ } ;
55+
56+ try {
57+ const { link } = await this . vercelTokenAuth . getProject ( this . project ) ;
58+ if ( link ) {
59+ props . branch . description = `Branch of \`${ link . repo } \` repository to deploye to` ;
60+ props . branch . default = link ?. productionBranch || "main" ;
61+ }
62+ return props ;
63+ } catch {
64+ return props ;
65+ }
66+ } ,
5067 async run ( { $ } ) {
68+ const { link } = await this . vercelTokenAuth . getProject ( this . project , $ ) ;
69+ if ( ! link ?. repoId ) {
70+ throw new ConfigurationError ( `No linked repository found for project with ID: ${ this . project } ` ) ;
71+ }
72+ const repoId = link . repoId ;
73+
5174 const data = {
5275 name : this . name ,
5376 project : this . project ,
5477 teamId : this . team ,
5578 public : this . public ,
5679 gitSource : {
5780 type : "github" ,
58- repoId : this . repoId ,
81+ repoId,
5982 ref : this . branch ,
6083 } ,
6184 } ;
62- if ( ! this . project ) { // projectSettings required if project is not specified
63- data . projectSettings = {
64- buildCommand : null ,
65- commandForIgnoringBuildStep : null ,
66- devCommand : null ,
67- framework : null ,
68- installCommand : null ,
69- nodeVersion : "22.x" ,
70- outputDirectory : null ,
71- rootDirectory : null ,
72- serverlessFunctionRegion : null ,
73- skipGitConnectDuringLink : true ,
74- sourceFilesOutsideRootDirectory : true ,
75- } ;
76- }
7785 const res = await this . vercelTokenAuth . createDeployment ( data , $ ) ;
7886 $ . export ( "$summary" , "Successfully created new deployment" ) ;
7987 return res ;
0 commit comments