Clasp: Allow manifest, file list via CLI

Created on 5 Feb 2018  路  9Comments  路  Source: google/clasp

Currently the file set to upload in the push command is automatically determined. It would be helpful to be able to specify files (both manifest and js) via the command line as well.

The particular use case is to be able to deploy different configurations -- e.g. in test mode I want to use an alternate manifest with execution API enabled, tests bundled, etc. while in prod mode I want to skip all that. This is particularly important for libraries where we don't want to have long-lived deployments, but may want to temporarily deploy as executable or web app for purposes of running tests and don't want to package code that is only used for resting.. Same can be used for add-ons and other things where we'd like to keep test code & configuration somewhat isolated.

My ideal is to have commands in package.json like:

"scripts": {
"push-test": "clasp push --env=test appsscript.test.json test/.js src/.js"
"push-prod": "clasp push --env=prod appscript.prod.json src/**.js",
...
}

Many CLIs allow specifying files via command line -- tsc, babel, jshint, etc.. all allow specifying which files to operate on as args. Typescript is also very close to what is being asked for. By default, it'll pick up all *.ts files as is the current behavior of clasp. But that can be overridden by explicitly providing a list of globs as args.

feature request

Most helpful comment

Sort of, but not just the project ID. Suppose the same technique could be used with renaming .claspignore and manifest files, but it's clunky. Better would be to just take the file patterns as optional arguments. If they're present, push those files. If not, fall back on the current algorithm.

Ideally we'd have both an environment option for auth/project ID and a way to easily change file sets. I'd like my package.json to look something like:

"scripts": {
  "push-test": "clasp push --env=test appsscript.test.json test/**.js src/**.js"
  "push-prod": "clasp push --env=prod appscript.prod.json src/**.js",
  ...
}

All 9 comments

Do you mean test/prod options like #12?

Sort of, but not just the project ID. Suppose the same technique could be used with renaming .claspignore and manifest files, but it's clunky. Better would be to just take the file patterns as optional arguments. If they're present, push those files. If not, fall back on the current algorithm.

Ideally we'd have both an environment option for auth/project ID and a way to easily change file sets. I'd like my package.json to look something like:

"scripts": {
  "push-test": "clasp push --env=test appsscript.test.json test/**.js src/**.js"
  "push-prod": "clasp push --env=prod appscript.prod.json src/**.js",
  ...
}

I don't see a use-case where a 1-line bash script can't solve. I'd rather have the CLI be minimal and use git's features or a bash file instead.

A few reasons:

  • It's not a 1 line script. Also need to make sure the ephemeral files are ignored by git or whatever source control system is being used.
  • Sometimes expressing things in the affirmative is easier than expressing them in the negative. Right now clasp only allows expressing things negatively -- tell me the files you don't want to push. In more complex projects, the affirmative expression can end up being more concise.
  • Taking args via CLI accommodates different build systems. Some build systems (e.g. bazel) don't put generated/intermediate files under the project directory, but rather in a separate parallel tree to avoid polluting the source dir. Clasp should be accommodating here.

I'm certainly open to other ways of solving the problem. But in general, it's pretty common that any CLI tools that operate on files allow passing the paths via arguments. That part shouldn't be controversial.

Questions (Can you modify the first comment with the details about this FR to reduce discussion?):

  • Can you point to some similar flags/samples in other CLIs?
  • Can you have a more concrete example? I don't really understand the use-case and why you need this feature.
  • Can we modify how .claspignore works to accommodate explicitly kept files?
  • Why can't you just do this:
mv .claspignore-prod .claspignore && mv .appsscript-prod.json .appsscript.json
mv .claspignore-test .claspignore && mv .appsscript-test.json .appsscript.json

Updated the original comment w/examples of other CLIs that behave this way as well as the use case later mentioned in the discussion.

There is similar CLI as clasp. it is gas-manager.
gas-manager has options to specify environment(project ID), credential, etc...
Please see https://github.com/soundTricker/gas-manager#cli

I'll look at PR proposals that use npm's config for environments in package.json.

{
  "config": {
    "env":  {
      "prod": ...
      "test": ...
    }
  }
}

I don't see a future where I can support this feature.
Hopefully a wrapper bash script can solve the issue at hand.

Closing this issue, but feel free to comment here as it can be re-opened at a later date.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coccoinomane picture coccoinomane  路  5Comments

OleksandrRakovets picture OleksandrRakovets  路  3Comments

dskeithbuck picture dskeithbuck  路  5Comments

smandava picture smandava  路  8Comments

nirazul picture nirazul  路  7Comments