google / clasp

🔗 Command Line Apps Script Projects
https://developers.google.com/apps-script/guides/clasp
Apache License 2.0
4.52k stars 422 forks source link

[RFC] (Re)create consistent GAS project for codebase: `remote create` (multi-developer workflow) #991

Open HoldYourWaffle opened 9 months ago

HoldYourWaffle commented 9 months ago

Depends on #989. For simplicity this proposal assumes it has been implemented.

To prevent ambiguity the term "project" in this proposal always refers to a Google Apps Script (GAS) project and "codebase" is used for a local project code folder/repository.

In most multi-developer workflows each developer has their own personal testing environment based on a shared codebase structure. Unfortunately such a multi-developer workflow is currently not well-supported by clasp, as demonstrated by the discussion in #921.

Private remotes as proposed in #989 would solve a significant portion of the hassle, but the resulting workflow still has a couple of flaws and limitations:

The running theme here is that there's no easy way to reliably and consistently (re)create a GAS project based on the shared structure of a codebase, similar to something like Docker or "Infrastructure as Code".

You could turn to scripting, but that's a treacherous path of system differences and shoddy error handling. This workflow is so common that I strongly believe it deserves first-party support. Scripting should only be necessary for truly custom scenarios.

Usecases

Prior art

Configuration

To consistently (re)create GAS projects some extra information needs to be added to .clasp.json:

New subcommand: remote create

The existing create command is intended to create a new codebase with accompanying GAS project, like you would do on scripts.google.com. We need a command that creates only a GAS project based on an existing codebase. I propose the following new subcommand:

clasp remote create <name>

This command should handle this workflow in three steps:

  1. Add a new remote called <name> to the codebase (private by default).
  2. Create a new (empty) GAS project based on .clasp.json.
  3. Push the codebase to this new remote.

Options

Implementation notes

remote create felt more natural than create --empty as proposed in #758, since it explicitly signals creating only a new remote rather than a whole new codebase. Having create behave significantly differently in a folder with a .clasp.json seems undesirable and would probably be a breaking change.

Other considerations

  1. Is sharing a codebase across projects with varying type-s a thing? If so, type could be moved/added to the remotes object with some form of shared default setting.