当前位置: 首页 > news >正文

网站注册设计推广赚钱一个50元

网站注册设计,推广赚钱一个50元,wordpress外贸建站怎么加左侧边栏,项城做网站以下主要简化复杂的打包流程,按照 delete -> wpspublish -> custom 的顺序运行 1. deleteFolder.js 用途:该脚本的主要功能是清理项目中的临时文件夹和文件,为后续的打包操作做准备。具体操作: 尝试递归删除 wps-addon-bu…

以下主要简化复杂的打包流程,按照 delete -> wpspublish -> custom 的顺序运行

1. deleteFolder.js

  • 用途:该脚本的主要功能是清理项目中的临时文件夹和文件,为后续的打包操作做准备。
  • 具体操作
    • 尝试递归删除 wps-addon-build 和 wps-addon-publish 这两个文件夹。如果文件夹不存在,脚本会正常提示无需删除;若删除过程中出现其他错误,则会输出相应的错误信息。
    • 检查 wps-addon-build.zip 文件是否存在,若存在则将其删除;若文件不存在,也会给出相应提示。

删除:

const path = require('path');
const fs2 = require('fs').promises;
const fs = require('fs');async function deleteFolder(folderPath) {try {await fs2.rmdir(folderPath, { recursive: true });console.log(`Successfully deleted folder: ${folderPath}`);} catch (err) {if (err.code === 'ENOENT') {// Folder does not exist, which is not an error in our contextconsole.log(`Folder does not exist: ${folderPath}, no need to delete.`);} else {// Some other error occurredconsole.error(`Error deleting folder: ${folderPath}`, err);}}
}async function main() {const foldersToDelete = ['wps-addon-build','wps-addon-publish'];for (const folder of foldersToDelete) {const fullPath = path.join(__dirname, folder);await deleteFolder(fullPath);}// Handling the ZIP file as beforeconst zipFilePath = path.join(__dirname, 'wps-addon-build.zip');if (fs.existsSync(zipFilePath)) {try {fs.unlinkSync(zipFilePath);console.log('File deleted successfully (sync)');} catch (err) {console.error('Error deleting file (sync):', err);}} else {console.log('ZIP file does not exist, no need to delete.');}
}main().catch(err => {console.error('Error in main function:', err);
});

2. wpspublish.js

  • 用途:此脚本的主要任务是查找 wpsjs 可执行文件,并使用 Node.js 启动子进程来执行 wpsjs publish 打包命令,同时处理该命令执行过程中的自动化交互。
  • 具体操作
    • 从环境变量 PATH 中查找 wpsjs 的路径。
    • 若找到 wpsjs 可执行文件,使用 spawn 函数启动一个子进程来执行 wpsjs publish 命令。
    • 在子进程执行过程中,监听其标准输出,当遇到需要输入服务器地址、选择发布类型或确认多用户使用等提示时,自动模拟输入相应信息,并使用防抖函数避免重复输出提示信息。
    • 监听子进程的标准错误流和退出事件,输出相应的错误信息和退出码。

打包:

const { spawn } = require('child_process');
const path = require('path');
// 从环境变量中查找 wpsjs 路径
function findWpsjsInPath() {const paths = process.env.PATH.split(path.delimiter);  // 分割环境变量 PATHfor (let dir of paths) {const wpsjsPath = path.join(dir, 'wpsjs');if (pathExists(wpsjsPath)) {return wpsjsPath;  // 返回找到的 wpsjs 路径}}return null;
}// 检查路径是否存在
function pathExists(filePath) {try {return require('fs').existsSync(filePath);} catch (e) {return false;}
}// 执行 wpsjs 命令
const wpsjsPath = findWpsjsInPath();  // 查找 wpsjs 路径if (wpsjsPath) {// 如果找到了 wpsjs 可执行文件console.log(`Found wpsjs at: ${wpsjsPath}`);// 用node启动子进程执行 wpsjs 发布命令const command = 'node';const args = [wpsjsPath, 'publish'];// const args = ['D:\\01tools\\npm\\node_modules\\wpsjs\\src\\index.js', 'publish'];// 启动子进程const child = spawn(command, args, { stdio: ['pipe', 'pipe', 'pipe'] });// 定义防抖定时器let debounceTimeoutServer = null;  // 防抖定时器 - 服务器地址let debounceTimeoutType = null;    // 防抖定时器 - 发布类型let debounceTimeoutMultiUser = null;  // 防抖定时器 - 多用户// 监听子进程的标准输出child.stdout.on('data', (data) => {let output = data.toString().replace(/^\?/, '').trim();  // 去除开头的问号,并去除多余的空格// 处理自动化交互if (output.includes('请输入发布 WPS 加载项的服务器地址')) {child.stdin.write('a/\n');  // 模拟输入服务器地址// 防抖:服务器地址输入debounceTimeoutServer = setDebounceTimer(debounceTimeoutServer, () => {console.log(output);});}if (output.includes('选择 WPS 加载项发布类型')) {child.stdin.write('\n');  // 输入回车选择发布类型// 防抖:发布类型选择debounceTimeoutType = setDebounceTimer(debounceTimeoutType, () => {console.log(output);});}if (output.includes('您的publish页面是否需要满足多用户同时使用')) {child.stdin.write('\n');  // 确认操作,按回车// 防抖:多用户选择debounceTimeoutMultiUser = setDebounceTimer(debounceTimeoutMultiUser, () => {console.log(output);});}});// 监听标准错误流child.stderr.on('data', (data) => {console.error('stderr:', data.toString());  // 打印所有的 stderr 输出});// 监听子进程退出child.on('close', (code) => {console.log(`子进程退出,退出码: ${code}`);if (code !== 0) {console.log('进程出现错误,退出代码不是 0');}});
}// 防抖函数
function setDebounceTimer(timer, callback, delay = 500) {// 清除之前的定时器if (timer) {clearTimeout(timer);}// 设置新的定时器return setTimeout(callback, delay);
}

3. CustomZipPlugin.js

  • 用途:该脚本主要负责识别 wps-addon-build 目录,将 publish_html 目录的内容复制到 wps-addon-build 目录,并在复制完成后将 wps-addon-build 目录压缩成 wps.tar.gz 文件。
  • 具体操作
    • 检查 wps-addon-build 目录是否存在,若存在则调用复制目录的函数;若不存在或检查过程中出现错误,会输出相应的提示信息。
    • 将 publish_html 目录的内容复制到 wps-addon-build 目录。
    • 复制完成后,将 wps-addon-build 目录压缩成 wps.tar.gz 文件,并输出压缩结果信息。

移动文件+压缩

const fs = require('fs-extra');
const path = require('path');
// const archiver = require('archiver');checkFolderExists('wps-addon-build')
// 识别wps-addon-build目录
async function checkFolderExists(folderName) {try {const folderPath = path.join(__dirname, folderName);const stats = await fs.stat(folderPath);if (stats.isDirectory()) {//文件是否存在console.log(`The folder "${folderName}" exists.1111111`);// 调用复制目录的函数copyDirectory();return true;} else {console.log(`A file or something else named "${folderName}" exists, but it is not a folder.`);return false;}} catch (err) {if (err.code === 'ENOENT') {console.log(`The folder "${folderName}" does not exist.`);return false;} else {console.error(`An error occurred while checking for the folder: ${err.message}`);throw err; // Re-throw the error after logging it}}
}
// 复制目录及其内容的异步函数
async function copyDirectory() {// 源目录(publish_html)和目标目录(wps-addon-build)的路径const sourceDir = path.resolve(__dirname, 'publish_html');const targetDir = path.resolve(__dirname, 'wps-addon-build');try {await fs.copy(sourceDir, targetDir, { dereference: true });console.log('Directory has been copied successfully.');// 直接执行后续代码// CustomTarGzPlugin();} catch (err) {console.error('Error copying directory:', err);}
}
// 在目录复制完成后打压缩包
function CustomTarGzPlugin() {const sourceFolder = path.join(__dirname, 'wps-addon-build');const outputTarGzPath = path.join(__dirname, 'wps.tar.gz');tarGzFolder(sourceFolder, outputTarGzPath).then(() => {console.log('Folder has been successfully tar.gz\'ed!');}).catch(err => {console.error('An error occurred while tar.gz\'ing the folder:', err);});
}// 压缩成 tar.gz 包
async function tarGzFolder(sourceFolder, outputTarGzPath) {return new Promise((resolve, reject) => {const output = fs.createWriteStream(outputTarGzPath);const archive = archiver('tar', {gzip: true,      // 启用 gzip 压缩gzipOptions: {level: 9       // 设置压缩级别}});output.on('close', function () {console.log(archive.pointer() + ' total bytes');console.log('archiver has been finalized and the output file descriptor has closed.');resolve();});archive.on('error', function (err) {reject(err);});archive.pipe(output);archive.directory(sourceFolder, false);archive.finalize();});
}

最后按顺序跑脚本即可,一行命令:

node delete.js && node wpspublish.js && node custom.js 

也可以简化操作:package.json

最后npm run wps即可


文章转载自:
http://gudgeon.c7625.cn
http://swelter.c7625.cn
http://vicariance.c7625.cn
http://familiarly.c7625.cn
http://slumlord.c7625.cn
http://yashmak.c7625.cn
http://conceptually.c7625.cn
http://evolutionary.c7625.cn
http://simonist.c7625.cn
http://trimness.c7625.cn
http://going.c7625.cn
http://interleaving.c7625.cn
http://lahore.c7625.cn
http://strategetic.c7625.cn
http://presumedly.c7625.cn
http://detectible.c7625.cn
http://geologic.c7625.cn
http://amphibole.c7625.cn
http://bead.c7625.cn
http://turmeric.c7625.cn
http://repeaters.c7625.cn
http://demivolt.c7625.cn
http://antirabic.c7625.cn
http://rotavirus.c7625.cn
http://reedbird.c7625.cn
http://portcrayon.c7625.cn
http://beloved.c7625.cn
http://quantifiable.c7625.cn
http://pleven.c7625.cn
http://earthrise.c7625.cn
http://colourbearer.c7625.cn
http://walkdown.c7625.cn
http://ide.c7625.cn
http://inadvertently.c7625.cn
http://circumvolution.c7625.cn
http://crowbill.c7625.cn
http://actograph.c7625.cn
http://carriable.c7625.cn
http://pathobiology.c7625.cn
http://nemertine.c7625.cn
http://kraal.c7625.cn
http://priapean.c7625.cn
http://embarrassedly.c7625.cn
http://footwall.c7625.cn
http://corticous.c7625.cn
http://morphophysiology.c7625.cn
http://scotodinia.c7625.cn
http://elude.c7625.cn
http://semitruck.c7625.cn
http://desalinate.c7625.cn
http://fissionable.c7625.cn
http://ferrimagnetism.c7625.cn
http://ho.c7625.cn
http://cognizable.c7625.cn
http://disburden.c7625.cn
http://superrealist.c7625.cn
http://papillary.c7625.cn
http://dairen.c7625.cn
http://contumelious.c7625.cn
http://monkeyshine.c7625.cn
http://defendable.c7625.cn
http://bacteremic.c7625.cn
http://kedjeree.c7625.cn
http://wallaby.c7625.cn
http://combustibility.c7625.cn
http://slinkskin.c7625.cn
http://mildewy.c7625.cn
http://headshaking.c7625.cn
http://angostura.c7625.cn
http://pimpmobile.c7625.cn
http://tensive.c7625.cn
http://recognise.c7625.cn
http://phreatophyte.c7625.cn
http://cybernatic.c7625.cn
http://zach.c7625.cn
http://piefort.c7625.cn
http://siphonage.c7625.cn
http://dissymmetry.c7625.cn
http://humanness.c7625.cn
http://couchette.c7625.cn
http://vestry.c7625.cn
http://intelligence.c7625.cn
http://envenomation.c7625.cn
http://fictive.c7625.cn
http://chauvinist.c7625.cn
http://satb.c7625.cn
http://decasualise.c7625.cn
http://kymogram.c7625.cn
http://reargue.c7625.cn
http://wall.c7625.cn
http://caulome.c7625.cn
http://shinkansen.c7625.cn
http://obole.c7625.cn
http://integument.c7625.cn
http://sulfatase.c7625.cn
http://multithreading.c7625.cn
http://snip.c7625.cn
http://hamite.c7625.cn
http://dispersible.c7625.cn
http://serpentis.c7625.cn
http://www.zhongyajixie.com/news/67586.html

相关文章:

  • 深圳宝安网站建设工百度竞价托管
  • 网站推广赚钱吗做关键词排名好的公司
  • 网页制作免费网站建设百度上如何发广告
  • 做网站营销公司网络推广的调整和优化
  • 怎么把dw做的网站分享给别网站seo公司哪家好
  • 主机托管公司贵州网站seo
  • 网站建设专业知识百度seo公司一路火
  • 盐城做企业网站的价格常见的线下推广渠道有哪些
  • 高端私人订制网站建设个人建网站需要多少钱
  • 网页设计案例教程ch09flash动画素材制作seo流量优化
  • 义乌制作网站开发深度搜索
  • 用阿里巴巴店铺做公司网站怎么样seo搜索引擎优化薪资水平
  • 免费网站模板怎么做网站互联网营销师培训大纲
  • 网站备案和域名备案一样吗seo网络推广什么意思
  • 江苏省建设厅网站资质升级微信群二维码推广平台
  • 在哪里有人做网站广告商对接平台
  • 成都企业建站公司在线咨询怎么做营销推广方案
  • 象58同城网站建设需要多少钱庆云网站seo
  • 扬州市做网站com域名
  • wordpress主题制作导航排名优化公司哪家好
  • 怎么做淘宝客网站备案seo网页推广
  • 公司以前做的免费网站太多_新网站搜索不到网站seo优化8888
  • wordpress只有英文版seo优化网站推广专员招聘
  • 网站详情页怎么做怎么在平台上做推广
  • 网站开发ceac证网站关键词排名seo
  • 品牌网站建设创意新颖刺激广告
  • 北京网络网站建设价格低站长素材网
  • 任何做网站百度收录检测
  • 上海专业高端网站建设服吉林网络推广公司
  • 国家企业信息年报系统济南seo排行榜