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

Commitd0aa838

Browse files
authored
Merge pull request#265 from SamKirkland/v4.3.0-beta
Version 4.3.0
2 parentsd6ad227 +f552793 commitd0aa838

File tree

5 files changed

+2238
-123
lines changed

5 files changed

+2238
-123
lines changed

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses:actions/checkout@v2
2424

2525
-name:📂 Sync files
26-
uses:SamKirkland/FTP-Deploy-Action@4.2.0
26+
uses:SamKirkland/FTP-Deploy-Action@4.3.0
2727
with:
2828
server:ftp.samkirkland.com
2929
username:myFtpUserName
@@ -98,7 +98,7 @@ jobs:
9898
npm run build
9999
100100
- name: 📂 Sync files
101-
uses: SamKirkland/FTP-Deploy-Action@4.2.0
101+
uses: SamKirkland/FTP-Deploy-Action@4.3.0
102102
with:
103103
server: ftp.samkirkland.com
104104
username: myFtpUserName
@@ -118,7 +118,7 @@ jobs:
118118
uses: actions/checkout@v2
119119
120120
- name: 📂 Sync files
121-
uses: SamKirkland/FTP-Deploy-Action@4.2.0
121+
uses: SamKirkland/FTP-Deploy-Action@4.3.0
122122
with:
123123
server: ftp.samkirkland.com
124124
username: myFtpUserName
@@ -141,7 +141,7 @@ jobs:
141141
uses: actions/checkout@v2
142142
143143
- name: 📂 Sync files
144-
uses: SamKirkland/FTP-Deploy-Action@4.2.0
144+
uses: SamKirkland/FTP-Deploy-Action@4.3.0
145145
with:
146146
server: ftp.samkirkland.com
147147
username: myFtpUserName
@@ -163,7 +163,7 @@ jobs:
163163
uses: actions/checkout@v2
164164
165165
- name: 📂 Sync files
166-
uses: SamKirkland/FTP-Deploy-Action@4.2.0
166+
uses: SamKirkland/FTP-Deploy-Action@4.3.0
167167
with:
168168
server: ftp.samkirkland.com
169169
username: myFtpUserName

‎dist/index.js‎

Lines changed: 82 additions & 52 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.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
*
@@ -3452,6 +3469,19 @@ function getDefaultSettings(withoutDefaults) {
34523469
};
34533470
}
34543471
exports.getDefaultSettings=getDefaultSettings;
3472+
functionapplyExcludeFilter(stat,excludeFilters){
3473+
// match exclude, return immediatley
3474+
if(excludeFilters.length>0){
3475+
// todo this could be a performance problem...
3476+
constpathWithFolderSlash=stat.path+(stat.isDirectory() ?"/" :"");
3477+
constexcludeMatch=multimatch_1.default(pathWithFolderSlash,excludeFilters,{matchBase:true,dot:true});
3478+
if(excludeMatch.length>0){
3479+
returnfalse;
3480+
}
3481+
}
3482+
returntrue;
3483+
}
3484+
exports.applyExcludeFilter=applyExcludeFilter;
34553485

34563486

34573487
/***/}),
@@ -7954,12 +7984,12 @@ function optionalInt(argumentName, rawValue) {
79547984
}
79557985
exports.optionalInt=optionalInt;
79567986
functionoptionalStringArray(argumentName,rawValue){
7957-
if(typeofrawValue==="string"){
7958-
thrownewError(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`);
7959-
}
79607987
if(rawValue.length===0){
79617988
returnundefined;
79627989
}
7990+
if(typeofrawValue==="string"){
7991+
thrownewError(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`);
7992+
}
79637993
returnrawValue;
79647994
}
79657995
exports.optionalStringArray=optionalStringArray;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp