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

environment vars & cli options to specify dotfiles #616

Closed
PopGoesTheWza opened this issue May 15, 2019 · 13 comments
Closed

environment vars & cli options to specify dotfiles #616

PopGoesTheWza opened this issue May 15, 2019 · 13 comments

Comments

@PopGoesTheWza
Copy link
Collaborator

In a fashion similar to tsc --project and tslint --project which allow to specify which (and where) your project configuration file to be used, it would be nice (and useful) to be able to define on the command line different clasp configuration.

Expected Behavior

clasp push --project dev.json
clasp push --project prod.json

Actual Behavior

(some kludgy workaround with additional folders and intricate path references)

Steps to Reproduce the Problem

Specifications

  • Node version (node -v): 10
  • Version (clasp -v): latest
  • OS (Mac/Linux/Windows): Mac (latest)
@grant
Copy link
Contributor

grant commented May 21, 2019

Why can't we:

clasp setting scriptId id1;
clasp push;
clasp setting scriptId id2;
clasp push;

?

What would dev.json include?

@PopGoesTheWza
Copy link
Collaborator Author

PopGoesTheWza commented May 21, 2019

@grant I have started implementing the following design:

  • overide path and name for .clasp.json, .claspignore, .clasprc.json & appsscript.json by precedence:
    1. commander options (-P, --project, -I, --ignore, -A, --auth -M, --manifest`)
    2. environment variables (clasp_config_project, clasp_config_ignore, clasp_config_auth & clasp_config_manifest)
    3. current implementation

Handling scriptIds directly on the command line is clumsy IMHO. And about half a dozen issues are likely to be addressed with cli option/environment vars overrides.

I am also considering an "extended" .clasp.json interface which would allow to hold it all in one file. I haven't yet fully thought it over, but it could look something like the following:

{
  // "legacy" properties
  "scriptId": "scriptId",
  "rootDir": "rootDir",
  "projectId": "projectId",
  "fileExtension": "fileExtension",
  "filePushOrder": "filePushOrder",
  // "extended properties
  "env": {
    // same "legacy" properties
    "claspIgnore": "pathAndNameToClaspIgnore",
    "clasprc": "pathAndNameToClaspRc",
    "manifest": "pathAndNameToAppsScriptJson",
  }
}

There you could do commands like clasp <cmd> --env <env>

@PopGoesTheWza PopGoesTheWza changed the title .clasp.json name and path to be a CLI parameter environment vars & cli options to specify dotfiles May 22, 2019
This was referenced May 27, 2019
@PopGoesTheWza
Copy link
Collaborator Author

PopGoesTheWza commented Jun 3, 2019

@grant

The goal of this feature request is to enable the user in specifying which/where the following configuration files to be used by Clasp:

  • .clasp.json
  • .claspignore
  • .clasprc.json (local auth)

This sould be possible through:

  • environment variables:
    • clasp_config_project
    • clasp_config_ignore
    • clasp_config_auth
  • cli options:
    • -P, --project <file>
    • -I, --ignore <file>
    • -A, --auth <file>

The rules to resolve a config file path would be by priority order:

  1. if defined via cli option, use this value
  2. if defined via environment variable, use this value
  3. use default/current behaviour

values can be absolute and relative path to a directory containing a config file of the default name (i.e. --project env/dev where a .clasp.json exist), or a path to a dotfile (i.e. --auth .clasprc_test.json)

@PopGoesTheWza
Copy link
Collaborator Author

@grant comments? thoughts?

@grant
Copy link
Contributor

grant commented Jun 11, 2019

I can’t really support feature that don’t have at least 10 users or solves a key use case.

I would maybe fork clasp if you really can’t use bash commands to do this and want to add it to the CLI.

@PopGoesTheWza
Copy link
Collaborator Author

PopGoesTheWza commented Jun 11, 2019

I can use command line or use my own fork even. The proposed change would potentially address #12 #483 #524 #12 #42 I think, but at that point I’ll Wait for more traction/support.

@chechedotmx
Copy link

I want to "git" my gas project, but I need to add some hardcode id´s (google sheet) to the git repository, it would be great to have environment variables inside .clasp.json to avoid the versioning of this id´s

@grant
Copy link
Contributor

grant commented Aug 16, 2019

A design/PR that only included the following would be fine:

  • CLASP_PROJECT
  • CLASP_AUTH

no flags, ignore file would be in the project. Be sure to document the variables.

@PopGoesTheWza
Copy link
Collaborator Author

@chechedotmx would environment variables to specify .clasp.json & .clasprc.json address your need?

@PopGoesTheWza
Copy link
Collaborator Author

@grant why no flags (cli options)? You're spoiling all the fun!

@grant
Copy link
Contributor

grant commented Aug 16, 2019

Want to start simple. Also flags may conflict with existing command flags.

@PopGoesTheWza
Copy link
Collaborator Author

@grant I already did the full PR, so limiting to only .clasp.json and .clasprc.json should not be problem. Even dishing out the cli options (which do not conflict)
I only need @chechedotmx approval to start.

@chechedotmx
Copy link

Sounds good @PopGoesTheWza

@PopGoesTheWza PopGoesTheWza mentioned this issue Aug 19, 2019
2 tasks
@sqrrrl sqrrrl closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants