12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- const path = require('path');
- const fs = require('fs');
- const currentDirectory = process.cwd();
- const distZipPath = path.join(currentDirectory, '/zip/client.zip');
- if(fs.existsSync(distZipPath)) {
- fs.unlinkSync(distZipPath);
- }
- const indexJsonPath = path.join(currentDirectory, 'src/config/index.json');
- const indexJsonContent = fs.readFileSync(indexJsonPath, 'utf8');
- const cacheJsonPath = path.join(currentDirectory, 'scripts/cache.json');
- fs.writeFileSync(cacheJsonPath, indexJsonContent, 'utf8');
- const indexJson = JSON.parse(indexJsonContent);
- indexJson.version = dateFormat(new Date());
- indexJson.target = "http://127.0.0.1:8090";
- indexJson.smsPhone = "";
- indexJson.vite = {};
- fs.writeFileSync(indexJsonPath, JSON.stringify(indexJson, null, 2));
- function dateFormat(date) {
- let format = 'yyyyMMddhhmmss';
- let o = {
- "M+": date.getMonth() + 1,
- "d+": date.getDate(),
- "h+": date.getHours(),
- "m+": date.getMinutes(),
- "s+": date.getSeconds(),
- "q+": Math.floor((date.getMonth() + 3) / 3),
- "S": date.getMilliseconds()
- }
- if (/(y+)/.test(format)) {
- format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
- }
- for (let k in o) {
- if (new RegExp("(" + k + ")").test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
- }
- }
- return format;
- }
|