zapier-platform-cli 16.5.1 → 17.0.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.
@@ -55,7 +55,7 @@
55
55
  "build": {
56
56
  "aliases": [],
57
57
  "args": {},
58
- "description": "Build a pushable zip from the current directory.\n\nThis command does the following:\n\n* Creates a temporary folder\n* Copies all code into the temporary folder\n* Adds an entry point: `zapierwrapper.js`\n* Generates and validates app definition.\n* Detects dependencies via browserify (optional, on by default)\n* Zips up all needed `.js` files. If you want to include more files, add a \"includeInBuild\" property (array with strings of regexp paths) to your `.zapierapprc`.\n* Moves the zip to `build/build.zip` and `build/source.zip` and deletes the temp folder\n\nThis command is typically followed by `zapier upload`.",
58
+ "description": "Build a pushable zip from the current directory.\n\nThis command does the following:\n\n* Creates a temporary folder\n* Copies all code into the temporary folder\n* Adds an entry point: `zapierwrapper.js`\n* Generates and validates app definition.\n* Detects dependencies via esbuild (optional, on by default)\n* Zips up all needed `.js` files. If you want to include more files, add a \"includeInBuild\" property (array with strings of regexp paths) to your `.zapierapprc`.\n* Moves the zip to `build/build.zip` and `build/source.zip` and deletes the temp folder\n\nThis command is typically followed by `zapier upload`.",
59
59
  "flags": {
60
60
  "disable-dependency-detection": {
61
61
  "description": "Disable \"smart\" file inclusion. By default, Zapier only includes files that are required by `index.js`. 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.",
@@ -337,7 +337,8 @@
337
337
  "description": "Initialize a new Zapier integration with a project template.\n\nAfter running this, you'll have a new integration in the specified directory. If you re-run this command on an existing directory, it will prompt before overwriting any existing files.\n\nThis doesn't register or deploy the integration with Zapier - try the `zapier register` and `zapier push` commands for that!",
338
338
  "examples": [
339
339
  "zapier init myapp",
340
- "zapier init ./path/myapp --template oauth2"
340
+ "zapier init ./path/myapp --template oauth2",
341
+ "zapier init ./path/myapp --template minimal --module esm"
341
342
  ],
342
343
  "flags": {
343
344
  "template": {
@@ -363,6 +364,18 @@
363
364
  ],
364
365
  "type": "option"
365
366
  },
367
+ "module": {
368
+ "char": "m",
369
+ "description": "Choose module type: CommonJS or ES Modules. Only enabled for Typescript and Minimal templates.",
370
+ "name": "module",
371
+ "hasDynamicHelp": false,
372
+ "multiple": false,
373
+ "options": [
374
+ "commonjs",
375
+ "esm"
376
+ ],
377
+ "type": "option"
378
+ },
366
379
  "debug": {
367
380
  "char": "d",
368
381
  "description": "Show extra debugging output.",
@@ -1780,88 +1793,6 @@
1780
1793
  "list.js"
1781
1794
  ]
1782
1795
  },
1783
- "delete:integration": {
1784
- "aliases": [
1785
- "delete:app"
1786
- ],
1787
- "args": {},
1788
- "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.",
1789
- "flags": {
1790
- "debug": {
1791
- "char": "d",
1792
- "description": "Show extra debugging output.",
1793
- "name": "debug",
1794
- "allowNo": false,
1795
- "type": "boolean"
1796
- },
1797
- "invokedFromAnotherCommand": {
1798
- "hidden": true,
1799
- "name": "invokedFromAnotherCommand",
1800
- "allowNo": false,
1801
- "type": "boolean"
1802
- }
1803
- },
1804
- "hasDynamicHelp": false,
1805
- "hiddenAliases": [],
1806
- "id": "delete:integration",
1807
- "pluginAlias": "zapier-platform-cli",
1808
- "pluginName": "zapier-platform-cli",
1809
- "pluginType": "core",
1810
- "strict": true,
1811
- "enableJsonFlag": false,
1812
- "skipValidInstallCheck": true,
1813
- "isESM": false,
1814
- "relativePath": [
1815
- "src",
1816
- "oclif",
1817
- "commands",
1818
- "delete",
1819
- "integration.js"
1820
- ]
1821
- },
1822
- "delete:version": {
1823
- "aliases": [],
1824
- "args": {
1825
- "version": {
1826
- "description": "Specify the version to delete. It must have no users or Zaps.",
1827
- "name": "version",
1828
- "required": true
1829
- }
1830
- },
1831
- "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.",
1832
- "flags": {
1833
- "debug": {
1834
- "char": "d",
1835
- "description": "Show extra debugging output.",
1836
- "name": "debug",
1837
- "allowNo": false,
1838
- "type": "boolean"
1839
- },
1840
- "invokedFromAnotherCommand": {
1841
- "hidden": true,
1842
- "name": "invokedFromAnotherCommand",
1843
- "allowNo": false,
1844
- "type": "boolean"
1845
- }
1846
- },
1847
- "hasDynamicHelp": false,
1848
- "hiddenAliases": [],
1849
- "id": "delete:version",
1850
- "pluginAlias": "zapier-platform-cli",
1851
- "pluginName": "zapier-platform-cli",
1852
- "pluginType": "core",
1853
- "strict": true,
1854
- "enableJsonFlag": false,
1855
- "skipValidInstallCheck": true,
1856
- "isESM": false,
1857
- "relativePath": [
1858
- "src",
1859
- "oclif",
1860
- "commands",
1861
- "delete",
1862
- "version.js"
1863
- ]
1864
- },
1865
1796
  "env:get": {
1866
1797
  "aliases": [],
1867
1798
  "args": {
@@ -2038,6 +1969,88 @@
2038
1969
  "unset.js"
2039
1970
  ]
2040
1971
  },
1972
+ "delete:integration": {
1973
+ "aliases": [
1974
+ "delete:app"
1975
+ ],
1976
+ "args": {},
1977
+ "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.",
1978
+ "flags": {
1979
+ "debug": {
1980
+ "char": "d",
1981
+ "description": "Show extra debugging output.",
1982
+ "name": "debug",
1983
+ "allowNo": false,
1984
+ "type": "boolean"
1985
+ },
1986
+ "invokedFromAnotherCommand": {
1987
+ "hidden": true,
1988
+ "name": "invokedFromAnotherCommand",
1989
+ "allowNo": false,
1990
+ "type": "boolean"
1991
+ }
1992
+ },
1993
+ "hasDynamicHelp": false,
1994
+ "hiddenAliases": [],
1995
+ "id": "delete:integration",
1996
+ "pluginAlias": "zapier-platform-cli",
1997
+ "pluginName": "zapier-platform-cli",
1998
+ "pluginType": "core",
1999
+ "strict": true,
2000
+ "enableJsonFlag": false,
2001
+ "skipValidInstallCheck": true,
2002
+ "isESM": false,
2003
+ "relativePath": [
2004
+ "src",
2005
+ "oclif",
2006
+ "commands",
2007
+ "delete",
2008
+ "integration.js"
2009
+ ]
2010
+ },
2011
+ "delete:version": {
2012
+ "aliases": [],
2013
+ "args": {
2014
+ "version": {
2015
+ "description": "Specify the version to delete. It must have no users or Zaps.",
2016
+ "name": "version",
2017
+ "required": true
2018
+ }
2019
+ },
2020
+ "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.",
2021
+ "flags": {
2022
+ "debug": {
2023
+ "char": "d",
2024
+ "description": "Show extra debugging output.",
2025
+ "name": "debug",
2026
+ "allowNo": false,
2027
+ "type": "boolean"
2028
+ },
2029
+ "invokedFromAnotherCommand": {
2030
+ "hidden": true,
2031
+ "name": "invokedFromAnotherCommand",
2032
+ "allowNo": false,
2033
+ "type": "boolean"
2034
+ }
2035
+ },
2036
+ "hasDynamicHelp": false,
2037
+ "hiddenAliases": [],
2038
+ "id": "delete:version",
2039
+ "pluginAlias": "zapier-platform-cli",
2040
+ "pluginName": "zapier-platform-cli",
2041
+ "pluginType": "core",
2042
+ "strict": true,
2043
+ "enableJsonFlag": false,
2044
+ "skipValidInstallCheck": true,
2045
+ "isESM": false,
2046
+ "relativePath": [
2047
+ "src",
2048
+ "oclif",
2049
+ "commands",
2050
+ "delete",
2051
+ "version.js"
2052
+ ]
2053
+ },
2041
2054
  "team:add": {
2042
2055
  "aliases": [
2043
2056
  "team:invite"
@@ -2417,5 +2430,5 @@
2417
2430
  ]
2418
2431
  }
2419
2432
  },
2420
- "version": "16.5.1"
2433
+ "version": "17.0.0"
2421
2434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-cli",
3
- "version": "16.5.1",
3
+ "version": "17.0.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/",
@@ -40,56 +40,56 @@
40
40
  "validate": "yarn test && yarn smoke-test && yarn lint"
41
41
  },
