Skip to content

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

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
Nov 6, 2019
Merged

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

merged 1 commit into from
Nov 6, 2019

Conversation

MasterOdin
Copy link
Contributor

Similar to watson-developer-cloud/node-sdk#990, this updates the build process for the repo to build the files to a dist/ directory instead of inline next to the source files. I add tsc-publish (which I maintain) to then help handle getting the right files (based off the .npmignore file) into the dist/ folder when you go to publish (through semantic-release).

To validate behavior and close the loop, I then did the following:

$ node_modules/.bin/semantic-release --no-ci
[1:28:38 PM] [semantic-release] › ℹ  Running semantic-release version 15.13.24
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/git"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[1:28:39 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[1:28:39 PM] [semantic-release] › ✔  Run automated release from branch master
[1:28:41 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[1:28:41 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[1:28:41 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[1:28:41 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[1:28:41 PM] [semantic-release] [@semantic-release/npm] › ℹ  Verify authentication for registry https://registry.npmjs.org/
[1:28:42 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/npm"
[1:28:42 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[1:28:42 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[1:28:43 PM] [semantic-release] › ℹ  Found git tag v1.3.0 associated with version 1.3.0
[1:28:43 PM] [semantic-release] › ℹ  Found 4 commits since last release
[1:28:43 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: feat: update name
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is minor
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: build: configure package to build and publish from dist directory
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: docs: Enhance node core comments

Refactor Basic Authenticator.
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: build: update npmignore to include some missed files (#67)
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[1:28:43 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 4 commits complete: minor release
[1:28:43 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:28:43 PM] [semantic-release] › ℹ  The next release version is 1.4.0
[1:28:43 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:28:43 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:28:43 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/changelog"
[1:28:43 PM] [semantic-release] [@semantic-release/changelog] › ℹ  Update /Users/mpeveler/work/github/node-sdk-core/CHANGELOG.md
[1:28:43 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/changelog"
[1:28:43 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/npm"
[1:28:43 PM] [semantic-release] [@semantic-release/npm] › ℹ  Write version 1.4.0 to package.json in /Users/mpeveler/work/github/node-sdk-core
v1.4.0

> [email protected] postversion /Users/mpeveler/work/github/node-sdk-core
> tsc-publish --no-checks --dry-run

> Running Command
> ExecCommand
>   npm run build

> [email protected] build /Users/mpeveler/work/github/node-sdk-core
> tsc

DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/.npmignore
   -> /Users/mpeveler/work/github/node-sdk-core/dist/.npmignore
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/AUTHENTICATION.md
   -> /Users/mpeveler/work/github/node-sdk-core/dist/AUTHENTICATION.md
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/CHANGELOG.md
   -> /Users/mpeveler/work/github/node-sdk-core/dist/CHANGELOG.md
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/LICENSE.md
   -> /Users/mpeveler/work/github/node-sdk-core/dist/LICENSE.md
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/MIGRATION-V1.md
   -> /Users/mpeveler/work/github/node-sdk-core/dist/MIGRATION-V1.md
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/README.md
   -> /Users/mpeveler/work/github/node-sdk-core/dist/README.md
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/test/utils/index.js
   -> /Users/mpeveler/work/github/node-sdk-core/dist/test/utils/index.js
DONE

> Running Command
> CopyCommand
   /Users/mpeveler/work/github/node-sdk-core/test/utils/unit-test-helpers.js
   -> /Users/mpeveler/work/github/node-sdk-core/dist/test/utils/unit-test-helpers.js
DONE

> Finished All Commands
> Copying and fixing package.json into ./dist
DONE

> Dry-run enabled, not running npm-publish
[1:28:51 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/npm"
[1:28:51 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/git"
[1:28:51 PM] [semantic-release] [@semantic-release/git] › ℹ  Found 3 file(s) to commit
[1:28:55 PM] [semantic-release] [@semantic-release/git] › ℹ  Prepared Git release: v1.4.0
[1:28:55 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/git"
[1:28:55 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:28:55 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:28:58 PM] [semantic-release] › ✔  Created tag v1.4.0
[1:28:58 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/npm"
[1:28:58 PM] [semantic-release] [@semantic-release/npm] › ℹ  Publishing version 1.4.0 to npm registry
npm notice
npm notice 📦  [email protected]
npm notice === Tarball Contents ===
npm notice 693B   auth/authenticators/authenticator-interface.js
npm notice 1.9kB  auth/authenticators/authenticator.js
npm notice 7.8kB  lib/base-service.js
npm notice 3.5kB  auth/authenticators/basic-authenticator.js
npm notice 3.6kB  auth/authenticators/bearer-token-authenticator.js
npm notice 3.5kB  auth/authenticators/cloud-pak-for-data-authenticator.js
npm notice 2.2kB  lib/content-type.js
npm notice 3.7kB  auth/token-managers/cp4d-token-manager.js
npm notice 3.2kB  auth/utils/get-authenticator-from-environment.js
npm notice 7.0kB  lib/helper.js
npm notice 3.3kB  auth/utils/helpers.js
npm notice 4.4kB  auth/authenticators/iam-authenticator.js
npm notice 6.0kB  auth/token-managers/iam-token-manager.js
npm notice 1.8kB  auth/authenticators/index.js
npm notice 898B   auth/index.js
npm notice 1.7kB  auth/token-managers/index.js
npm notice 1.4kB  auth/utils/index.js
npm notice 1.3kB  index.js
npm notice 1.0kB  test/utils/index.js
npm notice 6.7kB  auth/token-managers/jwt-token-manager.js
npm notice 815B   lib/logger.js
npm notice 2.0kB  auth/authenticators/no-auth-authenticator.js
npm notice 932B   lib/querystring.js
npm notice 201B   auth/utils/read-credentials-file.browser.js
npm notice 2.3kB  auth/utils/read-credentials-file.js
npm notice 3.9kB  auth/utils/read-external-sources.js
npm notice 15.0kB lib/request-wrapper.js
npm notice 949B   lib/stream-to-promise.js
npm notice 5.1kB  auth/authenticators/token-request-based-authenticator.js
npm notice 5.0kB  test/utils/unit-test-helpers.js
npm notice 2.2kB  package.json
npm notice 7.8kB  AUTHENTICATION.md
npm notice 9.0kB  CHANGELOG.md
npm notice 11.4kB LICENSE.md
npm notice 2.6kB  MIGRATION-V1.md
npm notice 3.7kB  README.md
npm notice 1.5kB  auth/authenticators/authenticator-interface.d.ts
npm notice 1.6kB  auth/authenticators/authenticator.d.ts
npm notice 5.3kB  lib/base-service.d.ts
npm notice 2.4kB  auth/authenticators/basic-authenticator.d.ts
npm notice 2.4kB  auth/authenticators/bearer-token-authenticator.d.ts
npm notice 2.6kB  auth/authenticators/cloud-pak-for-data-authenticator.d.ts
npm notice 270B   lib/content-type.d.ts
npm notice 2.4kB  auth/token-managers/cp4d-token-manager.d.ts
npm notice 1.1kB  auth/utils/get-authenticator-from-environment.d.ts
npm notice 3.2kB  lib/helper.d.ts
npm notice 1.7kB  auth/utils/helpers.d.ts
npm notice 3.4kB  auth/authenticators/iam-authenticator.d.ts
npm notice 3.0kB  auth/token-managers/iam-token-manager.d.ts
npm notice 2.3kB  auth/authenticators/index.d.ts
npm notice 709B   auth/index.d.ts
npm notice 1.4kB  auth/token-managers/index.d.ts
npm notice 1.1kB  auth/utils/index.d.ts
npm notice 954B   index.d.ts
npm notice 4.1kB  auth/token-managers/jwt-token-manager.d.ts
npm notice 134B   lib/logger.d.ts
npm notice 1.1kB  auth/authenticators/no-auth-authenticator.d.ts
npm notice 102B   lib/querystring.d.ts
npm notice 51B    auth/utils/read-credentials-file.browser.d.ts
npm notice 348B   auth/utils/read-credentials-file.d.ts
npm notice 1.1kB  auth/utils/read-external-sources.d.ts
npm notice 1.3kB  lib/request-wrapper.d.ts
npm notice 498B   lib/stream-to-promise.d.ts
npm notice 3.9kB  auth/authenticators/token-request-based-authenticator.d.ts
npm notice === Tarball Details ===
npm notice name:          masterodin-cloud-sdk-core
npm notice version:       1.4.0
npm notice package size:  40.7 kB
npm notice unpacked size: 188.3 kB
npm notice shasum:        4237bc9df9ba89e377a5b89dbb70fa2adfea10e0
npm notice integrity:     sha512-8PcidrBfS/Vjn[...]ATKCQGA1YMt8A==
npm notice total files:   64
npm notice
+ [email protected]
[1:29:06 PM] [semantic-release] [@semantic-release/npm] › ℹ  Published [email protected] on https://registry.npmjs.org/
[1:29:06 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/npm"
[1:29:06 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/github"
[1:29:06 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication
[1:29:08 PM] [semantic-release] [@semantic-release/github] › ℹ  Published GitHub release: https://github.com/MasterOdin/node-sdk-core/releases/tag/v1.4.0
[1:29:08 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/github"
[1:29:08 PM] [semantic-release] › ℹ  Start step "success" of plugin "@semantic-release/github"
[1:29:11 PM] [semantic-release] › ✔  Completed step "success" of plugin "@semantic-release/github"
[1:29:11 PM] [semantic-release] › ✔  Published release 1.4.0

to produce the masterodin-cloud-sdk-core package (which I will unpublish in ~70 hours) and then swapped out the ibm-cloud-sdk-core package with this one in node-sdk and successfully passed a npm run test there.

Checklist
  • npm test passes (tip: npm run lint-fix can correct most style issues)

@codecov
Copy link

codecov bot commented Nov 5, 2019

Codecov Report

Merging #69 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #69   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines           8      8           
  Branches        1      1           
=====================================
  Hits            8      8

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ec005d...35814c0. Read the comment docs.

@@ -92,7 +93,7 @@
"test-travis": "jest --runInBand test/unit/",
"report-coverage": "codecov",
"build": "tsc",
Copy link
Contributor

Choose a reason for hiding this comment

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

In the changes you made for the Watson Node SDK, you added the following step to the build script:
cp package.json dist/

Is there a reason you didn't do that here?

Copy link
Contributor Author

@MasterOdin MasterOdin Nov 5, 2019

Choose a reason for hiding this comment

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

Ah, sorry, I failed to explain why I made that change in that repo, apologies!

The Node SDK has a dependency on the existence of the package.json file in lib/common.ts and running the test suite without having package.json in place will cause some number of failures:
https://github.com/watson-developer-cloud/node-sdk/blob/7587c231f34c42dc2f8ec1567f177dd5a8832389/lib/common.ts#L4

This repo does not have that requirement (and will happily run without a package.json at all) so it's not necessary to copy it in, with the only requirement then is that the package.json has to be in-place for when semantic-release/npm runs its publish step, which is handled by tsc-publish in the postversion npm command.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, of course. That makes a lot of sense. Thanks!

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.

Looks good, thanks! 👍

@dpopp07 dpopp07 merged commit dbe1064 into IBM:master Nov 6, 2019
@ibm-devx-automation
Copy link

🎉 This PR is included in version 2.0.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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants