Skip to content

Commit

Permalink
Merge branch 'zapier-platform-major-release-16.0.0-dev' into PDE-5183
Browse files Browse the repository at this point in the history
  • Loading branch information
rnegron committed Nov 4, 2024
2 parents af5f8d5 + debe29c commit a85010f
Show file tree
Hide file tree
Showing 41 changed files with 8,006 additions and 5,457 deletions.
20 changes: 0 additions & 20 deletions docs/cli.html

This file was deleted.

859 changes: 859 additions & 0 deletions docs/cli.md

Large diffs are not rendered by default.

1,450 changes: 1,450 additions & 0 deletions packages/cli/docs/cli.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions packages/cli/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ Note: this is similar to `zapier migrate` but different in that this is temporar
**Usage**: `zapier canary:list`

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Examples**
* `zapier canary:list`
Expand Down Expand Up @@ -193,8 +193,8 @@ resources convert and relate to different actions.
* **Available Methods**: testable methods for this action

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.


## env:get
Expand All @@ -207,8 +207,8 @@ resources convert and relate to different actions.
* (required) `version` | The version to get the environment for.

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Examples**
* `zapier env:get 1.2.3`
Expand Down Expand Up @@ -257,8 +257,8 @@ resources convert and relate to different actions.
History includes all the changes made over the lifetime of your integration. This includes everything from creation, updates, migrations, admins, and invitee changes, as well as who made the change and when.

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.


## init
Expand Down Expand Up @@ -292,8 +292,8 @@ This doesn't register or deploy the integration with Zapier - try the `zapier re
This command also checks the current directory for a linked integration.

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Aliases**
* `apps`
Expand Down Expand Up @@ -409,8 +409,8 @@ Jobs are returned from oldest to newest.


**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Examples**
* `zapier jobs`
Expand Down Expand Up @@ -468,8 +468,8 @@ This won't show logs from running locally with `zapier test`, since those never
* `--detailed` | See extra info, like request/response body and headers.
* `-u, --user` | Only show logs for this user. Defaults to your account. Defaults to `me`.
* `--limit` | Cap the number of logs returned. Max is 50 (also the default) Defaults to `50`.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.


## migrate
Expand Down Expand Up @@ -696,8 +696,8 @@ Use the `zapier team:add` and `zapier team:remove` commands to modify your team.


**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Aliases**
* `team:list`
Expand Down Expand Up @@ -792,8 +792,8 @@ Invited users will be able to see your integration's name, logo, and description
Note that this list of users is NOT a comprehensive list of everyone who is using your integration. It only includes users who were invited directly by email (using the `zapier users:add` command or the web UI). Users who joined by clicking links generated using the `zapier user:links` command won't show up here.

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Aliases**
* `users:list`
Expand All @@ -806,8 +806,8 @@ Note that this list of users is NOT a comprehensive list of everyone who is usin
**Usage**: `zapier users:links`

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.


## users:remove
Expand Down Expand Up @@ -839,8 +839,8 @@ Run the standard validation routine powered by json-schema that checks your inte

**Flags**
* `--without-style` | Forgo pinging the Zapier server to run further checks.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.

**Examples**
* `zapier validate`
Expand All @@ -855,5 +855,5 @@ Run the standard validation routine powered by json-schema that checks your inte
**Usage**: `zapier versions`

