zapier-platform-cli 11.1.1 → 11.3.1

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.
@@ -46,10 +46,14 @@ class MigrateCommand extends BaseCommand {
46
46
  }
47
47
 
48
48
  const body = {
49
- percent,
49
+ job: {
50
+ name: 'migrate',
51
+ from_version: fromVersion,
52
+ to_version: toVersion,
53
+ email: user,
54
+ },
50
55
  };
51
56
  if (user) {
52
- body.user = user;
53
57
  this.startSpinner(
54
58
  `Starting migration from ${fromVersion} to ${toVersion} for ${user}`
55
59
  );
@@ -58,8 +62,12 @@ class MigrateCommand extends BaseCommand {
58
62
  `Starting migration from ${fromVersion} to ${toVersion} for ${percent}%`
59
63
  );
60
64
  }
65
+ if (percent) {
66
+ body.job.percent_human = percent;
67
+ }
68
+
69
+ const url = `/apps/${app.id}/migrations`;
61
70
 
62
- const url = `/apps/${app.id}/versions/${fromVersion}/migrate-to/${toVersion}`;
63
71
  try {
64
72
  await callAPI(url, { method: 'POST', body });
65
73
  } finally {
@@ -110,7 +118,7 @@ Start a migration to move users between different versions of your integration.
110
118
 
111
119
  Only use this command to migrate users between non-breaking versions, use \`zapier deprecate\` if you have breaking changes!
112
120
 
113
- Migration time varies based on the number of affected Zaps. Be patient and check \`zapier history\` to track the status.
121
+ Migration time varies based on the number of affected Zaps. Be patient and check \`zapier jobs\` to track the status. Or use \`zapier history\` if you want to see older jobs.
114
122
 
115
123
  Since a migration is only for non-breaking changes, users are not emailed about the update/migration. It will be a transparent process for them.
116
124
 
@@ -60,19 +60,22 @@ class PromoteCommand extends BaseCommand {
60
60
  `Preparing to promote version ${version} of your integration "${app.title}".`
61
61
  );
62
62
 
63
- const body = {};
64
- if (changelog) {
65
- body.changelog = changelog;
66
- }
63
+ const body = {
64
+ job: {
65
+ name: 'promote',
66
+ to_version: version,
67
+ changelog,
68
+ },
69
+ };
67
70
 
68
71
  this.startSpinner(`Verifying and promoting ${version}`);
69
72
 
70
- const url = `/apps/${app.id}/versions/${version}/promote/production`;
73
+ const url = `/apps/${app.id}/migrations`;
71
74
  try {
72
75
  await callAPI(
73
76
  url,
74
77
  {
75
- method: 'PUT',
78
+ method: 'POST',
76
79
  body,
77
80
  },
78
81
  true
@@ -120,7 +123,7 @@ PromoteCommand.args = [
120
123
  {
121
124
  name: 'version',
122
125
  required: true,
123
- description: 'The version you want promote.',
126
+ description: 'The version you want to promote.',
124
127
  },
125
128
  ];
126
129
 
@@ -136,6 +139,8 @@ Promote an integration version into production (non-private) rotation, which mea
136
139
 
137
140
  Promotes are an inherently safe operation for all existing users of your integration.
138
141
 
139
- If your integration is private and passes our integration checks, this will give you a URL to a form where you can fill in additional information for your integration to go public. After reviewing, the Zapier team will approve to make it public if there are no issues or decline with feedback.`;
142
+ If your integration is private and passes our integration checks, this will give you a URL to a form where you can fill in additional information for your integration to go public. After reviewing, the Zapier team will approve to make it public if there are no issues or decline with feedback.
143
+
144
+ Check \`zapier jobs\` to track the status of the promotion. Or use \`zapier history\` if you want to see older jobs.`;
140
145
 
141
146
  module.exports = PromoteCommand;
@@ -1,5 +1,3 @@
1
- const path = require('path');
2
- const { pathExists } = require('fs-extra');
3
1
  const { flags } = require('@oclif/command');
4
2
  const chalk = require('chalk');
5
3
 
@@ -9,6 +7,7 @@ const constants = require('../../constants');
9
7
  const { buildFlags } = require('../buildFlags');
10
8
  const { readCredentials } = require('../../utils/api');
11
9
  const { runCommand } = require('../../utils/misc');
10
+ const { getPackageManager } = require('../../utils/package-manager');
12
11
 
13
12
  class TestCommand extends BaseCommand {
14
13
  async perform() {
@@ -35,9 +34,7 @@ class TestCommand extends BaseCommand {
35
34
 
36
35
  const env = Object.assign({}, process.env, extraEnv);
37
36
 
38
- const useYarn =
39
- this.flags.yarn ||
40
- (await pathExists(path.join(process.cwd(), 'yarn.lock')));
37
+ const packageManager = await getPackageManager(this.flags);
41
38
 
42
39
  const passthroughArgs = this.argv.includes('--')
43
40
  ? this.argv.slice(this.argv.indexOf('--') + 1)
@@ -47,21 +44,22 @@ class TestCommand extends BaseCommand {
47
44
  'run',
48
45
  '--silent',
49
46
  'test',
50
- useYarn ? '' : '--', // yarn gives a warning if we include `--`
47
+ packageManager.useDoubleHyphenBeforeArgs ? '--' : '',
51
48
  ...passthroughArgs,
52
49
  ].filter(Boolean);
53
- const packageManager = useYarn ? 'yarn' : 'npm';
54
50
 
55
51
  this.log('Running test suite with the following command:');
56
52
  // some extra formatting happen w/ quotes so it's clear when they're already like that in the array,
57
53
  // but the space-joined array made that unclear
58
54
  this.log(
59
- `\n ${chalk.cyanBright.bold(packageManager)} ${chalk.cyanBright(
55
+ `\n ${chalk.cyanBright.bold(
56
+ packageManager.executable
57
+ )} ${chalk.cyanBright(
60
58
  argv.map((a) => (a.includes(' ') ? `"${a}"` : a)).join(' ')
61
59
  )}\n`
62
60
  );
63
61
 
64
- const output = await runCommand(packageManager, argv, {
62
+ const output = await runCommand(packageManager.executable, argv, {
65
63
  stdio: 'inherit',
66
64
  env,
67
65
  });
@@ -81,6 +79,10 @@ TestCommand.flags = buildFlags({
81
79
  description:
82
80
  "Use `yarn` instead of `npm`. This happens automatically if there's a `yarn.lock` file, but you can manually force `yarn` if you run tests from a sub-directory.",
83
81
  }),
82
+ pnpm: flags.boolean({
83
+ description:
84
+ "Use `pnpm` instead of `npm`. This happens automatically if there's a `pnpm-lock.yaml` file, but you can manually force `pnpm` if you run tests from a sub-directory.",
85
+ }),
84
86
  },
85
87
  });
86
88
 
@@ -1,5 +1,5 @@
1
1
  const chalk = require('chalk');
2
- const marked = require('marked');
2
+ const { marked } = require('marked');
3
3
  const TerminalRenderer = require('marked-terminal');
4
4
  const { stdtermwidth } = require('@oclif/plugin-help/lib/screen');
5
5
 
@@ -15,6 +15,7 @@ module.exports = {
15
15
  'env:set': require('./commands/env/set'),
16
16
  'env:unset': require('./commands/env/unset'),
17
17
  history: require('./commands/history'),
18
+ jobs: require('./commands/jobs'),
18
19
  init: require('./commands/init'),
19
20
  integrations: require('./commands/integrations'),
20
21
  link: require('./commands/link'),
package/src/utils/api.js CHANGED
@@ -327,6 +327,8 @@ const listLogs = (opts) => {
327
327
  const listEnv = (version) =>
328
328
  listEndpoint(`versions/${version}/environment`, 'env');
329
329
 
330
+ const listMigrations = () => listEndpoint('migrations');
331
+
330
332
  // the goal of this is to call `/check` with as much info as possible
331
333
  // if the app is registered and auth is available, then we can send app id
332
334
  // otherwise, we should just send the definition and get back checks about that
@@ -411,6 +413,7 @@ module.exports = {
411
413
  listInvitees,
412
414
  listLogs,
413
415
  listVersions,
416
+ listMigrations,
414
417
  readCredentials,
415
418
  upload,
416
419
  validateApp,
@@ -0,0 +1,45 @@
1
+ const { pathExists } = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ const packageManagers = [
5
+ {
6
+ lockFile: 'package-lock.json',
7
+ forceFlag: undefined,
8
+ executable: 'npm',
9
+ useDoubleHyphenBeforeArgs: true,
10
+ },
11
+ {
12
+ lockFile: 'yarn.lock',
13
+ forceFlag: 'yarn',
14
+ executable: 'yarn',
15
+ useDoubleHyphenBeforeArgs: false, // yarn gives a warning if we include `--`
16
+ },
17
+ {
18
+ lockFile: 'pnpm-lock.yaml',
19
+ forceFlag: 'pnpm',
20
+ executable: 'pnpm',
21
+ useDoubleHyphenBeforeArgs: true,
22
+ },
23
+ ];
24
+
25
+ const defaultPackageManager = packageManagers[0];
26
+
27
+ const getPackageManager = async (flags) => {
28
+ for (const man of packageManagers) {
29
+ if (flags[man.forceFlag]) {
30
+ return man;
31
+ }
32
+ }
33
+
34
+ for (const man of packageManagers) {
35
+ if (await pathExists(path.join(process.cwd(), man.lockFile))) {
36
+ return man;
37
+ }
38
+ }
39
+
40
+ return defaultPackageManager;
41
+ };
42
+
43
+ module.exports = {
44
+ getPackageManager,
45
+ };