- useful go utility functions
- utils.GetItemsInFolder now has just one argument for convenience
- added FilterArray which makes it more convenient to filter an array given an array and predicate(condition function)
- added methods that would cast the interface to the appropriate type
- made a slight change
- added index to element
- added FilterMapByKeys all the respective casting fns
- added func OverwriteMap which is like js Object.assign
- added func OverwriteMap which is like js Object.assign
- replaced FilterMapByKeys with FilterMap where its predicate fn accepts key,val
- added FilterJSONByPredicate
- added WriteCustomFormattedJSONToFile to help format files
- WriteCustomFormattedJSONToFile supports bytes and interface strcutures, added UnicodeUnquote which will remove all unicode from a string when writing from bytes to a file,
- added AddContentToEachLineInFile AddContentToFile, which takes a predicate function and updates the file based on the return of the predicate fn
- added MergeDirectories fn which would merge all files and folders from target dir into source dir w/o overrting anything
- added RunCommandWithOptions fn which supports optional target dir,optional get output, and panic on error
- added TraverseDirectory with a predicate fn
- added TruncateStringByRegex fn which allows the end user to provide a regex and has a predicate fn for every match in the pattern matcher which if returns true removes the substr from the array
- additional updates
- added cli and changed name to go_cli_scripts
- updated RunCommandWithOptions to print out standard err along with the reason why the command failed
- indicated all RunCommand fns are deprecated and RunCommandWithOptions should be used instead
- added ProcessFoldersMatchingPattern just like ProcessFilesMatchingPattern
added CreateStringObject an object that will give all sorts of cases camelCase kebab snakeCase classify
- fixied CreateStringObject
added IsRunningInDocker to see whether the given go script is running in a docker container or not
- [PATCH] updated GetInputFromStdin and ShowMenu to immediately cancel when the user hits Ctrl+C
- [PATCH] build mechanism seems to unexpectedly add unwanted code this patch should fix that
- [PATCH] fixed issue with RunCommandWithOptions where output gets returned from the program and printed to console
- added Uppercase method to CreateStringObjectType
- [PATCH] IsRunningInDocker will able to detect for macbooks as well
- [UPDATE] added ProxyURLs string
json:"proxyURLs"
for the VSCodeSettings.ExtensionPack struct
- [BREAKING CHANGE] TakeVariableArgs returns TakeVariableArgsResultStruct
type TakeVariableArgsResultStruct struct{
inputString string
inputArray []string
}
-
added github_utils and
-
file_utils FindExecutable GetSourceFilePath ExtractArchive DownloadFile
-
string_utils ContainsAny
methods
- [MAJOR UPDATE] finally got RunCommandWithOptions to work as intended stdout prints to terminal in addition to returning output from the inner running program to the main program
- [UPDATE] added PrintOutput to CommandOptions to optionally prevent output from getting to the command line
- [UPDATE] added PrintOutputOnly to CommandOptions by default stdOut. returns the final value of the program to the outer command running it and prints output to the command line, because of edge case this was added to only print output to the command line for convience sake
- [UPDATE] added TasksToRunOnFolderOpen for the vscode extension
-
[NEW FEATURE] Enhanced
WatchDirectory
function for dynamic directory monitoring with advanced filtering options.type WatchDirectoryParams struct { DirectoryToWatch string DebounceInMs int Predicate func(event fsnotify.Event) StartOnWatch bool IncludePatterns []string ExcludePatterns []string }
- The
WatchDirectory
function now includes parameters for include and exclude patterns using glob strings, allowing for more precise monitoring of directory changes. - Added
StartOnWatch
boolean parameter to immediately invoke the predicate function on the existing files in the directory at the start. - The include and exclude patterns are compiled using
CompileGlobs
and checked against each file event usingMatchAnyGlob
.
- The
-
[UPDATE]
CommandOptions
struct enhancements for process control.type CommandOptions struct { // ... existing fields ... CmdObj *exec.Cmd NonBlocking bool } func (c CommandOptions) EndProcess() error { return c.CmdObj.Process.Kill() }
- Enhanced
CommandOptions
to includeCmdObj
for direct process handling andNonBlocking
boolean for asynchronous command execution. - Added
EndProcess
method to facilitate immediate termination of the process associated withCmdObj
.
- Enhanced
- [UPDATE] - added ShowMenuMultiple to allow the user to select multiple options along with SelectionLimit int SelectedValues []string SelectedDelimiter string properties
- [UPDATE] - added RemoveContentFromFile function
- [FIX] - fixed EndProcess command to leverage the pointer to Self on the options.CommandOptions struct via the Self property
- you the developer have to provide the self property in order for EndProcess to find the command and kill it effectively
[PATCH] - fixed issue with EndProcess where it would kill the process but hang in the function it was called
- a glitch allows this fix to be found in 4.4.1
- [UPDATE] - added RemoveElementsNotInSource ArrayContainsAny array fns
- [UPDATE] - updated CDToLocation to accept a createIfNotExist parameter (2 argument)
- [UPDATE] - Added a new task "major update project" in .vscode/tasks.json.
- [FEATURE] - Introduced a new utility file docker-utils.go with a function to check if running inside Docker.
- [PATCH] - Updated vscode_settings_utils.go to use yaml.Unmarshal instead of json.Unmarshal.
- [REMOVE] - Removed redundant IsRunningInDocker function from vscode_settings_utils.go.
- [UPDATE] - Added a new dependency github.com/tailscale/hujson in go.mod and updated go.sum accordingly.
- [FEATURE] - Introduced a new function StandardizeJSON in utils/json_utils.go using hujson to standardize JSON input.
- [FIX] - Modified GetSettingsJSON in utils/vscode_settings_utils.go to use StandardizeJSON for processing input before unmarshalling.
- [REMOVE] - Removed the dependency github.com/tailscale/hujson from go.mod.
- [UPDATE] - Updated go.sum to reflect changes in dependencies.
- [UPDATE] - Modified the StandardizeJSON function in utils/json_utils.go to RemoveComments, which now removes line and block comments from JSON strings.
- [UPDATE] - Updated GetSettingsJSON in utils/vscode_settings_utils.go to use RemoveComments instead of StandardizeJSON for processing input before unmarshalling.
- [FIX] - Added error handling in RemoveComments to check for JSON validity after removing comments.
[REMOVE] output.txt
and scratchpad.go
files were deleted. The output.txt
file contained various utility functions and scratchpad.go
included main package content with file operations.
[UPDATE] copy_utils.go
and file_utils.go
in the utils
directory were updated. In copy_utils.go
, comments were removed, and error handling was improved for directory copying logic. In file_utils.go
, a new function FilterFilesByExtension
was added to filter files based on their extensions.
[UPDATE] Made a big change in the README file. It's now an overview of what the go_cli_scripts package does instead of a changelog. [BREAKING CHANGE] In cd_utils.go, tweaked the path in CDToWorkspaceRoot to go up three levels instead of four. Just a small path correction. [FIX] In file_utils.go, corrected a message that was supposed to say "Error writing to file" instead of "Error reading from file". Also added two new handy functions: RemovePathPrefix (gets rid of the start of a path) and EnsureDirAndCreateFile (makes sure a folder exists before creating a file in it).
-
[UPDATE] We've added a new
environments
array in theWindmillcodeExtensionPack
in your settings. This is in thevscode_settings_utils.go
file. It's like a new list where you can keep track of different settings for various environments you work in. Also addedsentryDSN
-
[FIX] Squashed a tiny bug in
file_utils.go
! Now, when you're filtering files, it won't ignore the ones with_test.dart
at the end. This means all your Dart files get the attention they deserve, even the test ones!
[UPDATE] Added FlutterMobileBuild struct with new settings to WindmillcodeExtensionPack. Now it includes args, toolArgs, and vmAdditionalArgs for configuring Flutter mobile builds. Check out vscode_settings_utils.go to see the changes.
[UPDATE] Yo! We just added a sweet new function FindRelativeToTarget in array_utils.go. It helps you find a string in an array that's right before or after the one you're looking for. Pretty handy, huh?
[UPDATE] Heads up! The RunCommand function in stdio_utils.go is no longer deprecated. Use it if you need a shorter version of run command wit hoptions
[UPDATE] Check this out! We’ve beefed up our string tools in string_utils.go. Now you can turn your strings into kebab-case with the new KebabCase method in CreateStringObjectType. Keep your strings looking sharp!
[UPDATE] Yo! We just beefed up our FlutterMobileBuild struct in the vscode_settings_utils.go file. Now it includes fields for PlayStoreServiceAccountKey, PackageName, PublishTarget, and TrackName. If you're working on publishing to the Play Store, these new fields will help configure things right from your code!
[UPDATE] Extended programming language support in WindmillcodeExtensionPack within utils/vscode_settings_utils.go. Added new fields for NodeJS, Java, Go, Ruby, Dart, CSharp, Swift, PHP, Rust, Kotlin, Scala, Perl, Lua, Haskell, Clojure, Erlang, Julia, ObjectiveC, FSharp, VisualBasic versions. This update will require developers to adjust any related configurations that depend on these language version settings.
[UPDATE] Removed commented-out code from examples/fast_immutable_collections.go
, examples/flutter_translate.go
, examples/go_cli_scripts_create_output.go
, examples/json_serilizable_create_output.go
, and examples/webview_flutter.go
. The unnecessary comments are gone, making the files cleaner and easier to read.
[UPDATE] Cleaned up examples/output.md
by removing all irrelevant, offensive, and unnecessary content. The file is now streamlined and professional.
[FIX] Fixed error handling in utils/vscode_settings_utils.go
by replacing fmt.Println
with LogErrorWithTraceBack
in the GetSettingsJSON
function. This ensures better logging and error tracking.
[UPDATE] Added LogErrorWithTraceBack
function in utils/common_utils.go
to log errors with traceback information. This new function helps in debugging by providing detailed error logs.
[PATCH] Changed the Filter
function in examples/webview_flutter.go
to remove redundant spaces and clean up the code.
[UPDATE] Added log
and runtime/debug
imports in utils/common_utils.go
for enhanced error logging.
[BUG] Fixed the file reading and JSON unmarshalling errors in GetSettingsJSON
by adding detailed logging in utils/vscode_settings_utils.go
. Now it logs errors with traceback for easier debugging.
[PATCH] utils/file_utils.go: Added ReadLines function to read lines from a file into a map.
[UPDATE] -added so users can specifiy their own paths
type GitPushingWorkToGitRemoteStruct struct {
RelativePaths []string `json:"relativePaths"`
AbsolutePaths []string `json:"absolutePaths"`
}
[6/5/2024 10:34:22 AM EST]
[UPDATE] Added utility functions in stdio_utils.go
and string_utils.go
to enhance command execution and argument handling.
File: utils/stdio_utils.go
- Function Added:
RunElevatedCommand
- Description: Run commands with elevated privileges (admin/sudo) based on the OS.
- Developer Impact: Now you can easily execute commands that need admin privileges without writing additional code.
File: utils/string_utils.go
- Function Added:
JoinArgs
- Description: Joins command arguments into a single string suitable for command-line execution.
- Developer Impact: Simplifies the process of formatting arguments for command-line execution, particularly useful for the new
RunElevatedCommand
function.
[UPDATE] Adjusted error handling in RunCommandWithOptions
to include detailed stderr output in case of failure.
File: utils/stdio_utils.go
- Function Modified:
RunCommandWithOptions
- Description: Now includes detailed standard error output in error messages.
- Developer Impact: Easier debugging and error tracing when commands fail.
[FIX] Refined JSON handling functions to remove comments and filter based on predicates.
File: utils/json_utils.go
- Functions Modified:
RemoveComments
FilterJSONByPredicate
- Developer Impact: Improved JSON processing capabilities, ensuring cleaner data and more flexible filtering options.
[7/9/2024 3:15:00 PM EST]
- Updated dependencies
7/25/2024 04:15:30 PM EST
[UPDATE] Added CDToShopifyApp function
- File: utils/cd_utils.go
- Function: CDToShopifyApp
- Details: Added a new function to change directory to the ShopifyApp location. Developers working with ShopifyApp can now easily navigate using this function.
[UPDATE]
Added FindElement
function to utils/array_utils.go
- This function helps find an element in an array based on a predicate
- Returns index, element, and an error if the element is not found
7/28/2024 06:15:00 PM EST
Updated CHANGELOG.md
[ADDED] Added:
- CDToShopifyApp function to
utils/cd_utils.go
[UPDATED] Updated:
FindElement
function toutils/array_utils.go
- This function helps find an element in an array based on a predicate
- Returns index, element, and an error if the element is not found
Updated utils/array_utils.go
[ADDED] Added:
FindElement
function to find an element in an arrayRemoveDuplicates
function to remove duplicate elements from an array- New conditions to
ConvertToStringArray
to handle integer types
Updated utils/file_utils.go
[ADDED] Added:
ReadFileFromPackage
function to read a file from package directoryGetFilePathFromPackage
function to get the absolute path of a file in the package
Updated utils/stdio_utils.go
[ADDED] Added:
KillPorts
function to kill processes running on specified ports- Expanded
CommandOptions
struct to includeEnvVars
andIsElevated
[ADDED] Added:
IntToStr
function to convert an integer to a string
Updated utils/vscode_settings_utils.go
[ADDED]
-
WindmillcodeExtensionPack
struct to include new propertiesAdded: -
settings.WindmillcodeExtensionPack.FirebaseCloudRunEmulatorsStruct
for Firebase Cloud Run emulator settings -
settings.WindmillcodeExtensionPack.ProcessIfDefaultIsPresentStruct
to handle default process settings -
settings.WindmillcodeExtensionPack.WMLPorts
struct to define various ports -
New methods to
WMLPorts
to get Firebase ports
[7/29/2024 4:15:00 PM EST]
[UPDATE] Added nonInteractive
field to ShowMenuModel
and ShowMenuMultipleModel
structs in utils/show_menu.go
.
[PATCH] Modified ShowMenu
and ShowMenuMultipleOptions
functions in utils/show_menu.go
to use default choices in non-interactive mode.
[UPDATE] Added SetGlobalVarsOptions
struct and SetGlobalVars
function in utils/stdio_utils.go
for setting global variables.
[PATCH] Updated TakeVariableArgs
, GetInputFromStdin
, and other input functions in utils/stdio_utils.go
to handle non-interactive mode based on global variables.
[UPDATE] Added ShopifyRunStruct
to vscode_settings_utils.go
and included it in WindmillcodeExtensionPack
struct.
[PATCH] Updated FirebaseCloudRunEmulatorsStruct
in vscode_settings_utils.go
to include KillPortOutputFileAcceptDefault
field.
These changes improve handling of non-interactive modes across various functions and structs. Developers should now set global variables using SetGlobalVars
and can use defaults in non-interactive mode by leveraging these updates.
[UPDATE] Made some JSON fields optional in Firebas eConfig in main.go
[UPDATE]
- console log message optimizations
[UPDATE] Added a new function ParseJSONFromString[T any]
in utils/json_utils.go
. This function makes it easier to parse JSON strings into Go structs, and it includes error handling to catch JSON parsing issues. If you're working with JSON in Go, this is a handy new tool to use.
[UPDATE] Added a new function ParseJSONFromString[T any]
in utils/json_utils.go
. This function makes it easier to parse JSON strings into Go structs. It also handles errors when the JSON format is bad. If you're dealing with JSON in Go, this will save you time.
[UPDATE] Added a new function CDToWxtApp
in utils/cd_utils.go
. It changes the directory to the location of the WxtApp
. Use this when working with apps/extensions under the apps/extensions/WxtApp
path.
[UPDATE] Updated WindmillcodeExtensionPack
in utils/vscode_settings_utils.go
. Added two new fields:
WxtBuildSafari
: ContainsBundleIdentifier
for Safari builds.AngularDeployToFirebase
: Includes settings for deploying Angular apps to Firebase and Sentry.
AngularDeployToFirebase
has options like:
- RunLint: Run lint checks before deployment.
- RunSSGScript: Run the SSG script for static site generation.
- RemoveBuildDirectories: Clears old build folders.
- DeployToSentry: Pushes source maps to Sentry (requires
SentryOrg
,SentryProject
, andSentryAuthToken
). - DeployToFirebase: Deploys the app to Firebase.
If you're using these features, update your settings JSON to include these fields.
[UPDATE] AngularDeployToFirebase
has an additional option :
FirebaseProjectId string json:"firebaseProjectId"
to specify the firebase projec
[UPDATE]
Renamed RemoveComments
function to CleanJSON
in utils/json_utils.go
. It now:
- Removes comments (both
//
and/* */
). - Removes trailing commas from arrays and objects.
- Throws better error messages when the JSON is invalid.
[BREAKING CHANGE] Changed cd_utils.md
to rename CDToTestNGApp to CDToSeleniumApp for clarity. Updated the description to match the function's purpose.
[FIX] Renamed CDToTestNGApp
to CDToSeleniumApp
in cd_utils.go
. Updated the directory path to "apps/testing/SeleniumApp"
.
[FIX] Improved the TraverseDirectory
function in file_utils.go
to skip missing paths gracefully. Added a check for os.IsNotExist
errors and adjusted the behavior to print a message and continue processing.
[UPDATE] Added the ReplaceAllSubstrings
function in string_utils.go
. Developers can use this to replace all occurrences of a target substring in a string. It includes validation to ensure the target substring is not empty.
[PATCH] Enhanced the Capitalize
function in string_utils.go
to handle cases where the input string is empty. Returns only the suffix in such cases. Adjusted logic to properly capitalize the first letter of non-empty strings.
[UPDATE] Added omitempty
tags to multiple struct fields in vscode_settings_utils.go
for improved JSON serialization. This change reduces unnecessary fields in serialized outputs when values are empty.
[BUG] Fixed directory paths in testng_utils.go
to ensure compatibility with OS-specific formats. Updated the EnvVarsFile
and TestNGFolder
default paths using JoinAndConvertPathToOSFormat
.
[PATCH] Added a new struct MiscReinitializeProjectStruct
in vscode_settings_utils.go
to support reinitialization logic for projects. Includes fields like ProjectName
, OrganizationName
, and various platform-specific configuration options.
[UPDATE] Updated the go get
command in the README.md
file from v5
to v6
for the go_cli_scripts
package. If you're integrating the library, make sure to use the updated version v6
.
[UPDATE] Updated import statements in the README.md
file from v5
to v6
for the go_cli_scripts
package. Developers need to replace v5
with v6
in their imports.
[CHECKPOINT] Added a new function CDToReactNativeExpoApp
in utils/cd_utils.go
that lets you navigate to the React Native Expo app directory. If you're working on this project type, you can now use this utility function.
[PATCH] Introduced a new file utils/vscode_tasks_utils.go
that handles creating and reading tasks.json
for VSCode. If you're dealing with VSCode tasks, this file has utilities to help generate or read dynamic task configurations.
[BUG] Fixed an issue in utils/vscode_tasks_utils.go
where the CreateTasksJson
function might fail if the tasks.json
file didn’t exist. The function now creates the file if it’s missing. Developers can now safely use this utility without manually creating the file.
[UPDATE] Added a new function CDToLaravelApp
in utils/cd_utils.go
. It helps developers quickly change directories to the Laravel app folder at apps/backend/LaravelApp
. Super handy for Laravel developers.
[PATCH] Fixed ProxyURLs
in MiscReinitializeProjectStruct
in utils/vscode_settings_utils.go
. It will now always include ProxyURLs
, even if it’s empty. This ensures consistency for developers relying on this property during JSON handling.
[UPDATE]
Added two new properties MySQL0
, ReactNativeExpoRun0
, and LaravelRun0
to the WMLPorts
struct in utils/vscode_settings_utils.go
. Developers can now specify ports for MySQL, React Native Expo, and Laravel in their JSON configurations.
[CHECKPOINT] This update extends the WMLPorts struct to support more frameworks and services. Be sure to update any dependent JSON files to include these new properties if needed.
[UPDATE]
File: utils/stdio_utils.go
What changed: Added a new property ExitRegex
in the CommandOptions
struct.
Why it matters: Developers can now specify to decide when a process should be terminated
[UPDATE] Updated go.mod
to require Go version 1.23. This means you'll need Go 1.23 or newer to use this module. (Go)
[DEPRECATED] Added a note that ExtractArchive
function in utils/file_utils.go
is now deprecated. You should start using ExtractArchiveWithOptions
instead. (HashiCorp Developer)
[UPDATE] Introduced a new function ExtractArchiveWithOptions
in utils/file_utils.go
. This function gives you more flexibility when extracting archives.
[UPDATE] Added new structs NPMInstallAppDepsStruct
, NPMInstallSpecifcPackagesStruct
, PythonInstallAppDepsStruct
, and PythonInstallSpecifcPackagesStruct
to the file utils/vscode_settings_utils.go
. These structs handle app dependencies and package installations, giving developers more granular control over settings.
[UPDATE] Updated WindmillcodeExtensionPack
in utils/vscode_settings_utils.go
to include properties for managing PythonInstallAppDeps
, PythonInstallSpecifcPackages
, NPMInstallSpecifcPackages
, and NPMInstallAppDeps
. Developers now have fields to configure these in their settings.
[UPDATE] In GetSettingsJSON
function, added initialization for NodeJSAppLocations
and PythonAppLocations
if they are nil
. This ensures default paths are set for Node.js and Python apps when not provided, saving developers time in configuring paths manually.
[UPDATE] Added a new PascalCase
property to the CreateStringObjectType
struct in utils/string_utils.go
. Developers can now generate PascalCase strings using the CreateStringObject
function.
[UPDATE]
Added a new struct MiscTranslateJsonStruct
to vscode_settings_utils.go
. If you're dealing with translations, this struct is mapped in WindmillcodeExtensionPack
. Developers can now leverage MiscTranslateJson
for JSON translation features.