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.
Files changed (73) hide show
  1. package/oclif.manifest.json +2316 -1
  2. package/package.json +43 -33
  3. package/scaffold/create.template.ts +64 -0
  4. package/scaffold/resource.template.ts +119 -0
  5. package/scaffold/search.template.ts +63 -0
  6. package/scaffold/test.template.ts +18 -0
  7. package/scaffold/trigger.template.ts +58 -0
  8. package/src/bin/run +4 -4
  9. package/src/bin/run.cmd +0 -3
  10. package/src/generators/index.js +11 -11
  11. package/src/index.js +1 -1
  12. package/src/oclif/ZapierBaseCommand.js +51 -44
  13. package/src/oclif/buildFlags.js +14 -16
  14. package/src/oclif/commands/analytics.js +6 -6
  15. package/src/oclif/commands/build.js +6 -6
  16. package/src/oclif/commands/cache/clear.js +13 -13
  17. package/src/oclif/commands/canary/create.js +27 -20
  18. package/src/oclif/commands/canary/delete.js +26 -16
  19. package/src/oclif/commands/canary/list.js +5 -7
  20. package/src/oclif/commands/convert.js +16 -16
  21. package/src/oclif/commands/delete/version.js +6 -6
  22. package/src/oclif/commands/deprecate.js +10 -11
  23. package/src/oclif/commands/describe.js +5 -5
  24. package/src/oclif/commands/env/get.js +5 -5
  25. package/src/oclif/commands/env/set.js +11 -12
  26. package/src/oclif/commands/env/unset.js +9 -10
  27. package/src/oclif/commands/init.js +12 -13
  28. package/src/oclif/commands/invoke.js +67 -69
  29. package/src/oclif/commands/jobs.js +1 -1
  30. package/src/oclif/commands/link.js +2 -2
  31. package/src/oclif/commands/login.js +15 -15
  32. package/src/oclif/commands/logout.js +1 -1
  33. package/src/oclif/commands/logs.js +9 -9
  34. package/src/oclif/commands/migrate.js +19 -22
  35. package/src/oclif/commands/promote.js +25 -27
  36. package/src/oclif/commands/push.js +2 -2
  37. package/src/oclif/commands/register.js +31 -32
  38. package/src/oclif/commands/scaffold.js +112 -106
  39. package/src/oclif/commands/team/add.js +12 -15
  40. package/src/oclif/commands/team/get.js +2 -2
  41. package/src/oclif/commands/team/remove.js +6 -6
  42. package/src/oclif/commands/test.js +8 -8
  43. package/src/oclif/commands/upload.js +1 -1
  44. package/src/oclif/commands/users/add.js +9 -11
  45. package/src/oclif/commands/users/get.js +7 -7
  46. package/src/oclif/commands/users/links.js +4 -4
  47. package/src/oclif/commands/users/remove.js +8 -9
  48. package/src/oclif/commands/validate.js +29 -21
  49. package/src/oclif/commands/versions.js +26 -1
  50. package/src/oclif/hooks/checkValidNodeVersion.js +1 -1
  51. package/src/oclif/hooks/deprecated.js +1 -1
  52. package/src/oclif/hooks/getAppRegistrationFieldChoices.js +4 -4
  53. package/src/oclif/hooks/renderMarkdownHelp.js +1 -2
  54. package/src/oclif/hooks/versionInfo.js +2 -2
  55. package/src/utils/analytics.js +4 -4
  56. package/src/utils/api.js +26 -29
  57. package/src/utils/ast.js +112 -11
  58. package/src/utils/auth-files-codegen.js +102 -99
  59. package/src/utils/build.js +27 -28
  60. package/src/utils/changelog.js +1 -1
  61. package/src/utils/check-missing-app-info.js +2 -2
  62. package/src/utils/convert.js +26 -20
  63. package/src/utils/credentials.js +1 -1
  64. package/src/utils/display.js +31 -8
  65. package/src/utils/files.js +3 -3
  66. package/src/utils/ignore.js +2 -2
  67. package/src/utils/local.js +1 -1
  68. package/src/utils/metadata.js +1 -1
  69. package/src/utils/misc.js +21 -22
  70. package/src/utils/promisify.js +1 -1
  71. package/src/utils/scaffold.js +293 -40
  72. package/src/utils/team.js +3 -3
  73. package/src/utils/xdg.js +3 -3
