clasp icon indicating copy to clipboard operation
clasp copied to clipboard

issue-1060

Open wattry opened this issue 6 months ago • 1 comments

Allow script ID as argument for list-deployments & list-versions

Add --json option to list-deployments & list-versions

Fixes #<issue_number_goes_here> (it's a good idea to open an issue first for discussion)

  • [x] npm run test succeeds.
 128 passing (581ms)
  • [x] npm run lint succeeds.
 λ npm run lint --fix

> @google/[email protected] lint
> npm run check


> @google/[email protected] check
> biome check src test && npm run compile

Checked 73 files in 24ms. No fixes applied.

> @google/[email protected] compile
> tspc
  • [x] Appropriate changes to README are included in PR.
### Versions

List versions of a script.

#### Options

- `--json`: Output list in json format.

#### Examples

- `clasp list-versions`: List all versions for the current project
- `clasp list-versions --json`: List all versions for the current project and output in json
- `clasp list-versions [scriptId]`: List all versions for a script ID
- `clasp list-versions [scriptId] --json`: List all versions for a script ID and output in json


### Deployments

List deployments of a script.

#### Options

- `--json`: Output list in json format.

#### Examples

- `clasp list-deployments`: List all deployments for the current project
- `clasp list-deployments --json`: List all deployments for the current project and output in json
- `clasp list-deployments [scriptId]`: List all deployments for a script ID
- `clasp list-deployments [scriptId] --json`: List all deployments for a script ID and output in json

wattry avatar May 30 '25 23:05 wattry

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar May 30 '25 23:05 google-cla[bot]

Didn't mean to close the issue yet, but wanted the --json flag to be a global option so it's consistent throughout all the commands. If you can resolve the merge conflicts, happy to merge the parameter stuff (but similarly, would rather do this uniformly if there are additional commands that would benefit)

sqrrrl avatar Jul 23 '25 01:07 sqrrrl

Ah okay I thought you were closing it because you were already implementing it globally as a broader change and this was unnecessary.

wattry avatar Jul 23 '25 15:07 wattry

Also should be able to do this without modifying anything in src/core. There's a method on the clasp instance to set the script ID if it isn't already set:

const clasp = options.clasp;
if (scriptId) { 
  clasp.withScriptId(scriptId);
} 

Right now that withScriptId function will throw an error if the script is already known, so this would fail if the user is calling it in a dir with a valid clasp project, but we can probably remove/relax that check in src/core/clasp.ts

sqrrrl avatar Jul 23 '25 17:07 sqrrrl

Also should be able to do this without modifying anything in src/core. There's a method on the clasp instance to set the script ID if it isn't already set:

const clasp = options.clasp;
if (scriptId) { 
  clasp.withScriptId(scriptId);
} 

Right now that withScriptId function will throw an error if the script is already known, so this would fail if the user is calling it in a dir with a valid clasp project, but we can probably remove/relax that check in src/core/clasp.ts

The intention behind that change was to be able to run it with the script id of library dependencies, not limited to the root package. When our users are trying to manage a package that has several libraries they have to navigate to the project and click on each package there.

Do you have any thoughts on that implementation or is it something that is out of scope for the project?

wattry avatar Jul 24 '25 14:07 wattry

This is what I was thinking to relax the check.

  withScriptId(scriptId: string) {
    if (this.options.project) {
      debug('Project is already configured, overriding scriptId with %s', scriptId);
    }

    this.options.project = {
      scriptId,
    };
    return this;
  }

wattry avatar Jul 24 '25 15:07 wattry