42
42
  "dependencies": {
43
- "@oclif/core": "4.0.34",
44
- "@oclif/plugin-autocomplete": "3.2.11",
45
- "@oclif/plugin-help": "6.2.18",
46
- "@oclif/plugin-not-found": "3.2.29",
47
- "@oclif/plugin-version": "2.2.16",
43
+ "@oclif/core": "4.3.0",
44
+ "@oclif/plugin-autocomplete": "3.2.28",
45
+ "@oclif/plugin-help": "6.2.28",
46
+ "@oclif/plugin-not-found": "3.2.51",
47
+ "@oclif/plugin-version": "2.2.28",
48
48
  "adm-zip": "0.5.16",
49
49
  "archiver": "7.0.1",
50
- "browserify": "17.0.1",
51
- "chrono-node": "2.7.7",
50
+ "chrono-node": "2.8.0",
52
51
  "cli-table3": "0.6.5",
53
52
  "colors": "1.4.0",
54
- "debug": "4.3.7",
55
- "dotenv": "16.4.6",
53
+ "debug": "4.4.0",
54
+ "dotenv": "16.5.0",
55
+ "esbuild": "0.25.4",
56
56
  "fs-extra": "11.2.0",
57
57
  "gulp-filter": "7.0.0",
58
- "gulp-prettier": "4.0.0",
58
+ "gulp-prettier": "5.0.0",
59
59
  "ignore": "5.2.4",
60
60
  "inquirer": "8.2.5",
61
- "jscodeshift": "^17.0.0",
61
+ "jscodeshift": "^17.3.0",
62
62
  "klaw": "4.1.0",
63
63
  "lodash": "4.17.21",
64
- "luxon": "3.5.0",
64
+ "luxon": "3.6.1",
65
65
  "marked": "14.1.4",
66
66
  "marked-terminal": "7.2.1",
67
67
  "minimatch": "9.0.3",
68
68
  "node-fetch": "2.7.0",
69
- "open": "10.1.0",
69
+ "open": "10.1.2",
70
70
  "ora": "5.4.0",
71
71
  "parse-gitignore": "0.5.1",
72
- "prettier": "3.4.1",
73
- "read": "4.0.0",
74
- "semver": "7.6.3",
72
+ "prettier": "3.5.3",
73
+ "read": "4.1.0",
74
+ "semver": "7.7.1",
75
75
  "string-length": "4.0.2",
76
76
  "through2": "4.0.2",
77
77
  "tmp": "0.2.3",
78
- "traverse": "0.6.10",
78
+ "traverse": "0.6.11",
79
79
  "update-notifier": "5.1.0",
80
80
  "yeoman-environment": "3.19.3",
81
81
  "yeoman-generator": "5.9.0"
82
82
  },
