mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[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:
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -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
|
||||
|
||||
12
utils/publish-legacy.sh
vendored
12
utils/publish-legacy.sh
vendored
@@ -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
|
||||
|
||||
9
utils/update-legacy-name.js
vendored
9
utils/update-legacy-name.js
vendored
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user