-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Configuring workflows #36
Comments
Tried to play with it. I can launch the terminal from an Alfred workflow but the working directory is just set to |
Maybe the idea of exposing a binary as part of your workflow (in case you want configuration) isn't that hacky after all.
Another possibility is to let the developer pick a keyword like |
Oh, this just popped in my mind and might actually be the best approach. The user provides the app with /**
* alfred-git config file
*/
{
// GitHub API Key
"apiKey": ""
}
When installing the workflow, it will call Somehow (not sure how yet), with a command (either Alfred or cli), it should be possible to open the config file again if you want to make changes. This doesn't require some tools like |
I like the above solution of just using a simple config file. Can use
Probably easiest to just expose a CLI binary. |
Looking into this. I guess it will be difficult to keep the comments in the config file. The reason is that I want to perform a merge if the workflow gets updated. Let me clarify with an example. This is the /**
* alfred-git config file
*/
{
// GitHub API Key
"apiKey": "abcd"
} This gets copied over to the config directory and the user fills in the API key like this. /**
* alfred-git config file
*/
{
// GitHub API Key
"apiKey": "abcd"
} The workflow gets updated, and a new config property was added. /**
* alfred-git config file
*/
{
// GitHub API Key
"apiKey": "",
// GitHub username
"username": ""
} I can't just overwrite the config file in the config directory as the user already set the API key. This means I will have to merge both config files and write the result of that merge. (Merging also means removing properties that where removed with the updated workflow). So after the merge, the result should be this. /**
* alfred-git config file
*/
{
// GitHub API Key
"apiKey": "abcd",
// GitHub username
"username": ""
} But I believe it's quite hard to parse the JSON file without removing the comments ( The question we could ask is, should we preserve comments? I believe we do because it could clarify the settings. Not sure how we can accomplish this though. |
I thought about this for a while and if we just use a flattened object, we might get away with simple regex expressions to do the merge. VS Code also has a flattened object and supports comments. {
"editor.insertSpaces": false,
"editor.scrollBeyondLastLine": false,
"editor.formatOnType": true,
"editor.renderIndentGuides": true,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.acceptSuggestionOnEnter": false
} Or we could just start without support for comments and use something like |
Maybe we could use this: https://github.com/hjson/hjson-js#modify--keep-comments ? |
Sweet! Will look into that. Already started working on something so I hope I could do a PR this week. Would make possibilities with Alfred endless... |
I'm creating a separate package that handles all this stuff. Feedback for a name of the package?
The |
We could allow a user to create a configure.js script which could use Inquirer.js or something to ask questions to the user. In the git or we could just start without support for comments and use something like Object.assign() or deep-assign to do the merge. Although if we would support nested objects, this might prevent us from implementing the above in the future. |
This comment has been minimized.
This comment has been minimized.
@issuehunt has funded $80.00 to this issue.
|
@issuehunt has funded $20.00 to this issue.
|
I'm trying to pick this one up again :). But give me some time to get back at it :). |
If anyone wants to work on this, see the initial attempt and feedback in #113. |
@sindresorhus has rewarded $90.00 to @samverschueren. See it on IssueHunt
|
So, a couple of weeks back I thought we could make much more powerfull workflows if there was a way to configure them individually per user.
For instance, if someone creates a git workflow, the user installing that workflow should be able to put an API key somewhere. It's very dirty if he needs to change the workflow in that visual workflow editor and put the API key somewhere.
I have a couple of ideas for this, not sure if all that easy to do.
Configure script
We could allow a user to create a
configure.js
script which could use Inquirer.js or something to ask questions to the user. In thegit
workflow example for instance, either we create a new activation keyword, for instanceconfigure-git
which opens the terminal and executesconfigure.js
. Orgit configure
for instance.The name of that script could be set via
package.json
Configure questions
A second approach would be easier to add for the user. This would allow someone to define the questions in
package.json
and will store them in the config of the workflow. This way, in your workflow, you could just grab them from the config.The first option offers the most flexibility in terms of the package you use to ask your questions (although 2 would offer more consistency).
The second one would definitely be easier for the developer, though less flexible. This would also mean every workflow is packaged with
Inquirer.js
, not sure how "heavy" it is. Although, it might be an idea to extract this in a separate package calledalfy-configure
and keep this the core. Something likealfy-test
.IssueHunt Summary
Backers (Total: $100.00)
Submitted pull Requests
Tips
The text was updated successfully, but these errors were encountered: