zapier-platform-cli 17.0.1 → 17.0.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.
@@ -2430,5 +2430,5 @@
2430
2430
  ]
2431
2431
  }
2432
2432
  },
2433
- "version": "17.0.1"
2433
+ "version": "17.0.2"
2434
2434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-cli",
3
- "version": "17.0.1",
3
+ "version": "17.0.2",
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/",
@@ -290,9 +290,9 @@ class ProjectGenerator extends Generator {
290
290
  {
291
291
  type: 'list',
292
292
  name: 'module',
293
- choices: ['commonjs', 'esm'],
293
+ choices: ['esm', 'commonjs'],
294
294
  message: 'Choose module type:',
295
- default: 'commonjs',
295
+ default: 'esm',
296
296
  },
297
297
  ]);
298
298
  this.options.module = this.answers.module;
@@ -20,7 +20,10 @@ export default {
20
20
  getAccessToken: {
21
21
  url: `${API_URL}/oauth/access-token`,
22
22
  method: 'POST',
23
- params: {
23
+ headers: {
24
+ 'content-type': 'application/x-www-form-urlencoded',
25
+ },
26
+ body: {
24
27
  client_id: '{{process.env.CLIENT_ID}}',
25
28
  client_secret: '{{process.env.CLIENT_SECRET}}',
26
29
  code: '{{bundle.inputData.code}}',
@@ -31,7 +34,10 @@ export default {
31
34
  refreshAccessToken: {
32
35
  url: `${API_URL}/oauth/refresh-token`,
33
36
  method: 'POST',
34
- params: {
37
+ headers: {
38
+ 'content-type': 'application/x-www-form-urlencoded',
39
+ },
40
+ body: {
35
41
  client_id: '{{process.env.CLIENT_ID}}',
36
42
  client_secret: '{{process.env.CLIENT_SECRET}}',
37
43
  refresh_token: '{{bundle.authData.refresh_token}}',
@@ -63,6 +63,7 @@ const requiredFiles = async ({ cwd, entryPoints }) => {
63
63
  external: ['../test/userapp'],
64
64
  format: 'esm',
65
65
  write: false, // no need to write outfile
66
+ absWorkingDir: cwd,
66
67
  });
67
68
 
68
69
  return Object.keys(result.metafile.inputs).map((path) =>
@@ -228,7 +228,10 @@ const loadAppRawUsingImport = async (
228
228
  try {
229
229
  // zapierwrapper.mjs is only available since zapier-platform-core v17.
230
230
  // And only zapierwrapper.mjs exposes appRaw just for this use case.
231
- appRaw = (await import(wrapperPath)).appRaw;
231
+ // Convert path to file:// URL for Windows compatibility with ESM imports
232
+ const pathForUrl = path.resolve(wrapperPath).replace(/\\/g, '/');
233
+ const wrapperUrl = new URL(`file:///${pathForUrl.replace(/^\//, '')}`);
234
+ appRaw = (await import(wrapperUrl.href)).appRaw;
232
235
  } catch (err) {
233
236
  if (err.name === 'SyntaxError') {
234
237
  // Run a separate process to print the line number of the SyntaxError.
@@ -251,7 +254,8 @@ const loadAppRawUsingImport = async (
251
254
  };
252
255
 
253
256
  const loadAppRawUsingRequire = (appDir) => {
254
- let appRaw = require(appDir);
257
+ const normalizedPath = path.resolve(appDir);
258
+ let appRaw = require(normalizedPath);
255
259
  if (appRaw && appRaw.default) {
256
260
  // Node.js 22+ supports using require() to import ESM.
257
261
  // For Node.js < 20.17.0, require() will throw an error on ESM.
@@ -325,7 +329,10 @@ const getLocalAppHandler = async ({
325
329
 
326
330
  // Assumes the entry point of zapier-platform-core is index.js
327
331
  const coreEntryPoint = path.join(corePackageDir, 'index.js');
328
- const zapier = (await import(coreEntryPoint)).default;
332
+ // Convert path to file:// URL for Windows compatibility with ESM imports
333
+ const pathForUrl = path.resolve(coreEntryPoint).replace(/\\/g, '/');
334
+ const coreEntryUrl = new URL(`file:///${pathForUrl.replace(/^\//, '')}`);
335
+ const zapier = (await import(coreEntryUrl.href)).default;
329
336
 
330
337
  const handler = zapier.createAppHandler(appRaw);
331
338
  if (handler.length === 3) {
@@ -360,6 +367,7 @@ const localAppCommand = async (event, appDir, shouldDeleteWrapper = true) => {
360
367
  appDir,
361
368
  shouldDeleteWrapper,
362
369
  });
370
+
363
371
  if (handler.length === 3) {
364
372
  // < 17: function handler(event, ctx, callback)
365
373
  return new Promise((resolve, reject) => {