Skip to content

Commit e2a619d

Browse files
committed
fix: build script now works on MacOS
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
1 parent 26f4888 commit e2a619d

3 files changed

Lines changed: 35 additions & 23 deletions

File tree

pkg/cli/commands.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ func RemoveWorkflows(pattern string, keepOrphans bool) error {
11781178
lockFile := strings.TrimSuffix(file, ".md") + ".lock.yml"
11791179
if _, err := os.Stat(lockFile); err == nil {
11801180
if err := os.Remove(lockFile); err != nil {
1181-
fmt.Println(console.FormatWarningMessage("Failed to remove %s: %v", lockFile, err)
1181+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to remove %s: %v", lockFile, err)))
11821182
} else {
11831183
fmt.Printf("Removed: %s", filepath.Base(lockFile))
11841184
}
@@ -1188,7 +1188,7 @@ func RemoveWorkflows(pattern string, keepOrphans bool) error {
11881188
// Clean up orphaned include files (if orphan removal is enabled)
11891189
if len(removedFiles) > 0 && !keepOrphans {
11901190
if err := cleanupOrphanedIncludes(false); err != nil {
1191-
fmt.Println(console.FormatWarningMessage("Failed to clean up orphaned includes: %v", err)
1191+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to clean up orphaned includes: %v", err)))
11921192
}
11931193
}
11941194

@@ -1248,7 +1248,7 @@ func StatusWorkflows(pattern string, verbose bool) error {
12481248
if verbose {
12491249
fmt.Printf("Verbose: Failed to fetch GitHub workflows: %v", err)
12501250
}
1251-
fmt.Println(console.FormatWarningMessage("Could not fetch GitHub workflow status: %v", err)
1251+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not fetch GitHub workflow status: %v", err)))
12521252
githubWorkflows = make(map[string]*GitHubWorkflow)
12531253
} else if verbose {
12541254
fmt.Printf("Successfully fetched %d GitHub workflows", len(githubWorkflows))
@@ -1636,7 +1636,7 @@ func collectIncludesRecursive(content, baseDir, workflowsDir string, dependencie
16361636
includedDir := filepath.Dir(fullSourcePath)
16371637
if err := collectIncludesRecursive(markdownContent, includedDir, workflowsDir, dependencies, seen); err != nil {
16381638
// Log error but continue processing other includes
1639-
fmt.Println(console.FormatWarningMessage("Error processing includes in %s: %v", fullSourcePath, err)
1639+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Error processing includes in %s: %v", fullSourcePath, err)))
16401640
}
16411641
}
16421642
}
@@ -1667,7 +1667,7 @@ func copyIncludeDependenciesWithForce(dependencies []IncludeDependency, githubWo
16671667
fmt.Printf("Optional include file not found: %s (you can create this file to configure the workflow)", dep.TargetPath)
16681668
continue
16691669
}
1670-
fmt.Println(console.FormatWarningMessage("Failed to read include file %s: %v", dep.SourcePath, err)
1670+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to read include file %s: %v", dep.SourcePath, err)))
16711671
continue
16721672
}
16731673

@@ -1977,7 +1977,7 @@ func findWorkflowInPackages(workflowPath string, verbose bool) ([]byte, *Workflo
19771977
packagesDir, err := getPackagesDir(local)
19781978
if err != nil {
19791979
if verbose {
1980-
fmt.Println(console.FormatWarningMessage("Failed to get packages directory (local=%v): %v", local, err)
1980+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to get packages directory (local=%v): %v", local, err)))
19811981
}
19821982
continue
19831983
}
@@ -2217,7 +2217,7 @@ func collectPackageIncludesRecursive(content, baseDir string, dependencies *[]In
22172217
includedContent, err := os.ReadFile(fullSourcePath)
22182218
if err != nil {
22192219
if verbose {
2220-
fmt.Println(console.FormatWarningMessage("Could not read include file %s: %v", fullSourcePath, err)
2220+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not read include file %s: %v", fullSourcePath, err)))
22212221
}
22222222
continue
22232223
}
@@ -2226,7 +2226,7 @@ func collectPackageIncludesRecursive(content, baseDir string, dependencies *[]In
22262226
markdownContent, err := parser.ExtractMarkdownContent(string(includedContent))
22272227
if err != nil {
22282228
if verbose {
2229-
fmt.Println(console.FormatWarningMessage("Could not extract markdown from %s: %v", fullSourcePath, err)
2229+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not extract markdown from %s: %v", fullSourcePath, err)))
22302230
}
22312231
continue
22322232
}
@@ -2235,7 +2235,7 @@ func collectPackageIncludesRecursive(content, baseDir string, dependencies *[]In
22352235
includedDir := filepath.Dir(fullSourcePath)
22362236
if err := collectPackageIncludesRecursive(markdownContent, includedDir, dependencies, seen, verbose); err != nil {
22372237
if verbose {
2238-
fmt.Println(console.FormatWarningMessage("Error processing includes in %s: %v", fullSourcePath, err)
2238+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Error processing includes in %s: %v", fullSourcePath, err)))
22392239
}
22402240
}
22412241
}
@@ -2275,7 +2275,7 @@ func copyIncludeDependenciesFromPackageWithForce(dependencies []IncludeDependenc
22752275
}
22762276
continue
22772277
}
2278-
fmt.Println(console.FormatWarningMessage("Failed to read include file %s: %v", dep.SourcePath, err)
2278+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to read include file %s: %v", dep.SourcePath, err)))
22792279
continue
22802280
}
22812281

@@ -2343,7 +2343,7 @@ func cleanupOrphanedIncludes(verbose bool) error {
23432343
content, err := os.ReadFile(mdFile)
23442344
if err != nil {
23452345
if verbose {
2346-
fmt.Println(console.FormatWarningMessage("Could not read %s for include analysis: %v", mdFile, err)
2346+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not read %s for include analysis: %v", mdFile, err)))
23472347
}
23482348
continue
23492349
}
@@ -2352,7 +2352,7 @@ func cleanupOrphanedIncludes(verbose bool) error {
23522352
includes, err := findIncludesInContent(string(content), filepath.Dir(mdFile), verbose)
23532353
if err != nil {
23542354
if verbose {
2355-
fmt.Println(console.FormatWarningMessage("Could not analyze includes in %s: %v", mdFile, err)
2355+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not analyze includes in %s: %v", mdFile, err)))
23562356
}
23572357
continue
23582358
}
@@ -2399,7 +2399,7 @@ func cleanupOrphanedIncludes(verbose bool) error {
23992399
includePath := filepath.Join(workflowsDir, include)
24002400
if err := os.Remove(includePath); err != nil {
24012401
if verbose {
2402-
fmt.Println(console.FormatWarningMessage("Failed to remove orphaned include %s: %v", include, err)
2402+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to remove orphaned include %s: %v", include, err)))
24032403
}
24042404
} else {
24052405
fmt.Printf("Removed orphaned include: %s", include)
@@ -2444,7 +2444,7 @@ func previewOrphanedIncludes(filesToRemove []string, verbose bool) ([]string, er
24442444
content, err := os.ReadFile(mdFile)
24452445
if err != nil {
24462446
if verbose {
2447-
fmt.Println(console.FormatWarningMessage("Could not read %s for include analysis: %v", mdFile, err)
2447+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not read %s for include analysis: %v", mdFile, err)))
24482448
}
24492449
continue
24502450
}
@@ -2453,7 +2453,7 @@ func previewOrphanedIncludes(filesToRemove []string, verbose bool) ([]string, er
24532453
includes, err := findIncludesInContent(string(content), filepath.Dir(mdFile), verbose)
24542454
if err != nil {
24552455
if verbose {
2456-
fmt.Println(console.FormatWarningMessage("Could not analyze includes in %s: %v", mdFile, err)
2456+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not analyze includes in %s: %v", mdFile, err)))
24572457
}
24582458
continue
24592459
}
@@ -2525,7 +2525,7 @@ func cleanupAllIncludes(verbose bool) error {
25252525
if strings.Contains(relPath, string(filepath.Separator)) {
25262526
if err := os.Remove(path); err != nil {
25272527
if verbose {
2528-
fmt.Println(console.FormatWarningMessage("Failed to remove include %s: %v", relPath, err)
2528+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to remove include %s: %v", relPath, err)))
25292529
}
25302530
} else {
25312531
fmt.Printf("Removed include: %s", relPath)
@@ -2578,7 +2578,7 @@ func listPackageWorkflows(verbose bool) error {
25782578
packagesDir, err := getPackagesDir(local)
25792579
if err != nil {
25802580
if verbose {
2581-
fmt.Println(console.FormatWarningMessage("Failed to get packages directory (local=%v): %v", local, err)
2581+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to get packages directory (local=%v): %v", local, err)))
25822582
}
25832583
continue
25842584
}
@@ -2603,7 +2603,7 @@ func listPackageWorkflows(verbose bool) error {
26032603
packages, err := findInstalledPackages(packagesDir)
26042604
if err != nil {
26052605
if verbose {
2606-
fmt.Println(console.FormatWarningMessage("Failed to scan %s packages: %v", locationName, err)
2606+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to scan %s packages: %v", locationName, err)))
26072607
}
26082608
continue
26092609
}
@@ -2734,7 +2734,7 @@ func resolveWorkflowFile(fileOrWorkflowName string, verbose bool) (string, error
27342734

27352735
defer func() {
27362736
if err := os.Remove(tmpFile.Name()); err != nil && verbose {
2737-
fmt.Println(console.FormatWarningMessage("Failed to clean up temporary file %s: %v", tmpFile.Name(), err)
2737+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to clean up temporary file %s: %v", tmpFile.Name(), err)))
27382738
}
27392739
}()
27402740

@@ -2788,7 +2788,7 @@ func RunWorkflowOnGitHub(workflowIdOrName string, enable bool, verbose bool) err
27882788
workflow, err := getWorkflowStatus(workflowIdOrName, verbose)
27892789
if err != nil {
27902790
if verbose {
2791-
fmt.Println(console.FormatWarningMessage("Could not check workflow status: %v", err)
2791+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not check workflow status: %v", err)))
27922792
}
27932793
}
27942794

@@ -3024,7 +3024,7 @@ func findMatchingLockFile(workflowName string, verbose bool) string {
30243024
lockFiles, err := filepath.Glob(filepath.Join(workflowsDir, "*.lock.yml"))
30253025
if err != nil {
30263026
if verbose {
3027-
fmt.Println(console.FormatWarningMessage("Failed to search for lock files: %v", err)
3027+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to search for lock files: %v", err)))
30283028
}
30293029
return ""
30303030
}
@@ -3198,7 +3198,7 @@ func getLatestWorkflowRunWithTimestamp(lockFileName string, verbose bool) (strin
31983198
if parsedTime, err := time.Parse(time.RFC3339, run.CreatedAt); err == nil {
31993199
createdAt = parsedTime
32003200
} else if verbose {
3201-
fmt.Println(console.FormatWarningMessage("Could not parse creation time '%s': %v", run.CreatedAt, err)
3201+
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not parse creation time '%s': %v", run.CreatedAt, err)))
32023202
}
32033203
}
32043204

pkg/workflow/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"scripts": {
1818
"typecheck": "tsc --noEmit",
19-
"compile": "tsc --project tsconfig.build.json && sed -i 's/^export {};$//' *.js && prettier --write '*.js'",
19+
"compile": "tsc --project tsconfig.build.json && node remove-export.js && prettier --write '*.js'",
2020
"test": "npm run typecheck && vitest run",
2121
"test:js": "vitest run",
2222
"test:js-watch": "vitest",

pkg/workflow/js/remove-export.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)