**Flags**
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
* `-d, --debug` | Show extra debugging output.
* `-f, --format` | Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq. One of `[plain | json | raw | row | table]`. Defaults to `table`.
37 changes: 20 additions & 17 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"/oclif.manifest.json"
],
"engines": {
"node": ">=16"
"node": ">=18"
},
"scripts": {
"docs": "ZAPIER_BASE_ENDPOINT='' node scripts/docs.js",
"preversion": "git pull && yarn validate",
"prepack": "oclif-dev manifest",
"prepack": "oclif manifest",
"postpack": "rm -f oclif.manifest.json",
"precommit": "yarn docs && git add docs",
"version": "yarn docs && git add docs/*",
Expand All @@ -40,11 +40,11 @@
"validate": "yarn test && yarn smoke-test && yarn lint"
},
"dependencies": {
"@oclif/command": "1.8.27",
"@oclif/config": "1.18.10",
"@oclif/plugin-autocomplete": "0.3.0",
"@oclif/plugin-help": "3.2.20",
"@oclif/plugin-not-found": "1.2.4",
"@oclif/core": "4.0.28",
"@oclif/plugin-autocomplete": "3.2.6",
"@oclif/plugin-help": "6.2.15",
"@oclif/plugin-not-found": "3.2.22",
"@oclif/plugin-version": "2.2.15",
"adm-zip": "0.5.10",
"archiver": "5.3.1",
"browserify": "17.0.0",
Expand Down Expand Up @@ -81,34 +81,37 @@
"yeoman-generator": "5.9.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.10",
"@oclif/test": "^1.2.9",
"@oclif/test": "^4.0.9",
"chai": "^4.3.7",
"decompress": "4.2.1",
"mock-fs": "^5.2.0",
"nock": "^13.3.1",
"stdout-stderr": "0.1.13",
"oclif": "^4.15.1",
"yamljs": "0.3.0"
},
"bin": {
"zapier": "./src/bin/run"
},
"oclif": {
"commands": "src/oclif/commands",
"additionalHelpFlags": ["-h"],
"additionalVersionFlags": ["-v"],
"bin": "zapier",
"dirname": "zapier",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-not-found",
"@oclif/plugin-autocomplete"
"@oclif/plugin-autocomplete",
"@oclif/plugin-help",
"@oclif/plugin-not-found",
"@oclif/plugin-version"
],
"hooks": {
"init": [
"./src/oclif/hooks/versionInfo",
"./src/oclif/hooks/deprecated",
"./src/oclif/hooks/updateNotifier",
"./src/oclif/hooks/checkValidNodeVersion",
"./src/oclif/hooks/deprecated",
"./src/oclif/hooks/getAppRegistrationFieldChoices",
"./src/oclif/hooks/renderMarkdownHelp",
"./src/oclif/hooks/getAppRegistrationFieldChoices"
"./src/oclif/hooks/updateNotifier",
"./src/oclif/hooks/versionInfo"
]
},
"topics": {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/bin/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

require('@oclif/command')
.run() // this looks through the directory to find all the commands
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'));
(async () => {
const oclif = await import('@oclif/core');
await oclif.execute({ development: false, dir: __dirname });
})();
3 changes: 0 additions & 3 deletions packages/cli/src/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
REM this is created by the oclif generator and is similar to a file that npm creates on install
REM see https://stackoverflow.com/a/28415646/1825390

@echo off

node "%~dp0\run" %*
2 changes: 1 addition & 1 deletion packages/cli/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// for now, requiring this file has no real effect

module.exports = require('@oclif/command');
module.exports = require('@oclif/core');
87 changes: 47 additions & 40 deletions packages/cli/src/oclif/ZapierBaseCommand.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { Command } = require('@oclif/command');
const { stdtermwidth } = require('@oclif/help/lib/screen');
const { renderList } = require('@oclif/help/lib/list');
const { Command } = require('@oclif/core');
const colors = require('colors/safe');

const { startSpinner, endSpinner, formatStyles } = require('../utils/display');
Expand All @@ -14,9 +12,9 @@ const inquirer = require('inquirer');
const DATA_FORMATS = ['json', 'raw'];

class ZapierBaseCommand extends Command {
run() {
async run() {
this._initPromptModules();
this._parseFlags();
await this._parseCommand();

if (this.flags.debug) {
this.debug.enabled = true; // enables this.debug on the command
Expand Down Expand Up @@ -67,11 +65,12 @@ class ZapierBaseCommand extends Command {
});
}

_parseFlags() {
const { flags, args } = this.parse(this._staticClassReference);
async _parseCommand() {
const { flags, args, argv } = await this.parse(this._staticClassReference);

this.flags = flags;
this.args = args;
this.argv = argv;
}

perform() {
Expand Down Expand Up @@ -137,6 +136,9 @@ class ZapierBaseCommand extends Command {
headers = [],
emptyMessage = '',
formatOverride = '',
hasBorder = true,
showHeaders = true,
style = undefined,
} = {}) {
const formatter = formatOverride
? formatStyles[formatOverride]
Expand All @@ -149,18 +151,10 @@ class ZapierBaseCommand extends Command {
this.log(colors.gray(emptyMessage));
} else {
// data comes out of the formatter ready to be printed (and it's always in the type to match the format) so we don't need to do anything special with it
console.log(formatter(rows, headers));
console.log(formatter(rows, headers, showHeaders, hasBorder, style));
}
}

/**
* Print text in a list style.
* @param {string[][]} items
*/
logList(items) {
this.log(renderList(items, { spacer: '\n', maxWidth: stdtermwidth }));
}

/**
*
* @param {Object} opts options object (as expected for this.prompt())
Expand Down Expand Up @@ -270,36 +264,45 @@ class ZapierBaseCommand extends Command {
return arg.required ? argName : `[${argName}]`;
};

return [
'zapier',
name,
...(this.args || []).filter((a) => !a.hidden).map((a) => formatArg(a)),
].join(' ');
const argv = Object.entries(this.args ?? {}).map(([argName, argValue]) => ({
name: argName,
...argValue,
}));
const visibleArgv = argv.filter((arg) => !arg.hidden);

return ['zapier', name, ...visibleArgv.map(formatArg)].join(' ');
}

// this is fine for now but we'll want to hack into https://github.com/oclif/plugin-help/blob/master/src/command.ts at some point
// the presentation is wrapped into the formatting, so it's a little tough to pull out
static markdownHelp(name) {
const formattedArgs = () =>
this.args.map((arg) =>
arg.hidden
const getFormattedArgs = () =>
Object.keys(this.args ?? {}).map((argName) => {
const arg = this.args[argName];
return arg.hidden
? null
: `* ${arg.required ? '(required) ' : ''}\`${arg.name}\` | ${
: `* ${arg.required ? '(required) ' : ''}\`${argName}\` | ${
arg.description
}`
);
const formattedFlags = () =>
}`;
});
const getFormattedFlags = () =>
Object.entries(this.flags)
.map(([longName, flag]) =>
flag.hidden
.map(([flagName, flagValue]) =>
flagValue.hidden
? null
: `* ${flag.required ? '(required) ' : ''}\`${
flag.char ? `-${flag.char}, ` : ''
}--${longName}\` |${
flag.description ? ` ${flag.description}` : ''
: `* ${flagValue.required ? '(required) ' : ''}\`${
flagValue.char ? `-${flagValue.char}, ` : ''
}--${flagName}\` |${
flagValue.description ? ` ${flagValue.description}` : ''
} ${
flag.options ? `One of \`[${flag.options.join(' | ')}]\`.` : ''
}${flag.default ? ` Defaults to \`${flag.default}\`.` : ''}
flagValue.options
? `One of \`[${flagValue.options.join(' | ')}]\`.`
: ''
}${
flagValue.default
? ` Defaults to \`${flagValue.default}\`.`
: ''
}
`.trim()
)
.filter(Boolean);
Expand All @@ -317,16 +320,20 @@ class ZapierBaseCommand extends Command {
'',
`**Usage**: \`${this.zUsage(name)}\``,
...(lengthyDescription ? ['', lengthyDescription] : []),
...(this.args ? ['', '**Arguments**', ...formattedArgs()] : []),
...(this.flags ? ['', '**Flags**', ...formattedFlags()] : []),
...(this.examples
...(Object.keys(this.args ?? {}).length
? ['', '**Arguments**', ...getFormattedArgs()]
: []),
...(Object.keys(this.flags ?? {}).length
? ['', '**Flags**', ...getFormattedFlags()]
: []),
...((this.examples ?? []).length
? [
'',
'**Examples**',
this.examples.map((e) => `* \`${e}\``).join('\n'),
]
: []),
...(this.aliases.length
...((this.aliases ?? []).length
? ['', '**Aliases**', this.aliases.map((e) => `* \`${e}\``).join('\n')]
: []),
]
Expand Down
Loading

0 comments on commit a85010f

Please sign in to comment.