zapier-platform-cli 17.7.2 → 17.9.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.
@@ -1051,14 +1051,14 @@
1051
1051
  ],
1052
1052
  "flags": {
1053
1053
  "user": {
1054
- "description": "Migrates all of a users' Private Zaps within all accounts for which the specified user is a member",
1054
+ "description": "Migrates a user's private Zaps under the user's individual account, excluding organization accounts",
1055
1055
  "name": "user",
1056
1056
  "hasDynamicHelp": false,
1057
1057
  "multiple": false,
1058
1058
  "type": "option"
1059
1059
  },
1060
1060
  "account": {
1061
- "description": "Migrates all of a users' Zaps, Private & Shared, within all accounts for which the specified user is a member",
1061
+ "description": "Migrates a user's private and shared Zaps under the user's individual and organization accounts",
1062
1062
  "name": "account",
1063
1063
  "hasDynamicHelp": false,
1064
1064
  "multiple": false,
@@ -1194,6 +1194,10 @@
1194
1194
  "aliases": [],
1195
1195
  "args": {},
1196
1196
  "description": "Build and upload the current integration.\n\nThis command is the same as running `zapier build` and `zapier upload` in sequence. See those for more info.",
1197
+ "examples": [
1198
+ "zapier push",
1199
+ "zapier push --snapshot MY-LABEL"
1200
+ ],
1197
1201
  "flags": {
1198
1202
  "disable-dependency-detection": {
1199
1203
  "description": "Disable \"smart\" file inclusion. By default, Zapier only includes files that are required by your entry point (`index.js` by default). 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 `.zapierapprc`. See the docs about `includeInBuild` for more info.",
@@ -1233,6 +1237,13 @@
1233
1237
  "name": "overwrite-partner-changes",
1234
1238
  "allowNo": false,
1235
1239
  "type": "boolean"
1240
+ },
1241
+ "snapshot": {
1242
+ "description": "Pass in a label to create a snapshot version of this integration for development and testing purposes. The version will be created as: 0.0.0-MY-LABEL",
1243
+ "name": "snapshot",
1244
+ "hasDynamicHelp": false,
1245
+ "multiple": false,
1246
+ "type": "option"
1236
1247
  }
1237
1248
  },
1238
1249
  "hasDynamicHelp": false,
@@ -1907,6 +1918,88 @@
1907
1918
  "list.js"
1908
1919
  ]
1909
1920
  },
1921
+ "delete:integration": {
1922
+ "aliases": [
1923
+ "delete:app"
1924
+ ],
1925
+ "args": {},
1926
+ "description": "Delete your integration (including all versions).\n\nThis only works if there are no active users or Zaps on any version. If you only want to delete certain versions, use the `zapier delete:version` command instead. It's unlikely that you'll be able to run this on an app that you've pushed publicly, since there are usually still users.",
1927
+ "flags": {
1928
+ "debug": {
1929
+ "char": "d",
1930
+ "description": "Show extra debugging output.",
1931
+ "name": "debug",
1932
+ "allowNo": false,
1933
+ "type": "boolean"
1934
+ },
1935
+ "invokedFromAnotherCommand": {
1936
+ "hidden": true,
1937
+ "name": "invokedFromAnotherCommand",
1938
+ "allowNo": false,
1939
+ "type": "boolean"
1940
+ }
1941
+ },
1942
+ "hasDynamicHelp": false,
1943
+ "hiddenAliases": [],
1944
+ "id": "delete:integration",
1945
+ "pluginAlias": "zapier-platform-cli",
1946
+ "pluginName": "zapier-platform-cli",
1947
+ "pluginType": "core",
1948
+ "strict": true,
1949
+ "enableJsonFlag": false,
1950
+ "skipValidInstallCheck": true,
1951
+ "isESM": false,
1952
+ "relativePath": [
1953
+ "src",
1954
+ "oclif",
1955
+ "commands",
1956
+ "delete",
1957
+ "integration.js"
1958
+ ]
1959
+ },
1960
+ "delete:version": {
1961
+ "aliases": [],
1962
+ "args": {
1963
+ "version": {
1964
+ "description": "Specify the version to delete. It must have no users or Zaps.",
1965
+ "name": "version",
1966
+ "required": true
1967
+ }
1968
+ },
1969
+ "description": "Delete a specific version of your integration.\n\nThis only works if there are no users or Zaps on that version. You will probably need to have run `zapier migrate` and `zapier deprecate` before this command will work.",
1970
+ "flags": {
1971
+ "debug": {
1972
+ "char": "d",
1973
+ "description": "Show extra debugging output.",
1974
+ "name": "debug",
1975
+ "allowNo": false,
1976
+ "type": "boolean"
1977
+ },
1978
+ "invokedFromAnotherCommand": {
1979
+ "hidden": true,
1980
+ "name": "invokedFromAnotherCommand",
1981
+ "allowNo": false,
1982
+ "type": "boolean"
1983
+ }
1984
+ },
1985
+ "hasDynamicHelp": false,
1986
+ "hiddenAliases": [],
1987
+ "id": "delete:version",
1988
+ "pluginAlias": "zapier-platform-cli",
1989
+ "pluginName": "zapier-platform-cli",
1990
+ "pluginType": "core",
1991
+ "strict": true,
1992
+ "enableJsonFlag": false,
1993
+ "skipValidInstallCheck": true,
1994
+ "isESM": false,
1995
+ "relativePath": [
1996
+ "src",
1997
+ "oclif",
1998
+ "commands",
1999
+ "delete",
2000
+ "version.js"
2001
+ ]
2002
+ },
1910
2003
  "env:get": {
1911
2004
  "aliases": [],
1912
2005
  "args": {
@@ -2083,88 +2176,6 @@
2083
2176
  "unset.js"
2084
2177
  ]
2085
2178
  },
