Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3fa328

Browse files
committed
550 bug fix
1 parentd6ad227 commitd3fa328

File tree

3 files changed

+2235
-118
lines changed

3 files changed

+2235
-118
lines changed

‎dist/index.js‎

Lines changed: 89 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,9 +2544,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
25442544
exports.HashDiff=exports.fileHash=void0;
25452545
constfs_1=__importDefault(__nccwpck_require__(5747));
25462546
constcrypto_1=__importDefault(__nccwpck_require__(6417));
2547-
functionformatNumber(number){
2548-
returnnumber.toLocaleString();
2549-
}
25502547
functionfileHash(filename,algorithm){
25512548
return__awaiter(this,void0,void0,function*(){
25522549
returnnewPromise((resolve,reject)=>{
@@ -2575,23 +2572,18 @@ function fileHash(filename, algorithm) {
25752572
}
25762573
exports.fileHash=fileHash;
25772574
classHashDiff{
2578-
getDiffs(localFiles,serverFiles,logger){
2575+
getDiffs(localFiles,serverFiles){
25792576
var_a,_b,_c;
25802577
constuploadList=[];
25812578
constdeleteList=[];
25822579
constreplaceList=[];
2580+
constsameList=[];
25832581
letsizeUpload=0;
25842582
letsizeDelete=0;
25852583
letsizeReplace=0;
25862584
// alphabetize each list based off path
25872585
constlocalFilesSorted=localFiles.data.sort((first,second)=>first.name.localeCompare(second.name));
25882586
constserverFilesSorted=serverFiles.data.sort((first,second)=>first.name.localeCompare(second.name));
2589-
logger.standard(`----------------------------------------------------------------`);
2590-
logger.standard(`Local Files:\t${formatNumber(localFilesSorted.length)}`);
2591-
logger.standard(`Server Files:\t${formatNumber(localFilesSorted.length)}`);
2592-
logger.standard(`----------------------------------------------------------------`);
2593-
logger.standard(`Calculating differences between client & server`);
2594-
logger.standard(`----------------------------------------------------------------`);
25952587
letlocalPosition=0;
25962588
letserverPosition=0;
25972589
while(localPosition+serverPosition<localFilesSorted.length+serverFilesSorted.length){
@@ -2608,15 +2600,11 @@ class HashDiff {
26082600
fileNameCompare=localFile.name.localeCompare(serverFile.name);
26092601
}
26102602
if(fileNameCompare<0){
2611-
leticon=localFile.type==="folder" ?`📁 Create` :`➕ Upload`;
2612-
logger.standard(`${icon}:${localFile.name}`);
26132603
uploadList.push(localFile);
26142604
sizeUpload+=(_a=localFile.size)!==null&&_a!==void0 ?_a :0;
26152605
localPosition+=1;
26162606
}
26172607
elseif(fileNameCompare>0){
2618-
leticon=serverFile.type==="folder" ?`📁` :`🗑️`;
2619-
logger.standard(`${icon} Delete:${serverFile.name} `);
26202608
deleteList.push(serverFile);
26212609
sizeDelete+=(_b=serverFile.size)!==null&&_b!==void0 ?_b :0;
26222610
serverPosition+=1;
@@ -2625,10 +2613,9 @@ class HashDiff {
26252613
// paths are a match
26262614
if(localFile.type==="file"&&serverFile.type==="file"){
26272615
if(localFile.hash===serverFile.hash){
2628-
logger.standard(`⚖️ File content is the same, doing nothing:${localFile.name}`);
2616+
sameList.push(localFile);
26292617
}
26302618
else{
2631-
logger.standard(`🔁 File replace:${localFile.name}`);
26322619
sizeReplace+=(_c=localFile.size)!==null&&_c!==void0 ?_c :0;
26332620
replaceList.push(localFile);
26342621
}
@@ -2637,10 +2624,26 @@ class HashDiff {
26372624
serverPosition+=1;
26382625
}
26392626
}
2627+
// optimize modifications
2628+
letfoldersToDelete=deleteList.filter((item)=>item.type==="folder");
2629+
// remove files/folders that have a nested parent folder we plan on deleting
2630+
constoptimizedDeleteList=deleteList.filter((itemToDelete)=>{
2631+
constparentFolderIsBeingDeleted=foldersToDelete.find((folder)=>{
2632+
constisSameFile=itemToDelete.name===folder.name;
2633+
constparentFolderExists=itemToDelete.name.startsWith(folder.name);
2634+
returnparentFolderExists&&!isSameFile;
2635+
})!==undefined;
2636+
if(parentFolderIsBeingDeleted){
2637+
// a parent folder is being deleted, no need to delete this one
2638+
returnfalse;
2639+
}
2640+
returntrue;
2641+
});
26402642
return{
26412643
upload:uploadList,
2642-
delete:deleteList,
2644+
delete:optimizedDeleteList,
26432645
replace:replaceList,
2646+
same:sameList,
26442647
sizeDelete,
26452648
sizeReplace,
26462649
sizeUpload
@@ -2764,6 +2767,11 @@ function getServerFiles(client, logger, timings, args) {
27642767
constserverFiles=yielddownloadFileList(client,logger,args["state-name"]);
27652768
logger.all(`----------------------------------------------------------------`);
27662769
logger.all(`Last published on 📅${newDate(serverFiles.generatedTime).toLocaleDateString(undefined,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"})}`);
2770+
// apply exclude options to server
2771+
if(args.exclude.length>0){
2772+
constfilteredData=serverFiles.data.filter((item)=>utilities_1.applyExcludeFilter({path:item.name,isDirectory:()=>item.type==="folder"},args.exclude));
2773+
serverFiles.data=filteredData;
2774+
}
27672775
returnserverFiles;
27682776
}
27692777
catch(error){
@@ -2810,7 +2818,33 @@ function deploy(args, logger, timings) {
28102818
constserverFiles=yieldgetServerFiles(client,logger,timings,args);
28112819
timings.start("logging");
28122820
constdiffTool=newHashDiff_1.HashDiff();
2813-
constdiffs=diffTool.getDiffs(localFiles,serverFiles,logger);
2821+
logger.standard(`----------------------------------------------------------------`);
2822+
logger.standard(`Local Files:\t${utilities_1.formatNumber(localFiles.data.length)}`);
2823+
logger.standard(`Server Files:\t${utilities_1.formatNumber(serverFiles.data.length)}`);
2824+
logger.standard(`----------------------------------------------------------------`);
2825+
logger.standard(`Calculating differences between client & server`);
2826+
logger.standard(`----------------------------------------------------------------`);
2827+
constdiffs=diffTool.getDiffs(localFiles,serverFiles);
2828+
diffs.upload.filter((itemUpload)=>itemUpload.type==="folder").map((itemUpload)=>{
2829+
logger.standard(`📁 Create:${itemUpload.name}`);
2830+
});
2831+
diffs.upload.filter((itemUpload)=>itemUpload.type==="file").map((itemUpload)=>{
2832+
logger.standard(`📄 Upload:${itemUpload.name}`);
2833+
});
2834+
diffs.replace.map((itemReplace)=>{
2835+
logger.standard(`🔁 File replace:${itemReplace.name}`);
2836+
});
2837+
diffs.delete.filter((itemUpload)=>itemUpload.type==="file").map((itemDelete)=>{
2838+
logger.standard(`📄 Delete:${itemDelete.name} `);
2839+
});
2840+
diffs.delete.filter((itemUpload)=>itemUpload.type==="folder").map((itemDelete)=>{
2841+
logger.standard(`📁 Delete:${itemDelete.name} `);
2842+
});
2843+
diffs.same.map((itemSame)=>{
2844+
if(itemSame.type==="file"){
2845+
logger.standard(`⚖️ File content is the same, doing nothing:${itemSame.name}`);
2846+
}
2847+
});
28142848
timings.stop("logging");
28152849
totalBytesUploaded=diffs.sizeUpload+diffs.sizeReplace;
28162850
timings.start("upload");
@@ -2835,7 +2869,7 @@ function deploy(args, logger, timings) {
28352869
logger.all(`----------------------------------------------------------------`);
28362870
logger.all(`Time spent hashing:${timings.getTimeFormatted("hash")}`);
28372871
logger.all(`Time spent connecting to server:${timings.getTimeFormatted("connecting")}`);
2838-
logger.all(`Time spent deploying:${timings.getTimeFormatted("upload")}(${uploadSpeed} /second)`);
2872+
logger.all(`Time spent deploying:${timings.getTimeFormatted("upload")}(${uploadSpeed}/second)`);
28392873
logger.all(` - changing dirs:${timings.getTimeFormatted("changingDir")}`);
28402874
logger.all(` - logging:${timings.getTimeFormatted("logging")}`);
28412875
logger.all(`----------------------------------------------------------------`);
@@ -2927,26 +2961,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29272961
return(mod&&mod.__esModule) ?mod :{"default":mod};
29282962
};
29292963
Object.defineProperty(exports,"__esModule",({value:true}));
2930-
exports.getLocalFiles=exports.applyExcludeFilter=void0;
2964+
exports.getLocalFiles=void0;
29312965
constreaddir_enhanced_1=__importDefault(__nccwpck_require__(8811));
29322966
consttypes_1=__nccwpck_require__(6703);
29332967
constHashDiff_1=__nccwpck_require__(9946);
2934-
constmultimatch_1=__importDefault(__nccwpck_require__(8222));
2935-
functionapplyExcludeFilter(stat,excludeFilter){
2936-
// match exclude, return immediatley
2937-
if(excludeFilter.length>0){
2938-
constpathWithFolderSlash=stat.path+(stat.isDirectory() ?"/" :"");
2939-
constexcludeMatch=multimatch_1.default(pathWithFolderSlash,excludeFilter,{matchBase:true,dot:true});
2940-
if(excludeMatch.length>0){
2941-
returnfalse;
2942-
}
2943-
}
2944-
returntrue;
2945-
}
2946-
exports.applyExcludeFilter=applyExcludeFilter;
2968+
constutilities_1=__nccwpck_require__(4389);
29472969
functiongetLocalFiles(args){
29482970
return__awaiter(this,void0,void0,function*(){
2949-
constfiles=yieldreaddir_enhanced_1.default.async(args["local-dir"],{deep:true,stats:true,sep:"/",filter:(stat)=>applyExcludeFilter(stat,args.exclude)});
2971+
constfiles=yieldreaddir_enhanced_1.default.async(args["local-dir"],{deep:true,stats:true,sep:"/",filter:(stat)=>utilities_1.applyExcludeFilter(stat,args.exclude)});
29502972
constrecords=[];
29512973
for(letstatoffiles){
29522974
if(stat.isDirectory()){
@@ -3138,22 +3160,12 @@ class FTPSyncProvider {
31383160
});
31393161
}
31403162
removeFolder(folderPath){
3141-
var_a,_b;
31423163
return__awaiter(this,void0,void0,function*(){
3143-
this.logger.all(`removing folder "${folderPath+"/"}"`);
3144-
constpath=this.getFileBreadcrumbs(folderPath+"/");
3145-
if(path.folders===null){
3146-
this.logger.verbose(` no need to change dir`);
3147-
}
3148-
else{
3149-
constrelativeFolderPath=path.folders[((_a=path.folders)===null||_a===void0 ?void0 :_a.length)-1]+"/";
3150-
this.logger.verbose(` removing folder "${relativeFolderPath}"`);
3151-
if(this.dryRun===false){
3152-
yieldutilities_1.retryRequest(this.logger,()=>__awaiter(this,void0,void0,function*(){returnyieldthis.client.removeDir(relativeFolderPath);}));
3153-
}
3164+
constabsoluteFolderPath="/"+(this.serverPath.startsWith("./") ?this.serverPath.replace("./","") :this.serverPath)+folderPath;
3165+
this.logger.all(`removing folder "${absoluteFolderPath}"`);
3166+
if(this.dryRun===false){
3167+
yieldutilities_1.retryRequest(this.logger,()=>__awaiter(this,void0,void0,function*(){returnyieldthis.client.removeDir(absoluteFolderPath);}));
31543168
}
3155-
// navigate back to the root folder
3156-
yieldthis.upDir((_b=path.folders)===null||_b===void0 ?void0 :_b.length);
31573169
this.logger.verbose(` completed`);
31583170
});
31593171
}
@@ -3304,10 +3316,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33043316
return(mod&&mod.__esModule) ?mod :{"default":mod};
33053317
};
33063318
Object.defineProperty(exports,"__esModule",({value:true}));
3307-
exports.getDefaultSettings=exports.Timer=exports.Timings=exports.retryRequest=exports.pluralize=exports.Logger=void0;
3319+
exports.applyExcludeFilter=exports.applyFolderFiltersToSubItems=exports.getDefaultSettings=exports.Timer=exports.Timings=exports.retryRequest=exports.formatNumber=exports.pluralize=exports.Logger=void0;
33083320
constpretty_ms_1=__importDefault(__nccwpck_require__(1127));
33093321
constmodule_1=__nccwpck_require__(8347);
33103322
consttypes_1=__nccwpck_require__(6703);
3323+
constmultimatch_1=__importDefault(__nccwpck_require__(8222));
33113324
classLogger{
33123325
constructor(level){
33133326
this.level=level;
@@ -3336,6 +3349,10 @@ function pluralize(count, singular, plural) {
33363349
returnplural;
33373350
}
33383351
exports.pluralize=pluralize;
3352+
functionformatNumber(number){
3353+
returnnumber.toLocaleString();
3354+
}
3355+
exports.formatNumber=formatNumber;
33393356
/**
33403357
* retry a request
33413358
*
@@ -3446,12 +3463,34 @@ function getDefaultSettings(withoutDefaults) {
34463463
"state-name":(_e=withoutDefaults["state-name"])!==null&&_e!==void0 ?_e :".ftp-deploy-sync-state.json",
34473464
"dry-run":(_f=withoutDefaults["dry-run"])!==null&&_f!==void0 ?_f :false,
34483465
"dangerous-clean-slate":(_g=withoutDefaults["dangerous-clean-slate"])!==null&&_g!==void0 ?_g :false,
3449-
"exclude":(_h=withoutDefaults.exclude)!==null&&_h!==void0 ?_h :module_1.excludeDefaults,
3466+
"exclude":applyFolderFiltersToSubItems((_h=withoutDefaults.exclude)!==null&&_h!==void0 ?_h :module_1.excludeDefaults),
34503467
"log-level":(_j=withoutDefaults["log-level"])!==null&&_j!==void0 ?_j :"standard",
34513468
"security":(_k=withoutDefaults.security)!==null&&_k!==void0 ?_k :"loose",
34523469
};
34533470
}
34543471
exports.getDefaultSettings=getDefaultSettings;
3472+
/**
3473+
* automatically exclude all sub-files/sub-folders if we exclude a folder.
3474+
* For example "test/" should also exclude "test/file.txt"
3475+
* to do this we add "**" to all folder paths
3476+
*/
3477+
functionapplyFolderFiltersToSubItems(excludeFilters){
3478+
returnexcludeFilters.map(filter=>filter.endsWith("/") ?`${filter}**` :filter);
3479+
}
3480+
exports.applyFolderFiltersToSubItems=applyFolderFiltersToSubItems;
3481+
functionapplyExcludeFilter(stat,excludeFilters){
3482+
// match exclude, return immediatley
3483+
if(excludeFilters.length>0){
3484+
// todo this could be a performance problem...
3485+
constpathWithFolderSlash=stat.path+(stat.isDirectory() ?"/" :"");
3486+
constexcludeMatch=multimatch_1.default(pathWithFolderSlash,excludeFilters,{matchBase:true,dot:true});
3487+
if(excludeMatch.length>0){
3488+
returnfalse;
3489+
}
3490+
}
3491+
returntrue;
3492+
}
3493+
exports.applyExcludeFilter=applyExcludeFilter;
34553494

34563495

34573496
/***/}),
@@ -7957,9 +7996,6 @@ function optionalStringArray(argumentName, rawValue) {
79577996
if(typeofrawValue==="string"){
79587997
thrownewError(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`);
79597998
}
7960-
if(rawValue.length===0){
7961-
returnundefined;
7962-
}
79637999
returnrawValue;
79648000
}
79658001
exports.optionalStringArray=optionalStringArray;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp