build: configure package to build and publish from dist directory #990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #969
This makes it so that
tsc
will now build all tsc files into the./dist
folder (and thewatson.js
andwatson.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. Whiletsc-publish
supports the entire pipeline, I've left the actual publish step to@semantic-release/npm
and only runtsc-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 thelint
ortest
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 thenpm 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 theprepare
phase so that thedist/
directory gets completely set-up with the package.json copied in as thepublish
phase requires the package.json to exist in thepkgRoot
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)