Skip to content
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

Add prepublishOnly script to test changed package names exist on npm #964

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Nov 5, 2024

Issue

Fixes: #950

Description

Add prepublish script to test changed package names exist on npm

Testing

CI

Verified that changed package names from #962 are tested

$ npm run prepublishOnly

> aws-sdk-js-codemod@2.4.2 prepublish
> tsx scripts/testChangedPackageNames

Changed package names: client-sagemaker-a2i-runtime, client-eks-auth
@aws-sdk/client-sagemaker-a2i-runtime exists
@aws-sdk/client-eks-auth exists

Verified that script fails if the package doesn't exist on npm

$ git diff | head
diff --git a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
index 2b7d087..bdf20bf 100644
--- a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
+++ b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
@@ -5,7 +5,7 @@ export const CLIENT_PACKAGE_NAMES_MAP: Record<string, string> = {
   ...CLIENT_NAMES.reduce((acc: Record<string, string>, name) => {
     acc[name] = `client-${name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}`
       .replace("-chime-sdk", "-chime-sdk-")
-      .replace("client-amplify-", "client-amplify")
+      .replace("client-amplify-", "client-amplify2")

$ npm run prepublishOnly

> aws-sdk-js-codemod@2.4.2 prepublishOnly
> tsx scripts/testChangedPackageNames

Changed package names: client-amplify2backend, client-amplify2uibuilder, client-sagemaker-a2i-runtime, client-eks-auth
node:internal/errors:984
  const err = new Error(message);
              ^

Error: Command failed: npm show @aws-sdk/client-amplify2backend version
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@aws-sdk%2fclient-amplify2backend - Not found
npm error 404
npm error 404  '@aws-sdk/client-amplify2backend@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: /Users/trivikram/.npm/_logs/2024-11-05T04_30_58_518Z-debug-0.log

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'npm show @aws-sdk/client-amplify2backend version',
  stdout: '',
  stderr: 'npm error code E404\n' +
    'npm error 404 Not Found - GET https://registry.npmjs.org/@aws-sdk%2fclient-amplify2backend - Not found\n' +
    'npm error 404\n' +
    "npm error 404  '@aws-sdk/client-amplify2backend@*' is not in this registry.\n" +
    'npm error 404\n' +
    'npm error 404 Note that you can also install from a\n' +
    'npm error 404 tarball, folder, http url, or git url.\n' +
    'npm error A complete log of this run can be found in: /Users/trivikram/.npm/_logs/2024-11-05T04_30_58_518Z-debug-0.log\n'
}

Node.js v20.18.0

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 5, 2024

⚠️ No Changeset found

Latest commit: be7b461

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@trivikr trivikr force-pushed the test-changed-package-names branch 2 times, most recently from f7520f3 to eeeb857 Compare November 5, 2024 04:22
@trivikr trivikr force-pushed the test-changed-package-names branch from eeeb857 to be7b461 Compare November 5, 2024 04:24
@trivikr trivikr marked this pull request as ready for review November 5, 2024 04:31
@trivikr trivikr requested a review from a team as a code owner November 5, 2024 04:31
@trivikr trivikr changed the title Add prepublish script to test changed package names exist on npm Add prepublishOnly script to test changed package names exist on npm Nov 5, 2024
@trivikr trivikr merged commit b2aeadc into main Nov 5, 2024
7 checks passed
@trivikr trivikr deleted the test-changed-package-names branch November 5, 2024 04:32
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Add a test doing checks with npm for verifying the presence of package.
1 participant