2086
- "delete:integration": {
2087
- "aliases": [
2088
- "delete:app"
2089
- ],
2090
- "args": {},
2091
- "description": "Delete your integration (including all versions).\n\nThis only works if there are no active users or Zaps on any version. If you only want to delete certain versions, use the `zapier delete:version` command instead. It's unlikely that you'll be able to run this on an app that you've pushed publicly, since there are usually still users.",
2092
- "flags": {
2093
- "debug": {
2094
- "char": "d",
2095
- "description": "Show extra debugging output.",
2096
- "name": "debug",
2097
- "allowNo": false,
2098
- "type": "boolean"
2099
- },
2100
- "invokedFromAnotherCommand": {
2101
- "hidden": true,
2102
- "name": "invokedFromAnotherCommand",
2103
- "allowNo": false,
2104
- "type": "boolean"
2105
- }
2106
- },
2107
- "hasDynamicHelp": false,
2108
- "hiddenAliases": [],
2109
- "id": "delete:integration",
2110
- "pluginAlias": "zapier-platform-cli",
2111
- "pluginName": "zapier-platform-cli",
2112
- "pluginType": "core",
2113
- "strict": true,
2114
- "enableJsonFlag": false,
2115
- "skipValidInstallCheck": true,
2116
- "isESM": false,
2117
- "relativePath": [
2118
- "src",
2119
- "oclif",
2120
- "commands",
2121
- "delete",
2122
- "integration.js"
2123
- ]
2124
- },
2125
- "delete:version": {
2126
- "aliases": [],
2127
- "args": {
2128
- "version": {
2129
- "description": "Specify the version to delete. It must have no users or Zaps.",
2130
- "name": "version",
2131
- "required": true
2132
- }
2133
- },
2134
- "description": "Delete a specific version of your integration.\n\nThis only works if there are no users or Zaps on that version. You will probably need to have run `zapier migrate` and `zapier deprecate` before this command will work.",
2135
- "flags": {
2136
- "debug": {
2137
- "char": "d",
2138
- "description": "Show extra debugging output.",
2139
- "name": "debug",
2140
- "allowNo": false,
2141
- "type": "boolean"
2142
- },
2143
- "invokedFromAnotherCommand": {
2144
- "hidden": true,
2145
- "name": "invokedFromAnotherCommand",
2146
- "allowNo": false,
2147
- "type": "boolean"
2148
- }
2149
- },
2150
- "hasDynamicHelp": false,
2151
- "hiddenAliases": [],
2152
- "id": "delete:version",
2153
- "pluginAlias": "zapier-platform-cli",
2154
- "pluginName": "zapier-platform-cli",
2155
- "pluginType": "core",
2156
- "strict": true,
2157
- "enableJsonFlag": false,
2158
- "skipValidInstallCheck": true,
2159
- "isESM": false,
2160
- "relativePath": [
2161
- "src",
2162
- "oclif",
2163
- "commands",
2164
- "delete",
2165
- "version.js"
2166
- ]
2167
- },
2168
2179
  "team:add": {
2169
2180
  "aliases": [
2170
2181
  "team:invite"
@@ -2544,5 +2555,5 @@
2544
2555
  ]
2545
2556
  }