83
83
  "devDependencies": {
84
- "@oclif/test": "^4.0.9",
84
+ "@oclif/test": "^4.1.12",
85
85
  "@types/jscodeshift": "^0.12.0",
86
86
  "@types/mocha": "^10.0.9",
87
87
  "chai": "^4.3.7",
88
88
  "decompress": "4.2.1",
89
- "mock-fs": "^5.2.0",
90
- "nock": "^13.3.1",
91
- "oclif": "^4.15.30",
92
- "typescript": "^5.6.3",
89
+ "mock-fs": "^5.5.0",
90
+ "nock": "^14.0.4",
91
+ "oclif": "^4.17.46",
92
+ "typescript": "^5.8.3",
93
93
  "yamljs": "0.3.0"
94
94
  },
95
95
  "bin": {
@@ -1,21 +1,31 @@
1
- import type { Create, PerformFunction } from 'zapier-platform-core';
1
+ import {
2
+ defineInputFields,
3
+ defineCreate,
4
+ type CreatePerform,
5
+ type InferInputData,
6
+ } from 'zapier-platform-core';
7
+
8
+ const inputFields = defineInputFields([
9
+ { key: 'name', required: true },
10
+ { key: 'fave_meal', label: 'Favorite Meal', required: false },
11
+ ]);
2
12
 
3
13
  // create a particular <%= LOWER_NOUN %> by name
4
- const perform: PerformFunction = async (z, bundle) => {
14
+ const perform = (async (z, bundle) => {
5
15
  const response = await z.request({
6
16
  method: 'POST',
7
17
  url: 'https://jsonplaceholder.typicode.com/posts',
8
18
  // if `body` is an object, it'll automatically get run through JSON.stringify
9
19
  // if you don't want to send JSON, pass a string in your chosen format here instead
10
20
  body: {
11
- name: bundle.inputData.name
12
- }
21
+ name: bundle.inputData.name,
22
+ },
13
23
  });
14
24
  // this should return a single object
15
25
  return response.data;
16
- };
26
+ }) satisfies CreatePerform<InferInputData<typeof inputFields>>;
17
27
 
