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

chore: allow un-overwritable scripts and devDependencies in package.json #1207

Merged
merged 2 commits into from May 28, 2020

Conversation

AllanZhengYP
Copy link
Contributor

There are 2 changes with this PR:

  1. If a client's package.json contains a local NPM scripts or devDependencies, they would be removed by codegen because these new entries don't exist package.json's template. This change avoids removing these entries.
    What is not changed: for the entries in scripts or devDependencies and exist in both newly generated client and existing client, the script prefers the ones in existing client.

  2. Temporarily pin the newly added internal dependencies version. We will review this before GA.(maybe re-introduce the range dependencies)

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

And pin the version of internal dependencies "@aws-sdk/*"
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 79845b7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

scripts/generate-clients/copy-to-clients.js Outdated Show resolved Hide resolved
Comment on lines +75 to +86
const pinDependencies = manifest => {
const removeRangeVersion = ([name, version]) =>
name.indexOf("@aws-sdk/") === 0
? [name, version.replace("^", "")]
: [name, version];
manifest.dependencies = Object.fromEntries(
Object.entries(manifest.dependencies).map(removeRangeVersion)
);
manifest.devDependencies = Object.fromEntries(
Object.entries(manifest.devDependencies).map(removeRangeVersion)
);
};
Copy link
Member

Choose a reason for hiding this comment

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

Optional: use functions all the way to avoid mutating manifest and having small functions

const filterAwsSdkDeps = (name) => name.indexOf("@aws-sdk/") === 0;
const removeCaretFromDepVersion = (version) => version.replace("^", "");

const getPinnedAwsSdkDeps = (deps) => ({
  ...deps,
  ...Object.entries(deps)
    .filter(([name, version]) => filterAwsSdkDeps(name))
    .reduce(
      (acc, [name, version]) => ({
        ...acc,
        [name]: removeCaretFromDepVersion(version),
      }),
      {}
    ),
});

const getManifestWithPinnedAwsSdkDeps = (manifest) => ({
  ...manifest,
  dependencies: getPinnedAwsSdkDeps(manifest.dependencies),
  devDependencies: getPinnedAwsSdkDeps(manifest.devDependencies),
});

Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 290a545
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@trivikr
Copy link
Member

trivikr commented May 28, 2020

Merging to unblock #1218

@trivikr trivikr changed the title chore: allow un-overwritable scripts and dev dependencies in package.json chore: allow un-overwritable scripts and devDependencies in package.json May 28, 2020
@trivikr trivikr merged commit 22c9c7b into aws:master May 28, 2020
@github-actions
Copy link

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 Jan 20, 2021
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.

None yet

3 participants