zapier-platform-cli 11.2.0 → 11.3.2

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.
@@ -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
+ };