Trying to publish to private npm repo from bitbucket. The bundle is built and added to a folder called dist.
image: node:14
pipelines:
default:
- parallel:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm test
- step:
name: Lint the node package
script:
- npm install eslint
- npx eslint .
caches:
- node
branches:
master:
- parallel:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm run build
- step:
name: Security Scan
script:
# Run a security scan for sensitive data.
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
- pipe: atlassian/git-secrets-scan:0.5.1
- step:
name: Deploy to Production
deployment: Production
script:
# Bump versions before publishing
- npm --no-git-tag-version version "2.0.$BITBUCKET_BUILD_NUMBER" -m "Upgrade to new version"
# Publish package
- pipe: atlassian/npm-publish:0.3.2
variables:
NPM_TOKEN: $NPM_TOKEN
Problem is that publishing to npm, dist folder is not published.
Folder structure after building (locally and expected)
- package-name
- dist
- index.ts
- package.json
But with the Bitbucket pipeline, only package.json is added to the package, and dist is ignored.
Inside package.json, I've added the property
"files": [
"dist"
]
According to npm docs , files always take precedence over gitignore and npmrc.
Verified with npm publish --dry-run locally to make sure the right files are built. And it is working fine in that case.
I was able to make it work by adding entries in npmignore files (not adding dist in npmignore and adding in gitignore). But this creates a lot of redundancy.
Will Bitbucket pipeline consider files attribute in package.json?