2546
2557
  },
2547
- "version": "17.7.2"
2558
+ "version": "17.9.0"
2548
2559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-cli",
3
- "version": "17.7.2",
3
+ "version": "17.9.0",
4
4
  "description": "The CLI for managing integrations in Zapier Developer Platform.",
5
5
  "repository": "zapier/zapier-platform",
6
6
  "homepage": "https://platform.zapier.com/",
@@ -64,7 +64,6 @@
64
64
  "luxon": "3.6.1",
65
65
  "marked": "14.1.4",
66
66
  "marked-terminal": "7.2.1",
67
- "node-fetch": "2.7.0",
68
67
  "open": "10.1.2",
69
68
  "ora": "5.4.0",
70
69
  "parse-gitignore": "0.5.1",
@@ -73,12 +73,12 @@ class SetEnvCommand extends BaseCommand {
73
73
  const failedKeys = e.json.errors[0].split('update: ')[1].split(', ');
74
74
  const successfulResult = omit(payload, failedKeys);
75
75
  if (!Object.keys(successfulResult).length) {
76
- this.error(e.json.errors[0]);
76
+ this.error(e.json.errors.join('\nError: '));
77
77
  }
78
78
 
79
79
  this.warn(successMessage(version));
80
80
  this.logJSON(successfulResult);
81
- this.warn(`However, these keys failed to update: ${failedKeys}`);
81
+ this.warn(e.json.errors.join('\nWarning: '));
82
82
  }
83
83
  }
84
84
  }
