Commit 5140bb8f authored by Auto Backup's avatar Auto Backup

build

parent 394f041c
...@@ -8,6 +8,7 @@ const DEFAULT_SRC = "G:/cpas-framework/release/win-unpacked"; ...@@ -8,6 +8,7 @@ const DEFAULT_SRC = "G:/cpas-framework/release/win-unpacked";
// Default subfolders list to copy (empty array means copy all folders) // Default subfolders list to copy (empty array means copy all folders)
const DEFAULT_SUB_FOLDERS = []; const DEFAULT_SUB_FOLDERS = [];
const PUBLISH_DIR= 'E:/产品安装包/05 大客户专版/109 致同/CPAS6.0 IAS版'
// Parse command line arguments // Parse command line arguments
function parseArgs() { function parseArgs() {
const args = process.argv.slice(2); const args = process.argv.slice(2);
...@@ -16,7 +17,7 @@ function parseArgs() { ...@@ -16,7 +17,7 @@ function parseArgs() {
src: DEFAULT_SRC, src: DEFAULT_SRC,
subFolders: [...DEFAULT_SUB_FOLDERS] subFolders: [...DEFAULT_SUB_FOLDERS]
}; };
for (let i = 0; i < args.length; i++) { for (let i = 0; i < args.length; i++) {
const arg = args[i]; const arg = args[i];
if (arg === '--dest' && i + 1 < args.length) { if (arg === '--dest' && i + 1 < args.length) {
...@@ -28,7 +29,7 @@ function parseArgs() { ...@@ -28,7 +29,7 @@ function parseArgs() {
params.subFolders = args[++i].split(',').map(f => f.trim()).filter(f => f); params.subFolders = args[++i].split(',').map(f => f.trim()).filter(f => f);
} }
} }
return params; return params;
} }
...@@ -53,23 +54,23 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) { ...@@ -53,23 +54,23 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) {
reject(`Error reading source directory: ${err}`); reject(`Error reading source directory: ${err}`);
return; return;
} }
let promises = []; let promises = [];
files.forEach(file => { files.forEach(file => {
const srcPath = path.join(src, file); const srcPath = path.join(src, file);
const destPath = path.join(dest, file); const destPath = path.join(dest, file);
// Check if it's a direct child of the root source directory // Check if it's a direct child of the root source directory
const relativePath = path.relative(rootSrc, srcPath); const relativePath = path.relative(rootSrc, srcPath);
const isDirectChild = relativePath === file && !relativePath.includes(path.sep); const isDirectChild = relativePath === file && !relativePath.includes(path.sep);
promises.push(new Promise((resolve, reject) => { promises.push(new Promise((resolve, reject) => {
fs.stat(srcPath, (err, stats) => { fs.stat(srcPath, (err, stats) => {
if (err) { if (err) {
reject(`Error getting file stats: ${err}`); reject(`Error getting file stats: ${err}`);
return; return;
} }
if (stats.isDirectory()) { if (stats.isDirectory()) {
// If it's a directory, check if filtering is needed // If it's a directory, check if filtering is needed
if (isDirectChild && subFolders.length > 0 && !subFolders.includes(file)) { if (isDirectChild && subFolders.length > 0 && !subFolders.includes(file)) {
...@@ -78,7 +79,7 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) { ...@@ -78,7 +79,7 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) {
resolve(); resolve();
return; return;
} }
// Create directory and copy internal files // Create directory and copy internal files
fs.mkdir(destPath, { recursive: true }, (err) => { fs.mkdir(destPath, { recursive: true }, (err) => {
if (err) { if (err) {
...@@ -115,7 +116,7 @@ async function main() { ...@@ -115,7 +116,7 @@ async function main() {
try { try {
// Parse command line arguments // Parse command line arguments
const { src, dest, subFolders } = parseArgs(); const { src, dest, subFolders } = parseArgs();
console.log(`Source path: ${src}`); console.log(`Source path: ${src}`);
console.log(`Destination path: ${dest}`); console.log(`Destination path: ${dest}`);
if (subFolders.length > 0) { if (subFolders.length > 0) {
...@@ -132,7 +133,7 @@ async function main() { ...@@ -132,7 +133,7 @@ async function main() {
// Copy files from source to destination (recursive) // Copy files from source to destination (recursive)
console.log("Starting file copy..."); console.log("Starting file copy...");
await copyFiles(src, dest, subFolders); await copyFiles(src, dest, subFolders);
const iss= '/CPAS6Setup_IASWithBom.iss' const iss= '/CPAS6Setup_IASWithBom.iss'
// If it's a file, copy directly // If it's a file, copy directly
fs.copyFile("."+iss, dest, fs.constants.COPYFILE_FICLONE, (err) => { fs.copyFile("."+iss, dest, fs.constants.COPYFILE_FICLONE, (err) => {
...@@ -151,7 +152,8 @@ async function main() { ...@@ -151,7 +152,8 @@ async function main() {
await execCommand(`D:/InnoSetup6/ISCC.exe "${dest}${iss}"`); await execCommand(`D:/InnoSetup6/ISCC.exe "${dest}${iss}"`);
console.log("ISCC.exe completed."); console.log("ISCC.exe completed.");
console.log("Script execution completed successfully."); console.log("Script execution completed successfully.");
await copyFiles(src, PUBLISH_DIR, ['resources']);
} catch (error) { } catch (error) {
console.error("An error occurred:", error); console.error("An error occurred:", error);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment