zapier / zapier-platform

The SDK for you to build an integration on Zapier

Home Page:https://platform.zapier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use the `scaffold` command with a TypeScript project?

narthur opened this issue · comments

I've been trying unsuccessfully to use the scaffold command with a new Zapier app project that was initialized like so:

zapier init audioverse-zapier/ -t typescript

But I keep getting this error:

zapier:scaffold Error: Invalid export type: "MemberExpression"

Here is the full output:

work@Nathans-MacBook-Pro audioverse-zapier % zapier scaffold resource teaching --debug --force
  zapier:scaffold argv is [ 'resource', 'teaching', '--debug', '--force' ] +0ms
  zapier:scaffold args are { actionType: 'resource', noun: 'teaching' } +1ms
  zapier:scaffold flags are { debug: true, force: true, entry: 'index.js', 'no-help': false } +1ms
  zapier:scaffold ------------ +0ms
⠋ Creating new file: resources/teaching.js  zapier:analytics sending {
  command: 'scaffold',
  isValidCommand: true,
  numArgs: 2,
  flags: { debug: true, force: true, entry: 'index.js', 'no-help': false },
  cliVersion: '11.1.1',
  os: 'darwin',
  sendUserId: true
} +0ms
✔ Creating new file: resources/teaching.js
✔ Creating new test file: test/resources/teaching.js
✖ Rewriting your index.js
  zapier:scaffold Error: Invalid export type: "MemberExpression"
  zapier:scaffold     at addKeyToPropertyOnApp (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/src/utils/ast.js:108:11)
  zapier:scaffold     at updateEntryFile (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/src/utils/scaffold.js:99:13)
  zapier:scaffold     at async ScaffoldCommand.perform (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/src/oclif/commands/scaffold.js:99:30)
  zapier:scaffold     at async Promise.all (index 1)
  zapier:scaffold     at async ScaffoldCommand._run (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/node_modules/@oclif/command/lib/command.js:43:20)
  zapier:scaffold     at async Config.runCommand (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/node_modules/@oclif/config/lib/config.js:173:24)
  zapier:scaffold     at async Main.run (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/node_modules/@oclif/command/lib/main.js:27:9)
  zapier:scaffold     at async Main._run (/Users/work/.nvm/versions/node/v14.17.0/lib/node_modules/zapier-platform-cli/node_modules/@oclif/command/lib/command.js:43:20) +55ms
 ›   Error: Invalid export type: "MemberExpression"

I've tried re-installing dependencies and even re-initializing the project after deleting all files multiple times, with no luck.

Does the scaffold command support typescript projects? If so, what am I doing wrong?

Hi @narthur. Thanks for filling this issue!

Scaffold doesn't support Typescript at this time. We should be throwing the following error, but it seems like that's not happening correctly:

if (entry.endsWith('ts')) {
this.error(
`Typescript isn't supported for scaffolding yet. Instead, try copying the example code at https://github.com/zapier/zapier-platform/blob/b8224ec9855be91c66c924b731199a068b1e913a/example-apps/typescript/src/resources/recipe.ts`
);
}

This is something on our roadmap, but because of the involved way we re-write the index.js file, it was out of scope for the initial project. Sorry about the confusion there!

@xavdid Thank you for the clarification, and glad to hear it's on the roadmap!