@@ -152,11 +152,11 @@ MigrateCommand.flags = buildFlags({
152
152
  commandFlags: {
153
153
  user: Flags.string({
154
154
  description:
155
- "Migrates all of a users' Private Zaps within all accounts for which the specified user is a member",
155
+ "Migrates a user's private Zaps under the user's individual account, excluding organization accounts",
156
156
  }),
157
157
  account: Flags.string({
158
158
  description:
159
- "Migrates all of a users' Zaps, Private & Shared, within all accounts for which the specified user is a member",
159
+ "Migrates a user's private and shared Zaps under the user's individual and organization accounts",
160
160
  }),
161
161
  yes: Flags.boolean({
162
162
  char: 'y',
@@ -12,7 +12,14 @@ class PushCommand extends ZapierBaseCommand {
12
12
  async perform() {
13
13
  const skipNpmInstall = this.flags['skip-npm-install'];
14
14
  const definition = await localAppCommand({ command: 'definition' });
15
- const version = definition.version;
15
+
16
+ const snapshotLabel = this.flags.snapshot;
17
+ if (snapshotLabel && snapshotLabel.length > 12) {
18
+ throw new Error('Snapshot label cannot exceed 12 characters');
19
+ }
20
+ const version = snapshotLabel
21
+ ? `0.0.0-${snapshotLabel}`
22
+ : definition.version;
16
23
  this.throwForInvalidVersion(version);
17
24
 
18
25
  await buildAndOrUpload(
@@ -23,6 +30,7 @@ class PushCommand extends ZapierBaseCommand {
23
30
  skipValidation: this.flags['skip-validation'],
24
31
  overwritePartnerChanges: this.flags['overwrite-partner-changes'],
25
32
  },
33
+ version,
26
34
  );
27
35
  this.log(
28
36
  `\nPush complete! Built ${BUILD_PATH} and ${SOURCE_PATH} and uploaded them to Zapier.`,
@@ -43,7 +51,12 @@ PushCommand.flags = {
43
51
  '(Internal Use Only) Allows Zapier Staff to push changes to integrations in certain situations.',
44
52
  hidden: true,
45
53
  }),
54
+ snapshot: Flags.string({
55
+ description:
56
+ 'Pass in a label to create a snapshot version of this integration for development and testing purposes. The version will be created as: 0.0.0-MY-LABEL',
57
+ }),
46
58
  };
59
+ PushCommand.examples = ['zapier push', 'zapier push --snapshot MY-LABEL'];
47
60
  PushCommand.description = `Build and upload the current integration.
48
61
 
49
62
  This command is the same as running \`zapier build\` and \`zapier upload\` in sequence. See those for more info.`;
package/src/utils/api.js CHANGED
@@ -11,7 +11,6 @@ const qs = require('querystring');
11
11
 
12
12
  const fs = require('fs');
13
13
  const AdmZip = require('adm-zip');
14
- const fetch = require('node-fetch');
15
14
  const path = require('path');
16
15
 
17
16
  const { writeFile, readFile } = require('./files');
@@ -429,6 +428,7 @@ const downloadSourceZip = async (dst) => {
429
428
  const upload = async (
430
429
  app,
431
430
  { skipValidation = false, overwritePartnerChanges = false } = {},
431
+ versionOverride,
432
432
  ) => {
433
433
  const zipPath = constants.BUILD_PATH;
434
434
  const sourceZipPath = constants.SOURCE_PATH;
@@ -461,10 +461,11 @@ const upload = async (
461
461
  headers['X-Overwrite-Partner-Changes'] = 'true';
462
462
  }
463
463
 
464
- startSpinner(`Uploading version ${definition.version}`);
464
+ const version = versionOverride ?? definition.version;
465
+ startSpinner(`Uploading version ${version}`);
465
466
  try {
466
467
  await callAPI(
467
- `/apps/${app.id}/versions/${definition.version}`,
468
+ `/apps/${app.id}/versions/${version}`,
468
469
  {
469
470
  method: 'PUT',
470
471
  body: {
@@ -761,6 +761,7 @@ const _buildFunc = async ({
761
761
  const buildAndOrUpload = async (
762
762
  { build = false, upload = false } = {},
763
763
  buildOpts,
764
+ versionOverride,
764
765
  ) => {
765
766
  if (!(build || upload)) {
766
767
  throw new Error('must either build or upload');
@@ -777,7 +778,7 @@ const buildAndOrUpload = async (
777
778
  await _buildFunc(buildOpts);
778
779
  }
779
780
  if (upload) {
780
- await _uploadFunc(app, buildOpts);
781
+ await _uploadFunc(app, buildOpts, versionOverride);
781
782
  }
782
783
  };
783
784
 
@@ -1,4 +1,3 @@
1
- const fetch = require('node-fetch');
2
1
  const { BASE_ENDPOINT } = require('../constants');
3
2
 
4
3
  const isSamlEmail = async (email) => {
package/src/utils/npm.js CHANGED
@@ -1,5 +1,3 @@
1
- const fetch = require('node-fetch');
2
-
3
1
  const BASE_URL = 'https://registry.npmjs.org';
4
2
 
5
3
  const getPackageLatestVersion = async (name) => {
@@ -1,89 +0,0 @@
1
- const fetch = require('node-fetch');
2
- const path = require('path');
3
- const fse = require('fs-extra');
4
- const AdmZip = require('adm-zip');
5
- const debug = require('debug')('zapier:example-apps');
6
-
7
- const xdg = require('./xdg');
8
- const { copyDir } = require('./files');
9
- const { PACKAGE_VERSION } = require('../constants');
10
-
11
- const REPO_ZIP_URL = `https://codeload.github.com/zapier/zapier-platform/zip/zapier-platform-cli%40${PACKAGE_VERSION}`;
12
- const zipName = `zapier-platform-zapier-platform-cli-${PACKAGE_VERSION}`;
13
- const folderName = `zapier-platform-cached`; // version independant
14
-
15
- const checkCacheUpToDate = async (repoDir) => {
16
- const etagPath = path.join(repoDir, 'etag');
17
- let currentEtag;
18
- try {
19
- currentEtag = await fse.readFile(etagPath, { encoding: 'utf8' });
20
- } catch (err) {
21
- currentEtag = '';
22
- }
23
- const res = await fetch(REPO_ZIP_URL, { method: 'HEAD' });
24
- const latestEtag = res.headers.get('etag');
25
-
26
- return currentEtag === latestEtag;
27
- };
28
-
29
- const downloadRepo = async (destDir) => {
30
- const destZipPath = path.join(destDir, `${zipName}.zip`);
31
-
32
- const res = await fetch(REPO_ZIP_URL);
33
- const dest = fse.createWriteStream(destZipPath);
34
- res.body.pipe(dest);
35
-
36
- await new Promise((resolve, reject) => {
37
- dest.on('finish', () => {
38
- resolve();
39
- });
40
- dest.on('error', reject);
41
- });
42
-
43
- const zip = new AdmZip(destZipPath);
44
- zip.extractAllTo(destDir, true);
45
-
46
- // Save etag for cache validation
47
- // this could probably just be cli version, but this is fine too
48
- const etagPath = path.join(destDir, zipName, 'etag');
49
- fse.writeFileSync(etagPath, res.headers.get('etag'));
50
-
51
- fse.removeSync(destZipPath);
52
- fse.renameSync(path.join(destDir, zipName), path.join(destDir, folderName));
53
-
54
- return destZipPath;
55
- };
56
-
57
- const ensureRepoCached = async () => {
58
- const cacheDir = xdg.ensureCacheDir();
59
- const repoDir = path.join(cacheDir, folderName);
60
-
61
- if (fse.existsSync(repoDir)) {
62
- debug('repo exists');
63
- if (!(await checkCacheUpToDate(repoDir))) {
64
- debug('cached repo is stale, re-downloading');
65
- await fse.remove(repoDir);
66
- await downloadRepo(cacheDir);
67
- }
68
- } else {
69
- debug('no cached repo, downloading');
70
- await downloadRepo(cacheDir);
71
- }
72
-
73
- return repoDir;
74
- };
75
-
76
- const downloadExampleAppTo = async (exampleName, destDir) => {
77
- const repoDir = await ensureRepoCached();
78
- const cachedExampleDir = path.join(repoDir, 'example-apps', exampleName);
79
- await copyDir(cachedExampleDir, destDir);
80
- };
81
-
82
- const removeReadme = (dir) => {
83
- return fse.remove(path.join(dir, 'README.md'));
84
- };
85
-
86
- module.exports = {
87
- downloadExampleAppTo,
88
- removeReadme,
89
- };
package/src/utils/xdg.js DELETED
@@ -1,59 +0,0 @@
1
- // XDG Base Directory Specification
2
- // See: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
3
-
4
- const fse = require('fs-extra');
5
- const os = require('os');
6
- const path = require('path');
7
-
8
- const ensureDir = (envVarName, defaultDir, extraPath = []) => {
9
- const baseDir = process.env[envVarName] || defaultDir;
10
- let appDir = path.join(baseDir, 'zapier');
11
- fse.ensureDirSync(appDir, 0o700);
12
-
13
- if (extraPath.length > 0) {
14
- const dirParts = [appDir].concat(extraPath);
15
- appDir = path.join.apply(null, dirParts);
16
- fse.ensureDirSync(appDir);
17
- }
18
-
19
- return appDir;
20
- };
21
-
22
- const HOME_DIR = os.homedir();
23
-
24
- let ensureDataDir, ensureCacheDir, ensureConfigDir;
25
-
26
- if (process.platform === 'win32') {
27
- const defaultAppDir = path.join(HOME_DIR, 'AppData', 'Local');
28
-
29
- // NOTE: LOCALAPPDATA is not available on Windows XP
30
- ensureDataDir = ensureDir.bind(null, 'LOCALAPPDATA', defaultAppDir, ['data']);
31
- ensureCacheDir = ensureDir.bind(null, 'LOCALAPPDATA', defaultAppDir, [
32
- 'cache',
33
- ]);
34
- ensureConfigDir = ensureDir.bind(null, 'LOCALAPPDATA', defaultAppDir, [
35
- 'config',
36
- ]);
37
- } else {
38
- ensureDataDir = ensureDir.bind(
39
- null,
40
- 'XDG_DATA_HOME',
41
- path.join(HOME_DIR, '.local', 'share'),
42
- );
43
- ensureCacheDir = ensureDir.bind(
44
- null,
45
- 'XDG_CACHE_HOME',
46
- path.join(HOME_DIR, '.cache'),
47
- );
48
- ensureConfigDir = ensureDir.bind(
49
- null,
50
- 'XDG_CONFIG_HOME',
51
- path.join(HOME_DIR, '.config'),
52
- );
53
- }
54
-
55
- module.exports = {
56
- ensureDataDir,
57
- ensureCacheDir,
58
- ensureConfigDir,
59
- };