18
- export default {
28
+ export default defineCreate({
19
29
  // see here for a full list of available properties:
20
30
  // https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#createschema
21
31
  key: '<%= KEY %>',
@@ -34,10 +44,7 @@ export default {
34
44
  '// Zapier will pass them in as `bundle.inputData` later. They\'re optional.',
35
45
  '// End-users will map data into these fields. In general, they should have any fields that the API can accept. Be sure to accurately mark which fields are required!'
36
46
  ].join('\n ') : '' %>
37
- inputFields: [
38
- {key: 'name', required: true},
39
- {key: 'fave_meal', label: 'Favorite Meal', required: false}
40
- ],
47
+ inputFields,
41
48
 
42
49
  <%= INCLUDE_INTRO_COMMENTS ? [
43
50
  '// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
@@ -46,7 +53,7 @@ export default {
46
53
  ].join('\n ') : '' %>
47
54
  sample: {
48
55
  id: 1,
49
- name: 'Test'
56
+ name: 'Test',
50
57
  },
51
58
 
52
59
  <%= INCLUDE_INTRO_COMMENTS ? [
@@ -59,6 +66,6 @@ export default {
59
66
  // these are placeholders to match the example `perform` above
60
67
  // {key: 'id', label: 'Person ID'},
61
68
  // {key: 'name', label: 'Person Name'}
62
- ]
63
- }
64
- } satisfies Create;
69
+ ],
70
+ },
71
+ });
@@ -1,7 +1,20 @@
1
- import type { PerformFunction, Search } from 'zapier-platform-core';
1
+ import {
2
+ defineInputFields,
3
+ defineSearch,
4
+ type SearchPerform,
5
+ type InferInputData,
6
+ } from 'zapier-platform-core';
7
+
8
+ const inputFields = defineInputFields([
9
+ {
10
+ key: 'name',
11
+ required: true,
12
+ helpText: 'Find the <%= NOUN %> with this name.',
13
+ },
14
+ ]);
2
15
 
3
16
  // find a particular <%= LOWER_NOUN %> by name
