Giter Club home page Giter Club logo

ssh-deploy-release's People

Contributors

guiguicucu avatar nstcactus avatar paulhayes avatar sibyx avatar sopi20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssh-deploy-release's Issues

Can't exclude a directory

Is it possible to make option.exclude work?

This is what I have done :

const Deployer = require('ssh-deploy-release');

const options = {
   localPath: '/Users/joe/workspace/codex/',
   host: 'my-server',
   port: '9222',
   username: 'joe',
   password: 'joe*',
   deployPath: '/var/lib/codex/',
   currentReleaseLink: 'htdocs',
   exclude : ['/.svn']
};

const deployer = new Deployer(options);
deployer.deployRelease(() => {
   console.log('Ok !')
});

There is a directory located in /Users/joe/workspace/codex/.svn.
I don't want this directory to be in my release.
Unfortunately, the configuration doesn't work.

Error while compressing in archive mode

When I execute yarn deployator deploy --environment=review --branch="master" --debug I get this error :

Compress release
Error while compressing
/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:147
      throw err;
      ^

Error: size mismatch
    at Sink.<anonymous> (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/pack.js:174:23)
    at Sink.f (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/once/once.js:25:25)
    at Sink.onfinish (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/end-of-stream/index.js:31:27)
    at Sink.emit (events.js:215:7)
    at finishMaybe (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:620:14)
    at endWritable (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:629:3)
    at Sink.Writable.end (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:567:22)
    at Readable.onend (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:299:28)
    at Readable.emit (events.js:215:7)
error Command failed with exit code 1.

Here is my config file :

"use strict";

module.exports = function (options) {
    return {
        common: {
            localPath: process.cwd(),
            share: {},
            exclude: [
                '.git'
            ],
            create: [],
            makeWritable: [
                'composer.json',
                'composer.lock',
                'vendor',
                'web',
            ],
            debug: true,
        },
        environments: {
            review: {
                host: 'myhost.com',
                username: 'username',
                password: 'pwd',
                deployPath: '/my/path/' + options.get('branch'),
                allowRemove: true
            },
        }
    };
};

Thanks

Set up a SFTP docker container to run tests

In order to be able to test seriously, we need a test SFTP server. We can use the atmoz/sftp image to set up an SFTP server accepting connections authenticated using password or private keys.
This would be the first step towards having real, reliable e2E tests.

Get rid of the dependance to scp2

scp2 hasn't been updated in 3 years and most probably won't be anytime soon since there is currently no maintainer.

This causes 2 dependency problems:

  • the lodash version it depends on has security issues which causes GitHub to send us alerts every week
  • it depends on [email protected] which prevents us from supporting the ed25519 key format when running in archive mode

It's less than 500 lines of code so we could include it in ssh-deploy-release.

This would allow us to fix #14.

Releases are not removed

Hello,

The option releasesToKeep seems not to be seen by the tool.

const Deployer = require('ssh-deploy-release');

const options = {
   localPath: '/Users/joe/codex/',
   host: 'joe.com',
   port: '9222',
   username: 'joe',
   password: 'mypwd',
   allowRemove: true,
   releasesToKeep: 5,
   deployPath: '/var/lib/www/codex/',
   currentReleaseLink: 'htdocs',
   exclude : ['.svn/**']
};

const deployer = new Deployer(options);
deployer.deployRelease(() => {
   console.log('Ok !')
});

The releases are well deployed but none of the releases are removed ever.

Do I need to use removeRelease explicitly? In that case, what is the purpose of allowRemove and releasesToKeep ?

Can't upload to a specific server.

Connect to .com
Connected

Compress release
Archive created : 5.23 MB

Create release folder on remote

  • /var/www/releases//2017-06-13-00-50-43-443-UTC

Remote command : mkdir -p /var/www/releases//2017-06-13-00-50-43-443-UTC
chmod ugo+w /var/www/releases//2017-06-13-00-50-43-443-UTC
Done

Upload archive to remote
⠸ Uploadingbuffer.js:262
throw new TypeError(kFromErrorMsg);
^

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at fromObject (buffer.js:262:9)
at Function.Buffer.from (buffer.js:101:10)
at new Buffer (buffer.js:80:17)
at onNEWKEYS (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:2282:29)
at Parser. (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:123:5)
at emitNone (events.js:86:13)
at Parser.emit (events.js:185:7)
at Parser.parsePacket (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Parser.js:468:12)
at Parser.execute (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Parser.js:249:14)
at Socket. (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:523:18)

tar gz archive type doesn't actually compress

From the readme:

#### options.archiveType
`zip` : Use *zip* compression (`unzip` command on remote)

`tar` : Use *tar gz* compression (`tar` command on remote)

Default : `tar`

The archive has a .tar.gz extension but it is not actually compressed.

I think the problem is at https://github.com/la-haute-societe/ssh-deploy-release/blob/master/src/Archiver.js#L33.

The archiver option is always an empty object.

I'm guessing there were some plans to wire in the gzip option specified here: https://github.com/la-haute-societe/ssh-deploy-release/blob/master/src/Options.js#L22

Decompress not working

The decompressArchiveOnRemoteTask does not work on my configuration. The "cd " + this.release.path command doesn't work so any of the following commands are performed on the root shell login. When I modify your code to use absolute paths for the untarring, just like you do with the rm, it's working perfectly.
The server I am deploying to is an ubuntu 16.04. Maybe it is OS specific.

[BUG] `remote.upload` only work work for single files in working directory

