Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "splice into" feature for Javascript/Typescript #9

Open
ElonVolo opened this issue May 17, 2023 · 1 comment
Open

Add a "splice into" feature for Javascript/Typescript #9

ElonVolo opened this issue May 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ElonVolo
Copy link
Owner

Problem: once of the most common uses of codemods, at least for me, is to update data in configuration files that are written in Javascript/Typescript instead of in JSON. I want to have a way of updating these values in a way more reliable that regexes, but I don't want to have to crack open a text editor and write a brand new set of code just to change to settings in a file.

Solution: give evcodeshift the ability to act as a simple command line utility where you can use the shell to pass evcodeshift a property name and a string with javascript code, and evcodeshift will replace the value at that property name with the new bit of code.

Here's how I envision this feature working. Let's say we have a file named my_config_file.js with the following content

let myconfigData = 
{
    "mobileID": "23423",
    "environments": {
        "ios": {
            "provisioning_profiles": [
                "15613CEFSGA",
                "235613CEFSGA",
                "AE6116341454"
            ]
        },
        "android": "8675309D",
        "electron": "ABEEF26401"
    }
}

I'd like to run the following commands on the shell to change the values of "electron" and "provisioning_profiles"

evcodeshift --edit my_config_file.js "electron" "DECAFBAD" 
evcodeshift --edit my_config_file.js "provisioning_profiles" "[\"111111\", \"22222\", \"333333\"]"

The new content of my_config_file.js look something like

let myconfigData = 
{
    "mobileID": "23423",
    "environments": {
        "ios": {
            "provisioning_profiles": [
                "111111",
                "22222",
                "333333"]
            ]
        },
        "android": "8675309D",
        "electron": "DECAFBAD"
    }
}
@ElonVolo ElonVolo added the enhancement New feature or request label May 17, 2023
@ishaqibrahimbot
Copy link

Tracking the implementation of the above feature in this draft PR: #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants