Skip to content

Commit

Permalink
[cli] Revert replace update-notifier dependency with built in (#9000)
Browse files Browse the repository at this point in the history
  • Loading branch information
leerob committed Dec 3, 2022
1 parent b37ac5f commit 2e0cbf1
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 518 deletions.
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"@vercel/redwood": "1.0.39",
"@vercel/remix": "1.1.1",
"@vercel/ruby": "1.3.45",
"@vercel/static-build": "1.0.42"
"@vercel/static-build": "1.0.42",
"update-notifier": "5.1.0"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
Expand Down
22 changes: 9 additions & 13 deletions packages/cli/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cpy from 'cpy';
import execa from 'execa';
import { join } from 'path';
import { remove, readJSON, writeFile } from 'fs-extra';
import { remove, writeFile } from 'fs-extra';

const dirRoot = join(__dirname, '..');
const distRoot = join(dirRoot, 'dist');
Expand Down Expand Up @@ -43,15 +43,15 @@ async function main() {
stdio: 'inherit',
});

const pkg = await readJSON(join(dirRoot, 'package.json'));
const dependencies = Object.keys(pkg?.dependencies ?? {});
// Do the initial `ncc` build
console.log('Dependencies:', dependencies);
const externs = [];
for (const dep of dependencies) {
externs.push('--external', dep);
}
const args = ['ncc', 'build', 'src/index.ts', ...externs];
console.log();
const args = [
'ncc',
'build',
'--external',
'update-notifier',
'src/index.ts',
];
await execa('yarn', args, { stdio: 'inherit', cwd: dirRoot });

// `ncc` has some issues with `@vercel/fun`'s runtime files:
Expand All @@ -78,10 +78,6 @@ async function main() {
// Band-aid to bundle stuff that `ncc` neglects to bundle
await cpy(join(dirRoot, 'src/util/projects/VERCEL_DIR_README.txt'), distRoot);
await cpy(join(dirRoot, 'src/util/dev/builder-worker.js'), distRoot);
await cpy(
join(dirRoot, 'src/util/get-latest-version/get-latest-worker.js'),
distRoot
);

console.log('Finished building Vercel CLI');
}
Expand Down
47 changes: 23 additions & 24 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import sourceMap from '@zeit/source-map-support';
import { mkdirp } from 'fs-extra';
import chalk from 'chalk';
import epipebomb from 'epipebomb';
import getLatestVersion from './util/get-latest-version';
import updateNotifier from 'update-notifier';
import { URL } from 'url';
import * as Sentry from '@sentry/node';
import hp from './util/humanize-path';
Expand Down Expand Up @@ -55,6 +55,13 @@ import { VercelConfig } from '@vercel/client';

const isCanary = pkg.version.includes('canary');

// Checks for available update and returns an instance
const notifier = updateNotifier({
pkg,
distTag: isCanary ? 'canary' : 'latest',
updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week
});

const VERCEL_DIR = getGlobalPathConfig();
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
const VERCEL_AUTH_CONFIG_PATH = configFiles.getAuthConfigFilePath();
Expand Down Expand Up @@ -142,30 +149,22 @@ const main = async () => {
}

// Print update information, if available
if (isTTY && !process.env.NO_UPDATE_NOTIFIER) {
// Check if an update is available. If so, `latest` will contain a string
// of the latest version, otherwise `undefined`.
const latest = getLatestVersion({
distTag: isCanary ? 'canary' : 'latest',
output,
pkg,
});
if (latest) {
console.log(
info(
`${chalk.black.bgCyan('UPDATE AVAILABLE')} ` +
`Run ${cmd(
await getUpdateCommand()
)} to install ${getTitleName()} CLI ${latest}`
)
);
if (notifier.update && notifier.update.latest !== pkg.version && isTTY) {
const { latest } = notifier.update;
console.log(
info(
`${chalk.black.bgCyan('UPDATE AVAILABLE')} ` +
`Run ${cmd(
await getUpdateCommand()
)} to install ${getTitleName()} CLI ${latest}`
)
);

console.log(
`${info(
`Changelog: https://github.com/vercel/vercel/releases/tag/vercel@${latest}`
)}\n`
);
}
console.log(
info(
`Changelog: https://github.com/vercel/vercel/releases/tag/vercel@${latest}`
)
);
}

// The second argument to the command can be:
Expand Down
186 changes: 0 additions & 186 deletions packages/cli/src/util/get-latest-version/get-latest-worker.js

This file was deleted.

0 comments on commit 2e0cbf1

Please sign in to comment.