I tried to use the upload.remote function to upload a .env-file from my local pc to the target directory at the server.
The .env-File is placed in ../private from the perspective of the working directory, where the deploy-script was started /backend.

image

Nevertheless what I try, I got "Error: No such File".

Found the BUG

I've did some debuging, and figured out, that the implementation of upload.remote was logical wrong:

image`

This piece of code shows, that the src is always added to the server-target path.
This fully breaks the functionality, if your src is not equal to a single filename without any path.

Example:

$src = '/home/me/private/myFileToUpload.txt';
$target = '/var/www/serverRoot/';
sftp.fastPut(src, `${target}/${src}`

Will try to upload the file to:

/var/www/serverRoot//home/me/private/myFileToUpload.txt

Synchronize mode doesn't honor the `port` setting

preproduction: {
    localPath:    'www',
    host:         'xxx.xxx.xxx.xxx',
    port:         2201,
    username:     'root',
    password:     'xxxxxxxx',
    deployPath:   '/srv/www/preprod',
},

Trying to deploy using this example config fails with the following error message:

Fatal error : Error: Command failed: rsync --rsh='sshpass -p "xxxxxxxx" ssh -l root -o StrictHostKeyChecking=no'  -a --stats --delete www/ [email protected]:/srv/www/preprod/synchronized
ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]

How to use with npm script?

I cant find in the documentation any about how to load / use the config file with npm script?

I install it with npm install ssh-deploy-release --save then i add npm run ssh-deploy-release? but how i tell him what configs he have to use?

Error Message about: ERR_REQUIRE_ESM

I try to run my deploy-script, but got this error:

> DEPLOY_TYPE=production node scripts/deployment.cjs

start deployment.cjs
/home/me/myProject/node_modules/cli-progress/lib/formatter.js:1
const _stringWidth = require('string-width');
                     ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/me/myProject/node_modules/string-width/index.js from /home/me/myProject/node_modules/cli-progress/lib/formatter.js not supported.
Instead change the require of index.js in /home/me/myProject/node_modules/cli-progress/lib/formatter.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/formatter.js:1:22)
    at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/generic-bar.js:3:20)
    at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/single-bar.js:1:21)
    at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/cli-progress.js:1:20)
    at Object.<anonymous> (/home/me/myProject/node_modules/ssh-deploy-release/dist/Remote.js:19:21)
    at Object.<anonymous> (/home/me/myProject/node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:15:16)
    at Object.<anonymous> (/home/me/myProject/scripts/deployment.cjs:3:18) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.16.0

As you see in the above output, the error appears right before the second console.log, so the issue must be on ssh-deploy-release and it's dependencies.

image

Fails for Windows OpenSSH deployment

Bugs

  1. Fails due to path formation uses Linux directory separator instead of Windows
  2. Error occurred while processing: -p
    • -p switch in mkdir is not recognised in windows

Add progress of upload

Mb add some progress bar when upload is in progress? It take too long and I am not sure is it stuck or working. Also I notice that upload speed is lower then usual (for example when I use other SFTP client).

Add a compression option

Add a compression option to enable the rsync -z flag when in synchronize mode.

The default value could be true to speed up builds and false could be passed to make it work on server not supporting compression.

Bug while using mode synchronize

There is a kind of serious bug while using mode "synchronize",

at first the deployment fails, but it also creates a file in the directory with the characters from the command, including also the password:

Screenshot 2021-02-05 165431

I think it is caused because the password is wrapped with single quote, that will break the open single quote at --rsh

Using mode "archive" works like a charm.

Simplify rsync excludes

Requiring another way to set excludes for synchronize mode (rsync) is error prone.

The rsync command has an --exclude switch that can be called several times to exclude different files and folders :

rsync -a --exclude media --exclude storage/ --exclude some/deep/directory

This works for files & directories, so we could just build a list of --exclude switches from the
exclude option form the configuration.

The only pitfall is that it doesn't support the glob syntax: --exclude craft/storage/** or --exclude craft/storage/* doesn't work, you have to use either --exclude craft/storage/ or --exclude craft/storage. To avoid headaches we should advise in the exclude option documentation to use both the glob and the rsync syntax to exclude a directory:

{
    ...
    exclude: [
        'craft/storage/**', // Glob syntax
        'craft/storage/',   // rsync syntax
    ],
    ...
}

Another option would be to rewrite the excludes written in glob syntax when using the synchronize mode but it seems like a bad idea.

NPM publish using TravisCI

Currently, publishing to the NPM registry is a manual operation.

This should be automated so that the package is published automatically on each tag push.

Error when privateKeyFile is defined but passphrase isn't

Present in 3.0.0-beta.7.

node_modules/any-shell-escape/shell-escape.js:31
    stringOrArray.forEach(function(member) {
                  ^

TypeError: Cannot read property 'forEach' of undefined
    at module.exports (node_modules/any-shell-escape/shell-escape.js:31:19)
    at module.exports.synchronize (node_modules/ssh-deploy-release/dist/Remote.js:168:35)
    at module.exports.uploadReleaseTask (node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:233:17)
    at eachfn (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:2952:28)
    at replenish (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:444:21)
    at iterateeCallback (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:428:21)
    at node_modules/ssh-deploy-release/node_modules/async/dist/async.js:325:20
    at result (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:2957:17)
    at remote.createFolder (node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:191:7)
    at wrapper (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:272:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Script breaks when command in onAfterDeploy send stdout message

I don't know if this is expected behavior but the whole script breaks when standard message (not error or warning) comes from the command inside onAfterDeploy. My solution right now is to put a 2>/dev/null || true after yeach command, so that the process don't break without reason.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.