[tests] Deprecate "now" npm package in favor of "vercel" (#5119)

We deprecated all the `now` scoped packages in favor of the `vercel` equivalents, however the deprecation message disappears after each publish, so we must to run `npm deprecate` after `npm publish` for legacy packages.
This commit is contained in:
Steven
2020-08-28 15:39:06 -04:00
committed by GitHub
parent be24510f16
commit 57a17eb416
3 changed files with 18 additions and 5 deletions

View File

@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 12
- name: Install
run: yarn install --check-files --frozen-lockfile
- name: Build

View File

@@ -14,7 +14,15 @@ commit="$(git log --format="%H" -n 1)"
tags="$(git show-ref --tags -d | grep ^"$commit" | sed -e 's,.* refs/tags/,,' -e 's/\^{}//')"
for tag in $tags; do
package_dir="$(node "${__dirname}/update-legacy-name.js" "$tag")"
str="$(node "${__dirname}/update-legacy-name.js" "$tag")"
IFS='|' # set delimiter
read -ra ADDR <<< "$str" # str is read into an array as tokens separated by IFS
package_dir="${ADDR[0]}"
old_name="${ADDR[1]}"
new_name="${ADDR[2]}"
version="${ADDR[3]}"
IFS=' ' # reset to default after usage
cd "${__dirname}/../packages/${package_dir}"
@@ -25,4 +33,6 @@ for tag in $tags; do
echo "Running \`npm publish $npm_tag\` in \"$(pwd)\""
npm publish $npm_tag
echo "Running \`npm deprecate $old_name@$version\` in favor of $new_name"
npm deprecate "$old_name@$version" "\"$old_name\" is deprecated and will stop receiving updates on December 31, 2020. Please use \"$new_name\" instead."
done

View File

@@ -29,7 +29,8 @@ if (!packageDir) {
const pkgJsonPath = join(packagesDir, packageDir, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
const originalName = pkg.name;
const oldName = pkg.name;
const version = pkg.version;
if (pkg.name === '@vercel/client') {
// The legacy name for `@vercel/client` is `now-client` (global scope)
@@ -42,10 +43,12 @@ if (pkg.name === '@vercel/client') {
}
}
console.error(`Updated package name: "${originalName}" -> "${pkg.name}"`);
const newName = pkg.name;
console.error(`Updated package name: "${oldName}" -> "${newName}"`);
fs.writeFileSync(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
// Log the directory name to stdout for the `publish-legacy.sh`
// script to consume for the `npm publish` that happens next.
console.log(packageDir);
const IFS = '|';
console.log([packageDir, oldName, newName, version].join(IFS));