4
- const perform: PerformFunction = async (z, bundle) => {
17
+ const perform = (async (z, bundle) => {
5
18
  const response = await z.request({
6
19
  url: 'https://jsonplaceholder.typicode.com/posts',
7
20
  params: {
@@ -10,9 +23,9 @@ const perform: PerformFunction = async (z, bundle) => {
10
23
  });
11
24
  // this should return an array of objects (but only the first will be used)
12
25
  return response.data;
13
- };
26
+ }) satisfies SearchPerform<InferInputData<typeof inputFields>>;
14
27
 
15
- export default {
28
+ export default defineSearch({
16
29
  // see here for a full list of available properties:
17
30
  // https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#searchschema
18
31
  key: '<%= KEY %>',
@@ -30,13 +43,7 @@ export default {
30
43
  '// `inputFields` defines the fields a user could provide',
31
44
  '// Zapier will pass them in as `bundle.inputData` later. Searches need at least one `inputField`.'
32
45
  ].join('\n ') : '' %>
33
- inputFields: [
34
- {
35
- key: 'name',
36
- required: true,
37
- helpText: 'Find the <%= NOUN %> with this name.',
38
- },
39
- ],
46
+ inputFields,
40
47
 
41
48
  <%= INCLUDE_INTRO_COMMENTS ? [
42
49
  '// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
@@ -60,4 +67,4 @@ export default {
60
67
  // {key: 'name', label: 'Person Name'}
61
68
  ],
62
69
  },
63
- } satisfies Search;
70
+ });
@@ -1,7 +1,10 @@
1
- import type { PerformFunction, Trigger } from 'zapier-platform-core';
1
+ import {
2
+ defineTrigger,
3
+ type PollingTriggerPerform,
4
+ } from 'zapier-platform-core';
2
5
 
3
6
  // triggers on a new <%= LOWER_NOUN %> with a certain tag
4
- const perform: PerformFunction = async (z, bundle) => {
7
+ const perform = (async (z, bundle) => {
5
8
  const response = await z.request({
6
9
  url: 'https://jsonplaceholder.typicode.com/posts',
7
10
  params: {
@@ -10,9 +13,9 @@ const perform: PerformFunction = async (z, bundle) => {
10
13
  });
11
14
  // this should return an array of objects
12
15
  return response.data;
13
- };
16
+ }) satisfies PollingTriggerPerform;
14
17
 
15
- export default {
18
+ export default defineTrigger({
16
19
  // see here for a full list of available properties:
17
20
  // https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#triggerschema
18
21
  key: '<%= KEY %>' as const,
@@ -55,4 +58,4 @@ export default {
55
58
  // {key: 'name', label: 'Person Name'}
56
59
  ],
57
60
  },
58
- } satisfies Trigger;
61
+ });
@@ -32,6 +32,18 @@ const writeGitignore = (gen) => {
32
32
  };
33
33
 
34
34
  const writeGenericPackageJson = (gen, packageJsonExtension) => {
35
+ const moduleExtension =
36
+ gen.options.module === 'esm'
37
+ ? {
38
+ exports: './index.js',
39
+ type: 'module',
40
+ }
41
+ : {
42
+ main: 'index.js',
43
+ };
44
+
45
+ const fullExtension = merge(moduleExtension, packageJsonExtension);
46
+
35
47
  gen.fs.writeJSON(
36
48
  gen.destinationPath('package.json'),
37
49
  merge(
@@ -39,7 +51,6 @@ const writeGenericPackageJson = (gen, packageJsonExtension) => {
39
51
  name: gen.options.packageName,
40
52
  version: '1.0.0',
41
53
  description: '',
42
- main: 'index.js',
43
54
  scripts: {
44
55
  test: 'jest --testTimeout 10000',
45
56
  },
@@ -51,12 +62,24 @@ const writeGenericPackageJson = (gen, packageJsonExtension) => {
51
62
  },
52
63
  private: true,
53
64
  },
54
- packageJsonExtension,
65
+ fullExtension,
55
66
  ),
56
67
  );
57
68
  };
58
69
 
59
70
  const writeTypeScriptPackageJson = (gen, packageJsonExtension) => {
71
+ const moduleExtension =
72
+ gen.options.module === 'esm'
73
+ ? {
74
+ exports: './dist/index.js',
75
+ type: 'module',
76
+ }
77
+ : {
78
+ main: 'index.js',
79
+ };
80
+
81
+ const fullExtension = merge(moduleExtension, packageJsonExtension);
82
+
60
83
  gen.fs.writeJSON(
61
84
  gen.destinationPath('package.json'),
62
85
  merge(
@@ -64,7 +87,6 @@ const writeTypeScriptPackageJson = (gen, packageJsonExtension) => {
64
87
  name: gen.options.packageName,
65
88
  version: '1.0.0',
66
89
  description: '',
67
- main: 'src/index.js',
68
90
  scripts: {
69
91
  test: 'vitest',
70
92
  },
@@ -76,19 +98,40 @@ const writeTypeScriptPackageJson = (gen, packageJsonExtension) => {
76
98
  },
77
99
  private: true,
78
100
  },
79
- packageJsonExtension,
101
+ fullExtension,
80
102
  ),
81
103
  );
82
104
  };
83
105
 
84
106
  const writeGenericIndex = (gen, hasAuth) => {
107
+ const templatePath =
108
+ gen.options.module === 'esm'
109
+ ? 'index-esm.template.js'
110
+ : 'index.template.js';
85
111
  gen.fs.copyTpl(
86
- gen.templatePath('index.template.js'),
112
+ gen.templatePath(templatePath),
87
113
  gen.destinationPath('index.js'),
88
114
  { corePackageName: PLATFORM_PACKAGE, hasAuth },
89
115
  );
90
116
  };
91
117
 
118
+ const writeTypeScriptIndex = (gen) => {
119
+ const templatePath =
120
+ gen.options.module === 'esm'
121
+ ? 'index-esm.template.ts'
122
+ : 'index.template.ts';
123
+ gen.fs.copyTpl(
124
+ gen.templatePath(templatePath),
125
+ gen.destinationPath('src/index.ts'),
126
+ );
127
+
128
+ // create root directory index.js if it's commonjs
129
+ if (gen.options.module === 'commonjs') {
130
+ const content = `module.exports = require('./dist').default;`;
131
+ gen.fs.write(gen.destinationPath('index.js'), content);
132
+ }
133
+ };
134
+
92
135
  const authTypes = {
93
136
  'basic-auth': 'basic',
94
137
  'custom-auth': 'custom',
@@ -170,7 +213,7 @@ const writeForStandaloneTypeScriptTemplate = (gen) => {
170
213
  const packageJsonExtension = {
171
214
  typescript: {
172
215
  scripts: {
173
- test: 'vitest',
216
+ test: 'vitest --run',
174
217
  clean: 'rimraf ./dist ./build',
175
218
  build: 'npm run clean && tsc',
176
219
  '_zapier-build': 'npm run build',
@@ -189,6 +232,7 @@ const writeForStandaloneTypeScriptTemplate = (gen) => {
189
232
  gen.templatePath(gen.options.template, '**', '*.{js,json,ts}'),
190
233
  gen.destinationPath(),
191
234
  );
235
+ writeTypeScriptIndex(gen);
192
236
  };
193
237
 
194
238
  const TEMPLATE_ROUTES = {
@@ -207,6 +251,8 @@ const TEMPLATE_ROUTES = {
207
251
  typescript: writeForStandaloneTypeScriptTemplate,
208
252
  };
209
253
 
254
+ const ESM_SUPPORTED_TEMPLATES = ['minimal', 'typescript'];
255
+
210
256
  const TEMPLATE_CHOICES = Object.keys(TEMPLATE_ROUTES);
211
257
 
212
258
  class ProjectGenerator extends Generator {
@@ -235,6 +281,31 @@ class ProjectGenerator extends Generator {
235
281
  ]);
236
282
  this.options.template = this.answers.template;
237
283
  }
284
+
285
+ if (
286
+ ESM_SUPPORTED_TEMPLATES.includes(this.options.template) &&
287
+ !this.options.module
288
+ ) {
289
+ this.answers = await this.prompt([
290
+ {
291
+ type: 'list',
292
+ name: 'module',
293
+ choices: ['commonjs', 'esm'],
294
+ message: 'Choose module type:',
295
+ default: 'commonjs',
296
+ },
297
+ ]);
298
+ this.options.module = this.answers.module;
299
+ }
300
+
301
+ if (
302
+ !ESM_SUPPORTED_TEMPLATES.includes(this.options.template) &&
303
+ this.options.module === 'esm'
304
+ ) {
305
+ throw new Error(
306
+ 'ESM is not supported for this template, please use a different template or set the module to commonjs',
307
+ );
308
+ }
238
309
  }
239
310
 
240
311
  writing() {
@@ -0,0 +1,36 @@
1
+ <% if (hasAuth) { %>
2
+ import {
3
+ config as authentication,
4
+ befores = [],
5
+ afters = [],
6
+ } from './authentication';
7
+ <% } %>
8
+
9
+ import packageJson from './package.json' with { type: 'json' };
10
+ import zapier from '<%= corePackageName %>';
11
+
12
+ export default {
13
+ // This is just shorthand to reference the installed dependencies you have.
14
+ // Zapier will need to know these before we can upload.
15
+ version: packageJson.version,
16
+ platformVersion: zapier.version,
17
+
18
+ <% if (hasAuth) { %>
19
+ authentication,
20
+
21
+ beforeRequest: [...befores],
22
+
23
+ afterResponse: [...afters],
24
+ <% } %>
25
+
26
+ // If you want your trigger to show up, you better include it here!
27
+ triggers: {},
28
+
29
+ // If you want your searches to show up, you better include it here!
30
+ searches: {},
31
+
32
+ // If you want your creates to show up, you better include it here!
33
+ creates: {},
34
+
35
+ resources: {},
36
+ };
@@ -0,0 +1,24 @@
1
+ import zapier, { defineApp } from 'zapier-platform-core';
2
+
3
+ import packageJson from '../package.json' with { type: 'json' };
4
+
5
+ import MovieCreate from './creates/movie.js';
6
+ import MovieTrigger from './triggers/movie.js';
7
+ import authentication from './authentication.js';
8
+ import { addBearerHeader } from './middleware.js';
9
+
10
+ export default defineApp({
11
+ version: packageJson.version,
12
+ platformVersion: zapier.version,
13
+
14
+ authentication,
15
+ beforeRequest: [addBearerHeader],
16
+
17
+ triggers: {
18
+ [MovieTrigger.key]: MovieTrigger,
19
+ },
20
+
21
+ creates: {
22
+ [MovieCreate.key]: MovieCreate,
23
+ },
24
+ });