zapier-platform-cli 15.18.1 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/oclif.manifest.json +2316 -1
- package/package.json +43 -33
- package/scaffold/create.template.ts +64 -0
- package/scaffold/resource.template.ts +119 -0
- package/scaffold/search.template.ts +63 -0
- package/scaffold/test.template.ts +18 -0
- package/scaffold/trigger.template.ts +58 -0
- package/src/bin/run +4 -4
- package/src/bin/run.cmd +0 -3
- package/src/generators/index.js +11 -11
- package/src/index.js +1 -1
- package/src/oclif/ZapierBaseCommand.js +51 -44
- package/src/oclif/buildFlags.js +14 -16
- package/src/oclif/commands/analytics.js +6 -6
- package/src/oclif/commands/build.js +6 -6
- package/src/oclif/commands/cache/clear.js +13 -13
- package/src/oclif/commands/canary/create.js +27 -20
- package/src/oclif/commands/canary/delete.js +26 -16
- package/src/oclif/commands/canary/list.js +5 -7
- package/src/oclif/commands/convert.js +16 -16
- package/src/oclif/commands/delete/version.js +6 -6
- package/src/oclif/commands/deprecate.js +10 -11
- package/src/oclif/commands/describe.js +5 -5
- package/src/oclif/commands/env/get.js +5 -5
- package/src/oclif/commands/env/set.js +11 -12
- package/src/oclif/commands/env/unset.js +9 -10
- package/src/oclif/commands/init.js +12 -13
- package/src/oclif/commands/invoke.js +67 -69
- package/src/oclif/commands/jobs.js +1 -1
- package/src/oclif/commands/link.js +2 -2
- package/src/oclif/commands/login.js +15 -15
- package/src/oclif/commands/logout.js +1 -1
- package/src/oclif/commands/logs.js +9 -9
- package/src/oclif/commands/migrate.js +19 -22
- package/src/oclif/commands/promote.js +25 -27
- package/src/oclif/commands/push.js +2 -2
- package/src/oclif/commands/register.js +31 -32
- package/src/oclif/commands/scaffold.js +112 -106
- package/src/oclif/commands/team/add.js +12 -15
- package/src/oclif/commands/team/get.js +2 -2
- package/src/oclif/commands/team/remove.js +6 -6
- package/src/oclif/commands/test.js +8 -8
- package/src/oclif/commands/upload.js +1 -1
- package/src/oclif/commands/users/add.js +9 -11
- package/src/oclif/commands/users/get.js +7 -7
- package/src/oclif/commands/users/links.js +4 -4
- package/src/oclif/commands/users/remove.js +8 -9
- package/src/oclif/commands/validate.js +29 -21
- package/src/oclif/commands/versions.js +26 -1
- package/src/oclif/hooks/checkValidNodeVersion.js +1 -1
- package/src/oclif/hooks/deprecated.js +1 -1
- package/src/oclif/hooks/getAppRegistrationFieldChoices.js +4 -4
- package/src/oclif/hooks/renderMarkdownHelp.js +1 -2
- package/src/oclif/hooks/versionInfo.js +2 -2
- package/src/utils/analytics.js +4 -4
- package/src/utils/api.js +26 -29
- package/src/utils/ast.js +112 -11
- package/src/utils/auth-files-codegen.js +102 -99
- package/src/utils/build.js +27 -28
- package/src/utils/changelog.js +1 -1
- package/src/utils/check-missing-app-info.js +2 -2
- package/src/utils/convert.js +26 -20
- package/src/utils/credentials.js +1 -1
- package/src/utils/display.js +31 -8
- package/src/utils/files.js +3 -3
- package/src/utils/ignore.js +2 -2
- package/src/utils/local.js +1 -1
- package/src/utils/metadata.js +1 -1
- package/src/utils/misc.js +21 -22
- package/src/utils/promisify.js +1 -1
- package/src/utils/scaffold.js +293 -40
- package/src/utils/team.js +3 -3
- package/src/utils/xdg.js +3 -3
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const { Command } = require('@oclif/
|
|
2
|
-
const { stdtermwidth } = require('@oclif/help/lib/screen');
|
|
3
|
-
const { renderList } = require('@oclif/help/lib/list');
|
|
1
|
+
const { Command } = require('@oclif/core');
|
|
4
2
|
const colors = require('colors/safe');
|
|
5
3
|
|
|
6
4
|
const { startSpinner, endSpinner, formatStyles } = require('../utils/display');
|
|
@@ -14,9 +12,9 @@ const inquirer = require('inquirer');
|
|
|
14
12
|
const DATA_FORMATS = ['json', 'raw'];
|
|
15
13
|
|
|
16
14
|
class ZapierBaseCommand extends Command {
|
|
17
|
-
run() {
|
|
15
|
+
async run() {
|
|
18
16
|
this._initPromptModules();
|
|
19
|
-
this.
|
|
17
|
+
await this._parseCommand();
|
|
20
18
|
|
|
21
19
|
if (this.flags.debug) {
|
|
22
20
|
this.debug.enabled = true; // enables this.debug on the command
|
|
@@ -47,7 +45,7 @@ class ZapierBaseCommand extends Command {
|
|
|
47
45
|
|
|
48
46
|
if (!this.flags.debug && !this.flags.invokedFromAnotherCommand) {
|
|
49
47
|
errTextLines.push(
|
|
50
|
-
colors.gray('re-run this command with `--debug` for more info')
|
|
48
|
+
colors.gray('re-run this command with `--debug` for more info'),
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -67,11 +65,12 @@ class ZapierBaseCommand extends Command {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
const { flags, args } = this.parse(this._staticClassReference);
|
|
68
|
+
async _parseCommand() {
|
|
69
|
+
const { flags, args, argv } = await this.parse(this._staticClassReference);
|
|
72
70
|
|
|
73
71
|
this.flags = flags;
|
|
74
72
|
this.args = args;
|
|
73
|
+
this.argv = argv;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
perform() {
|
|
@@ -93,7 +92,7 @@ class ZapierBaseCommand extends Command {
|
|
|
93
92
|
throwForInvalidVersion(version) {
|
|
94
93
|
if (!version.match(/^\d+\.\d+\.\d+$/g)) {
|
|
95
94
|
throw new Error(
|
|
96
|
-
`${version} is an invalid version str. Try something like \`1.2.3
|
|
95
|
+
`${version} is an invalid version str. Try something like \`1.2.3\``,
|
|
97
96
|
);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -137,6 +136,9 @@ class ZapierBaseCommand extends Command {
|
|
|
137
136
|
headers = [],
|
|
138
137
|
emptyMessage = '',
|
|
139
138
|
formatOverride = '',
|
|
139
|
+
hasBorder = true,
|
|
140
|
+
showHeaders = true,
|
|
141
|
+
style = undefined,
|
|
140
142
|
} = {}) {
|
|
141
143
|
const formatter = formatOverride
|
|
142
144
|
? formatStyles[formatOverride]
|
|
@@ -149,18 +151,10 @@ class ZapierBaseCommand extends Command {
|
|
|
149
151
|
this.log(colors.gray(emptyMessage));
|
|
150
152
|
} else {
|
|
151
153
|
// 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
|
|
152
|
-
console.log(formatter(rows, headers));
|
|
154
|
+
console.log(formatter(rows, headers, showHeaders, hasBorder, style));
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
/**
|
|
157
|
-
* Print text in a list style.
|
|
158
|
-
* @param {string[][]} items
|
|
159
|
-
*/
|
|
160
|
-
logList(items) {
|
|
161
|
-
this.log(renderList(items, { spacer: '\n', maxWidth: stdtermwidth }));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
158
|
/**
|
|
165
159
|
*
|
|
166
160
|
* @param {Object} opts options object (as expected for this.prompt())
|
|
@@ -270,44 +264,53 @@ class ZapierBaseCommand extends Command {
|
|
|
270
264
|
return arg.required ? argName : `[${argName}]`;
|
|
271
265
|
};
|
|
272
266
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
267
|
+
const argv = Object.entries(this.args ?? {}).map(([argName, argValue]) => ({
|
|
268
|
+
name: argName,
|
|
269
|
+
...argValue,
|
|
270
|
+
}));
|
|
271
|
+
const visibleArgv = argv.filter((arg) => !arg.hidden);
|
|
272
|
+
|
|
273
|
+
return ['zapier', name, ...visibleArgv.map(formatArg)].join(' ');
|
|
278
274
|
}
|
|
279
275
|
|
|
280
276
|
// 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
|
|
281
277
|
// the presentation is wrapped into the formatting, so it's a little tough to pull out
|
|
282
278
|
static markdownHelp(name) {
|
|
283
|
-
const
|
|
284
|
-
this.args.map((
|
|
285
|
-
arg.
|
|
279
|
+
const getFormattedArgs = () =>
|
|
280
|
+
Object.keys(this.args ?? {}).map((argName) => {
|
|
281
|
+
const arg = this.args[argName];
|
|
282
|
+
return arg.hidden
|
|
286
283
|
? null
|
|
287
|
-
: `* ${arg.required ? '(required) ' : ''}\`${
|
|
284
|
+
: `* ${arg.required ? '(required) ' : ''}\`${argName}\` | ${
|
|
288
285
|
arg.description
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
const
|
|
286
|
+
}`;
|
|
287
|
+
});
|
|
288
|
+
const getFormattedFlags = () =>
|
|
292
289
|
Object.entries(this.flags)
|
|
293
|
-
.map(([
|
|
294
|
-
|
|
290
|
+
.map(([flagName, flagValue]) =>
|
|
291
|
+
flagValue.hidden
|
|
295
292
|
? null
|
|
296
|
-
: `* ${
|
|
297
|
-
|
|
298
|
-
}--${
|
|
299
|
-
|
|
293
|
+
: `* ${flagValue.required ? '(required) ' : ''}\`${
|
|
294
|
+
flagValue.char ? `-${flagValue.char}, ` : ''
|
|
295
|
+
}--${flagName}\` |${
|
|
296
|
+
flagValue.description ? ` ${flagValue.description}` : ''
|
|
300
297
|
} ${
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
298
|
+
flagValue.options
|
|
299
|
+
? `One of \`[${flagValue.options.join(' | ')}]\`.`
|
|
300
|
+
: ''
|
|
301
|
+
}${
|
|
302
|
+
flagValue.default
|
|
303
|
+
? ` Defaults to \`${flagValue.default}\`.`
|
|
304
|
+
: ''
|
|
305
|
+
}
|
|
306
|
+
`.trim(),
|
|
304
307
|
)
|
|
305
308
|
.filter(Boolean);
|
|
306
309
|
|
|
307
310
|
const descriptionParts = this.description.split('\n\n').filter(Boolean);
|
|
308
311
|
const blurb = descriptionParts[0];
|
|
309
312
|
const lengthyDescription = colors.stripColors(
|
|
310
|
-
descriptionParts.length > 1 ? descriptionParts.slice(1).join('\n\n') : ''
|
|
313
|
+
descriptionParts.length > 1 ? descriptionParts.slice(1).join('\n\n') : '',
|
|
311
314
|
);
|
|
312
315
|
|
|
313
316
|
return [
|
|
@@ -317,16 +320,20 @@ class ZapierBaseCommand extends Command {
|
|
|
317
320
|
'',
|
|
318
321
|
`**Usage**: \`${this.zUsage(name)}\``,
|
|
319
322
|
...(lengthyDescription ? ['', lengthyDescription] : []),
|
|
320
|
-
...(this.args
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
...(Object.keys(this.args ?? {}).length
|
|
324
|
+
? ['', '**Arguments**', ...getFormattedArgs()]
|
|
325
|
+
: []),
|
|
326
|
+
...(Object.keys(this.flags ?? {}).length
|
|
327
|
+
? ['', '**Flags**', ...getFormattedFlags()]
|
|
328
|
+
: []),
|
|
329
|
+
...((this.examples ?? []).length
|
|
323
330
|
? [
|
|
324
331
|
'',
|
|
325
332
|
'**Examples**',
|
|
326
333
|
this.examples.map((e) => `* \`${e}\``).join('\n'),
|
|
327
334
|
]
|
|
328
335
|
: []),
|
|
329
|
-
...(this.aliases.length
|
|
336
|
+
...((this.aliases ?? []).length
|
|
330
337
|
? ['', '**Aliases**', this.aliases.map((e) => `* \`${e}\``).join('\n')]
|
|
331
338
|
: []),
|
|
332
339
|
]
|
package/src/oclif/buildFlags.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags } = require('@oclif/core');
|
|
2
2
|
const { pickBy } = require('lodash');
|
|
3
3
|
|
|
4
4
|
const { formatStyles } = require('../utils/display');
|
|
5
5
|
|
|
6
6
|
const baseFlags = {
|
|
7
|
-
|
|
7
|
+
debug: Flags.boolean({
|
|
8
|
+
char: 'd',
|
|
9
|
+
description: 'Show extra debugging output.',
|
|
10
|
+
// pull from env?
|
|
11
|
+
}),
|
|
12
|
+
format: Flags.string({
|
|
8
13
|
char: 'f',
|
|
9
14
|
options: Object.keys(formatStyles),
|
|
10
15
|
default: 'table',
|
|
11
16
|
description:
|
|
12
17
|
'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.',
|
|
13
18
|
}),
|
|
14
|
-
debug: flags.boolean({
|
|
15
|
-
char: 'd',
|
|
16
|
-
description: 'Show extra debugging output.',
|
|
17
|
-
// pull from env?
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
19
|
// Indicates we're calling a command from another command so we know when not
|
|
21
20
|
// to print duplicate messages.
|
|
22
|
-
invokedFromAnotherCommand:
|
|
21
|
+
invokedFromAnotherCommand: Flags.boolean({
|
|
23
22
|
hidden: true,
|
|
24
23
|
}),
|
|
25
24
|
};
|
|
@@ -32,14 +31,13 @@ const defaultOpts = {
|
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
* pass in flag objects, plus whether or not to include debug and
|
|
34
|
+
* pass in flag objects, plus whether or not to include debug, format, and
|
|
35
|
+
* invokedFormatAnotherCommand.
|
|
36
36
|
*/
|
|
37
37
|
const buildFlags = ({ commandFlags = {}, opts = {} } = {}) => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
commandFlags,
|
|
42
|
-
pickBy(baseFlags, (v, k) => selectedBaseFlags[k])
|
|
43
|
-
);
|
|
38
|
+
const options = { ...defaultOpts, ...opts };
|
|
39
|
+
const pickedFlags = pickBy(baseFlags, (_v, k) => options[k]);
|
|
40
|
+
return { ...commandFlags, ...pickedFlags };
|
|
44
41
|
};
|
|
42
|
+
|
|
45
43
|
module.exports = { buildFlags };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const BaseCommand = require('../ZapierBaseCommand');
|
|
2
|
-
const {
|
|
2
|
+
const { Flags } = require('@oclif/core');
|
|
3
3
|
const { buildFlags } = require('../buildFlags');
|
|
4
4
|
const {
|
|
5
5
|
currentAnalyticsMode,
|
|
@@ -13,8 +13,8 @@ class AnalyticsCommand extends BaseCommand {
|
|
|
13
13
|
const currentMode = await currentAnalyticsMode();
|
|
14
14
|
this.log(
|
|
15
15
|
`The current analytics mode is ${colors.cyan(
|
|
16
|
-
currentMode
|
|
17
|
-
)}. Analytics may be skipped anyway if you've got DISABLE_ZAPIER_ANALYTICS set to a truthy value
|
|
16
|
+
currentMode,
|
|
17
|
+
)}. Analytics may be skipped anyway if you've got DISABLE_ZAPIER_ANALYTICS set to a truthy value.`,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
if (this.flags.mode) {
|
|
@@ -23,8 +23,8 @@ class AnalyticsCommand extends BaseCommand {
|
|
|
23
23
|
} else {
|
|
24
24
|
this.log(
|
|
25
25
|
`You can see what data is sent by running \`${colors.yellow(
|
|
26
|
-
'DEBUG=zapier:analytics zapier someCommand'
|
|
27
|
-
)}\`.\n\nYou can change your analytics preferences by re-running this command with the \`--mode\` flag.\n\nThe data collected is as generic as we can make it while still getting useful input. No specific information about your filesystem is collected. Your Zapier user id is collected so that we can better debug issues. We will never use this data for any advertising puposes
|
|
26
|
+
'DEBUG=zapier:analytics zapier someCommand',
|
|
27
|
+
)}\`.\n\nYou can change your analytics preferences by re-running this command with the \`--mode\` flag.\n\nThe data collected is as generic as we can make it while still getting useful input. No specific information about your filesystem is collected. Your Zapier user id is collected so that we can better debug issues. We will never use this data for any advertising puposes.`,
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -32,7 +32,7 @@ class AnalyticsCommand extends BaseCommand {
|
|
|
32
32
|
|
|
33
33
|
AnalyticsCommand.flags = buildFlags({
|
|
34
34
|
commandFlags: {
|
|
35
|
-
mode:
|
|
35
|
+
mode: Flags.string({
|
|
36
36
|
char: 'm',
|
|
37
37
|
options: Object.keys(modes),
|
|
38
38
|
description:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const BaseCommand = require('../ZapierBaseCommand');
|
|
2
|
+
const { Flags } = require('@oclif/core');
|
|
2
3
|
const { buildFlags } = require('../buildFlags');
|
|
3
|
-
const { flags } = require('@oclif/command');
|
|
4
4
|
const {
|
|
5
5
|
BUILD_PATH,
|
|
6
6
|
SOURCE_PATH,
|
|
@@ -17,26 +17,26 @@ class BuildCommand extends BaseCommand {
|
|
|
17
17
|
skipNpmInstall: this.flags['skip-npm-install'],
|
|
18
18
|
disableDependencyDetection: this.flags['disable-dependency-detection'],
|
|
19
19
|
skipValidation: this.flags['skip-validation'],
|
|
20
|
-
}
|
|
20
|
+
},
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
this.log(
|
|
24
|
-
`\nBuild complete! Created ${BUILD_PATH} and ${SOURCE_PATH}. Try the \`zapier upload\` command now
|
|
24
|
+
`\nBuild complete! Created ${BUILD_PATH} and ${SOURCE_PATH}. Try the \`zapier upload\` command now.`,
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
BuildCommand.flags = buildFlags({
|
|
30
30
|
commandFlags: {
|
|
31
|
-
'disable-dependency-detection':
|
|
31
|
+
'disable-dependency-detection': Flags.boolean({
|
|
32
32
|
description: `Disable "smart" file inclusion. By default, Zapier only includes files that are required by \`index.js\`. If you (or your dependencies) require files dynamically (such as with \`require(someVar)\`), then you may see "Cannot find module" errors. Disabling this may make your \`build.zip\` too large. If that's the case, try using the \`includeInBuild\` option in your \`${CURRENT_APP_FILE}\`. See the docs about \`includeInBuild\` for more info.`,
|
|
33
33
|
}),
|
|
34
|
-
'skip-npm-install':
|
|
34
|
+
'skip-npm-install': Flags.boolean({
|
|
35
35
|
description:
|
|
36
36
|
'Skips installing a fresh copy of npm dependencies on build. Helpful for using `yarn` or local copies of dependencies.',
|
|
37
37
|
hidden: true,
|
|
38
38
|
}),
|
|
39
|
-
'skip-validation':
|
|
39
|
+
'skip-validation': Flags.boolean({
|
|
40
40
|
description:
|
|
41
41
|
"Skips local pre-push validation checks, and remote validation check of the CLI app's schema and AppVersion integrity.",
|
|
42
42
|
hidden: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const BaseCommand = require('../../ZapierBaseCommand');
|
|
2
|
+
const { Args } = require('@oclif/core');
|
|
2
3
|
const { buildFlags } = require('../../buildFlags');
|
|
3
4
|
const { listVersions, getWritableApp, callAPI } = require('../../../utils/api');
|
|
4
5
|
const { cyan } = require('colors/safe');
|
|
@@ -14,13 +15,13 @@ class ClearCacheCommand extends BaseCommand {
|
|
|
14
15
|
let selectedMajorVersion = majorVersion ? Number(majorVersion) : null;
|
|
15
16
|
if (Number.isNaN(selectedMajorVersion)) {
|
|
16
17
|
throw new Error(
|
|
17
|
-
`Invalid major version '${majorVersion}'. Must be a number
|
|
18
|
+
`Invalid major version '${majorVersion}'. Must be a number.`,
|
|
18
19
|
);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const majorVersions = [
|
|
22
23
|
...new Set(
|
|
23
|
-
versions.map((appVersion) => Number(appVersion.version.split('.')[0]))
|
|
24
|
+
versions.map((appVersion) => Number(appVersion.version.split('.')[0])),
|
|
24
25
|
),
|
|
25
26
|
];
|
|
26
27
|
// Finds the current version in package.json.
|
|
@@ -30,14 +31,14 @@ class ClearCacheCommand extends BaseCommand {
|
|
|
30
31
|
if (selectedMajorVersion === null) {
|
|
31
32
|
selectedMajorVersion = await this._promptForMajorVersionSelection(
|
|
32
33
|
majorVersions,
|
|
33
|
-
currentVersion
|
|
34
|
+
currentVersion,
|
|
34
35
|
);
|
|
35
36
|
} else {
|
|
36
37
|
if (!majorVersions.includes(selectedMajorVersion)) {
|
|
37
38
|
throw new Error(
|
|
38
39
|
`This integration does not have any versions on major version '${selectedMajorVersion}'. Valid versions are: ${majorVersions.join(
|
|
39
|
-
', '
|
|
40
|
-
)}
|
|
40
|
+
', ',
|
|
41
|
+
)}`,
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -45,9 +46,9 @@ class ClearCacheCommand extends BaseCommand {
|
|
|
45
46
|
if (
|
|
46
47
|
!(await this.confirm(
|
|
47
48
|
`Are you sure you want to clear all cache data for major version '${cyan(
|
|
48
|
-
selectedMajorVersion
|
|
49
|
+
selectedMajorVersion,
|
|
49
50
|
)}'?`,
|
|
50
|
-
true
|
|
51
|
+
true,
|
|
51
52
|
))
|
|
52
53
|
) {
|
|
53
54
|
this.log('\ncancelled');
|
|
@@ -86,19 +87,18 @@ class ClearCacheCommand extends BaseCommand {
|
|
|
86
87
|
return await this.promptWithList(
|
|
87
88
|
"Which major version's cache data would you like to delete?",
|
|
88
89
|
majorVersionChoices,
|
|
89
|
-
{ default: currentMajorVersion }
|
|
90
|
+
{ default: currentMajorVersion },
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
ClearCacheCommand.args =
|
|
95
|
-
{
|
|
96
|
-
name: 'majorVersion',
|
|
95
|
+
ClearCacheCommand.args = {
|
|
96
|
+
majorVersion: Args.string({
|
|
97
97
|
description:
|
|
98
98
|
'(Optional) The cache data will be deleted for this major version. If not provided, you must pick from a list of major versions for this integration.',
|
|
99
99
|
required: false,
|
|
100
|
-
},
|
|
101
|
-
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
102
|
ClearCacheCommand.flags = buildFlags();
|
|
103
103
|
ClearCacheCommand.description = `Clear the cache data for a major version.
|
|
104
104
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const ZapierBaseCommand = require('../../ZapierBaseCommand');
|
|
2
|
+
const { Args, Flags } = require('@oclif/core');
|
|
2
3
|
const { createCanary, listCanaries } = require('../../../utils/api');
|
|
3
4
|
const { buildFlags } = require('../../buildFlags');
|
|
4
|
-
const { flags } = require('@oclif/command');
|
|
5
5
|
|
|
6
6
|
class CanaryCreateCommand extends ZapierBaseCommand {
|
|
7
7
|
async perform() {
|
|
@@ -16,8 +16,10 @@ class CanaryCreateCommand extends ZapierBaseCommand {
|
|
|
16
16
|
const activeCanaries = await listCanaries();
|
|
17
17
|
if (activeCanaries.objects.length > 0) {
|
|
18
18
|
const existingCanary = activeCanaries.objects[0];
|
|
19
|
-
const secondsRemaining =
|
|
20
|
-
|
|
19
|
+
const secondsRemaining =
|
|
20
|
+
existingCanary.until_timestamp - Math.floor(Date.now() / 1000);
|
|
21
|
+
this
|
|
22
|
+
.log(`A canary deployment already exists from version ${existingCanary.from_version} to version ${existingCanary.to_version}, there are ${secondsRemaining} seconds remaining.
|
|
21
23
|
|
|
22
24
|
If you would like to stop this canary now, run \`zapier canary:delete ${existingCanary.from_version} ${existingCanary.to_version}\``);
|
|
23
25
|
return;
|
|
@@ -27,8 +29,7 @@ If you would like to stop this canary now, run \`zapier canary:delete ${existing
|
|
|
27
29
|
- From version: ${versionFrom}
|
|
28
30
|
- To version: ${versionTo}
|
|
29
31
|
- Traffic amount: ${percent}%
|
|
30
|
-
- Duration: ${duration} seconds`
|
|
31
|
-
);
|
|
32
|
+
- Duration: ${duration} seconds`);
|
|
32
33
|
|
|
33
34
|
await createCanary(versionFrom, versionTo, percent, duration);
|
|
34
35
|
|
|
@@ -41,7 +42,7 @@ If you would like to stop this canary now, run \`zapier canary:delete ${existing
|
|
|
41
42
|
this.throwForInvalidVersion(versionTo);
|
|
42
43
|
|
|
43
44
|
if (versionFrom === versionTo) {
|
|
44
|
-
this.error('`VERSIONFROM` and `VERSIONTO` can not be the same')
|
|
45
|
+
this.error('`VERSIONFROM` and `VERSIONTO` can not be the same');
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -60,23 +61,29 @@ If you would like to stop this canary now, run \`zapier canary:delete ${existing
|
|
|
60
61
|
|
|
61
62
|
CanaryCreateCommand.flags = buildFlags({
|
|
62
63
|
commandFlags: {
|
|
63
|
-
percent:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
percent: Flags.integer({
|
|
65
|
+
char: 'p',
|
|
66
|
+
description: 'Percent of traffic to route to new version',
|
|
67
|
+
required: true,
|
|
68
|
+
}),
|
|
69
|
+
duration: Flags.integer({
|
|
70
|
+
char: 'd',
|
|
71
|
+
description: 'Duration of the canary in seconds',
|
|
72
|
+
required: true,
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
67
76
|
|
|
68
|
-
CanaryCreateCommand.args =
|
|
69
|
-
{
|
|
70
|
-
name: 'versionFrom',
|
|
71
|
-
required: true,
|
|
77
|
+
CanaryCreateCommand.args = {
|
|
78
|
+
versionFrom: Args.string({
|
|
72
79
|
description: 'Version to route traffic from',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'versionTo',
|
|
76
80
|
required: true,
|
|
81
|
+
}),
|
|
82
|
+
versionTo: Args.string({
|
|
77
83
|
description: 'Version to canary traffic to',
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
required: true,
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
80
87
|
|
|
81
88
|
CanaryCreateCommand.description = `Create a new canary deployment, diverting a specified percentage of traffic from one version to another for a specified duration.
|
|
82
89
|
|
|
@@ -88,7 +95,7 @@ Note: this is similar to \`zapier migrate\` but different in that this is tempor
|
|
|
88
95
|
|
|
89
96
|
CanaryCreateCommand.examples = [
|
|
90
97
|
'zapier canary:create 1.0.0 1.1.0 -p 25 -d 720',
|
|
91
|
-
'zapier canary:create 2.0.0 2.1.0 --percent 50 --duration 300'
|
|
98
|
+
'zapier canary:create 2.0.0 2.1.0 --percent 50 --duration 300',
|
|
92
99
|
];
|
|
93
100
|
CanaryCreateCommand.skipValidInstallCheck = true;
|
|
94
101
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const ZapierBaseCommand = require('../../ZapierBaseCommand');
|
|
2
|
+
const { Args } = require('@oclif/core');
|
|
2
3
|
const { deleteCanary, listCanaries } = require('../../../utils/api');
|
|
3
4
|
|
|
4
5
|
class CanaryDeleteCommand extends ZapierBaseCommand {
|
|
@@ -7,19 +8,28 @@ class CanaryDeleteCommand extends ZapierBaseCommand {
|
|
|
7
8
|
|
|
8
9
|
this.validateVersions(versionFrom, versionTo);
|
|
9
10
|
|
|
10
|
-
const existingCanary = await this.findExistingCanary(
|
|
11
|
+
const existingCanary = await this.findExistingCanary(
|
|
12
|
+
versionFrom,
|
|
13
|
+
versionTo,
|
|
14
|
+
);
|
|
11
15
|
if (!existingCanary) {
|
|
12
|
-
this.log(
|
|
16
|
+
this.log(
|
|
17
|
+
`There is no active canary from version ${versionFrom} to version ${versionTo}`,
|
|
18
|
+
);
|
|
13
19
|
return;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
|
-
const confirmed = await this.confirm(
|
|
22
|
+
const confirmed = await this.confirm(
|
|
23
|
+
`Are you sure you want to delete the canary from ${versionFrom} to ${versionTo}?`,
|
|
24
|
+
);
|
|
17
25
|
if (!confirmed) {
|
|
18
26
|
this.log('Canary deletion cancelled.');
|
|
19
27
|
return;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
this.startSpinner(
|
|
30
|
+
this.startSpinner(
|
|
31
|
+
`Deleting active canary from ${versionFrom} to ${versionTo}`,
|
|
32
|
+
);
|
|
23
33
|
await deleteCanary(versionFrom, versionTo);
|
|
24
34
|
this.stopSpinner();
|
|
25
35
|
this.log('Canary deployment deleted successfully.');
|
|
@@ -27,7 +37,9 @@ class CanaryDeleteCommand extends ZapierBaseCommand {
|
|
|
27
37
|
|
|
28
38
|
async findExistingCanary(versionFrom, versionTo) {
|
|
29
39
|
const activeCanaries = await listCanaries();
|
|
30
|
-
return activeCanaries.objects.find(
|
|
40
|
+
return activeCanaries.objects.find(
|
|
41
|
+
(c) => c.from_version === versionFrom && c.to_version === versionTo,
|
|
42
|
+
);
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
validateVersions(versionFrom, versionTo) {
|
|
@@ -35,25 +47,23 @@ class CanaryDeleteCommand extends ZapierBaseCommand {
|
|
|
35
47
|
this.throwForInvalidVersion(versionTo);
|
|
36
48
|
|
|
37
49
|
if (versionFrom === versionTo) {
|
|
38
|
-
this.error('Versions can not be the same')
|
|
50
|
+
this.error('Versions can not be the same');
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
CanaryDeleteCommand.args =
|
|
44
|
-
{
|
|
45
|
-
name: 'versionFrom',
|
|
46
|
-
required: true,
|
|
55
|
+
CanaryDeleteCommand.args = {
|
|
56
|
+
versionFrom: Args.string({
|
|
47
57
|
description: 'Version to route traffic from',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'versionTo',
|
|
51
58
|
required: true,
|
|
59
|
+
}),
|
|
60
|
+
versionTo: Args.string({
|
|
52
61
|
description: 'Version canary traffic is routed to',
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
required: true,
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
55
65
|
CanaryDeleteCommand.description = 'Delete an active canary deployment';
|
|
56
66
|
CanaryDeleteCommand.examples = ['zapier canary:delete 1.0.0 1.1.0'];
|
|
57
67
|
CanaryDeleteCommand.skipValidInstallCheck = true;
|
|
58
68
|
|
|
59
|
-
module.exports = CanaryDeleteCommand;
|
|
69
|
+
module.exports = CanaryDeleteCommand;
|
|
@@ -7,11 +7,11 @@ class CanaryListCommand extends ZapierBaseCommand {
|
|
|
7
7
|
async perform() {
|
|
8
8
|
const canaries = await listCanaries();
|
|
9
9
|
|
|
10
|
-
const formattedCanaries = canaries.objects.map(c => ({
|
|
10
|
+
const formattedCanaries = canaries.objects.map((c) => ({
|
|
11
11
|
from_version: c.from_version,
|
|
12
12
|
to_version: c.to_version,
|
|
13
13
|
percent: c.percent,
|
|
14
|
-
seconds_remaining: c.until_timestamp - Math.floor(Date.now() / 1000)
|
|
14
|
+
seconds_remaining: c.until_timestamp - Math.floor(Date.now() / 1000),
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
17
|
this.log(bold('Active Canaries') + '\n');
|
|
@@ -23,16 +23,14 @@ class CanaryListCommand extends ZapierBaseCommand {
|
|
|
23
23
|
['Traffic Amount', 'percent'],
|
|
24
24
|
['Seconds Remaining', 'seconds_remaining'],
|
|
25
25
|
],
|
|
26
|
-
emptyMessage: grey(
|
|
27
|
-
`No active canary deployments found.`
|
|
28
|
-
),
|
|
26
|
+
emptyMessage: grey(`No active canary deployments found.`),
|
|
29
27
|
});
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
CanaryListCommand.flags = buildFlags({ opts: { format: true } });
|
|
34
32
|
CanaryListCommand.description = 'List all active canary deployments';
|
|
35
|
-
CanaryListCommand.examples = ['zapier canary:list']
|
|
33
|
+
CanaryListCommand.examples = ['zapier canary:list'];
|
|
36
34
|
CanaryListCommand.skipValidInstallCheck = true;
|
|
37
35
|
|
|
38
|
-
module.exports = CanaryListCommand;
|
|
36
|
+
module.exports = CanaryListCommand;
|