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

fix: run oclif lock during prepack #212

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions bin/sf-prepack.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,38 @@ const packageRoot = require('../utils/package-path');

shell.exec('yarn build');

const semverIsLessThan = (version, target) => {
const [major, minor, patch] = version.split('.').map((v) => parseInt(v, 10));
const [targetMajor, targetMinor, targetPatch] = target.split('.').map((v) => parseInt(v, 10));
if (major < targetMajor) {
return true;
}
if (major === targetMajor && minor < targetMinor) {
return true;
}
if (major === targetMajor && minor === targetMinor && patch < targetPatch) {
return true;
}
return false;
};

if (isPlugin(packageRoot)) {
if (shell.which('oclif')) {
shell.exec('oclif manifest .');
const version = shell.exec('oclif --version', { silent: true }).stdout.trim().replace('oclif/', '').split(' ')[0];
if (semverIsLessThan(version, '3.14.0')) {
// eslint-disable-next-line no-console
console.log(
chalk.yellow('Warning:'),
// eslint-disable-next-line max-len
`oclif version ${version} is less than 3.14.0. Please upgrade to 3.14.0 or higher to use generate oclif.lock file.`
);
} else {
shell.exec('oclif lock');
}
} else if (shell.which('oclif-dev')) {
// eslint-disable-next-line no-console
console.log(chalk.yellow('Warning:'), 'oclif-dev is deprecated. Please use oclif instead.');
shell.exec('oclif-dev manifest');
} else {
// eslint-disable-next-line no-console
Expand Down
2 changes: 1 addition & 1 deletion utils/shelljs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ shell.exec = function (command, ...args) {
// eslint-disable-next-line no-console
console.error(chalk.blue(command));
try {
origExec.call(shell, command, ...args);
return origExec.call(shell, command, ...args);
} catch (err) {
// Setting -e will throw an error. We are already displaying the command
// output above which has information on the problem, so don't show the
Expand Down