Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init(options) {
const { out, config, reporter } = this;
const { manifest } = config;
const repoUrl = manifest.repository &&
githubUrlFromGit(manifest.repository.url, {
extraBaseUrls: ['gitlab.com'],
});
if (!hasYarn() && options.yarn) {
throw new Error('Could not use Yarn without yarn.lock file');
}
const runTests = !options.yolo;
const runCleanup = options.cleanup && !options.yolo;
const runPublish = options.publish;
const pkgManager = options.yarn === true ? 'yarn' : 'npm';
const isOnGitHub = repoUrl && hostedGitInfo.fromUrl(repoUrl).type === 'github';
const steps = [];
steps.push(async (curr, total) => {
this.reporter.step(curr, total, 'Prerequisite checks', '✨');
runPublish && (await prerequisiteTasks(manifest, options));
// title: 'Check current branch',
const { stdout: branch } = await execa('git', ['symbolic-ref', '--short', 'HEAD']);
if (branch !== 'master' && !options.anyBranch) {
throw new Error('Not on `master` branch. Use --any-branch to publish anyway.');
}
export async function run(config, reporter, flags, args) {
await config.loadPackageManifest();
const options = args.length > 0
? Object.assign({ cleanup: true }, flags, { yarn: hasYarn(), version: args[0] }) : await ui(Object.assign({}, flags, { yarn: hasYarn() }), config.manifest);
if (!options.confirm) {
return;
}
const publish = new Publish(flags, config, reporter);
await publish.init(options);
const newManifest = await config.loadPackageManifest();
console.log(chalk.bold(`\n🎉 ${newManifest.name} v${newManifest.version} published!`));
console.log(`You can see it at: ${chalk.underline(`https://unpkg.com/${newManifest.name}@${newManifest.version}/`)}`);
}
import hasYarn from "has-yarn";
export default {
anyBranch: false,
noYarn: !hasYarn (),
noPublish: false,
noCleanup: false,
skipInstall: false,
hook: null,
directory: "dist",
branch: "gh-pages"
};