zapier-platform-cli 17.9.1 → 18.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.
- package/oclif.manifest.json +1 -1
- package/package.json +26 -25
- package/src/bin/run-deprecated +14 -0
- package/src/constants.js +1 -1
- package/src/generators/index.js +91 -87
- package/src/generators/pull.js +34 -31
- package/src/oclif/commands/init.js +7 -3
- package/src/oclif/commands/invoke.js +1 -1
- package/src/oclif/commands/pull.js +4 -3
- package/src/oclif/hooks/updateNotifier.js +5 -3
- package/src/utils/build.js +5 -4
- package/src/utils/esm-wrapper.js +86 -0
- package/src/version-store.js +1 -0
- package/src/bin/run.cmd +0 -3
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.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,58 +40,59 @@
|
|
|
40
40
|
"validate": "yarn test && yarn smoke-test && yarn lint"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@oclif/core": "4.
|
|
44
|
-
"@oclif/plugin-autocomplete": "3.2.
|
|
45
|
-
"@oclif/plugin-help": "6.2.
|
|
46
|
-
"@oclif/plugin-not-found": "3.2.
|
|
47
|
-
"@oclif/plugin-version": "2.2.
|
|
43
|
+
"@oclif/core": "4.5.2",
|
|
44
|
+
"@oclif/plugin-autocomplete": "3.2.34",
|
|
45
|
+
"@oclif/plugin-help": "6.2.32",
|
|
46
|
+
"@oclif/plugin-not-found": "3.2.62",
|
|
47
|
+
"@oclif/plugin-version": "2.2.32",
|
|
48
48
|
"adm-zip": "0.5.16",
|
|
49
49
|
"archiver": "7.0.1",
|
|
50
|
-
"chrono-node": "2.8.
|
|
50
|
+
"chrono-node": "2.8.3",
|
|
51
51
|
"cli-table3": "0.6.5",
|
|
52
52
|
"colors": "1.4.0",
|
|
53
|
-
"debug": "4.4.
|
|
53
|
+
"debug": "4.4.1",
|
|
54
54
|
"decompress": "4.2.1",
|
|
55
|
-
"dotenv": "
|
|
56
|
-
"esbuild": "0.25.
|
|
57
|
-
"fs-extra": "11.
|
|
55
|
+
"dotenv": "17.2.1",
|
|
56
|
+
"esbuild": "0.25.8",
|
|
57
|
+
"fs-extra": "11.3.1",
|
|
58
58
|
"gulp-filter": "7.0.0",
|
|
59
59
|
"gulp-prettier": "5.0.0",
|
|
60
|
-
"ignore": "
|
|
60
|
+
"ignore": "7.0.5",
|
|
61
61
|
"inquirer": "8.2.5",
|
|
62
62
|
"jscodeshift": "^17.3.0",
|
|
63
63
|
"lodash": "4.17.21",
|
|
64
|
-
"luxon": "3.
|
|
65
|
-
"marked": "
|
|
66
|
-
"marked-terminal": "7.
|
|
67
|
-
"open": "10.
|
|
64
|
+
"luxon": "3.7.1",
|
|
65
|
+
"marked": "15.0.12",
|
|
66
|
+
"marked-terminal": "7.3.0",
|
|
67
|
+
"open": "10.2.0",
|
|
68
68
|
"ora": "5.4.0",
|
|
69
69
|
"parse-gitignore": "0.5.1",
|
|
70
|
-
"prettier": "3.
|
|
70
|
+
"prettier": "3.6.2",
|
|
71
71
|
"read": "4.1.0",
|
|
72
|
-
"semver": "7.7.
|
|
72
|
+
"semver": "7.7.2",
|
|
73
73
|
"string-length": "4.0.2",
|
|
74
74
|
"through2": "4.0.2",
|
|
75
75
|
"tmp": "0.2.4",
|
|
76
76
|
"traverse": "0.6.11",
|
|
77
|
-
"update-notifier": "
|
|
78
|
-
"yeoman-environment": "
|
|
79
|
-
"yeoman-generator": "5.
|
|
77
|
+
"update-notifier": "7.3.1",
|
|
78
|
+
"yeoman-environment": "4.4.3",
|
|
79
|
+
"yeoman-generator": "7.5.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@oclif/test": "^4.1.
|
|
82
|
+
"@oclif/test": "^4.1.13",
|
|
83
83
|
"@types/jscodeshift": "^0.12.0",
|
|
84
84
|
"@types/mocha": "^10.0.9",
|
|
85
85
|
"chai": "^4.3.7",
|
|
86
86
|
"mock-fs": "^5.5.0",
|
|
87
|
-
"nock": "^14.0.
|
|
88
|
-
"oclif": "^4.
|
|
87
|
+
"nock": "^14.0.7",
|
|
88
|
+
"oclif": "^4.22.5",
|
|
89
89
|
"rimraf": "^5.0.10",
|
|
90
90
|
"typescript": "^5.8.3",
|
|
91
91
|
"yamljs": "0.3.0"
|
|
92
92
|
},
|
|
93
93
|
"bin": {
|
|
94
|
-
"zapier": "./src/bin/run"
|
|
94
|
+
"zapier": "./src/bin/run-deprecated",
|
|
95
|
+
"zapier-platform": "./src/bin/run"
|
|
95
96
|
},
|
|
96
97
|
"oclif": {
|
|
97
98
|
"commands": "src/oclif/commands",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
const oclif = await import('@oclif/core');
|
|
7
|
+
await oclif.execute({ development: false, dir: __dirname });
|
|
8
|
+
|
|
9
|
+
console.warn(
|
|
10
|
+
'[DEPRECATION WARNING] ' +
|
|
11
|
+
'The executable name "zapier" is deprecated and will be removed in a future version. ' +
|
|
12
|
+
'Please use "zapier-platform" instead.',
|
|
13
|
+
);
|
|
14
|
+
})();
|
package/src/constants.js
CHANGED
|
@@ -20,7 +20,7 @@ const BUILD_PATH = `${BUILD_DIR}/build.zip`;
|
|
|
20
20
|
const SOURCE_PATH = `${BUILD_DIR}/source.zip`;
|
|
21
21
|
const NODE_VERSION = versionStore[versionStore.length - 1].nodeVersion;
|
|
22
22
|
const LAMBDA_VERSION = `v${NODE_VERSION}`;
|
|
23
|
-
const NODE_VERSION_CLI_REQUIRES = '>=
|
|
23
|
+
const NODE_VERSION_CLI_REQUIRES = '>=22'; // should be the oldest non-ETL version
|
|
24
24
|
const AUTH_KEY = 'deployKey';
|
|
25
25
|
const ANALYTICS_KEY = 'analyticsMode';
|
|
26
26
|
const ANALYTICS_MODES = {
|
package/src/generators/index.js
CHANGED
|
@@ -2,12 +2,12 @@ const path = require('path');
|
|
|
2
2
|
|
|
3
3
|
const { merge } = require('lodash');
|
|
4
4
|
const filter = require('gulp-filter');
|
|
5
|
-
const
|
|
5
|
+
const { createGeneratorClass } = require('../utils/esm-wrapper');
|
|
6
6
|
const prettier = require('gulp-prettier');
|
|
7
7
|
|
|
8
8
|
const { PACKAGE_VERSION, PLATFORM_PACKAGE } = require('../constants');
|
|
9
9
|
const authFilesCodegen = require('../utils/auth-files-codegen');
|
|
10
|
-
const
|
|
10
|
+
const PullGeneratorPromise = require('./pull');
|
|
11
11
|
|
|
12
12
|
const writeGenericReadme = (gen) => {
|
|
13
13
|
gen.fs.copyTpl(
|
|
@@ -133,6 +133,7 @@ const writeGenericAuth = (gen) => {
|
|
|
133
133
|
const content = authFilesCodegen[authType](gen.options.language);
|
|
134
134
|
const destPath = (key) =>
|
|
135
135
|
gen.options.language === 'typescript' ? `src/${key}.ts` : `${key}.js`;
|
|
136
|
+
|
|
136
137
|
Object.entries(content).forEach(([key, value]) => {
|
|
137
138
|
gen.fs.write(gen.destinationPath(destPath(key)), value);
|
|
138
139
|
});
|
|
@@ -238,104 +239,107 @@ const TS_SUPPORTED_TEMPLATES = [
|
|
|
238
239
|
|
|
239
240
|
const TEMPLATE_CHOICES = Object.keys(TEMPLATE_ROUTES);
|
|
240
241
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
async prompting() {
|
|
255
|
-
if (!this.options.template) {
|
|
256
|
-
// Filter template choices based on language and module type
|
|
257
|
-
let templateChoices = TEMPLATE_CHOICES;
|
|
258
|
-
let defaultTemplate = 'minimal';
|
|
259
|
-
|
|
260
|
-
// TypeScript filtering takes precedence over ESM filtering
|
|
261
|
-
if (this.options.language === 'typescript') {
|
|
262
|
-
templateChoices = TS_SUPPORTED_TEMPLATES;
|
|
263
|
-
defaultTemplate = 'basic-auth';
|
|
264
|
-
} else if (this.options.module === 'esm') {
|
|
265
|
-
templateChoices = ESM_SUPPORTED_TEMPLATES;
|
|
266
|
-
defaultTemplate = 'minimal'; // minimal is the only ESM template
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
this.answers = await this.prompt([
|
|
270
|
-
{
|
|
271
|
-
type: 'list',
|
|
272
|
-
name: 'template',
|
|
273
|
-
choices: templateChoices,
|
|
274
|
-
message: 'Choose a project template to start with:',
|
|
275
|
-
default: defaultTemplate,
|
|
276
|
-
},
|
|
242
|
+
const ProjectGeneratorPromise = createGeneratorClass((Generator) => {
|
|
243
|
+
return class ProjectGenerator extends Generator {
|
|
244
|
+
initializing() {
|
|
245
|
+
this.sourceRoot(path.resolve(__dirname, 'templates'));
|
|
246
|
+
this.destinationRoot(path.resolve(this.options.path));
|
|
247
|
+
|
|
248
|
+
const jsFilter = filter(['*.js', '*.json', '*.ts'], { restore: true });
|
|
249
|
+
this.queueTransformStream([
|
|
250
|
+
{ disabled: true },
|
|
251
|
+
jsFilter,
|
|
252
|
+
prettier({ singleQuote: true }),
|
|
253
|
+
jsFilter.restore,
|
|
277
254
|
]);
|
|
278
|
-
this.options.template = this.answers.template;
|
|
279
255
|
}
|
|
280
256
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
257
|
+
async prompting() {
|
|
258
|
+
if (!this.options.template) {
|
|
259
|
+
// Filter template choices based on language and module type
|
|
260
|
+
let templateChoices = TEMPLATE_CHOICES;
|
|
261
|
+
let defaultTemplate = 'minimal';
|
|
262
|
+
|
|
263
|
+
// TypeScript filtering takes precedence over ESM filtering
|
|
264
|
+
if (this.options.language === 'typescript') {
|
|
265
|
+
templateChoices = TS_SUPPORTED_TEMPLATES;
|
|
266
|
+
defaultTemplate = 'basic-auth';
|
|
267
|
+
} else if (this.options.module === 'esm') {
|
|
268
|
+
templateChoices = ESM_SUPPORTED_TEMPLATES;
|
|
269
|
+
defaultTemplate = 'minimal'; // minimal is the only ESM template
|
|
270
|
+
}
|
|
296
271
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
'
|
|
303
|
-
|
|
304
|
-
|
|
272
|
+
this.answers = await this.prompt([
|
|
273
|
+
{
|
|
274
|
+
type: 'list',
|
|
275
|
+
name: 'template',
|
|
276
|
+
choices: templateChoices,
|
|
277
|
+
message: 'Choose a project template to start with:',
|
|
278
|
+
default: defaultTemplate,
|
|
279
|
+
},
|
|
280
|
+
]);
|
|
281
|
+
this.options.template = this.answers.template;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (
|
|
285
|
+
ESM_SUPPORTED_TEMPLATES.includes(this.options.template) &&
|
|
286
|
+
!this.options.module
|
|
287
|
+
) {
|
|
288
|
+
this.answers = await this.prompt([
|
|
289
|
+
{
|
|
290
|
+
type: 'list',
|
|
291
|
+
name: 'module',
|
|
292
|
+
choices: ['esm', 'commonjs'],
|
|
293
|
+
message: 'Choose module type:',
|
|
294
|
+
default: 'esm',
|
|
295
|
+
},
|
|
296
|
+
]);
|
|
297
|
+
this.options.module = this.answers.module;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (this.options.language) {
|
|
301
|
+
if (this.options.language === 'typescript') {
|
|
302
|
+
// check if the template supports typescript
|
|
303
|
+
if (!TS_SUPPORTED_TEMPLATES.includes(this.options.template)) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
'Typescript is not supported for this template, please use a different template or set the language to javascript. Supported templates: ' +
|
|
306
|
+
TS_SUPPORTED_TEMPLATES.join(', '),
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
// if they try to combine typescript with commonjs, throw an error
|
|
310
|
+
if (this.options.module === 'commonjs') {
|
|
311
|
+
throw new Error('Typescript is not supported for commonjs');
|
|
312
|
+
} // esm is supported for typescript templates
|
|
305
313
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
} // esm is supported for typescript templates
|
|
314
|
+
} else {
|
|
315
|
+
// default to javascript for the language if it's not set
|
|
316
|
+
this.options.language = 'javascript';
|
|
310
317
|
}
|
|
311
|
-
} else {
|
|
312
|
-
// default to javascript for the language if it's not set
|
|
313
|
-
this.options.language = 'javascript';
|
|
314
|
-
}
|
|
315
318
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
319
|
+
if (
|
|
320
|
+
!ESM_SUPPORTED_TEMPLATES.includes(this.options.template) &&
|
|
321
|
+
this.options.module === 'esm' &&
|
|
322
|
+
this.options.language === 'javascript'
|
|
323
|
+
) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
'ESM is not supported for this template, please use a different template, set the module to commonjs, or try setting the language to Typescript',
|
|
326
|
+
);
|
|
327
|
+
}
|
|
324
328
|
}
|
|
325
|
-
}
|
|
326
329
|
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
writing() {
|
|
331
|
+
this.options.packageName = path.basename(this.options.path);
|
|
329
332
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
333
|
+
const writeFunc = TEMPLATE_ROUTES[this.options.template];
|
|
334
|
+
writeFunc(this);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
});
|
|
334
338
|
|
|
335
339
|
module.exports = {
|
|
336
340
|
TEMPLATE_CHOICES,
|
|
337
341
|
ESM_SUPPORTED_TEMPLATES,
|
|
338
342
|
TS_SUPPORTED_TEMPLATES,
|
|
339
|
-
PullGenerator,
|
|
340
|
-
ProjectGenerator,
|
|
343
|
+
PullGenerator: PullGeneratorPromise,
|
|
344
|
+
ProjectGenerator: ProjectGeneratorPromise,
|
|
341
345
|
};
|
package/src/generators/pull.js
CHANGED
|
@@ -2,7 +2,7 @@ const colors = require('colors/safe');
|
|
|
2
2
|
const debug = require('debug')('zapier:pull');
|
|
3
3
|
const inquirer = require('inquirer');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const
|
|
5
|
+
const { createGeneratorClass } = require('../utils/esm-wrapper');
|
|
6
6
|
|
|
7
7
|
const maybeOverwriteFiles = async (gen) => {
|
|
8
8
|
const dstDir = gen.options.dstDir;
|
|
@@ -12,17 +12,19 @@ const maybeOverwriteFiles = async (gen) => {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// Export a factory function that creates the PullGenerator class
|
|
16
|
+
module.exports = createGeneratorClass((Generator) => {
|
|
17
|
+
return class PullGenerator extends Generator {
|
|
18
|
+
initializing() {
|
|
19
|
+
debug('SRC', this.options.sourceFiles);
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
prompting() {
|
|
23
|
+
const prompts = [
|
|
24
|
+
{
|
|
25
|
+
type: 'confirm',
|
|
26
|
+
name: 'confirm',
|
|
27
|
+
message: `Warning: You are about to overwrite existing files.
|
|
26
28
|
|
|
27
29
|
Before proceeding, please make sure you have saved your work. Consider creating a backup or saving your current state in a git branch.
|
|
28
30
|
|
|
@@ -30,23 +32,24 @@ If presented with a series of options ('ynarxdeiH'), you may
|
|
|
30
32
|
press Enter to view more details about each option. For example, 'x' will abort the process.
|
|
31
33
|
|
|
32
34
|
Do you want to continue?`,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
return inquirer.prompt(prompts).then((answers) => {
|
|
40
|
+
if (!answers.confirm) {
|
|
41
|
+
this.log(colors.green('zapier pull cancelled'));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
writing() {
|
|
48
|
+
maybeOverwriteFiles(this);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
end() {
|
|
52
|
+
this.log(colors.green('zapier pull completed successfully'));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
});
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
const { join } = require('path');
|
|
2
2
|
|
|
3
3
|
const { Args, Flags } = require('@oclif/core');
|
|
4
|
-
const
|
|
4
|
+
const { createEnv } = require('../../utils/esm-wrapper');
|
|
5
5
|
|
|
6
6
|
const BaseCommand = require('../ZapierBaseCommand');
|
|
7
7
|
const { buildFlags } = require('../buildFlags');
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
TEMPLATE_CHOICES,
|
|
10
|
+
ProjectGenerator: ProjectGeneratorPromise,
|
|
11
|
+
} = require('../../generators');
|
|
9
12
|
|
|
10
13
|
class InitCommand extends BaseCommand {
|
|
11
14
|
async perform() {
|
|
12
15
|
const { path } = this.args;
|
|
13
16
|
const { template, module, language } = this.flags;
|
|
14
17
|
|
|
15
|
-
const env =
|
|
18
|
+
const env = await createEnv(); // await needed because createEnv() uses dynamic import() for ESM-only yeoman-environment
|
|
19
|
+
const ProjectGenerator = await ProjectGeneratorPromise; // await needed because generator classes are now created via ESM dynamic import
|
|
16
20
|
env.registerStub(ProjectGenerator, 'zapier:integration');
|
|
17
21
|
|
|
18
22
|
await env.run('zapier:integration', { path, template, module, language });
|
|
@@ -1086,7 +1086,7 @@ class InvokeCommand extends BaseCommand {
|
|
|
1086
1086
|
async perform() {
|
|
1087
1087
|
let authId = this.flags['authentication-id'];
|
|
1088
1088
|
|
|
1089
|
-
const dotenvResult = dotenv.config({ override: true });
|
|
1089
|
+
const dotenvResult = dotenv.config({ override: true, quiet: true });
|
|
1090
1090
|
if (!authId && _.isEmpty(dotenvResult.parsed)) {
|
|
1091
1091
|
console.warn(
|
|
1092
1092
|
'The .env file does not exist or is empty. ' +
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const AdmZip = require('adm-zip');
|
|
2
2
|
const { ensureFileSync } = require('fs-extra');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const
|
|
4
|
+
const { createEnv } = require('../../utils/esm-wrapper');
|
|
5
5
|
|
|
6
6
|
const ZapierBaseCommand = require('../ZapierBaseCommand');
|
|
7
7
|
const { downloadSourceZip } = require('../../utils/api');
|
|
8
8
|
const { ensureDir, makeTempDir, removeDirSync } = require('../../utils/files');
|
|
9
9
|
const { walkDirWithPresetBlocklist } = require('../../utils/build');
|
|
10
10
|
const { buildFlags } = require('../buildFlags');
|
|
11
|
-
const
|
|
11
|
+
const PullGeneratorPromise = require('../../generators/pull');
|
|
12
12
|
|
|
13
13
|
const listFiles = (dir) => {
|
|
14
14
|
const relPaths = [];
|
|
@@ -38,7 +38,8 @@ class PullCommand extends ZapierBaseCommand {
|
|
|
38
38
|
const currentDir = process.cwd();
|
|
39
39
|
const sourceFiles = listFiles(srcDst);
|
|
40
40
|
|
|
41
|
-
const env =
|
|
41
|
+
const env = await createEnv(); // await needed because createEnv() uses dynamic import() for ESM-only yeoman-environment
|
|
42
|
+
const PullGenerator = await PullGeneratorPromise; // await needed because generator classes are now created via ESM dynamic import
|
|
42
43
|
const namespace = 'zapier:pull';
|
|
43
44
|
env.registerStub(PullGenerator, namespace);
|
|
44
45
|
await env.run(namespace, {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { createUpdateNotifier } = require('../../utils/esm-wrapper');
|
|
2
2
|
const pkg = require('../../../package.json');
|
|
3
3
|
const { UPDATE_NOTIFICATION_INTERVAL } = require('../../constants');
|
|
4
4
|
|
|
5
5
|
// can't be fat arrow because it inherits `this` from commands
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// Made async because createUpdateNotifier() uses dynamic import() to load ESM-only update-notifier package
|
|
7
|
+
module.exports = async function (options) {
|
|
8
|
+
const notifier = await createUpdateNotifier({
|
|
9
|
+
// await needed for ESM dynamic import
|
|
8
10
|
pkg,
|
|
9
11
|
updateCheckInterval: UPDATE_NOTIFICATION_INTERVAL,
|
|
10
12
|
});
|
package/src/utils/build.js
CHANGED
|
@@ -11,7 +11,7 @@ const archiver = require('archiver');
|
|
|
11
11
|
const colors = require('colors/safe');
|
|
12
12
|
const esbuild = require('esbuild');
|
|
13
13
|
const fse = require('fs-extra');
|
|
14
|
-
const
|
|
14
|
+
const { createUpdateNotifier } = require('./esm-wrapper');
|
|
15
15
|
const decompress = require('decompress');
|
|
16
16
|
|
|
17
17
|
const {
|
|
@@ -468,7 +468,8 @@ const makeSourceZip = async (workingDir, zipPath) => {
|
|
|
468
468
|
await zip.finish();
|
|
469
469
|
};
|
|
470
470
|
|
|
471
|
-
const maybeNotifyAboutOutdated = () => {
|
|
471
|
+
const maybeNotifyAboutOutdated = async () => {
|
|
472
|
+
// Made async because createUpdateNotifier() uses dynamic import() to load ESM-only update-notifier package
|
|
472
473
|
// find a package.json for the app and notify on the core dep
|
|
473
474
|
// `build` won't run if package.json isn't there, so if we get to here we're good
|
|
474
475
|
const requiredVersion = _.get(
|
|
@@ -477,7 +478,7 @@ const maybeNotifyAboutOutdated = () => {
|
|
|
477
478
|
);
|
|
478
479
|
|
|
479
480
|
if (requiredVersion) {
|
|
480
|
-
const notifier =
|
|
481
|
+
const notifier = await createUpdateNotifier({
|
|
481
482
|
pkg: { name: PLATFORM_PACKAGE, version: requiredVersion },
|
|
482
483
|
updateCheckInterval: UPDATE_NOTIFICATION_INTERVAL,
|
|
483
484
|
});
|
|
@@ -603,7 +604,7 @@ const _buildFunc = async (
|
|
|
603
604
|
const maybeEndSpinner = printProgress ? endSpinner : () => {};
|
|
604
605
|
|
|
605
606
|
if (checkOutdated) {
|
|
606
|
-
maybeNotifyAboutOutdated();
|
|
607
|
+
await maybeNotifyAboutOutdated(); // await needed because function is now async due to ESM import
|
|
607
608
|
}
|
|
608
609
|
const appDir = process.cwd();
|
|
609
610
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommonJS wrapper for ESM-only modules
|
|
3
|
+
* This allows us to use yeoman-environment v4+, yeoman-generator v7+, and update-notifier v7+ from CommonJS code without downgrading
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
let yeomanEnvironment = null;
|
|
7
|
+
let yeomanGenerator = null;
|
|
8
|
+
let updateNotifier = null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Lazy-load yeoman-environment using dynamic import
|
|
12
|
+
* @returns {Promise<Object>} The yeoman-environment module
|
|
13
|
+
*/
|
|
14
|
+
async function getYeomanEnvironment() {
|
|
15
|
+
if (!yeomanEnvironment) {
|
|
16
|
+
yeomanEnvironment = await import('yeoman-environment');
|
|
17
|
+
}
|
|
18
|
+
return yeomanEnvironment;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Lazy-load yeoman-generator using dynamic import
|
|
23
|
+
* @returns {Promise<Object>} The yeoman-generator module
|
|
24
|
+
*/
|
|
25
|
+
async function getYeomanGenerator() {
|
|
26
|
+
if (!yeomanGenerator) {
|
|
27
|
+
yeomanGenerator = await import('yeoman-generator');
|
|
28
|
+
}
|
|
29
|
+
return yeomanGenerator;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Lazy-load update-notifier using dynamic import
|
|
34
|
+
* @returns {Promise<Object>} The update-notifier module
|
|
35
|
+
*/
|
|
36
|
+
async function getUpdateNotifier() {
|
|
37
|
+
if (!updateNotifier) {
|
|
38
|
+
updateNotifier = await import('update-notifier');
|
|
39
|
+
}
|
|
40
|
+
return updateNotifier;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a yeoman environment (async version of yeoman.createEnv())
|
|
45
|
+
* @param {Object} options - Environment options
|
|
46
|
+
* @returns {Promise<Object>} Environment instance
|
|
47
|
+
*/
|
|
48
|
+
async function createEnv(options) {
|
|
49
|
+
const yeoman = await getYeomanEnvironment();
|
|
50
|
+
return yeoman.createEnv(options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the Generator class (async version of require('yeoman-generator'))
|
|
55
|
+
* @returns {Promise<Function>} The Generator class
|
|
56
|
+
*/
|
|
57
|
+
async function getGenerator() {
|
|
58
|
+
const yeomanGen = await getYeomanGenerator();
|
|
59
|
+
return yeomanGen.default;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create a generator class factory that extends the yeoman Generator
|
|
64
|
+
* @param {Function} generatorFactory - A function that takes Generator class and returns a class extending it
|
|
65
|
+
* @returns {Promise<Function>} The generated class
|
|
66
|
+
*/
|
|
67
|
+
async function createGeneratorClass(generatorFactory) {
|
|
68
|
+
const Generator = await getGenerator();
|
|
69
|
+
return generatorFactory(Generator);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create an update notifier (async version of require('update-notifier'))
|
|
74
|
+
* @param {Object} options - Update notifier options (pkg, updateCheckInterval, etc.)
|
|
75
|
+
* @returns {Promise<Object>} Update notifier instance
|
|
76
|
+
*/
|
|
77
|
+
async function createUpdateNotifier(options) {
|
|
78
|
+
const updateNotifierModule = await getUpdateNotifier();
|
|
79
|
+
return updateNotifierModule.default(options);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
createEnv,
|
|
84
|
+
createGeneratorClass,
|
|
85
|
+
createUpdateNotifier,
|
|
86
|
+
};
|
package/src/version-store.js
CHANGED
package/src/bin/run.cmd
DELETED