zapier-platform-cli 17.9.0 → 17.9.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.
@@ -2555,5 +2555,5 @@
2555
2555
  ]
2556
2556
  }
2557
2557
  },
2558
- "version": "17.9.0"
2558
+ "version": "17.9.1"
2559
2559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-cli",
3
- "version": "17.9.0",
3
+ "version": "17.9.1",
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/",
@@ -8,6 +8,7 @@ const { recordAnalytics } = require('../utils/analytics');
8
8
  const { getWritableApp } = require('../utils/api');
9
9
 
10
10
  const inquirer = require('inquirer');
11
+ const { throwForInvalidVersion } = require('../utils/version');
11
12
 
12
13
  const DATA_FORMATS = ['json', 'raw'];
13
14
 
@@ -90,16 +91,7 @@ class ZapierBaseCommand extends Command {
90
91
 
91
92
  // validate that user input looks like a semver version
92
93
  throwForInvalidVersion(version) {
93
- if (
94
- !version.match(
95
- // this is mirrored in schemas/VersionSchema.js and developer_cli/constants.py
96
- /^(?:0|[1-9]\d{0,2})\.(?:0|[1-9]\d{0,2})\.(?:0|[1-9]\d{0,2})(?:-(?=.{1,12}$)[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/g,
97
- )
98
- ) {
99
- throw new Error(
100
- `${version} is an invalid version str. Try something like \`1.2.3\` or \`0.0.0-TICKET\``,
101
- );
102
- }
94
+ return throwForInvalidVersion(version);
103
95
  }
104
96
 
105
97
  async getWritableApp() {
@@ -6,21 +6,18 @@ const colors = require('colors/safe');
6
6
  const BuildCommand = require('./build');
7
7
 
8
8
  const { buildAndOrUpload } = require('../../utils/build');
9
- const { localAppCommand } = require('../../utils/local');
10
-
11
9
  class PushCommand extends ZapierBaseCommand {
12
10
  async perform() {
13
11
  const skipNpmInstall = this.flags['skip-npm-install'];
14
- const definition = await localAppCommand({ command: 'definition' });
15
12
 
16
13
  const snapshotLabel = this.flags.snapshot;
17
14
  if (snapshotLabel && snapshotLabel.length > 12) {
18
15
  throw new Error('Snapshot label cannot exceed 12 characters');
19
16
  }
20
- const version = snapshotLabel
17
+
18
+ const snapshotVersion = snapshotLabel
21
19
  ? `0.0.0-${snapshotLabel}`
22
- : definition.version;
23
- this.throwForInvalidVersion(version);
20
+ : undefined;
24
21
 
25
22
  await buildAndOrUpload(
26
23
  { build: true, upload: true },
@@ -30,7 +27,7 @@ class PushCommand extends ZapierBaseCommand {
30
27
  skipValidation: this.flags['skip-validation'],
31
28
  overwritePartnerChanges: this.flags['overwrite-partner-changes'],
32
29
  },
33
- version,
30
+ snapshotVersion,
34
31
  );
35
32
  this.log(
36
33
  `\nPush complete! Built ${BUILD_PATH} and ${SOURCE_PATH} and uploaded them to Zapier.`,
package/src/utils/api.js CHANGED
@@ -428,7 +428,7 @@ const downloadSourceZip = async (dst) => {
428
428
  const upload = async (
429
429
  app,
430
430
  { skipValidation = false, overwritePartnerChanges = false } = {},
431
- versionOverride,
431
+ snapshotVersion,
432
432
  ) => {
433
433
  const zipPath = constants.BUILD_PATH;
434
434
  const sourceZipPath = constants.SOURCE_PATH;
@@ -461,7 +461,7 @@ const upload = async (
461
461
  headers['X-Overwrite-Partner-Changes'] = 'true';
462
462
  }
463
463
 
464
- const version = versionOverride ?? definition.version;
464
+ const version = snapshotVersion ?? definition.version;
465
465
  startSpinner(`Uploading version ${version}`);
466
466
  try {
467
467
  await callAPI(
@@ -45,6 +45,7 @@ const checkMissingAppInfo = require('./check-missing-app-info');
45
45
  const { findCorePackageDir, isWindows, runCommand } = require('./misc');
46
46
  const { isBlocklisted, respectGitIgnore } = require('./ignore');
47
47
  const { localAppCommand } = require('./local');
48
+ const { throwForInvalidVersion } = require('./version');
48
49
 
49
50
  const debug = require('debug')('zapier:build');
50
51
 
@@ -588,13 +589,16 @@ const testBuildZip = async (zipPath) => {
588
589
  }
589
590
  };
590
591
 
591
- const _buildFunc = async ({
592
- skipNpmInstall = false,
593
- disableDependencyDetection = false,
594
- skipValidation = false,
595
- printProgress = true,
596
- checkOutdated = true,
597
- } = {}) => {
592
+ const _buildFunc = async (
593
+ {
594
+ skipNpmInstall = false,
595
+ disableDependencyDetection = false,
596
+ skipValidation = false,
597
+ printProgress = true,
598
+ checkOutdated = true,
599
+ } = {},
600
+ snapshotVersion,
601
+ ) => {
598
602
  const maybeStartSpinner = printProgress ? startSpinner : () => {};
599
603
  const maybeEndSpinner = printProgress ? endSpinner : () => {};
600
604
 
@@ -659,6 +663,9 @@ const _buildFunc = async ({
659
663
  false,
660
664
  );
661
665
 
666
+ const version = snapshotVersion ?? rawDefinition.version;
667
+ throwForInvalidVersion(version);
668
+
662
669
  try {
663
670
  fs.writeFileSync(
664
671
  path.join(workingDir, 'definition.json'),
@@ -761,7 +768,7 @@ const _buildFunc = async ({
761
768
  const buildAndOrUpload = async (
762
769
  { build = false, upload = false } = {},
763
770
  buildOpts,
764
- versionOverride,
771
+ snapshotVersion,
765
772
  ) => {
766
773
  if (!(build || upload)) {
767
774
  throw new Error('must either build or upload');
@@ -775,10 +782,10 @@ const buildAndOrUpload = async (
775
782
  }
776
783
 
777
784
  if (build) {
778
- await _buildFunc(buildOpts);
785
+ await _buildFunc(buildOpts, snapshotVersion);
779
786
  }
780
787
  if (upload) {
781
- await _uploadFunc(app, buildOpts, versionOverride);
788
+ await _uploadFunc(app, buildOpts, snapshotVersion);
782
789
  }
783
790
  };
784
791
 
@@ -282,13 +282,21 @@ const getLocalAppHandler = async ({
282
282
  appRaw = loadAppRawUsingRequire(appDir);
283
283
  } catch (err) {
284
284
  if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_REQUIRE_ESM') {
285
- appRaw = await loadAppRawUsingImport(
286
- appDir,
287
- corePackageDir,
288
- shouldDeleteWrapper,
289
- );
285
+ try {
286
+ appRaw = await loadAppRawUsingImport(
287
+ appDir,
288
+ corePackageDir,
289
+ shouldDeleteWrapper,
290
+ );
291
+ } catch (err) {
292
+ err.message =
293
+ 'Your ESM integration requires a compiled `dist/` directory. Run `zapier build` to compile your code first.\n\n' +
294
+ err.message;
295
+ throw err;
296
+ }
290
297
  } else {
291
298
  // err.name === 'SyntaxError' or others
299
+
292
300
  throw err;
293
301
  }
294
302
  }
@@ -0,0 +1,16 @@
1
+ const throwForInvalidVersion = (version) => {
2
+ if (
3
+ !version.match(
4
+ // this is mirrored in schemas/VersionSchema.js and developer_cli/constants.py
5
+ /^(?:0|[1-9]\d{0,2})\.(?:0|[1-9]\d{0,2})\.(?:0|[1-9]\d{0,2})(?:-(?=.{1,12}$)[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/g,
6
+ )
7
+ ) {
8
+ throw new Error(
9
+ `${version} is an invalid version str. Try something like \`1.2.3\` or \`0.0.0-TICKET\``,
10
+ );
11
+ }
12
+ };
13
+
14
+ module.exports = {
15
+ throwForInvalidVersion,
16
+ };