├── .github └── workflows │ └── issue-40.yml ├── .gitignore ├── .vscode └── launch.json ├── README.md ├── action.yml ├── deployer.test.js ├── dist ├── build │ └── Release │ │ └── cpufeatures.node ├── index.js ├── lib │ └── protocol │ │ └── crypto │ │ └── build │ │ └── Release │ │ └── sshcrypto.node ├── licenses.txt └── pagent.exe ├── lib └── deployer.js ├── package-lock.json ├── package.json ├── sftp.js └── test ├── file1 ├── file2 └── folder1 ├── file3 └── file4 /.github/workflows/issue-40.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Test issue 40# 4 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request 6 | # events but only for the master branch 7 | on: 8 | workflow_dispatch: 9 | env: 10 | TZ: "Asia/Shanghai" 11 | 12 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 13 | jobs: 14 | # This workflow contains a single job called "build" 15 | build: 16 | # The type of runner that the job will run on 17 | runs-on: ubuntu-latest 18 | 19 | # Steps represent a sequence of tasks that will be executed as part of the job 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | fetch-depth: 2 24 | 25 | - name: restore timestamps 26 | uses: chetan/git-restore-mtime-action@v2 27 | 28 | - name: SFTP uploader v2.0.4 29 | uses: wangyucode/sftp-upload-action@v2.0.4 30 | with: 31 | host: ${{ secrets.HOST }} 32 | port: 22 33 | username: ${{ secrets.USERNAME }} 34 | privateKey: ${{ secrets.SERVER_KEY }} 35 | localDir: "." 36 | remoteDir: "/tmp/test/" 37 | dryRun: false 38 | exclude: ".git,node_modules,not-remove,dist/*,*.json" 39 | 40 | - name: SFTP uploader v2.0.3 41 | uses: wangyucode/sftp-upload-action@v2.0.3 42 | with: 43 | host: ${{ secrets.HOST }} 44 | port: 22 45 | username: ${{ secrets.USERNAME }} 46 | privateKey: ${{ secrets.SERVER_KEY }} 47 | localDir: "." 48 | remoteDir: "/tmp/test/" 49 | dryRun: false 50 | exclude: "**/.git,**/node_modules,**/not-remove,**/dist/*,**/*.json" 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | id 2 | node_modules/ 3 | coverage/ 4 | test.js 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "program": "${workspaceFolder}/test.js" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sftp-upload-action 2 | 3 | this is a github action script for upload files to server via SFTP protocol. 4 | 5 | ![release](https://flat.badgen.net/github/release/wangyucode/sftp-upload-action) 6 | [![Depfu](https://badges.depfu.com/badges/4b5cc2f5563a240e7b6c6106ded3e4c0/overview.svg)](https://depfu.com/github/wangyucode/sftp-upload-action?project_id=37917) 7 | 8 | ## Inputs 9 | 10 | ``` 11 | host: 'example.com', # Required. 12 | port: 22, # Optional, Default to 22. 13 | username: 'user', # Required. 14 | password: 'password', # Optional. 15 | privateKey: '', # Optional, your private key(Raw content or key path). 16 | passphrase: '', # Optional. 17 | compress: false, # Optional, compress for ssh connection. Default to false. 18 | localDir: 'dist', # Required, Absolute or relative to cwd. 19 | remoteDir: '/path/to/dest' # Required, Absolute path only. 20 | dryRun: false # Optional. Default to false. 21 | exclude: 'node_modules/,**/*.spec.ts' # Optional. exclude patterns (glob), working on both server-side and client-side like .gitignore, use ',' to split, Default to ''. 22 | forceUpload: false # Optional, Force uploading all files, Default to false(upload only newer files). 23 | removeExtraFilesOnServer: false # Optional, Remove extra files on server. Default to false. 24 | ``` 25 | 26 | ## Example usage 27 | 28 | ### Use password 29 | 30 | ```yml 31 | - name: SFTP uploader 32 | uses: wangyucode/sftp-upload-action@v2.0.4 33 | with: 34 | host: "wycode.cn" 35 | password: ${{ secrets.password }} 36 | localDir: "dist" 37 | remoteDir: "/data/nginx/www/wycode.cn/" 38 | ``` 39 | 40 | ### Use privateKey 41 | 42 | ```yml 43 | - name: SFTP uploader 44 | uses: wangyucode/sftp-upload-action@v2.0.4 45 | with: 46 | host: "wycode.cn" 47 | privateKey: ${{ secrets.key }} 48 | localDir: "dist" 49 | remoteDir: "/data/nginx/www/wycode.cn/" 50 | ``` 51 | 52 | ### Example for a complete github action file 53 | 54 | ```yml 55 | name: Upload complete repo (e.g. website) to a SFTP destination 56 | 57 | on: [push] 58 | 59 | jobs: 60 | Upload-to-SFTP: 61 | runs-on: ubuntu-latest 62 | steps: 63 | - name: 🚚 Get latest code # Checkout the latest code 64 | uses: actions/checkout@v3 65 | 66 | - name: 📂 SFTP uploader # Upload to SFTP 67 | uses: wangyucode/sftp-upload-action@v2.0.4 68 | with: 69 | host: ${{ secrets.HOST }} # Recommended to put the credentials in github secrets. 70 | username: ${{ secrets.USER }} 71 | password: ${{ secrets.PASSWORD }} 72 | compress: true # Compression 73 | forceUpload: true # Optional, Force uploading all files, Default to false(upload only newer files). 74 | localDir: "." # Required, Absolute or relative to cwd. 75 | remoteDir: "/" # Required, Absolute path only. 76 | exclude: ".git,.DS_Store,**/node_modules" # Optional. exclude patterns (glob) like .gitignore, use ',' to split, Default to ''. 77 | ``` 78 | 79 | ## Upload newer files 80 | 81 | the action will check `modifyTime` and upload the newer files if `forceUpload` is false. 82 | but you should restore the modified time before uploading. 83 | here is an action that can change the modified time: https://github.com/marketplace/actions/git-restore-mtime 84 | 85 | ## Other Options 86 | 87 | [Crane](https://github.com/wangyucode/crane) is a simple, fast, and secure tool written in Rust for downloading and deploying your `.tar.gz` archive files without the need for server passwords or keys. 88 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'SFTP uploader' 2 | author: 'wycode.cn' 3 | branding: 4 | color: 'green' 5 | icon: 'upload' 6 | description: 'upload files to server via SFTP' 7 | inputs: 8 | host: 9 | required: true 10 | port: 11 | required: false 12 | default: 22 13 | username: 14 | required: false 15 | default: 'root' 16 | password: 17 | required: true 18 | compress: 19 | required: false 20 | default: false 21 | localDir: 22 | required: true 23 | remoteDir: 24 | required: true 25 | dryRun: 26 | required: false 27 | default: false 28 | privateKey: 29 | required: false 30 | default: '' 31 | passphrase: 32 | required: false 33 | default: '' 34 | exclude: 35 | required: false 36 | default: '' 37 | forceUpload: 38 | required: false 39 | default: false 40 | removeExtraFilesOnServer: 41 | required: false 42 | default: false 43 | runs: 44 | using: 'node20' 45 | main: 'dist/index.js' 46 | -------------------------------------------------------------------------------- /deployer.test.js: -------------------------------------------------------------------------------- 1 | const { Deployer } = require('./lib/deployer'); 2 | 3 | const excludeOption = 4 | '.editorconfig,.env.example,.eslintrc.json,.git*,**/.git*,.npm*,.nvmrc,.prettier*,artisan,composer*,package*,phpunit.xml,tsconfig.json,vite.config.js,.vscode/,resources/css/,resources/js/,tests/,database/,scripts/,node_modules/,.DS_Store'; 5 | 6 | const deploy = new Deployer( 7 | { 8 | host: '192.168.0.99', 9 | compress: true, 10 | localDir: './test', 11 | remoteDir: '/root/test/', 12 | }, 13 | { 14 | exclude: excludeOption.split(','), 15 | dryRun: false, 16 | } 17 | ); 18 | 19 | describe('Deployer', () => { 20 | test('isIgnoreFile', () => { 21 | expect(deploy.isIgnoreFile('.npmrc')).toBe(true); 22 | expect(deploy.isIgnoreFile('.npmignore')).toBe(true); 23 | expect(deploy.isIgnoreFile('.github/')).toBe(true); 24 | expect(deploy.isIgnoreFile('.gitignore')).toBe(true); 25 | expect(deploy.isIgnoreFile('.gitattributes')).toBe(true); 26 | expect(deploy.isIgnoreFile('resources/css/')).toBe(true); 27 | expect(deploy.isIgnoreFile('resources/views/')).toBe(false); 28 | expect(deploy.isIgnoreFile('node_modules/')).toBe(true); 29 | expect(deploy.isIgnoreFile('storage/app/public/.gitignore')).toBe(true); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /dist/build/Release/cpufeatures.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangyucode/sftp-upload-action/057558caceafb0ae9b9690d9afac6fa876be7d66/dist/build/Release/cpufeatures.node -------------------------------------------------------------------------------- /dist/lib/protocol/crypto/build/Release/sshcrypto.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangyucode/sftp-upload-action/057558caceafb0ae9b9690d9afac6fa876be7d66/dist/lib/protocol/crypto/build/Release/sshcrypto.node -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | @actions/exec 14 | MIT 15 | The MIT License (MIT) 16 | 17 | Copyright 2019 GitHub 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | @actions/http-client 26 | MIT 27 | Actions Http Client for Node.js 28 | 29 | Copyright (c) GitHub, Inc. 30 | 31 | All rights reserved. 32 | 33 | MIT License 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 36 | associated documentation files (the "Software"), to deal in the Software without restriction, 37 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 38 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 39 | subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 44 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 45 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 47 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | 50 | @actions/io 51 | MIT 52 | The MIT License (MIT) 53 | 54 | Copyright 2019 GitHub 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 57 | 58 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 59 | 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 61 | 62 | asn1 63 | MIT 64 | Copyright (c) 2011 Mark Cavage, All rights reserved. 65 | 66 | Permission is hereby granted, free of charge, to any person obtaining a copy 67 | of this software and associated documentation files (the "Software"), to deal 68 | in the Software without restriction, including without limitation the rights 69 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 70 | copies of the Software, and to permit persons to whom the Software is 71 | furnished to do so, subject to the following conditions: 72 | 73 | The above copyright notice and this permission notice shall be included in 74 | all copies or substantial portions of the Software. 75 | 76 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 77 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 78 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 79 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 80 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 81 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 82 | THE SOFTWARE 83 | 84 | 85 | balanced-match 86 | MIT 87 | (MIT) 88 | 89 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 90 | 91 | Permission is hereby granted, free of charge, to any person obtaining a copy of 92 | this software and associated documentation files (the "Software"), to deal in 93 | the Software without restriction, including without limitation the rights to 94 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 95 | of the Software, and to permit persons to whom the Software is furnished to do 96 | so, subject to the following conditions: 97 | 98 | The above copyright notice and this permission notice shall be included in all 99 | copies or substantial portions of the Software. 100 | 101 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 102 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 103 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 104 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 105 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 106 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 107 | SOFTWARE. 108 | 109 | 110 | bcrypt-pbkdf 111 | BSD-3-Clause 112 | The Blowfish portions are under the following license: 113 | 114 | Blowfish block cipher for OpenBSD 115 | Copyright 1997 Niels Provos 116 | All rights reserved. 117 | 118 | Implementation advice by David Mazieres . 119 | 120 | Redistribution and use in source and binary forms, with or without 121 | modification, are permitted provided that the following conditions 122 | are met: 123 | 1. Redistributions of source code must retain the above copyright 124 | notice, this list of conditions and the following disclaimer. 125 | 2. Redistributions in binary form must reproduce the above copyright 126 | notice, this list of conditions and the following disclaimer in the 127 | documentation and/or other materials provided with the distribution. 128 | 3. The name of the author may not be used to endorse or promote products 129 | derived from this software without specific prior written permission. 130 | 131 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 132 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 133 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 134 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 135 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 136 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 137 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 138 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 139 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 140 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 141 | 142 | 143 | 144 | The bcrypt_pbkdf portions are under the following license: 145 | 146 | Copyright (c) 2013 Ted Unangst 147 | 148 | Permission to use, copy, modify, and distribute this software for any 149 | purpose with or without fee is hereby granted, provided that the above 150 | copyright notice and this permission notice appear in all copies. 151 | 152 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 153 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 154 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 155 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 156 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 157 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 158 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 159 | 160 | 161 | 162 | Performance improvements (Javascript-specific): 163 | 164 | Copyright 2016, Joyent Inc 165 | Author: Alex Wilson 166 | 167 | Permission to use, copy, modify, and distribute this software for any 168 | purpose with or without fee is hereby granted, provided that the above 169 | copyright notice and this permission notice appear in all copies. 170 | 171 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 172 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 173 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 174 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 175 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 176 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 177 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 178 | 179 | 180 | brace-expansion 181 | MIT 182 | MIT License 183 | 184 | Copyright (c) 2013 Julian Gruber 185 | 186 | Permission is hereby granted, free of charge, to any person obtaining a copy 187 | of this software and associated documentation files (the "Software"), to deal 188 | in the Software without restriction, including without limitation the rights 189 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 190 | copies of the Software, and to permit persons to whom the Software is 191 | furnished to do so, subject to the following conditions: 192 | 193 | The above copyright notice and this permission notice shall be included in all 194 | copies or substantial portions of the Software. 195 | 196 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 197 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 198 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 199 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 200 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 201 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 202 | SOFTWARE. 203 | 204 | 205 | buffer-from 206 | MIT 207 | MIT License 208 | 209 | Copyright (c) 2016, 2018 Linus Unnebäck 210 | 211 | Permission is hereby granted, free of charge, to any person obtaining a copy 212 | of this software and associated documentation files (the "Software"), to deal 213 | in the Software without restriction, including without limitation the rights 214 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 215 | copies of the Software, and to permit persons to whom the Software is 216 | furnished to do so, subject to the following conditions: 217 | 218 | The above copyright notice and this permission notice shall be included in all 219 | copies or substantial portions of the Software. 220 | 221 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 222 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 223 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 224 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 225 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 226 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 227 | SOFTWARE. 228 | 229 | 230 | concat-stream 231 | MIT 232 | The MIT License 233 | 234 | Copyright (c) 2013 Max Ogden 235 | 236 | Permission is hereby granted, free of charge, 237 | to any person obtaining a copy of this software and 238 | associated documentation files (the "Software"), to 239 | deal in the Software without restriction, including 240 | without limitation the rights to use, copy, modify, 241 | merge, publish, distribute, sublicense, and/or sell 242 | copies of the Software, and to permit persons to whom 243 | the Software is furnished to do so, 244 | subject to the following conditions: 245 | 246 | The above copyright notice and this permission notice 247 | shall be included in all copies or substantial portions of the Software. 248 | 249 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 250 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 251 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 252 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 253 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 254 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 255 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 256 | 257 | cpu-features 258 | MIT 259 | Copyright Brian White. All rights reserved. 260 | 261 | Permission is hereby granted, free of charge, to any person obtaining a copy 262 | of this software and associated documentation files (the "Software"), to 263 | deal in the Software without restriction, including without limitation the 264 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 265 | sell copies of the Software, and to permit persons to whom the Software is 266 | furnished to do so, subject to the following conditions: 267 | 268 | The above copyright notice and this permission notice shall be included in 269 | all copies or substantial portions of the Software. 270 | 271 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 272 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 273 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 274 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 275 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 276 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 277 | IN THE SOFTWARE. 278 | 279 | err-code 280 | MIT 281 | 282 | inherits 283 | ISC 284 | The ISC License 285 | 286 | Copyright (c) Isaac Z. Schlueter 287 | 288 | Permission to use, copy, modify, and/or distribute this software for any 289 | purpose with or without fee is hereby granted, provided that the above 290 | copyright notice and this permission notice appear in all copies. 291 | 292 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 293 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 294 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 295 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 296 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 297 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 298 | PERFORMANCE OF THIS SOFTWARE. 299 | 300 | 301 | 302 | minimatch 303 | ISC 304 | The ISC License 305 | 306 | Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors 307 | 308 | Permission to use, copy, modify, and/or distribute this software for any 309 | purpose with or without fee is hereby granted, provided that the above 310 | copyright notice and this permission notice appear in all copies. 311 | 312 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 313 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 314 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 315 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 316 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 317 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 318 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 319 | 320 | 321 | promise-retry 322 | MIT 323 | Copyright (c) 2014 IndigoUnited 324 | 325 | Permission is hereby granted, free of charge, to any person obtaining a copy 326 | of this software and associated documentation files (the "Software"), to deal 327 | in the Software without restriction, including without limitation the rights 328 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 329 | copies of the Software, and to permit persons to whom the Software is furnished 330 | to do so, subject to the following conditions: 331 | 332 | The above copyright notice and this permission notice shall be included in all 333 | copies or substantial portions of the Software. 334 | 335 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 336 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 337 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 338 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 339 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 340 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 341 | THE SOFTWARE. 342 | 343 | 344 | readable-stream 345 | MIT 346 | Node.js is licensed for use as follows: 347 | 348 | """ 349 | Copyright Node.js contributors. All rights reserved. 350 | 351 | Permission is hereby granted, free of charge, to any person obtaining a copy 352 | of this software and associated documentation files (the "Software"), to 353 | deal in the Software without restriction, including without limitation the 354 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 355 | sell copies of the Software, and to permit persons to whom the Software is 356 | furnished to do so, subject to the following conditions: 357 | 358 | The above copyright notice and this permission notice shall be included in 359 | all copies or substantial portions of the Software. 360 | 361 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 362 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 363 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 364 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 365 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 366 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 367 | IN THE SOFTWARE. 368 | """ 369 | 370 | This license applies to parts of Node.js originating from the 371 | https://github.com/joyent/node repository: 372 | 373 | """ 374 | Copyright Joyent, Inc. and other Node contributors. All rights reserved. 375 | Permission is hereby granted, free of charge, to any person obtaining a copy 376 | of this software and associated documentation files (the "Software"), to 377 | deal in the Software without restriction, including without limitation the 378 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 379 | sell copies of the Software, and to permit persons to whom the Software is 380 | furnished to do so, subject to the following conditions: 381 | 382 | The above copyright notice and this permission notice shall be included in 383 | all copies or substantial portions of the Software. 384 | 385 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 386 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 387 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 388 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 389 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 390 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 391 | IN THE SOFTWARE. 392 | """ 393 | 394 | 395 | retry 396 | MIT 397 | Copyright (c) 2011: 398 | Tim Koschützki (tim@debuggable.com) 399 | Felix Geisendörfer (felix@debuggable.com) 400 | 401 | Permission is hereby granted, free of charge, to any person obtaining a copy 402 | of this software and associated documentation files (the "Software"), to deal 403 | in the Software without restriction, including without limitation the rights 404 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 405 | copies of the Software, and to permit persons to whom the Software is 406 | furnished to do so, subject to the following conditions: 407 | 408 | The above copyright notice and this permission notice shall be included in 409 | all copies or substantial portions of the Software. 410 | 411 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 412 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 413 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 414 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 415 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 416 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 417 | THE SOFTWARE. 418 | 419 | 420 | safe-buffer 421 | MIT 422 | The MIT License (MIT) 423 | 424 | Copyright (c) Feross Aboukhadijeh 425 | 426 | Permission is hereby granted, free of charge, to any person obtaining a copy 427 | of this software and associated documentation files (the "Software"), to deal 428 | in the Software without restriction, including without limitation the rights 429 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 430 | copies of the Software, and to permit persons to whom the Software is 431 | furnished to do so, subject to the following conditions: 432 | 433 | The above copyright notice and this permission notice shall be included in 434 | all copies or substantial portions of the Software. 435 | 436 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 437 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 438 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 439 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 440 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 441 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 442 | THE SOFTWARE. 443 | 444 | 445 | safer-buffer 446 | MIT 447 | MIT License 448 | 449 | Copyright (c) 2018 Nikita Skovoroda 450 | 451 | Permission is hereby granted, free of charge, to any person obtaining a copy 452 | of this software and associated documentation files (the "Software"), to deal 453 | in the Software without restriction, including without limitation the rights 454 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 455 | copies of the Software, and to permit persons to whom the Software is 456 | furnished to do so, subject to the following conditions: 457 | 458 | The above copyright notice and this permission notice shall be included in all 459 | copies or substantial portions of the Software. 460 | 461 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 462 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 463 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 464 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 465 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 466 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 467 | SOFTWARE. 468 | 469 | 470 | ssh2 471 | MIT 472 | Copyright Brian White. All rights reserved. 473 | 474 | Permission is hereby granted, free of charge, to any person obtaining a copy 475 | of this software and associated documentation files (the "Software"), to 476 | deal in the Software without restriction, including without limitation the 477 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 478 | sell copies of the Software, and to permit persons to whom the Software is 479 | furnished to do so, subject to the following conditions: 480 | 481 | The above copyright notice and this permission notice shall be included in 482 | all copies or substantial portions of the Software. 483 | 484 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 485 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 486 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 487 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 488 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 489 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 490 | IN THE SOFTWARE. 491 | 492 | ssh2-sftp-client 493 | Apache-2.0 494 | Apache License 495 | Version 2.0, January 2004 496 | http://www.apache.org/licenses/ 497 | 498 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 499 | 500 | 1. Definitions. 501 | 502 | "License" shall mean the terms and conditions for use, reproduction, 503 | and distribution as defined by Sections 1 through 9 of this document. 504 | 505 | "Licensor" shall mean the copyright owner or entity authorized by 506 | the copyright owner that is granting the License. 507 | 508 | "Legal Entity" shall mean the union of the acting entity and all 509 | other entities that control, are controlled by, or are under common 510 | control with that entity. For the purposes of this definition, 511 | "control" means (i) the power, direct or indirect, to cause the 512 | direction or management of such entity, whether by contract or 513 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 514 | outstanding shares, or (iii) beneficial ownership of such entity. 515 | 516 | "You" (or "Your") shall mean an individual or Legal Entity 517 | exercising permissions granted by this License. 518 | 519 | "Source" form shall mean the preferred form for making modifications, 520 | including but not limited to software source code, documentation 521 | source, and configuration files. 522 | 523 | "Object" form shall mean any form resulting from mechanical 524 | transformation or translation of a Source form, including but 525 | not limited to compiled object code, generated documentation, 526 | and conversions to other media types. 527 | 528 | "Work" shall mean the work of authorship, whether in Source or 529 | Object form, made available under the License, as indicated by a 530 | copyright notice that is included in or attached to the work 531 | (an example is provided in the Appendix below). 532 | 533 | "Derivative Works" shall mean any work, whether in Source or Object 534 | form, that is based on (or derived from) the Work and for which the 535 | editorial revisions, annotations, elaborations, or other modifications 536 | represent, as a whole, an original work of authorship. For the purposes 537 | of this License, Derivative Works shall not include works that remain 538 | separable from, or merely link (or bind by name) to the interfaces of, 539 | the Work and Derivative Works thereof. 540 | 541 | "Contribution" shall mean any work of authorship, including 542 | the original version of the Work and any modifications or additions 543 | to that Work or Derivative Works thereof, that is intentionally 544 | submitted to Licensor for inclusion in the Work by the copyright owner 545 | or by an individual or Legal Entity authorized to submit on behalf of 546 | the copyright owner. For the purposes of this definition, "submitted" 547 | means any form of electronic, verbal, or written communication sent 548 | to the Licensor or its representatives, including but not limited to 549 | communication on electronic mailing lists, source code control systems, 550 | and issue tracking systems that are managed by, or on behalf of, the 551 | Licensor for the purpose of discussing and improving the Work, but 552 | excluding communication that is conspicuously marked or otherwise 553 | designated in writing by the copyright owner as "Not a Contribution." 554 | 555 | "Contributor" shall mean Licensor and any individual or Legal Entity 556 | on behalf of whom a Contribution has been received by Licensor and 557 | subsequently incorporated within the Work. 558 | 559 | 2. Grant of Copyright License. Subject to the terms and conditions of 560 | this License, each Contributor hereby grants to You a perpetual, 561 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 562 | copyright license to reproduce, prepare Derivative Works of, 563 | publicly display, publicly perform, sublicense, and distribute the 564 | Work and such Derivative Works in Source or Object form. 565 | 566 | 3. Grant of Patent License. Subject to the terms and conditions of 567 | this License, each Contributor hereby grants to You a perpetual, 568 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 569 | (except as stated in this section) patent license to make, have made, 570 | use, offer to sell, sell, import, and otherwise transfer the Work, 571 | where such license applies only to those patent claims licensable 572 | by such Contributor that are necessarily infringed by their 573 | Contribution(s) alone or by combination of their Contribution(s) 574 | with the Work to which such Contribution(s) was submitted. If You 575 | institute patent litigation against any entity (including a 576 | cross-claim or counterclaim in a lawsuit) alleging that the Work 577 | or a Contribution incorporated within the Work constitutes direct 578 | or contributory patent infringement, then any patent licenses 579 | granted to You under this License for that Work shall terminate 580 | as of the date such litigation is filed. 581 | 582 | 4. Redistribution. You may reproduce and distribute copies of the 583 | Work or Derivative Works thereof in any medium, with or without 584 | modifications, and in Source or Object form, provided that You 585 | meet the following conditions: 586 | 587 | (a) You must give any other recipients of the Work or 588 | Derivative Works a copy of this License; and 589 | 590 | (b) You must cause any modified files to carry prominent notices 591 | stating that You changed the files; and 592 | 593 | (c) You must retain, in the Source form of any Derivative Works 594 | that You distribute, all copyright, patent, trademark, and 595 | attribution notices from the Source form of the Work, 596 | excluding those notices that do not pertain to any part of 597 | the Derivative Works; and 598 | 599 | (d) If the Work includes a "NOTICE" text file as part of its 600 | distribution, then any Derivative Works that You distribute must 601 | include a readable copy of the attribution notices contained 602 | within such NOTICE file, excluding those notices that do not 603 | pertain to any part of the Derivative Works, in at least one 604 | of the following places: within a NOTICE text file distributed 605 | as part of the Derivative Works; within the Source form or 606 | documentation, if provided along with the Derivative Works; or, 607 | within a display generated by the Derivative Works, if and 608 | wherever such third-party notices normally appear. The contents 609 | of the NOTICE file are for informational purposes only and 610 | do not modify the License. You may add Your own attribution 611 | notices within Derivative Works that You distribute, alongside 612 | or as an addendum to the NOTICE text from the Work, provided 613 | that such additional attribution notices cannot be construed 614 | as modifying the License. 615 | 616 | You may add Your own copyright statement to Your modifications and 617 | may provide additional or different license terms and conditions 618 | for use, reproduction, or distribution of Your modifications, or 619 | for any such Derivative Works as a whole, provided Your use, 620 | reproduction, and distribution of the Work otherwise complies with 621 | the conditions stated in this License. 622 | 623 | 5. Submission of Contributions. Unless You explicitly state otherwise, 624 | any Contribution intentionally submitted for inclusion in the Work 625 | by You to the Licensor shall be under the terms and conditions of 626 | this License, without any additional terms or conditions. 627 | Notwithstanding the above, nothing herein shall supersede or modify 628 | the terms of any separate license agreement you may have executed 629 | with Licensor regarding such Contributions. 630 | 631 | 6. Trademarks. This License does not grant permission to use the trade 632 | names, trademarks, service marks, or product names of the Licensor, 633 | except as required for reasonable and customary use in describing the 634 | origin of the Work and reproducing the content of the NOTICE file. 635 | 636 | 7. Disclaimer of Warranty. Unless required by applicable law or 637 | agreed to in writing, Licensor provides the Work (and each 638 | Contributor provides its Contributions) on an "AS IS" BASIS, 639 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 640 | implied, including, without limitation, any warranties or conditions 641 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 642 | PARTICULAR PURPOSE. You are solely responsible for determining the 643 | appropriateness of using or redistributing the Work and assume any 644 | risks associated with Your exercise of permissions under this License. 645 | 646 | 8. Limitation of Liability. In no event and under no legal theory, 647 | whether in tort (including negligence), contract, or otherwise, 648 | unless required by applicable law (such as deliberate and grossly 649 | negligent acts) or agreed to in writing, shall any Contributor be 650 | liable to You for damages, including any direct, indirect, special, 651 | incidental, or consequential damages of any character arising as a 652 | result of this License or out of the use or inability to use the 653 | Work (including but not limited to damages for loss of goodwill, 654 | work stoppage, computer failure or malfunction, or any and all 655 | other commercial damages or losses), even if such Contributor 656 | has been advised of the possibility of such damages. 657 | 658 | 9. Accepting Warranty or Additional Liability. While redistributing 659 | the Work or Derivative Works thereof, You may choose to offer, 660 | and charge a fee for, acceptance of support, warranty, indemnity, 661 | or other liability obligations and/or rights consistent with this 662 | License. However, in accepting such obligations, You may act only 663 | on Your own behalf and on Your sole responsibility, not on behalf 664 | of any other Contributor, and only if You agree to indemnify, 665 | defend, and hold each Contributor harmless for any liability 666 | incurred by, or claims asserted against, such Contributor by reason 667 | of your accepting any such warranty or additional liability. 668 | 669 | END OF TERMS AND CONDITIONS 670 | 671 | APPENDIX: How to apply the Apache License to your work. 672 | 673 | To apply the Apache License to your work, attach the following 674 | boilerplate notice, with the fields enclosed by brackets "[]" 675 | replaced with your own identifying information. (Don't include 676 | the brackets!) The text should be enclosed in the appropriate 677 | comment syntax for the file format. We also recommend that a 678 | file or class name and description of purpose be included on the 679 | same "printed page" as the copyright notice for easier 680 | identification within third-party archives. 681 | 682 | Copyright 2020 Tim Cross 683 | 684 | Licensed under the Apache License, Version 2.0 (the "License"); 685 | you may not use this file except in compliance with the License. 686 | You may obtain a copy of the License at 687 | 688 | http://www.apache.org/licenses/LICENSE-2.0 689 | 690 | Unless required by applicable law or agreed to in writing, software 691 | distributed under the License is distributed on an "AS IS" BASIS, 692 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 693 | See the License for the specific language governing permissions and 694 | limitations under the License. 695 | 696 | 697 | string_decoder 698 | MIT 699 | Node.js is licensed for use as follows: 700 | 701 | """ 702 | Copyright Node.js contributors. All rights reserved. 703 | 704 | Permission is hereby granted, free of charge, to any person obtaining a copy 705 | of this software and associated documentation files (the "Software"), to 706 | deal in the Software without restriction, including without limitation the 707 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 708 | sell copies of the Software, and to permit persons to whom the Software is 709 | furnished to do so, subject to the following conditions: 710 | 711 | The above copyright notice and this permission notice shall be included in 712 | all copies or substantial portions of the Software. 713 | 714 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 715 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 716 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 717 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 718 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 719 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 720 | IN THE SOFTWARE. 721 | """ 722 | 723 | This license applies to parts of Node.js originating from the 724 | https://github.com/joyent/node repository: 725 | 726 | """ 727 | Copyright Joyent, Inc. and other Node contributors. All rights reserved. 728 | Permission is hereby granted, free of charge, to any person obtaining a copy 729 | of this software and associated documentation files (the "Software"), to 730 | deal in the Software without restriction, including without limitation the 731 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 732 | sell copies of the Software, and to permit persons to whom the Software is 733 | furnished to do so, subject to the following conditions: 734 | 735 | The above copyright notice and this permission notice shall be included in 736 | all copies or substantial portions of the Software. 737 | 738 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 739 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 740 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 741 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 742 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 743 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 744 | IN THE SOFTWARE. 745 | """ 746 | 747 | 748 | 749 | tunnel 750 | MIT 751 | The MIT License (MIT) 752 | 753 | Copyright (c) 2012 Koichi Kobayashi 754 | 755 | Permission is hereby granted, free of charge, to any person obtaining a copy 756 | of this software and associated documentation files (the "Software"), to deal 757 | in the Software without restriction, including without limitation the rights 758 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 759 | copies of the Software, and to permit persons to whom the Software is 760 | furnished to do so, subject to the following conditions: 761 | 762 | The above copyright notice and this permission notice shall be included in 763 | all copies or substantial portions of the Software. 764 | 765 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 766 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 767 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 768 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 769 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 770 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 771 | THE SOFTWARE. 772 | 773 | 774 | tweetnacl 775 | Unlicense 776 | This is free and unencumbered software released into the public domain. 777 | 778 | Anyone is free to copy, modify, publish, use, compile, sell, or 779 | distribute this software, either in source code form or as a compiled 780 | binary, for any purpose, commercial or non-commercial, and by any 781 | means. 782 | 783 | In jurisdictions that recognize copyright laws, the author or authors 784 | of this software dedicate any and all copyright interest in the 785 | software to the public domain. We make this dedication for the benefit 786 | of the public at large and to the detriment of our heirs and 787 | successors. We intend this dedication to be an overt act of 788 | relinquishment in perpetuity of all present and future rights to this 789 | software under copyright law. 790 | 791 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 792 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 793 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 794 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 795 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 796 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 797 | OTHER DEALINGS IN THE SOFTWARE. 798 | 799 | For more information, please refer to 800 | 801 | 802 | typedarray 803 | MIT 804 | /* 805 | Copyright (c) 2010, Linden Research, Inc. 806 | Copyright (c) 2012, Joshua Bell 807 | 808 | Permission is hereby granted, free of charge, to any person obtaining a copy 809 | of this software and associated documentation files (the "Software"), to deal 810 | in the Software without restriction, including without limitation the rights 811 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 812 | copies of the Software, and to permit persons to whom the Software is 813 | furnished to do so, subject to the following conditions: 814 | 815 | The above copyright notice and this permission notice shall be included in 816 | all copies or substantial portions of the Software. 817 | 818 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 819 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 820 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 821 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 822 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 823 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 824 | THE SOFTWARE. 825 | $/LicenseInfo$ 826 | */ 827 | 828 | // Original can be found at: 829 | // https://bitbucket.org/lindenlab/llsd 830 | // Modifications by Joshua Bell inexorabletash@gmail.com 831 | // https://github.com/inexorabletash/polyfill 832 | 833 | // ES3/ES5 implementation of the Krhonos Typed Array Specification 834 | // Ref: http://www.khronos.org/registry/typedarray/specs/latest/ 835 | // Date: 2011-02-01 836 | // 837 | // Variations: 838 | // * Allows typed_array.get/set() as alias for subscripts (typed_array[]) 839 | 840 | 841 | util-deprecate 842 | MIT 843 | (The MIT License) 844 | 845 | Copyright (c) 2014 Nathan Rajlich 846 | 847 | Permission is hereby granted, free of charge, to any person 848 | obtaining a copy of this software and associated documentation 849 | files (the "Software"), to deal in the Software without 850 | restriction, including without limitation the rights to use, 851 | copy, modify, merge, publish, distribute, sublicense, and/or sell 852 | copies of the Software, and to permit persons to whom the 853 | Software is furnished to do so, subject to the following 854 | conditions: 855 | 856 | The above copyright notice and this permission notice shall be 857 | included in all copies or substantial portions of the Software. 858 | 859 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 860 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 861 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 862 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 863 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 864 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 865 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 866 | OTHER DEALINGS IN THE SOFTWARE. 867 | -------------------------------------------------------------------------------- /dist/pagent.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangyucode/sftp-upload-action/057558caceafb0ae9b9690d9afac6fa876be7d66/dist/pagent.exe -------------------------------------------------------------------------------- /lib/deployer.js: -------------------------------------------------------------------------------- 1 | const { lstat, opendir } = require('fs/promises'); 2 | const Client = require('ssh2-sftp-client'); 3 | const path = require('path'); 4 | const { minimatch } = require('minimatch'); 5 | 6 | class Deployer { 7 | 8 | constructor(config, options) { 9 | this.config = { 10 | username: 'root', 11 | port: 22, 12 | ...config 13 | }; 14 | this.options = { 15 | dryRun: false, 16 | exclude: [], 17 | ...options 18 | }; 19 | if (this.options.dryRun) console.warn('dryRun option is enabled! no files will be changed.'); 20 | this.sftp = new Client(); 21 | this.localFiles = []; 22 | this.remoteFiles = []; 23 | this.removeExtraFiles = []; 24 | 25 | } 26 | 27 | async sync() { 28 | await this.sftp.connect(this.config); 29 | console.log('connected to server'); 30 | 31 | await this.listLocalFiles(this.config.localDir); 32 | console.log(`found ${this.localFiles.length} local files`); 33 | 34 | await this.listRemoteFiles(this.config.remoteDir); 35 | console.log(`found ${this.remoteFiles.length} remote files`); 36 | 37 | await this.upload(); 38 | console.log('upload successfully'); 39 | if (this.options.removeExtraFilesOnServer) await this.deleteExtraFilesOnServer(); 40 | 41 | await this.sftp.end(); 42 | console.log('disconnected from server'); 43 | } 44 | 45 | async upload() { 46 | // upload files to remote 47 | for (const l of this.localFiles) { 48 | const r = this.remoteFiles.find(r => r.path === l.path.replace(/\\/g, '/')); 49 | const localFile = path.join(this.config.localDir, l.path); 50 | const remoteFile = path.posix.join(this.config.remoteDir, l.path.replace(/\\/g, '/')); 51 | if (this.options.forceUpload) { 52 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''} force upload -> ${l.path}`); 53 | // remove before upload 54 | if (r) { 55 | if (r.isDirectory) { 56 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}deleting folder -> ${remoteFile}`); 57 | if (!this.options.dryRun) await this.sftp.rmdir(remoteFile, true); 58 | } else { 59 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}deleting file -> ${remoteFile}`); 60 | if (!this.options.dryRun) await this.sftp.delete(remoteFile, true); 61 | } 62 | } 63 | if (l.isDirectory) { 64 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}creating folder -> ${remoteFile}`); 65 | if (!this.options.dryRun) await this.sftp.mkdir(remoteFile, true); 66 | } else { 67 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}uploading file -> ${remoteFile}`); 68 | if (!this.options.dryRun) await this.sftp.put(localFile, remoteFile); 69 | } 70 | 71 | } else { 72 | if (r) { 73 | if (r.isDirectory !== l.isDirectory) { 74 | throw new Error(`remote has different file type and same name of ${r.path}, consider using 'forceUpload' to overwrite it.`); 75 | } else if (!r.isDirectory) { 76 | if (r.size !== l.size) { 77 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}replace different -> ${l.path}`); 78 | if (!this.options.dryRun) await this.sftp.put(localFile, remoteFile); 79 | } else if (r.mtime < l.mtime) { 80 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}replace newer -> ${l.path}`); 81 | if (!this.options.dryRun) await this.sftp.put(localFile, remoteFile); 82 | } else { 83 | console.log(`server has same file: ${localFile}, skipping upload.`); 84 | } 85 | } 86 | } else if (!l.isDirectory) { 87 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}creating file -> ${remoteFile}`); 88 | if (!this.options.dryRun) { 89 | await this.sftp.mkdir(path.dirname(remoteFile), true); 90 | await this.sftp.put(localFile, remoteFile); 91 | } 92 | } else { 93 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}creating folder -> ${remoteFile}`); 94 | if (!this.options.dryRun) await this.sftp.mkdir(remoteFile, true); 95 | } 96 | } 97 | } 98 | } 99 | 100 | 101 | async listLocalFiles(localPath) { 102 | const stats = await lstat(localPath); 103 | if (stats.isDirectory()) { 104 | const dir = await opendir(localPath); 105 | for await (const file of dir) { 106 | const filePath = path.join(localPath, file.name); 107 | const relativePath = this.getRelativePath(filePath, false); 108 | if (this.isIgnoreFile(relativePath)) { 109 | console.log(`ignored local -> ${relativePath}`); 110 | continue; 111 | } 112 | if (file.isDirectory()) { 113 | this.localFiles.push({ path: relativePath, isDirectory: true }); 114 | // recursion 115 | await this.listLocalFiles(filePath); 116 | } else { 117 | const fileState = await lstat(filePath); 118 | this.localFiles.push({ path: relativePath, size: fileState.size, mtime: fileState.mtimeMs }); 119 | } 120 | } 121 | } else { 122 | this.localFiles.push({ path: this.getRelativePath(localPath, false), size: stats.size, mtime: stats.mtimeMs }); 123 | } 124 | } 125 | 126 | async listRemoteFiles(remotePath) { 127 | let fileInfo = await this.sftp.exists(remotePath); 128 | if (!fileInfo) { 129 | console.log(`remote folder not exist -> ${remotePath}`); 130 | return; 131 | } 132 | if (fileInfo === 'd') { 133 | const filesOnServer = await this.sftp.list(remotePath); 134 | for (const file of filesOnServer) { 135 | const filePath = path.posix.join(remotePath, file.name); 136 | const relativePath = this.getRelativePath(filePath, true); 137 | 138 | if (this.isIgnoreFile(`${relativePath}${file.type === 'd' ? '/' : ''}`)) { 139 | console.log(`ignored remote ${relativePath}`); 140 | continue; 141 | } 142 | 143 | if (this.options.removeExtraFilesOnServer) { 144 | const localFile = this.localFiles.find(l => relativePath === l.path.replace(/\\/g, '/')); 145 | if (!localFile) { 146 | console.log(`found extra remote file -> ${filePath}`); 147 | this.removeExtraFiles.push({ filePath, isDirectory: file.type === 'd' }); 148 | } 149 | } 150 | 151 | if (file.type === 'd') { 152 | // recursion 153 | this.remoteFiles.push({ path: relativePath, isDirectory: true }); 154 | await this.listRemoteFiles(filePath); 155 | } else { 156 | this.remoteFiles.push({ path: relativePath, size: file.size, mtime: file.modifyTime }); 157 | } 158 | } 159 | } else { 160 | this.remoteFiles.push({ path: this.getRelativePath(remotePath, true), size: stats.size, mtime: stats.modifyTime }); 161 | } 162 | } 163 | 164 | 165 | async deleteExtraFilesOnServer() { 166 | for (const file of this.removeExtraFiles) { 167 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}removing extra ${file.isDirectory ? 'folder' : 'file'} '${file.filePath}' on remote.`); 168 | if (!this.options.dryRun) file.isDirectory ? await this.sftp.rmdir(file.filePath, true) : await this.sftp.delete(file.filePath); 169 | } 170 | } 171 | 172 | async removeExtraFilesOnServer(remotePath, isDirectory) { 173 | const exist = this.localFiles.some(l => l.path === remotePath); 174 | if (exist) return false; 175 | console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}removing extra ${isDirectory ? 'folder' : 'file'} '${remotePath}' on remote.`); 176 | const remoteFile = path.posix.join(this.config.remoteDir, remotePath); 177 | if (!this.options.dryRun) isDirectory ? await this.sftp.rmdir(remoteFile, true) : await this.sftp.delete(remoteFile); 178 | return true; 179 | } 180 | 181 | getRelativePath(file, isRemote) { 182 | const dirPath = isRemote ? path.posix.resolve(this.config.remoteDir) : path.posix.resolve(this.config.localDir); 183 | const filePath = isRemote ? path.posix.resolve(file) : path.posix.resolve(file); 184 | return dirPath === filePath ? filePath : filePath.replace(`${dirPath}/`, ''); 185 | } 186 | 187 | isIgnoreFile(path) { 188 | return this.options.exclude.some(pattern => minimatch(path, pattern)); 189 | } 190 | } 191 | 192 | module.exports = { Deployer }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sftp-upload-action", 3 | "version": "2.0.4", 4 | "description": "sftp upload using sftp-sync-deploy", 5 | "private": true, 6 | "scripts": { 7 | "build": "ncc build sftp.js --license licenses.txt", 8 | "test": "jest --coverage" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/wangyucode/sftp-upload-action.git" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC", 17 | "bugs": { 18 | "url": "https://github.com/wangyucode/sftp-upload-action/issues" 19 | }, 20 | "homepage": "https://github.com/wangyucode/sftp-upload-action#readme", 21 | "dependencies": { 22 | "@actions/core": "1.11.1", 23 | "minimatch": "10.0.1", 24 | "ssh2-sftp-client": "11.0.0" 25 | }, 26 | "devDependencies": { 27 | "@vercel/ncc": "^0.38.2", 28 | "jest": "^29.6.2" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sftp.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const fs = require('fs'); 3 | const { Deployer } = require('./lib/deployer'); 4 | 5 | const config = { 6 | host: core.getInput('host'), // Required. 7 | port: core.getInput('port'), // Optional, Default to 22. 8 | username: core.getInput('username'), // Required. 9 | password: core.getInput('password'), // Optional. 10 | privateKey: core.getInput('privateKey'), // Optional. 11 | passphrase: core.getInput('passphrase'), // Optional. 12 | algorithms: core.getInput('compress') ? {compress: 'zlib@openssh.com'} : {}, // Optional. Default to false. 13 | agent: core.getInput('agent'), // Optional, path to the ssh-agent socket. 14 | localDir: core.getInput('localDir'), // Required, Absolute or relative to cwd. 15 | remoteDir: core.getInput('remoteDir') // Required, Absolute path only. 16 | }; 17 | 18 | const options = { 19 | dryRun: JSON.parse(core.getInput('dryRun')), // Enable dry-run mode. Default to false. 20 | exclude: core.getInput('exclude').split(','), // exclude patterns (glob) like .gitignore. 21 | forceUpload: JSON.parse(core.getInput('forceUpload')), // Force uploading all files, Default to false(upload only newer files). 22 | removeExtraFilesOnServer: JSON.parse(core.getInput('removeExtraFilesOnServer')) // Remove extra files on server, default to false. 23 | }; 24 | 25 | if (config.privateKey && !/^[-]+[A-Z ]+[-]+\n/.test(config.privateKey)) { 26 | try { 27 | config.privateKey = fs.readFileSync(config.privateKey);; 28 | } catch (err) { 29 | console.error(err); 30 | throw new Error(`Private key file not found ${config.privateKey}`); 31 | } 32 | } 33 | 34 | new Deployer(config, options) 35 | .sync() 36 | .then(() => console.log('sftp upload success!')); 37 | 38 | -------------------------------------------------------------------------------- /test/file1: -------------------------------------------------------------------------------- 1 | content of the the file1. 2 | -------------------------------------------------------------------------------- /test/file2: -------------------------------------------------------------------------------- 1 | content of the the file2. 2 | -------------------------------------------------------------------------------- /test/folder1/file3: -------------------------------------------------------------------------------- 1 | content of the the file. 2 | -------------------------------------------------------------------------------- /test/folder1/file4: -------------------------------------------------------------------------------- 1 | content of the the file4. 2 | changed 3 | --------------------------------------------------------------------------------