Lines 16-56javascript
17 const targetDir = process.cwd();
18 fse.ensureDirSync(path.join(targetDir, packageName));
19 for (const [filename, template] of Object.entries(TEMPLATES)) {
20 const rendered = ejs.render(template, MenuValue);
21 const destPath = path.join(targetDir, packageName, filename);
22 fse.writeFileSync(destPath, rendered, 'utf-8');
23 log.info(colors.green(`生成文件: ${filename}`));
25 log.info(colors.green('项目创建完成!'));
27 log.error('项目创建时发生错误:', err.message);
31function generateTemplates(packageName) {
33 TEMPLATES[`${packageName}.js`] = `
35 const localPath = "/sdcard/Download/zzCommonUtil"
37 const zzCommonFunc = require(localPath + '/zzCommonUtil.js')
38 const { timeout, tempImag } = require(localPath + '/constant.js')
MediumDynamic Require
Package source references dynamic require/import behavior.
lib/actions/handlers/create-template.jsView on unpkg · L36 39 const pkgName = "<%= packageName %>"
42 function gameAction() {
43 // 行为操作 zzCommonFunc.clickAction 广告第四个参数需要设为true
44 zzCommonFunc.setScreenshot(tempImag)
47 zzCommonFunc.taskMainThread(pkgName, () => { }, () => {
48 // zzCommonFunc.appCommonAction 第三个参数为是否循环,第四个参数是否IAA
49 zzCommonFunc.newThread(() => zzCommonFunc.appCommonAction(pkgName, gameAction, true, true), false, timeout, () => { })
50 }, () => { }, apkType, '')
53 TEMPLATES['project.json'] = `
56 "main": "<%= packageName %>.js",