Skip to content

build: configure package to build and publish from dist directory #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2019
Merged

Conversation

MasterOdin
Copy link
Contributor

@MasterOdin MasterOdin commented Oct 18, 2019

Closes #969

This makes it so that tsc will now build all tsc files into the ./dist folder (and the watson.js and watson.min.js are generated into ./dist/dist) to help keep the source tree clean while developing.

Additionally, to handle the publishing aspect of this new folder structure without losing the flat import structure for end-user, this adds tsc-publish (which for disclosure is my own package I use for publishing my own typescript projects) to handle the steps of building the package and getting the right files into place when specifying a non-root outDir so that one would publish from that directory. The package itself uses the .npmignore file to decide on what files to copy into the build directory. While tsc-publish supports the entire pipeline, I've left the actual publish step to @semantic-release/npm and only run tsc-publish --dry-run, which only does the act of building and copying files. The --no-checks flag is there so that it does not run the lint or test commands as part of its process.

Tested that semantic-release works by building and publishing masterodin-watson-test package, which I will un-publish in 48 hours so as to not have it permanently exist (it's been removed, I can put up a new package on Tuesday when I'm back at work). I then used that package to test the npm install process as and end-user in my existing projects to verify that an end-user will not be affected in any way by the build process change.

I moved the building for the semantic-release/npm to be tied to the postversion command so that it gets run in the prepare phase so that the dist/ directory gets completely set-up with the package.json copied in as the publish phase requires the package.json to exist in the pkgRoot directory at the start of the step.

NPM Publish Report

npm notice 📦 [email protected]
npm notice === Tarball Contents ===
npm notice 10.2kB LICENSE
npm notice 1.0kB lib/common.js
npm notice 1.3kB auth/index.js
npm notice 21.6kB lib/recognize-stream.js
npm notice 1.6kB sdk.js
npm notice 9.4kB lib/synthesize-stream.js
npm notice 228.1kB speech-to-text/v1-generated.js
npm notice 68.8kB text-to-speech/v1-generated.js
npm notice 165.1kB assistant/v1.js
npm notice 4.1kB authorization/v1.js
npm notice 54.5kB compare-comply/v1.js
npm notice 202.6kB discovery/v1.js
npm notice 18.0kB natural-language-classifier/v1.js
npm notice 13.5kB natural-language-understanding/v1.js
npm notice 9.1kB speech-to-text/v1.js
npm notice 5.7kB text-to-speech/v1.js
npm notice 12.9kB assistant/v2.js
npm notice 41.3kB language-translator/v3.js
npm notice 25.1kB personality-insights/v3.js
npm notice 19.3kB tone-analyzer/v3.js
npm notice 31.6kB visual-recognition/v3.js
npm notice 41.9kB visual-recognition/v4.js
npm notice 2.4MB dist/watson.js
npm notice 843.0kB dist/watson.min.js
npm notice 2.0kB lib/websocket-utils.js
npm notice 4.5kB package.json
npm notice 53.4kB CHANGELOG.md
npm notice 7.0kB MIGRATION-V5.md
npm notice 31.7kB README.md
npm notice 226B lib/common.d.ts
npm notice 821B auth/index.d.ts
npm notice 9.0kB lib/recognize-stream.d.ts
npm notice 1.6kB sdk.d.ts
npm notice 4.1kB lib/synthesize-stream.d.ts
npm notice 259.3kB speech-to-text/v1-generated.d.ts
npm notice 58.8kB text-to-speech/v1-generated.d.ts
npm notice 159.5kB assistant/v1.d.ts
npm notice 2.2kB authorization/v1.d.ts
npm notice 81.7kB compare-comply/v1.d.ts
npm notice 211.3kB discovery/v1.d.ts
npm notice 13.3kB natural-language-classifier/v1.d.ts
npm notice 35.3kB natural-language-understanding/v1.d.ts
npm notice 4.4kB speech-to-text/v1.d.ts
npm notice 1.8kB text-to-speech/v1.d.ts
npm notice 25.5kB assistant/v2.d.ts
npm notice 33.0kB language-translator/v3.d.ts
npm notice 35.0kB personality-insights/v3.d.ts
npm notice 25.5kB tone-analyzer/v3.d.ts
npm notice 29.1kB visual-recognition/v3.d.ts
npm notice 33.0kB visual-recognition/v4.d.ts
npm notice 1.3kB lib/websocket-utils.d.ts

If this gets merged, I'll be happy to apply a similar patch to https://github.com/IBM/node-sdk-core.

Checklist
  • npm test passes (tip: npm run autofix can correct most style issues)

Copy link
Contributor

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great, I'm all for it. Seems very thorough - nice work. Would like for @germanattanasio to put a second set of eyes on it if he wants, otherwise I'll merge in the next few days

Copy link
Contributor

@germanattanasio germanattanasio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. Thanks @MasterOdin! I left a comment related to uglifyjs

@germanattanasio germanattanasio merged commit 7587c23 into watson-developer-cloud:master Oct 28, 2019
@MasterOdin
Copy link
Contributor Author

Thanks for merging! @dpopp07 and @germanattanasio please let me know if you would like me to open a similar PR for the node-sdk-core since I believe it has a similar setup of building in-place and same semantic-release based release process.

@dpopp07
Copy link
Contributor

dpopp07 commented Oct 28, 2019

@MasterOdin Yes, that would be great. I would like the same experience for both repos

@watson-github-bot
Copy link
Collaborator

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Build and release node-sdk from a build directory
4 participants