@@ -1,3 +1,5 @@
1
+ const { Args, Flags } = require('@oclif/core');
2
+
1
3
  const BaseCommand = require('../ZapierBaseCommand');
2
4
  const { buildFlags } = require('../buildFlags');
3
5
 
@@ -6,8 +8,6 @@ const { convertApp } = require('../../utils/convert');
6
8
  const { isExistingEmptyDir } = require('../../utils/files');
7
9
  const { initApp } = require('../../utils/init');
8
10
 
9
- const { flags } = require('@oclif/command');
10
-
11
11
  class ConvertCommand extends BaseCommand {
12
12
  generateCreateFunc(appId, version) {
13
13
  return async (tempAppDir) => {
@@ -23,7 +23,7 @@ class ConvertCommand extends BaseCommand {
23
23
 
24
24
  if (!versionInfo.definition_override) {
25
25
  this.error(
26
- `Integration ${appId} @ ${version} is already a CLI integration and can't be converted. Instead, pick a version that was created using the Visual Builder.`
26
+ `Integration ${appId} @ ${version} is already a CLI integration and can't be converted. Instead, pick a version that was created using the Visual Builder.`,
27
27
  );
28
28
  }
29
29
  this.stopSpinner();
@@ -32,7 +32,7 @@ class ConvertCommand extends BaseCommand {
32
32
  } catch (e) {
33
33
  if (e.status === 404) {
34
34
  this.error(
35
- `Visual Builder integration ${appId} @ ${version} not found. Double check the integration id and version.`
35
+ `Visual Builder integration ${appId} @ ${version} not found. Double check the integration id and version.`,
36
36
  );
37
37
  }
38
38
  this.error(e.json.errors[0]);
@@ -45,7 +45,7 @@ class ConvertCommand extends BaseCommand {
45
45
  const { version } = this.flags;
46
46
  if (!appId) {
47
47
  this.error(
48
- 'You must provide an integrationId. See zapier convert --help for more info.'
48
+ 'You must provide an integrationId. See zapier convert --help for more info.',
49
49
  );
50
50
  }
51
51
 
@@ -60,23 +60,22 @@ class ConvertCommand extends BaseCommand {
60
60
  }
61
61
  }
62
62
 
63
- ConvertCommand.args = [
64
- {
65
- name: 'integrationId',
66
- required: true,
63
+ ConvertCommand.args = {
64
+ integrationId: Args.string({
67
65
  description: `To get the integration/app ID, go to "https://developer.zapier.com", click on an integration, and copy the number directly after "/app/" in the URL.`,
68
- parse: (input) => Number(input),
69
- },
70
- {
71
- name: 'path',
72
66
  required: true,
67
+ parse: (input) => Number(input),
68
+ }),
69
+ path: Args.string({
73
70
  description:
74
71
  'Relative to your current path - IE: `.` for current directory.',
75
- },
76
- ];
72
+ required: true,
73
+ }),
74
+ };
75
+
77
76
  ConvertCommand.flags = buildFlags({
78
77
  commandFlags: {
79
- version: flags.string({
78
+ version: Flags.string({
80
79
  char: 'v',
81
80
  description:
82
81
  'Convert a specific version. Required when converting a Visual Builder integration.',
@@ -84,6 +83,7 @@ ConvertCommand.flags = buildFlags({
84
83
  }),
85
84
  },
86
85
  });
86
+
87
87
  ConvertCommand.description = `Convert a Visual Builder integration to a CLI integration.
88
88
 
89
89
  The resulting CLI integration will be identical to its Visual Builder version and ready to push and use immediately!
@@ -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 { callAPI } = require('../../../utils/api');
4
5
 
@@ -17,13 +18,12 @@ class DeleteVersionCommand extends BaseCommand {
17
18
  }
18
19
  }
19
20
 
20
- DeleteVersionCommand.args = [
21
- {
22
- name: 'version',
23
- required: true,
21
+ DeleteVersionCommand.args = {
22
+ version: Args.string({
24
23
  description: `Specify the version to delete. It must have no users or Zaps.`,
25
- },
26
- ];
24
+ required: true,
25
+ }),
26
+ };
27
27
  DeleteVersionCommand.flags = buildFlags();
28
28
  DeleteVersionCommand.skipValidInstallCheck = true;
29
29
  DeleteVersionCommand.description = `Delete a specific version of your integration.
@@ -1,4 +1,5 @@
1
1
  const BaseCommand = require('../ZapierBaseCommand');
2
+ const { Args } = require('@oclif/core');
2
3
  const { buildFlags } = require('../buildFlags');
3
4
 
4
5
  const { callAPI } = require('../../utils/api');
@@ -8,7 +9,7 @@ class DeprecateCommand extends BaseCommand {
8
9
  const app = await this.getWritableApp();
9
10
  const { version, date } = this.args;
10
11
  this.log(
11
- `Preparing to deprecate version ${version} your app "${app.title}".\n`
12
+ `Preparing to deprecate version ${version} your app "${app.title}".\n`,
12
13
  );
13
14
  const url = `/apps/${app.id}/versions/${version}/deprecate`;
14
15
  this.startSpinner(`Deprecating ${version}`);
@@ -20,25 +21,23 @@ class DeprecateCommand extends BaseCommand {
20
21
  });
21
22
  this.stopSpinner();
22
23
  this.log(
23
- `\nWe'll let users know that this version is no longer recommended and will cease to work on ${date}.`
24
+ `\nWe'll let users know that this version is no longer recommended and will cease to work on ${date}.`,
24
25
  );
25
26
  }
26
27
  }
27
28
 
28
29
  DeprecateCommand.flags = buildFlags();
29
- DeprecateCommand.args = [
30
- {
31
- name: 'version',
30
+ DeprecateCommand.args = {
31
+ version: Args.string({
32
32
  description: 'The version to deprecate.',
33
33
  required: true,
34
- },
35
- {
36
- name: 'date',
37
- required: true,
34
+ }),
35
+ date: Args.string({
38
36
  description:
39
37
  'The date (YYYY-MM-DD) when Zapier will make the specified version unavailable.',
40
- },
41
- ];
38
+ required: true,
39
+ }),
40
+ };
42
41
  DeprecateCommand.examples = ['zapier deprecate 1.2.3 2011-10-01'];
43
42
  DeprecateCommand.description = `Mark a non-production version of your integration as deprecated, with removal by a certain date.
44
43
 
@@ -95,7 +95,7 @@ class DescribeCommand extends BaseCommand {
95
95
  authentication.redirect_uri = version.oauth_redirect_uri;
96
96
  } else {
97
97
  authentication.redirect_uri = grey(
98
- 'Run `zapier push` to see the redirect_uri.'
98
+ 'Run `zapier push` to see the redirect_uri.',
99
99
  );
100
100
  }
101
101
  }
@@ -134,7 +134,7 @@ class DescribeCommand extends BaseCommand {
134
134
  .map((method) => method({ key: resource.key }))
135
135
  .filter((path) => _.has(definition, path))
136
136
  .join('\n'),
137
- })
137
+ }),
138
138
  );
139
139
  this.logTitle('Resources');
140
140
  this.logTable({
@@ -153,7 +153,7 @@ class DescribeCommand extends BaseCommand {
153
153
  const rows = _.values(definition[type]).map((row) => {
154
154
  // add possible action paths
155
155
  let paths = actionTemplates.map((method) =>
156
- method({ type, key: row.key })
156
+ method({ type, key: row.key }),
157
157
  );
158
158
 
159
159
  // add possible resource paths
@@ -161,7 +161,7 @@ class DescribeCommand extends BaseCommand {
161
161
  const key = row.operation.resource.split('.')[0];
162
162
  const resourceTemplates = makeResourceTemplates(typeMap[type]);
163
163
  paths = paths.concat(
164
- resourceTemplates.map((method) => method({ key }))
164
+ resourceTemplates.map((method) => method({ key })),
165
165
  );
166
166
  }
167
167
 
@@ -182,7 +182,7 @@ class DescribeCommand extends BaseCommand {
182
182
  ['Available Methods', 'paths', grey('n/a')],
183
183
  ],
184
184
  emptyMessage: grey(
185
- `Nothing found for ${type}. Use the \`zapier scaffold\` command to add one.`
185
+ `Nothing found for ${type}. Use the \`zapier scaffold\` command to add one.`,
186
186
  ),
187
187
  });
188
188
 
@@ -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 { listEnv } = require('../../../utils/api');
4
5
 
@@ -22,13 +23,12 @@ class GetEnvCommand extends BaseCommand {
22
23
  }
23
24
  }
24
25
 
25
- GetEnvCommand.args = [
26
- {
27
- name: 'version',
26
+ GetEnvCommand.args = {
27
+ version: Args.string({
28
28
  description: 'The version to get the environment for.',
29
29
  required: true,
30
- },
31
- ];
30
+ }),
31
+ };
32
32
  GetEnvCommand.flags = buildFlags({ opts: { format: true } });
33
33
  GetEnvCommand.description = `Get environment variables for a version.`;
34
34
  GetEnvCommand.examples = [`zapier env:get 1.2.3`];
@@ -1,3 +1,4 @@
1
+ const { Args } = require('@oclif/core');
1
2
  const { cyan } = require('colors/safe');
2
3
  const { omit } = require('lodash');
3
4
 
@@ -7,7 +8,7 @@ const { callAPI } = require('../../../utils/api');
7
8
 
8
9
  const successMessage = (version) =>
9
10
  `Successfully wrote the following to the environment of version ${cyan(
10
- version
11
+ version,
11
12
  )}:`;
12
13
 
13
14
  class SetEnvCommand extends BaseCommand {
@@ -19,7 +20,7 @@ class SetEnvCommand extends BaseCommand {
19
20
 
20
21
  if (!valuesToSet.length) {
21
22
  this.error(
22
- 'Must specify at least one key-value pair to set (like `SOME_KEY=1234`)'
23
+ 'Must specify at least one key-value pair to set (like `SOME_KEY=1234`)',
23
24
  );
24
25
  }
25
26
 
@@ -39,7 +40,7 @@ class SetEnvCommand extends BaseCommand {
39
40
  const app = await this.getWritableApp();
40
41
  if (!app.all_versions.includes(version)) {
41
42
  this.error(
42
- `Version ${version} doesn't exist on integration "${app.title}"`
43
+ `Version ${version} doesn't exist on integration "${app.title}"`,
43
44
  );
44
45
  }
45
46
 
@@ -53,7 +54,7 @@ class SetEnvCommand extends BaseCommand {
53
54
  body: payload,
54
55
  method: 'POST',
55
56
  },
56
- true
57
+ true,
57
58
  );
58
59
 
59
60
  this.log(successMessage(version));
@@ -73,19 +74,17 @@ class SetEnvCommand extends BaseCommand {
73
74
  }
74
75
  }
75
76
 
76
- SetEnvCommand.args = [
77
- {
78
- name: 'version',
77
+ SetEnvCommand.args = {
78
+ version: Args.string({
79
79
  description:
80
80
  'The version to set the environment for. Values are copied forward when a new version is created, but this command will only ever affect the specified version.',
81
81
  required: true,
82
- },
83
- {
84
- name: 'key-value pairs...',
82
+ }),
83
+ 'key-value pairs...': Args.string({
85
84
  description:
86
85
  'The key-value pairs to set. Keys are case-insensitive. Each pair should be space separated and pairs should be separated by an `=`. For example: `A=123 B=456`',
87
- },
88
- ];
86
+ }),
87
+ };
89
88
  SetEnvCommand.flags = buildFlags();
90
89
  SetEnvCommand.description = `Set environment variables for a version.`;
91
90
  SetEnvCommand.examples = [`zapier env:set 1.2.3 SECRET=12345 OTHER=4321`];
@@ -1,3 +1,4 @@
1
+ const { Args } = require('@oclif/core');
1
2
  const { cyan } = require('colors/safe');
2
3
 
3
4
  const BaseCommand = require('../../ZapierBaseCommand');
@@ -6,7 +7,7 @@ const { callAPI } = require('../../../utils/api');
6
7
 
7
8
  const successMessage = (version) =>
8
9
  `Successfully unset the following keys in the environment of version ${cyan(
9
- version
10
+ version,
10
11
  )} (if they existed):`;
11
12
 
12
13
  class UnsetEnvCommand extends BaseCommand {
@@ -36,7 +37,7 @@ class UnsetEnvCommand extends BaseCommand {
36
37
  const app = await this.getWritableApp();
37
38
  if (!app.all_versions.includes(version)) {
38
39
  this.error(
39
- `Version ${version} doesn't exist on integration "${app.title}"`
40
+ `Version ${version} doesn't exist on integration "${app.title}"`,
40
41
  );
41
42
  }
42
43
 
@@ -54,17 +55,15 @@ class UnsetEnvCommand extends BaseCommand {
54
55
  }
55
56
  }
56
57
 
57
- UnsetEnvCommand.args = [
58
- {
59
- name: 'version',
58
+ UnsetEnvCommand.args = {
59
+ version: Args.string({
60
60
  description: 'The version to set the environment for.',
61
61
  required: true,
62
- },
63
- {
64
- name: 'keys...',
62
+ }),
63
+ 'keys...': Args.string({
65
64
  description: 'The keys to unset. Keys are case-insensitive.',
66
- },
67
- ];
65
+ }),
66
+ };
68
67
  UnsetEnvCommand.flags = buildFlags();
69
68
  UnsetEnvCommand.description = `Unset environment variables for a version.`;
70
69
  UnsetEnvCommand.examples = [`zapier env:unset 1.2.3 SECRET OTHER`];
@@ -1,6 +1,6 @@
1
1
  const { join } = require('path');
2
2
 
3
- const { flags } = require('@oclif/command');
3
+ const { Args, Flags } = require('@oclif/core');
4
4
  const yeoman = require('yeoman-environment');
5
5
 
6
6
  const BaseCommand = require('../ZapierBaseCommand');
@@ -15,31 +15,30 @@ class InitCommand extends BaseCommand {
15
15
  const env = yeoman.createEnv();
16
16
  env.registerStub(ProjectGenerator, 'zapier:integration');
17
17
 
18
- env.run('zapier:integration', { path, template }, () => {
19
- this.log();
20
- this.log(`A new integration has been created in directory "${path}".`);
21
- this.log(`Read all about it in "${join(path, 'README.md')}".`);
22
- });
18
+ await env.run('zapier:integration', { path, template });
19
+
20
+ this.log();
21
+ this.log(`A new integration has been created in directory "${path}".`);
22
+ this.log(`Read all about it in "${join(path, 'README.md')}".`);
23
23
  }
24
24
  }
25
25
 
26
26
  InitCommand.flags = buildFlags({
27
27
  commandFlags: {
28
- template: flags.string({
28
+ template: Flags.string({
29
29
  char: 't',
30
30
  description: 'The template to start your integration with.',
31
31
  options: TEMPLATE_CHOICES,
32
32
  }),
33
33
  },
34
34
  });
35
- InitCommand.args = [
36
- {
37
- name: 'path',
38
- required: true,
35
+ InitCommand.args = {
36
+ path: Args.string({
39
37
  description:
40
38
  "Where to create the new integration. If the directory doesn't exist, it will be created. If the directory isn't empty, we'll ask for confirmation",
41
- },
42
- ];
39
+ required: true,
40
+ }),
41
+ };
43
42
  InitCommand.examples = [
44
43
  'zapier init myapp',
45
44
  'zapier init ./path/myapp --template oauth2',