@@ -13,10 +13,12 @@ import * as fs from "../../util/fs.js";
1313import * as http from "node:http" ;
1414import { URL } from "node:url" ;
1515import open from "open" ;
16+ import { execSync } from "child_process" ;
17+ import path from "path" ;
1618
1719import { ciStr } from "../../util/ci.js" ;
1820import { getProjectsByOrgReq , sendMapRepoAndFinishProjectCreationReq , sendCreateProjectReq , sendGetRepoIdReq } from "../../util/graphql.js" ;
19- import { confirmExistingProjectLink , confirmOverwriteCiHypFile , fileExists , getCiHypFilePath , getSettingsFilePath , getGitConfigFilePath , getGitRemoteUrl , getGithubWorkflowDir , promptProjectLinkSelection , promptProjectName , readSettingsJson , writeGithubInstallationIdToSettingsFile } from "../../util/index.js" ;
21+ import { confirmExistingProjectLink , confirmOverwriteCiHypFile , fileExists , getCiHypFilePath , getSettingsFilePath , getGitConfigFilePath , getGitRemoteUrl , getGithubWorkflowDir , promptProjectLinkSelection , promptProjectName , readSettingsJson , writeGithubInstallationIdToSettingsFile , hasGitRemoteUrl } from "../../util/index.js" ;
2022
2123export default class LinkIndex extends Command {
2224 static override args = { } ;
@@ -109,6 +111,20 @@ export default class LinkIndex extends Command {
109111 throw new Error ( chalk . red ( "No .git found in this directory. Please initialize a git repository with `git init`." ) ) ;
110112 }
111113
114+ const hasRemoteOrigin = await hasGitRemoteUrl ( gitConfigFilePath ) ;
115+
116+ if ( ! hasRemoteOrigin ) {
117+ this . log ( chalk . red ( "`hyp link` requires a git remote to work" ) ) ;
118+ const gitRoot = execSync ( "git rev-parse --show-toplevel" , { encoding : "utf-8" } ) . trim ( ) ;
119+ const projectName = path . basename ( gitRoot ) ;
120+ this . log ( `Please create a GitHub repository: https://github.com/new?name=${ projectName } ` ) ;
121+ this . log ( `And push your code:` ) ;
122+ this . log ( `> git remote add origin <GIT_URL>` ) ;
123+ this . log ( `> git push -u origin main` ) ;
124+
125+ return ;
126+ }
127+
112128 const gitUrl = await getGitRemoteUrl ( gitConfigFilePath ) ;
113129
114130 // check the .hypermode/settings.json and see if there is a installationId with a key for the github owner. if there is,
0 commit comments