10

More specifically, I want every new SFDX project to include a ".scripts/" directory, populated with pre-written scripts (for deployments, data transformation, whatever).

Another use-case could be pre-set data-load scripts and files.

How do I do that? Mod some config files? Add a JavaScript or PowerShell On-Load/On-Complete hook?

1
  • So now there is a ./scripts directory created by default in sfdx projects.. nice. To populate it, i think i'll just write a powershell function and invoke it manually from within the project after creating it, to add the scripts I want. Commented Jun 6, 2020 at 19:11

2 Answers 2

1

There is a promising -t TEMPLATE parameter to the sfdx force:project:create command, but it only supports two pre-defined values, standard and empty. There doesn't seem to be a way to build and pass custom templates.

I think it would be simplest to wrap the sfdx command in a shell script that passes parameters through and then does the additional work you want to do. You could also explore creating a CLI plugin.

0

I also wanted to accomplish this task. I just looked through the source code of sfdx, and it is relatively easy to understand. If you look at the repo on github here: forcedotcom/salesforcedx-templates

You can see that src/generators/projectGenerator.ts has the code for generating out the files and folder structure when you create a new template. The files included are hard coded - but I don't think it would be difficult to create a new template based on the standard one that would include more files that you want.

You would just have to do some compiling yourself (not familiar enough on whether you could do this in a plugin, or whether you would have to compile the whole sfdx yourself each time a new version comes out).

So in short - one possibility to do this is to modify the sfdx code yourself - but that seems like the effort involved might not be worth having to recompile it for each new version. That sounds like a lot of effort.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .