Deploy to NPM has no local_dir available

Hi,
I’m having trouble deploying to NPM (https://github.com/merlosy/ngx-material-file-input/blob/master/.travis.yml).
As much as I want to use it, I just cannot specify a dist directory! This is a big issue for me since I have multiple deploy provider running.
the npm publish command is actually more helpful.

If someone has a solution, that’d be very helpful! or a fix on the deploy provider?

This is the code for the npm provider: https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb Hope it will help you understand what is happening.
You didn’t give any error details, the build log in particular, so can’t say anything else.

Thanks for the reply but I don’t see how it can help.
I have a deploy step with 3 different providers(gh-pages, github release, npm release), each deploy a different artifact or set of files.
The issue with before_script is that it applies to all 3 of them. (Right?)

Logs of my last attempt: https://travis-ci.org/merlosy/ngx-material-file-input/jobs/500943603

The 3rd deploy is deploying everything to npm, but I wanted to deploy just the dist/material-file-input folder

thanks

According to https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb#L33 , it runs npm publish in the project root, passing only API key and tag if specified. All that happens next is hence up to the utility.

According to https://docs.npmjs.com/files/package.json , you can specify files to deploy with the “files” parameter or, as per https://docs.npmjs.com/cli/publish, exclude files with a .gitignore or .npmignore. It looks like with this, the tree will still be rooted at the project root – i.e. if you specify e.g. “dist/material-file-input/*” it will create the directories dist/material-file-input and their content under them. If you rather need the deployed tree to be rooted at dist/material-file-input, you need to move project.json (and other appropriate metafiles if any) there and use the script provider:

deploy:
    script:
        - cd dist/material-file-input
        - NPM_API_KEY=<api_key> npm publish <etc>

There are a couple of viable options.

  1. Split your build into stages; the test stage that runs the tests, and the deploy stage with three different jobs, each running different deployments. One of them (one for npm) can naturally execute cd … in before_deploy step.
  2. Write a PR that adds the local_dir option to the npm provider. This seems straightforward.

(Note that the script provider does not accept multiple commands.)

1 Like

I created PR #1023 for this. If this is merged, when it will be released on Travis CI?