question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Additional actions

See original GitHub issue

2.1.0 brings the concept of actions — see #28.

So far we have clone and remove. I can think of a few others that might be useful:

  • rename — for moving files out of the way to prevent them being clobbered by clone
  • replace — for replacing placeholder stuff in particular files, such as this TODO. Would need to come after a…
  • prompt — get some user input. terkelg/prompts has some nice conventions we could adopt.

So you could do this sort of thing:

[
  {
    "action": "prompt",
    "questions": [
      { "type": "text", "name": "name", "message": "What is the project name?" }
    ]
  },
  {
    "action": "replace",
    "delimiters": ["<<", ">>"],
    "values": ["name"],
    "files": ["package.json"]
  }
]

then if you had a package.json like

{
  "name": "<<name>>",
  ...
}

it would get filled in. Not fully baked (maybe the replace action should run in the context of the prompt?) but you get the idea. cc @mhkeller if you have thoughts

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
gustavnikolajcommented, Feb 1, 2019

I have made a project scaffolding project that I use all the time when I need to test something quickly. It contains the set of tools that I find myself always copying around anyway. It’s already really useful, but I’ve had to include a self removing script into it, to do the bootstrapping. It can be seen here: https://github.com/gustavnikolaj/template-node

That means that I have to run it like so:

$ npx degit gustavnikolaj/template-node <targetDir> && node bootstrap.js

All I do in that script is to run some actions that execute npm commands to configure test and linting tools etc. As an example; I don’t want to depend on a fixed version of say eslint, so instead of including it in a package.json file in the degit source repo, I run a command at install time that installs the latest version of it.

The same thing goes for package.json - if I include it in the repo, I’d have to go in and update it after setting it up - but running npm init -y in my bootstrap script does the right thing (picking information about the writer from git config, and picking the name of the package from the folder).

The obvious way of integrating this behavior would be to allow an action type that allowed the module to include such a boostrap script.

I understand why you might not want to allow arbitrary command execution, but maybe it would be okay if we required the user to answer y/N in a prompt before execution.

Another solution could be to add an action that would allow you to execute commands in the context of the directory.

[
    {
        "action": "shell",
        "shell": "git init"
    },
    {
        "action": "shell",
        "shell": "npm init -y"
    },
    {
        "action": "shell",
        "shell": "npm install --save-dev eslint ..."
    }
]

That would cover most of my use cases. I would also like a way to transform files after the fact though. Something that would allow me to define a script target in the package.json file that got created after running the npm init shell command.

I don’t know how to do that with declarative actions, but maybe someone else has an idea? 😃

I’m happy to contribute PRs for any of these features if we can reach something that would work for us. I use my template project enough to justify improving it a little, and removing some of the ugly hacks 😃

1reaction
loreanvictorcommented, May 20, 2022

I was in need of this for rapidly creating some packages, so I made a wrapper over degit for this purpose specifically. it doesn’t have the “exec” action proposed here to avoid the security issues mentioned, thought it might be useful to some other people checking this thread (like me).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Additional action | Final Fantasy Wiki - Fandom
Additional actions, colloquially known as cross-class skills, are abilities in Final Fantasy XIV. They are abilities that can be used by multiple ...
Read more >
Import additional actions into Automator on Mac - Apple Support
Copy the action or actions you want to add to your Mac. Open Automator. Open Automator for me. Choose File > Import Actions....
Read more >
Viewsets - Django REST framework
Routing additional HTTP methods for extra actions. Extra actions can map additional HTTP methods to separate ViewSet methods. For example, the above password ......
Read more >
How to set up 'Additional Actions' and 'Also request for' list on ...
Procedure · Navigate to any page with "SC Order Status" widget. · Press Control key + Right Click to get service portal menu....
Read more >
Extra Actions - FireGiant
Extra Actions ; ScheduleReboot After · 'InstallFinalize' /> ; ScheduleReboot After · 'InstallFinalize'>Version9X</ScheduleReboot> ; Custom Action · 'LaunchFile' After ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found