@@ -149,6 +149,8 @@ function buildModuleDiffCommand(pkg, flags = "", tag = null) {
149149function moduleHasChangesSinceTag ( pkg ) : boolean | null {
150150 /** Check if a module has changes since the tag matching the current release */
151151 try {
152+ fetchTagIfNotExistsLocally ( pkg ) ;
153+
152154 execSync ( buildModuleDiffCommand ( pkg , "--exit-code" ) , { stdio : "ignore" } ) ;
153155 // if the command exits with 0, there are no changes
154156 return false ;
@@ -163,6 +165,27 @@ function moduleHasChangesSinceTag(pkg): boolean | null {
163165 }
164166}
165167
168+ function fetchTagIfNotExistsLocally ( pkg ) {
169+ /** Fetch the tag from the remote if it doesn't exist locally */
170+ const tag = moduleString ( pkg , "-v" ) ;
171+
172+ // Check if the tag exists locally
173+ const localTag = execSync ( `git tag --list ${ tag } ` ) . toString ( ) . trim ( ) ;
174+ if ( localTag !== "" ) {
175+ return ;
176+ }
177+
178+ const cmd = `git fetch origin tag ${ tag } --no-tags` ;
179+ try {
180+ execSync ( cmd , { stdio : "ignore" } ) ;
181+ } catch ( error ) {
182+ // If the tag doesn't exist, this will throw an error
183+ if ( error . status === 128 ) {
184+ console . log ( chalk . red ( `Tag ${ tag } does not exist on remote.` ) ) ;
185+ }
186+ }
187+ }
188+
166189function printChangeInfoForPublishedPackage ( pkg , showChanges = false ) {
167190 const cmd = buildModuleDiffCommand ( pkg ) ;
168191 console . log ( chalk . bold ( pkg . name ) , `has changes since v${ pkg . version } .` ) ;
@@ -175,6 +198,16 @@ function printChangeInfoForPublishedPackage(pkg, showChanges = false) {
175198
176199 console . log ( "Run the following command to see detailed changes:" ) ;
177200 console . log ( chalk . dim ( ">" ) , chalk . dim ( cmd ) ) ;
201+
202+ // Check if is synced with the remote
203+ // TODO: this only works if the current branch is pushed to the remote
204+ console . log ( "or view the changes in GitHub:" ) ;
205+ const repoUrl = "https://github.com/UW-Macrostrat/web-components" ;
206+ const tag = moduleString ( pkg , "-v" ) ;
207+ // Get head commit hash
208+ const headCommit = execSync ( "git rev-parse HEAD" ) . toString ( ) . trim ( ) ;
209+ const url = `${ repoUrl } /compare/${ tag } ...${ headCommit } ` ;
210+ console . log ( chalk . dim ( url ) ) ;
178211}
179212
180213/* checks for unstaged changes */
@@ -228,6 +261,9 @@ export async function checkIfPackageCanBePublished(
228261}
229262
230263function checkForChangelogEntry ( pkg : PackageData ) {
264+ /** Check whether the package has a changelog entry for the current version
265+ */
266+
231267 const dir = getPackageDirectory ( pkg . name ) ;
232268 const changelogPath = path . join ( dir , "CHANGELOG.md" ) ;
233269 const CHANGELOG = chalk . bold ( "CHANGELOG" ) ;
0 commit comments